---
name: "m17nDraw"
section: "3m17n"
platform: "linux"
package: "m17n-docs"
version: "1.8.4-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/m17nDraw"
---

# m17nDraw(3m17n)

\- Drawing M-texts on a window.

## NAME

m17nDraw\_-\_Dra -  - Drawing M-texts on a window.

## SYNOPSIS

### Data Structures

struct **MDrawControl**\
 Type of a text drawing control.  struct **MDrawMetric**\
 Type of metric for glyphs 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. \
\
  "

### Variables

int **mdraw\_line\_break\_option**\
 Option of line breaking for drawing text.

## Detailed Description

Drawing M-texts on a window.

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 layout 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 pixels.

**unsigned int MDrawControl::min\_line\_descent** If nonzero, the values are minimum line descent pixels.

**unsigned int MDrawControl::max\_line\_ascent** If nonzero, the values are maximum line ascent pixels.

**unsigned int MDrawControl::max\_line\_descent** If nonzero, the values are maximum line descent pixels.

**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** **If nonzero, show the cursor according to \<cursor\_width\>.**

**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** **If non-NULL, limit the drawing effect to the specified region.**

### MDrawMetric

**Type of metric for glyphs and texts.**

**FIELD DOCUMENTATION:**

**int MDrawMetric::x** **X coordinates of a glyph or a text.**

**int MDrawMetric::y** **Y coordinates of a glyph or a text.**

**unsigned int MDrawMetric::width** **Pixel width of a glyph or a text.**

**unsigned int MDrawMetric::height** **Pixel height of a glyph or a text.**

### MDrawGlyphInfo

**Type of information about a glyph.**

**FIELD DOCUMENTATION:**

**int MDrawGlyphInfo::from** **Start position of character range corresponding to the glyph.**

**int MDrawGlyphInfo::to** **End position of character range corresponding to the glyph.**

**int MDrawGlyphInfo::line\_from** **Start position of character range corresponding to the line of the glyph.**

**int MDrawGlyphInfo::line\_to** **End position of character range corresponding to the line of the glyph.**

**int MDrawGlyphInfo::x** **X coordinates of the glyph.**

**int MDrawGlyphInfo::y** **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 glyphs. Note that we do not need the members prev\_to because it must be the same as the member \<from\>.** \

**int MDrawGlyphInfo::next\_to** **Character ranges corresponding to logically next glyphs. Note that we do not need the members next\_from because it must be the same as the member \<to\> respectively.** \

**int MDrawGlyphInfo::left\_from** **Start position of character ranges corresponding to visually left glyphs.** \

**int MDrawGlyphInfo::left\_to** **End position of character ranges corresponding to visually left glyphs.** \

**int MDrawGlyphInfo::right\_from** **Start position of character ranges corresponding to visually right glyphs.** \

**int MDrawGlyphInfo::right\_to** **End position of character ranges corresponding to visually left glyphs.** \

**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**

**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 height of the glyph. Nominal distance to the next glyph.** \

**int MDrawGlyph::x\_off** **X offset relative to the glyph position.**

**int MDrawGlyph::y\_off** **Y offset relative to the glyph position.**

**int MDrawGlyph::lbearing** **Metric of the glyph (left-bearing).**

**int MDrawGlyph::rbearing** **Metric of the glyph (right-bearing).**

**int MDrawGlyph::ascent** **Metric of the glyph (ascent).**

**int MDrawGlyph::descent** **Metric of the glyph (descent).**

**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

**Window system dependent type for a window. 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

**Window system dependent type for a region. 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.** \

## Variable Documentation

### int mdraw\_line\_break\_option

**Option of line breaking for drawing text. The variable mdraw\_line\_break\_option specifies line breaking options by logical-or of the members of MTextLineBreakOption. It controls the line breaking algorithm of the function mdraw\_default\_line\_break().** \

## Author

**Generated automatically by Doxygen for The m17n Library from the source code.**

## COPYRIGHT

**Copyright (C) 2001 Information-technology Promotion Agency (IPA)**\
 **Copyright (C) 2001-2011 National Institute of Advanced Industrial Science and Technology (AIST)**\
 **Permission is granted to copy, distribute and/or modify this document** **under the terms of the GNU Free Documentation License**  **\<http://www.gnu.org/licenses/fdl.html\>.**
