From 5b27cc70fc328201987b0350da9f3c1514ca7b03 Mon Sep 17 00:00:00 2001 From: Vincent Wei Date: Wed, 9 Aug 2023 11:13:40 +0800 Subject: [PATCH 1/3] use draw_one_vowel and DrawVowel for vowel --- include/gdi.h | 21 ++++++- src/include/ourhdr.h | 2 + src/newgdi/drawtext.c | 15 +++-- src/newgdi/drawtext.h | 4 ++ src/newgdi/glyph.c | 124 +++++++++++++++++++++++++++++++++++++ src/newgdi/tabbedtextout.c | 30 +++++---- src/newgdi/textout.c | 36 +++++++---- 7 files changed, 200 insertions(+), 32 deletions(-) diff --git a/include/gdi.h b/include/gdi.h index 0493d946..760c6ed6 100644 --- a/include/gdi.h +++ b/include/gdi.h @@ -12972,7 +12972,7 @@ MG_EXPORT Glyph32 GUIAPI GetGlyphValueAlt(LOGFONT* logfont, Achar32 chv); * int* adv_x, int* adv_y) * \brief Draw a glyph. * - * This function draws a glyph to the specific postion of a DC. + * This function draws a glyph to the specific position of a DC. * * \param hdc The device context. * \param x The output start x position. @@ -12988,6 +12988,25 @@ MG_EXPORT Glyph32 GUIAPI GetGlyphValueAlt(LOGFONT* logfont, Achar32 chv); MG_EXPORT int GUIAPI DrawGlyph (HDC hdc, int x, int y, Glyph32 glyph_value, int* adv_x, int* adv_y); +/** + * \fn int GUIAPI DrawVowel (HDC hdc, int x, int y, Glyph32 glyph_value, \ + * int last_adv) + * \brief Draw a glyph as vowel. + * + * This function draws a glyph as a vowel of the last glyph to + * the specific position of a DC. + * + * \param hdc The device context. + * \param x The output start x position. + * \param y The output start y position. + * \param glyph_value The glyph value. + * \param last_adv The advance on the baseline of the last glyph. + * + * \return The advance on baseline of the vowel. + */ +MG_EXPORT int GUIAPI DrawVowel (HDC hdc, int x, int y, Glyph32 glyph_value, + int last_adv); + /* * \fn int GUIAPI DrawGlyphString (HDC hdc, Glyph32* glyphs, int nr_glyphs, * const POINT* pts); diff --git a/src/include/ourhdr.h b/src/include/ourhdr.h index 52c508b1..527efb99 100644 --- a/src/include/ourhdr.h +++ b/src/include/ourhdr.h @@ -73,6 +73,8 @@ #if defined(__GNU_LIBRARY__) && !defined(_SEM_SEMUN_UNDEFINED) /* union semun is defined by including */ +#elif defined(__DARWIN__) +/* union semun is defined by including */ #else /* according to X/OPEN we have to define it ourselves */ union semun { diff --git a/src/newgdi/drawtext.c b/src/newgdi/drawtext.c index d3494e40..0c707b5f 100644 --- a/src/newgdi/drawtext.c +++ b/src/newgdi/drawtext.c @@ -146,18 +146,18 @@ static BOOL cb_drawtextex2 (void* context, Glyph32 glyph_value, case ACHAR_BASIC_VOWEL: if (!ctxt->only_extent) { +#if 0 int bkmode = ctxt->pdc->bkmode; ctxt->pdc->bkmode = BM_TRANSPARENT; -#if 0 _gdi_draw_one_glyph (ctxt->pdc, glyph_value, (ctxt->pdc->ta_flags & TA_X_MASK) != TA_RIGHT, ctxt->x, ctxt->y, &adv_x, &adv_y); -#else - _gdi_draw_one_glyph (ctxt->pdc, glyph_value, - (ctxt->pdc->ta_flags & TA_X_MASK) != TA_RIGHT, - ctxt->last_x, ctxt->last_y, &adv_x, &adv_y); -#endif ctxt->pdc->bkmode = bkmode; +#else + _gdi_draw_one_vowel (ctxt->pdc, glyph_value, + (ctxt->pdc->ta_flags & TA_X_MASK) != TA_RIGHT, + ctxt->last_x, ctxt->last_y, ctxt->last_adv); +#endif adv_x = adv_y = 0; } break; @@ -182,6 +182,7 @@ static BOOL cb_drawtextex2 (void* context, Glyph32 glyph_value, ctxt->last_x = ctxt->x; ctxt->last_y = ctxt->y; + ctxt->last_adv = adv_x; ctxt->x += adv_x; ctxt->y += adv_y; @@ -200,6 +201,7 @@ int _gdi_get_drawtext_extent (PDC pdc, const unsigned char* text, int len, ctxt.last_x = 0; ctxt.last_y = 0; ctxt.advance = 0; + ctxt.last_adv = 0; ctxt.only_extent = TRUE; ctxt.nFormat = _tmp->nFormat; ctxt.tab_width = _tmp->tab_width; @@ -318,6 +320,7 @@ int DrawTextEx2 (HDC hdc, const char* pText, int nCount, ctxt.y = y; ctxt.last_x = x; ctxt.last_y = y; + ctxt.last_adv = 0; while (nCount > 0) { int line_x, maxwidth; diff --git a/src/newgdi/drawtext.h b/src/newgdi/drawtext.h index 5e926494..eb59a74a 100644 --- a/src/newgdi/drawtext.h +++ b/src/newgdi/drawtext.h @@ -82,6 +82,9 @@ static inline int _gdi_get_glyph_advance (PDC pdc, Glyph32 glyph_value, direction, pdc->cExtra, x, y, adv_x, adv_y, bbox); } +int _gdi_draw_one_vowel (PDC pdc, Glyph32 glyph_value, BOOL direction, + int x, int y, int last_adv); + int _gdi_draw_one_glyph (PDC pdc, Glyph32 glyph_value, BOOL direction, int x, int y, int* adv_x, int* adv_y); @@ -133,6 +136,7 @@ typedef struct _DRAWTEXTEX2_CTXT int x, y; int last_x, last_y; int advance; + int last_adv; int nFormat; int nCount; diff --git a/src/newgdi/glyph.c b/src/newgdi/glyph.c index 7bdcf2bd..45ab50d8 100644 --- a/src/newgdi/glyph.c +++ b/src/newgdi/glyph.c @@ -2935,6 +2935,105 @@ end: return advance; } +int _gdi_draw_one_vowel (PDC pdc, Glyph32 glyph_value, BOOL direction, + int x, int y, int last_adv) +{ + LOGFONT* logfont; + DEVFONT* devfont; + + BBOX bbox; + int advance, adv_x, adv_y; + GAL_Rect fg_gal_rc; + + RECT rc_output; + RECT rc_front; + RECT rc_tmp; + + int italic = 0; + int bold = 0; + SIZE bbx_size; + int flag = 0; + int glyph_bmptype; + + y += pdc->alExtra; + + rc_tmp = pdc->rc_output; + advance = _gdi_get_glyph_advance (pdc, glyph_value, direction, + x, y, &adv_x, &adv_y, &bbox); + if (last_adv > 0) { + /* Adjust position */ + if (direction) + x += (last_adv - advance) >> 1; + else + x -= (last_adv - advance) >> 1; + advance = 0; /* no advance */ + } + + logfont = pdc->pLogFont; + devfont = SELECT_DEVFONT_BY_GLYPH (logfont, glyph_value); + + glyph_bmptype = devfont->font_ops->get_glyph_bmptype (logfont, devfont) + & DEVFONTGLYPHTYPE_MASK_BMPTYPE; + + // VincentWei: only use auto bold when the weight of devfont does not + // match the weight of logfont. + if (((int)(logfont->style & FS_WEIGHT_MASK) - + (int)(devfont->style & FS_WEIGHT_MASK)) > FS_WEIGHT_AUTOBOLD + && (glyph_bmptype == DEVFONTGLYPHTYPE_MONOBMP)) { + bold = GET_DEVFONT_SCALE (logfont, devfont); + } + + if (logfont->style & FS_SLANT_ITALIC + && !(devfont->style & FS_SLANT_ITALIC)) { + italic = devfont->font_ops->get_font_height (logfont, devfont) >> 1; + } + + fg_gal_rc.x = bbox.x; + fg_gal_rc.y = bbox.y; + fg_gal_rc.w = bbox.w + italic; + fg_gal_rc.h = bbox.h; + + if (glyph_bmptype == DEVFONTGLYPHTYPE_MONOBMP + && (logfont->style & FS_DECORATE_OUTLINE)) { + fg_gal_rc.x--; fg_gal_rc.y--; + fg_gal_rc.w += 2; fg_gal_rc.h += 2; + } + + rc_front.left = fg_gal_rc.x; + rc_front.top = fg_gal_rc.y; + rc_front.right = fg_gal_rc.x + fg_gal_rc.w; + rc_front.bottom = fg_gal_rc.y + fg_gal_rc.h; + rc_output = rc_front; + + if (!(pdc = __mg_check_ecrgn ((HDC)pdc))) { + return advance; + } + + if (!IntersectRect(&pdc->rc_output, &rc_output, &pdc->rc_output)) { + goto end; + } + + if (WITHOUT_DRAWING (pdc)) goto end; + + ENTER_DRAWING (pdc); + + pdc->step = 1; + pdc->cur_ban = NULL; + + /* bbox is the real glyph pixels on one scan-line. */ + bbx_size.cx = bbox.w; + bbx_size.cy = bbox.h; + + _gdi_direct_fillglyph (pdc, glyph_value, &fg_gal_rc, &bbx_size, + y - bbox.y, advance, italic, bold); + + LEAVE_DRAWING (pdc); +end: + pdc->rc_output = rc_tmp; + UNLOCK_GCRINFO (pdc); + return advance; +} + int _gdi_get_italic_added_width (LOGFONT* logfont) { /* FIXME: use the correct devfont for auto-italic */ @@ -2992,6 +3091,31 @@ int GUIAPI DrawGlyph (HDC hdc, int x, int y, Glyph32 glyph_value, return advance; } +int GUIAPI DrawVowel (HDC hdc, int x, int y, Glyph32 glyph_value, + int last_adv) +{ + int my_adv_x, my_adv_y; + int advance; + PDC pdc; + + if (glyph_value == INV_GLYPH_VALUE) + return 0; + + pdc = dc_HDC2PDC(hdc); + /* Transfer logical to device to screen here. */ + coor_LP2SP (pdc, &x, &y); + pdc->rc_output = pdc->DevRC; + + /* convert to the start point on baseline. */ + _gdi_get_baseline_point (pdc, &x, &y); + + advance = _gdi_draw_one_vowel (pdc, glyph_value, + (pdc->ta_flags & TA_X_MASK) != TA_RIGHT, + x, y, last_adv); + + return advance; +} + int GUIAPI DrawGlyphStrings(HDC hdc, Glyph32* glyphs, int nr_glyphs, const POINT* pts) { diff --git a/src/newgdi/tabbedtextout.c b/src/newgdi/tabbedtextout.c index d0a9eff6..9cdc8c6c 100644 --- a/src/newgdi/tabbedtextout.c +++ b/src/newgdi/tabbedtextout.c @@ -124,6 +124,7 @@ typedef struct _TABBEDTEXTOUT_CTXT int x, y; int last_x, last_y; int advance; + int last_adv; BOOL only_extent; } TABBEDTEXTOUT_CTXT; @@ -160,18 +161,18 @@ static BOOL cb_tabbedtextout (void* context, Glyph32 glyph_value, case ACHAR_BASIC_VOWEL: if (!ctxt->only_extent) { +#if 0 int bkmode = ctxt->pdc->bkmode; ctxt->pdc->bkmode = BM_TRANSPARENT; -#if 0 _gdi_draw_one_glyph (ctxt->pdc, glyph_value, (ctxt->pdc->ta_flags & TA_X_MASK) != TA_RIGHT, ctxt->x, ctxt->y, &adv_x, &adv_y); -#else - _gdi_draw_one_glyph (ctxt->pdc, glyph_value, - (ctxt->pdc->ta_flags & TA_X_MASK) != TA_RIGHT, - ctxt->last_x, ctxt->last_y, &adv_x, &adv_y); -#endif ctxt->pdc->bkmode = bkmode; +#else + _gdi_draw_one_vowel (ctxt->pdc, glyph_value, + (ctxt->pdc->ta_flags & TA_X_MASK) != TA_RIGHT, + ctxt->last_x, ctxt->last_y, ctxt->last_adv); +#endif } adv_x = adv_y = 0; break; @@ -196,6 +197,7 @@ static BOOL cb_tabbedtextout (void* context, Glyph32 glyph_value, ctxt->last_x = ctxt->x; ctxt->last_y = ctxt->y; + ctxt->last_adv = adv_x; ctxt->x += adv_x; ctxt->y += adv_y; @@ -220,6 +222,7 @@ typedef struct _TABBEDTEXTOUTEX_CTXT int x, y; int last_x, last_y; int advance; + int last_adv; } TABBEDTEXTOUTEX_CTXT; static BOOL cb_tabbedtextoutex (void* context, Glyph32 glyph_value, @@ -258,18 +261,18 @@ static BOOL cb_tabbedtextoutex (void* context, Glyph32 glyph_value, break; case ACHAR_BASIC_VOWEL: { +#if 0 int bkmode = ctxt->pdc->bkmode; ctxt->pdc->bkmode = BM_TRANSPARENT; -#if 0 _gdi_draw_one_glyph (ctxt->pdc, glyph_value, (ctxt->pdc->ta_flags & TA_X_MASK) != TA_RIGHT, ctxt->x, ctxt->y, &adv_x, &adv_y); -#else - _gdi_draw_one_glyph (ctxt->pdc, glyph_value, - (ctxt->pdc->ta_flags & TA_X_MASK) != TA_RIGHT, - ctxt->last_x, ctxt->last_y, &adv_x, &adv_y); -#endif ctxt->pdc->bkmode = bkmode; +#else + _gdi_draw_one_vowel (ctxt->pdc, glyph_value, + (ctxt->pdc->ta_flags & TA_X_MASK) != TA_RIGHT, + ctxt->last_x, ctxt->last_y, ctxt->last_adv); +#endif adv_x = adv_y = 0; break; } @@ -287,6 +290,7 @@ static BOOL cb_tabbedtextoutex (void* context, Glyph32 glyph_value, ctxt->last_x = ctxt->x; ctxt->last_y = ctxt->y; + ctxt->last_adv = adv_x; ctxt->x += adv_x; ctxt->y += adv_y; @@ -314,6 +318,7 @@ int _gdi_tabbed_text_out (PDC pdc, int x, int y, ctxt.last_x = x; ctxt.last_y = y; ctxt.advance = 0; + ctxt.last_adv = 0; ctxt.only_extent = only_extent; if (!only_extent) @@ -460,6 +465,7 @@ static int _gdi_tabbedex_text_out (PDC pdc, int x, int y, ctxt.last_x = x; ctxt.last_y = y; ctxt.advance = 0; + ctxt.last_adv = 0; /* init the tab relative info.*/ ctxt.nTabs = nTabs; diff --git a/src/newgdi/textout.c b/src/newgdi/textout.c index bcdfe499..4a4a8349 100644 --- a/src/newgdi/textout.c +++ b/src/newgdi/textout.c @@ -116,6 +116,7 @@ typedef struct _DRAW_GLYPHS_CTXT { int x, y; int last_x, last_y; int advance; + int last_adv; } DRAW_GLYPHS_CTXT; static BOOL cb_draw_glyph (void* context, Glyph32 glyph_value, unsigned int char_type) @@ -132,7 +133,8 @@ static BOOL cb_draw_glyph (void* context, Glyph32 glyph_value, unsigned int char #if 0 DrawGlyph (ctxt->hdc, ctxt->x, ctxt->y, glyph_value, &adv_x, &adv_y); #else - DrawGlyph (ctxt->hdc, ctxt->last_x, ctxt->last_y, glyph_value, &adv_x, &adv_y); + DrawVowel (ctxt->hdc, ctxt->last_x, ctxt->last_y, glyph_value, + ctxt->last_adv); #endif SetBkMode (ctxt->hdc, bkmode); adv_x = 0; @@ -145,6 +147,7 @@ static BOOL cb_draw_glyph (void* context, Glyph32 glyph_value, unsigned int char ctxt->last_x = ctxt->x; ctxt->last_y = ctxt->y; + ctxt->last_adv = adv_x; ctxt->x += adv_x; ctxt->y += adv_y; @@ -157,6 +160,7 @@ typedef struct _TEXTOUT_CTXT int x, y; int last_x, last_y; int advance; + int last_adv; BOOL only_extent; } TEXTOUT_CTXT; @@ -171,18 +175,18 @@ static BOOL cb_textout (void* context, Glyph32 glyph_value, } else if (check_vowel(char_type)) { if (!ctxt->only_extent) { +#if 0 int bkmode = ctxt->pdc->bkmode; ctxt->pdc->bkmode = BM_TRANSPARENT; -#if 0 _gdi_draw_one_glyph (ctxt->pdc, glyph_value, (ctxt->pdc->ta_flags & TA_X_MASK) != TA_RIGHT, ctxt->x, ctxt->y, &adv_x, &adv_y); -#else - _gdi_draw_one_glyph (ctxt->pdc, glyph_value, - (ctxt->pdc->ta_flags & TA_X_MASK) != TA_RIGHT, - ctxt->last_x, ctxt->last_y, &adv_x, &adv_y); -#endif ctxt->pdc->bkmode = bkmode; +#else + _gdi_draw_one_vowel (ctxt->pdc, glyph_value, + (ctxt->pdc->ta_flags & TA_X_MASK) != TA_RIGHT, + ctxt->last_x, ctxt->last_y, ctxt->last_adv); +#endif } adv_x = adv_y = 0; } @@ -203,6 +207,7 @@ static BOOL cb_textout (void* context, Glyph32 glyph_value, ctxt->last_x = ctxt->x; ctxt->last_y = ctxt->y; + ctxt->last_adv = adv_x; ctxt->x += adv_x; ctxt->y += adv_y; @@ -223,6 +228,7 @@ int _gdi_text_out (PDC pdc, int x, int y, ctxt.last_x = x; ctxt.last_y = y; ctxt.advance = 0; + ctxt.last_adv = 0; ctxt.only_extent = FALSE; _gdi_start_new_line (pdc); @@ -280,6 +286,7 @@ int _gdi_get_text_extent (PDC pdc, const unsigned char* text, int len, ctxt.last_x = 0; ctxt.last_y = 0; ctxt.advance = 0; + ctxt.last_adv = 0; ctxt.only_extent = TRUE; _gdi_start_new_line (pdc); @@ -334,6 +341,7 @@ typedef struct _TEXTOUTOMITTED_CTXT int x, y; int last_x, last_y; int advance; + int last_adv; Uint32 max_extent; } TEXTOUTOMITTED_CTXT; @@ -348,18 +356,18 @@ cb_textout_omitted (void* context, Glyph32 glyph_value, unsigned int char_type) adv_x = adv_y = 0; } else if (check_vowel(char_type)) { +#if 0 int bkmode = ctxt->pdc->bkmode; ctxt->pdc->bkmode = BM_TRANSPARENT; -#if 0 _gdi_draw_one_glyph (ctxt->pdc, glyph_value, (ctxt->pdc->ta_flags & TA_X_MASK) != TA_RIGHT, ctxt->x, ctxt->y, &adv_x, &adv_y); -#else - _gdi_draw_one_glyph (ctxt->pdc, glyph_value, - (ctxt->pdc->ta_flags & TA_X_MASK) != TA_RIGHT, - ctxt->last_x, ctxt->last_y, &adv_x, &adv_y); -#endif ctxt->pdc->bkmode = bkmode; +#else + _gdi_draw_one_vowel (ctxt->pdc, glyph_value, + (ctxt->pdc->ta_flags & TA_X_MASK) != TA_RIGHT, + ctxt->last_x, ctxt->last_y, ctxt->last_adv); +#endif adv_x = adv_y = 0; } else { @@ -381,6 +389,7 @@ cb_textout_omitted (void* context, Glyph32 glyph_value, unsigned int char_type) ctxt->last_x = ctxt->x; ctxt->last_y = ctxt->y; + ctxt->last_adv = adv_x; ctxt->x += adv_x; ctxt->y += adv_y; @@ -401,6 +410,7 @@ int _gdi_textout_omitted (PDC pdc, int x, int y, ctxt.last_x = x; ctxt.last_y = y; ctxt.advance = 0; + ctxt.last_adv = 0; ctxt.max_extent = max_extent; _gdi_start_new_line (pdc); From 0a5ace7f828ab1f7e5b11d564ba3cdf6ae5bca99 Mon Sep 17 00:00:00 2001 From: Vincent Wei Date: Wed, 9 Aug 2023 14:08:40 +0800 Subject: [PATCH 2/3] add a new method for DEVFONTOPS: get_feature(). currently used for check whether a devfont contains correct bounding box values for marks --- include/gdi.h | 2 ++ src/font/bitmapfont.c | 12 +++++++ src/font/freetype1.c | 12 +++++++ src/font/freetype2.c | 12 +++++++ src/font/nullfont.c | 12 +++++++ src/font/qpf.c | 12 +++++++ src/font/rawbitmap.c | 12 +++++++ src/font/scripteasy.c | 12 +++++++ src/font/upf.c | 12 +++++++ src/font/varbitmap.c | 12 +++++++ src/include/devfont.h | 10 +++++- src/newgdi/drawtext.c | 25 +++++++------- src/newgdi/drawtext.h | 2 ++ src/newgdi/glyph.c | 13 ++++++++ src/newgdi/tabbedtextout.c | 50 ++++++++++++++-------------- src/newgdi/textout.c | 68 ++++++++++++++++++++------------------ 16 files changed, 208 insertions(+), 70 deletions(-) diff --git a/include/gdi.h b/include/gdi.h index 760c6ed6..05cae2da 100644 --- a/include/gdi.h +++ b/include/gdi.h @@ -13003,6 +13003,8 @@ MG_EXPORT int GUIAPI DrawGlyph (HDC hdc, int x, int y, Glyph32 glyph_value, * \param last_adv The advance on the baseline of the last glyph. * * \return The advance on baseline of the vowel. + * + * Since 5.0.13 */ MG_EXPORT int GUIAPI DrawVowel (HDC hdc, int x, int y, Glyph32 glyph_value, int last_adv); diff --git a/src/font/bitmapfont.c b/src/font/bitmapfont.c index ea85bbf6..82b03a9b 100644 --- a/src/font/bitmapfont.c +++ b/src/font/bitmapfont.c @@ -202,6 +202,17 @@ static void destroy (GLYPHTREENODE *root) /*** device font ops ***/ +static DWORD get_feature (LOGFONT* logfont, DEVFONT* devfont, + enum devfont_feature feature) +{ + switch (feature) { + case DEVFONT_FEATURE_MARK_BBOX: + return 0; + } + + return 0; +} + static DWORD get_glyph_bmptype (LOGFONT* logfont, DEVFONT* devfont) { return DEVFONTGLYPHTYPE_PRERDRBMP; @@ -380,6 +391,7 @@ static int get_glyph_bbox (LOGFONT* logfont, DEVFONT* devfont, /**************************** Global data ************************************/ FONTOPS __mg_bitmap_font_ops = { + get_feature, get_glyph_bmptype, get_ave_width, get_max_width, diff --git a/src/font/freetype1.c b/src/font/freetype1.c index c83a88ed..6b82e1a1 100644 --- a/src/font/freetype1.c +++ b/src/font/freetype1.c @@ -255,6 +255,17 @@ compute_kernval (TTFINSTANCEINFO* ttf_inst_info) return kernval; } +static DWORD get_feature (LOGFONT* logfont, DEVFONT* devfont, + enum devfont_feature feature) +{ + switch (feature) { + case DEVFONT_FEATURE_MARK_BBOX: + return 0; + } + + return 0; +} + static DWORD get_glyph_bmptype (LOGFONT* logfont, DEVFONT* devfont) { if (logfont->style & FS_WEIGHT_BOOK) @@ -792,6 +803,7 @@ static int is_rotatable (LOGFONT* logfont, DEVFONT* devfont, int rot_desired) } /**************************** Global data ************************************/ FONTOPS __mg_ttf_ops = { + get_feature, get_glyph_bmptype, get_ave_width, get_max_width, diff --git a/src/font/freetype2.c b/src/font/freetype2.c index eb7c7991..17781334 100644 --- a/src/font/freetype2.c +++ b/src/font/freetype2.c @@ -197,6 +197,17 @@ print_bitmap_grey (const BYTE* buffer, int width, int rows, int pitch) printf("*******************************************\n"); } +static DWORD get_feature (LOGFONT* logfont, DEVFONT* devfont, + enum devfont_feature feature) +{ + switch (feature) { + case DEVFONT_FEATURE_MARK_BBOX: + return 1; + } + + return 0; +} + static DWORD get_glyph_bmptype (LOGFONT* logfont, DEVFONT* devfont) { switch (logfont->style & FS_RENDER_MASK) { @@ -1265,6 +1276,7 @@ void font_TermFreetypeLibrary (void) /**************************** Global data ************************************/ FONTOPS __mg_ttf_ops = { + get_feature, get_glyph_bmptype, get_ave_width, get_max_width, diff --git a/src/font/nullfont.c b/src/font/nullfont.c index 13a02e16..31e5a3ef 100644 --- a/src/font/nullfont.c +++ b/src/font/nullfont.c @@ -66,6 +66,17 @@ #define NUF_WIDTH 8 #define NUF_HEIGHT 1 +static DWORD get_feature (LOGFONT* logfont, DEVFONT* devfont, + enum devfont_feature feature) +{ + switch (feature) { + case DEVFONT_FEATURE_MARK_BBOX: + return 0; + } + + return 0; +} + static DWORD get_glyph_bmptype (LOGFONT* logfont, DEVFONT* devfont) { return DEVFONTGLYPHTYPE_MONOBMP; @@ -171,6 +182,7 @@ static void unload_font_data (DEVFONT* devfont, void* data) } FONTOPS __mg_null_font_ops = { + get_feature, get_glyph_bmptype, get_ave_width, get_max_width, diff --git a/src/font/qpf.c b/src/font/qpf.c index 87acf83e..a24de7a2 100644 --- a/src/font/qpf.c +++ b/src/font/qpf.c @@ -287,6 +287,17 @@ static unsigned char def_smooth_bitmap [] = static QPF_GLYPH def_glyph = {&def_metrics, def_bitmap}; static QPF_GLYPH def_smooth_glyph = {&def_smooth_metrics, def_smooth_bitmap}; +static DWORD get_feature (LOGFONT* logfont, DEVFONT* devfont, + enum devfont_feature feature) +{ + switch (feature) { + case DEVFONT_FEATURE_MARK_BBOX: + return 0; + } + + return 0; +} + static DWORD get_glyph_bmptype (LOGFONT* logfont, DEVFONT* devfont) { if (QPFONT_INFO_P (devfont)->fm->flags & FLAG_MODE_SMOOTH) @@ -541,6 +552,7 @@ static int is_rotatable (LOGFONT* logfont, DEVFONT* devfont, int rot_desired) /**************************** Global data ************************************/ FONTOPS __mg_qpf_ops = { + get_feature, get_glyph_bmptype, get_ave_width, get_max_width, diff --git a/src/font/rawbitmap.c b/src/font/rawbitmap.c index 1f5742e6..c439b3ac 100644 --- a/src/font/rawbitmap.c +++ b/src/font/rawbitmap.c @@ -151,6 +151,17 @@ static void unload_font_data (DEVFONT* devfont, void* data) /*************** Raw bitmap font operations *********************************/ +static DWORD get_feature (LOGFONT* logfont, DEVFONT* devfont, + enum devfont_feature feature) +{ + switch (feature) { + case DEVFONT_FEATURE_MARK_BBOX: + return 0; + } + + return 0; +} + static DWORD get_glyph_bmptype (LOGFONT* logfont, DEVFONT* devfont) { return DEVFONTGLYPHTYPE_MONOBMP; @@ -280,6 +291,7 @@ static int is_rotatable (LOGFONT* logfont, DEVFONT* devfont, int rot_desired) /**************************** Global data ************************************/ FONTOPS __mg_rbf_ops = { + get_feature, get_glyph_bmptype, get_ave_width, get_ave_width, // max_width same as ave_width diff --git a/src/font/scripteasy.c b/src/font/scripteasy.c index 9942c0e8..811ef70c 100644 --- a/src/font/scripteasy.c +++ b/src/font/scripteasy.c @@ -377,6 +377,17 @@ static int get_max_width (LOGFONT* logfont, DEVFONT* devfont) return logfont->size; } +static DWORD get_feature (LOGFONT* logfont, DEVFONT* devfont, + enum devfont_feature feature) +{ + switch (feature) { + case DEVFONT_FEATURE_MARK_BBOX: + return 0; + } + + return 0; +} + static DWORD get_glyph_bmptype (LOGFONT* logfont, DEVFONT* devfont) { if (logfont->style & FS_WEIGHT_BOOK) @@ -598,6 +609,7 @@ static int is_rotatable (LOGFONT* logfont, DEVFONT* devfont, int rot_desired) /**************************** Global data ************************************/ static FONTOPS scripteasy_font_ops = { + get_feature, get_glyph_bmptype, get_ave_width, get_max_width, diff --git a/src/font/upf.c b/src/font/upf.c index dfcd6f7b..0f0e8999 100644 --- a/src/font/upf.c +++ b/src/font/upf.c @@ -148,6 +148,17 @@ static void unload_font_data (DEVFONT* devfont, void* data) free (((UPFINFO*) data)); } +static DWORD get_feature (LOGFONT* logfont, DEVFONT* devfont, + enum devfont_feature feature) +{ + switch (feature) { + case DEVFONT_FEATURE_MARK_BBOX: + return 0; + } + + return 0; +} + static DWORD get_glyph_bmptype (LOGFONT* logfont, DEVFONT* devfont) { Uint8* p_upf = (Uint8 *)UPFONT_INFO_P (devfont)->root_dir; @@ -525,6 +536,7 @@ static int is_rotatable (LOGFONT* logfont, DEVFONT* devfont, int rot_desired) } FONTOPS __mg_upf_ops = { + get_feature, get_glyph_bmptype, get_ave_width, get_max_width, diff --git a/src/font/varbitmap.c b/src/font/varbitmap.c index be58014a..97d6c72d 100644 --- a/src/font/varbitmap.c +++ b/src/font/varbitmap.c @@ -109,6 +109,17 @@ typedef struct _FONT_PROPT { int def_glyph; } FONT_PROPT; +static DWORD get_feature (LOGFONT* logfont, DEVFONT* devfont, + enum devfont_feature feature) +{ + switch (feature) { + case DEVFONT_FEATURE_MARK_BBOX: + return 0; + } + + return 0; +} + static DWORD get_glyph_bmptype (LOGFONT* logfont, DEVFONT* devfont) { return DEVFONTGLYPHTYPE_MONOBMP; @@ -477,6 +488,7 @@ static void unload_font_data (DEVFONT* devfont, void* data) } FONTOPS __mg_vbf_ops = { + get_feature, get_glyph_bmptype, get_ave_width, get_max_width, diff --git a/src/include/devfont.h b/src/include/devfont.h index a25d7001..fff71918 100644 --- a/src/include/devfont.h +++ b/src/include/devfont.h @@ -209,7 +209,7 @@ struct _CHARSETOPS /** Default character. */ Achar32 def_char_value; - /** Whether use legacy BIDI algorithm (Since 5.0.13). */ + /** Whether using legacy BIDI algorithm (Since 5.0.13). */ unsigned legacy_bidi:1; /** The method to get the length of the first character. */ @@ -266,9 +266,17 @@ struct _CHARSETOPS #define DEVFONTGLYPHTYPE_MASK_BMPTYPE 0x0F +enum devfont_feature { + DEVFONT_FEATURE_MARK_BBOX = 0, +}; + /** The font operation structure. */ struct _FONTOPS { + /** The method to get the feature value of the font (Since 5.0.13). */ + DWORD (*get_feature) (LOGFONT* logfont, DEVFONT* devfont, + enum devfont_feature feature); + /** The method to get the glyph bitmap type . */ DWORD (*get_glyph_bmptype) (LOGFONT* logfont, DEVFONT* devfont); diff --git a/src/newgdi/drawtext.c b/src/newgdi/drawtext.c index 0c707b5f..05df66ad 100644 --- a/src/newgdi/drawtext.c +++ b/src/newgdi/drawtext.c @@ -146,18 +146,19 @@ static BOOL cb_drawtextex2 (void* context, Glyph32 glyph_value, case ACHAR_BASIC_VOWEL: if (!ctxt->only_extent) { -#if 0 - int bkmode = ctxt->pdc->bkmode; - ctxt->pdc->bkmode = BM_TRANSPARENT; - _gdi_draw_one_glyph (ctxt->pdc, glyph_value, - (ctxt->pdc->ta_flags & TA_X_MASK) != TA_RIGHT, - ctxt->x, ctxt->y, &adv_x, &adv_y); - ctxt->pdc->bkmode = bkmode; -#else - _gdi_draw_one_vowel (ctxt->pdc, glyph_value, - (ctxt->pdc->ta_flags & TA_X_MASK) != TA_RIGHT, - ctxt->last_x, ctxt->last_y, ctxt->last_adv); -#endif + if (_gdi_if_mark_bbox_is_ok(ctxt->pdc, glyph_value)) { + int bkmode = ctxt->pdc->bkmode; + ctxt->pdc->bkmode = ctxt->pdc->bkmode_set; + _gdi_draw_one_glyph (ctxt->pdc, glyph_value, + (ctxt->pdc->ta_flags & TA_X_MASK) != TA_RIGHT, + ctxt->x, ctxt->y, &adv_x, &adv_y); + ctxt->pdc->bkmode = bkmode; + } + else { + _gdi_draw_one_vowel (ctxt->pdc, glyph_value, + (ctxt->pdc->ta_flags & TA_X_MASK) != TA_RIGHT, + ctxt->last_x, ctxt->last_y, ctxt->last_adv); + } adv_x = adv_y = 0; } break; diff --git a/src/newgdi/drawtext.h b/src/newgdi/drawtext.h index eb59a74a..b3acfe1c 100644 --- a/src/newgdi/drawtext.h +++ b/src/newgdi/drawtext.h @@ -82,6 +82,8 @@ static inline int _gdi_get_glyph_advance (PDC pdc, Glyph32 glyph_value, direction, pdc->cExtra, x, y, adv_x, adv_y, bbox); } +BOOL _gdi_if_mark_bbox_is_ok(PDC pdc, Glyph32 gv); + int _gdi_draw_one_vowel (PDC pdc, Glyph32 glyph_value, BOOL direction, int x, int y, int last_adv); diff --git a/src/newgdi/glyph.c b/src/newgdi/glyph.c index 45ab50d8..3b3a68b3 100644 --- a/src/newgdi/glyph.c +++ b/src/newgdi/glyph.c @@ -2806,6 +2806,18 @@ static void draw_glyph_lines (PDC pdc, int x1, int y1, int x2, int y2) } } +BOOL _gdi_if_mark_bbox_is_ok(PDC pdc, Glyph32 gv) +{ + LOGFONT* logfont; + DEVFONT* devfont; + + logfont = pdc->pLogFont; + devfont = SELECT_DEVFONT_BY_GLYPH (logfont, gv); + + return devfont->font_ops->get_feature(logfont, devfont, + DEVFONT_FEATURE_MARK_BBOX) != 0; +} + int _gdi_draw_one_glyph (PDC pdc, Glyph32 glyph_value, BOOL direction, int x, int y, int* adv_x, int* adv_y) { @@ -3091,6 +3103,7 @@ int GUIAPI DrawGlyph (HDC hdc, int x, int y, Glyph32 glyph_value, return advance; } +/* XXX: an experimental API */ int GUIAPI DrawVowel (HDC hdc, int x, int y, Glyph32 glyph_value, int last_adv) { diff --git a/src/newgdi/tabbedtextout.c b/src/newgdi/tabbedtextout.c index 9cdc8c6c..e3229142 100644 --- a/src/newgdi/tabbedtextout.c +++ b/src/newgdi/tabbedtextout.c @@ -161,18 +161,19 @@ static BOOL cb_tabbedtextout (void* context, Glyph32 glyph_value, case ACHAR_BASIC_VOWEL: if (!ctxt->only_extent) { -#if 0 - int bkmode = ctxt->pdc->bkmode; - ctxt->pdc->bkmode = BM_TRANSPARENT; - _gdi_draw_one_glyph (ctxt->pdc, glyph_value, - (ctxt->pdc->ta_flags & TA_X_MASK) != TA_RIGHT, - ctxt->x, ctxt->y, &adv_x, &adv_y); - ctxt->pdc->bkmode = bkmode; -#else - _gdi_draw_one_vowel (ctxt->pdc, glyph_value, - (ctxt->pdc->ta_flags & TA_X_MASK) != TA_RIGHT, - ctxt->last_x, ctxt->last_y, ctxt->last_adv); -#endif + if (_gdi_if_mark_bbox_is_ok(ctxt->pdc, glyph_value)) { + int bkmode = ctxt->pdc->bkmode; + ctxt->pdc->bkmode = ctxt->pdc->bkmode_set; + _gdi_draw_one_glyph (ctxt->pdc, glyph_value, + (ctxt->pdc->ta_flags & TA_X_MASK) != TA_RIGHT, + ctxt->x, ctxt->y, &adv_x, &adv_y); + ctxt->pdc->bkmode = bkmode; + } + else { + _gdi_draw_one_vowel (ctxt->pdc, glyph_value, + (ctxt->pdc->ta_flags & TA_X_MASK) != TA_RIGHT, + ctxt->last_x, ctxt->last_y, ctxt->last_adv); + } } adv_x = adv_y = 0; break; @@ -261,18 +262,19 @@ static BOOL cb_tabbedtextoutex (void* context, Glyph32 glyph_value, break; case ACHAR_BASIC_VOWEL: { -#if 0 - int bkmode = ctxt->pdc->bkmode; - ctxt->pdc->bkmode = BM_TRANSPARENT; - _gdi_draw_one_glyph (ctxt->pdc, glyph_value, - (ctxt->pdc->ta_flags & TA_X_MASK) != TA_RIGHT, - ctxt->x, ctxt->y, &adv_x, &adv_y); - ctxt->pdc->bkmode = bkmode; -#else - _gdi_draw_one_vowel (ctxt->pdc, glyph_value, - (ctxt->pdc->ta_flags & TA_X_MASK) != TA_RIGHT, - ctxt->last_x, ctxt->last_y, ctxt->last_adv); -#endif + if (_gdi_if_mark_bbox_is_ok(ctxt->pdc, glyph_value)) { + int bkmode = ctxt->pdc->bkmode; + ctxt->pdc->bkmode = ctxt->pdc->bkmode_set; + _gdi_draw_one_glyph (ctxt->pdc, glyph_value, + (ctxt->pdc->ta_flags & TA_X_MASK) != TA_RIGHT, + ctxt->x, ctxt->y, &adv_x, &adv_y); + ctxt->pdc->bkmode = bkmode; + } + else { + _gdi_draw_one_vowel (ctxt->pdc, glyph_value, + (ctxt->pdc->ta_flags & TA_X_MASK) != TA_RIGHT, + ctxt->last_x, ctxt->last_y, ctxt->last_adv); + } adv_x = adv_y = 0; break; } diff --git a/src/newgdi/textout.c b/src/newgdi/textout.c index 4a4a8349..9252e9ce 100644 --- a/src/newgdi/textout.c +++ b/src/newgdi/textout.c @@ -128,15 +128,15 @@ static BOOL cb_draw_glyph (void* context, Glyph32 glyph_value, unsigned int char adv_x = adv_y = 0; } else if (check_vowel(char_type)) { - int bkmode = GetBkMode (ctxt->hdc); - SetBkMode (ctxt->hdc, BM_TRANSPARENT); -#if 0 - DrawGlyph (ctxt->hdc, ctxt->x, ctxt->y, glyph_value, &adv_x, &adv_y); -#else - DrawVowel (ctxt->hdc, ctxt->last_x, ctxt->last_y, glyph_value, - ctxt->last_adv); -#endif - SetBkMode (ctxt->hdc, bkmode); + PDC pdc = dc_HDC2PDC(ctxt->hdc); + if (_gdi_if_mark_bbox_is_ok(pdc, glyph_value)) { + DrawGlyph (ctxt->hdc, ctxt->x, ctxt->y, glyph_value, + &adv_x, &adv_y); + } + else { + DrawVowel (ctxt->hdc, ctxt->last_x, ctxt->last_y, + glyph_value, ctxt->last_adv); + } adv_x = 0; adv_y = 0; } @@ -175,18 +175,19 @@ static BOOL cb_textout (void* context, Glyph32 glyph_value, } else if (check_vowel(char_type)) { if (!ctxt->only_extent) { -#if 0 - int bkmode = ctxt->pdc->bkmode; - ctxt->pdc->bkmode = BM_TRANSPARENT; - _gdi_draw_one_glyph (ctxt->pdc, glyph_value, - (ctxt->pdc->ta_flags & TA_X_MASK) != TA_RIGHT, - ctxt->x, ctxt->y, &adv_x, &adv_y); - ctxt->pdc->bkmode = bkmode; -#else - _gdi_draw_one_vowel (ctxt->pdc, glyph_value, - (ctxt->pdc->ta_flags & TA_X_MASK) != TA_RIGHT, - ctxt->last_x, ctxt->last_y, ctxt->last_adv); -#endif + if (_gdi_if_mark_bbox_is_ok(ctxt->pdc, glyph_value)) { + int bkmode = ctxt->pdc->bkmode; + ctxt->pdc->bkmode = ctxt->pdc->bkmode_set; + _gdi_draw_one_glyph (ctxt->pdc, glyph_value, + (ctxt->pdc->ta_flags & TA_X_MASK) != TA_RIGHT, + ctxt->x, ctxt->y, &adv_x, &adv_y); + ctxt->pdc->bkmode = bkmode; + } + else { + _gdi_draw_one_vowel (ctxt->pdc, glyph_value, + (ctxt->pdc->ta_flags & TA_X_MASK) != TA_RIGHT, + ctxt->last_x, ctxt->last_y, ctxt->last_adv); + } } adv_x = adv_y = 0; } @@ -356,18 +357,19 @@ cb_textout_omitted (void* context, Glyph32 glyph_value, unsigned int char_type) adv_x = adv_y = 0; } else if (check_vowel(char_type)) { -#if 0 - int bkmode = ctxt->pdc->bkmode; - ctxt->pdc->bkmode = BM_TRANSPARENT; - _gdi_draw_one_glyph (ctxt->pdc, glyph_value, - (ctxt->pdc->ta_flags & TA_X_MASK) != TA_RIGHT, - ctxt->x, ctxt->y, &adv_x, &adv_y); - ctxt->pdc->bkmode = bkmode; -#else - _gdi_draw_one_vowel (ctxt->pdc, glyph_value, - (ctxt->pdc->ta_flags & TA_X_MASK) != TA_RIGHT, - ctxt->last_x, ctxt->last_y, ctxt->last_adv); -#endif + if (_gdi_if_mark_bbox_is_ok(ctxt->pdc, glyph_value)) { + int bkmode = ctxt->pdc->bkmode; + ctxt->pdc->bkmode = ctxt->pdc->bkmode_set; + _gdi_draw_one_glyph (ctxt->pdc, glyph_value, + (ctxt->pdc->ta_flags & TA_X_MASK) != TA_RIGHT, + ctxt->x, ctxt->y, &adv_x, &adv_y); + ctxt->pdc->bkmode = bkmode; + } + else { + _gdi_draw_one_vowel (ctxt->pdc, glyph_value, + (ctxt->pdc->ta_flags & TA_X_MASK) != TA_RIGHT, + ctxt->last_x, ctxt->last_y, ctxt->last_adv); + } adv_x = adv_y = 0; } else { From f0bae4444c1630d722beb1d2535cc4d3d965e39f Mon Sep 17 00:00:00 2001 From: Vincent Wei Date: Thu, 10 Aug 2023 09:23:56 +0800 Subject: [PATCH 3/3] update version --- README.md | 1 + RELEASE-NOTES.md | 3 ++- Version.md | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6f5cef63..547f1276 100644 --- a/README.md +++ b/README.md @@ -561,6 +561,7 @@ A brief history description of the development progress is listed as follow: 1. May., 2021: FMSoft released MiniGUI version 5.0.6. 1. Jan., 2022: FMSoft released MiniGUI version 5.0.9. 1. Sep., 2022: FMSoft released MiniGUI version 5.0.10. +1. Aug., 2023: FMSoft released MiniGUI version 5.0.13. ## AUTHORS AND COPYING diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index bdcd2e0e..f6ae912a 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -34,7 +34,7 @@ ## Version 5.0.13 -On July 31, 2023, FMSoft announces the availability of MiniGUI 5.0.13, +On Aug. 31, 2023, FMSoft announces the availability of MiniGUI 5.0.13, which is an enhancement release with some minor enhancements of MiniGUI 5.0.x. @@ -48,6 +48,7 @@ In this version, we made some enhancements: - Add `BIDI_FLAG_NONE` and `BIDI_FLAG_LEGACY`. * BUGFIXING: - Ignore C0CTRL characters when renerding text. + - Support for vowels. ## Version 5.0.12 diff --git a/Version.md b/Version.md index aa4da7b0..bdddfb20 100644 --- a/Version.md +++ b/Version.md @@ -1,4 +1,4 @@ -Version 5.0.14 (2023/07/31) +Version 5.0.13 (2023/08/31) This is a minor enhancement and bugfix release of MiniGUI 5.0.x, the stable version.