man m17nDraw () - Drawing M-texts on a window.

NAME

Drawing - Drawing M-texts on a window.

Data Structures

struct MDrawControl

Type of a text drawing control. struct MDrawMetric

Type of metric for gylphs and texts. struct MDrawGlyphInfo

Type of information about a glyph. struct MDrawGlyph

Type of information about a glyph metric and font.

Typedefs

typedef void * MDrawWindow

Window system dependent type for a window. typedef void * MDrawRegion

Window system dependent type for a region.

Functions

int mdraw_text (MFrame *frame, MDrawWindow win, int x, int y, MText *mt, int from, int to)

Draw an M-text on a window. int mdraw_image_text (MFrame *frame, MDrawWindow win, int x, int y, MText *mt, int from, int to)

Draw an M-text on a window as an image. int mdraw_text_with_control (MFrame *frame, MDrawWindow win, int x, int y, MText *mt, int from, int to, MDrawControl *control)

Draw an M-text on a window with fine control. int mdraw_text_extents (MFrame *frame, MText *mt, int from, int to, MDrawControl *control, MDrawMetric *overall_ink_return, MDrawMetric *overall_logical_return, MDrawMetric *overall_line_return)

Compute text pixel width. int mdraw_text_per_char_extents (MFrame *frame, MText *mt, int from, int to, MDrawControl *control, MDrawMetric *ink_array_return, MDrawMetric *logical_array_return, int array_size, int *num_chars_return, MDrawMetric *overall_ink_return, MDrawMetric *overall_logical_return)

Compute the text dimensions of each character of M-text. int mdraw_coordinates_position (MFrame *frame, MText *mt, int from, int to, int x_offset, int y_offset, MDrawControl *control)

Return the character position nearest to the coordinates. int mdraw_glyph_info (MFrame *frame, MText *mt, int from, int pos, MDrawControl *control, MDrawGlyphInfo *info)

Compute information about a glyph. int mdraw_glyph_list (MFrame *frame, MText *mt, int from, int to, MDrawControl *control, MDrawGlyph *glyphs, int array_size, int *num_glyphs_return)

Compute information about glyph sequence. void mdraw_text_items (MFrame *frame, MDrawWindow win, int x, int y, MDrawTextItem *items, int nitems)

Draw one or more textitems. int mdraw_default_line_break (MText *mt, int pos, int from, int to, int line, int y)

calculate a line breaking position. void mdraw_per_char_extents (MFrame *frame, MText *mt, MDrawMetric *array_return, MDrawMetric *overall_return)

Obtain per character dimension information. void mdraw_clear_cache (MText *mt)

clear cached information.

Detailed Description

The m17n GUI API provides functions to draw M-texts.

The fonts used for drawing are selected automatically based on the fontset and the properties of a face. A face also specifies the appearance of M-texts, i.e. font size, color, underline, etc.

The drawing format of M-texts can be controlled in a variety of ways, which provides powerful 2-dimensional layouting facility.

Data Structure Documentation

MDrawControl

Type of a text drawing control.

FIELD DOCUMENTATION:

unsigned MDrawControl::as_image

If nonzero, draw an M-text as image, i.e. with background filled with background colors of faces put on the M-text. Otherwise, the background is not changed.

unsigned MDrawControl::align_head

If nonzero and the first glyph of each line has negative lbearing, shift glyphs horizontally to right so that no pixel is drawn to the left of the specified position.

unsigned MDrawControl::two_dimensional

If nonzero, draw an M-text two-dimensionally, i.e., newlines in M-text breaks lines and the following characters are drawn in the next line. If <format> is non-NULL, and the function returns nonzero line width, a line longer than that width is also broken.

unsigned MDrawControl::orientation_reversed

If nonzero, draw an M-text to the right of a specified position.

unsigned MDrawControl::enable_bidi

If nonzero, reorder glyphs correctly for bidi text.

unsigned MDrawControl::ignore_formatting_char

If nonzero, don't draw characters whose general category (in Unicode) is Cf (Other, format).

unsigned MDrawControl::fixed_width

If nonzero, draw glyphs suitable for a terminal. Not yet implemented.

unsigned MDrawControl::anti_alias

If nonzero, draw glyphs with anti-aliasing if a backend font driver supports it.

unsigned MDrawControl::disable_overlapping_adjustment

If nonzero, disable the adjustment of glyph positions to avoid horizontal overlapping at font boundary.

unsigned int MDrawControl::min_line_ascent

If nonzero, the values are minimum line ascent and descent pixels.

unsigned int MDrawControl::min_line_descent

unsigned int MDrawControl::max_line_ascent

If nonzero, the values are maximum line ascent and descent pixels.

unsigned int MDrawControl::max_line_descent

unsigned int MDrawControl::max_line_width

If nonzero, the value specifies how many pixels each line can occupy on the display. The value zero means that there is no limit. It is ignored if <format> is non-NULL.

unsigned int MDrawControl::tab_width

If nonzero, the value specifies the distance between tab stops in columns (the width of one column is the width of a space in the default font of the frame). The value zero means 8.

void(* MDrawControl::format)(int line, int y, int *indent, int *width)

If non-NULL, the value is a function that calculates the indentation and width limit of each line based on the line number LINE and the coordinate Y. The function store the indentation and width limit at the place pointed by INDENT and WIDTH respectively.

The indentation specifies how many pixels the first glyph of each line is shifted to the right (if the member <orientation_reversed> is zero) or to the left (otherwise). If the value is negative, each line is shifted to the reverse direction.

The width limit specifies how many pixels each line can occupy on the display. The value 0 means that there is no limit.

