MiniGUI API Reference (MiniGUI-Threads)  v5.0.6
A mature and proven cross-platform GUI system for embedded and smart IoT devices
Modules | Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
Logical font operations

MiniGUI uses logical font to render text in a DC. You can create a logical font by using CreateLogFont and select it into a DC by using SelectFont, then you can use this logical font to render text by using TextOutLen or DrawTextEx. More...

Modules

 Abstract Character Types
 MiniGUI uses a Uint32 value to store the type information of a character.
 
 Language Code
 The language code specifies the content language.
 

Data Structures

struct  _LOGFONT
 
struct  _DEVFONT
 
struct  _FONTMETRICS
 
struct  _GLYPHBITMAP
 

Macros

#define FONT_CHARSET_GB1988_0   "GB1988-0"
 EUC encoding of GB1988 charset, treat as ISO8859-1. More...
 
#define FONT_CHARSET_GB2312_0   "GB2312-0"
 EUC encoding of GB2312 charset. More...
 
#define FONT_CHARSET_GB18030_0   "GB18030-0"
 EUC encoding of GB18030 charset. More...
 
#define FONT_CHARSET_EUCTW   "EUC-TW"
 EUC encoding of CNS11643 charset, not supported. More...
 
#define FONT_CHARSET_KSC5636_0   "KSC5636-0"
 EUC encoding of KSC5636 charset, treat as ISO8859-1. More...
 
#define FONT_CHARSET_KSC5601_0   "KSC5601-0"
 EUC encoding of KSC5601 charset. More...
 
#define FONT_CHARSET_JISX0201_0   "JISX0201-0"
 EUC encoding of JISX0201 charset. More...
 
#define FONT_CHARSET_JISX0208_0   "JISX0208-0"
 EUC encoding of JISX0208 charset. More...
 
#define FONT_CHARSET_JISX0201_1   "JISX0201-1"
 Shift-JIS encoding of JISX0201 charset. More...
 
#define FONT_CHARSET_JISX0208_1   "JISX0208-1"
 Shift-JIS encoding of JISX0208 charset. More...
 
#define FONT_CHARSET_ISO_10646_1   "ISO-10646-1"
 UCS-2 encoding of UNICODE. More...
 
#define FONT_CHARSET_UTF8   "UTF-8"
 UTF-8 encoding of UNICODE. More...
 
#define FONT_CHARSET_UTF16LE   "UTF-16LE"
 UTF-16 encoding (Little-Endian) of UNICODE. More...
 
#define FONT_CHARSET_UTF16BE   "UTF-16BE"
 UTF-16 encoding (Big-Endian) of UNICODE. More...
 
#define INV_LOGFONT   0
 Invalid logfont. More...
 

Typedefs

typedef struct _LOGFONT LOGFONT
 
typedef LOGFONTPLOGFONT
 Data type of pointer to a LOGFONT. More...
 
typedef struct _WORDINFO WORDINFO
 Date type of _WORDINFO. More...
 
typedef struct _FONTMETRICS FONTMETRICS
 
typedef struct _GLYPHBITMAP GLYPHBITMAP
 

Enumerations

enum  FT2LCDFilter {
  MG_SMOOTH_NONE = 0, MG_SMOOTH_DEFAULT = 1, MG_SMOOTH_LIGHT = 2, MG_SMOOTH_LEGACY = 16,
  MG_SMOOTH_MAX
}
 

Functions

MG_EXPORT void GUIAPI GetFontMetrics (LOGFONT *log_font, FONTMETRICS *font_metrics)
 Get metrics information of a logical font. More...
 
MG_EXPORT void GUIAPI GetGlyphBitmap (LOGFONT *log_font, const char *mchar, int mchar_len, GLYPHBITMAP *glyph_bitmap)
 Get the glyph bitmap information when uses a logical font to output a multi-byte character. More...
 
static BOOL GUIAPI InitVectorialFonts (void)
 Initializes vectorial font renderer. More...
 
static void GUIAPI TermVectorialFonts (void)
 Terminates vectorial font renderer. More...
 
MG_EXPORT PLOGFONT GUIAPI CreateLogFont (const char *type, const char *family, const char *charset, char weight, char slant, char flip, char other, char underline, char struckout, int size, int rotation)
 Creates a logical font. More...
 
MG_EXPORT PLOGFONT GUIAPI CreateLogFontEx (const char *type, const char *family, const char *charset, char weight, char slant, char flip, char other, char decoration, char rendering, int size, int rotation)
 Creates a logical font. More...
 
MG_EXPORT PLOGFONT GUIAPI CreateLogFontByName (const char *font_name)
 Creates a logical font by a font name. More...
 
