MiniGUI API Reference (MiniGUI-Standalone)
v5.0.6
A mature and proven cross-platform GUI system for embedded and smart IoT devices
|
To lay out, shape, and render a text in mixed scripts, you should call GetUCharsUntilParagraphBoundary function first to convert a multi-byte string to a Unicode string under the specified white space rule, breaking rule, and transformation rule. For example, converting a general C string in UTF-8 or GB18030 to a Uchar32 string by calling this function. You can call CreateLogFontForMChar2UChar function to create a dummy logfont object for this purpose in order to expense a minimal memory. More...
Modules | |
White Space Rules | |
The white space rule indicates GetUCharsUntilParagraphBoundary. | |
Glyph Rendering Flags | |
The glyph rendering flags indicate GetGlyphsExtentFromUChars and CreateLayout how to lay out the text: | |
Data Structures | |
struct | _GLYPHEXTINFO |
struct | _GLYPHPOS |
Macros | |
#define | GLYPHBMP_TYPE_MONO 0x00 |
#define | GLYPHBMP_TYPE_GREY 0x01 |
#define | GLYPHBMP_TYPE_GREY4b 0x02 |
#define | GLYPHBMP_TYPE_SUBPIXEL 0x03 |
#define | GLYPHBMP_TYPE_PRERENDER 0x04 |
#define | UCHAR2ACHAR(uc) ((uc) | 0x80000000) |
The macro to convert a Uchar32 value to Achar32 value. More... | |
Typedefs | |
typedef struct _ACHARMAPINFO | ACHARMAPINFO |
Data type of struct _ACHARMAPINFO. More... | |
typedef struct _GLYPHINFO | GLYPHINFO |
Data type of struct _GLYPHINFO. More... | |
typedef struct _GLYPHEXTINFO | GLYPHEXTINFO |
typedef struct _GLYPHPOS | GLYPHPOS |
typedef struct _TEXTRUNS | TEXTRUNS |
typedef struct _LAYOUT | LAYOUT |
typedef struct _LAYOUTLINE | LAYOUTLINE |
typedef int | BOOL |
A type definition for boolean value. More... | |
Enumerations | |
enum | ACHARSHAPETYPE |
Achar32 shape type. More... | |
Functions | |
MG_EXPORT Achar32 GUIAPI | GetACharValue (LOGFONT *logfont, const char *mchar, int mchar_len, const char *pre_mchar, int pre_len) |
Get the character value of a multi-byte character. More... | |
MG_EXPORT int GUIAPI | GetNextUChar (LOGFONT *logfont, const char *mchar, int mchar_len, Uchar32 *uc) |
Get the Uchar32 value (Unicode code point) of a multi-byte character in specified LOGFONT object. More... | |
MG_EXPORT Uint32 GUIAPI | GetACharType (LOGFONT *logfont, Achar32 chv) |
Retrieve the basic type, the general cateory of Unicode, and the break class of Unicode of an abstract character. More... | |
MG_EXPORT Achar32 GUIAPI | GetShapedAChar (LOGFONT *logfont, const char *mchar, int mchar_len, ACHARSHAPETYPE shape_type) |
Get the glyph shape of a character. More... | |
MG_EXPORT BOOL GUIAPI | GetMirrorAChar (LOGFONT *logfont, Achar32 chv, Achar32 *mirrored) |
Get the mirrored abstract character if possible. More... | |
MG_EXPORT BidiType GUIAPI | GetACharBidiType (LOGFONT *log_font, Achar32 chv) |
Retrieve the BIDI type of an abstract character. More... | |
MG_EXPORT int GUIAPI | BIDIGetTextLogicalAChars (LOGFONT *log_font, const char *text, int text_len, Achar32 **achars, ACHARMAPINFO **achars_map) |
Get logical achars string of the text. More... | |
MG_EXPORT void GUIAPI | BIDIGetTextRangesLog2Vis (LOGFONT *log_font, const char *text, int text_len, int start_index, int end_index, int **ranges, int *nr_ranges) |
Get a list of visual ranges corresponding to a given logical range. More... | |
MG_EXPORT int GUIAPI | BIDIGetTextVisualAChars (LOGFONT *log_font, const char *text, int text_len, Achar32 **achars, ACHARMAPINFO **achars_map) |
Get visual achars and glyph_map info relative with logical string byte index. More... | |
MG_EXPORT BOOL GUIAPI | BIDILogAChars2VisACharsEx (LOGFONT *log_font, Achar32 *achars, int nr_achars, int pel, void *extra, CB_REVERSE_ARRAY cb_reverse_extra) |
Reorder the specified logical glyph string in visual order and reorder an extra array to reflect the visule order of the achars. More... | |
MG_EXPORT Achar32 *GUIAPI | BIDILogAChars2VisAChars (LOGFONT *log_font, Achar32 *achars, int nr_achars, ACHARMAPINFO *achars_map) |
Reorder the specified logical glyph string in visual order and reorder glyph map if specified. More... | |
MG_EXPORT int GUIAPI | GetACharsExtent (HDC hdc, Achar32 *achars, int nr_achars, SIZE *size) |
Get visual extent value of an achar string. More... | |
MG_EXPORT int GUIAPI | GetACharsExtentPoint (HDC hdc, Achar32 *achars, int nr_achars, int max_extent, SIZE *size) |
Get the visual extent value of an achar string. More... | |
MG_EXPORT Glyph32 GUIAPI | GetGlyphValue (LOGFONT *logfont, const char *mchar, int mchar_len, const char *pre_mchar, int pre_len) |
Get the glyph value of a multi-byte character. More... | |
MG_EXPORT Glyph32 GUIAPI | GetGlyphValueAlt (LOGFONT *logfont, Achar32 chv) |
Get the LOGFONT glyph value of an abstract character. More... | |
MG_EXPORT int GUIAPI | DrawGlyph (HDC hdc, int x, int y, Glyph32 glyph_value, int *adv_x, int *adv_y) |
Draw a glyph. More... | |
MG_EXPORT int GUIAPI | GetGlyphsExtent (HDC hdc, Glyph32 *glyphs, int nr_glyphs, SIZE *size) |
Get visual extent value of a glyph string. More... | |
MG_EXPORT int GUIAPI | GetGlyphsExtentPoint (HDC hdc, Glyph32 *glyphs, int nr_glyphs, int max_extent, SIZE *size) |
Get the visual extent value of an glyph string. More... | |
MG_EXPORT int GUIAPI | GetGlyphInfo (LOGFONT *logfont, Glyph32 glyph_value, GLYPHINFO *glyph_info) |
Retrieve the information of a glyph. More... | |
MG_EXPORT int GUIAPI | GetUCharsUntilParagraphBoundary (LOGFONT *logfont, const char *mstr, int mstr_len, Uint8 wsr, Uchar32 **uchars, int *nr_uchars) |
Convert a multi-byte character string to a Unicode character (Uchar32) string until the end of text (null character) or an explicit paragraph boundary encountered. More... | |
MG_EXPORT Uchar32 GUIAPI | AChar2UChar (LOGFONT *logfont, Achar32 chv) |
Get Uchar32 value (Unicode wide character value) from a LOGFONT abstract character value. More... | |
MG_EXPORT int GUIAPI | AChars2UChars (LOGFONT *logfont, const Achar32 *chs, Uchar32 *ucs, int n) |
Convert an Achar32 array to Unicode character array. More... | |
MG_EXPORT BOOL GUIAPI | UChar2AChar (LOGFONT *logfont, Uchar32 uc, Achar32 *ac) |
Get the LOGFONT Achar32 value from a Unicode character value. More... | |
MG_EXPORT int GUIAPI | UChars2AChars (LOGFONT *logfont, const Uchar32 *ucs, Achar32 *acs, int n) |
Convert an Uchar32 array to Unicode character array. More... | |
MG_EXPORT int GUIAPI | GetGlyphsExtentFromUChars (LOGFONT *logfont_upright, const Achar32 *uchars, int nr_uchars, const BreakOppo *break_oppos, Uint32 render_flags, int x, int y, int letter_spacing, int word_spacing, int tab_size, int max_extent, SIZE *line_size, Glyph32 *glyphs, GLYPHEXTINFO *glyph_ext_info, GLYPHPOS *glyph_pos, LOGFONT **logfont_sideways) |
Get the visual extent info of all glyphs fitting in the specified maximal output extent. More... | |
MG_EXPORT TEXTRUNS *GUIAPI | CreateTextRuns (const Uchar32 *ucs, int nr_ucs, LanguageCode lang_code, ParagraphDir base_dir, const char *logfont_name, RGBCOLOR color, RGBCOLOR bg_color, BreakOppo *break_oppos) |
Split a Uchar32 paragraph string in mixed scripts into text runs. More... | |
MG_EXPORT BOOL GUIAPI | SetFontNameInTextRuns (TEXTRUNS *truns, int start_index, int length, const char *logfont_name) |
Set logfont name of text runs. More... | |
const MG_EXPORT char *GUIAPI | GetFontNameInTextRuns (const TEXTRUNS *truns, int index) |
MG_EXPORT BOOL GUIAPI | SetTextColorInTextRuns (TEXTRUNS *truns, int start_index, int length, RGBCOLOR color) |
Set text color in a TEXTRUNS object. More... | |
MG_EXPORT RGBCOLOR GUIAPI | GetTextColorInTextRuns (const TEXTRUNS *truns, int index) |
MG_EXPORT BOOL GUIAPI | SetBackgroundColorInTextRuns (TEXTRUNS *truns, int start_index, int length, RGBCOLOR color) |
Set background color in a TEXTRUNS object. More... | |
MG_EXPORT RGBCOLOR GUIAPI | GetBackgroundColorInTextRuns (const TEXTRUNS *truns, int index) |
MG_EXPORT BOOL GUIAPI | DestroyTextRuns (TEXTRUNS *truns) |
Destroy the glyph run info object. It also frees all data allocated for shapping and layouting the glyphs. More... | |
MG_EXPORT BOOL GUIAPI | InitBasicShapingEngine (TEXTRUNS *truns) |
Initialize the base shaping engine for a TEXTRUNS object. More... | |
MG_EXPORT BOOL GUIAPI | InitComplexShapingEngine (TEXTRUNS *truns) |
Initialize the complex shaping engine for a TEXTRUNS object. More... | |
MG_EXPORT LAYOUT *GUIAPI | CreateLayout (const TEXTRUNS *truns, Uint32 render_flags, const BreakOppo *break_oppos, BOOL persist_lines, int max_line_extent, int indent, int letter_spacing, int word_spacing, int tab_size, int *tabs, int nr_tabs) |
Create layout information structure for laying out a paragraph. More... | |
MG_EXPORT BOOL GUIAPI | DestroyLayout (LAYOUT *layout) |
Destroy the specified layout information structure. More... | |
MG_EXPORT LAYOUTLINE *GUIAPI | LayoutNextLine (LAYOUT *layout, LAYOUTLINE *prev_line, int max_extent, BOOL last_line, CB_GLYPH_LAID_OUT cb_laid_out, GHANDLE ctxt) |
Layout the next line of a paragraph according to the layout information. More... | |
MG_EXPORT BOOL GUIAPI | GetLayoutLineSize (const LAYOUTLINE *line, SIZE *line_size) |
Get the size of a layout line. More... | |
MG_EXPORT int GUIAPI | CalcLayoutBoundingRect (LAYOUT *layout, int max_line_extent, int max_height, int line_height, int x, int y, RECT *bounding) |
Calculate the bounding rectangle of a layout. More... | |
MG_EXPORT int | DrawLayoutLine (HDC hdc, const LAYOUTLINE *line, int x, int y) |
Draw a laid out line at the specific position. More... | |
To lay out, shape, and render a text in mixed scripts, you should call GetUCharsUntilParagraphBoundary function first to convert a multi-byte string to a Unicode string under the specified white space rule, breaking rule, and transformation rule. For example, converting a general C string in UTF-8 or GB18030 to a Uchar32 string by calling this function. You can call CreateLogFontForMChar2UChar function to create a dummy logfont object for this purpose in order to expense a minimal memory.
If the text is in simple scripts, like Latin or Chinese, you can call GetGlyphsExtentFromUChars function to lay out the paragraph. This function returns a glyph string which can fit in a line with the specified maximal extent and rendering flags. After this, you call DrawGlyphStringEx function to draw the glyph string to the specific position of a DC.
If the text is in complex and/or mixed scripts, like Arabic, Thai, and Indic, you should create a TEXTRUNS object first by calling CreateTextRuns function, then initialize the shaping engine for laying out the text.
MiniGUI provides two types of shaping engine. One is the basic shaping engine. The corresponding function is InitBasicShapingEngine. The other is called complex shaping engine, which is based on HarfBuzz. The corresponding function is InitComplexShapingEngine. The latter one can give you a better shaping result.
After this, you should call CreateLayout to create a layout object for laying out the text, then call LayoutNextLine to lay out the lines one by one.
You can render the laid out lines by calling DrawLayoutLine function.
Finally, you call DestroyLayout and DestroyTextRuns to destroy the layout object and text runs object.
Before rendering the glyphs laid out, you can also call GetLayoutLineRect to get the line rectangle, or call CalcLayoutBoundingRect to get the bounding rectangle of one paragraph.
These new APIs provide a very flexible implementation for your apps to process the complex scripts.
Note that MiniGUI uses Achar32 type for an abstract character index value under a certain charset/encoding, and uses Glyph32 type for the glyph index value in a device font.
Under Unicode charset or encodings, the abstract character index value will be identical to the Unicode code point, i.e., Achar32 is equivalent to Uchar32 under this situation.
#define GLYPHBMP_TYPE_GREY 0x01 |
#define GLYPHBMP_TYPE_GREY4b 0x02 |
#define GLYPHBMP_TYPE_MONO 0x00 |
#define GLYPHBMP_TYPE_PRERENDER 0x04 |
#define GLYPHBMP_TYPE_SUBPIXEL 0x03 |
#define UCHAR2ACHAR | ( | uc | ) | ((uc) | 0x80000000) |
The macro to convert a Uchar32 value to Achar32 value.
Since 4.0.0
typedef struct _ACHARMAPINFO ACHARMAPINFO |
Data type of struct _ACHARMAPINFO.
typedef BOOL |
A type definition for boolean value.
The prototype of callback function for LayoutNextLine.
This callback function will be called by LayoutNextLine when a glyph is laid out.
ctxt | The context value passed to LayoutNextLine. |
glyph_value | The glyph value. |
glyph_pos | The glyph position and orientation information. |
render_data | The shaping data of the glyph. |
Since 4.0.0
typedef struct _GLYPHEXTINFO GLYPHEXTINFO |
The glyph extent information.
typedef struct _GLYPHINFO GLYPHINFO |
Data type of struct _GLYPHINFO.
typedef struct _LAYOUT LAYOUT |
typedef struct _LAYOUTLINE LAYOUTLINE |
typedef struct _TEXTRUNS TEXTRUNS |
enum typedef enum ACHARSHAPETYPE |
AChar2UChar | ( | LOGFONT * | logfont, |
Achar32 | chv | ||
) |
Get Uchar32 value (Unicode wide character value) from a LOGFONT abstract character value.
Only valid for UNICODE.
logfont | The LOGFONT object |
chv | The LOGFONT character value. |
Since 4.0.0
int AChars2UChars | ( | LOGFONT * | logfont, |
const Achar32 * | achs, | ||
Uchar32 * | ucs, | ||
int | n | ||
) |
Convert an Achar32 array to Unicode character array.
Only valid for UNICODE.
logfont | The LOGFONT object |
achs | The array of the abstract character values. |
ucs | The buffer to store the converted Uchar32 characters. |
n | The length of the Achar32 array. |
Since 4.0.0
int GUIAPI BIDIGetTextLogicalAChars | ( | LOGFONT * | log_font, |
const char * | text, | ||
int | text_len, | ||
Achar32 ** | achars, | ||
ACHARMAPINFO ** | achars_map | ||
) |
Get logical achars string of the text.
log_font | The logical font. |
text | The logical text string. |
text_len | The lenght of the logical text string in bytes. |
achars | The pointer to the logical glyph string. |
achars_map | The position map from the logical achars string to the logical text. |
void GUIAPI BIDIGetTextRangesLog2Vis | ( | LOGFONT * | log_font, |
const char * | text, | ||
int | text_len, | ||
int | start_index, | ||
int | end_index, | ||
int ** | ranges, | ||
int * | nr_ranges | ||
) |
Get a list of visual ranges corresponding to a given logical range.
log_font | The logical font. |
text | The pointer to the logical text string. |
text_len | The length of the logical text string in bytes. |
start_index | The start index of the logical range. |
end_index | The end index of the logical range. |
ranges | The pointer to store a pointer to an array of arranges. |
nr_ranges | The number of ranges stored in ranges. |
int GUIAPI BIDIGetTextVisualAChars | ( | LOGFONT * | log_font, |
const char * | text, | ||
int | text_len, | ||
Achar32 ** | achars, | ||
ACHARMAPINFO ** | achars_map | ||
) |
Get visual achars and glyph_map info relative with logical string byte index.
log_font | The logical font. |
text | The logical text string. |
text_len | The length of the logical text string in bytes. |
achars | The pointer to the visual glyph string. |
achars_map | The position map from visual achars string to the logical text. |
BOOL GUIAPI BIDILogAChars2VisAChars | ( | LOGFONT * | log_font, |
Achar32 * | achars, | ||
int | nr_achars, | ||
ACHARMAPINFO * | achars_map | ||
) |
Reorder the specified logical glyph string in visual order and reorder glyph map if specified.
This function reorders the logical glyph string in place to visual order. If achars_map is not NULL, it also reorders the map to reflect the visual order.
log_font | The logical font. |
achars | The pointer to the glyph string. |
nr_achars | The length of the glyph string. |
achars_map | The position map returned by BIDIGetTextLogicalAChars; can be NULL. |
BOOL GUIAPI BIDILogAChars2VisACharsEx | ( | LOGFONT * | log_font, |
Achar32 * | achars, | ||
int | nr_achars, | ||
int | pel, | ||
void * | extra, | ||
CB_REVERSE_ARRAY | cb_reverse_extra | ||
) |
Reorder the specified logical glyph string in visual order and reorder an extra array to reflect the visule order of the achars.
This function reorders the logical glyph string in place to visual order. If extra and cb_reverse_extra are both not NULL, it also reorders the array pointed by extra by calling the callback function cb_reverse_extra.
log_font | The logical font. |
achars | The pointer to the glyph string. |
nr_achars | The length of the glyph string. |
pel | The paragraph embedding level, can be one of the following values:
|
extra | The pointer to the extra array to reorder; can be NULL. |
cb_reverse_extra | The callback function to reverse the extra array. |
int GUIAPI CalcLayoutBoundingRect | ( | LAYOUT * | layout, |
int | max_line_extent, | ||
int | max_height, | ||
int | line_height, | ||
int | x, | ||
int | y, | ||
RECT * | bounding | ||
) |
Calculate the bounding rectangle of a layout.
This function calculates the bounding rectangle of the specific layout object layout.
layout | The LAYOUT object. |
max_line_extent | The maximal line extent; only effective if the line extent mode of the layout object is variable. |
max_height | The maximal height of the lines; no limit if it is less than 0. |
line_height | The line height. If it is less than 0, this function will try to determine the line height automatically. |
x | The x-position of first line. |
y | The y-position of first line. |
bounding | The buffer to receive the result. |
Since 4.0.0
LAYOUT *GUIAPI CreateLayout | ( | const TEXTRUNS * | truns, |
Uint32 | render_flags, | ||
const BreakOppo * | break_oppos, | ||
BOOL | persist_lines, | ||
int | max_line_extent, | ||
int | indent, | ||
int | letter_spacing, | ||
int | word_spacing, | ||
int | tab_size, | ||
int * | tabs, | ||
int | nr_tabs | ||
) |
Create layout information structure for laying out a paragraph.
This function creates a LAYOUT object for laying out a TEXTRUNS object truns, which represents a Uchar32 paragraph in mixed scripts ready to lay out.
truns | The TEXTRUNS object. |
render_flags | The render flags; see glyph_render_flags. |
break_oppos | The breaking opportunities of the paragraph. |
persist_lines | Whether to persist the lines laid out. |
max_line_extent | The fixed maximal line extent. |
indent | The indentation value. |
letter_spacing | This parameter specifies additional spacing (commonly called tracking) between adjacent glyphs. |
word_spacing | This parameter specifies the additional spacing between words. |
tab_size | The tab size used to render preserved tab characters. |
tabs | The array of the tab stops; can be NULL. |
nr_tabs | The length of the tab stops array. |
Since 4.0.0
TEXTRUNS *GUIAPI CreateTextRuns | ( | const Uchar32 * | ucs, |
int | nr_ucs, | ||
LanguageCode | lang_code, | ||
ParagraphDir | base_dir, | ||
const char * | logfont_name, | ||
RGBCOLOR | color, | ||
RGBCOLOR | bg_color, | ||
BreakOppo * | break_oppos | ||
) |
Split a Uchar32 paragraph string in mixed scripts into text runs.
This function splits the Uchar32 paragraph ucs in mixed scripts into text runs, and returns a TEXTRUNS object.
ucs | The Uchar32 string returned by GetUCharsUntilParagraphBoundary. |
nr_ucs | The length of the Uchar32 string. |
lang_code | The language code. |
base_dir | The base direction of the paragraph. |
logfont_name | The default logfont name. You can change the font of some text in the paragraph by calling SetFontNameInTextRuns. |
color | The default text color. You can change the text color of some text in the paragraph by calling SetTextColorInTextRuns. |
bg_color | The default background color. You can change the background color of some text in the paragraph by calling SetBackgroundColorInTextRuns. If the background is transparent, please pass MakeRGBA(0,0,0,0) for this argument. |
break_oppos | If not NULL, the break opportunities will be tailored according to the script type of every text run. Please skip the first entry when you pass the pointer. |
Since 4.0.0
Destroy the specified layout information structure.
This function destroy the specific layout information object layout.
layout | The LAYOUT object. |
Since 4.0.0
Destroy the glyph run info object. It also frees all data allocated for shapping and layouting the glyphs.
This function destroies the specific TEXTRUNS object truns.
truns | The TEXTRUNS object. |
Since 4.0.0
int GUIAPI DrawGlyph | ( | HDC | hdc, |
int | x, | ||
int | y, | ||
Glyph32 | glyph_value, | ||
int * | adv_x, | ||
int * | adv_y | ||
) |
Draw a glyph.
This function draws a glyph to the specific postion of a DC.
hdc | The device context. |
x | The output start x position. |
y | The output start y position. |
glyph_value | The glyph value. |
adv_x | The pointer used to return the advance in x-coordinate of the glyph, can be NULL. |
adv_y | The pointer used to return the advance in y-coordinate of the glyph, can be NULL. |
DrawLayoutLine | ( | HDC | hdc, |
const LAYOUTLINE * | line, | ||
int | x, | ||
int | y | ||
) |
Draw a laid out line at the specific position.
This function draws a laied out line at the specified position.
hdc | The device context. |
line | The laid out LAYOUTLINE object. It should be one returned by LayoutNextLine. |
x | The buffer contained the x-corrdinate of the output position of the first glyph in the line. The x-corrdinate of the next line will be returned through this buffer as well. |
y | The buffer contained the y-corrdinate of the output position of the first glyph in the line. The y-corrdinate of the next line will be returned through this buffer as well. |
Since 4.0.0
Retrieve the BIDI type of an abstract character.
This function retrieves the BIDI type of an abstract character.
logfont | The logical font. |
chv | The abstract character value. |
Get visual extent value of an achar string.
This function gets the extent value of an achar string on a DC. Note that this function will ignore all breaks in the achar string.
hdc | The device context. |
achars | The pointer to the achar string. |
nr_achars | The length of the achar string. |
size | The buffer restoring the extents of the achar strings. |
int GUIAPI GetACharsExtentPoint | ( | HDC | hdc, |
Achar32 * | achars, | ||
int | nr_achars, | ||
int | max_extent, | ||
SIZE * | size | ||
) |
Get the visual extent value of an achar string.
This function gets the visual extent value of a glpyh string. Note that this function ignore all breaks in the achar string.
hdc | The device context. |
achars | The pointer to the achar string. |
nr_achars | The length of the achar string len. |
max_extent | The maximal output extent value. |
size | The real extent of all visual achars in the achar string. |
Retrieve the basic type, the general cateory of Unicode, and the break class of Unicode of an abstract character.
This function retrieves the basic type, the general category defined by Unicode terms, and the break class defined by Unicode of an abstract character.
logfont | The logical font. |
chv | An Achar32 value. |
Achar32 GUIAPI GetACharValue | ( | LOGFONT * | logfont, |
const char * | mchar, | ||
int | mchar_len, | ||
const char * | pre_mchar, | ||
int | pre_len | ||
) |
Get the character value of a multi-byte character.
logfont | The logical font. |
mchar | The pointer to the multi-byte character. |
mchar_len | The length of mchar in bytes. |
pre_mchar | The pointer to the multi-byte character before mchar. |
pre_len | The length of per_mchar in bytes. |
Get the background color of a specific character in a TEXTRUNS object.
Since 4.0.0
const MG_EXPORT char* GUIAPI GetFontNameInTextRuns | ( | const TEXTRUNS * | truns, |
int | index | ||
) |
Get the font name of a specific character in a TEXTRUNS object.
Since 4.0.0
Retrieve the information of a glyph.
This function retrieves the information of a glyph.
logfont | The logical font. |
glyph_value | The glyph value. |
glyph_info | The glyph information will be returned through this struct. |
Get visual extent value of a glyph string.
This function gets the extent value of a glyph string on a DC. Note that this function will ignore all special types in the glyph string.
hdc | The device context. |
glyphs | The pointer to the glyph string. |
nr_glyphs | The length of the glyph string. |
size | The buffer restoring the extents of the glyph string. |
int GUIAPI GetGlyphsExtentFromUChars | ( | LOGFONT * | logfont_upright, |
const Achar32 * | uchars, | ||
int | nr_uchars, | ||
const BreakOppo * | break_oppos, | ||
Uint32 | render_flags, | ||
int | x, | ||
int | y, | ||
int | letter_spacing, | ||
int | word_spacing, | ||
int | tab_size, | ||
int | max_extent, | ||
SIZE * | line_size, | ||
Glyph32 * | glyphs, | ||
GLYPHEXTINFO * | glyph_ext_info, | ||
GLYPHPOS * | glyph_pos, | ||
LOGFONT ** | logfont_sideways | ||
) |
Get the visual extent info of all glyphs fitting in the specified maximal output extent.
This function gets the visual extent information of a glyph string which can fit a line with the specified maximal extent.
logfont_upright | The logfont used to render the uchar string. Note that the charset/encoding of this logfont should be Unicode, such as UTF-8, UTF-16LE, and UTF-16BE. |
uchars | The pointer to the achar string. |
nr_uchars | The number of the glyphs. |
break_oppos | The pointer to the break opportunities array of the glyphs. It should be returned by UStrGetBreaks. However, the caller should skip the first unit (the break opportunity before the first glyph) when passing the pointer to this function. |
render_flags | The render flags; see glyph_render_flags. |
x | The x-position of first glyph. |
y | The y-position of first glyph. |
letter_spacing | This parameter specifies additional spacing (commonly called tracking) between adjacent glyphs. |
word_spacing | This parameter specifies the additional spacing between words. |
tab_size | The tab size used to render preserved tab characters. |
max_extent | The maximal output extent value. No limit when it is < 0. |
line_size | The buffer to store the line extent info; can be NULL. |
glyphs | The buffer to store the glyphs, which can fit in the max extent; cannot be NULL. |
glyph_ext_info | The buffer to store the extent info of all glyphs which can fit in the max extent; can be NULL. |
glyph_pos | The buffer to store the positions and orientations of all glyphs which can fit in the max extent; cannot be NULL. |
logfont_sideways | The buffer to store the LOGFONT object created by this function for sideways glyphs if text orientation specified in render_flags is mixed (GRF_TEXT_ORIENTATION_MIXED) or sideways (GRF_TEXT_ORIENTATION_SIDEWAYS). If *logfont_sidways is not NULL, this function will try to use this LOGFONT object for sideways glyphs. |
Since 4.0.0
int GUIAPI GetGlyphsExtentPoint | ( | HDC | hdc, |
Glyph32 * | glyphs, | ||
int | nr_glyphs, | ||
int | max_extent, | ||
SIZE * | size | ||
) |
Get the visual extent value of an glyph string.
This function gets the visual extent value of a glpyh string. Note that this function ignore all special types in the glyph string.
hdc | The device context. |
glyphs | The pointer to the glyph string. |
nr_glyphs | The length of the glyph string len. |
max_extent | The maximal output extent value. |
size | The real extent of all visual glyphs in the glyph string. |
Glyph32 GUIAPI GetGlyphValue | ( | LOGFONT * | logfont, |
const char * | mchar, | ||
int | mchar_len, | ||
const char * | pre_mchar, | ||
int | pre_len | ||
) |
Get the glyph value of a multi-byte character.
logfont | The logical font. |
mchar | The pointer to the multi-byte character. |
mchar_len | The length of mchar in bytes. |
pre_mchar | The pointer to the multi-byte character before mchar. |
pre_len | The length of per_mchar in bytes. |
Glyph32 GUIAPI GetGlyphValueAlt | ( | LOGFONT * | logfont, |
Achar32 | chv | ||
) |
Get the LOGFONT glyph value of an abstract character.
logfont | The logical font. |
chv | The value of the abstract character. |
BOOL GUIAPI GetLayoutLineSize | ( | const LAYOUTLINE * | line, |
SIZE * | line_size | ||
) |
Get the size of a layout line.
This function gets the size of the specific layout line object line.
line | The layout line object. |
line_size | The buffer to store the result. |
Since 4.0.0
Get the mirrored abstract character if possible.
logfont | The logical font. |
chv | The abstract character value. |
mirrored | The buffer to store the mirrored Achar32 value if the multi-byte character has a mirrored character. |
int GUIAPI GetNextUChar | ( | LOGFONT * | logfont, |
const char * | mchar, | ||
int | mchar_len, | ||
Uchar32 * | uc | ||
) |
Get the Uchar32 value (Unicode code point) of a multi-byte character in specified LOGFONT object.
This function get the Uchar32 value of a mutil-byte character in specified LOGFONT object logfont, which is under speicific charset/encoding.
logfont | The logical font. |
mchar | The pointer to the multi-byte character. |
mchar_len | The length of mchar in bytes. |
uc | The buffer to receive the Uchar32 value. |
Achar32 GUIAPI GetShapedAChar | ( | LOGFONT * | logfont, |
const char * | mchar, | ||
int | mchar_len, | ||
ACHARSHAPETYPE | shape_type | ||
) |
Get the glyph shape of a character.
logfont | The logical font. |
mchar | The pointer to the multi-byte character. |
mchar_len | The length of mchar in bytes. |
shape_type | The requested shape type. |
Get the text color of a specific character in a TEXTRUNS object.
Since 4.0.0
int GUIAPI GetUCharsUntilParagraphBoundary | ( | LOGFONT * | logfont, |
const char * | mstr, | ||
int | mstr_len, | ||
Uint8 | wsr, | ||
Uchar32 ** | uchars, | ||
int * | nr_uchars | ||
) |
Convert a multi-byte character string to a Unicode character (Uchar32) string until the end of text (null character) or an explicit paragraph boundary encountered.
This function calculates and allocates the Uchar32 string from a multi-byte string until it encounters the end of text (null character) or an explicit paragraph boundary. It also processes the text according to the specified white space rule wsr and the text transformation rule ctr.
The implementation of this function conforms to the CSS Text Module Level 3:
https://www.w3.org/TR/css-text-3/
Note that you are responsible for freeing the Uchar32 string allocated by this function.
logfont | The logfont used to parse the string. |
mstr | The pointer to the multi-byte string. |
mstr_len | The length of mstr in bytes. |
wsr | The white space rule; see white_space_rules. |
uchars | The pointer to a buffer to store the address of the Uchar32 array which contains the Unicode character values. |
nr_uchars | The buffer to store the number of the allocated Uchar32 array. |
Since 4.0.0
Initialize the base shaping engine for a TEXTRUNS object.
This function initializes the base shaping engine for the specific TEXTRUNS object truns.
The basic shaping engine performs the basic shaping process according to the Unicode character properties if the script type (writing system) is Arabic. This includes the mirroring/brackets subsititions, and the mandatory ligatures.
For the better shaping glyphs, you can call InitComplexShapingEngine to perform the shaping process based on the data contained in the OpenType Layout tables in the underlaying OpenType fonts or TrueType fonts. MiniGUI uses LGPL'd HarfBuzz to implement the complex shaping engine.
After initializing the shapping engine, you can call CreateLayout to layout the Uchar32 paragraph string.
truns | The TEXTRUNS object. |
Since 4.0.0
Initialize the complex shaping engine for a TEXTRUNS object.
This function initializes the complex shaping engine for the specific TEXTRUNS object truns.
The complex shaping engine performs the complex shaping process according to the data contained in the OpenType Layout tables (GSUB, GPOS, and so on) contained in a OpenType font. The complex shaping engine is implemented based on HarfBuzz.
You can call InitBasicShapingEngine to initialize the basic shaping process which shapes the glyphs based on the Unicode character properties instead.
After initializing the shapping engine, you can call CreateLayout to layout the Uchar32 paragraph string.
truns | The TEXTRUNS object. |
Since 4.0.0
LAYOUTLINE *GUIAPI LayoutNextLine | ( | LAYOUT * | layout, |
LAYOUTLINE * | prev_line, | ||
int | max_extent, | ||
BOOL | last_line, | ||
CB_GLYPH_LAID_OUT | cb_laid_out, | ||
GHANDLE | ctxt | ||
) |
Layout the next line of a paragraph according to the layout information.
This function lays out the next line of in a LAYOUTLINE object layout. If prev_line is NULL, the function will returns the first line.
You can pass the maximal extent of the next line via max_extent to control the output extent of every line. The function will wrap or ellipsize the line according to the rendering flags of the LAYOUT object. You can also control whether to render the next line as the last line of the LAYOUT object via last_line parameter.
The line size will be returned through line_size if it is not NULL. When there is a glyph positioned, the function will call cb_laid_out with the context ctxt. You can draw the glyph to a DC or do anything you want.
The previous line will be release if the LAYOUTLINE object is not persisted. In this way, you can save memory use of the LAYOUTLINE object.
layout | The LAYOUT object. |
prev_line | NULL or the previous line object returned by this function. |
max_extent | The maximal extent of the next line; No limit if it is less than 0. This parameter is only effective when the line extent mode of the layout object is variable. |
last_line | Whether try to lay out all left characters in one line. |
cb_laid_out | The callback for one laid out glyph. |
ctxt | The context will be passed to cb_laid_out. This parameter is only effective when cb_laid_out is not NULL. |
Since 4.0.0
MG_EXPORT BOOL GUIAPI SetBackgroundColorInTextRuns | ( | TEXTRUNS * | truns, |
int | start_index, | ||
int | length, | ||
RGBCOLOR | color | ||
) |
Set background color in a TEXTRUNS object.
This function set a new background color for all text or a part of the text in a TEXTRUNS object truns.
truns | The TEXTRUNS object. |
start_index | The start index of the text which will use the new font name. |
length | The length of the text which will use the new font name. |
color | The new background color. |
Since 4.0.0
MG_EXPORT BOOL GUIAPI SetFontNameInTextRuns | ( | TEXTRUNS * | truns, |
int | start_index, | ||
int | length, | ||
const char * | logfont_name | ||
) |
Set logfont name of text runs.
This function set a new LOGFONT name for all text or a part of the text in a TEXTRUNS object.
truns | The TEXTRUNS object. |
start_index | The start index of the text which will use the new font name. |
length | The length of the text which will use the new font name. |
logfont_name | The new logfont name. |
Since 4.0.0
MG_EXPORT BOOL GUIAPI SetTextColorInTextRuns | ( | TEXTRUNS * | truns, |
int | start_index, | ||
int | length, | ||
RGBCOLOR | color | ||
) |
Set text color in a TEXTRUNS object.
This function set a new text color for all text or a part of the text in a TEXTRUNS object truns.
truns | The TEXTRUNS object. |
start_index | The start index of the text which will use the new font name. |
length | The length of the text which will use the new font name. |
color | The new text color. |
Since 4.0.0
Get the LOGFONT Achar32 value from a Unicode character value.
This function converts a Unicode character value uc to the abstract character value which is defined by the charset of the LOGFONT object logfont.
logfont | The LOGFONT object |
uc | The Unicode character value. |
ac | The buffer to store the converted Achar32 value. |
Since 4.0.0
int UChars2AChars | ( | LOGFONT * | logfont, |
const Uchar32 * | ucs, | ||
Achar32 * | acs, | ||
int | n | ||
) |
Convert an Uchar32 array to Unicode character array.
Only valid for UNICODE.
logfont | The LOGFONT object |
ucs | The array of the Unicode characters. |
acs | The buffer to store the converted abstract characters. |
n | The length of the Uchar32 array. |
Since 4.0.0