From 3a9274e9a0a0b8adc97d89fd0048658758ada9c9 Mon Sep 17 00:00:00 2001 From: Vincent Wei Date: Sun, 3 Mar 2019 18:54:39 +0800 Subject: [PATCH] add SIZE* sz for get_glyph_monobmp and get_glyph_graybmp --- src/font/logfont.c | 19 +++++++++++++------ src/font/qpf.c | 8 ++++---- src/font/rawbitmap.c | 2 +- src/font/upf.c | 6 +++--- src/font/varbitmap.c | 2 +- src/include/devfont.h | 4 ++-- src/newgdi/glyph.c | 26 ++++++++++++++++++-------- src/newgdi/tabbedtextout.c | 18 ++++++++++++++++-- src/newgdi/textout.c | 16 +++++++++++++++- 9 files changed, 73 insertions(+), 28 deletions(-) diff --git a/src/font/logfont.c b/src/font/logfont.c index 6b1d3d0e..fe5d89a6 100644 --- a/src/font/logfont.c +++ b/src/font/logfont.c @@ -278,6 +278,10 @@ PLOGFONT GUIAPI CreateLogFontIndirect (LOGFONT *reflf) // reset request size of newlf to reflf->size_request newlf->size = reflf->size_request; + if (newlf->size > FONT_MAX_SIZE) + newlf->size = FONT_MAX_SIZE; + else if (newlf->size < FONT_MIN_SIZE) + newlf->size = FONT_MIN_SIZE; // create new devfont instance if need for (i = 0; i < MAXNR_DEVFONTS; i++) { @@ -333,9 +337,12 @@ PLOGFONT GUIAPI CreateLogFontIndirectEx (LOGFONT *reflf, int rotation) newlf->charset == NULL) goto error; - // reset request size of newlf to reflf->size_request newlf->size = reflf->size_request; + if (newlf->size > FONT_MAX_SIZE) + newlf->size = FONT_MAX_SIZE; + else if (newlf->size < FONT_MIN_SIZE) + newlf->size = FONT_MIN_SIZE; newlf->rotation = rotation; // check if all devfonts support rotation @@ -352,11 +359,11 @@ PLOGFONT GUIAPI CreateLogFontIndirectEx (LOGFONT *reflf, int rotation) // create new devfont instance if need for (i = 0; i < MAXNR_DEVFONTS; i++) { DEVFONT* df = reflf->devfonts[i]; - if (df->font_ops->new_instance) - newlf->devfonts[i] = df->font_ops->new_instance(newlf, - df, i == 0); - if (df == NULL) { - goto error; + if (df && df->font_ops->new_instance) { + newlf->devfonts[i] = df->font_ops->new_instance(newlf, df, i == 0); + if (newlf->devfonts[i] == NULL) { + goto error; + } } } diff --git a/src/font/qpf.c b/src/font/qpf.c index a03dc842..0f6ce611 100644 --- a/src/font/qpf.c +++ b/src/font/qpf.c @@ -329,7 +329,7 @@ static int get_font_descent (LOGFONT* logfont, DEVFONT* devfont) } static const void* get_glyph_monobitmap (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; @@ -339,14 +339,14 @@ static const void* get_glyph_monobitmap (LOGFONT* logfont, DEVFONT* devfont, uc16 = (*devfont->charset_ops->conv_to_uc32) (glyph_value); else uc16 = glyph_value; - + glyph = get_glyph (QPFONT_INFO_P (devfont)->tree, uc16); if (glyph == NULL) { if (uc16 < 0x80 && logfont->devfonts[0] != devfont) { /* ASCII */ unsigned char ascii_ch = uc16; return logfont->devfonts[0]->font_ops->get_glyph_monobitmap (logfont, - logfont->devfonts[0], ascii_ch, pitch, scale); + logfont->devfonts[0], ascii_ch, sz, pitch, scale); } else glyph = &def_glyph; @@ -366,7 +366,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; diff --git a/src/font/rawbitmap.c b/src/font/rawbitmap.c index f166d950..0612bc9a 100644 --- a/src/font/rawbitmap.c +++ b/src/font/rawbitmap.c @@ -204,7 +204,7 @@ static int get_font_descent (LOGFONT* logfont, DEVFONT* devfont) } static const void* get_glyph_monobitmap (LOGFONT* logfont, DEVFONT* devfont, - Glyph32 glyph_value, int* pitch, unsigned short* scale) + Glyph32 glyph_value, SIZE* sz, int* pitch, unsigned short* scale) { int bitmap_size; diff --git a/src/font/upf.c b/src/font/upf.c index a4c0b1bc..56cbeaae 100644 --- a/src/font/upf.c +++ b/src/font/upf.c @@ -268,7 +268,7 @@ print_bitmap(char* bits, int width, int height, int pitch) #endif static const void* get_glyph_monobitmap (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; @@ -290,7 +290,7 @@ static const void* get_glyph_monobitmap (LOGFONT* logfont, DEVFONT* devfont, if (uc16 < 0x80 && logfont->devfonts[0] != devfont) { /* ASCII */ unsigned char ascii_ch = uc16; return logfont->devfonts[0]->font_ops->get_glyph_monobitmap (logfont, - logfont->devfonts[0], ascii_ch, pitch, scale); + logfont->devfonts[0], ascii_ch, sz, pitch, scale); } else glyph = &def_glyph; @@ -316,7 +316,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; diff --git a/src/font/varbitmap.c b/src/font/varbitmap.c index 9449702b..58efd4f6 100644 --- a/src/font/varbitmap.c +++ b/src/font/varbitmap.c @@ -239,7 +239,7 @@ static int get_glyph_advance (LOGFONT* logfont, DEVFONT* devfont, } static const void* get_glyph_monobitmap (LOGFONT* logfont, DEVFONT* devfont, - Glyph32 glyph_value, int* pitch, unsigned short* scale) + Glyph32 glyph_value, SIZE* sz, int* pitch, unsigned short* scale) { int offset; Glyph32 eff_value; diff --git a/src/include/devfont.h b/src/include/devfont.h index 1e9c89ed..f91b66ed 100644 --- a/src/include/devfont.h +++ b/src/include/devfont.h @@ -254,11 +254,11 @@ struct _FONTOPS /** The method to get mono-bitmap function. */ const void* (*get_glyph_monobitmap) (LOGFONT* logfont, DEVFONT* devfont, - Glyph32 glyph_value, int* pitch, unsigned short* scale); + 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, - Glyph32 galph_value, int* pitch, unsigned short* scale); + 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, diff --git a/src/newgdi/glyph.c b/src/newgdi/glyph.c index e0bd20e4..d96709b9 100644 --- a/src/newgdi/glyph.c +++ b/src/newgdi/glyph.c @@ -230,6 +230,7 @@ int GUIAPI GetGlyphInfo (LOGFONT* logfont, Glyph32 glyph_value, /* get the relative device font */ DEVFONT* devfont = SELECT_DEVFONT(logfont, glyph_value); glyph_value = REAL_GLYPH (glyph_value); + SIZE sz; /* get glyph type */ if (glyph_info->mask & GLYPH_INFO_TYPE) @@ -247,7 +248,8 @@ int GUIAPI GetGlyphInfo (LOGFONT* logfont, Glyph32 glyph_value, } /* get metrics of the glyph */ - if (glyph_info->mask & GLYPH_INFO_METRICS) { + if ((glyph_info->mask & GLYPH_INFO_METRICS) || + (glyph_info->mask & GLYPH_INFO_BMP)) { glyph_info->advance_x = 0; glyph_info->advance_y = 0; glyph_info->bbox_x = 0; @@ -256,6 +258,9 @@ int GUIAPI GetGlyphInfo (LOGFONT* logfont, Glyph32 glyph_value, _font_get_glyph_advance (logfont, devfont, glyph_value, TRUE, 0, 0, 0, &glyph_info->advance_x, &glyph_info->advance_x, (BBOX*)(&glyph_info->bbox_x)); + + sz.cx = glyph_info->bbox_w; + sz.cy = glyph_info->bbox_h; } /* get glyph bitmap info */ @@ -266,14 +271,18 @@ 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, &glyph_info->bmp_pitch, NULL); + logfont, devfont, glyph_value, &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; 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; @@ -281,7 +290,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; @@ -2017,7 +2028,7 @@ static BOOL _gdi_get_glyph_data (PDC pdc, Glyph32 glyph_value, } data = (BYTE*)(*devfont->font_ops->get_glyph_monobitmap) (logfont, - devfont, glyph_value, &pitch, &scale); + devfont, glyph_value, bbox, &pitch, &scale); if (data == NULL) break; @@ -2051,7 +2062,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, glyph_value, &pitch, &scale); + devfont, glyph_value, bbox, &pitch, &scale); ctxt->cb = _dc_bookgrey_scan_line; if (data && scale > 1) { bbox->cx = bbox->cx / scale; @@ -2073,7 +2084,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, glyph_value, &pitch, &scale); + devfont, glyph_value, bbox, &pitch, &scale); ctxt->cb = _dc_ft2subpixel_scan_line; /* flip the subpixeled pixmap */ @@ -2936,7 +2947,6 @@ Glyph32 _gdi_set_glyph_dfi(LOGFONT* lf, Glyph32 gv) } } - // return the first devfont as the default return SET_GLYPH_DFI(gv, dfi); } diff --git a/src/newgdi/tabbedtextout.c b/src/newgdi/tabbedtextout.c index cc09bbab..db0c87c7 100644 --- a/src/newgdi/tabbedtextout.c +++ b/src/newgdi/tabbedtextout.c @@ -572,8 +572,22 @@ int GUIAPI GetTabbedTextExtentPoint (HDC hdc, const char* text, (NULL, 0, (const unsigned char*)text, len_cur_char); glyph_type = devfont->charset_ops->glyph_type (glyph_value); - if(devfont == mbc_devfont) - glyph_value |= 0x80000000; + if (devfont == mbc_devfont) { + int i, dfi; + DEVFONT* df; + + dfi = 1; + for (i = 1; i < MAXNR_DEVFONTS; i++) { + if ((df = log_font->devfonts[i])) { + if (df->font_ops->is_glyph_existed(log_font, df, + glyph_value)) { + dfi = i; + break; + } + } + } + glyph_value = SET_GLYPH_DFI(glyph_value, dfi); + } switch (glyph_type & GLYPHTYPE_MCHAR_MASK) { case MCHAR_TYPE_ZEROWIDTH: diff --git a/src/newgdi/textout.c b/src/newgdi/textout.c index bfd3054d..3edce224 100644 --- a/src/newgdi/textout.c +++ b/src/newgdi/textout.c @@ -479,11 +479,25 @@ int GUIAPI GetTextExtentPoint (HDC hdc, const char* text, int len, if (mbc_devfont && (len_cur_char = mbc_devfont->charset_ops->len_first_char ((const unsigned char*)text, left_bytes)) > 0) { + int i, dfi; + DEVFONT* df; glyph_value = (*mbc_devfont->charset_ops->char_glyph_value)(NULL, 0, (const unsigned char*)text, 0); - advance_cur_char = _gdi_get_glyph_advance (pdc, glyph_value | 0x80000000, + dfi = 1; + for (i = 1; i < MAXNR_DEVFONTS; i++) { + if ((df = log_font->devfonts[i])) { + if (df->font_ops->is_glyph_existed(log_font, df, + glyph_value)) { + dfi = i; + break; + } + } + } + glyph_value = SET_GLYPH_DFI(glyph_value, dfi); + + advance_cur_char = _gdi_get_glyph_advance (pdc, glyph_value, (pdc->ta_flags & TA_X_MASK) == TA_LEFT, 0, 0, NULL, NULL, NULL); }