MG_EXPORT PLOGFONT GUIAPI CreateLogFontForMChar2UChar (const char *charset)
 Create a logical font for conversion from multi-byte character string to Uchar32 string. More...
 
MG_EXPORT PLOGFONT GUIAPI CreateLogFontIndirect (LOGFONT *logfont)
 Creates a logical font indirectly from a LOGFONT structure. More...
 
MG_EXPORT PLOGFONT GUIAPI CreateLogFontIndirectEx (LOGFONT *logfont, int rotation)
 Creates a new logical font indirectly from a LOGFONT structure with a rotation degrees. More...
 
MG_EXPORT void GUIAPI DestroyLogFont (PLOGFONT log_font)
 Destroys a logical font. More...
 
MG_EXPORT void GUIAPI GetLogFontInfo (HDC hdc, LOGFONT *log_font)
 Get logical font information of a DC. More...
 
MG_EXPORT PLOGFONT GUIAPI GetCurFont (HDC hdc)
 Get the pointer to the current logical font of a DC. More...
 
MG_EXPORT PLOGFONT GUIAPI SelectFont (HDC hdc, PLOGFONT log_font)
 Selects a logical font into a DC. More...
 
const MG_EXPORT DEVFONT *GUIAPI GetNextDevFont (const DEVFONT *dev_font)
 Get next devfont information. More...
 
MG_EXPORT BOOL GUIAPI ft2SetLcdFilter (LOGFONT *logfont, FT2LCDFilter filter)
 Set freetype2 smooth mode. More...
 
MG_EXPORT DEVFONT *GUIAPI LoadDevFontFromIncoreData (const char *devfont_name, const void *data)
 Load device font from incore data. More...
 
MG_EXPORT DEVFONT *GUIAPI LoadDevFontFromFile (const char *devfont_name, const char *file_name)
 Load device font from font file. More...
 
MG_EXPORT void GUIAPI DestroyDynamicDevFont (DEVFONT **devfont)
 Destroy device font loaded dynamically from font file. More...
 

Variables

const typedef LOGFONTCPLOGFONT
 Data type of pointer to a LOGFONT. More...
 

Detailed Description

MiniGUI uses logical font to render text in a DC. You can create a logical font by using CreateLogFont and select it into a DC by using SelectFont, then you can use this logical font to render text by using TextOutLen or DrawTextEx.

Macro Definition Documentation

◆ FONT_CHARSET_EUCTW

#define FONT_CHARSET_EUCTW   "EUC-TW"

EUC encoding of CNS11643 charset, not supported.

Definition at line 6402 of file gdi.h.

◆ FONT_CHARSET_GB18030_0

#define FONT_CHARSET_GB18030_0   "GB18030-0"

EUC encoding of GB18030 charset.

Definition at line 6395 of file gdi.h.

◆ FONT_CHARSET_GB1988_0

#define FONT_CHARSET_GB1988_0   "GB1988-0"

EUC encoding of GB1988 charset, treat as ISO8859-1.

Definition at line 6382 of file gdi.h.

◆ FONT_CHARSET_GB2312_0

#define FONT_CHARSET_GB2312_0   "GB2312-0"

EUC encoding of GB2312 charset.

Definition at line 6388 of file gdi.h.

◆ FONT_CHARSET_ISO_10646_1

#define FONT_CHARSET_ISO_10646_1   "ISO-10646-1"

UCS-2 encoding of UNICODE.

Definition at line 6447 of file gdi.h.

◆ FONT_CHARSET_JISX0201_0

#define FONT_CHARSET_JISX0201_0   "JISX0201-0"

EUC encoding of JISX0201 charset.

Definition at line 6422 of file gdi.h.

◆ FONT_CHARSET_JISX0201_1

#define FONT_CHARSET_JISX0201_1   "JISX0201-1"

Shift-JIS encoding of JISX0201 charset.

Definition at line 6435 of file gdi.h.

◆ FONT_CHARSET_JISX0208_0

#define FONT_CHARSET_JISX0208_0   "JISX0208-0"

EUC encoding of JISX0208 charset.

Definition at line 6428 of file gdi.h.

◆ FONT_CHARSET_JISX0208_1

#define FONT_CHARSET_JISX0208_1   "JISX0208-1"

Shift-JIS encoding of JISX0208 charset.

Definition at line 6441 of file gdi.h.

◆ FONT_CHARSET_KSC5601_0

#define FONT_CHARSET_KSC5601_0   "KSC5601-0"

EUC encoding of KSC5601 charset.

Definition at line 6415 of file gdi.h.

◆ FONT_CHARSET_KSC5636_0

#define FONT_CHARSET_KSC5636_0   "KSC5636-0"

EUC encoding of KSC5636 charset, treat as ISO8859-1.

