Support for vowels to fix Issue #121

This commit is contained in:
Vincent Wei
2023-07-26 16:49:01 +08:00
parent 4c2b20c49f
commit 43101379ed
5 changed files with 77 additions and 9 deletions

View File

@@ -210,6 +210,8 @@ static unsigned int unicode_char_type (Achar32 chv)
mchar_type = ACHAR_BASIC_LF;
else if (break_type == UCHAR_BREAK_SPACE)
mchar_type = ACHAR_BASIC_SPACE;
else if (basic_type == UCHAR_CATEGORY_NON_SPACING_MARK)
mchar_type = ACHAR_BASIC_VOWEL;
else if (chv != 0x00AD && ISZEROWIDTHTYPE (basic_type))
mchar_type = ACHAR_BASIC_ZEROWIDTH;
else if ((chv >= 0x1160 && chv < 0x1200)

View File

@@ -148,9 +148,15 @@ static BOOL cb_drawtextex2 (void* context, Glyph32 glyph_value,
if (!ctxt->only_extent) {
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;
adv_x = adv_y = 0;
}
@@ -174,6 +180,8 @@ static BOOL cb_drawtextex2 (void* context, Glyph32 glyph_value,
break;
}
ctxt->last_x = ctxt->x;
ctxt->last_y = ctxt->y;
ctxt->x += adv_x;
ctxt->y += adv_y;
@@ -189,6 +197,8 @@ int _gdi_get_drawtext_extent (PDC pdc, const unsigned char* text, int len,
ctxt.pdc = pdc;
ctxt.x = 0;
ctxt.y = 0;
ctxt.last_x = 0;
ctxt.last_y = 0;
ctxt.advance = 0;
ctxt.only_extent = TRUE;
ctxt.nFormat = _tmp->nFormat;
@@ -306,6 +316,8 @@ int DrawTextEx2 (HDC hdc, const char* pText, int nCount,
ctxt.pdc = pdc;
ctxt.x = x;
ctxt.y = y;
ctxt.last_x = x;
ctxt.last_y = y;
while (nCount > 0) {
int line_x, maxwidth;

View File

@@ -131,6 +131,7 @@ typedef struct _DRAWTEXTEX2_CTXT
int line_height;
int x, y;
int last_x, last_y;
int advance;
int nFormat;

View File

@@ -122,6 +122,7 @@ typedef struct _TABBEDTEXTOUT_CTXT
int line_height;
int x, y;
int last_x, last_y;
int advance;
BOOL only_extent;
@@ -161,9 +162,15 @@ static BOOL cb_tabbedtextout (void* context, Glyph32 glyph_value,
if (!ctxt->only_extent) {
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;
}
adv_x = adv_y = 0;
@@ -187,6 +194,8 @@ static BOOL cb_tabbedtextout (void* context, Glyph32 glyph_value,
break;
}
ctxt->last_x = ctxt->x;
ctxt->last_y = ctxt->y;
ctxt->x += adv_x;
ctxt->y += adv_y;
@@ -209,6 +218,7 @@ typedef struct _TABBEDTEXTOUTEX_CTXT
/* para for current char. */
int x, y;
int last_x, last_y;
int advance;
} TABBEDTEXTOUTEX_CTXT;
@@ -250,9 +260,15 @@ static BOOL cb_tabbedtextoutex (void* context, Glyph32 glyph_value,
case ACHAR_BASIC_VOWEL: {
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;
adv_x = adv_y = 0;
break;
@@ -269,6 +285,8 @@ static BOOL cb_tabbedtextoutex (void* context, Glyph32 glyph_value,
}
}
ctxt->last_x = ctxt->x;
ctxt->last_y = ctxt->y;
ctxt->x += adv_x;
ctxt->y += adv_y;
@@ -293,6 +311,8 @@ int _gdi_tabbed_text_out (PDC pdc, int x, int y,
ctxt.x = x;
ctxt.y = y;
ctxt.last_x = x;
ctxt.last_y = y;
ctxt.advance = 0;
ctxt.only_extent = only_extent;
@@ -437,6 +457,8 @@ static int _gdi_tabbedex_text_out (PDC pdc, int x, int y,
ctxt.x = x;
ctxt.y = y;
ctxt.last_x = x;
ctxt.last_y = y;
ctxt.advance = 0;
/* init the tab relative info.*/
@@ -593,6 +615,7 @@ static int get_tabbed_text_extent_point_for_bidi(HDC hdc,
int adv_x = 0, adv_y = 0;
switch (achar_type & ACHARTYPE_BASIC_MASK) {
case ACHAR_BASIC_VOWEL:
case ACHAR_BASIC_ZEROWIDTH:
case ACHAR_BASIC_CTRL1:
case ACHAR_BASIC_CTRL2:
@@ -715,6 +738,7 @@ int GUIAPI GetTabbedTextExtentPoint (HDC hdc, const char* text,
gv = GetGlyphValueAlt(log_font, ach);
switch (char_type & ACHARTYPE_BASIC_MASK) {
case ACHAR_BASIC_VOWEL:
case ACHAR_BASIC_ZEROWIDTH:
case ACHAR_BASIC_CTRL1:
case ACHAR_BASIC_CTRL2:
@@ -792,6 +816,7 @@ int GUIAPI GetTabbedACharsExtentPointEx(HDC hdc,
int adv_x = 0, adv_y = 0;
switch (achar_type & ACHARTYPE_BASIC_MASK) {
case ACHAR_BASIC_VOWEL:
case ACHAR_BASIC_ZEROWIDTH:
case ACHAR_BASIC_CTRL1:
case ACHAR_BASIC_CTRL2:

View File

@@ -113,8 +113,8 @@ static inline BOOL is_utf16_logfont (PDC pdc)
typedef struct _DRAW_GLYPHS_CTXT {
HDC hdc;
int x;
int y;
int x, y;
int last_x, last_y;
int advance;
} DRAW_GLYPHS_CTXT;
@@ -129,7 +129,11 @@ static BOOL cb_draw_glyph (void* context, Glyph32 glyph_value, unsigned int char
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
DrawGlyph (ctxt->hdc, ctxt->last_x, ctxt->last_y, glyph_value, &adv_x, &adv_y);
#endif
SetBkMode (ctxt->hdc, bkmode);
adv_x = 0;
adv_y = 0;
@@ -139,6 +143,8 @@ static BOOL cb_draw_glyph (void* context, Glyph32 glyph_value, unsigned int char
glyph_value, &adv_x, &adv_y);
}
ctxt->last_x = ctxt->x;
ctxt->last_y = ctxt->y;
ctxt->x += adv_x;
ctxt->y += adv_y;
@@ -148,8 +154,8 @@ static BOOL cb_draw_glyph (void* context, Glyph32 glyph_value, unsigned int char
typedef struct _TEXTOUT_CTXT
{
PDC pdc;
int x;
int y;
int x, y;
int last_x, last_y;
int advance;
BOOL only_extent;
} TEXTOUT_CTXT;
@@ -167,12 +173,18 @@ static BOOL cb_textout (void* context, Glyph32 glyph_value,
if (!ctxt->only_extent) {
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;
}
adv_x = 0;
adv_x = adv_y = 0;
}
else {
if (ctxt->only_extent)
@@ -189,6 +201,8 @@ static BOOL cb_textout (void* context, Glyph32 glyph_value,
}
}
ctxt->last_x = ctxt->x;
ctxt->last_y = ctxt->y;
ctxt->x += adv_x;
ctxt->y += adv_y;
@@ -206,6 +220,8 @@ int _gdi_text_out (PDC pdc, int x, int y,
ctxt.pdc = pdc;
ctxt.x = x;
ctxt.y = y;
ctxt.last_x = x;
ctxt.last_y = y;
ctxt.advance = 0;
ctxt.only_extent = FALSE;
@@ -261,6 +277,8 @@ int _gdi_get_text_extent (PDC pdc, const unsigned char* text, int len,
ctxt.pdc = pdc;
ctxt.x = 0;
ctxt.y = 0;
ctxt.last_x = 0;
ctxt.last_y = 0;
ctxt.advance = 0;
ctxt.only_extent = TRUE;
@@ -313,8 +331,8 @@ static int str_omitted_3dot (char *dest, const char *src,
typedef struct _TEXTOUTOMITTED_CTXT
{
PDC pdc;
int x;
int y;
int x, y;
int last_x, last_y;
int advance;
Uint32 max_extent;
} TEXTOUTOMITTED_CTXT;
@@ -332,9 +350,15 @@ cb_textout_omitted (void* context, Glyph32 glyph_value, unsigned int char_type)
else if (check_vowel(char_type)) {
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;
adv_x = adv_y = 0;
}
@@ -355,6 +379,8 @@ cb_textout_omitted (void* context, Glyph32 glyph_value, unsigned int char_type)
ctxt->pdc->bkmode = bkmode;
}
ctxt->last_x = ctxt->x;
ctxt->last_y = ctxt->y;
ctxt->x += adv_x;
ctxt->y += adv_y;
@@ -372,6 +398,8 @@ int _gdi_textout_omitted (PDC pdc, int x, int y,
ctxt.pdc = pdc;
ctxt.x = x;
ctxt.y = y;
ctxt.last_x = x;
ctxt.last_y = y;
ctxt.advance = 0;
ctxt.max_extent = max_extent;
@@ -599,7 +627,7 @@ ret:
int GUIAPI DrawACharString (HDC hdc, int startx, int starty,
Achar32* achars, int len, int* adv_x, int* adv_y)
{
DRAW_GLYPHS_CTXT ctxt = {hdc, startx, starty, 0};
DRAW_GLYPHS_CTXT ctxt = {hdc, startx, starty, startx, starty, 0};
if ((((PDC)hdc)->ta_flags & TA_X_MASK) == TA_LEFT)
_gdi_output_visual_achars((PDC)hdc, achars,
@@ -693,7 +721,7 @@ int GUIAPI GetACharsExtent(HDC hdc, Achar32* achars, int nr_achars, SIZE* size)
devfont = SELECT_DEVFONT_BY_GLYPH(log_font, achars[i]);
char_type = devfont->charset_ops->char_type(achars[i]);
if (check_zero_width (char_type)) {
if (check_zero_width(char_type) || check_vowel(char_type)) {
adv_x = adv_y = 0;
}
else {