Reorganize object fields. Make some fields more generic, so that we can access them the same way regardless of Type 1 or CFF. * include/freetype/internal/psaux.h (PS_Builder): Change `TT_Face' to `FT_Face'. Remove unused fields. * src/psaux/psft.c: Update all accesses of `PS_Builder.face'. Add some asserts to guard against casting `T1_Face' as `TT_Face'. * src/type1/t1objs.h (T1_GlyphSlot): Reorder fields to follow `CFF_GlyphSlot', so that we can pretend they are the same in the interpreter. * src/psaux/psobjs.c (ps_builder_init, ps_builder_add_point): Updated with above changes.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221
diff --git a/ChangeLog b/ChangeLog
index 1264e38..c75a316 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,26 @@
2017-09-25 Ewald Hew <ewaldhew@gmail.com>
+ [psaux, type1] Reorganize object fields.
+
+ Make some fields more generic, so that we can access them the same
+ way regardless of Type 1 or CFF.
+
+ * include/freetype/internal/psaux.h (PS_Builder): Change `TT_Face'
+ to `FT_Face'.
+ Remove unused fields.
+
+ * src/psaux/psft.c: Update all accesses of `PS_Builder.face'.
+ Add some asserts to guard against casting `T1_Face' as `TT_Face'.
+
+ * src/type1/t1objs.h (T1_GlyphSlot): Reorder fields to follow
+ `CFF_GlyphSlot', so that we can pretend they are the same in the
+ interpreter.
+
+ * src/psaux/psobjs.c (ps_builder_init, ps_builder_add_point):
+ Updated with above changes.
+
+2017-09-25 Ewald Hew <ewaldhew@gmail.com>
+
[psaux] Prepare for Type 1 mode.
Add some checks for Type 1 data passing through.
diff --git a/include/freetype/internal/psaux.h b/include/freetype/internal/psaux.h
index 45013e4..bde0bfa 100644
--- a/include/freetype/internal/psaux.h
+++ b/include/freetype/internal/psaux.h
@@ -513,7 +513,7 @@ FT_BEGIN_HEADER
struct PS_Builder_
{
FT_Memory memory;
- TT_Face face;
+ FT_Face face;
CFF_GlyphSlot glyph;
FT_GlyphLoader loader;
FT_Outline* base;
@@ -532,9 +532,6 @@ FT_BEGIN_HEADER
FT_Bool metrics_only;
- void* hints_funcs; /* hinter-specific */
- void* hints_globals; /* hinter-specific */
-
FT_Bool is_t1;
PS_Builder_FuncsRec funcs;
diff --git a/src/psaux/psft.c b/src/psaux/psft.c
index 34ac0b6..25d4a40 100644
--- a/src/psaux/psft.c
+++ b/src/psaux/psft.c
@@ -293,9 +293,9 @@
cf2_getUnitsPerEm( PS_Decoder* decoder )
{
FT_ASSERT( decoder && decoder->builder.face );
- FT_ASSERT( decoder->builder.face->root.units_per_EM );
+ FT_ASSERT( decoder->builder.face->units_per_EM );
- return decoder->builder.face->root.units_per_EM;
+ return decoder->builder.face->units_per_EM;
}
@@ -355,7 +355,7 @@
FT_Bool no_stem_darkening_driver =
driver->no_stem_darkening;
FT_Char no_stem_darkening_font =
- builder->face->root.internal->no_stem_darkening;
+ builder->face->internal->no_stem_darkening;
/* local error */
FT_Error error2 = FT_Err_Ok;
@@ -384,9 +384,14 @@
&hinted,
&scaled );
- /* copy isCFF2 boolean from TT_Face to CF2_Font */
- font->isCFF2 = builder->face->is_cff2;
- font->isT1 = is_t1;
+ if ( is_t1 )
+ font->isCFF2 = FALSE;
+ else
+ {
+ /* copy isCFF2 boolean from TT_Face to CF2_Font */
+ font->isCFF2 = ((TT_Face)builder->face)->is_cff2;
+ }
+ font->isT1 = is_t1;
font->renderingFlags = 0;
if ( hinted )
@@ -472,10 +477,11 @@
FT_ASSERT( decoder && decoder->builder.face );
FT_ASSERT( vec && len );
-
- face = decoder->builder.face;
+ FT_ASSERT( !decoder->builder.is_t1 );
+
+ face = (TT_Face)decoder->builder.face;
mm = (FT_Service_MultiMasters)face->mm;
-
+
return mm->get_var_blend( FT_FACE( face ), len, NULL, vec, NULL );
}
#endif
@@ -487,7 +493,7 @@
{
FT_ASSERT( decoder &&
decoder->builder.face &&
- decoder->builder.face->root.size );
+ decoder->builder.face->size );
/*
* Note that `y_ppem' can be zero if there wasn't a call to
@@ -499,7 +505,7 @@
*
*/
return cf2_intToFixed(
- decoder->builder.face->root.size->metrics.y_ppem );
+ decoder->builder.face->size->metrics.y_ppem );
}
@@ -650,13 +656,14 @@
FT_ASSERT( decoder );
+ FT_ASSERT( !decoder->builder.is_t1 );
FT_ZERO( buf );
#ifdef FT_CONFIG_OPTION_INCREMENTAL
/* Incremental fonts don't necessarily have valid charsets. */
/* They use the character code, not the glyph index, in this case. */
- if ( decoder->builder.face->root.internal->incremental_interface )
+ if ( decoder->builder.face->internal->incremental_interface )
gid = code;
else
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
@@ -666,7 +673,7 @@
return FT_THROW( Invalid_Glyph_Format );
}
- error = decoder->get_glyph_callback( decoder->builder.face,
+ error = decoder->get_glyph_callback( (TT_Face)decoder->builder.face,
(CF2_UInt)gid,
&charstring,
&len );
@@ -690,8 +697,9 @@
CF2_Buffer buf )
{
FT_ASSERT( decoder );
+ FT_ASSERT( !decoder->builder.is_t1 );
- decoder->free_glyph_callback( decoder->builder.face,
+ decoder->free_glyph_callback( (TT_Face)decoder->builder.face,
(FT_Byte**)&buf->start,
(FT_ULong)( buf->end - buf->start ) );
}
diff --git a/src/psaux/psobjs.c b/src/psaux/psobjs.c
index a4dd448..dcb3474 100644
--- a/src/psaux/psobjs.c
+++ b/src/psaux/psobjs.c
@@ -2062,9 +2062,9 @@
{
T1_Builder t1builder = (T1_Builder)builder;
- ps_builder->face = (TT_Face)t1builder->face;
- ps_builder->glyph = t1builder->glyph;
ps_builder->memory = t1builder->memory;
+ ps_builder->face = (FT_Face)t1builder->face;
+ ps_builder->glyph = (CFF_GlyphSlot)t1builder->glyph;
ps_builder->loader = t1builder->loader;
ps_builder->base = t1builder->base;
ps_builder->current = t1builder->current;
@@ -2086,8 +2086,8 @@
{
CFF_Builder* cffbuilder = (CFF_Builder*)builder;
- ps_builder->face = cffbuilder->face;
ps_builder->memory = cffbuilder->memory;
+ ps_builder->face = (FT_Face)cffbuilder->face;
ps_builder->glyph = cffbuilder->glyph;
ps_builder->loader = cffbuilder->loader;
ps_builder->base = cffbuilder->base;
@@ -2172,7 +2172,7 @@
else
#endif
#ifdef T1_CONFIG_OPTION_OLD_ENGINE
- if ( builder->face->is_t1 )
+ if ( builder->is_t1 )
{
point->x = FIXED_TO_INT( x );
point->y = FIXED_TO_INT( y );
diff --git a/src/type1/t1objs.h b/src/type1/t1objs.h
index 39d26bf..d009b39 100644
--- a/src/type1/t1objs.h
+++ b/src/type1/t1objs.h
@@ -120,12 +120,12 @@ FT_BEGIN_HEADER
FT_Bool hint;
FT_Bool scaled;
- FT_Int max_points;
- FT_Int max_contours;
-
FT_Fixed x_scale;
FT_Fixed y_scale;
+ FT_Int max_points;
+ FT_Int max_contours;
+
} T1_GlyphSlotRec;