Definition at line 6409 of file gdi.h.

◆ FONT_CHARSET_UTF16BE

#define FONT_CHARSET_UTF16BE   "UTF-16BE"

UTF-16 encoding (Big-Endian) of UNICODE.

Definition at line 6465 of file gdi.h.

◆ FONT_CHARSET_UTF16LE

#define FONT_CHARSET_UTF16LE   "UTF-16LE"

UTF-16 encoding (Little-Endian) of UNICODE.

Definition at line 6459 of file gdi.h.

◆ FONT_CHARSET_UTF8

#define FONT_CHARSET_UTF8   "UTF-8"

UTF-8 encoding of UNICODE.

Definition at line 6453 of file gdi.h.

◆ INV_LOGFONT

#define INV_LOGFONT   0

Invalid logfont.

Definition at line 7606 of file gdi.h.

Typedef Documentation

◆ FONTMETRICS

typedef struct _FONTMETRICS FONTMETRICS

The font metrics structure.

◆ GLYPHBITMAP

typedef struct _GLYPHBITMAP GLYPHBITMAP

The glyph bitmap structure.

◆ LOGFONT

typedef struct _LOGFONT LOGFONT

The logical font structure.

Note
All fields are read-only.

◆ PLOGFONT

typedef LOGFONT * PLOGFONT

Data type of pointer to a LOGFONT.

Definition at line 6513 of file gdi.h.

◆ WORDINFO

typedef struct _WORDINFO WORDINFO

Date type of _WORDINFO.

Definition at line 6527 of file gdi.h.

Enumeration Type Documentation

◆ FT2LCDFilter

List of values to identify various types of LCD filters, Note a freetype2 specific definition.

Enumerator
MG_SMOOTH_NONE 

equal to FT_LCD_FILTER_NONE

MG_SMOOTH_DEFAULT 

equal to FT_LCD_FILTER_DEFAULT

MG_SMOOTH_LIGHT 

equal to FT_LCD_FILTER_LIGHT

MG_SMOOTH_LEGACY 

equal to FT_LCD_FILTER_LEGACY

MG_SMOOTH_MAX 

equal to FT_LCD_FILTER_MAX

Definition at line 8163 of file gdi.h.

Function Documentation

◆ CreateLogFont()

PLOGFONT GUIAPI CreateLogFont ( const char *  type,
const char *  family,
const char *  charset,
char  weight,
char  slant,
char  flip,
char  other,
char  underline,
char  struckout,
int  size,
int  rotation 
)

Creates a logical font.

This function creates a logical font.

Parameters
typeThe type of the logical font, can be one of the values:
  • FONT_TYPE_NAME_BITMAP_RAW
    Creates a logical font by using raw bitmap device font, i.e. mono-space bitmap font.
  • FONT_TYPE_NAME_BITMAP_VAR
    Creates a logical font by using var-width bitmap device font.
  • FONT_TYPE_NAME_BITMAP_QPF
    Creates a logical font by using qpf device font.
  • FONT_TYPE_NAME_BITMAP_BMP
    Creates a logical font by using bitmap font.
  • FONT_TYPE_NAME_SCALE_TTF
    Creates a logical font by using scalable TrueType device font.
  • FONT_TYPE_NAME_SCALE_T1F
    Creates a logical font by using scalable Adobe Type1 device font.
  • FONT_TYPE_NAME_ANY
    Creates a logical font by using any type device font.
familyThe family of the logical font, such as "Courier", "Helvetica", and so on. Since version 4.0.0, you can specify up to 7 family names separated by comma, e.g., "Helvetica,黑体,Naskh,SansSerif". Note that a family name should be encoded in UTF-8 and without special characters (middle spaces are allowed).
charsetThe charset of the logical font. You can specify a sigle-byte charset like "ISO8859-1", or a multi-byte charset like "UTF-8", or "GB2312-0".
weightThe weight of the logical font, can be one of the values:
  • FONT_WEIGHT_ANY
    Any one.
  • FONT_WEIGHT_THIN
    Thin.
  • FONT_WEIGHT_EXTRA_LIGHT
    Extra light (Ultra light).
  • FONT_WEIGHT_LIGHT
    Light.
  • FONT_WEIGHT_NORMAL
    Normal.
  • FONT_WEIGHT_REGULAR
    Regular.
  • FONT_WEIGHT_MEDIUM
    Medium.
  • FONT_WEIGHT_DEMIBOLD
    Semi Bold (Demi Bold).
  • FONT_WEIGHT_BOLD
    Bold.
  • FONT_WEIGHT_EXTRA_BOLD
    Extra bold (Ultra Bold).
  • FONT_WEIGHT_BLACK
    Black (Heavy).
  • FONT_WEIGHT_BOOK
    For backforward compatibility only, same as FONT_WEIGHT_REGULAR and FONT_RENDER_GREY.
  • FONT_WEIGHT_SUBPIXEL
    For backforward compatibility only, same as FONT_WEIGHT_REGULAR and FONT_RENDER_SUBPIXEL.
