merge some changes from dev-3-4 for fix some bugs about freetype2 font engine and vbf font engine.

This commit is contained in:
Vincent Wei
2019-03-04 12:55:09 +08:00
parent ea20032dae
commit 3b61f25bb5
10 changed files with 353 additions and 323 deletions
+142 -150
View File
File diff suppressed because it is too large Load Diff
+5 -5
View File
@@ -440,7 +440,7 @@ static int get_glyph_bbox (LOGFONT* logfont, DEVFONT* devfont,
/* call this function to get the bitmap/pixmap of the char */
static const void*
char_bitmap_pixmap (LOGFONT* logfont, DEVFONT* devfont,
const Glyph32 glyph_value, int* pitch, BOOL is_grey)
const Glyph32 glyph_value, SIZE* sz, int* pitch, BOOL is_grey)
{
TT_Raster_Map Raster;
TT_Error error;
@@ -538,17 +538,17 @@ char_bitmap_pixmap (LOGFONT* logfont, DEVFONT* devfont,
}
static const void* get_glyph_monobitmap (LOGFONT* logfont, DEVFONT* devfont,
const Glyph32 glyph_value, int* pitch, unsigned short* scale)
const Glyph32 glyph_value, SIZE* sz, int* pitch, unsigned short* scale)
{
if (scale) *scale = 1;
return char_bitmap_pixmap (logfont, devfont, glyph_value, pitch, FALSE);
return char_bitmap_pixmap (logfont, devfont, glyph_value, sz, pitch, FALSE);
}
static const void* get_glyph_greybitmap (LOGFONT* logfont, DEVFONT* devfont,
const Glyph32 glyph_value, int* pitch, unsigned short* scale)
const Glyph32 glyph_value, SIZE* sz, int* pitch, unsigned short* scale)
{
if (scale) *scale = 1;
return char_bitmap_pixmap (logfont, devfont, glyph_value, pitch, TRUE);
return char_bitmap_pixmap (logfont, devfont, glyph_value, sz, pitch, TRUE);
}
/* call this function after getting the bitmap/pixmap of the char
+159 -135
View File
File diff suppressed because it is too large Load Diff
+12 -11
View File
@@ -63,13 +63,12 @@ extern "C" {
#ifdef _MGFONT_TTF_CACHE
typedef unsigned long HCACHE;
typedef int (* MakeHashKeyFunc)(unsigned short unicode);
typedef int (* MakeHashKeyFunc)(UChar32 unicode);
#endif
typedef struct tagFTFACEINFO {
#ifdef _MGFONT_TTF_CACHE
/*should be MAX_PATH*/
char filepathname[256];
char* filepathname;
int face_index;
int cmap_index;
#else
@@ -114,26 +113,28 @@ typedef struct tagFTINSTANCEINFO {
#define _TTF_HASH_NDIR 37
typedef struct tagTTFCACHEINFO {
unsigned short unicode;
short glyph_code;
UChar32 unicode;
FT_UInt glyph_code;
FT_Vector advance;
FT_BBox bbox;
FT_Vector delta;
int flag;
int pitch;
int width;
int height;
void *bitmap;
} TTFCACHEINFO, *PTTFCACHEINFO;
extern HCACHE __mg_ttc_create(char *family, char *charset, DWORD style, int size,
int nblk, int blksize, int ndir, MakeHashKeyFunc makeHashKey);
extern HCACHE __mg_ttc_create(const char *df_name,
int style, int size, int rotation,
int nblk, int blksize, int ndir, MakeHashKeyFunc makeHashKey);
extern HCACHE __mg_ttc_is_exist(const char *df_name,
int style, int size, int rotation);
extern int __mg_ttc_write(HCACHE hCache, TTFCACHEINFO *data, int size);
extern void __mg_ttc_release(HCACHE hCache);
extern int __mg_ttc_sys_init(int maxCache, int cacheSize);
extern void __mg_ttc_sys_deinit(void);
extern TTFCACHEINFO *__mg_ttc_search(HCACHE hCache,
unsigned short unicode, int *size);
extern HCACHE __mg_ttc_is_exist(char *family, char *charset,
DWORD style, int size);
extern TTFCACHEINFO *__mg_ttc_search(HCACHE hCache, UChar32 unicode, int *size);
extern void __mg_ttc_refer(HCACHE hCache);
#endif
+3 -3
View File
@@ -329,7 +329,7 @@ static int get_font_descent (LOGFONT* logfont, DEVFONT* devfont)
}
static const void* get_glyph_monobitmap (LOGFONT* logfont, DEVFONT* devfont,
const Glyph32 glyph_value, int* pitch, unsigned short* scale)
const Glyph32 glyph_value, SIZE* sz, int* pitch, unsigned short* scale)
{
unsigned int uc16;
QPF_GLYPH* glyph;
@@ -345,7 +345,7 @@ static const void* get_glyph_monobitmap (LOGFONT* logfont, DEVFONT* devfont,
if (uc16 < 0x80 && logfont->sbc_devfont != devfont) { /* ASCII */
unsigned char ascii_ch = uc16;
return logfont->sbc_devfont->font_ops->get_glyph_monobitmap (logfont,
logfont->sbc_devfont, ascii_ch, pitch, scale);
logfont->sbc_devfont, ascii_ch, sz, pitch, scale);
}
else
glyph = &def_glyph;
@@ -365,7 +365,7 @@ static const void* get_glyph_monobitmap (LOGFONT* logfont, DEVFONT* devfont,
}
static const void* get_glyph_greybitmap (LOGFONT* logfont, DEVFONT* devfont,
Glyph32 glyph_value, int* pitch, unsigned short* scale)
Glyph32 glyph_value, SIZE* sz, int* pitch, unsigned short* scale)
{
unsigned int uc16;
QPF_GLYPH* glyph;
+1 -1
View File
@@ -208,7 +208,7 @@ static int get_font_descent (LOGFONT* logfont, DEVFONT* devfont)
}
static const void* get_glyph_monobitmap (LOGFONT* logfont, DEVFONT* devfont,
const Glyph32 glyph_value, int* pitch, unsigned short* scale)
const Glyph32 glyph_value, SIZE* sz, int* pitch, unsigned short* scale)
{
int bitmap_size;
Glyph32 glyph_tmp = glyph_value;
+3 -3
View File
@@ -279,7 +279,7 @@ print_bitmap(char* bits, int width, int height, int pitch)
#endif
static const void* get_glyph_monobitmap (LOGFONT* logfont, DEVFONT* devfont,
const Glyph32 glyph_value, int* pitch, unsigned short* scale)
const Glyph32 glyph_value, SIZE* sz, int* pitch, unsigned short* scale)
{
unsigned int uc16;
UPFGLYPH* glyph;
@@ -300,7 +300,7 @@ static const void* get_glyph_monobitmap (LOGFONT* logfont, DEVFONT* devfont,
if (uc16 < 0x80 && logfont->sbc_devfont != devfont) { /* ASCII */
unsigned char ascii_ch = uc16;
return logfont->sbc_devfont->font_ops->get_glyph_monobitmap (logfont,
logfont->sbc_devfont, ascii_ch, pitch, scale);
logfont->sbc_devfont, ascii_ch, sz, pitch, scale);
}
else
glyph = &def_glyph;
@@ -326,7 +326,7 @@ static const void* get_glyph_monobitmap (LOGFONT* logfont, DEVFONT* devfont,
}
static const void* get_glyph_greybitmap (LOGFONT* logfont, DEVFONT* devfont,
Glyph32 glyph_value, int* pitch, unsigned short* scale)
Glyph32 glyph_value, SIZE* sz, int* pitch, unsigned short* scale)
{
unsigned int uc16;
UPFGLYPH* glyph;
+4 -1
View File
@@ -111,6 +111,9 @@ static int get_ch_width (LOGFONT* logfont, DEVFONT* devfont,
if (vbf_info->bits_offset == NULL)
return vbf_info->max_width * scale;
if (glyph_value < vbf_info->first_glyph || glyph_value > vbf_info->last_glyph)
glyph_value = vbf_info->def_glyph;
return vbf_info->advance_x [glyph_value - vbf_info->first_glyph] * scale;
}
@@ -234,7 +237,7 @@ static int get_glyph_advance (LOGFONT* logfont, DEVFONT* devfont,
}
static const void* get_glyph_monobitmap (LOGFONT* logfont, DEVFONT* devfont,
const Glyph32 glyph_value, int* pitch, unsigned short* scale)
const Glyph32 glyph_value, SIZE* sz, int* pitch, unsigned short* scale)
{
int offset;
Glyph32 eff_value = glyph_value;
+2 -2
View File
@@ -225,11 +225,11 @@ struct _FONTOPS
/** The method to get mono-bitmap function. */
const void* (*get_glyph_monobitmap) (LOGFONT* logfont, DEVFONT* devfont,
const Glyph32 glyph_value, int* pitch, unsigned short* scale);
const Glyph32 glyph_value, SIZE* sz, int* pitch, unsigned short* scale);
/** The method to get grey bitmap, pitch and scale function */
const void* (*get_glyph_greybitmap) (LOGFONT* logfont, DEVFONT* devfont,
const Glyph32 galph_value, int* pitch, unsigned short* scale);
const Glyph32 galph_value, SIZE* sz, int* pitch, unsigned short* scale);
/** The method to get the pre-rendered bitmap of one glyph. */
int (*get_glyph_prbitmap) (LOGFONT* logfont, DEVFONT* devfont,
+22 -12
View File
@@ -203,6 +203,7 @@ int GUIAPI GetGlyphInfo (LOGFONT* logfont, Glyph32 glyph_value,
{
int advance = 0;
int pitch = 0;
SIZE sz;
/* get the relative device font*/
DEVFONT* devfont = SELECT_DEVFONT(logfont, glyph_value);
@@ -240,6 +241,9 @@ int GUIAPI GetGlyphInfo (LOGFONT* logfont, Glyph32 glyph_value,
glyph_info->advance_x++;
}
sz.cx = glyph_info->bbox_w;
sz.cy = glyph_info->bbox_h;
/*get height and descent of devfont*/
if (glyph_info->mask & GLYPH_INFO_METRICS)
{
@@ -256,7 +260,9 @@ int GUIAPI GetGlyphInfo (LOGFONT* logfont, Glyph32 glyph_value,
switch (glyph_info->bmp_type) {
case GLYPHBMP_TYPE_MONO:
glyph_info->bits = devfont->font_ops->get_glyph_monobitmap (
logfont, devfont, glyph_value, &pitch, NULL);
logfont, devfont, glyph_value, &sz, &pitch, NULL);
glyph_info->bbox_w = sz.cx;
glyph_info->bbox_h = sz.cy;
glyph_info->bmp_pitch = pitch;
glyph_info->bmp_size = pitch * glyph_info->bbox_h;
break;
@@ -264,7 +270,9 @@ int GUIAPI GetGlyphInfo (LOGFONT* logfont, Glyph32 glyph_value,
case GLYPHBMP_TYPE_GREY:
glyph_info->bits = devfont->font_ops->get_glyph_greybitmap (
logfont, devfont, glyph_value,
&glyph_info->bmp_pitch, NULL);
&sz, &glyph_info->bmp_pitch, NULL);
glyph_info->bbox_w = sz.cx;
glyph_info->bbox_h = sz.cy;
glyph_info->bmp_size =
glyph_info->bmp_pitch * glyph_info->bbox_h;
break;
@@ -272,7 +280,9 @@ int GUIAPI GetGlyphInfo (LOGFONT* logfont, Glyph32 glyph_value,
case GLYPHBMP_TYPE_SUBPIXEL:
glyph_info->bits = devfont->font_ops->get_glyph_greybitmap (
logfont, devfont, glyph_value,
&glyph_info->bmp_pitch, NULL);
&sz, &glyph_info->bmp_pitch, NULL);
glyph_info->bbox_w = sz.cx;
glyph_info->bbox_h = sz.cy;
glyph_info->bmp_size =
glyph_info->bmp_pitch * glyph_info->bbox_h;
break;
@@ -1838,14 +1848,14 @@ static BOOL get_subpixel_bmp (PDC pdc, Glyph32 glyph_value, SIZE* bbx_size,
*devfont->font_ops->get_glyph_greybitmap) {
/* the returned bits will be the subpixled pixmap */
data = (*devfont->font_ops->get_glyph_greybitmap) (logfont, devfont,
REAL_GLYPH(glyph_value), &data_pitch, &scale);
REAL_GLYPH(glyph_value), bbx_size, &data_pitch, &scale);
}
#endif
if (data == NULL)
{
data = (*devfont->font_ops->get_glyph_monobitmap) (logfont, devfont,
REAL_GLYPH(glyph_value), &data_pitch, &scale);
REAL_GLYPH(glyph_value), bbx_size, &data_pitch, &scale);
}
if (data == NULL)
@@ -1891,7 +1901,7 @@ static BOOL get_book_bmp (PDC pdc, Glyph32 glyph_value, SIZE* bbx_size,
/*get preybitmap and expand*/
if (devfont->font_ops->get_glyph_greybitmap) {
data = (*devfont->font_ops->get_glyph_greybitmap) (logfont, devfont,
REAL_GLYPH(glyph_value), &data_pitch, &scale);
REAL_GLYPH(glyph_value), bbx_size, &data_pitch, &scale);
}
if (data)
@@ -1928,7 +1938,7 @@ static BOOL get_book_bmp (PDC pdc, Glyph32 glyph_value, SIZE* bbx_size,
}
data = (*devfont->font_ops->get_glyph_monobitmap) (logfont, devfont,
REAL_GLYPH(glyph_value), &data_pitch, &scale);
REAL_GLYPH(glyph_value), bbx_size, &data_pitch, &scale);
if (data == NULL)
return FALSE;
@@ -1991,7 +2001,7 @@ static BOOL get_light_bmp (PDC pdc, Glyph32 glyph_value, SIZE* bbx_size,
data = NULL;
data = (*devfont->font_ops->get_glyph_monobitmap) (logfont, devfont,
REAL_GLYPH(glyph_value), &pitch, &scale);
REAL_GLYPH(glyph_value), bbx_size, &pitch, &scale);
if (data == NULL)
return FALSE;
@@ -2079,7 +2089,7 @@ static BOOL get_regular_bmp (PDC pdc, Glyph32 glyph_value, SIZE* bbx_size,
data = NULL;
data = (*devfont->font_ops->get_glyph_monobitmap) (logfont, devfont,
REAL_GLYPH(glyph_value), &pitch, &scale);
REAL_GLYPH(glyph_value), bbx_size, &pitch, &scale);
if (!data)
return FALSE;
@@ -3726,7 +3736,7 @@ static BOOL _gdi_get_glyph_data (PDC pdc, Glyph32 glyph_value,
}
data = (BYTE*)(*devfont->font_ops->get_glyph_monobitmap) (logfont, devfont,
REAL_GLYPH(glyph_value), &pitch, &scale);
REAL_GLYPH(glyph_value), bbox, &pitch, &scale);
if (data == NULL)
break;
@@ -3760,7 +3770,7 @@ static BOOL _gdi_get_glyph_data (PDC pdc, Glyph32 glyph_value,
/* get preybitmap */
if (devfont->font_ops->get_glyph_greybitmap) {
data = (BYTE*)(*devfont->font_ops->get_glyph_greybitmap) (logfont, devfont,
REAL_GLYPH (glyph_value), &pitch, &scale);
REAL_GLYPH (glyph_value), bbox, &pitch, &scale);
ctxt->cb = _dc_bookgrey_scan_line;
if (data && scale > 1) {
bbox->cx = bbox->cx / scale;
@@ -3782,7 +3792,7 @@ static BOOL _gdi_get_glyph_data (PDC pdc, Glyph32 glyph_value,
*devfont->font_ops->get_glyph_greybitmap) {
/* the returned bits will be the subpixled pixmap */
data = (BYTE*)(*devfont->font_ops->get_glyph_greybitmap) (logfont, devfont,
REAL_GLYPH(glyph_value), &pitch, &scale);
REAL_GLYPH(glyph_value), bbox, &pitch, &scale);
ctxt->cb = _dc_ft2subpixel_scan_line;
}
#endif