diff --git a/include/gdi.h b/include/gdi.h index 54e49559..020cb1ef 100644 --- a/include/gdi.h +++ b/include/gdi.h @@ -12904,16 +12904,6 @@ typedef struct _RENDERDATA { */ LOGFONT* logfont; - /** - * The text color of the glyph. - */ - RGBCOLOR fg_color; - - /** - * The background color of the glyph. - */ - RGBCOLOR bg_color; - /** * The Unicode character corresponding to the glyph. */ @@ -12951,8 +12941,7 @@ typedef BOOL (*CB_GLYPH_LAID_OUT) (GHANDLE ctxt, /** * \fn LAYOUTLINE* GUIAPI LayoutNextLine(LAYOUTINFO* layout_info, - * LAYOUTLINE* prev_line, - * int x, int y, int max_extent, BOOL last_line, SIZE* line_size, + * LAYOUTLINE* prev_line, int max_extent, BOOL last_line, * CB_GLYPH_LAID_OUT cb_laid_out, GHANDLE ctxt) * \brief Layout the next line of a paragraph according to the layout * information. @@ -12985,12 +12974,6 @@ typedef BOOL (*CB_GLYPH_LAID_OUT) (GHANDLE ctxt, * \param cb_laid_out The callback for one laid out glyph. * \param ctxt The context will be passed to \a cb_laid_out. * This parameter is only effective when cb_laid_out is not NULL. - * \param x The x-corrdinate of the output position of the first glyph - * in the next line. This parameter is only effective when - * \a cb_laid_out is not NULL. - * \param y The y-corrdinate of the output position of the first glyph - * in the next line. This parameter is only effective when - * \a cb_laid_out is not NULL. * * \return NULL for no line, otherwise the next line object. * @@ -12999,9 +12982,8 @@ typedef BOOL (*CB_GLYPH_LAID_OUT) (GHANDLE ctxt, * Since 3.4.0 */ MG_EXPORT LAYOUTLINE* GUIAPI LayoutNextLine(LAYOUTINFO* layout_info, - LAYOUTLINE* prev_line, - int max_extent, BOOL last_line, - CB_GLYPH_LAID_OUT cb_laid_out, GHANDLE ctxt, int x, int y); + LAYOUTLINE* prev_line, int max_extent, BOOL last_line, + CB_GLYPH_LAID_OUT cb_laid_out, GHANDLE ctxt); /** * \fn BOOL GUIAPI GetLayoutLineSize(LAYOUTLINE* line, @@ -13061,7 +13043,7 @@ MG_EXPORT int GUIAPI CalcLayoutBoundingRect(LAYOUTINFO* layout_info, int x, int y, RECT* bounding); /** - * \fn BOOL DrawShapedGlyph(HDC hdc, LOGFONT* logfont, + * \fn BOOL DrawShapedGlyph(HDC hdc, * Glyph32 glyph_value, const GLYPHPOS* glyph_pos, * const RENDERDATA render_data) * \brief Draw a laid out glyph. diff --git a/src/font/unicode-iterators.c b/src/font/unicode-iterators.c index 3abd15ef..d3d7a2e3 100644 --- a/src/font/unicode-iterators.c +++ b/src/font/unicode-iterators.c @@ -3,8 +3,7 @@ * and Graphics User Interface (GUI) support system for embedded systems * and smart IoT devices. * - * Copyright (C) 2002~2018, Beijing FMSoft Technologies Co., Ltd. - * Copyright (C) 1998~2002, WEI Yongming + * Copyright (C) 2019, Beijing FMSoft Technologies Co., Ltd. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -33,7 +32,7 @@ */ /* -** ucs-iterator.c: The implementation of the uchar string iterators. +** unicode-iterators.c: The implementation of the uchar string iterators. ** ** Create by WEI Yongming at 2019/03/18 ** diff --git a/src/newgdi/glyph-shaped.c b/src/newgdi/glyph-shaped.c index e001ca75..413a1b40 100644 --- a/src/newgdi/glyph-shaped.c +++ b/src/newgdi/glyph-shaped.c @@ -62,7 +62,49 @@ BOOL DrawShapedGlyph(HDC hdc, Glyph32 gv, const GLYPHPOS* glyph_pos, const RENDERDATA* render_data) { - return FALSE; + RGBCOLOR fg_color, bg_color; + + if (glyph_pos == NULL || render_data == NULL) + return FALSE; + + bg_color = GetBackgroundColorInTextRuns(render_data->truninfo, + render_data->uc_index); + + if (glyph_pos->suppressed == 0 && glyph_pos->whitespace == 0) { + Uint32 old_ta; + PLOGFONT old_lf = NULL; + gal_pixel fg_pixel, bg_pixel; + + old_ta = SetTextAlign(hdc, TA_LEFT | TA_TOP | TA_UPDATECP); + + old_lf = SelectFont(hdc, render_data->logfont); + + fg_color = GetTextColorInTextRuns(render_data->truninfo, + render_data->uc_index); + fg_pixel = DWORD2Pixel(hdc, fg_color); + SetTextColor(hdc, (DWORD)fg_pixel); + + if (bg_color) { + bg_pixel = DWORD2Pixel(hdc, bg_color); + SetBkColor(hdc, (DWORD)bg_pixel); + SetBkMode(hdc, BM_OPAQUE); + } + else { + SetBkMode(hdc, BM_TRANSPARENT); + } + + DrawGlyph(hdc, glyph_pos->x, glyph_pos->y, gv, NULL, NULL); + + if (old_lf) + SelectFont(hdc, old_lf); + + SetTextAlign(hdc, old_ta); + } + else if (glyph_pos->whitespace && bg_color) { + // TODO: draw background for whitespace. + } + + return TRUE; } int DrawLayoutLine(HDC hdc, const LAYOUTLINE* line, diff --git a/src/newgdi/layoutinfo.c b/src/newgdi/layoutinfo.c index b18d3653..54ce429d 100644 --- a/src/newgdi/layoutinfo.c +++ b/src/newgdi/layoutinfo.c @@ -1354,16 +1354,8 @@ static void justify_clusters (LAYOUTLINE *line, LayoutState *state) dir = run->lrun->el % 2 == 0 ? +1 : -1; - /* We need character offset of the start of the run. - * We don't have this. - * Compute by counting from the beginning of the line. - * The naming is confusing. Note that: - * - * run->lrun->si is the index of start of run. - * state->line_start_index is the index of start of line. - */ assert(run->lrun->si >= state->line_start_index); - offset = state->line_start_index + run->lrun->si; + offset = run->lrun->si; if ((have_cluster = (dir > 0))) __mg_glyph_run_iter_init_start(&cluster_iter, run, text); @@ -1491,7 +1483,7 @@ static void justify_words (LAYOUTLINE *line, int offset; assert(run->lrun->si >= state->line_start_index); - offset = state->line_start_index + run->lrun->si; + offset = run->lrun->si; for (have_cluster = __mg_glyph_run_iter_init_start(&cluster_iter, run, text); @@ -1732,7 +1724,7 @@ done: } static int traverse_line_glyphs(const LAYOUTINFO* layout, - const LAYOUTLINE* line, int x, int y, + const LAYOUTLINE* line, CB_GLYPH_LAID_OUT cb_laid_out, GHANDLE ctxt) { int j; @@ -1751,17 +1743,19 @@ static int traverse_line_glyphs(const LAYOUTINFO* layout, ShapedGlyph* glyph_info; extra.logfont = run->lrun->lf; +#if 0 extra.fg_color = GetTextColorInTextRuns(layout->truninfo, extra.uc_index); extra.bg_color = GetBackgroundColorInTextRuns(layout->truninfo, extra.uc_index); +#endif extra.uc = run->lrun->ucs[run->gstr->log_clusters[j]]; extra.uc_index = run->lrun->si + run->gstr->log_clusters[j]; glyph_info = run->gstr->glyphs + j; - pos.x = x + line_adv; - pos.y = y; + pos.x = line_adv; + pos.y = 0; pos.x_off = glyph_info->x_off; pos.y_off = glyph_info->y_off; pos.advance = glyph_info->width; @@ -1798,7 +1792,7 @@ static int traverse_line_glyphs(const LAYOUTINFO* layout, LAYOUTLINE* GUIAPI LayoutNextLine( LAYOUTINFO* layout, LAYOUTLINE* prev_line, int max_extent, BOOL last_line, - CB_GLYPH_LAID_OUT cb_laid_out, GHANDLE ctxt, int x, int y) + CB_GLYPH_LAID_OUT cb_laid_out, GHANDLE ctxt) { LAYOUTLINE* next_line = NULL; LayoutState state; @@ -1806,7 +1800,8 @@ LAYOUTLINE* GUIAPI LayoutNextLine( if (prev_line && prev_line->list.next && prev_line->list.next != &layout->lines) { // must be a line persisted and not the last line. - return (LAYOUTLINE*)prev_line->list.next; + next_line = (LAYOUTLINE*)prev_line->list.next; + goto out; } if (layout->persist && layout->nr_left_ucs == 0) { @@ -1933,7 +1928,7 @@ out: } if (next_line && cb_laid_out) { - traverse_line_glyphs(layout, next_line, x, y, cb_laid_out, ctxt); + traverse_line_glyphs(layout, next_line, cb_laid_out, ctxt); } return next_line; @@ -1993,7 +1988,7 @@ int GUIAPI CalcLayoutBoundingRect(LAYOUTINFO* layout, } line = LayoutNextLine(layout, line, max_line_extent, last_line, - NULL, NULL, 0, 0); + NULL, NULL); if (line == NULL) { break;