slantThe slant of the logical font, can be one of the values:
  • FONT_SLANT_ANY
    Any one.
  • FONT_SLANT_ROMAN
    Regular font.
  • FONT_SLANT_OBLIQUE
    Oblique font.
flipDoes flip the glyph of the font, can be one of the following values:
  • FONT_FLIP_NONE
    Do not flip the glyph.
  • FONT_FLIP_HORZ
    Flip the glyph horizontally .
  • FONT_FLIP_VERT
    Flip the glyph vertically.
  • FONT_FLIP_HORZVERT
    Flip the glyph horizontally and vertically.
otherOther rendering features, can be one of the following values:
  • FONT_OTHER_NONE
    Not specified.
  • FONT_OTHER_AUTOSCALE
    Auto scale the bitmap glyph to match the desired font size.
  • FONT_OTHER_TTFNOCACHE
    Do not use cache when using TrueType font.
  • FONT_OTHER_TTFKERN
    Kern the glyph when using TrueType font.
  • FONT_OTHER_TTFNOCACHEKERN
    When using TrueType font, kern the glyph and do not use cache.
  • FONT_OTHER_LCDPORTRAIT
    When using TrueType font and sub-pixels smoothing strategy, set LCD portrait and do not kern the glyph.
  • FONT_OTHER_LCDPORTRAITKERN
    When using TrueType font and sub-pixels smoothing strategy, set LCD portrait and kern the glyph.
underlineThe underline of the logical font, can be one of the values:
  • FONT_UNDERLINE_ALL
    Any one.
  • FONT_UNDERLINE_LINE
    With underline.
  • FONT_UNDERLINE_NONE
    Without underline.
struckoutThe struckout line of the logical font, can be one of the values:
  • FONT_STRUCKOUT_ALL
    Any one.
  • FONT_STRUCKOUT_LINE
    With struckout line.
  • FONT_STRUCKOUT_NONE
    Without struckout line.
sizeThe size, i.e. the height, of the logical font. Note that the size of the created logical font may be different from the size expected.
rotationThe rotation of the logical font, it is in units of tenth degrees. Note that you can specify rotation only for vector fonts (use FreeType 2 font engine).
Returns
The pointer to the logical font created, NULL on error.
See also
CreateLogFontIndirect, CreateLogFontByName, SelectFont

Example:

static LOGFONT *logfont, *logfontgb12, *logfontbig24;
logfont = CreateLogFont (NULL, "SansSerif", "ISO8859-1",
FONT_WEIGHT_REGULAR, FONT_SLANT_ITALIC, FONT_FLIP_NONE,
FONT_OTHER_NIL, FONT_UNDERLINE_NONE, FONT_STRUCKOUT_LINE,
16, 0);
logfontgb12 = CreateLogFont (NULL, "song", "GB2312",
FONT_WEIGHT_REGULAR, FONT_SLANT_ROMAN, FONT_FLIP_NONE,
FONT_OTHER_NIL, FONT_UNDERLINE_LINE, FONT_STRUCKOUT_LINE,
12, 0);
logfontbig24 = CreateLogFont (NULL, "ming", "BIG5",
FONT_WEIGHT_REGULAR, FONT_SLANT_ROMAN, FONT_FLIP_NONE,
FONT_OTHER_NIL, FONT_UNDERLINE_LINE, FONT_STRUCKOUT_NONE,
24, 0);

◆ CreateLogFontByName()

PLOGFONT GUIAPI CreateLogFontByName ( const char *  font_name)

Creates a logical font by a font name.

This function creates a logical font by a font name specified by font_name. Note that since version 4.0.0, you can specify up to 7 family names in the LOGFONT name, such as:

 ttf-Courier,宋体,Naskh,SansSerif-rrncns-U-16-UTF-8

In this way, you can specify a logfont to use multiple devfonts to render a complex text. This is useful when different glyphs are contained in different font files. It is well known that, a font is often designed for a particular language/script or a few similar languages/scripts.

Since 4.0.0, the previous width field of a logfont name is used for the glyph orientation:

  • 'U': Glyphs stand upright (default).
  • 'S': Glyphs are rotated 90 degrees clockwise (sideways).
  • 'D': Glyphs are upside-down.
  • 'L': Glyphs are rotated 90 degrees counter-clockwise (sideways left).
Parameters
font_nameThe name of the logfont.
Returns
The pointer to the logical font created, NULL on error.
See also
CreateLogFont, SelectFont

