diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 9ef83837..554b6496 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -267,42 +267,68 @@ We use the slice allocator when laying out the text in complex scripts. Note that this implementation is derived from LGPL'd glib. -#### Other Changes +#### Backward Compatibility Issues -* The fields `height` and `descent` have been removed from GLYPHINFO structure. -One should get the font metrics information by calling `GetFontMetrics` function -if you want to get the height and descent data of one font. +In MiniGUI 4.0.0, we changed some unreasonable APIs which were introduced +in early versions. There are also other changes broke the backward +compatibility. This section gives you a summary about these changes. -* The the basic glyph type and break type have been removed from GLYPHINFO -structure. - -* More fields added for GLYPHBITMAP structure in order to return the completed -rasterized glyph bitmap information. - -* A new BITMAP type: `BMP_TYPE_REPLACEKEY`. When `bmType` of a BITMAP object -has this bit set, any pixel which is equal to `bmColorKey` will be replaced by -`bmColorRep`. +* Rename `UChar32` to `Uchar32` and `UChar16` to `Uchar16` in order to +avoid the conflict with typedef of UChar32 in the system header +``. * Rename `mg_FT_LcdFilter` to `FT2LCDFilter` in order to follow MiniGUI naming rules. -* Rename `UChar32` to `Uchar32` and `UChar16` to `Uchar16` in order to -avoid the conflict with typedef of UChar32 in 'unicode/umachine.h'. - * Redefine `Uchar32` and `Glyph32` as `Uint32` instead of `int`. +In early versions, we did not significantly distinguish between +characters and glyphs. This will lead to some confusion. Therefore, +we introduce a new type called `Achar32`, which is the character's +index value under a certain charset/encoding. While the type `Glyph32` +is the index value of a glyph in a font. + +In order to reflect the correct character and glyph concepts, +the following functions were changed: + + * GetGlyphShape -> GetShapedAChar + +The following functions are changed and deprecated, you should use +the new Unicode version functions instead: + + * GetGlyphBIDIType -> GetACharBidiType + * BIDIGetTextLogicalGlyphs -> BIDIGetTextLogicalAChars + * BIDIGetTextVisualGlyphs -> BIDIGetTextVisualAChars + * BIDILogAChars2VisGlyphsEx -> BIDILogAChars2VisACharsEx + * BIDILogAChars2VisGlyphs -> BIDILogAChars2VisAChars + +The following new functions were added: + + * GetGlyphValueAlt + * GetACharType + * GetMirrorAChar + +The following functions are deprecated: + + * BIDIGetTextRangesLog2Vis + * BIDIGetLogicalEmbedLevelsEx + * GetGlyphBitmap + +The fields `height` and `descent` have been removed from GLYPHINFO structure. +You should get the font metrics information by calling `GetFontMetrics` function +if you want to get the height and descent data of one font. + +The the basic glyph type and break type have been removed from GLYPHINFO +structure. You should use `GetACharType` instead. + +#### Other Changes + +A new BITMAP type `BMP_TYPE_REPLACEKEY` was added. When `bmType` of a BITMAP object +has this bit set, any pixel which is equal to `bmColorKey` will be replaced by +`bmColorRep`. + #### Deprecated APIs or Features -The following old APIs are deprecated, you should use the Unicode version -APIs instead: - -* BIDIGetTextLogicalAChars -* BIDIGetTextRangesLog2Vis -* BIDIGetTextVisualAChars -* BIDILogAChars2VisACharsEx -* BIDILogAChars2VisAChars -* BIDIGetLogicalEmbedLevelsEx - Support for FreeType1 was removed. You should always use FreeType2 to support vector fonts, such as TrueType fonts (TTF), TrueType collections (TTC), OpenType fonts (OTF, both TrueType diff --git a/include/gdi.h b/include/gdi.h index b0926bf0..85699594 100644 --- a/include/gdi.h +++ b/include/gdi.h @@ -12042,7 +12042,23 @@ MG_EXPORT int GUIAPI GetACharsExtentPoint (HDC hdc, Achar32* achars, int nr_achars, int max_extent, SIZE* size); /** - * \fn Glyph32 GUIAPI GetGlyphValue (LOGFONT* logfont, Achar32 chv) + * \fn Glyph32 GUIAPI GetGlyphValue (LOGFONT* logfont, const char* mchar, \ + * int mchar_len, const char* pre_mchar, int pre_len) + * \brief Get the glyph value of a multi-byte character. + * + * \param logfont The logical font. + * \param mchar The pointer to the multi-byte character. + * \param mchar_len The length of \a mchar in bytes. + * \param pre_mchar The pointer to the multi-byte character before \a mchar. + * \param pre_len The length of \a per_mchar in bytes. + * + * \return The glyph value of the multi-byte character. + */ +MG_EXPORT Glyph32 GUIAPI GetGlyphValue (LOGFONT* logfont, const char* mchar, + int mchar_len, const char* pre_mchar, int pre_len); + +/** + * \fn Glyph32 GUIAPI GetGlyphValueAlt (LOGFONT* logfont, Achar32 chv) * \brief Get the LOGFONT glyph value of an abstract character. * * \param logfont The logical font. @@ -12051,7 +12067,7 @@ MG_EXPORT int GUIAPI GetACharsExtentPoint (HDC hdc, Achar32* achars, * \return The glyph value of the abstract character; * INV_GLYPH_VALUE on failure. */ -MG_EXPORT Glyph32 GUIAPI GetGlyphValue(LOGFONT* logfont, Achar32 chv); +MG_EXPORT Glyph32 GUIAPI GetGlyphValueAlt(LOGFONT* logfont, Achar32 chv); /** * \fn int GUIAPI DrawGlyph (HDC hdc, int x, int y, Glyph32 glyph_value, \ diff --git a/src/newgdi/glyph.c b/src/newgdi/glyph.c index c653fa1b..49f1c3c6 100644 --- a/src/newgdi/glyph.c +++ b/src/newgdi/glyph.c @@ -71,7 +71,7 @@ int ft2IsFreeTypeDevfont (DEVFONT* devfont); #define FS_WEIGHT_AUTOBOLD 29 -Glyph32 GetGlyphValue(LOGFONT* lf, Achar32 chv) +Glyph32 GetGlyphValueAlt(LOGFONT* lf, Achar32 chv) { Glyph32 gv = INV_GLYPH_VALUE; int i, dfi = 0; @@ -123,6 +123,15 @@ error: return INV_GLYPH_VALUE; } +Glyph32 GUIAPI GetGlyphValue (LOGFONT* logfont, const char* mchar, + int mchar_len, const char* pre_mchar, int pre_len) +{ + Achar32 achar = GetACharValue(logfont, mchar, + mchar_len, pre_mchar, pre_len); + + return GetGlyphValueAlt(logfont, achar); +} + int GUIAPI GetGlyphInfo (LOGFONT* logfont, Glyph32 glyph_value, GLYPHINFO* glyph_info) { @@ -192,7 +201,7 @@ void GUIAPI GetGlyphBitmap (LOGFONT* logfont, const char* mchar, memset(&glyph_info, 0, sizeof(GLYPHINFO)); achar = GetACharValue(logfont,(const char*)mchar, mchar_len, NULL, 0); - glyph_value = GetGlyphValue(logfont, achar); + glyph_value = GetGlyphValueAlt(logfont, achar); glyph_info.mask = GLYPH_INFO_METRICS | GLYPH_INFO_BMP; glyph_info.bmp_type = GLYPHBMP_TYPE_MONO; diff --git a/src/newgdi/layout-ellipsize.c b/src/newgdi/layout-ellipsize.c index 78d8e034..1302a0d6 100644 --- a/src/newgdi/layout-ellipsize.c +++ b/src/newgdi/layout-ellipsize.c @@ -345,7 +345,8 @@ static void shape_ellipsis (EllipsizeState *state) layout_run = __mg_layout_run_new_ellipsis (state->layout, text_run, ellipsis_ucs, 1); - ellipsis_gv = GetGlyphValue(layout_run->lf, ellipsis_ucs[0]); + ellipsis_gv = GetGlyphValueAlt(layout_run->lf, + UCHAR2ACHAR(ellipsis_ucs[0])); /* If the devfont of the glyph value of the specific ellipsis character * is SBC devfont, we use "...". */ diff --git a/src/newgdi/layout.c b/src/newgdi/layout.c index 53c1f010..fbd0a2f8 100644 --- a/src/newgdi/layout.c +++ b/src/newgdi/layout.c @@ -474,15 +474,19 @@ static void shape_space(const LAYOUT* layout, const LayoutRun* lrun, gstr->glyphs[i].y_off = 0; if (gc == UCHAR_CATEGORY_SPACE_SEPARATOR) { - Glyph32 space_gv = GetGlyphValue(lrun->lf, UCHAR_SPACE); - gstr->glyphs[i].width - = _font_get_glyph_log_width(lrun->lf, space_gv); + Glyph32 space_gv; if (IsUCharWide(lrun->ucs[i])) { - Glyph32 space_gv = GetGlyphValue(lrun->lf, UCHAR_IDSPACE); - gstr->glyphs[i].width - = _font_get_glyph_log_width(lrun->lf, space_gv); + space_gv = GetGlyphValueAlt(lrun->lf, + UCHAR2ACHAR(UCHAR_IDSPACE)); } + else { + space_gv = GetGlyphValueAlt(lrun->lf, + UCHAR2ACHAR(UCHAR_SPACE)); + } + + gstr->glyphs[i].width + = _font_get_glyph_log_width(lrun->lf, space_gv); // A simple implementation for word spacing. gstr->glyphs[i].width += layout->ws; diff --git a/src/newgdi/legacy-bidi.c b/src/newgdi/legacy-bidi.c index 0ae26bb3..295cef7f 100644 --- a/src/newgdi/legacy-bidi.c +++ b/src/newgdi/legacy-bidi.c @@ -143,7 +143,7 @@ static int jump_vowels_ltr (PDC pdc, Achar32* achs, int nr_achs, if (!check_vowel(get_char_type (pdc->pLogFont, achs[i]))) return i; - if ((gv = GetGlyphValue(pdc->pLogFont, achs[i])) == INV_GLYPH_VALUE) { + if ((gv = GetGlyphValueAlt(pdc->pLogFont, achs[i])) == INV_GLYPH_VALUE) { _DBG_PRINTF("%s: got a bad glyph value from achar: %x\n", __FUNCTION__, achs[i]); return i; @@ -188,7 +188,7 @@ static int output_visual_achars_ltr (PDC pdc, Achar32* visual_achars, chv = *(visual_achars); char_type = get_char_type (pdc->pLogFont, chv); - if ((gv = GetGlyphValue(pdc->pLogFont, chv)) == INV_GLYPH_VALUE) { + if ((gv = GetGlyphValueAlt(pdc->pLogFont, chv)) == INV_GLYPH_VALUE) { _DBG_PRINTF("%s: got a bad glyph value from achar: %x\n", __FUNCTION__, chv); goto end; @@ -209,8 +209,8 @@ static int output_visual_achars_ltr (PDC pdc, Achar32* visual_achars, if (vowel_num) { char_type = get_char_type (pdc->pLogFont, biggest_vowel); - gv = GetGlyphValue(pdc->pLogFont, biggest_vowel); - if ((gv = GetGlyphValue(pdc->pLogFont, biggest_vowel)) == + gv = GetGlyphValueAlt(pdc->pLogFont, biggest_vowel); + if ((gv = GetGlyphValueAlt(pdc->pLogFont, biggest_vowel)) == INV_GLYPH_VALUE) { _DBG_PRINTF("%s: got a bad glyph value from achar: %x\n", __FUNCTION__, biggest_vowel); @@ -232,7 +232,7 @@ static int output_visual_achars_ltr (PDC pdc, Achar32* visual_achars, chv = *(visual_achars - j); if (chv != biggest_vowel) { char_type = get_char_type (pdc->pLogFont, chv); - if ((gv = GetGlyphValue(pdc->pLogFont, chv)) == + if ((gv = GetGlyphValueAlt(pdc->pLogFont, chv)) == INV_GLYPH_VALUE) { _DBG_PRINTF("%s: got a bad glyph value from achar: %x\n", __FUNCTION__, chv); @@ -277,7 +277,7 @@ static int output_vowels_rtl (PDC pdc, Achar32* end_achar, int left_num, if (check_vowel(char_type)) { Glyph32 gv; - if ((gv = GetGlyphValue(pdc->pLogFont, chv)) == INV_GLYPH_VALUE) { + if ((gv = GetGlyphValueAlt(pdc->pLogFont, chv)) == INV_GLYPH_VALUE) { _DBG_PRINTF("%s: got a bad glyph value from achar: %x\n", __FUNCTION__, chv); break; @@ -323,7 +323,7 @@ static int output_unowned_vowels_rtl (PDC pdc, Achar32* end_achar, int left_num, if (!check_vowel(char_type)) break; - if ((gv = GetGlyphValue(pdc->pLogFont, chv)) == + if ((gv = GetGlyphValueAlt(pdc->pLogFont, chv)) == INV_GLYPH_VALUE) { _DBG_PRINTF("%s: got a bad glyph value from achar: %x\n", __FUNCTION__, chv); @@ -340,7 +340,7 @@ static int output_unowned_vowels_rtl (PDC pdc, Achar32* end_achar, int left_num, /*output the biggest_vowel*/ if (max_advance) { char_type = get_char_type (pdc->pLogFont, biggest_vowel); - if ((gv = GetGlyphValue(pdc->pLogFont, biggest_vowel)) == + if ((gv = GetGlyphValueAlt(pdc->pLogFont, biggest_vowel)) == INV_GLYPH_VALUE) { _DBG_PRINTF("%s: got a bad glyph value from achar: %x\n", __FUNCTION__, biggest_vowel); @@ -359,7 +359,7 @@ static int output_unowned_vowels_rtl (PDC pdc, Achar32* end_achar, int left_num, Glyph32 gv; char_type = get_char_type (pdc->pLogFont, chv); - if ((gv = GetGlyphValue(pdc->pLogFont, chv)) == INV_GLYPH_VALUE) { + if ((gv = GetGlyphValueAlt(pdc->pLogFont, chv)) == INV_GLYPH_VALUE) { _DBG_PRINTF("%s: got a bad glyph value from achar: %x\n", __FUNCTION__, chv); break; @@ -399,7 +399,7 @@ static int output_visual_achars_rtl (PDC pdc, Achar32* visual_achars, chv = visual_achars[cur]; char_type = get_char_type (pdc->pLogFont, chv); - if ((gv = GetGlyphValue(pdc->pLogFont, chv)) == INV_GLYPH_VALUE) { + if ((gv = GetGlyphValueAlt(pdc->pLogFont, chv)) == INV_GLYPH_VALUE) { _DBG_PRINTF("%s: got a bad glyph value from achar: %x\n", __FUNCTION__, chv); return outed_glyph_num; @@ -493,7 +493,7 @@ do_glyph: else char_type = sbc_devfont->charset_ops->char_type (chv); - gv = GetGlyphValue(pdc->pLogFont, chv); + gv = GetGlyphValueAlt(pdc->pLogFont, chv); if (gv == INV_GLYPH_VALUE) { continue; } @@ -603,7 +603,7 @@ int _gdi_reorder_text (PDC pdc, const unsigned char* text, int text_len, char_type = sbc_devfont->charset_ops->char_type (chv); - gv = GetGlyphValue (pdc->pLogFont, chv); + gv = GetGlyphValueAlt (pdc->pLogFont, chv); if (gv == INV_GLYPH_VALUE) continue; @@ -622,7 +622,7 @@ int _gdi_reorder_text (PDC pdc, const unsigned char* text, int text_len, char_type = sbc_devfont->charset_ops->char_type (chv); - gv = GetGlyphValue (pdc->pLogFont, chv); + gv = GetGlyphValueAlt (pdc->pLogFont, chv); if (gv == INV_GLYPH_VALUE) continue; @@ -682,7 +682,7 @@ _gdi_get_achars_string_charbreak(PDC pdc, const unsigned char* text, prev_len += len_cur_char; } - gv = GetGlyphValue(pdc->pLogFont, chv); + gv = GetGlyphValueAlt(pdc->pLogFont, chv); line_width += _gdi_get_glyph_advance (pdc, gv, TRUE, 0, 0, NULL, NULL, &bbox); left_bytes -= len_cur_char; @@ -697,7 +697,7 @@ _gdi_get_achars_string_charbreak(PDC pdc, const unsigned char* text, (NULL, 0, text, left_bytes); logical_achars[i++] = chv; - gv = GetGlyphValue(pdc->pLogFont, chv); + gv = GetGlyphValueAlt(pdc->pLogFont, chv); line_width += _gdi_get_glyph_advance (pdc, gv, TRUE, 0, 0, NULL, NULL, &bbox); left_bytes -= len_cur_char; @@ -941,7 +941,7 @@ _gdi_output_achars_direct_sbc_rtol_break(PDC pdc, const unsigned char* text, char_type = sbc_devfont->charset_ops->char_type (chv); - gv = GetGlyphValue(pdc->pLogFont, chv); + gv = GetGlyphValueAlt(pdc->pLogFont, chv); if (!cb_one_glyph (context, gv, char_type)) break; } diff --git a/src/newgdi/shape-glyphs-basic.c b/src/newgdi/shape-glyphs-basic.c index ff8cd8d5..ff8afe7b 100644 --- a/src/newgdi/shape-glyphs-basic.c +++ b/src/newgdi/shape-glyphs-basic.c @@ -185,7 +185,7 @@ static BOOL shape_layout_run(SEInstance* inst, } } else { - gv = GetGlyphValue(run->lf, UCHAR2ACHAR(shaped_ucs[i])); + gv = GetGlyphValueAlt(run->lf, UCHAR2ACHAR(shaped_ucs[i])); gs->glyphs[j].gv = gv; gs->glyphs[j].is_cluster_start = 0; @@ -217,7 +217,7 @@ static BOOL shape_layout_run(SEInstance* inst, } } else { - gv = GetGlyphValue(run->lf, UCHAR2ACHAR(shaped_ucs[i])); + gv = GetGlyphValueAlt(run->lf, UCHAR2ACHAR(shaped_ucs[i])); gs->glyphs[j].gv = gv; gs->glyphs[j].is_cluster_start = 0; diff --git a/src/newgdi/shape-glyphs-complex.c b/src/newgdi/shape-glyphs-complex.c index 171c1f1d..4c2f10a2 100644 --- a/src/newgdi/shape-glyphs-complex.c +++ b/src/newgdi/shape-glyphs-complex.c @@ -271,7 +271,7 @@ static BOOL shape_layout_run(SEInstance* inst, Glyph32 gv; if (glyph_info[i].codepoint == 0) { - gv = GetGlyphValue(run->lf, + gv = GetGlyphValueAlt(run->lf, UCHAR2ACHAR(run->ucs[glyph_info[i].cluster])); if (REAL_GLYPH(gv) == 0) { _WRN_PRINTF("Got an invalid glyph for uchar: 0x%04x", diff --git a/src/newgdi/simple-glyph-renderer.c b/src/newgdi/simple-glyph-renderer.c index 07ac63e2..b0ca347d 100644 --- a/src/newgdi/simple-glyph-renderer.c +++ b/src/newgdi/simple-glyph-renderer.c @@ -803,7 +803,7 @@ static inline BOOL is_stop_or_common(const MYGLYPHINFO* gi) static void init_glyph_info(MYGLYPHARGS* args, int i, MYGLYPHINFO* gi) { - args->gvs[i] = GetGlyphValue(args->lfur, SET_MBCHV(args->ucs[i])); + args->gvs[i] = GetGlyphValueAlt(args->lfur, UCHAR2ACHAR(args->ucs[i])); gi->uc = args->ucs[i]; gi->gc = UCharGetCategory(gi->uc); @@ -1031,7 +1031,8 @@ int GUIAPI GetGlyphsExtentFromUChars(LOGFONT* logfont_upright, } } else if (is_whitespace_glyph(&args, gis, n)) { - Glyph32 space_gv = GetGlyphValue(logfont_upright, UCHAR_SPACE); + Glyph32 space_gv = GetGlyphValueAlt(logfont_upright, + UCHAR2ACHAR(UCHAR_SPACE)); gis[n].whitespace = 1; ges[n].line_adv = _font_get_glyph_log_width(logfont_upright, diff --git a/src/newgdi/textout.c b/src/newgdi/textout.c index 2f2328cd..7582a442 100644 --- a/src/newgdi/textout.c +++ b/src/newgdi/textout.c @@ -465,7 +465,7 @@ int GUIAPI GetTextExtentPoint (HDC hdc, const char* text, int len, chv = (*mbc_devfont->charset_ops->get_char_value)(NULL, 0, (const unsigned char*)text, 0); - gv = GetGlyphValue(pdc->pLogFont, chv); + gv = GetGlyphValueAlt(pdc->pLogFont, chv); advance_cur_char = _gdi_get_glyph_advance (pdc, gv, (pdc->ta_flags & TA_X_MASK) == TA_LEFT, 0, 0, NULL, NULL, NULL); @@ -476,7 +476,7 @@ int GUIAPI GetTextExtentPoint (HDC hdc, const char* text, int len, chv = (*sbc_devfont->charset_ops->get_char_value)( NULL, 0, (const unsigned char*)text, 0); - gv = GetGlyphValue(pdc->pLogFont, chv); + gv = GetGlyphValueAlt(pdc->pLogFont, chv); advance_cur_char = _gdi_get_glyph_advance (pdc, gv, (pdc->ta_flags & TA_X_MASK) == TA_LEFT, 0, 0, NULL, NULL, NULL); @@ -547,7 +547,7 @@ int GUIAPI GetACharsExtentPoint(HDC hdc, Achar32* achars, int nr_achars, else { Glyph32 gv; - if ((gv = GetGlyphValue(log_font, achars[i])) == INV_GLYPH_VALUE) { + if ((gv = GetGlyphValueAlt(log_font, achars[i])) == INV_GLYPH_VALUE) { _DBG_PRINTF("%s: got a bad glyph value from achar: %x\n", __FUNCTION__, achars[i]); break; @@ -594,7 +594,7 @@ int GUIAPI GetACharsExtent(HDC hdc, Achar32* achars, int nr_achars, SIZE* size) else { Glyph32 gv; - if ((gv = GetGlyphValue(log_font, achars[i])) == INV_GLYPH_VALUE) { + if ((gv = GetGlyphValueAlt(log_font, achars[i])) == INV_GLYPH_VALUE) { _DBG_PRINTF("%s: got a bad glyph value from achar: %x\n", __FUNCTION__, achars[i]); break;