mirror of
https://github.com/VincentWei/MiniGUI.git
synced 2026-09-25 19:13:46 +08:00
tune __mg_ft2_get_face return filename and face
This commit is contained in:
@@ -774,7 +774,7 @@ static void get_kerning (LOGFONT* logfont, DEVFONT* devfont,
|
||||
static void* get_ft_face (LOGFONT* logfont, DEVFONT* devfont)
|
||||
{
|
||||
FTFACEINFO* ft_face_info = FT_FACE_INFO_P (devfont);
|
||||
return ft_face_info->face;
|
||||
return ft_face_info;
|
||||
}
|
||||
|
||||
#ifdef _MGFONT_TTF_CACHE
|
||||
@@ -1032,11 +1032,9 @@ static void* load_font_data (DEVFONT* devfont,
|
||||
|
||||
FT_LOCK(&ft_lock);
|
||||
|
||||
#ifdef _MGFONT_TTF_CACHE
|
||||
ft_face_info->filepathname = strdup (file_name);
|
||||
if (ft_face_info->filepathname == NULL)
|
||||
goto error;
|
||||
#endif
|
||||
|
||||
error = FT_New_Face(ft_library, file_name, 0, &ft_face_info->face);
|
||||
face = ft_face_info->face;
|
||||
@@ -1135,9 +1133,7 @@ error_free:
|
||||
static void unload_font_data (DEVFONT* devfont, void* data)
|
||||
{
|
||||
FT2_DATA* ft_data = (FT2_DATA*)data;
|
||||
#ifdef _MGFONT_TTF_CACHE
|
||||
free(ft_data->ft_face_info->filepathname);
|
||||
#endif
|
||||
FT_Done_Face((ft_data->ft_face_info)->face);
|
||||
free(ft_data->ft_face_info);
|
||||
free(ft_data->ft_inst_info);
|
||||
@@ -1281,9 +1277,9 @@ FONTOPS __mg_ttf_ops = {
|
||||
};
|
||||
|
||||
/* Get the FreeType2 face object for HarfBuzz shaping engine */
|
||||
void* __mg_ft2_get_face(LOGFONT* lf, Uchar32 uc, int* dfi)
|
||||
const FT2INFO* __mg_ft2_get_face(LOGFONT* lf, Uchar32 uc, int* dfi)
|
||||
{
|
||||
void* face = NULL;
|
||||
const FT2INFO* face = NULL;
|
||||
DEVFONT* df;
|
||||
int i;
|
||||
|
||||
|
||||
@@ -74,13 +74,13 @@ typedef int (* MakeHashKeyFunc)(Glyph32 gv);
|
||||
#endif
|
||||
|
||||
typedef struct tagFTFACEINFO {
|
||||
#ifdef _MGFONT_TTF_CACHE
|
||||
char* filepathname;
|
||||
FT_Face face;
|
||||
BOOL valid;
|
||||
#ifdef _MGFONT_TTF_CACHE
|
||||
int face_index;
|
||||
int cmap_index;
|
||||
#endif
|
||||
FT_Face face;
|
||||
BOOL valid;
|
||||
} FTFACEINFO, *PFTFACEINFO;
|
||||
|
||||
typedef struct tagFTINSTANCEINFO {
|
||||
|
||||
@@ -348,7 +348,13 @@ typedef struct {
|
||||
} FONTOPS_INFO;
|
||||
|
||||
extern FONTOPS_INFO __mg_fontops_infos[];
|
||||
void* __mg_ft2_get_face(LOGFONT* lf, Uchar32 uc, int* dfi);
|
||||
|
||||
typedef struct tagFT2FILEANDFACE {
|
||||
char* filepathname;
|
||||
void* face;
|
||||
} FT2INFO;
|
||||
|
||||
const FT2INFO* __mg_ft2_get_face(LOGFONT* lf, Uchar32 uc, int* dfi);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ static hb_font_t* get_hb_font_for_script(SEInstance* inst,
|
||||
LOGFONT* lf, ScriptType st, Uchar32 uc, int* dfi)
|
||||
{
|
||||
struct list_head* f;
|
||||
FT_Face face;
|
||||
const FT2INFO* file_face;
|
||||
hb_font_t* hb_font;
|
||||
//hb_face_t* hb_face;
|
||||
FtFontInfo *new_fi;
|
||||
@@ -98,14 +98,14 @@ static hb_font_t* get_hb_font_for_script(SEInstance* inst,
|
||||
}
|
||||
}
|
||||
|
||||
face = (FT_Face)__mg_ft2_get_face(lf, uc, dfi);
|
||||
if (face == NULL) {
|
||||
file_face = __mg_ft2_get_face(lf, uc, dfi);
|
||||
if (file_face == NULL) {
|
||||
_WRN_PRINTF("Cannot get FT2 face for logfont (%p) and uc (0x%x)\n",
|
||||
lf, uc);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
hb_font = hb_ft_font_create_referenced(face);
|
||||
hb_font = hb_ft_font_create_referenced(file_face->face);
|
||||
//hb_font = hb_ft_font_create(face, NULL);
|
||||
if (hb_font == NULL)
|
||||
return NULL;
|
||||
@@ -115,7 +115,7 @@ static hb_font_t* get_hb_font_for_script(SEInstance* inst,
|
||||
new_fi = mg_slice_new(FtFontInfo);
|
||||
new_fi->lf = lf;
|
||||
new_fi->st = st;
|
||||
new_fi->face = face;
|
||||
new_fi->face = file_face->face;
|
||||
new_fi->hb_font = hb_font;
|
||||
//new_fi->hb_face = hb_face;
|
||||
new_fi->dfi = *dfi;
|
||||
|
||||
Reference in New Issue
Block a user