◆ CreateLogFontEx()

PLOGFONT GUIAPI CreateLogFontEx ( const char *  type,
const char *  family,
const char *  charset,
char  weight,
char  slant,
char  flip,
char  other,
char  decoration,
char  rendering,
int  size,
int  rotation 
)

Creates a logical font.

This function creates a logical font.

Parameters
typeThe type of the logical font, can be one of the values:
  • FONT_TYPE_NAME_BITMAP_RAW
    Creates a logical font by using raw bitmap device font, i.e. mono-space bitmap font.
  • FONT_TYPE_NAME_BITMAP_VAR
    Creates a logical font by using var-width bitmap device font.
  • FONT_TYPE_NAME_BITMAP_QPF
    Creates a logical font by using qpf device font.
  • FONT_TYPE_NAME_BITMAP_BMP
    Creates a logical font by using bitmap font.
  • FONT_TYPE_NAME_SCALE_TTF
    Creates a logical font by using scalable TrueType device font.
  • FONT_TYPE_NAME_SCALE_T1F
    Creates a logical font by using scalable Adobe Type1 device font.
  • FONT_TYPE_NAME_ANY
    Creates a logical font by using any type device font.
familyThe family of the logical font, such as "Courier", "Helvetica", and so on. Since version 4.0.0, you can specify up to 7 family names separated by comma, e.g., "Helvetica,黑体,Naskh,SansSerif". Note that a family name should be encoded in UTF-8 and without special characters (middle spaces are allowed).
charsetThe charset of the logical font. You can specify a sigle-byte charset like "ISO8859-1", or a multi-byte charset like "GB2312-0" and "UTF-8".
weightThe weight of the logical font, can be one of the values:
  • FONT_WEIGHT_ANY
    Any one.
  • FONT_WEIGHT_THIN
    Thin.
  • FONT_WEIGHT_EXTRA_LIGHT
    Extra light (Ultra light).
  • FONT_WEIGHT_LIGHT
    Light.
  • FONT_WEIGHT_NORMAL
    Normal.
  • FONT_WEIGHT_REGULAR
    Regular.
  • FONT_WEIGHT_MEDIUM
    Medium.
  • FONT_WEIGHT_DEMIBOLD
    Semi Bold (Demi Bold).
  • FONT_WEIGHT_BOLD
    Bold.
  • FONT_WEIGHT_EXTRA_BOLD
    Extra bold (Ultra Bold).
  • FONT_WEIGHT_BLACK
    Black (Heavy).
slantThe slant of the logical font, can be one of the values:
  • FONT_SLANT_ANY
    Any one.
  • FONT_SLANT_ROMAN
    Regular font.
  • FONT_SLANT_ITALIC
    Italic font.
  • FONT_SLANT_OB
    Italic font.
flipDoes flip the glyph of the font, can be one of the following values:
  • FONT_FLIP_NONE
    Do not flip the glyph.
  • FONT_FLIP_HORZ
    Flip the glyph horizontally .
  • FONT_FLIP_VERT
    Flip the glyph vertically.
  • FONT_FLIP_HORZVERT
    Flip the glyph horizontally and vertically.
otherOther rendering features, can be one of the following values:
  • FONT_OTHER_NONE
    Not specified.
  • FONT_OTHER_AUTOSCALE
    Auto scale the bitmap glyph to match the desired font size.
  • FONT_OTHER_TTFNOCACHE
    Do not use cache when using TrueType font.
  • FONT_OTHER_TTFKERN
    Kern the glyph when using TrueType font.
  • FONT_OTHER_TTFNOCACHEKERN
    When using TrueType font, kern the glyph and do not use cache.
  • FONT_OTHER_LCDPORTRAIT
    When using TrueType font and sub-pixels smoothing strategy, set lcd portrait and do not use kern the glyph.
  • FONT_OTHER_LCDPORTRAITKERN
    When using TrueType font and sub-pixels smoothing strategy, set lcd portrait and use kern the glyph.
decorationThe decoration (underline and/or struckout line) of the logical font, can be one of the values:
  • FONT_DECORATE_NONE
    Without underline and struckout line.
  • FONT_DECORATE_UNDERLINE
    With underline.
  • FONT_DECORATE_STRUCKOUT
    With struckout line.
  • FONT_DECORATE_BOTH
    With both underline and struckout line.
renderingThe rendering type of the logical font, can be one of the values:
  • FONT_RENDER_ANY
    Any one (not specified).
  • FONT_RENDER_MONO
    Use a monochromatic bitmap.
  • FONT_RENDER_OUTLINE
    Render the glyph with an outline.
  • FONT_RENDER_GREY
    Render the glyph by using a gray bitmap.
  • FONT_RENDER_SUBPIXEL
    Use subpixel rendering method (TrueType only).
