ref: c26f7f975b5f7f58f2b6da3d3308e3915f757a6f
parent: ae7dc1f62d826083d418e86cce3f66a76dff038a
author: Alexei Podtelezhnikov <[email protected]>
date: Thu Sep 28 20:13:19 EDT 2017
Bitmap metrics presetting [2/2]. * src/base/ftobjs.c (FT_Load_Glyph): Preset the bitmap metrics when appropriate but `FT_Render_Glyph' is not called. * include/freetype/freetype.h (FT_GlyphSlotRec): Document the change.
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2017-09-29 Alexei Podtelezhnikov <[email protected]>
+
+ Bitmap metrics presetting [2/2].
+
+ * src/base/ftobjs.c (FT_Load_Glyph): Preset the bitmap metrics when
+ appropriate but `FT_Render_Glyph' is not called.
+ * include/freetype/freetype.h (FT_GlyphSlotRec): Document the change.
+
2017-09-28 Alexei Podtelezhnikov <[email protected]>
[smooth, raster] Miscellaneous cleanups.
@@ -38,7 +46,7 @@
function.
* src/base/ftobjs.c (ft_glyphslot_preset_bitmap): New function that
- calculates prespective bitmap metrics for the given rendering mode.
+ calculates prospective bitmap metrics for the given rendering mode.
* include/freetype/internal/ftobjs.h (ft_glyphslot_preset_bitmap):
Declare it.
--- a/include/freetype/freetype.h
+++ b/include/freetype/freetype.h
@@ -1696,17 +1696,13 @@
/* @FT_GLYPH_FORMAT_COMPOSITE, but other values */
/* are possible. */
/* */
- /* bitmap :: This field is used as a bitmap descriptor */
- /* when the slot format is */
- /* @FT_GLYPH_FORMAT_BITMAP. Note that the */
- /* address and content of the bitmap buffer can */
- /* change between calls of @FT_Load_Glyph and a */
- /* few other functions. */
+ /* bitmap :: This field is used as a bitmap descriptor. */
+ /* Note that the address and content of the */
+ /* bitmap buffer can change between calls of */
+ /* @FT_Load_Glyph and a few other functions. */
/* */
/* bitmap_left :: The bitmap's left bearing expressed in */
- /* integer pixels. Only valid if the format is */
- /* @FT_GLYPH_FORMAT_BITMAP, this is, if the */
- /* glyph slot contains a bitmap. */
+ /* integer pixels. */
/* */
/* bitmap_top :: The bitmap's top bearing expressed in integer */
/* pixels. This is the distance from the */
@@ -1753,7 +1749,9 @@
/* If @FT_Load_Glyph is called with default flags (see */
/* @FT_LOAD_DEFAULT) the glyph image is loaded in the glyph slot in */
/* its native format (e.g., an outline glyph for TrueType and Type~1 */
- /* formats). */
+ /* formats). [Since 2.8.2] The prospective bitmap metrics are */
+ /* calculated according to @FT_LOAD_TARGET_XXX and other flags even */
+ /* for the outline glyph, even if @FT_LOAD_RENDER is not set. */
/* */
/* This image can later be converted into a bitmap by calling */
/* @FT_Render_Glyph. This function searches the current renderer for */
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -983,20 +983,22 @@
FT_TRACE5(( " linear x advance: %d\n" , slot->linearHoriAdvance ));
FT_TRACE5(( " linear y advance: %d\n" , slot->linearVertAdvance ));
- /* do we need to render the image now? */
+ /* do we need to render the image or preset the bitmap now? */
if ( !error &&
slot->format != FT_GLYPH_FORMAT_BITMAP &&
- slot->format != FT_GLYPH_FORMAT_COMPOSITE &&
- load_flags & FT_LOAD_RENDER )
+ slot->format != FT_GLYPH_FORMAT_COMPOSITE )
{
FT_Render_Mode mode = FT_LOAD_TARGET_MODE( load_flags );
- if ( mode == FT_RENDER_MODE_NORMAL &&
- (load_flags & FT_LOAD_MONOCHROME ) )
+ if ( mode == FT_RENDER_MODE_NORMAL &&
+ load_flags & FT_LOAD_MONOCHROME )
mode = FT_RENDER_MODE_MONO;
- error = FT_Render_Glyph( slot, mode );
+ if ( load_flags & FT_LOAD_RENDER )
+ error = FT_Render_Glyph( slot, mode );
+ else if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 )
+ ft_glyphslot_preset_bitmap( slot, mode, NULL );
}
Exit: