diff --git a/src/font/freetype2.c b/src/font/freetype2.c index 01c7cc8c..91d7fd97 100644 --- a/src/font/freetype2.c +++ b/src/font/freetype2.c @@ -260,7 +260,7 @@ load_or_search_glyph (FTINSTANCEINFO* ft_inst_info, FT_Face* face, else { if (char_type == DEVFONTGLYPHTYPE_SUBPIXEL && ft_inst_info->ft_lcdfilter != FT_LCD_FILTER_NONE) - ft_load_flags |= FT_LOAD_TARGET_LCD; + ft_load_flags |= FT_LOAD_TARGET_LCD | FT_LOAD_FORCE_AUTOHINT; else ft_load_flags |= FT_LOAD_TARGET_NORMAL | FT_LOAD_FORCE_AUTOHINT; } @@ -385,9 +385,9 @@ get_glyph_bbox (LOGFONT* logfont, DEVFONT* devfont, Glyph32 gv, else { FT_Glyph_Get_CBox (ft_inst_info->glyph, FT_GLYPH_BBOX_PIXELS, &bbox); - //Note: using subpixel filter, the bbox_w is 2 pixel wider than normal. if (IS_SUBPIXEL(logfont) && (ft_inst_info->ft_lcdfilter != FT_LCD_FILTER_NONE)) { + // Note: using subpixel filter, the bbox_w is 2 pixel wider than normal. bbox.xMin -= 1; bbox.xMax += 1; } @@ -468,9 +468,6 @@ char_bitmap_pixmap (LOGFONT* logfont, DEVFONT* devfont, FT_LOCK(&ft_lock); - if (IS_SUBPIXEL(logfont)) - FT_Library_SetLcdFilter(ft_library, ft_inst_info->ft_lcdfilter); - #ifdef _MGFONT_TTF_CACHE if (ft_inst_info->cache) { TTFCACHEINFO *cacheinfo; @@ -483,7 +480,8 @@ char_bitmap_pixmap (LOGFONT* logfont, DEVFONT* devfont, if (pitch) *pitch = cacheinfo->pitch; - if (!is_grey && sz) { + /* VincentWei: override the bbox.w and bbox.h with bitmap information */ + if (sz) { sz->cx = cacheinfo->width; sz->cy = cacheinfo->height; } @@ -495,6 +493,9 @@ char_bitmap_pixmap (LOGFONT* logfont, DEVFONT* devfont, } #endif /* _MGFONT_TTF_CACHE */ + if (IS_SUBPIXEL(logfont)) + FT_Library_SetLcdFilter(ft_library, ft_inst_info->ft_lcdfilter); + if (load_or_search_glyph (ft_inst_info, &face, gv, get_glyph_bmptype(logfont, devfont))) { _ERR_PRINTF ("%s: load_or_search_glyph failed in freetype2\n", @@ -573,8 +574,8 @@ char_bitmap_pixmap (LOGFONT* logfont, DEVFONT* devfont, source->pitch, ft_inst_info->cache)); } - /* VincentWei: override the bbox.w and bbox.h with bitmap for monobitmap */ - if (!is_grey && sz) { + /* VincentWei: override the bbox.w and bbox.h with bitmap information */ + if (sz) { sz->cx = pcache->width; sz->cy = pcache->height; } @@ -596,7 +597,7 @@ char_bitmap_pixmap (LOGFONT* logfont, DEVFONT* devfont, buffer = get_raster_bitmap_buffer(source->rows * source->pitch); memcpy(buffer, source->buffer, source->rows * source->pitch); /* VincentWei: override the bbox.w and bbox.h with bitmap */ - if (!is_grey && sz) { + if (sz) { sz->cx = source->width; sz->cy = source->rows; } @@ -880,8 +881,10 @@ new_instance (LOGFONT* logfont, DEVFONT* devfont, BOOL need_sbc_font) FT_LOAD_TARGET_MONO | FT_LOAD_FORCE_AUTOHINT; else { if ((logfont->style & FS_RENDER_MASK) == FS_RENDER_SUBPIXEL - && ft_inst_info->ft_lcdfilter != FT_LCD_FILTER_NONE) - ft_inst_info->image_type.flags |= FT_LOAD_TARGET_LCD; + && ft_inst_info->ft_lcdfilter != FT_LCD_FILTER_NONE) { + ft_inst_info->image_type.flags |= + FT_LOAD_TARGET_LCD | FT_LOAD_FORCE_AUTOHINT; + } else ft_inst_info->image_type.flags |= FT_LOAD_TARGET_NORMAL | FT_LOAD_FORCE_AUTOHINT; @@ -922,7 +925,7 @@ new_instance (LOGFONT* logfont, DEVFONT* devfont, BOOL need_sbc_font) ft_inst_info->cache = __mg_ttc_create(devfont->name, logfont->style, logfont->size, logfont->rotation, - nblk , blksize, _TTF_HASH_NDIR, make_hash_key); + nblk, blksize, _TTF_HASH_NDIR, make_hash_key); DP(("__mg_ttc_create() return %p\n", ft_inst_info->cache)); } else { diff --git a/src/newgdi/glyph.c b/src/newgdi/glyph.c index 49f1c3c6..65727f2d 100644 --- a/src/newgdi/glyph.c +++ b/src/newgdi/glyph.c @@ -1986,6 +1986,8 @@ static BOOL _gdi_get_glyph_data (PDC pdc, Glyph32 glyph_value, /* the returned bits will be the subpixled pixmap */ data = (BYTE*)(*devfont->font_ops->get_glyph_greybitmap) (logfont, devfont, glyph_value, bbox, &pitch, &scale); + // the width of SUBPIXEL bitmap is 3x real width of bbox + bbox->cx /= 3; ctxt->cb = _dc_ft2subpixel_scan_line; /* flip the subpixeled pixmap */