sizeThe size, i.e. the height, of the logical font. Note that the size of the created logical font may be different from the size expected.
rotationThe rotation of the logical font, it is in units of tenth degrees. Note that you can specify rotation only for TrueType and Adobe Type1 fonts.
Returns
The pointer to the logical font created, NULL on error.
See also
CreateLogFontIndirect, CreateLogFontByName, SelectFont

Example:

static LOGFONT *logfont, *logfontgb12, *logfontttf;
logfont = CreateLogFontEx (NULL, "SansSerif", "ISO8859-1",
FONT_WEIGHT_REGULAR, FONT_SLANT_ITALIC, FONT_FLIP_NONE,
FONT_OTHER_NIL, FONT_DECORATE_NONE, FONT_RENDER_MONO,
16, 0);
logfontgb12 = CreateLogFontEx (NULL, "song", "GB2312",
FONT_WEIGHT_REGULAR, FONT_SLANT_ROMAN, FONT_FLIP_NONE,
FONT_OTHER_NIL, FONT_DECORATE_NONE, FONT_RENDER_MONO,
12, 0);
logfontttf = CreateLogFontEx ("ttf", "Courier", "UTF-8",
FONT_WEIGHT_BLACK, FONT_SLANT_ROMAN, FONT_FLIP_NONE,
FS_OTHER_LCDPORTRAIT, FONT_DECORATE_NONE, FONT_RENDER_SUBPIXEL,
24, 0);

◆ CreateLogFontForMChar2UChar()

PLOGFONT GUIAPI CreateLogFontForMChar2UChar ( const char *  charset)

Create a logical font for conversion from multi-byte character string to Uchar32 string.

This function creates a logical font in order to convert a multi-byte character string to Uchar32 string. You can use this logfont for GetUCharsUntilParagraphBoundary.

Parameters
charsetThe charset name of the multi-byte character string.
Returns
The pointer to the logical font created, NULL on error.
See also
DestroyLogFont, GetUCharsUntilParagraphBoundary

Since 4.0.0

◆ CreateLogFontIndirect()

PLOGFONT GUIAPI CreateLogFontIndirect ( LOGFONT logfont)

Creates a logical font indirectly from a LOGFONT structure.

This function creates a logical font from information in a LOGFONT object.

Parameters
logfontThe pointer to the reference logical font structure.
Returns
The pointer to the logical font created, NULL on error.
See also
CreateLogFont, SelectFont

◆ CreateLogFontIndirectEx()

PLOGFONT GUIAPI CreateLogFontIndirectEx ( LOGFONT logfont,
int  rotation 
)

Creates a new logical font indirectly from a LOGFONT structure with a rotation degrees.

This function creates a new logical font from information in the LOGFONT object logfont and the new rotation value rotation.

Since 4.0.0.

Parameters
logfontThe pointer to the reference logical font structure.
rotationThe rotation of the logical font, it is in units of tenth degrees. Note that you can specify rotation only for vector fonts (use FreeType2 font engine).
Returns
The pointer to the logical font created, NULL on error. If rotation is not zero and the devfonts of the logfont does not support rotation, it returns NULL.
See also
CreateLogFont, CreateLogFontIndirect, SelectFont

◆ DestroyDynamicDevFont()

void GUIAPI DestroyDynamicDevFont ( DEVFONT **  devfont)

Destroy device font loaded dynamically from font file.

Parameters
devfontThe double pointer to DEVFONT structure. Note that the pointer must be the double pointer to device font loaded by LoadDevFontFromFile.
See also
LoadDevFontFromFile

◆ DestroyLogFont()

void GUIAPI DestroyLogFont ( PLOGFONT  log_font)

Destroys a logical font.

This function destroys the specified logical font log_font.

Parameters
log_fontThe logical font will be destroied.
See also
CreateLogFont, CreateLogFontIndirect

◆ ft2SetLcdFilter()

BOOL ft2SetLcdFilter ( LOGFONT logfont,
FT2LCDFilter  filter 
)

Set freetype2 smooth mode.

This function can be used to set freetype2 library handle font smooth mode.

Parameters
logfontThe logical font.
filterThe handle font smooth mode, it must be a value of FT2LCDFilter.
Returns
TRUE on success, otherwise FALSE.
See also
FT2LCDFilter

◆ GetCurFont()

PLOGFONT GUIAPI GetCurFont ( HDC  hdc)

Get the pointer to the current logical font of a DC.

This function returns the pointer to the current logical font selected to the DC hdc.

Parameters
hdcThe device context.
Returns
The pointer to the current logical font.
See also
GetLogFontInfo, SelectFont

