From c1cbb8423e04361c08205a90cf2c5319dc8bd5a4 Mon Sep 17 00:00:00 2001 From: Vincent Wei Date: Tue, 26 Mar 2019 18:44:05 +0800 Subject: [PATCH] parameters of CB_GLYPH_LAID_OUT --- include/gdi.h | 2 +- src/newgdi/layoutinfo.c | 39 ++++++++++++++++++++++++++++++++------- src/newgdi/layoutinfo.h | 3 ++- src/newgdi/textrunsinfo.h | 2 +- 4 files changed, 36 insertions(+), 10 deletions(-) diff --git a/include/gdi.h b/include/gdi.h index dd81454f..fd2af2a6 100644 --- a/include/gdi.h +++ b/include/gdi.h @@ -12739,7 +12739,7 @@ MG_EXPORT LAYOUTINFO* GUIAPI CreateLayoutInfo( MG_EXPORT BOOL GUIAPI DestroyLayoutInfo(LAYOUTINFO* layout_info); typedef BOOL (*CB_GLYPH_LAID_OUT) (GHANDLE ctxt, - LOGFONT* lf, RGBCOLOR color, Glyph32 gv, const GLYPHPOS* pos); + LOGFONT* lf, Uchar32 uc, Glyph32 gv, const GLYPHPOS* pos, RGBCOLOR color); /** * Layout the next line of a paragraph according to the layout information. diff --git a/src/newgdi/layoutinfo.c b/src/newgdi/layoutinfo.c index 5db40354..4c7c67c8 100644 --- a/src/newgdi/layoutinfo.c +++ b/src/newgdi/layoutinfo.c @@ -1616,7 +1616,8 @@ done: return line; } -static int traverse_line_glyphs(LAYOUTLINE* line, int x, int y, +static int traverse_line_glyphs(const LAYOUTINFO* layout, + const LAYOUTLINE* line, int x, int y, CB_GLYPH_LAID_OUT cb_laid_out, GHANDLE ctxt) { int j = 0; @@ -1626,15 +1627,39 @@ static int traverse_line_glyphs(LAYOUTLINE* line, int x, int y, list_for_each(i, &line->gruns) { GlyphRun* run = (GlyphRun*)i; for (j = 0; j < run->gstr->nr_glyphs; j++) { - ShapedGlyph* sg = run->gstr->glyphs + j; + int index; + Uchar32 uc; GLYPHPOS pos; + RGBCOLOR color; + ShapedGlyph* glyph_info; + + index = run->lrun->si + run->gstr->log_clusters[j]; + uc = run->lrun->ucs[index]; + color = __mg_textruns_get_text_color(layout->truninfo, index); + glyph_info = run->gstr->glyphs + j; pos.x = x + line_adv; pos.y = y; - pos.x_off = sg->x_off; - pos.y_off = sg->y_off; - line_adv += sg->width; - cb_laid_out(ctxt, run->lrun->lf, 0, run->gstr->glyphs[j].gv, &pos); + pos.x_off = glyph_info->x_off; + pos.y_off = glyph_info->y_off; + + pos.suppressed = 0; + pos.whitespace = 0; + pos.orientation = run->lrun->ort; + pos.hanged = glyph_info->hanged; + + if (run->lrun->flags & LAYOUTRUN_FLAG_NO_SHAPING) { + if (glyph_info->width > 0) { + pos.whitespace = 1; + } + else { + pos.suppressed = 1; + } + } + + cb_laid_out(ctxt, run->lrun->lf, uc, glyph_info->gv, &pos, color); + + line_adv += glyph_info->width; } } return 0; @@ -1742,7 +1767,7 @@ out: } if (next_line && cb_laid_out) { - traverse_line_glyphs(next_line, x, y, cb_laid_out, ctxt); + traverse_line_glyphs(layout, next_line, x, y, cb_laid_out, ctxt); } return next_line; diff --git a/src/newgdi/layoutinfo.h b/src/newgdi/layoutinfo.h index 447bf0bb..d5ae18cf 100644 --- a/src/newgdi/layoutinfo.h +++ b/src/newgdi/layoutinfo.h @@ -51,9 +51,10 @@ struct _ShapedGlyph { Glyph32 gv; int x_off; int y_off; - int width; + Uint32 width:24; Uint32 is_cluster_start:1; + Uint32 hanged:2; }; struct _GlyphString { diff --git a/src/newgdi/textrunsinfo.h b/src/newgdi/textrunsinfo.h index a829c3e1..65508b9a 100644 --- a/src/newgdi/textrunsinfo.h +++ b/src/newgdi/textrunsinfo.h @@ -125,7 +125,7 @@ struct _TEXTRUNSINFO { extern "C" { #endif /* __cplusplus */ -RGBCOLOR __mg_textruns_get_color(const TEXTRUNSINFO* runinfo, int index); +RGBCOLOR __mg_textruns_get_text_color(const TEXTRUNSINFO* runinfo, int index); const TextRun* __mg_text_run_get_by_offset(const TEXTRUNSINFO* runinfo, int index, int *start_offset);