Enhance GetGlyphInfo to return the FreeType face, font file path, and glyph index

This commit is contained in:
Vincent Wei
2021-05-11 10:41:54 +08:00
parent a85386499e
commit 754b8f3014
3 changed files with 38 additions and 0 deletions
+2
View File
@@ -36,6 +36,8 @@ In this version, we fixed some bugs and made some optimizations and enhancements
- Fix memory leaks when using block heap.
- Fix a bug in ServerGetWinZNodeRegion.
* ENHANCEMENTS:
- Enhance `GetGlyphInfo` to return the FreeType face, font file path, and glyph
index.
- NEW API `StretchBltEx` to support different scaling filters and rotation.
- Use Pixman to support color blending methods for `BitBlt` and `StretchBlt`.
- Enhance fallback compositor to support animation when switching among layers.
+12
View File
@@ -12951,6 +12951,7 @@ MG_EXPORT int GUIAPI GetGlyphsExtentPoint (HDC hdc, Glyph32* glyphs,
#define GLYPH_INFO_METRICS 0x01
#define GLYPH_INFO_BMP 0x02
#define GLYPH_INFO_FACE 0x04
/** The type of glyph bitmap: monochrome */
#define GLYPHBMP_TYPE_MONO 0x00
@@ -12973,6 +12974,7 @@ typedef struct _GLYPHINFO {
* or bitmap infomation. Or'ed with the following values:
* - GLYPH_INFO_METRICS
* - GLYPH_INFO_BMP
* - GLYPH_INFO_FACE
*/
Uint32 mask;
@@ -13005,6 +13007,16 @@ typedef struct _GLYPHINFO {
* It is only valid if bmp_type is GLYPHBMP_TYPE_PRERENDER
*/
BITMAP prbitmap;
/**
* The FreeType face, font file path, and the glyph index
* (when mask has GLYPH_INFO_FACE set).
* You can use these information to render the glyph by yourself.
* Only available if the device font is a TrueType/OpenType font.
*/
void* ft_face;
const char* file_path;
Uint32 index;
} GLYPHINFO;
/**
+24
View File
@@ -198,6 +198,30 @@ int GUIAPI GetGlyphInfo (LOGFONT* logfont, Glyph32 glyph_value,
}
}
/* get FreeType face and glyph index */
if (glyph_info->mask & GLYPH_INFO_FACE) {
glyph_info->index = glyph_value;
if (devfont->font_ops->get_ft_face) {
/* keep sync with tagFTFACEINFO in freetype2.h */
struct _FTFACEINFO {
char* path;
void* face;
};
struct _FTFACEINFO* face_info = (struct _FTFACEINFO*)
devfont->font_ops->get_ft_face (logfont, devfont);
assert (face_info);
glyph_info->ft_face = face_info->face;
glyph_info->file_path = face_info->path;
}
else {
glyph_info->ft_face = NULL;
glyph_info->file_path = NULL;
}
}
glyph_info->bmp_width = sz.cx;
glyph_info->bmp_height = sz.cy;
return 0;