◆ GetFontMetrics()

void GUIAPI GetFontMetrics ( LOGFONT log_font,
FONTMETRICS font_metrics 
)

Get metrics information of a logical font.

This function returns the font metrics information of the specified logical font log_font.

Parameters
log_fontThe pointer to the logical font.
font_metricsThe buffer receives the metrics information.
Returns
None.
See also
GetGlyphInfo, FONTMETRICS

◆ GetGlyphBitmap()

void GUIAPI GetGlyphBitmap ( LOGFONT log_font,
const char *  mchar,
int  mchar_len,
GLYPHBITMAP glyph_bitmap 
)

Get the glyph bitmap information when uses a logical font to output a multi-byte character.

This function gets the glyph bitmap of one multi-byte character (specified by mchar and mchar_len) and returns the bitmap information through font_bitmap when using log_font to render the character.

Parameters
log_fontThe logical font used to render the character.
mcharThe pointer to the multi-byte character.
mchar_lenThe length of the multi-byte character.
glyph_bitmapThe buffer receives the glyph bitmap information.
Returns
None.

Example:

GLYPHBITMAP glyph_bitmap = {0};
GetGlyphBitmap (log_font, "A", 1, &glyph_bitmap);
Note
Deprecated. This function is a legacy implementation. New applications should use GetGlyphInfo instead.
See also
GetFontMetrics, GLYPHBITMAP, GetGlyphInfo

◆ GetLogFontInfo()

void GUIAPI GetLogFontInfo ( HDC  hdc,
LOGFONT log_font 
)

Get logical font information of a DC.

This function gets the logical font information of the specified DC hdc, and copies to the LOGFONT structure pointed to by log_font.

Parameters
hdcThe device context.
log_fontThe pointer to the LOGFONT structure to save the logical font info.
See also
GetCurFont

◆ GetNextDevFont()

const DEVFONT *GUIAPI GetNextDevFont ( const DEVFONT dev_font)

Get next devfont information.

This function can be used to enumerate all device fonts loaded by MiniGUI.

Parameters
dev_fontThe pointer to the current device font, can be NULL to get the first device font.
Returns
The next device font.

◆ InitVectorialFonts()

BOOL GUIAPI InitVectorialFonts ( void  )
inlinestatic

Initializes vectorial font renderer.

Before 5.0.0, for the performance reason, under MiniGUI-Processes and MiniGUI-Standalone runtime modes, MiniGUI does not load vector fonts, such as TrueType or Adobe Type 1, at startup automatically. This function initializes the vector font engines for MiniGUI-Processes and MiniGUI-Standalone apps. If you want to render text in vector fonts, you must call this function to initialize the vector font engines.

Since 5.0.0, MiniGUI always initialize the vector font engines at startup if it was configured for all runtime modes.

Returns
Always return TRUE.
See also
TermVectorialFonts

Definition at line 7706 of file gdi.h.

◆ LoadDevFontFromFile()

DEVFONT *GUIAPI LoadDevFontFromFile ( const char *  devfont_name,
const char *  file_name 
)

Load device font from font file.

This function can be used to load device font from font file.Now,it support free type font file and qpf font file.

Parameters
devfont_nameThe device font name.
file_nameThe font file name.
Returns
the pointer to the new device font on success, NULL on error.
See also
GetNextDevFont, DestroyDynamicDevFont

◆ LoadDevFontFromIncoreData()

DEVFONT *GUIAPI LoadDevFontFromIncoreData ( const char *  devfont_name,
const void *  data 
)

Load device font from incore data.

This function can be used to load device font from incore data.

Parameters
devfont_nameThe device font name.
dataThe pointer to the incore font data.
Returns
the pointer to the new device font on success, NULL on error.
See also
GetNextDevFont, DestroyDynamicDevFont

◆ SelectFont()

PLOGFONT GUIAPI SelectFont ( HDC  hdc,
PLOGFONT  log_font 
)

Selects a logical font into a DC.

This function selects the specified logical font log_font into the device context hdc.

Parameters
hdcThe device context.
log_fontThe pointer to the logical font to be selected into the DC.
Returns
The old logical font of the DC.
See also
GetCurFont

Example:

