From 7ce1fe47ff71831ee7cc6ae45600239741579c17 Mon Sep 17 00:00:00 2001 From: Vincent Wei Date: Wed, 27 Feb 2019 18:33:32 +0800 Subject: [PATCH] implementation of character transformation of GetGlyphsAndBreaks; fix a bug of UCharToFullSizeKana --- include/gdi.h | 2 +- src/font/charset.c | 2 +- src/newgdi/glyph-css.c | 46 ++++++++++++++++++++++++++++++++++++++---- 3 files changed, 44 insertions(+), 6 deletions(-) diff --git a/include/gdi.h b/include/gdi.h index f2156d75..3dc919d7 100644 --- a/include/gdi.h +++ b/include/gdi.h @@ -10312,7 +10312,7 @@ static inline int GUIAPI LanguageCodeFromISO639s1Code (const char* iso639_1) * * - CTR_NONE, * - or one of CTR_CAPITALIZE, CTR_UPPERCASE, and CTR_LOWERCASE, - * - and OR'ed with CTR_ FULL_WIDTH and/or CTR_FULL_SIZE_KANA + * - and OR'ed with CTR_FULL_WIDTH and/or CTR_FULL_SIZE_KANA * * @{ */ diff --git a/src/font/charset.c b/src/font/charset.c index d219517a..ef59c4fc 100644 --- a/src/font/charset.c +++ b/src/font/charset.c @@ -4798,7 +4798,7 @@ Uchar32 GUIAPI UCharToFullSizeKana (Uchar32 uc) int mid = TABLESIZE (kana_small_to_full_size_table) / 2; if (uc < kana_small_to_full_size_table[lower].one - || uc < kana_small_to_full_size_table[upper].one) + || uc > kana_small_to_full_size_table[upper].one) return uc; do { diff --git a/src/newgdi/glyph-css.c b/src/newgdi/glyph-css.c index 54a453f7..91f6ef87 100644 --- a/src/newgdi/glyph-css.c +++ b/src/newgdi/glyph-css.c @@ -1382,6 +1382,14 @@ static void dbg_dump_gbctxt(struct glyph_break_ctxt* gbctxt, #define dbg_dump_gbctxt(gbctxt, func, uc, gwsbo) #endif +static inline Glyph32 uc2gv(Glyph32 gv, Uchar32 uc) +{ + if (IS_MBC_GLYPH(gv)) + return SET_MBC_GLYPH(uc); + + return uc; +} + static int gbctxt_push_back(struct glyph_break_ctxt* gbctxt, Glyph32 gv, Uchar32 uc, Uint8 bt, Uint16 lbo) { @@ -1452,6 +1460,39 @@ static int gbctxt_push_back(struct glyph_break_ctxt* gbctxt, check_sentence_breaks(gbctxt, uc, gc, gbctxt->n); dbg_dump_gbctxt(gbctxt, "check_sentence_breaks", uc, gwsbo); + // Character Transformation + // NOTE: Assume character transformation will not affect the breaks + if (gbctxt->ctr) { + Uchar32 new_uc = uc; + + switch(gbctxt->ctr & CTR_CASE_MASK) { + case CTR_UPPERCASE: + new_uc = UCharToUpper(uc); + break; + + case CTR_LOWERCASE: + new_uc = UCharToLower(uc); + break; + + case CTR_CAPITALIZE: + if (gbctxt->bos[gbctxt->n] & BOV_WB_WORD_START) + new_uc = UCharToUpper(uc); + break; + } + + if (gbctxt->ctr & CTR_FULL_WIDTH) { + new_uc = UCharToFullWidth(new_uc); + } + + if (gbctxt->ctr & CTR_FULL_SIZE_KANA) { + new_uc = UCharToFullSizeKana(new_uc); + } + + if (new_uc != uc) { + gbctxt->gvs[gbctxt->n - 1] = uc2gv(gv, new_uc); + } + } + gbctxt->prev_uc = uc; /* uc might not be a valid Unicode base character, but really all we @@ -2237,10 +2278,7 @@ int GUIAPI GetGlyphsAndBreaks(LOGFONT* logfont, const char* mstr, int mstr_len, // Every tab is converted to a space (U+0020). _DBG_PRINTF ("CSS: Every tab is converted to a space (U+0020)\n"); uc = UCHAR_SPACE; - if (IS_MBC_GLYPH(gv)) - gv = SET_MBC_GLYPH(UCHAR_SPACE); - else - gv = UCHAR_SPACE; + gv = uc2gv(gv, uc); } /*