diff --git a/include/gdi.h b/include/gdi.h index 5bdd2535..1aec9ea1 100644 --- a/include/gdi.h +++ b/include/gdi.h @@ -5457,6 +5457,7 @@ MG_EXPORT int GUIAPI SubtractRect (RECT* rc, const RECT* psrc1, const RECT* psrc /* Font-related structures */ #define LEN_LOGFONT_NAME_FIELD 31 +#define LEN_LOGFONT_FAMILY_FILED (LEN_LOGFONT_NAME_FIELD*7+6) #define LEN_UNIDEVFONT_NAME 255 #define LEN_FONT_NAME LEN_LOGFONT_NAME_FIELD @@ -5723,9 +5724,10 @@ MG_EXPORT int GUIAPI SubtractRect (RECT* rc, const RECT* psrc1, const RECT* psrc #define FONT_MAX_SIZE 256 #define FONT_MIN_SIZE 4 +#define MAXNR_DEVFONTS 8 struct _DEVFONT; -typedef struct _DEVFONT DEVFONT; +typedef struct _DEVFONT DEVFONT; /** * The logical font structure. @@ -5733,48 +5735,45 @@ typedef struct _DEVFONT DEVFONT; */ typedef struct _LOGFONT { /** The type of the logical font. */ - char type [LEN_LOGFONT_NAME_FIELD + 1]; + char* type; /** The family name of the logical font. */ - char family [LEN_LOGFONT_NAME_FIELD + 1]; + char* family; /** The charset of the logical font. */ - char charset [LEN_LOGFONT_NAME_FIELD + 1]; + char* charset; /** The styles of the logical font. */ DWORD32 style; /** The size of the logical font. */ - int size; + int size; /** The rotation angle of the logical font. */ - int rotation; + int rotation; /** The ascent of the logical font. */ - int ascent; + int ascent; /** The descent of the logical font. */ - int descent; + int descent; /** The size requested initially. */ - int size_request; + int size_request; - /* The devfonts for the logfont */ - DEVFONT* devfonts[4]; - /* The scale factors of devfonts */ - Uint8 df_scales[4]; + /* + * The following fields are internally used. + * They may be changed in the future. + */ - /* To be deprecated. The scale factor of sbc device font. */ - unsigned short sbc_scale; - /* To be deprecated. The scale factor of mbc device font. */ - unsigned short mbc_scale; - /* To be deprecated. Device font in single charset set */ - DEVFONT* sbc_devfont; - /* To be deprecated. Device font in multiply charset set */ - DEVFONT* mbc_devfont; + // The scale factors of devfonts + unsigned short scales[MAXNR_DEVFONTS]; + // The devfonts for the logfont + DEVFONT* devfonts[MAXNR_DEVFONTS]; } LOGFONT; + /** * \var typedef LOGFONT* PLOGFONT * \brief Data type of pointer to a LOGFONT. */ typedef LOGFONT* PLOGFONT; /** - * \var typedef const LOGFONT* CPLOGFONT - * \brief Data type of pointer to a const LOGFONT. + * \var typedef LOGFONT* CPLOGFONT + * \brief Data type of pointer to a LOGFONT. */ -typedef const LOGFONT* CPLOGFONT; +typedef LOGFONT* CPLOGFONT; struct _WORDINFO; /** @@ -6436,12 +6435,6 @@ struct _DEVFONT { BOOL need_unload; }; -#define SBC_DEVFONT_INFO(logfont) (logfont.sbc_devfont) -#define MBC_DEVFONT_INFO(logfont) (logfont.mbc_devfont) - -#define SBC_DEVFONT_INFO_P(logfont) (logfont->sbc_devfont) -#define MBC_DEVFONT_INFO_P(logfont) (logfont->mbc_devfont) - /** * \def INV_LOGFONT * \brief Invalid logfont. @@ -6545,10 +6538,12 @@ MG_EXPORT void GUIAPI TermVectorialFonts (void); * - FONT_TYPE_NAME_ALL\n * Creates a logical font by using any type device font. * \param family The family of the logical font, such as "Courier", - * "Helvetica", and so on. + * "Helvetica", and so on. Since version 3.4.0, you can specify + * up to 7 family names separated by comma, e.g., + * "Helvetica,Naskh". * \param charset The charset of the logical font. You can specify a * sigle-byte charset like "ISO8859-1", or a multi-byte charset - * like "GB2312-0". + * like "UTF-8", or "GB2312-0". * \param weight The weight of the logical font, can be one of the values: * - FONT_WEIGHT_ALL\n * Any one. @@ -6668,7 +6663,9 @@ MG_EXPORT PLOGFONT GUIAPI CreateLogFont (const char* type, const char* family, * - FONT_TYPE_NAME_ALL\n * Creates a logical font by using any type device font. * \param family The family of the logical font, such as "Courier", - * "Helvetica", and so on. + * "Helvetica", and so on. Since version 3.4.0, you can specify + * up to 7 family names separated by comma, e.g., + * "Helvetica,Naskh". * \param charset The charset of the logical font. You can specify a * sigle-byte charset like "ISO8859-1", or a multi-byte charset * like "GB2312-0". @@ -6773,9 +6770,17 @@ MG_EXPORT PLOGFONT GUIAPI CreateLogFontEx (const char* type, const char* family, * \brief Creates a logical font by a font name. * * This function creates a logical font by a font name specified by - * \a font_name. + * \a font_name. Note that since version 3.4.0, you can specify up + * to 4 family names in the LOGFONT name, such as: * - * \param font_name The name of the font. + * ttf-Courier,Naskh-rrncns-*-16-UTF-8 + * + * In this way, you can specify a logfont to use multiple devfonts + * to render a complex text. This is useful when different glyphs are + * contained in different font files. Whereas, a font is often designed + * for a particular language/script or a few similar languages/scripts. + * + * \param font_name The name of the logfont. * * \return The pointer to the logical font created, NULL on error. * @@ -6817,7 +6822,8 @@ MG_EXPORT PLOGFONT GUIAPI CreateLogFontIndirect (LOGFONT* logfont); * * \sa CreateLogFont, CreateLogFontIndirect, SelectFont */ -MG_EXPORT PLOGFONT GUIAPI CreateLogFontIndirectEx (LOGFONT* logfont, int rotation); +MG_EXPORT PLOGFONT GUIAPI CreateLogFontIndirectEx (LOGFONT* logfont, + int rotation); /** * \fn void GUIAPI DestroyLogFont (PLOGFONT log_font) @@ -9535,8 +9541,8 @@ typedef Uint32 Glyph32; */ #define INV_GLYPH_VALUE 0xFFFFFFFF -#define GLYPH_DEVFONT_INDEX_MASK 0xC0000000 -#define GLYPH_DEVFONT_INDEX_SHIFT 30 +#define GLYPH_DEVFONT_INDEX_MASK 0xF0000000 +#define GLYPH_DEVFONT_INDEX_SHIFT 28 /** * \def REAL_GLYPH(glyph) @@ -9547,20 +9553,18 @@ typedef Uint32 Glyph32; #define REAL_GLYPH(glyph) ((glyph) & ~GLYPH_DEVFONT_INDEX_MASK) /** - * \def SELECT_DEVFONT_EX(plogfont, glyph) + * \def SELECT_DEVFONT(logfont, glyph) * \brief Select a DEVFONT according to the LOGFONT glyph value. * - * \param plogfont The pointer to a logical font. - * \param glyph The logical glyph value. + * \param logfont The pointer to a logical font. + * \param glyph The logical glyph value. * */ -#define SELECT_DEVFONT_EX(plogfont, glyph) \ - (plogfont)->devfonts[((glyph) >> GLYPH_DEVFONT_INDEX_SHIFT) & 0x03] +#define SELECT_DEVFONT(logfont, glyph) \ + (logfont)->devfonts[((glyph) >> GLYPH_DEVFONT_INDEX_SHIFT) & 0x07] -/* to be deprecated */ -#define SELECT_DEVFONT(plogfont, glyph) \ - ((glyph) & GLYPH_DEVFONT_INDEX_MASK ? \ - (plogfont)->mbc_devfont : (plogfont)->sbc_devfont) +#define DFI_IN_GLYPH(glyph) \ + (((glyph) >> GLYPH_DEVFONT_INDEX_SHIFT) & 0x07) /** * \def IS_MBC_GLYPH(glyph) @@ -9570,13 +9574,9 @@ typedef Uint32 Glyph32; */ #define IS_MBC_GLYPH(glyph) ((glyph) & GLYPH_DEVFONT_INDEX_MASK) -/** - * \def SET_MBC_GLYPH(glyph) - * \brief set the glyph with multibyte mask - * - * \param glyph glyph value - */ -#define SET_MBC_GLYPH(glyph) ((glyph) | 0x80000000) +#define SET_GLYPH_DFI(glyph, dfi) \ + (((glyph) & ~GLYPH_DEVFONT_INDEX_MASK) | \ + (((Glyph32)((dfi) & 0x07)) << GLYPH_DEVFONT_INDEX_SHIFT)) /** * \var typedef struct _GLYPHMAPINFO GLYPHMAPINFO diff --git a/src/control/bidiedit.c b/src/control/bidiedit.c index efa16164..2e331d62 100644 --- a/src/control/bidiedit.c +++ b/src/control/bidiedit.c @@ -1071,14 +1071,12 @@ static int inline get_glyph_bidi_type (LOGFONT* logfont, Glyph32 glyph) DEVFONT* devfont; if (IS_MBC_GLYPH(glyph)) { - devfont = logfont->mbc_devfont; + devfont = logfont->devfonts[1]; - if (devfont->charset_ops->bidi_glyph_type) - { + if (devfont->charset_ops->bidi_glyph_type) { return devfont->charset_ops->bidi_glyph_type (glyph); } - else - { + else { return BIDI_TYPE_LTR; } } diff --git a/src/font/charset-bidi.c b/src/font/charset-bidi.c index 3a9f28ce..7753ba11 100644 --- a/src/font/charset-bidi.c +++ b/src/font/charset-bidi.c @@ -754,13 +754,13 @@ Uint32 __mg_charset_bidi_str_base_dir (const CHARSETOPS* charset_ops, BOOL GetGlyphBIDIType (LOGFONT* log_font, Glyph32 glyph_value, Uint32 *bidi_type) { - DEVFONT* mbc_devfont = log_font->mbc_devfont; + DEVFONT* devfont = SELECT_DEVFONT(log_font, glyph_value); - if (mbc_devfont == NULL || - mbc_devfont->charset_ops->bidi_glyph_type == NULL) + if (devfont == NULL || + devfont->charset_ops->bidi_glyph_type == NULL) return FALSE; - *bidi_type = mbc_devfont->charset_ops->bidi_glyph_type (glyph_value); + *bidi_type = devfont->charset_ops->bidi_glyph_type (glyph_value); return TRUE; } diff --git a/src/font/charset.c b/src/font/charset.c index b61b93b6..cb5d0dbb 100644 --- a/src/font/charset.c +++ b/src/font/charset.c @@ -750,8 +750,8 @@ static BOOL get_mirror_glyph (const BIDICHAR_MIRROR_MAP* map, int n, Glyph32 gly pos = step = (n / 2) + 1; - BOOL is_mbc; - is_mbc = IS_MBC_GLYPH(glyph); + int dfi; + dfi = DFI_IN_GLYPH(glyph); glyph = REAL_GLYPH(glyph); while (step > 1) { @@ -777,9 +777,9 @@ static BOOL get_mirror_glyph (const BIDICHAR_MIRROR_MAP* map, int n, Glyph32 gly if (mirrored){ *mirrored = found ? map[pos].mirrored : glyph; - /* use the same mbc font for mirror char. */ - if(is_mbc) - *mirrored = SET_MBC_GLYPH(*mirrored); + /* use the same devfont index for mirror char. */ + if (dfi) + *mirrored = SET_GLYPH_DFI(*mirrored, dfi); } return found; diff --git a/src/font/devfont.c b/src/font/devfont.c index 6315f54e..6f3c3ece 100644 --- a/src/font/devfont.c +++ b/src/font/devfont.c @@ -105,8 +105,8 @@ void font_ResetDevFont (void) #define MATCHED_WEIGHT 0x08 #define MATCHED_SLANT 0x10 -static DEVFONT* get_matched_devfont (LOGFONT* log_font, DEVFONT* list_head, - int list_len, char* req_charset) +static DEVFONT* get_matched_devfont (LOGFONT* lf, const char* family, + DEVFONT* list_head, int list_len, char* req_charset) { int i = 0; BYTE* match_bits; @@ -124,28 +124,28 @@ static DEVFONT* get_matched_devfont (LOGFONT* log_font, DEVFONT* list_head, dev_font = list_head; while (dev_font) { int type_req; - int weight_req = log_font->style & FS_WEIGHT_MASK; + int weight_req = lf->style & FS_WEIGHT_MASK; int weight_cur = dev_font->style & FS_WEIGHT_MASK; /* clear match_bits first. */ match_bits [i] = 0; /* does match this font type? */ - type_req = fontConvertFontType (log_font->type); + type_req = fontConvertFontType (lf->type); if (type_req == FONT_TYPE_ALL) match_bits [i] |= MATCHED_TYPE; else if (type_req == fontGetFontTypeFromName (dev_font->name)) match_bits [i] |= MATCHED_TYPE; - /* does match this family? */ + /* does match this family requested? */ #if 0 // since 3.4.0 char family [LEN_LOGFONT_NAME_FIELD + 1]; fontGetFamilyFromName (dev_font->name, family); - if (strcasecmp (family, log_font->family) == 0) { + if (strcasecmp (family, lf->family) == 0) { match_bits [i] |= MATCHED_FAMILY; } #else - if (fontDoesMatchFamily(dev_font->name, log_font->family)) { + if (fontDoesMatchFamily(dev_font->name, family?family:lf->family)) { match_bits [i] |= MATCHED_FAMILY; } #endif @@ -159,7 +159,7 @@ static DEVFONT* get_matched_devfont (LOGFONT* log_font, DEVFONT* list_head, if (weight_req == FS_WEIGHT_ANY || weight_req == weight_cur) { match_bits [i] |= MATCHED_WEIGHT; } - else if (dev_font->font_ops->get_glyph_bmptype(log_font, dev_font) + else if (dev_font->font_ops->get_glyph_bmptype(lf, dev_font) == DEVFONTGLYPHTYPE_MONOBMP && weight_req > FS_WEIGHT_DEMIBOLD && weight_cur < FS_WEIGHT_MEDIUM) { @@ -184,16 +184,16 @@ static DEVFONT* get_matched_devfont (LOGFONT* log_font, DEVFONT* list_head, int error, size_error, weight_error, slant_error; - size_error = log_font->size - - (*dev_font->font_ops->get_font_size) (log_font, dev_font, - log_font->size); + size_error = lf->size - + (*dev_font->font_ops->get_font_size) (lf, dev_font, + lf->size); size_error = ABS (size_error); - weight_error = (log_font->style & FS_WEIGHT_MASK) - + weight_error = (lf->style & FS_WEIGHT_MASK) - (dev_font->style & FS_WEIGHT_MASK); weight_error = ABS (weight_error); - slant_error = (log_font->style & FS_SLANT_MASK) - + slant_error = (lf->style & FS_SLANT_MASK) - (dev_font->style & FS_SLANT_MASK); slant_error = ABS (slant_error); @@ -215,8 +215,8 @@ static DEVFONT* get_matched_devfont (LOGFONT* log_font, DEVFONT* list_head, for (i = 0; i < list_len; i++) { int error; if (match_bits [i] & MATCHED_CHARSET) { - error = log_font->size - - (*dev_font->font_ops->get_font_size) (log_font, dev_font, log_font->size); + error = lf->size - + (*dev_font->font_ops->get_font_size) (lf, dev_font, lf->size); error = ABS (error); if (min_error >= error) { /* use >=, make the later has a higher priority */ min_error = error; @@ -233,40 +233,41 @@ matched: #endif if (matched_font) - matched_font->font_ops->get_font_size (log_font, matched_font, log_font->size); + matched_font->font_ops->get_font_size (lf, matched_font, lf->size); return matched_font; } -DEVFONT* font_GetMatchedSBDevFont (LOGFONT* log_font) +DEVFONT* font_GetMatchedSBDevFont (LOGFONT* lf, const char* family) { DEVFONT* matched_devfont; - if (GetCharsetOps (log_font->charset)->bytes_maxlen_char > 1) { + if (GetCharsetOps (lf->charset)->bytes_maxlen_char > 1) { /*mbc logfont --- sbc devfont*/ char sysfont_charset [LEN_LOGFONT_NAME_FIELD + 1]; - fontGetCharsetFromName (g_SysLogFont[0]->sbc_devfont->name, sysfont_charset); - matched_devfont = get_matched_devfont (log_font, sb_dev_font_head, + fontGetCharsetFromName (g_SysLogFont[0]->devfonts[0]->name, + sysfont_charset); + matched_devfont = get_matched_devfont (lf, family, sb_dev_font_head, nr_sb_dev_fonts, sysfont_charset); } else { /*sbc logfont --- sbc devfont*/ - matched_devfont = get_matched_devfont (log_font, sb_dev_font_head, - nr_sb_dev_fonts, log_font->charset); + matched_devfont = get_matched_devfont (lf, family, sb_dev_font_head, + nr_sb_dev_fonts, lf->charset); } return matched_devfont; } -DEVFONT* font_GetMatchedMBDevFont (LOGFONT* log_font) +DEVFONT* font_GetMatchedMBDevFont (LOGFONT* lf, const char* family) { /*sbc logfont doesn't need mbc font*/ - if (GetCharsetOps (log_font->charset)->bytes_maxlen_char == 1) + if (GetCharsetOps (lf->charset)->bytes_maxlen_char == 1) return NULL; /*mbc logfont --- mbc devfont*/ else - return get_matched_devfont (log_font, mb_dev_font_head, - nr_mb_dev_fonts, log_font->charset); + return get_matched_devfont (lf, family, mb_dev_font_head, + nr_mb_dev_fonts, lf->charset); } const DEVFONT* GUIAPI GetNextDevFont (const DEVFONT* dev_font) diff --git a/src/font/freetype2.c b/src/font/freetype2.c index 186e310e..c91d4840 100644 --- a/src/font/freetype2.c +++ b/src/font/freetype2.c @@ -1163,24 +1163,22 @@ FONTOPS __mg_ttf_ops = { BOOL ft2SetLcdFilter (LOGFONT* logfont, FT2LCDFilter filter) { + int i; BOOL rv = FALSE; DEVFONT* devfont; if (IS_SUBPIXEL(logfont)) { if (filter >= MG_SMOOTH_MAX) filter = MG_SMOOTH_DEFAULT; - devfont = logfont->sbc_devfont; - if (devfont && devfont->font_ops == &__mg_ttf_ops) { - FTINSTANCEINFO* ft_inst_info = FT_INST_INFO_P (devfont); - ft_inst_info->ft_lcdfilter = filter; - rv = TRUE; - } + for (i = 0; i < MAXNR_DEVFONTS; i++) { + if ((devfont = logfont->devfonts[i]) == NULL) + break; - devfont = logfont->mbc_devfont; - if (devfont && devfont->font_ops == &__mg_ttf_ops) { - FTINSTANCEINFO* ft_inst_info = FT_INST_INFO_P (devfont); - ft_inst_info->ft_lcdfilter = filter; - rv = TRUE; + if (devfont->font_ops == &__mg_ttf_ops) { + FTINSTANCEINFO* ft_inst_info = FT_INST_INFO_P (devfont); + ft_inst_info->ft_lcdfilter = filter; + rv = TRUE; + } } /* remove subpixel style if filter is none */ diff --git a/src/font/logfont.c b/src/font/logfont.c index 7ffe155b..998af3b8 100644 --- a/src/font/logfont.c +++ b/src/font/logfont.c @@ -32,7 +32,7 @@ * . */ /* -** logfont.c: Log fonts management. +** reflf.c: Log fonts management. ** ** Create date: 2000/07/07 */ @@ -57,337 +57,302 @@ CHARSETOPS* GetCharsetOps (const char* charset_name); -static inline int get_rotation (LOGFONT* logfont, +static inline int get_rotation (LOGFONT* reflf, DEVFONT* devfont, int rot_desired) { if (devfont->font_ops->is_rotatable) - return devfont->font_ops->is_rotatable (logfont, devfont, rot_desired); + return devfont->font_ops->is_rotatable(reflf, devfont, rot_desired); else return 0; } -/************************** Exported functions ******************************/ +static int get_family_name_len (const char* family) +{ + int n = 0; + while (family[n] && family[n] != ',') { + n++; + } + + return n; +} + +/* Adjust the logical font information */ +static void adjust_newlf_info (LOGFONT* newlf) +{ + int i; + + i = 0; + newlf->ascent = 0; + while (newlf->devfonts[i]) { + int value = newlf->devfonts[i]->font_ops->get_font_ascent( + newlf, newlf->devfonts[i]); + newlf->ascent = MAX (newlf->ascent, value); + i++; + } + + i = 0; + newlf->descent = 0; + while (newlf->devfonts[i]) { + int value = newlf->devfonts[i]->font_ops->get_font_descent( + newlf, newlf->devfonts[i]); + newlf->descent = MAX (newlf->descent, value); + i++; + } + + newlf->size = newlf->ascent + newlf->descent; +} + static PLOGFONT gdiCreateLogFont (const char* type, const char* family, const char* charset, DWORD style, int size, int rotation) { - PLOGFONT log_font; - int sbc_value, mbc_value = 0; - char dev_name_field [LEN_LOGFONT_NAME_FIELD + 1]; - DEVFONT* sbc_devfont, *mbc_devfont; + PLOGFONT newlf; + char name_field[LEN_LOGFONT_NAME_FIELD + 1]; + DEVFONT* devfonts[MAXNR_DEVFONTS] = {}; + const char* iter; + int i; // is valid style? if (style == 0xFFFFFFFF) return INV_LOGFONT; // is supported charset? - if (GetCharsetOps (charset) == NULL) { - _ERR_PRINTF ("FONT>LogFont: Not supprted charset: %s.\n", charset); + if (GetCharsetOps(charset) == NULL) { + _ERR_PRINTF("FONT>LogFont: Not supprted charset: %s.\n", charset); return INV_LOGFONT; } - /* - * fix "Invalid read of size 4" in mgncs - */ - //if ((log_font = (malloc (sizeof (LOGFONT))) == NULL) - if ((log_font = (PLOGFONT)malloc (sizeof (FONT_RES))) == NULL) + if ((newlf = (PLOGFONT)calloc(sizeof (FONT_RES), 1)) == NULL) return INV_LOGFONT; + ((FONT_RES *)newlf)->key = -1; - /* - * fix "Invalid read of size 4" in mgncs - */ - ((FONT_RES *)log_font)->key = -1; + newlf->style = style; + if (type == NULL) + type = FONT_TYPE_NAME_ALL; + newlf->type = strdup(type); + newlf->family = strdup(family); + newlf->charset = strdup(charset); - log_font->style = style; + if (newlf->type == NULL || newlf->family == NULL || newlf->charset == NULL) + goto error; - if (type) { - strncpy (log_font->type, type, LEN_LOGFONT_NAME_FIELD); - log_font->type [LEN_LOGFONT_NAME_FIELD] = '\0'; - } - else - strcpy (log_font->type, FONT_TYPE_NAME_ALL); - - strncpy (log_font->family, family, LEN_LOGFONT_NAME_FIELD); - log_font->family [LEN_LOGFONT_NAME_FIELD] = '\0'; - - strncpy (log_font->charset, charset, LEN_LOGFONT_NAME_FIELD); - log_font->charset [LEN_LOGFONT_NAME_FIELD] = '\0'; - - log_font->size_request = size; + newlf->size_request = size; if (size > FONT_MAX_SIZE) - log_font->size = FONT_MAX_SIZE; + newlf->size = FONT_MAX_SIZE; else if (size < FONT_MIN_SIZE) - log_font->size = FONT_MIN_SIZE; + newlf->size = FONT_MIN_SIZE; else - log_font->size = size; + newlf->size = size; - log_font->rotation = rotation; - log_font->sbc_scale = 1; - log_font->mbc_scale = 1; + newlf->rotation = rotation; - _DBG_PRINTF ("FONT>LogFont: requested info: type: %s, family: %s, style: %p, charset: %s, size: %d.\n", - log_font->type, log_font->family, (PVOID)log_font->style, log_font->charset, - log_font->size); + _DBG_PRINTF ("FONT>LogFont: requested info: type: %s, family: %s, style: %x, charset: %s, size: %d.\n", + newlf->type, newlf->family, + newlf->style, newlf->charset, newlf->size); - sbc_devfont = font_GetMatchedSBDevFont (log_font); - mbc_devfont = font_GetMatchedMBDevFont (log_font); + iter = family; + for (i = 0; i < MAXNR_DEVFONTS; i++) { - /* return error */ - if (sbc_devfont == NULL) { - free (log_font); - return INV_LOGFONT; + int n = get_family_name_len(iter); + + if (n <= 0) + break; + + strncpy (name_field, iter, n); + name_field[LEN_LOGFONT_NAME_FIELD] = '\0'; + + newlf->scales[i] = 1; + if (i == 0) { + _DBG_PRINTF ("FONT>LogFont: try to match SBC Devfont for family (%s)\n", + name_field); + if ((devfonts[0] = font_GetMatchedSBDevFont (newlf, name_field)) == NULL) + goto error; + + // do not forward iter + } + else { + _DBG_PRINTF ("FONT>LogFont: try to match MBC Devfont for family (%s)\n", + name_field); + if ((devfonts[i] = font_GetMatchedSBDevFont (newlf, name_field)) == NULL) + goto error; + + iter += n; + if (*iter == ',' || *iter == ' ') + iter++; + } } - /* check if sbc_devfont and mbc_devfont support rotation */ - if (get_rotation(log_font, sbc_devfont, rotation) == rotation - && (!mbc_devfont || get_rotation(log_font, mbc_devfont, rotation) == rotation)) - log_font->rotation = rotation; - else - log_font->rotation = 0; - - if (sbc_devfont->font_ops->new_instance) - sbc_devfont = (*sbc_devfont->font_ops->new_instance) (log_font, sbc_devfont, TRUE); - if (sbc_devfont == NULL) { - free (log_font); - return INV_LOGFONT; + // check if all devfonts support rotation + if (rotation) { + for (i = 0; i < MAXNR_DEVFONTS; i++) { + if (devfonts[i] && + get_rotation(newlf, devfonts[i], rotation) != rotation) { + newlf->rotation = 0; + break; + } + } } - if (mbc_devfont && mbc_devfont->font_ops->new_instance) - mbc_devfont = (*mbc_devfont->font_ops->new_instance) (log_font, mbc_devfont, FALSE); - - log_font->sbc_devfont = sbc_devfont; - log_font->mbc_devfont = mbc_devfont; - - /* - * Adjust the logical font information - */ - - /*reset type name of logfont*/ - if (log_font->mbc_devfont) { - fontGetTypeNameFromName (log_font->mbc_devfont->name, dev_name_field); - strncpy (log_font->type, dev_name_field, LEN_LOGFONT_NAME_FIELD); - log_font->type[LEN_LOGFONT_NAME_FIELD] = '\0'; - } - else { - fontGetTypeNameFromName (log_font->sbc_devfont->name, dev_name_field); - strncpy (log_font->type, dev_name_field, LEN_LOGFONT_NAME_FIELD); - log_font->type[LEN_LOGFONT_NAME_FIELD] = '\0'; + // create new instance of devfont if need + for (i = 0; i < MAXNR_DEVFONTS; i++) { + if (devfonts[i] && devfonts[i]->font_ops->new_instance) { + devfonts[i] = devfonts[i]->font_ops->new_instance(newlf, + devfonts[i], i == 0); + if (devfonts[i] == NULL) + goto error; + } } - /*reset family name of logfont*/ - if (log_font->mbc_devfont) { - fontGetFamilyFromName (log_font->mbc_devfont->name, dev_name_field); - strncpy (log_font->family, dev_name_field, LEN_LOGFONT_NAME_FIELD); - log_font->family [LEN_LOGFONT_NAME_FIELD] = '\0'; - } - else { - fontGetFamilyFromName (log_font->sbc_devfont->name, dev_name_field); - strncpy (log_font->family, dev_name_field, LEN_LOGFONT_NAME_FIELD); - log_font->family [LEN_LOGFONT_NAME_FIELD] = '\0'; + memcpy(newlf->devfonts, devfonts, sizeof(devfonts)); + + adjust_newlf_info(newlf); + + _DBG_PRINTF ("FONT>LogFont: created info: type: %s, family: %s, style: %x, charset: %s, size: %d.\n", + newlf->type, newlf->family, newlf->style, newlf->charset, newlf->size); + + return newlf; + +error: + for (i = 0; i < MAXNR_DEVFONTS; i++) { + if (newlf->devfonts[i] && newlf->devfonts[i]->font_ops->new_instance + && newlf->devfonts[i] != devfonts[i]) { + newlf->devfonts[i]->font_ops->delete_instance(newlf->devfonts[i]); + } } - /*reset charset name of logfont*/ - if (log_font->mbc_devfont) { - strncpy (log_font->charset, - log_font->mbc_devfont->charset_ops->name, LEN_LOGFONT_NAME_FIELD); - log_font->charset [LEN_LOGFONT_NAME_FIELD] = '\0'; - } - else { - strncpy (log_font->charset, - log_font->sbc_devfont->charset_ops->name, LEN_LOGFONT_NAME_FIELD); - log_font->charset [LEN_LOGFONT_NAME_FIELD] = '\0'; - } + if (newlf->type) free(newlf->type); + if (newlf->family) free(newlf->family); + if (newlf->charset) free(newlf->charset); - /*reset ascent of logfont*/ - sbc_value = log_font->sbc_devfont->font_ops->get_font_ascent (log_font, - log_font->sbc_devfont); - if (log_font->mbc_devfont) { - mbc_value = log_font->mbc_devfont->font_ops->get_font_ascent (log_font, - log_font->mbc_devfont); - log_font->ascent = MAX (sbc_value, mbc_value); - } - else { - log_font->ascent = sbc_value; - } + free(newlf); - /*reset descent of logfont*/ - sbc_value = log_font->sbc_devfont->font_ops->get_font_descent (log_font, - log_font->sbc_devfont); - if (log_font->mbc_devfont) { - mbc_value = log_font->mbc_devfont->font_ops->get_font_descent (log_font, - log_font->mbc_devfont); - log_font->descent = MAX (sbc_value, mbc_value); - } - else { - log_font->descent = sbc_value; - } - - /*reset size of logfont*/ - log_font->size = log_font->ascent + log_font->descent; - -#if 0 // VincentWei: support fillping for subpixel renderer - /* reset style of logfont */ - /* remove HORZVERT style if weight is subpixel */ - if ((log_font->style & FS_RENDER_MASK) == FS_RENDER_SUBPIXEL) { - log_font->style &= ~FS_FLIP_HORZVERT; - log_font->style &= ~FS_SLANT_ITALIC; - } - - /* remove HORZVERT style if the glyph bmptype is subpixel */ - DWORD glyph_bmptype; - glyph_bmptype = log_font->sbc_devfont->font_ops->get_glyph_bmptype - (log_font, log_font->sbc_devfont) & DEVFONTGLYPHTYPE_MASK_BMPTYPE; - if (glyph_bmptype == GLYPHBMP_TYPE_SUBPIXEL) { - log_font->style &= ~FS_FLIP_HORZVERT; - } - else if (log_font->mbc_devfont) { - glyph_bmptype = log_font->mbc_devfont->font_ops->get_glyph_bmptype - (log_font, log_font->mbc_devfont) & DEVFONTGLYPHTYPE_MASK_BMPTYPE; - if (glyph_bmptype == GLYPHBMP_TYPE_SUBPIXEL) - log_font->style &= ~FS_FLIP_HORZVERT; - } -#endif - - _DBG_PRINTF ("FONT>LogFont: created info: type: %s, family: %s, style: %p, charset: %s, size: %d.\n", - log_font->type, log_font->family, (PVOID)log_font->style, log_font->charset, - log_font->size); - - return log_font; + return INV_LOGFONT; } -PLOGFONT GUIAPI CreateLogFontIndirect (LOGFONT *logfont) +PLOGFONT GUIAPI CreateLogFontIndirect (LOGFONT *reflf) { - PLOGFONT newfont; - DEVFONT* sbc_devfont, *mbc_devfont; - int sbc_value, mbc_value = 0; + PLOGFONT newlf; + int i; - if (!logfont) return NULL; + if (!reflf) + return NULL; - // VincentWei: make sure the logfont has the key for resource manager. - //if ((newfont = malloc (sizeof (LOGFONT))) == NULL) - if ((newfont = (PLOGFONT)malloc (sizeof (FONT_RES))) == NULL) + // VincentWei: make sure the reflf has the key for resource manager. + if ((newlf = (PLOGFONT)calloc (sizeof (FONT_RES), 1)) == NULL) return INV_LOGFONT; + // VincentWei: make sure the reflf has an invalid key for resource manager. + ((FONT_RES *)newlf)->key = -1; - // VincentWei: make sure the logfont has an invalid key for resource manager. - memcpy (newfont, logfont, sizeof(LOGFONT)); - ((FONT_RES *)newfont)->key = -1; + memcpy (newlf, reflf, sizeof(LOGFONT)); + newlf->type = strdup(reflf->type); + newlf->family = strdup(reflf->family); + newlf->charset = strdup(reflf->charset); + if (newlf->type == NULL || newlf->family == NULL || + newlf->charset == NULL) + goto error; - // reset request size of newfont to logfont->size_request - newfont->size = logfont->size_request; - sbc_devfont = logfont->sbc_devfont; - if (sbc_devfont->font_ops->new_instance) - sbc_devfont = (*sbc_devfont->font_ops->new_instance) (newfont, sbc_devfont, TRUE); - if (sbc_devfont == NULL) { - free (newfont); - return INV_LOGFONT; + // reset request size of newlf to reflf->size_request + newlf->size = reflf->size_request; + + // create new devfont instance if need + for (i = 0; i < MAXNR_DEVFONTS; i++) { + DEVFONT* df = reflf->devfonts[i]; + if (df->font_ops->new_instance) + newlf->devfonts[i] = df->font_ops->new_instance(newlf, + df, i == 0); + if (df == NULL) { + goto error; + } } - mbc_devfont = logfont->mbc_devfont; - if (mbc_devfont && mbc_devfont->font_ops->new_instance) - mbc_devfont = (*mbc_devfont->font_ops->new_instance) (newfont, mbc_devfont, FALSE); + adjust_newlf_info(newlf); - newfont->sbc_devfont = sbc_devfont; - newfont->mbc_devfont = mbc_devfont; + return newlf; - /*reset ascent of logfont*/ - sbc_value = newfont->sbc_devfont->font_ops->get_font_ascent (newfont, - newfont->sbc_devfont); - if (newfont->mbc_devfont) { - mbc_value = newfont->mbc_devfont->font_ops->get_font_ascent (newfont, - newfont->mbc_devfont); - newfont->ascent = MAX (sbc_value, mbc_value); - } - else { - newfont->ascent = sbc_value; +error: + for (i = 0; i < MAXNR_DEVFONTS; i++) { + if (newlf->devfonts[i] && newlf->devfonts[i]->font_ops->new_instance + && newlf->devfonts[i] != reflf->devfonts[i]) { + newlf->devfonts[i]->font_ops->delete_instance(newlf->devfonts[i]); + } } - /*reset descent of logfont*/ - sbc_value = newfont->sbc_devfont->font_ops->get_font_descent (newfont, - newfont->sbc_devfont); - if (newfont->mbc_devfont) { - mbc_value = newfont->mbc_devfont->font_ops->get_font_descent (newfont, - newfont->mbc_devfont); - newfont->descent = MAX (sbc_value, mbc_value); - } - else { - newfont->descent = sbc_value; - } + if (newlf->type) free(newlf->type); + if (newlf->family) free(newlf->family); + if (newlf->charset) free(newlf->charset); - /*reset size of logfont*/ - newfont->size = newfont->ascent + newfont->descent; - return newfont; + free(newlf); + + return INV_LOGFONT; } -PLOGFONT GUIAPI CreateLogFontIndirectEx (LOGFONT *logfont, int rotation) +PLOGFONT GUIAPI CreateLogFontIndirectEx (LOGFONT *reflf, int rotation) { - PLOGFONT newfont; - DEVFONT* sbc_devfont, *mbc_devfont; - int sbc_value, mbc_value = 0; + PLOGFONT newlf; + int i; - if (!logfont) return NULL; + if (!reflf) + return NULL; - // VincentWei: make sure the logfont has the key for resource manager. - if ((newfont = (PLOGFONT)malloc (sizeof (FONT_RES))) == NULL) + // VincentWei: make sure the reflf has the key for resource manager. + if ((newlf = (PLOGFONT)calloc (sizeof (FONT_RES), 1)) == NULL) return INV_LOGFONT; + // VincentWei: make sure the reflf has an invalid key for resource manager. + ((FONT_RES *)newlf)->key = -1; - // VincentWei: make sure the logfont has an invalid key for resource manager. - memcpy (newfont, logfont, sizeof(LOGFONT)); - ((FONT_RES *)newfont)->key = -1; + memcpy (newlf, reflf, sizeof(LOGFONT)); + newlf->type = strdup(reflf->type); + newlf->family = strdup(reflf->family); + newlf->charset = strdup(reflf->charset); + if (newlf->type == NULL || newlf->family == NULL || + newlf->charset == NULL) + goto error; - sbc_devfont = logfont->sbc_devfont; - mbc_devfont = logfont->mbc_devfont; - newfont->size = logfont->size_request; - newfont->rotation = rotation; - if (logfont->rotation == 0 && rotation != 0) { - /* check if sbc_devfont and mbc_devfont support rotation */ - if (get_rotation(newfont, sbc_devfont, rotation) == rotation - && (!mbc_devfont || get_rotation(newfont, mbc_devfont, rotation) == rotation)) - newfont->rotation = rotation; - else - newfont->rotation = 0; + // reset request size of newlf to reflf->size_request + newlf->size = reflf->size_request; + newlf->rotation = rotation; + + // check if all devfonts support rotation + if (rotation) { + for (i = 0; i < MAXNR_DEVFONTS; i++) { + DEVFONT* df = newlf->devfonts[i]; + if (df && get_rotation(newlf, df, rotation) != rotation) { + newlf->rotation = 0; + break; + } + } } - if (sbc_devfont->font_ops->new_instance) - sbc_devfont = (*sbc_devfont->font_ops->new_instance) (newfont, sbc_devfont, TRUE); - if (sbc_devfont == NULL) { - free (newfont); - return INV_LOGFONT; + // create new devfont instance if need + for (i = 0; i < MAXNR_DEVFONTS; i++) { + DEVFONT* df = reflf->devfonts[i]; + if (df->font_ops->new_instance) + newlf->devfonts[i] = df->font_ops->new_instance(newlf, + df, i == 0); + if (df == NULL) { + goto error; + } } - if (mbc_devfont && mbc_devfont->font_ops->new_instance) - mbc_devfont = (*mbc_devfont->font_ops->new_instance) (newfont, mbc_devfont, FALSE); + adjust_newlf_info(newlf); + return newlf; - newfont->sbc_devfont = sbc_devfont; - newfont->mbc_devfont = mbc_devfont; - - /*reset ascent of logfont*/ - sbc_value = newfont->sbc_devfont->font_ops->get_font_ascent (newfont, - newfont->sbc_devfont); - if (newfont->mbc_devfont) { - mbc_value = newfont->mbc_devfont->font_ops->get_font_ascent (newfont, - newfont->mbc_devfont); - newfont->ascent = MAX (sbc_value, mbc_value); - } - else { - newfont->ascent = sbc_value; +error: + for (i = 0; i < MAXNR_DEVFONTS; i++) { + if (newlf->devfonts[i] && newlf->devfonts[i]->font_ops->new_instance + && newlf->devfonts[i] != reflf->devfonts[i]) { + newlf->devfonts[i]->font_ops->delete_instance(newlf->devfonts[i]); + } } - /*reset descent of logfont*/ - sbc_value = newfont->sbc_devfont->font_ops->get_font_descent (newfont, - newfont->sbc_devfont); - if (newfont->mbc_devfont) { - mbc_value = newfont->mbc_devfont->font_ops->get_font_descent (newfont, - newfont->mbc_devfont); - newfont->descent = MAX (sbc_value, mbc_value); - } - else { - newfont->descent = sbc_value; - } + if (newlf->type) free(newlf->type); + if (newlf->family) free(newlf->family); + if (newlf->charset) free(newlf->charset); - /*reset size of logfont*/ - newfont->size = newfont->ascent + newfont->descent; - return newfont; + free(newlf); + + return INV_LOGFONT; } PLOGFONT GUIAPI CreateLogFont (const char* type, const char* family, @@ -429,7 +394,8 @@ PLOGFONT GUIAPI CreateLogFont (const char* type, const char* family, style_name[6] = 0; - return gdiCreateLogFont (type, family, charset, fontConvertStyle (style_name), size, rotation); + return gdiCreateLogFont (type, family, charset, + fontConvertStyle (style_name), size, rotation); } PLOGFONT GUIAPI CreateLogFontEx (const char* type, const char* family, @@ -446,13 +412,14 @@ PLOGFONT GUIAPI CreateLogFontEx (const char* type, const char* family, style_name[5] = rendering; style_name[6] = 0; - return gdiCreateLogFont (type, family, charset, fontConvertStyle (style_name), size, rotation); + return gdiCreateLogFont (type, family, charset, + fontConvertStyle (style_name), size, rotation); } PLOGFONT GUIAPI CreateLogFontByName (const char* font_name) { char type[LEN_LOGFONT_NAME_FIELD + 1]; - char family[LEN_LOGFONT_NAME_FIELD + 1]; + char family[LEN_LOGFONT_FAMILY_FILED + 1]; char charset[LEN_LOGFONT_NAME_FIELD + 1]; DWORD style; int height; @@ -467,157 +434,65 @@ PLOGFONT GUIAPI CreateLogFontByName (const char* font_name) return gdiCreateLogFont (type, family, charset, style, height, 0); } -void GUIAPI DestroyLogFont (PLOGFONT log_font) +void GUIAPI DestroyLogFont (PLOGFONT logfont) { - LOGFONT* logfont = (PLOGFONT)log_font; + int i; - if (!log_font) return; + for (i = 0; i < MAXNR_DEVFONTS; i++) { + DEVFONT* df = logfont->devfonts[i]; + if (df && df->font_ops->new_instance) + df->font_ops->delete_instance(df); + } - if (logfont->sbc_devfont->font_ops->delete_instance) - logfont->sbc_devfont->font_ops->delete_instance (logfont->sbc_devfont); - if (logfont->mbc_devfont && logfont->mbc_devfont->font_ops->delete_instance) - logfont->mbc_devfont->font_ops->delete_instance (logfont->mbc_devfont); + free(logfont->type); + free(logfont->family); + free(logfont->charset); - free (logfont); + free(logfont); } -void GUIAPI GetLogFontInfo (HDC hdc, LOGFONT* log_font) +void GUIAPI GetLogFontInfo (HDC hdc, LOGFONT* logfont) { - if (!log_font) return; - memcpy (log_font, dc_HDC2PDC (hdc)->pLogFont, sizeof (LOGFONT)); + if (!logfont) + return; + + /* + * NOTE: change the size to copy when LOGFONT structure changed + * The function only copy the opened fields of the LOGFONT. + */ + memcpy (logfont, dc_HDC2PDC (hdc)->pLogFont, sizeof (LOGFONT)); } -void GUIAPI GetFontMetrics (LOGFONT* log_font, FONTMETRICS* font_metrics) +void GUIAPI GetFontMetrics (LOGFONT* logfont, FONTMETRICS* font_metrics) { - int sbc_value, mbc_value; + int i; + DEVFONT* df; - if (!log_font) return; + if (!logfont) return; if (!font_metrics) return; - font_metrics->font_height = log_font->size; + font_metrics->font_height = logfont->size; + font_metrics->ascent = logfont->ascent; + font_metrics->descent = logfont->descent; - sbc_value = log_font->sbc_devfont->font_ops->get_font_ascent (log_font, - log_font->sbc_devfont); - if (log_font->mbc_devfont) { - mbc_value = log_font->mbc_devfont->font_ops->get_font_ascent (log_font, - log_font->mbc_devfont); - font_metrics->ascent = MAX (sbc_value, mbc_value); - } - else { - font_metrics->ascent = sbc_value; + i = 0; + font_metrics->max_width = 0; + while ((df = logfont->devfonts[i])) { + int value = df->font_ops->get_max_width(logfont, df); + font_metrics->max_width = MAX(font_metrics->max_width, value); + i++; } - font_metrics->descent = font_metrics->font_height - font_metrics->ascent; - - sbc_value = log_font->sbc_devfont->font_ops->get_max_width (log_font, - log_font->sbc_devfont); - if (log_font->mbc_devfont) { - mbc_value = log_font->mbc_devfont->font_ops->get_max_width (log_font, - log_font->mbc_devfont); - font_metrics->max_width = MAX (sbc_value, mbc_value); - } - else { - font_metrics->max_width = sbc_value; + /* FIXME: ave_width should depend on the glyph number of devfont */ + i = 0; + font_metrics->ave_width = 0; + while ((df = logfont->devfonts[i])) { + int value = df->font_ops->get_max_width(logfont, df); + font_metrics->ave_width += value; + i++; } - sbc_value = log_font->sbc_devfont->font_ops->get_ave_width (log_font, - log_font->sbc_devfont); - if (log_font->mbc_devfont) { - mbc_value = log_font->mbc_devfont->font_ops->get_ave_width (log_font, - log_font->mbc_devfont); - font_metrics->ave_width = mbc_value; - } - else { - font_metrics->ave_width = sbc_value; - } + if (i > 0) + font_metrics->ave_width /= i; } -#if 0 -void GUIAPI GetGlyphBitmap (LOGFONT* log_font, - const unsigned char* mchar, int mchar_len, - GLYPHBITMAP* glyph_bitmap) -{ - DEVFONT* sbc_devfont; - DEVFONT* mbc_devfont; - DEVFONT* devfont; - Glyph32 glyph_value; - - if (!log_font) return; - if (!glyph_bitmap) return; - if (!mchar) return; - - sbc_devfont = log_font->sbc_devfont; - mbc_devfont = log_font->mbc_devfont; - - if (mbc_devfont) { - int mbc_len; - - mbc_len = mbc_devfont->charset_ops->len_first_char(mchar, mchar_len); - if (mbc_len == 0) { - devfont = sbc_devfont; - } - else { - devfont = mbc_devfont; - } - } - else { - devfont = sbc_devfont; - } - glyph_value = devfont->charset_ops->char_glyph_value(NULL, 0, mchar, mchar_len); - - if (devfont->font_ops->get_glyph_bbox) { - glyph_bitmap->bbox_x = 0; - glyph_bitmap->bbox_y = 0; - devfont->font_ops->get_glyph_bbox (log_font, devfont, glyph_value, - &glyph_bitmap->bbox_x, - &glyph_bitmap->bbox_y, - &glyph_bitmap->bbox_w, - &glyph_bitmap->bbox_h); - } - else { - glyph_bitmap->bbox_x = 0; - glyph_bitmap->bbox_w = 0; - - glyph_bitmap->bbox_y = devfont->font_ops->get_font_descent (log_font, - devfont); - devfont->font_ops->get_glyph_advance (log_font, - devfont, glyph_value, &glyph_bitmap->bbox_w, 0); - glyph_bitmap->bbox_h = devfont->font_ops->get_font_height (log_font, - devfont); - } - - if (devfont->font_ops->get_glyph_advance) { - glyph_bitmap->advance_x = 0; - glyph_bitmap->advance_y = 0; - if (devfont->font_ops->start_str_output) - devfont->font_ops->start_str_output (log_font, devfont); - devfont->font_ops->get_glyph_advance (log_font, devfont, - glyph_value, - &glyph_bitmap->advance_x, &glyph_bitmap->advance_y); - } - else { - glyph_bitmap->advance_x = glyph_bitmap->bbox_w; - glyph_bitmap->advance_y = 0; - } - - /* restore to the original value if the scale factor is there. */ - if (GET_DEVFONT_SCALE (log_font, devfont) > 1) { - int scale = GET_DEVFONT_SCALE (log_font, devfont); - - glyph_bitmap->bbox_x /= scale; - glyph_bitmap->bbox_y /= scale; - glyph_bitmap->bbox_w /= scale; - glyph_bitmap->bbox_h /= scale; - glyph_bitmap->advance_x /= scale; - glyph_bitmap->advance_y /= scale; - } - - glyph_bitmap->bmp_pitch = (glyph_bitmap->bbox_w + 7) >> 3; - - glyph_bitmap->bmp_size = glyph_bitmap->bmp_pitch * glyph_bitmap->bbox_h; - - glyph_bitmap->bits = devfont->font_ops->get_glyph_monobitmap (log_font, - devfont, glyph_value, NULL); -} - -#endif diff --git a/src/font/qpf.c b/src/font/qpf.c index 1985fc57..a03dc842 100644 --- a/src/font/qpf.c +++ b/src/font/qpf.c @@ -343,10 +343,10 @@ static const void* get_glyph_monobitmap (LOGFONT* logfont, DEVFONT* devfont, glyph = get_glyph (QPFONT_INFO_P (devfont)->tree, uc16); if (glyph == NULL) { - if (uc16 < 0x80 && logfont->sbc_devfont != devfont) { /* ASCII */ + if (uc16 < 0x80 && logfont->devfonts[0] != devfont) { /* ASCII */ unsigned char ascii_ch = uc16; - return logfont->sbc_devfont->font_ops->get_glyph_monobitmap (logfont, - logfont->sbc_devfont, ascii_ch, pitch, scale); + return logfont->devfonts[0]->font_ops->get_glyph_monobitmap (logfont, + logfont->devfonts[0], ascii_ch, pitch, scale); } else glyph = &def_glyph; @@ -411,21 +411,21 @@ static int get_glyph_bbox (LOGFONT* logfont, DEVFONT* devfont, glyph = get_glyph (QPFONT_INFO_P (devfont)->tree, uc16); if (glyph == NULL) { - if (uc16 < 0x80 && logfont->sbc_devfont != devfont) { /* ASCII */ + if (uc16 < 0x80 && logfont->devfonts[0] != devfont) { /* ASCII */ unsigned char ascii_ch = uc16; - if (logfont->sbc_devfont->font_ops->get_glyph_bbox) { - return logfont->sbc_devfont->font_ops->get_glyph_bbox (logfont, - logfont->sbc_devfont, ascii_ch, + if (logfont->devfonts[0]->font_ops->get_glyph_bbox) { + return logfont->devfonts[0]->font_ops->get_glyph_bbox (logfont, + logfont->devfonts[0], ascii_ch, px, py, pwidth, pheight); } else { int width, height, ascent; - logfont->sbc_devfont->font_ops->get_glyph_advance - (logfont, logfont->sbc_devfont, glyph_value, &width, 0); - height = logfont->sbc_devfont->font_ops->get_font_height - (logfont, logfont->sbc_devfont); - ascent = logfont->sbc_devfont->font_ops->get_font_ascent - (logfont, logfont->sbc_devfont); + logfont->devfonts[0]->font_ops->get_glyph_advance + (logfont, logfont->devfonts[0], glyph_value, &width, 0); + height = logfont->devfonts[0]->font_ops->get_font_height + (logfont, logfont->devfonts[0]); + ascent = logfont->devfonts[0]->font_ops->get_font_ascent + (logfont, logfont->devfonts[0]); if (pwidth) *pwidth = width; if (pheight) *pheight = height; @@ -464,11 +464,11 @@ static int get_glyph_advance (LOGFONT* logfont, DEVFONT* devfont, glyph = get_glyph (QPFONT_INFO_P (devfont)->tree, uc16); if (glyph == NULL) { - if (uc16 < 0x80 && logfont->sbc_devfont != devfont) { /* ASCII */ + if (uc16 < 0x80 && logfont->devfonts[0] != devfont) { /* ASCII */ unsigned char ascii_ch = uc16; - if (logfont->sbc_devfont->font_ops->get_glyph_advance) { - return logfont->sbc_devfont->font_ops-> - get_glyph_advance (logfont, logfont->sbc_devfont, + if (logfont->devfonts[0]->font_ops->get_glyph_advance) { + return logfont->devfonts[0]->font_ops-> + get_glyph_advance (logfont, logfont->devfonts[0], ascii_ch, px, py); } } @@ -507,13 +507,13 @@ static BOOL is_glyph_existed (LOGFONT* logfont, DEVFONT* devfont, Glyph32 glyph_ uc16 = (*devfont->charset_ops->conv_to_uc32) (glyph_value); else uc16 = glyph_value; - + glyph = get_glyph (QPFONT_INFO_P (devfont)->tree, uc16); if (glyph == NULL) { - if (uc16 < 0x80 && logfont->sbc_devfont != devfont) /* ASCII */ - return logfont->sbc_devfont->font_ops->is_glyph_existed (logfont, - logfont->sbc_devfont, glyph_value); + if (uc16 < 0x80 && logfont->devfonts[0] != devfont) /* ASCII */ + return logfont->devfonts[0]->font_ops->is_glyph_existed (logfont, + logfont->devfonts[0], glyph_value); else return FALSE; } diff --git a/src/font/rawbitmap.c b/src/font/rawbitmap.c index 9ead37b4..f166d950 100644 --- a/src/font/rawbitmap.c +++ b/src/font/rawbitmap.c @@ -188,7 +188,7 @@ static int get_font_ascent (LOGFONT* logfont, DEVFONT* devfont) static int get_font_descent (LOGFONT* logfont, DEVFONT* devfont) { int height = RBFONT_INFO_P (devfont)->height; - + height *= GET_DEVFONT_SCALE (logfont, devfont); if (height >= 40) diff --git a/src/font/sysfont.c b/src/font/sysfont.c index b730be13..0d267fff 100644 --- a/src/font/sysfont.c +++ b/src/font/sysfont.c @@ -205,28 +205,28 @@ void mg_TermSysFont (void) const char* GUIAPI GetSysCharset (BOOL wchar) { if (wchar) { - if (g_SysLogFont[1]->mbc_devfont) - return MBC_DEVFONT_INFO_P (g_SysLogFont[1])->charset_ops->name; + if (g_SysLogFont[1]->devfonts[1]) + return g_SysLogFont[1]->devfonts[1]->charset_ops->name; else return NULL; } - else - return SBC_DEVFONT_INFO_P (g_SysLogFont[0])->charset_ops->name; + else + return g_SysLogFont[0]->devfonts[0]->charset_ops->name; } int GUIAPI GetSysCharWidth (void) { - DEVFONT* sbc_devfont = g_SysLogFont[0]->sbc_devfont; + DEVFONT* sbc_devfont = g_SysLogFont[0]->devfonts[0]; return sbc_devfont->font_ops->get_ave_width (g_SysLogFont[0], sbc_devfont); } int GUIAPI GetSysCCharWidth (void) { - DEVFONT* mbc_devfont = g_SysLogFont[1]->mbc_devfont; + DEVFONT* mbc_devfont = g_SysLogFont[1]->devfonts[1]; if (mbc_devfont) - return mbc_devfont->font_ops->get_ave_width (g_SysLogFont[1], mbc_devfont); + return mbc_devfont->font_ops->get_ave_width (g_SysLogFont[1], mbc_devfont); else return GetSysCharWidth () * 2; } @@ -238,14 +238,14 @@ int GUIAPI GetSysCharHeight (void) int GUIAPI GetSysFontMaxWidth (int font_id) { - DEVFONT* sbc_devfont = g_SysLogFont[font_id]->sbc_devfont; + DEVFONT* sbc_devfont = g_SysLogFont[font_id]->devfonts[0]; return sbc_devfont->font_ops->get_max_width (g_SysLogFont[font_id], sbc_devfont); } int GUIAPI GetSysFontAveWidth (int font_id) { - DEVFONT* sbc_devfont = g_SysLogFont[font_id]->sbc_devfont; + DEVFONT* sbc_devfont = g_SysLogFont[font_id]->devfonts[0]; return sbc_devfont->font_ops->get_ave_width (g_SysLogFont[font_id], sbc_devfont); } diff --git a/src/font/textops.c b/src/font/textops.c index 88c70e2c..1240d9d0 100644 --- a/src/font/textops.c +++ b/src/font/textops.c @@ -50,8 +50,8 @@ int GUIAPI GetTextMCharInfo (PLOGFONT log_font, const char* mstr, int len, int* pos_chars) { - DEVFONT* sbc_devfont = log_font->sbc_devfont; - DEVFONT* mbc_devfont = log_font->mbc_devfont; + DEVFONT* sbc_devfont = log_font->devfonts[0]; + DEVFONT* mbc_devfont = log_font->devfonts[1]; int count = 0; int left_bytes = len; int len_cur_char; @@ -86,8 +86,8 @@ int GUIAPI GetTextMCharInfo (PLOGFONT log_font, const char* mstr, int len, int GUIAPI GetTextWordInfo (PLOGFONT log_font, const char* mstr, int len, int* pos_words, WORDINFO* info_words) { - DEVFONT* sbc_devfont = log_font->sbc_devfont; - DEVFONT* mbc_devfont = log_font->mbc_devfont; + DEVFONT* sbc_devfont = log_font->devfonts[0]; + DEVFONT* mbc_devfont = log_font->devfonts[1]; WORDINFO word_info; int count = 0; int left_bytes = len; @@ -150,8 +150,8 @@ int GUIAPI GetTextWordInfo (PLOGFONT log_font, const char* mstr, int len, int GUIAPI GetFirstMCharLen (PLOGFONT log_font, const char* mstr, int len) { - DEVFONT* sbc_devfont = log_font->sbc_devfont; - DEVFONT* mbc_devfont = log_font->mbc_devfont; + DEVFONT* sbc_devfont = log_font->devfonts[0]; + DEVFONT* mbc_devfont = log_font->devfonts[1]; int len_cur_char = 0; if (mbc_devfont) { @@ -171,8 +171,8 @@ int GUIAPI GetFirstMCharLen (PLOGFONT log_font, const char* mstr, int len) int GUIAPI GetLastMCharLen (PLOGFONT log_font, const char* mstr, int len) { - DEVFONT* sbc_devfont = log_font->sbc_devfont; - DEVFONT* mbc_devfont = log_font->mbc_devfont; + DEVFONT* sbc_devfont = log_font->devfonts[0]; + DEVFONT* mbc_devfont = log_font->devfonts[1]; int left_bytes = len; int len_cur_char; int lastlen = 0; @@ -204,8 +204,8 @@ int GUIAPI GetLastMCharLen (PLOGFONT log_font, const char* mstr, int len) int GUIAPI GetFirstWord (PLOGFONT log_font, const char* mstr, int len, WORDINFO* word_info) { - DEVFONT* sbc_devfont = log_font->sbc_devfont; - DEVFONT* mbc_devfont = log_font->mbc_devfont; + DEVFONT* sbc_devfont = log_font->devfonts[0]; + DEVFONT* mbc_devfont = log_font->devfonts[1]; if (mbc_devfont) { int mbc_pos; @@ -234,8 +234,8 @@ int GUIAPI GetFirstWord (PLOGFONT log_font, const char* mstr, int len, int GUIAPI MB2WCEx (PLOGFONT log_font, void* dest, BOOL wc32, const unsigned char* mchar, int n) { - DEVFONT* mbc_devfont = log_font->mbc_devfont; - DEVFONT* sbc_devfont = log_font->sbc_devfont; + DEVFONT* mbc_devfont = log_font->devfonts[1]; + DEVFONT* sbc_devfont = log_font->devfonts[0]; DEVFONT* devfont; int len_cur_char = 0; Glyph32 glyph_value; @@ -282,8 +282,8 @@ int GUIAPI MB2WCEx (PLOGFONT log_font, void* dest, BOOL wc32, int GUIAPI WC2MBEx (PLOGFONT log_font, unsigned char *s, Uchar32 wc) { - DEVFONT* mbc_devfont = log_font->mbc_devfont; - DEVFONT* sbc_devfont = log_font->sbc_devfont; + DEVFONT* mbc_devfont = log_font->devfonts[1]; + DEVFONT* sbc_devfont = log_font->devfonts[0]; unsigned char mchar [16]; int len_cur_char = 0; @@ -311,8 +311,8 @@ int GUIAPI MBS2WCSEx (PLOGFONT log_font, void* dest, BOOL wc32, const unsigned char* mstr, int mstr_len, int n, int* conved_mstr_len) { - DEVFONT* mbc_devfont = log_font->mbc_devfont; - DEVFONT* sbc_devfont = log_font->sbc_devfont; + DEVFONT* mbc_devfont = log_font->devfonts[1]; + DEVFONT* sbc_devfont = log_font->devfonts[0]; DEVFONT* devfont; int left, count = 0; Uchar32* uchar32; @@ -406,8 +406,8 @@ int GUIAPI WCS2MBSEx (PLOGFONT log_font, unsigned char* dest, const void *wcs, int wcs_len, BOOL wc32, int n, int* conved_wcs_len) { - DEVFONT* mbc_devfont = log_font->mbc_devfont; - DEVFONT* sbc_devfont = log_font->sbc_devfont; + DEVFONT* mbc_devfont = log_font->devfonts[1]; + DEVFONT* sbc_devfont = log_font->devfonts[0]; int wc_count = 0, count = 0; unsigned char mchar [16] = {0}; const Uchar32* uchar32; @@ -493,7 +493,7 @@ int GUIAPI WCS2MBSEx (PLOGFONT log_font, unsigned char* dest, size_t __mg_strlen (PLOGFONT log_font, const char* mstr) { - DEVFONT* mbc_devfont = log_font->mbc_devfont; + DEVFONT* mbc_devfont = log_font->devfonts[1]; if (mbc_devfont && strstr (mbc_devfont->charset_ops->name, "UTF-16")) { size_t len = 0; @@ -514,7 +514,7 @@ char* __mg_strnchr (PLOGFONT log_font, const char* s, size_t n, int c, { size_t i; unsigned char c1, c2; - DEVFONT* mbc_devfont = log_font->mbc_devfont; + DEVFONT* mbc_devfont = log_font->devfonts[1]; if (mbc_devfont) { *chlen = 2; @@ -566,7 +566,7 @@ int __mg_substrlen (PLOGFONT log_font, const char* text, int len, len = substr - text; if (*nr_delim == 2) { - DEVFONT* mbc_devfont = log_font->mbc_devfont; + DEVFONT* mbc_devfont = log_font->devfonts[1]; unsigned char c1, c2; if (strstr (mbc_devfont->charset_ops->name, "UTF-16LE")) { diff --git a/src/font/upf.c b/src/font/upf.c index 299cf1db..a4c0b1bc 100644 --- a/src/font/upf.c +++ b/src/font/upf.c @@ -287,10 +287,10 @@ static const void* get_glyph_monobitmap (LOGFONT* logfont, DEVFONT* devfont, glyph = get_glyph (p_upf, (UPFNODE *)(((UPFV1_FILE_HEADER *)p_upf)->off_nodes + p_upf), uc16); if (glyph == NULL) { - if (uc16 < 0x80 && logfont->sbc_devfont != devfont) { /* ASCII */ + if (uc16 < 0x80 && logfont->devfonts[0] != devfont) { /* ASCII */ unsigned char ascii_ch = uc16; - return logfont->sbc_devfont->font_ops->get_glyph_monobitmap (logfont, - logfont->sbc_devfont, ascii_ch, pitch, scale); + return logfont->devfonts[0]->font_ops->get_glyph_monobitmap (logfont, + logfont->devfonts[0], ascii_ch, pitch, scale); } else glyph = &def_glyph; @@ -377,21 +377,21 @@ static int get_glyph_bbox (LOGFONT* logfont, DEVFONT* devfont, glyph = get_glyph (p_upf, (UPFNODE *)(((UPFV1_FILE_HEADER *)p_upf)->off_nodes + p_upf), uc16); if (glyph == NULL) { - if (uc16 < 0x80 && logfont->sbc_devfont != devfont) { /* ASCII */ + if (uc16 < 0x80 && logfont->devfonts[0] != devfont) { /* ASCII */ unsigned char ascii_ch = uc16; - if (logfont->sbc_devfont->font_ops->get_glyph_bbox) { - return logfont->sbc_devfont->font_ops->get_glyph_bbox (logfont, - logfont->sbc_devfont, ascii_ch, + if (logfont->devfonts[0]->font_ops->get_glyph_bbox) { + return logfont->devfonts[0]->font_ops->get_glyph_bbox (logfont, + logfont->devfonts[0], ascii_ch, px, py, pwidth, pheight); } else { int width, height, ascent; - logfont->sbc_devfont->font_ops->get_glyph_advance - (logfont, logfont->sbc_devfont, glyph_value, &width, 0); - height = logfont->sbc_devfont->font_ops->get_font_height - (logfont, logfont->sbc_devfont); - ascent = logfont->sbc_devfont->font_ops->get_font_ascent - (logfont, logfont->sbc_devfont); + logfont->devfonts[0]->font_ops->get_glyph_advance + (logfont, logfont->devfonts[0], glyph_value, &width, 0); + height = logfont->devfonts[0]->font_ops->get_font_height + (logfont, logfont->devfonts[0]); + ascent = logfont->devfonts[0]->font_ops->get_font_ascent + (logfont, logfont->devfonts[0]); if (pwidth) *pwidth = width; if (pheight) *pheight = height; @@ -435,11 +435,11 @@ static int get_glyph_advance (LOGFONT* logfont, DEVFONT* devfont, glyph = get_glyph (p_upf, (UPFNODE *)(((UPFV1_FILE_HEADER *)p_upf)->off_nodes + p_upf), uc16); if (glyph == NULL) { - if (uc16 < 0x80 && logfont->sbc_devfont != devfont) { /* ASCII */ + if (uc16 < 0x80 && logfont->devfonts[0] != devfont) { /* ASCII */ unsigned char ascii_ch = uc16; - if (logfont->sbc_devfont->font_ops->get_glyph_advance) { - return logfont->sbc_devfont->font_ops->get_glyph_advance ( - logfont, logfont->sbc_devfont, ascii_ch, px, py); + if (logfont->devfonts[0]->font_ops->get_glyph_advance) { + return logfont->devfonts[0]->font_ops->get_glyph_advance ( + logfont, logfont->devfonts[0], ascii_ch, px, py); } } else @@ -495,9 +495,9 @@ static BOOL is_glyph_existed (LOGFONT* logfont, DEVFONT* devfont, Glyph32 glyph_ glyph = get_glyph (p_upf, (UPFNODE *)(((UPFV1_FILE_HEADER *)p_upf)->off_nodes + p_upf), uc16); if (glyph == NULL) { - if (uc16 < 0x80 && logfont->sbc_devfont != devfont) /* ASCII */ - return logfont->sbc_devfont->font_ops->is_glyph_existed (logfont, - logfont->sbc_devfont, glyph_value); + if (uc16 < 0x80 && logfont->devfonts[0] != devfont) /* ASCII */ + return logfont->devfonts[0]->font_ops->is_glyph_existed (logfont, + logfont->devfonts[0], glyph_value); else return FALSE; } diff --git a/src/include/devfont.h b/src/include/devfont.h index 480ad9df..c4c543d6 100644 --- a/src/include/devfont.h +++ b/src/include/devfont.h @@ -68,14 +68,36 @@ void font_AddMBDevFont (DEVFONT* dev_font); void font_DelRelatedDevFont (DEVFONT* dev_font); void font_ResetDevFont (void); -DEVFONT* font_GetMatchedSBDevFont (LOGFONT* log_font); -DEVFONT* font_GetMatchedMBDevFont (LOGFONT* log_font); +DEVFONT* font_GetMatchedSBDevFont (LOGFONT* lf, const char* family); +DEVFONT* font_GetMatchedMBDevFont (LOGFONT* lf, const char* family); + +static inline unsigned short get_devfont_scale(LOGFONT* lf, + const DEVFONT* df) +{ + int i; + for (i = 0; i < MAXNR_DEVFONTS; i++) { + if (lf->devfonts[i] == df) + return lf->scales[i]; + } + + return 1; +} + +static inline void set_devfont_scale(LOGFONT* lf, DEVFONT* df, + unsigned short s) +{ + int i; + for (i = 0; i < MAXNR_DEVFONTS; i++) { + if (lf->devfonts[i] == df) + lf->scales[i] = s; + } +} #define GET_DEVFONT_SCALE(logfont, devfont) \ - ((devfont->charset_ops->bytes_maxlen_char > 1)?logfont->mbc_scale:logfont->sbc_scale) + get_devfont_scale(logfont, devfont) #define SET_DEVFONT_SCALE(logfont, devfont, scale) \ - ((devfont->charset_ops->bytes_maxlen_char > 1)?(logfont->mbc_scale = scale):(logfont->sbc_scale = scale)) + set_devfont_scale(logfont, devfont, scale) unsigned short font_GetBestScaleFactor (int height, int expect); @@ -265,8 +287,8 @@ struct _FONTOPS }; typedef struct { - char* type; - FONTOPS* fontops; + char* type; + FONTOPS* fontops; } FONTOPS_INFO; extern FONTOPS_INFO __mg_fontops_infos[]; diff --git a/src/include/glyph.h b/src/include/glyph.h index 62e929e9..9474d694 100644 --- a/src/include/glyph.h +++ b/src/include/glyph.h @@ -41,12 +41,12 @@ #ifndef GUI_GDI_GLYPH_H #define GUI_GDI_GLYPH_H - - #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ +Glyph32 _gdi_set_glyph_dfi(LOGFONT* lf, Glyph32 gv); + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/src/kernel/desktop-procs.c b/src/kernel/desktop-procs.c index 0a1c881e..a7ff50ec 100644 --- a/src/kernel/desktop-procs.c +++ b/src/kernel/desktop-procs.c @@ -1038,7 +1038,7 @@ static int srvChangeCaption (int cli, int idx_znode, const char *caption) if (caplen < 32) { strcpy (nodes[idx_znode].caption, caption); } else { - GetTextCharPos (menufont, caption, caplen, (32 - 3), /* '...' = 3*/ + get_text_char_pos (menufont, caption, caplen, (32 - 3), /* '...' = 3*/ &fit_chars, pos_chars); memcpy(nodes[idx_znode].caption, caption, pos_chars[fit_chars-1]); diff --git a/src/kernel/desktop.c b/src/kernel/desktop.c index 1e9033de..6d4c822d 100644 --- a/src/kernel/desktop.c +++ b/src/kernel/desktop.c @@ -1340,11 +1340,11 @@ static HWND dskSetActiveZOrderNode (int cli, int idx_znode) return old_hwnd; } -static void GetTextCharPos (PLOGFONT log_font, const char *text, +static void get_text_char_pos (PLOGFONT log_font, const char *text, int len, int fit_bytes, int *fit_chars, int *pos_chars) { - DEVFONT* sbc_devfont = log_font->sbc_devfont; - DEVFONT* mbc_devfont = log_font->mbc_devfont; + DEVFONT* sbc_devfont = log_font->devfonts[0]; + DEVFONT* mbc_devfont = log_font->devfonts[1]; int len_cur_char; int left_bytes = len; int char_count = 0, bytes = 0; @@ -1624,11 +1624,11 @@ static int AllocZOrderNode (int cli, HWND hwnd, HWND main_win, strcpy (nodes[free_slot].caption, caption); } else { int tail_pos; - GetTextCharPos (menufont, caption, caplen, (32 - 3), /* '...' = 3*/ + get_text_char_pos (menufont, caption, caplen, (32 - 3), /* '...' = 3*/ &fit_chars, pos_chars); tail_pos = pos_chars[fit_chars-1]; - + if ((tail_pos + 3) >= 32 && fit_chars > 4) { tail_pos = pos_chars[fit_chars-2]; if (tail_pos + 3 >= 32) { @@ -1640,7 +1640,7 @@ static int AllocZOrderNode (int cli, HWND hwnd, HWND main_win, } memcpy(nodes[free_slot].caption, caption, tail_pos); strcpy ((nodes[free_slot].caption + tail_pos), "..."); - + } } diff --git a/src/newgdi/bidi.c b/src/newgdi/bidi.c index 5087085a..ea6d0ca8 100644 --- a/src/newgdi/bidi.c +++ b/src/newgdi/bidi.c @@ -65,29 +65,30 @@ static Glyph32* _gdi_get_glyphs_string(PDC pdc, const unsigned char* text, int left_bytes = text_len; unsigned int glyph_type; Glyph32 glyph_value; - DEVFONT* sbc_devfont = pdc->pLogFont->sbc_devfont; - DEVFONT* mbc_devfont = pdc->pLogFont->mbc_devfont; + DEVFONT* sbc_devfont = pdc->pLogFont->devfonts[0]; + DEVFONT* mbc_devfont = pdc->pLogFont->devfonts[1]; Glyph32 *logical_glyphs = NULL; if (mbc_devfont) { int prev_len = 0; const unsigned char* prev_mchar = NULL; logical_glyphs = malloc(text_len * sizeof (Glyph32)); - while (left_bytes > 0){ + while (left_bytes > 0) { len_cur_char = mbc_devfont->charset_ops->len_first_char ((const unsigned char*)text, left_bytes); if (len_cur_char > 0) { glyph_value = mbc_devfont->charset_ops->char_glyph_value (prev_mchar, prev_len, text, left_bytes); - logical_glyphs[i++] = SET_MBC_GLYPH(glyph_value); + logical_glyphs[i++] + = _gdi_set_glyph_dfi(pdc->pLogFont, glyph_value); glyph_type = (*mbc_devfont->charset_ops->glyph_type) (glyph_value); - if(!(glyph_type & MCHAR_TYPE_NOSPACING_MARK)){ + if (!(glyph_type & MCHAR_TYPE_NOSPACING_MARK)){ prev_mchar = text; prev_len = len_cur_char; } - else{ + else { prev_len += len_cur_char; } @@ -109,17 +110,20 @@ static Glyph32* _gdi_get_glyphs_string(PDC pdc, const unsigned char* text, else break; } - if(nr_glyphs) *nr_glyphs = i; + + if (nr_glyphs) + *nr_glyphs = i; } + return logical_glyphs; } static unsigned int inline get_glyph_type(LOGFONT* logfont, Glyph32 glyph_value) { if (IS_MBC_GLYPH (glyph_value)) - return logfont->mbc_devfont->charset_ops->glyph_type(glyph_value); + return logfont->devfonts[1]->charset_ops->glyph_type(glyph_value); else - return logfont->sbc_devfont->charset_ops->glyph_type(glyph_value); + return logfont->devfonts[0]->charset_ops->glyph_type(glyph_value); } static int inline get_glyph_advance_in_dc (PDC pdc, Glyph32 glyph_value) @@ -378,8 +382,8 @@ static int _gdi_output_glyphs_direct(PDC pdc, const unsigned char* text, { unsigned int glyph_type; Glyph32 glyph_value; - DEVFONT* sbc_devfont = pdc->pLogFont->sbc_devfont; - DEVFONT* mbc_devfont = pdc->pLogFont->mbc_devfont; + DEVFONT* sbc_devfont = pdc->pLogFont->devfonts[0]; + DEVFONT* mbc_devfont = pdc->pLogFont->devfonts[1]; int len_cur_char = 0; int left_bytes = text_len; int prev_len = 0; @@ -403,7 +407,7 @@ static int _gdi_output_glyphs_direct(PDC pdc, const unsigned char* text, glyph_value = mbc_devfont->charset_ops->char_glyph_value (prev_mchar, prev_len, text, left_bytes); - glyph_value = SET_MBC_GLYPH(glyph_value); + glyph_value = _gdi_set_glyph_dfi(pdc->pLogFont, glyph_value); goto do_glyph; } } @@ -461,7 +465,7 @@ do_glyph: Glyph32* _gdi_bidi_reorder (PDC pdc, const unsigned char* text, int text_len, int* nr_glyphs) { - DEVFONT* mbc_devfont = pdc->pLogFont->mbc_devfont; + DEVFONT* mbc_devfont = pdc->pLogFont->devfonts[1]; Glyph32 *logical_glyphs = NULL; if (mbc_devfont && mbc_devfont->charset_ops->bidi_glyph_type) { @@ -480,8 +484,8 @@ int _gdi_reorder_text (PDC pdc, const unsigned char* text, int text_len, int i = 0; unsigned int glyph_type; Glyph32 glyph_value; - DEVFONT* sbc_devfont = pdc->pLogFont->sbc_devfont; - DEVFONT* mbc_devfont = pdc->pLogFont->mbc_devfont; + DEVFONT* sbc_devfont = pdc->pLogFont->devfonts[0]; + DEVFONT* mbc_devfont = pdc->pLogFont->devfonts[1]; if (mbc_devfont) { int nr_glyphs = 0; @@ -490,7 +494,7 @@ int _gdi_reorder_text (PDC pdc, const unsigned char* text, int text_len, if (mbc_devfont->charset_ops->bidi_glyph_type) { logical_glyphs = _gdi_bidi_reorder (pdc, text, text_len, &nr_glyphs); - if(!logical_glyphs || nr_glyphs <= 0) + if (!logical_glyphs || nr_glyphs <= 0) return 0; i = _gdi_output_visual_glyphs (pdc, logical_glyphs, nr_glyphs, @@ -556,8 +560,8 @@ _gdi_get_glyphs_string_charbreak(PDC pdc, const unsigned char* text, int left_bytes = text_len; unsigned int glyph_type; Glyph32 glyph_value; - DEVFONT* sbc_devfont = pdc->pLogFont->sbc_devfont; - DEVFONT* mbc_devfont = pdc->pLogFont->mbc_devfont; + DEVFONT* sbc_devfont = pdc->pLogFont->devfonts[0]; + DEVFONT* mbc_devfont = pdc->pLogFont->devfonts[1]; Glyph32 *logical_glyphs = NULL; DRAWTEXTEX2_CTXT* ctxt = (DRAWTEXTEX2_CTXT*)context; @@ -582,7 +586,7 @@ _gdi_get_glyphs_string_charbreak(PDC pdc, const unsigned char* text, prev_mchar = text; prev_len = len_cur_char; - logical_glyphs[i++] = SET_MBC_GLYPH(glyph_value); + logical_glyphs[i++] = _gdi_set_glyph_dfi(pdc->pLogFont, glyph_value); glyph_type = (*mbc_devfont->charset_ops->glyph_type) (glyph_value); @@ -630,8 +634,8 @@ static int _gdi_get_nextword_width (PDC pdc, const unsigned char* pText, int nCount, int* nChars, void* context) { SIZE size; - DEVFONT* sbc_devfont = pdc->pLogFont->sbc_devfont; - DEVFONT* mbc_devfont = pdc->pLogFont->mbc_devfont; + DEVFONT* sbc_devfont = pdc->pLogFont->devfonts[0]; + DEVFONT* mbc_devfont = pdc->pLogFont->devfonts[1]; WORDINFO word_info = {0}; *nChars = 0; @@ -725,7 +729,7 @@ static Glyph32* _gdi_get_glyphs_string_wordbreak(PDC pdc, const unsigned char* text, int text_len, int* nr_glyphs, void* context) { - DEVFONT* mbc_devfont = pdc->pLogFont->mbc_devfont; + DEVFONT* mbc_devfont = pdc->pLogFont->devfonts[1]; DRAWTEXTEX2_CTXT* ctxt = (DRAWTEXTEX2_CTXT*)context; Glyph32 *logical_glyphs = NULL; @@ -823,7 +827,7 @@ _gdi_output_glyphs_direct_sbc_rtol_break(PDC pdc, const unsigned char* text, int i = 0; unsigned int glyph_type; Glyph32 glyph_value; - DEVFONT* sbc_devfont = pdc->pLogFont->sbc_devfont; + DEVFONT* sbc_devfont = pdc->pLogFont->devfonts[0]; if(ctxt->nFormat & DT_WORDBREAK){ _gdi_get_glyphs_string_sbc_rtol_wordbreak(pdc, @@ -858,7 +862,7 @@ int _gdi_reorder_text_break (PDC pdc, const unsigned char* text, int text_len, BOOL direction, CB_ONE_GLYPH cb_one_glyph, void* context) { int i = 0; - DEVFONT* mbc_devfont = pdc->pLogFont->mbc_devfont; + DEVFONT* mbc_devfont = pdc->pLogFont->devfonts[1]; if (mbc_devfont) { int nr_glyphs = text_len; @@ -1356,8 +1360,8 @@ void GUIAPI BIDIGetTextRangesLog2Vis(LOGFONT* log_font, *nr_ranges = 0; /* it is not bidi string. */ - if (!log_font->mbc_devfont || (log_font->mbc_devfont && - !log_font->mbc_devfont->charset_ops->bidi_glyph_type)) { + if (!log_font->devfonts[1] || (log_font->devfonts[1] && + !log_font->devfonts[1]->charset_ops->bidi_glyph_type)) { *ranges = NULL; return; } @@ -1444,7 +1448,7 @@ int GUIAPI BIDIGetTextVisualGlyphs(LOGFONT* log_font, GLYPHMAPINFO** glyphs_map) { int nr_glyphs = 0; - DEVFONT* mbc_devfont = log_font->mbc_devfont; + DEVFONT* mbc_devfont = log_font->devfonts[1]; if (glyphs == NULL || glyphs_map == NULL) return nr_glyphs; @@ -1465,7 +1469,7 @@ int GUIAPI BIDIGetTextVisualGlyphs(LOGFONT* log_font, Glyph32* GUIAPI BIDILogGlyphs2VisGlyphs(LOGFONT* log_font, Glyph32* glyphs, int nr_glyphs, GLYPHMAPINFO* glyphs_map) { - DEVFONT* mbc_devfont = log_font->mbc_devfont; + DEVFONT* mbc_devfont = log_font->devfonts[1]; if (nr_glyphs > 0 && mbc_devfont && mbc_devfont->charset_ops->bidi_glyph_type) { @@ -1483,7 +1487,7 @@ BOOL GUIAPI BIDILogGlyphs2VisGlyphsEx(LOGFONT* log_font, Glyph32* glyphs, int nr_glyphs, int pel, void* extra, CB_REVERSE_EXTRA cb_reorder_extra) { - DEVFONT* mbc_devfont = log_font->mbc_devfont; + DEVFONT* mbc_devfont = log_font->devfonts[1]; if (nr_glyphs > 0 && mbc_devfont && mbc_devfont->charset_ops->bidi_glyph_type) { @@ -1501,7 +1505,7 @@ void GUIAPI BIDIGetLogicalEmbedLevelsEx(LOGFONT* log_font, Glyph32* glyphs, int nr_glyphs, int pel, Uint8** embedding_levels) { - DEVFONT* mbc_devfont = log_font->mbc_devfont; + DEVFONT* mbc_devfont = log_font->devfonts[1]; if (*embedding_levels == NULL) *embedding_levels = malloc(nr_glyphs * sizeof (Uint8)); @@ -1519,7 +1523,7 @@ void GUIAPI BIDIGetVisualEmbedLevelsEx(LOGFONT* log_font, Glyph32* glyphs, int nr_glyphs, int pel, Uint8** embedding_levels) { - DEVFONT* mbc_devfont = log_font->mbc_devfont; + DEVFONT* mbc_devfont = log_font->devfonts[1]; if (*embedding_levels == NULL) *embedding_levels = malloc(nr_glyphs * sizeof (Uint8)); diff --git a/src/newgdi/drawtext.c b/src/newgdi/drawtext.c index 0c7cc850..5eb2f05c 100644 --- a/src/newgdi/drawtext.c +++ b/src/newgdi/drawtext.c @@ -64,7 +64,7 @@ extern int __mg_substrlen (PLOGFONT log_font, const char* text, int len, static inline BOOL is_utf16_logfont (PDC pdc) { DEVFONT* mbc_devfont; - mbc_devfont = pdc->pLogFont->mbc_devfont; + mbc_devfont = pdc->pLogFont->devfonts[1]; if (mbc_devfont && strstr (mbc_devfont->charset_ops->name, "UTF-16")) { return TRUE; } @@ -135,8 +135,8 @@ static int txtGetWidthOfNextWord (PDC pdc, const unsigned char* pText, int nCount, int* nChars) { SIZE size; - DEVFONT* sbc_devfont = pdc->pLogFont->sbc_devfont; - DEVFONT* mbc_devfont = pdc->pLogFont->mbc_devfont; + DEVFONT* sbc_devfont = pdc->pLogFont->devfonts[0]; + DEVFONT* mbc_devfont = pdc->pLogFont->devfonts[1]; WORDINFO word_info = {0}; *nChars = 0; @@ -433,12 +433,12 @@ int DrawTextEx2 (HDC hdc, const char* pText, int nCount, line_height = pdc->pLogFont->size + pdc->alExtra + pdc->blExtra; if (nFormat & DT_TABSTOP) nTabWidth = HIWORD (nFormat) * - (*pdc->pLogFont->sbc_devfont->font_ops->get_ave_width) - (pdc->pLogFont, pdc->pLogFont->sbc_devfont); + (*pdc->pLogFont->devfonts[0]->font_ops->get_ave_width) + (pdc->pLogFont, pdc->pLogFont->devfonts[0]); else { nTabWidth = pdc->tabstop * - (*pdc->pLogFont->sbc_devfont->font_ops->get_ave_width) - (pdc->pLogFont, pdc->pLogFont->sbc_devfont); + (*pdc->pLogFont->devfonts[0]->font_ops->get_ave_width) + (pdc->pLogFont, pdc->pLogFont->devfonts[0]); } /* Transfer logical to device to screen here. */ diff --git a/src/newgdi/glyph-unicode.c b/src/newgdi/glyph-unicode.c index a0d38c86..21536e08 100644 --- a/src/newgdi/glyph-unicode.c +++ b/src/newgdi/glyph-unicode.c @@ -157,6 +157,7 @@ typedef enum { } _WordType; struct glyph_break_ctxt { + LOGFONT* lf; DEVFONT* mbc_devfont; DEVFONT* sbc_devfont; Glyph32* gvs; @@ -317,7 +318,7 @@ static int get_next_glyph(struct glyph_break_ctxt* gbctxt, if (mclen > 0) { *gv = gbctxt->mbc_devfont->charset_ops->char_glyph_value (NULL, 0, (Uint8*)mstr, mclen); - *gv = SET_MBC_GLYPH(*gv); + *gv = _gdi_set_glyph_dfi(gbctxt->lf, *gv); if (gbctxt->mbc_devfont->charset_ops->conv_to_uc32) *uc = gbctxt->mbc_devfont->charset_ops->conv_to_uc32(*gv); @@ -1484,7 +1485,7 @@ static int gbctxt_push_back(struct glyph_break_ctxt* gbctxt, //dbg_dump_gbctxt(gbctxt, "check_word_breaks", uc, gwsbo); check_sentence_breaks(gbctxt, uc, gc, gbctxt->n); - //dbg_dump_gbctxt(gbctxt, "check_sentence_breaks", uc, gwsbo); + dbg_dump_gbctxt(gbctxt, "check_sentence_breaks", uc, gwsbo); // Character Transformation // NOTE: Assume character transformation will not affect the breaks @@ -2202,8 +2203,9 @@ int GUIAPI GetGlyphsAndBreaks(LOGFONT* logfont, const char* mstr, int mstr_len, col_nl = TRUE; memset(&gbctxt, 0, sizeof(gbctxt)); - gbctxt.mbc_devfont = logfont->mbc_devfont; - gbctxt.sbc_devfont = logfont->sbc_devfont; + gbctxt.lf = logfont; + gbctxt.mbc_devfont = logfont->devfonts[1]; + gbctxt.sbc_devfont = logfont->devfonts[0]; #if 0 gbctxt.gvs = NULL; gbctxt.ucs = NULL; diff --git a/src/newgdi/glyph.c b/src/newgdi/glyph.c index c202b602..e0bd20e4 100644 --- a/src/newgdi/glyph.c +++ b/src/newgdi/glyph.c @@ -73,19 +73,33 @@ Glyph32 GUIAPI GetGlyphValue (LOGFONT* logfont, const char* mchar, int mchar_len, const char* pre_mchar, int pre_len) { int len_cur_char; - - Glyph32 glyph_value = INV_GLYPH_VALUE; - DEVFONT* sbc_devfont = logfont->sbc_devfont; - DEVFONT* mbc_devfont = logfont->mbc_devfont; + Glyph32 gv = INV_GLYPH_VALUE; + DEVFONT* sbc_devfont = logfont->devfonts[0]; + DEVFONT* mbc_devfont = logfont->devfonts[1]; if (mbc_devfont) { + int i, dfi; + DEVFONT* df; + len_cur_char = mbc_devfont->charset_ops->len_first_char ((const unsigned char*)mchar, mchar_len); if (len_cur_char > 0) { - glyph_value = mbc_devfont->charset_ops->char_glyph_value + gv = mbc_devfont->charset_ops->char_glyph_value ((Uint8*)pre_mchar, pre_len, (Uint8*)mchar, mchar_len); - return SET_MBC_GLYPH(glyph_value); + + dfi = 1; + for (i = 1; i < MAXNR_DEVFONTS; i++) { + if ((df = logfont->devfonts[i])) { + if (df->font_ops->is_glyph_existed(logfont, df, gv)) { + dfi = i; + break; + } + } + } + + // return the first devfont as the default + return SET_GLYPH_DFI(gv, dfi); } } @@ -93,11 +107,11 @@ Glyph32 GUIAPI GetGlyphValue (LOGFONT* logfont, const char* mchar, ((const unsigned char*)mchar, mchar_len); if (len_cur_char > 0) { - glyph_value = sbc_devfont->charset_ops->char_glyph_value + gv = sbc_devfont->charset_ops->char_glyph_value (NULL, 0, (Uint8*)mchar, mchar_len); } - return glyph_value; + return gv; } Glyph32 GUIAPI GetGlyphShape (LOGFONT* logfont, const char* mchar, @@ -106,14 +120,17 @@ Glyph32 GUIAPI GetGlyphShape (LOGFONT* logfont, const char* mchar, int len_cur_char; Glyph32 glyph_value = INV_GLYPH_VALUE; - DEVFONT* sbc_devfont = logfont->sbc_devfont; - DEVFONT* mbc_devfont = logfont->mbc_devfont; + DEVFONT* sbc_devfont = logfont->devfonts[0]; + DEVFONT* mbc_devfont = logfont->devfonts[1]; if (mbc_devfont) { len_cur_char = mbc_devfont->charset_ops->len_first_char ( (const unsigned char*)mchar, mchar_len); if (len_cur_char > 0) { + int i, dfi; + DEVFONT* df; + if (mbc_devfont->charset_ops->glyph_shape) glyph_value = mbc_devfont->charset_ops->glyph_shape( (const unsigned char*)mchar, mchar_len, shape_type); @@ -121,7 +138,17 @@ Glyph32 GUIAPI GetGlyphShape (LOGFONT* logfont, const char* mchar, glyph_value = mbc_devfont->charset_ops->char_glyph_value (NULL, 0, (Uint8*)mchar, len_cur_char); - return SET_MBC_GLYPH(glyph_value); + dfi = 1; + for (i = 1; i < MAXNR_DEVFONTS; i++) { + if ((df = logfont->devfonts[i])) { + if (df->font_ops->is_glyph_existed(logfont, df, glyph_value)) { + dfi = i; + break; + } + } + } + + return SET_GLYPH_DFI(glyph_value, dfi); } } @@ -2467,7 +2494,7 @@ static void make_back_area(PDC pdc, int x0, int y0, int x1, int y1, if (pdc->pLogFont->rotation) *flag = ROTATE_RECT; else if (pdc->pLogFont->style & FS_SLANT_ITALIC && - !(pdc->pLogFont->sbc_devfont->style & FS_SLANT_ITALIC)) + !(pdc->pLogFont->devfonts[0]->style & FS_SLANT_ITALIC)) *flag = ITALIC_RECT; else *flag = ROMAN_RECT; @@ -2873,7 +2900,7 @@ end: int _gdi_get_italic_added_width (LOGFONT* logfont) { if (logfont->style & FS_SLANT_ITALIC - && !(logfont->sbc_devfont->style & FS_SLANT_ITALIC)) { + && !(logfont->devfonts[0]->style & FS_SLANT_ITALIC)) { return (logfont->size + 1) >> 1; } else { @@ -2883,17 +2910,33 @@ int _gdi_get_italic_added_width (LOGFONT* logfont) void _gdi_start_new_line (PDC pdc) { - DEVFONT* sbc_devfont = pdc->pLogFont->sbc_devfont; - DEVFONT* mbc_devfont = pdc->pLogFont->mbc_devfont; + int i; + DEVFONT* df; - if (mbc_devfont) { - if (mbc_devfont->font_ops->start_str_output) { - mbc_devfont->font_ops->start_str_output(pdc->pLogFont, mbc_devfont); + for (i = 0; i < MAXNR_DEVFONTS; i++) { + if ((df = pdc->pLogFont->devfonts[i])) { + if (df->font_ops->start_str_output) { + df->font_ops->start_str_output(pdc->pLogFont, df); + } } } - - if (sbc_devfont->font_ops->start_str_output) { - sbc_devfont->font_ops->start_str_output(pdc->pLogFont, sbc_devfont); - } +} + +Glyph32 _gdi_set_glyph_dfi(LOGFONT* lf, Glyph32 gv) +{ + int i, dfi = 1; + DEVFONT* df; + + for (i = 1; i < MAXNR_DEVFONTS; i++) { + if ((df = lf->devfonts[i])) { + if (df->font_ops->is_glyph_existed(lf, df, gv)) { + dfi = i; + break; + } + } + } + + // return the first devfont as the default + return SET_GLYPH_DFI(gv, dfi); } diff --git a/src/newgdi/tabbedtextout.c b/src/newgdi/tabbedtextout.c index 88dfd7de..cc09bbab 100644 --- a/src/newgdi/tabbedtextout.c +++ b/src/newgdi/tabbedtextout.c @@ -64,7 +64,7 @@ extern int __mg_substrlen (PLOGFONT log_font, const char* text, int len, static inline BOOL is_utf16_logfont (PDC pdc) { DEVFONT* mbc_devfont; - mbc_devfont = pdc->pLogFont->mbc_devfont; + mbc_devfont = pdc->pLogFont->devfonts[1]; if (mbc_devfont && strstr (mbc_devfont->charset_ops->name, "UTF-16")) { return TRUE; } @@ -332,8 +332,8 @@ int GUIAPI TabbedTextOutLen (HDC hdc, int x, int y, if (len < 0) len = __mg_strlen (pdc->pLogFont, spText); if (len == 0) return 0; - tab_width = pdc->pLogFont->sbc_devfont->font_ops->get_ave_width - (pdc->pLogFont, pdc->pLogFont->sbc_devfont) * pdc->tabstop; + tab_width = pdc->pLogFont->devfonts[0]->font_ops->get_ave_width + (pdc->pLogFont, pdc->pLogFont->devfonts[0]) * pdc->tabstop; /* override start point by current text position */ if ((pdc->ta_flags & TA_CP_MASK) == TA_UPDATECP) { @@ -379,8 +379,8 @@ int GUIAPI GetTabbedTextExtent (HDC hdc, const char* spText, int len, return 0; } - tab_width = pdc->pLogFont->sbc_devfont->font_ops->get_ave_width - (pdc->pLogFont, pdc->pLogFont->sbc_devfont) * pdc->tabstop; + tab_width = pdc->pLogFont->devfonts[0]->font_ops->get_ave_width + (pdc->pLogFont, pdc->pLogFont->devfonts[0]) * pdc->tabstop; advance = _gdi_tabbed_text_out (pdc, 0, 0, (const unsigned char*) spText, len, tab_width, TRUE, NULL, &size); @@ -400,8 +400,8 @@ int _gdi_tabbedex_text_out (PDC pdc, int x, int y, #if 0 DEVFONT* sbc_devfont; DEVFONT* mbc_devfont; - sbc_devfont = pdc->pLogFont->sbc_devfont; - mbc_devfont = pdc->pLogFont->mbc_devfont; + sbc_devfont = pdc->pLogFont->devfonts[0]; + mbc_devfont = pdc->pLogFont->devfonts[1]; #endif ctxt.pdc = pdc; @@ -484,8 +484,8 @@ int GUIAPI TabbedTextOutEx (HDC hdc, int x, int y, const char* spText, if (nCount == 0) return 0; if (nTabs == 0 || pTabPos == NULL) { - int ave_width = (*pdc->pLogFont->sbc_devfont->font_ops->get_ave_width) - (pdc->pLogFont, pdc->pLogFont->sbc_devfont); + int ave_width = (*pdc->pLogFont->devfonts[0]->font_ops->get_ave_width) + (pdc->pLogFont, pdc->pLogFont->devfonts[0]); def_tab = ave_width * pdc->tabstop; } else @@ -519,8 +519,8 @@ int GUIAPI GetTabbedTextExtentPoint (HDC hdc, const char* text, { PDC pdc = dc_HDC2PDC (hdc); LOGFONT* log_font = pdc->pLogFont; - DEVFONT* sbc_devfont = log_font->sbc_devfont; - DEVFONT* mbc_devfont = log_font->mbc_devfont; + DEVFONT* sbc_devfont = log_font->devfonts[0]; + DEVFONT* mbc_devfont = log_font->devfonts[1]; DEVFONT* devfont; int left_bytes = len; int len_cur_char; diff --git a/src/newgdi/text.c b/src/newgdi/text.c index c512a3cd..4e08020e 100644 --- a/src/newgdi/text.c +++ b/src/newgdi/text.c @@ -61,18 +61,22 @@ int GUIAPI GetFontHeight (HDC hdc) int GUIAPI GetMaxFontWidth (HDC hdc) { + int i; + DEVFONT* df; PDC pdc = dc_HDC2PDC(hdc); - DEVFONT* sbc_devfont = pdc->pLogFont->sbc_devfont; - DEVFONT* mbc_devfont = pdc->pLogFont->mbc_devfont; - int sbc_max_width = (*sbc_devfont->font_ops->get_max_width) - (pdc->pLogFont, sbc_devfont); - int mbc_max_width = 0; + int max_width = 0; - if (mbc_devfont) - mbc_max_width = (*mbc_devfont->font_ops->get_max_width) - (pdc->pLogFont, mbc_devfont); - - return (sbc_max_width > mbc_max_width) ? sbc_max_width : mbc_max_width; + for (i = 0; i < MAXNR_DEVFONTS; i++) { + int value; + df = pdc->pLogFont->devfonts[i]; + if (df == NULL) + break; + + value = df->font_ops->get_max_width(pdc->pLogFont, df); + max_width = MAX(max_width, value); + } + + return max_width; } void GUIAPI GetLastTextOutPos (HDC hdc, POINT* pt) diff --git a/src/newgdi/textout.c b/src/newgdi/textout.c index 5da8af74..bfd3054d 100644 --- a/src/newgdi/textout.c +++ b/src/newgdi/textout.c @@ -64,7 +64,7 @@ extern int __mg_substrlen (PLOGFONT log_font, const char* text, int len, static inline BOOL is_utf16_logfont (PDC pdc) { DEVFONT* mbc_devfont; - mbc_devfont = pdc->pLogFont->mbc_devfont; + mbc_devfont = pdc->pLogFont->devfonts[1]; if (mbc_devfont && strstr (mbc_devfont->charset_ops->name, "UTF-16")) { return TRUE; } @@ -452,8 +452,8 @@ int GUIAPI GetTextExtentPoint (HDC hdc, const char* text, int len, { PDC pdc = dc_HDC2PDC (hdc); LOGFONT* log_font = pdc->pLogFont; - DEVFONT* sbc_devfont = log_font->sbc_devfont; - DEVFONT* mbc_devfont = log_font->mbc_devfont; + DEVFONT* sbc_devfont = log_font->devfonts[0]; + DEVFONT* mbc_devfont = log_font->devfonts[1]; int len_cur_char, advance_cur_char; int left_bytes = len; int char_count = 0; diff --git a/src/textedit/mtextedit.c b/src/textedit/mtextedit.c index 309af27c..7a2038ec 100644 --- a/src/textedit/mtextedit.c +++ b/src/textedit/mtextedit.c @@ -3850,7 +3850,7 @@ static int texteditor_get_text_count(mTextEditor* self, int start_with, BOOL bTe return len; } - if(plogfont->mbc_devfont == NULL) + if(plogfont->devfonts[1] == NULL) return len; while(idx < len)