use draw_one_vowel and DrawVowel for vowel

This commit is contained in:
Vincent Wei
2023-08-09 11:13:40 +08:00
parent 43101379ed
commit 5b27cc70fc
7 changed files with 200 additions and 32 deletions

View File

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

View File

@@ -73,6 +73,8 @@
#if defined(__GNU_LIBRARY__) && !defined(_SEM_SEMUN_UNDEFINED)
/* union semun is defined by including <sys/sem.h> */
#elif defined(__DARWIN__)
/* union semun is defined by including <sys/sem.h> */
#else
/* according to X/OPEN we have to define it ourselves */
union semun {

View File

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

View File

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

View File

@@ -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)
{

View File

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

View File

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