LINE and Y are reset to 0 when a line is broken by a newline character, and incremented each time when a long line is broken because of the width limit.

This has an effect only when <two_dimensional> is nonzero.

int(* MDrawControl::line_break)(MText *mt, int pos, int from, int to, int line, int y)

If non-NULL, the value is a function that calculates a line breaking position when a line is too long to fit within the width limit. POS is the position of the character next to the last one that fits within the limit. FROM is the position of the first character of the line, and TO is the position of the last character displayed on the line if there were not width limit. LINE and Y are the same as the arguments to <format>.

The function must return a character position to break the line.

The function should not modify MT.

The mdraw_default_line_break() function is useful for such a script that uses SPACE as a word separator.

int MDrawControl::with_cursor

int MDrawControl::cursor_pos

Specifies the character position to display a cursor. If it is greater than the maximum character position, the cursor is displayed next to the last character of an M-text. If the value is negative, even if <cursor_width> is nonzero, cursor is not displayed.

int MDrawControl::cursor_width

If nonzero, display a cursor at the character position <cursor_pos>. If the value is positive, it is the pixel width of the cursor. If the value is negative, the cursor width is the same as the underlining glyph(s).

int MDrawControl::cursor_bidi

If nonzero and <cursor_width> is also nonzero, display double bar cursors; at the character position <cursor_pos> and at the logically previous character. Both cursors have one pixel width with horizontal fringes at upper or lower positions.

int MDrawControl::partial_update

If nonzero, on drawing partial text, pixels of surrounding texts that intrude into the drawing area are also drawn. For instance, some CVC sequence of Thai text (C is consonant, V is upper vowel) is drawn so that V is placed over the middle of two Cs. If this CVC sequence is already drawn and only the last C is drawn again (for instance by updating cursor position), the right half of V is erased if this member is zero. By setting this member to nonzero, even with such a drawing, we can keep this CVC sequence correctly displayed.

int MDrawControl::disable_caching

If nonzero, don't cache the result of any drawing information of an M-text.

MDrawRegion MDrawControl::clip_region

MDrawMetric

Type of metric for gylphs and texts.

FIELD DOCUMENTATION:

int MDrawMetric::x

int MDrawMetric::y

unsigned int MDrawMetric::width

unsigned int MDrawMetric::height

MDrawGlyphInfo

Type of information about a glyph.

FIELD DOCUMENTATION:

int MDrawGlyphInfo::from

Character range corresponding to the glyph.

int MDrawGlyphInfo::to

Character range corresponding to the glyph.

int MDrawGlyphInfo::line_from

Character ranges corresponding to the line of the glyph.

int MDrawGlyphInfo::line_to

Character ranges corresponding to the line of the glyph.

int MDrawGlyphInfo::x

X/Y coordinates of the glyph.

int MDrawGlyphInfo::y

X/Y coordinates of the glyph.

MDrawMetric MDrawGlyphInfo::metrics

Metric of the glyph.

MFont* MDrawGlyphInfo::font

Font used for the glyph. Set to NULL if no font is found for the glyph.

int MDrawGlyphInfo::prev_from

Character ranges corresponding to logically previous and next glyphs. Note that we do not need the members prev_to and next_from because they must be the same as the members from and to respectively.

int MDrawGlyphInfo::next_to

Character ranges corresponding to logically previous and next glyphs. Note that we do not need the members prev_to and next_from because they must be the same as the members from and to respectively.

int MDrawGlyphInfo::left_from

Character ranges corresponding to visually left and right glyphs.

int MDrawGlyphInfo::left_to

Character ranges corresponding to visually left and right glyphs.

int MDrawGlyphInfo::right_from

int MDrawGlyphInfo::right_to

int MDrawGlyphInfo::logical_width

Logical width of the glyph. Nominal distance to the next glyph.

MDrawGlyph

Type of information about a glyph metric and font.

FIELD DOCUMENTATION:

int MDrawGlyph::from

Character range corresponding to the glyph.

int MDrawGlyph::to

Character range corresponding to the glyph.

int MDrawGlyph::glyph_code

Font glyph code of the glyph.

int MDrawGlyph::x_advance

Logical width of the glyph. Nominal distance to the next glyph.

int MDrawGlyph::y_advance

Logical width of the glyph. Nominal distance to the next glyph.

int MDrawGlyph::x_off

X/Y offset relative to the glyph position.

int MDrawGlyph::y_off

X/Y offset relative to the glyph position.

int MDrawGlyph::lbearing

Metric of the glyph.

int MDrawGlyph::rbearing

Metric of the glyph.

int MDrawGlyph::ascent

Metric of the glyph.

int MDrawGlyph::descent

Metric of the glyph.

MFont* MDrawGlyph::font

Font used for the glyph. Set to NULL if no font is found for the glyph.

MSymbol MDrawGlyph::font_type

Type of the font. One of Mx, Mfreetype, Mxft.

void* MDrawGlyph::fontp

Pointer to the font structure. The actual type is (XFontStruct *) if <font_type> member is Mx, FT_Face if <font_type> member is Mfreetype, and (XftFont *) if <font_type> member is Mxft.

Typedef Documentation

typedef void* MDrawWindow

The type MDrawWindow is for a window; a rectangular area that works in several ways like a miniature screen.

What it actually points depends on a window system. A program that uses the m17n-X library must coerce the type Drawable to this type.

typedef void* MDrawRegion

The type MDrawRegion is for a region; an arbitrary set of pixels on the screen (typically a rectangular area).

What it actually points depends on a window system. A program that uses the m17n-X library must coerce the type Region to this type.