Skip to content

Commit

Permalink
Support for vowels to fix Issue #121
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentWei committed Jul 26, 2023
1 parent 4c2b20c commit 4310137
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 9 deletions.
2 changes: 2 additions & 0 deletions src/font/charset-unicode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 12 additions & 0 deletions src/newgdi/drawtext.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/newgdi/drawtext.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ typedef struct _DRAWTEXTEX2_CTXT
int line_height;

int x, y;
int last_x, last_y;
int advance;

int nFormat;
Expand Down
25 changes: 25 additions & 0 deletions src/newgdi/tabbedtextout.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ typedef struct _TABBEDTEXTOUT_CTXT
int line_height;

int x, y;
int last_x, last_y;
int advance;

BOOL only_extent;
Expand Down Expand Up @@ -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;
Expand All @@ -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;

Expand All @@ -209,6 +218,7 @@ typedef struct _TABBEDTEXTOUTEX_CTXT

/* para for current char. */
int x, y;
int last_x, last_y;
int advance;
} TABBEDTEXTOUTEX_CTXT;

Expand Down Expand Up @@ -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;
Expand All @@ -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;

Expand All @@ -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;

Expand Down Expand Up @@ -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.*/
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
46 changes: 37 additions & 9 deletions src/newgdi/textout.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand All @@ -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;

Expand All @@ -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;
Expand All @@ -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)
Expand All @@ -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;

Expand All @@ -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;

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
Expand All @@ -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;

Expand All @@ -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;

Expand Down Expand Up @@ -599,7 +627,7 @@ int GUIAPI GetTextExtentPoint (HDC hdc,
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,
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 4310137

Please sign in to comment.