void OnModeDrawText (HDC hdc)
{
RECT rc1, rc2, rc3, rc4;
const char* szBuff1 = "This is a good day. \n"
"This text is drawn by calling DrawText.";
const char* szBuff2 = "This is a good day. \n"
"This text is drawn by calling DrawText.";
const char* szBuff3 = "Single line text, center.";
const char* szBuff4 =
"This text is drawn by calling DrawText.";
rc1.left = 1; rc1.top = 1; rc1.right = 401; rc1.bottom = 101;
rc2.left = 0; rc2.top = 110; rc2.right = 401; rc2.bottom = 351;
rc3.left = 0; rc3.top = 361; rc3.right = 401; rc3.bottom = 451;
rc4.left = 0; rc4.top = 461; rc4.right = 401; rc4.bottom = 551;
Rectangle (hdc, rc1.left, rc1.top, rc1.right, rc1.bottom);
Rectangle (hdc, rc2.left, rc2.top, rc2.right, rc2.bottom);
Rectangle (hdc, rc3.left, rc3.top, rc3.right, rc3.bottom);
Rectangle (hdc, rc4.left, rc4.top, rc4.right, rc4.bottom);
InflateRect (&rc1, -1, -1);
InflateRect (&rc2, -1, -1);
InflateRect (&rc3, -1, -1);
InflateRect (&rc4, -1, -1);
SelectFont (hdc, logfontgb12);
DrawText (hdc, szBuff1, -1, &rc1, DT_NOCLIP | DT_CENTER | DT_WORDBREAK);
SelectFont (hdc, logfontgb16);
DrawText (hdc, szBuff2, -1, &rc2, DT_NOCLIP | DT_RIGHT | DT_WORDBREAK);
SelectFont (hdc, logfontgb24);
DrawText (hdc, szBuff3, -1, &rc3, DT_NOCLIP | DT_SINGLELINE | DT_CENTER | DT_VCENTER);
SelectFont (hdc, logfontgb16);
DrawTextEx (hdc, szBuff4, -1, &rc4, 32, DT_NOCLIP | DT_LEFT | DT_WORDBREAK);
}

◆ TermVectorialFonts()

void GUIAPI TermVectorialFonts ( void  )
inlinestatic

Terminates vectorial font renderer.

Before 5.0.0, this function terminates the vector font engines. When you are done with the vector fonts, you should call this function to unload the vector fonts to save memory.

Since 5.0.0, MiniGUI always initialize the FreeType fonts at startup if it was configured for all runtime modes. Therefore, this function does nothing.

See also
InitVectorialFonts

Definition at line 7726 of file gdi.h.

Variable Documentation

◆ CPLOGFONT

typedef LOGFONT * CPLOGFONT

Data type of pointer to a LOGFONT.

Definition at line 6519 of file gdi.h.

RGBA_lightwhite
#define RGBA_lightwhite
Definition: gdi.h:540
DWORD2Pixel
static gal_pixel DWORD2Pixel(HDC hdc, DWORD dword)
An inline function to convert DWORD color to gal_pixel.
Definition: gdi.h:3318
CreateLogFontEx
MG_EXPORT PLOGFONT GUIAPI CreateLogFontEx(const char *type, const char *family, const char *charset, char weight, char slant, char flip, char other, char decoration, char rendering, int size, int rotation)
Creates a logical font.
_RECT::right
int right
Definition: common.h:948
NULL
#define NULL
A value indicates null pointer.
Definition: common.h:369
HDC
GHANDLE HDC
Handle to device context.
Definition: common.h:412
_LOGFONT
Definition: gdi.h:6478
SetBkColor
#define SetBkColor(hdc, color)
Set the background color of a DC to a new value.
Definition: gdi.h:2606
_RECT
Definition: common.h:936
InflateRect
static void InflateRect(RECT *prc, int cx, int cy)
Increases or decreases the width and height of an rectangle.
Definition: gdi.h:5951
DrawText
#define DrawText(hdc, text, n, rc, format)
Draws a formatted text in a rectangle.
Definition: gdi.h:10976
_RECT::bottom
int bottom
Definition: common.h:952
_GLYPHBITMAP
Definition: gdi.h:7641
SelectFont
MG_EXPORT PLOGFONT GUIAPI SelectFont(HDC hdc, PLOGFONT log_font)
Selects a logical font into a DC.
Rectangle
MG_EXPORT void GUIAPI Rectangle(HDC hdc, int x0, int y0, int x1, int y1)
Draws a rectangle.
CreateLogFont
MG_EXPORT PLOGFONT GUIAPI CreateLogFont(const char *type, const char *family, const char *charset, char weight, char slant, char flip, char other, char underline, char struckout, int size, int rotation)
Creates a logical font.
GetGlyphBitmap
MG_EXPORT void GUIAPI GetGlyphBitmap(LOGFONT *log_font, const char *mchar, int mchar_len, GLYPHBITMAP *glyph_bitmap)
Get the glyph bitmap information when uses a logical font to output a multi-byte character.
DrawTextEx
#define DrawTextEx(hdc, text, n, rc, indent, format)
Draws a formatted text in a rectangle.
Definition: gdi.h:10987
_RECT::top
int top
Definition: common.h:944
_RECT::left
int left
Definition: common.h:940