Commit a3d30257 authored by David Turner's avatar David Turner
Browse files

defining new types to hold "internal" fields of public

objects:

  FT_Face_Internal, FT_Size_Internal, FT_Slot_Internal

these contain some fields that may change between releases
of FreeType, without affecting the size of FT_FaceRec,
FT_SizeRec, FT_GlyphSlotRec, etc.., which means that
drivers wouldn't need to be recompiled if we only add new
fields to an internal structure..

I plan to hack a few things related to the auto-hinter and
I need this move to ensure that we will not break binary
compatibility between 2.0 and 2.1 :-)

- David
parent d2d17013
......@@ -393,6 +393,21 @@
/*************************************************************************/
/*************************************************************************/
/*********************************************************************
*
* <Type>
* FT_Face_Internal
*
* <Description>
* an opaque handle to a FT_Face_InternalRec structure, used to
* model private data of a given FT_Face object.
*
* this fields might change between releases of FreeType 2 and
* are not generally available to client applications
*
*/
typedef struct FT_Face_InternalRec_* FT_Face_Internal;
/*************************************************************************/
/* */
/* FreeType base face class */
......@@ -570,18 +585,10 @@
/* this should be set to 0. Only relevant for */
/* scalable formats. */
/* */
/* transform_matrix :: A 2x2 matrix of 16.16 coefficients used */
/* to transform glyph outlines after they are */
/* loaded from the font. Only used by the */
/* convenience functions. */
/* */
/* transform_delta :: A translation vector used to transform */
/* glyph outlines after they are loaded from */
/* the font. Only used by the convenience */
/* functions. */
/* */
/* transform_flags :: Some flags used to classify the transform. */
/* Only used by the convenience functions. */
/* internal :: a pointer to internal fields of the face */
/* object. These fields can change freely */
/* between releases of FreeType and are not */
/* publicly available.. */
/* */
typedef struct FT_FaceRec_
{
......@@ -620,6 +627,7 @@
FT_GlyphSlot glyph;
FT_Size size;
FT_CharMap charmap;
/*@private begin */
......@@ -627,18 +635,12 @@
FT_Memory memory;
FT_Stream stream;
FT_CharMap charmap;
FT_ListRec sizes_list;
FT_Generic autohint;
void* extensions;
FT_UShort max_points;
FT_Short max_contours;
FT_Matrix transform_matrix;
FT_Vector transform_delta;
FT_Int transform_flags;
FT_Face_Internal internal;
/*@private end */
......@@ -848,6 +850,17 @@
#define FT_STYLE_FLAG_BOLD 2
/*********************************************************************
*
* <Type>
* FT_Size_Internal
*
* <Description>
* an opaque handle to a FT_Size_InternalRec structure, used to
* model private data of a given FT_Size object.
*/
typedef struct FT_Size_InternalRec_* FT_Size_Internal;
/*************************************************************************/
/* */
/* FreeType base size metrics */
......@@ -914,16 +927,16 @@
/* */
typedef struct FT_Size_Metrics_
{
FT_UShort x_ppem; /* horizontal pixels per EM */
FT_UShort y_ppem; /* vertical pixels per EM */
FT_UShort x_ppem; /* horizontal pixels per EM */
FT_UShort y_ppem; /* vertical pixels per EM */
FT_Fixed x_scale; /* two scales used to convert font units */
FT_Fixed y_scale; /* to 26.6 frac. pixel coordinates.. */
FT_Fixed x_scale; /* two scales used to convert font units */
FT_Fixed y_scale; /* to 26.6 frac. pixel coordinates.. */
FT_Pos ascender; /* ascender in 26.6 frac. pixels */
FT_Pos descender; /* descender in 26.6 frac. pixels */
FT_Pos height; /* text height in 26.6 frac. pixels */
FT_Pos max_advance; /* max horizontal advance, in 26.6 pixels */
FT_Pos ascender; /* ascender in 26.6 frac. pixels */
FT_Pos descender; /* descender in 26.6 frac. pixels */
FT_Pos height; /* text height in 26.6 frac. pixels */
FT_Pos max_advance; /* max horizontal advance, in 26.6 pixels */
} FT_Size_Metrics;
......@@ -951,9 +964,11 @@
/* */
typedef struct FT_SizeRec_
{
FT_Face face; /* parent face object */
FT_Generic generic; /* generic pointer for client uses */
FT_Size_Metrics metrics; /* size metrics */
FT_Face face; /* parent face object */
FT_Generic generic; /* generic pointer for client uses */
FT_Size_Metrics metrics; /* size metrics */
FT_Size_Internal internal;
} FT_SizeRec;
......@@ -974,20 +989,16 @@
typedef struct FT_SubGlyph_ FT_SubGlyph;
/*************************************************************************/
/* */
/* <Struct> */
/* FT_GlyphLoader */
/* */
/* <Description> */
/* The glyph loader is an internal object used to load several glyphs */
/* together (for example, in the case of composites). */
/* */
/* <Note> */
/* The glyph loader implementation is not part of the high-level API, */
/* hence the forward structure declaration. */
/* */
typedef struct FT_GlyphLoader_ FT_GlyphLoader;
/*********************************************************************
*
* <Type>
* FT_Slot_Internal
*
* <Description>
* an opaque handle to a FT_Slot_InternalRec structure, used to
* model private data of a given FT_GlyphSlot object.
*/
typedef struct FT_Slot_InternalRec_* FT_Slot_Internal;
/*************************************************************************/
......@@ -1146,14 +1157,7 @@
void* other;
/*@private begin */
FT_GlyphLoader* loader;
FT_Bool glyph_transformed;
FT_Matrix glyph_matrix;
FT_Vector glyph_delta;
/*@private end */
FT_Slot_Internal internal;
} FT_GlyphSlotRec;
......
......@@ -75,6 +75,95 @@
#define ABS( a ) ( (a) < 0 ? -(a) : (a) )
#endif
/*************************************************************************/
/* */
/* <Struct> */
/* FT_GlyphLoader */
/* */
/* <Description> */
/* The glyph loader is an internal object used to load several glyphs */
/* together (for example, in the case of composites). */
/* */
/* <Note> */
/* The glyph loader implementation is not part of the high-level API, */
/* hence the forward structure declaration. */
/* */
typedef struct FT_GlyphLoader_ FT_GlyphLoader;
/*************************************************************************/
/* */
/* <Struct> */
/* FT_Face_InternalRec */
/* */
/* <Description> */
/* this structure contains the internal fields of each FT_Face */
/* object. These fields may change between different releases */
/* of FreeType. */
/* */
/* <Fields> */
/* transform_matrix :: A 2x2 matrix of 16.16 coefficients used */
/* to transform glyph outlines after they are */
/* loaded from the font. Only used by the */
/* convenience functions. */
/* */
/* transform_delta :: A translation vector used to transform */
/* glyph outlines after they are loaded from */
/* the font. Only used by the convenience */
/* functions. */
/* */
/* transform_flags :: Some flags used to classify the transform. */
/* Only used by the convenience functions. */
/* */
/* */
/* */
/* */
typedef struct FT_Face_InternalRec_
{
FT_UShort max_points;
FT_Short max_contours;
FT_Matrix transform_matrix;
FT_Vector transform_delta;
FT_Int transform_flags;
} FT_Face_InternalRec;
/*************************************************************************/
/* */
/* <Struct> */
/* FT_Slot_InternalRec */
/* */
/* <Description> */
/* this structure contains the internal fields of each FT_GlyphSlot */
/* object. These fields may change between different releases */
/* of FreeType. */
/* */
/* <Fields> */
/* loader :: the glyph loader object used to load */
/* outlines in the glyph slot */
/* */
/* glyph_transformed :: boolean. set to TRUE when the loaded glyph */
/* must be transformed through a specific */
/* font transform. this is _not_ the same as */
/* the face transform set through */
/* FT_Set_Transform */
/* */
/* glyph_matrix :: the 2x2 matrix corresponding to the glyph */
/* transform, when required */
/* */
/* glyph_delta :: the 2d translation vector corresponding to */
/* the glyph transform, when required */
/* */
typedef struct FT_Slot_InternalRec_
{
FT_GlyphLoader* loader;
FT_Bool glyph_transformed;
FT_Matrix glyph_matrix;
FT_Vector glyph_delta;
} FT_GlyphSlot_InternalRec;
/*************************************************************************/
/*************************************************************************/
......
......@@ -1286,12 +1286,12 @@
/* XXX: TO DO - slot->linearHoriAdvance */
/* now copy outline into glyph slot */
ah_loader_rewind( slot->loader );
error = ah_loader_copy_points( slot->loader, gloader );
ah_loader_rewind( slot->internal->loader );
error = ah_loader_copy_points( slot->internal->loader, gloader );
if ( error )
goto Exit;
slot->outline = slot->loader->base.outline;
slot->outline = slot->internal->loader->base.outline;
slot->format = ft_glyph_format_outline;
}
......
......@@ -674,16 +674,23 @@
FT_Driver_Class* clazz = driver->clazz;
FT_Memory memory = driver->root.memory;
FT_Error error = FT_Err_Ok;
FT_Slot_Internal internal;
slot->library = driver->root.library;
if ( ALLOC( internal, sizeof( *internal ) ) )
goto Exit;
slot->internal = internal;
if ( FT_DRIVER_USES_OUTLINES( driver ) )
error = FT_GlyphLoader_New( memory, &slot->loader );
error = FT_GlyphLoader_New( memory, &internal->loader );
if ( !error && clazz->init_slot )
error = clazz->init_slot( slot );
Exit:
return error;
}
......@@ -728,6 +735,9 @@
FT_Memory memory = driver->root.memory;
if ( clazz->done_slot )
clazz->done_slot( slot );
/* free bitmap buffer if needed */
if ( slot->flags & ft_glyph_own_bitmap )
FREE( slot->bitmap.buffer );
......@@ -735,12 +745,11 @@
/* free glyph loader */
if ( FT_DRIVER_USES_OUTLINES( driver ) )
{
FT_GlyphLoader_Done( slot->loader );
slot->loader = 0;
FT_GlyphLoader_Done( slot->internal->loader );
slot->internal->loader = 0;
}
if ( clazz->done_slot )
clazz->done_slot( slot );
FREE( slot->internal );
}
......@@ -876,40 +885,45 @@
FT_Matrix* matrix,
FT_Vector* delta )
{
FT_Face_Internal internal;
if ( !face )
return;
face->transform_flags = 0;
internal = face->internal;
internal->transform_flags = 0;
if ( !matrix )
{
face->transform_matrix.xx = 0x10000L;
face->transform_matrix.xy = 0;
face->transform_matrix.yx = 0;
face->transform_matrix.yy = 0x10000L;
matrix = &face->transform_matrix;
internal->transform_matrix.xx = 0x10000L;
internal->transform_matrix.xy = 0;
internal->transform_matrix.yx = 0;
internal->transform_matrix.yy = 0x10000L;
matrix = &internal->transform_matrix;
}
else
face->transform_matrix = *matrix;
internal->transform_matrix = *matrix;
/* set transform_flags bit flag 0 if `matrix' isn't the identity */
if ( ( matrix->xy | matrix->yx ) ||
matrix->xx != 0x10000L ||
matrix->yy != 0x10000L )
face->transform_flags |= 1;
internal->transform_flags |= 1;
if ( !delta )
{
face->transform_delta.x = 0;
face->transform_delta.y = 0;
delta = &face->transform_delta;
internal->transform_delta.x = 0;
internal->transform_delta.y = 0;
delta = &internal->transform_delta;
}
else
face->transform_delta = *delta;
internal->transform_delta = *delta;
/* set transform_flags bit flag 1 if `delta' isn't the null vector */
if ( delta->x | delta->y )
face->transform_flags |= 2;
internal->transform_flags |= 2;
}
......@@ -1044,8 +1058,11 @@
if ( ( load_flags & FT_LOAD_IGNORE_TRANSFORM ) == 0 )
{
FT_Face_Internal internal = face->internal;
/* now, transform the glyph image if needed */
if ( face->transform_flags )
if ( internal->transform_flags )
{
/* get renderer */
FT_Renderer renderer = ft_lookup_glyph_renderer( slot );
......@@ -1053,10 +1070,10 @@
if ( renderer )
error = renderer->clazz->transform_glyph( renderer, slot,
&face->transform_matrix,
&face->transform_delta );
&internal->transform_matrix,
&internal->transform_delta );
/* transform advance */
FT_Vector_Transform( &slot->advance, &face->transform_matrix );
FT_Vector_Transform( &slot->advance, &internal->transform_matrix );
}
}
......@@ -1147,6 +1164,7 @@
if ( driver->clazz->done_size )
driver->clazz->done_size( size );
FREE( size->internal );
FREE( size );
}
......@@ -1190,6 +1208,7 @@
( face->face_flags & FT_FACE_FLAG_EXTERNAL_STREAM ) != 0 );
/* get rid of it */
FREE( face->internal );
FREE( face );
}
......@@ -1228,6 +1247,7 @@
FT_Driver_Class* clazz;
FT_Face face = 0;
FT_Error error;
FT_Face_Internal internal;
clazz = driver->clazz;
......@@ -1237,9 +1257,14 @@
if ( ALLOC( face, clazz->face_object_size ) )
goto Fail;
face->driver = driver;
face->memory = memory;
face->stream = stream;
if ( ALLOC( internal, sizeof(*internal) ) )
goto Fail;
face->internal = internal;
face->driver = driver;
face->memory = memory;
face->stream = stream;
error = clazz->init_face( stream,
face,
......@@ -1255,6 +1280,7 @@
if ( error )
{
clazz->done_face( face );
FREE( face->internal );
FREE( face );
*aface = 0;
}
......@@ -1574,14 +1600,19 @@
face->size = size;
}
/* initialize transformation for convenience functions */
face->transform_matrix.xx = 0x10000L;
face->transform_matrix.xy = 0;
face->transform_matrix.yx = 0;
face->transform_matrix.yy = 0x10000L;
face->transform_delta.x = 0;
face->transform_delta.y = 0;
/* initialize internal face data */
{
FT_Face_Internal internal = face->internal;
internal->transform_matrix.xx = 0x10000L;
internal->transform_matrix.xy = 0;
internal->transform_matrix.yx = 0;
internal->transform_matrix.yy = 0x10000L;
internal->transform_delta.x = 0;
internal->transform_delta.y = 0;
}
*aface = face;
goto Exit;
......@@ -1809,6 +1840,9 @@
goto Exit;
size->face = face;
/* for now, do not use any internal fields in size objects */
size->internal = 0;
if ( clazz->init_size )
error = clazz->init_size( size );
......@@ -2038,6 +2072,21 @@
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
/* <Note> */
/* the values of "pixel_width" and "pixel_height" correspond to */
/* the pixel values of the _typographic_ character size, which are */
/* NOT necessarily the same as the dimensions of the glyph */
/* "bitmap cells". */
/* */
/* The "character size" is really the size of an abstract square */
/* called the "EM", used to design the font. However, depending */
/* on the font design, glyphs will be smaller or greater than the */
/* EM. */
/* */
/* this means that setting the pixel size to 8x8 doesn't guarantee */
/* in any way that you'll end up with glyph bitmaps that all fit */
/* within an 8x8 cell.. far from it.. */
/* */
FT_EXPORT_DEF( FT_Error ) FT_Set_Pixel_Sizes( FT_Face face,
FT_UInt pixel_width,
FT_UInt pixel_height )
......
......@@ -243,7 +243,7 @@
if ( glyph )
{
FT_GlyphLoader* loader = glyph->root.loader;
FT_GlyphLoader* loader = glyph->root.internal->loader;
builder->loader = loader;
......
......@@ -264,12 +264,15 @@
/* advance width */
if ( load_flags & FT_LOAD_NO_RECURSE )
{
FT_Slot_Internal internal = glyph->root.internal;
glyph->root.metrics.horiBearingX = decoder.builder.left_bearing.x;
glyph->root.metrics.horiAdvance = decoder.builder.advance.x;
glyph->root.glyph_matrix = font_matrix;
glyph->root.glyph_delta = font_offset;
glyph->root.glyph_transformed = 1;
internal->glyph_matrix = font_matrix;
internal->glyph_delta = font_offset;
internal->glyph_transformed = 1;
}
else
{
......@@ -280,7 +283,7 @@
/* copy the _unscaled_ advance width */
metrics->horiAdvance = decoder.builder.advance.x;
glyph->root.linearHoriAdvance = decoder.builder.advance.x;
glyph->root.glyph_transformed = 0;
glyph->root.internal->glyph_transformed = 0;
/* make up vertical metrics */
metrics->vertBearingX = 0;
......
......@@ -269,8 +269,8 @@
root->underline_position = face->cid.font_info.underline_position;
root->underline_thickness = face->cid.font_info.underline_thickness;
root->max_points = 0;
root->max_contours = 0;
root->internal->max_points = 0;
root->internal->max_contours = 0;
}
}
......
......@@ -1076,7 +1076,7 @@
if ( glyph )
{
FT_GlyphLoader* loader = glyph->loader;
FT_GlyphLoader* loader = glyph->internal->loader;
builder->loader = loader;
......
......@@ -222,7 +222,7 @@
if ( decoder->builder.no_recurse )
{
FT_GlyphSlot glyph = (FT_GlyphSlot)decoder->builder.glyph;
FT_GlyphLoader* loader = glyph->loader;
FT_GlyphLoader* loader = glyph->internal->loader;
FT_SubGlyph* subg;
......
......@@ -583,11 +583,11 @@
face->root.num_glyphs = maxProfile->numGlyphs;
face->root.max_points = MAX( maxProfile->maxCompositePoints,
maxProfile->maxPoints );
face->root.internal->max_points = MAX( maxProfile->maxCompositePoints,
maxProfile->maxPoints );
face->root.max_contours = MAX( maxProfile->maxCompositeContours,
maxProfile->maxContours );
face->root.internal->max_contours = MAX( maxProfile->maxCompositeContours,
maxProfile->maxContours );
face->max_components = (FT_ULong)maxProfile->maxComponentElements +
maxProfile->maxComponentDepth;
......@@ -599,8 +599,8 @@
/* We also increase maxPoints and maxContours in order to support */
/* some broken fonts. */
face->root.max_points += 8;
face->root.max_contours += 4;
face->root.internal->max_points += 8;
face->root.internal->max_contours += 4;
FT_TRACE2(( "MAXP loaded.\n" ));