And some more.

2007-11-07  Behdad Esfahbod  <behdad@gnome.org>

        * pango/opentype/*: And some more.
This commit is contained in:
Behdad Esfahbod 2007-11-07 09:59:18 +00:00 committed by Behdad Esfahbod
parent 78ef65ba08
commit 47d2c33e3d
11 changed files with 95 additions and 96 deletions

View File

@ -28,10 +28,10 @@ typedef struct HB_GlyphItemRec_ {
} HB_GlyphItemRec, *HB_GlyphItem;
typedef struct HB_PositionRec_ {
FT_Pos x_pos;
FT_Pos y_pos;
FT_Pos x_advance;
FT_Pos y_advance;
HB_Fixed x_pos;
HB_Fixed y_pos;
HB_Fixed x_advance;
HB_Fixed y_advance;
HB_UShort back; /* number of glyphs to go back
for drawing current glyph */
HB_Bool new_advance; /* if set, the advance width values are

View File

@ -131,7 +131,7 @@ HB_UShort arabic_props[] = { I|L, M|L, M|L, M|L, M|L, F|L, I|L, M|L
void
try_string (FT_Library library,
FT_Face face,
HB_Font font,
HB_GSUB gsub)
{
HB_Error error;
@ -139,9 +139,9 @@ try_string (FT_Library library,
HB_GSUB_String *out_str;
HB_UInt i;
if ((error = HB_GSUB_String_New (face->memory, &in_str)))
if ((error = HB_GSUB_String_New (font->memory, &in_str)))
croak ("HB_GSUB_String_New", error);
if ((error = HB_GSUB_String_New (face->memory, &out_str)))
if ((error = HB_GSUB_String_New (font->memory, &out_str)))
croak ("HB_GSUB_String_New", error);
if ((error = HB_GSUB_String_Set_Length (in_str, N_ELEMENTS (arabic_str))))
@ -149,7 +149,7 @@ try_string (FT_Library library,
for (i=0; i < N_ELEMENTS (arabic_str); i++)
{
in_str->string[i] = FT_Get_Char_Index (face, arabic_str[i]);
in_str->string[i] = FT_Get_Char_Index (font, arabic_str[i]);
in_str->properties[i] = arabic_props[i];
in_str->components[i] = i;
in_str->ligIDs[i] = i;
@ -173,7 +173,7 @@ main (int argc, char **argv)
{
HB_Error error;
FT_Library library;
FT_Face face;
HB_Font font;
HB_GSUB gsub;
HB_GPOS gpos;
@ -186,13 +186,13 @@ main (int argc, char **argv)
if ((error = FT_Init_FreeType (&library)))
croak ("FT_Init_FreeType", error);
if ((error = FT_New_Face (library, argv[1], 0, &face)))
if ((error = FT_New_Face (library, argv[1], 0, &font)))
croak ("FT_New_Face", error);
printf ("<?xml version=\"1.0\"?>\n");
printf ("<OpenType>\n");
if (!(error = HB_Load_GSUB_Table (face, &gsub, NULL)))
if (!(error = HB_Load_GSUB_Table (font, &gsub, NULL)))
{
HB_Dump_GSUB_Table (gsub, stdout);
@ -202,7 +202,7 @@ main (int argc, char **argv)
else if (error != HB_Err_Not_Covered)
fprintf (stderr, "HB_Load_GSUB_Table %x\n", error);
if (!(error = HB_Load_GPOS_Table (face, &gpos, NULL)))
if (!(error = HB_Load_GPOS_Table (font, &gpos, NULL)))
{
HB_Dump_GPOS_Table (gpos, stdout);
@ -215,14 +215,14 @@ main (int argc, char **argv)
printf ("</OpenType>\n");
#if 0
select_cmap (face);
select_cmap (font);
add_features (gsub);
try_string (library, face, gsub);
try_string (library, font, gsub);
#endif
if ((error = FT_Done_Face (face)))
if ((error = FT_Done_Face (font)))
croak ("FT_Done_Face", error);
if ((error = FT_Done_FreeType (library)))

View File

@ -35,9 +35,9 @@ static void Free_NewGlyphClasses( HB_GDEFHeader* gdef );
static HB_Error GDEF_Create( void* ext,
PFace face )
PFace font )
{
DEFINE_LOAD_LOCALS( face->stream );
DEFINE_LOAD_LOCALS( font->stream );
HB_GDEFHeader* gdef = (HB_GDEFHeader*)ext;
Long table;
@ -54,11 +54,11 @@ static HB_Error GDEF_Create( void* ext,
/* we store the start offset and the size of the subtable */
table = HB_LookUp_Table( face, TTAG_GDEF );
table = HB_LookUp_Table( font, TTAG_GDEF );
if ( table < 0 )
return HB_Err_Ok; /* The table is optional */
if ( FILE_Seek( face->dirTables[table].Offset ) ||
if ( FILE_Seek( font->dirTables[table].Offset ) ||
ACCESS_Frame( 4L ) )
return error;
@ -74,7 +74,7 @@ static HB_Error GDEF_Create( void* ext,
static HB_Error GDEF_Destroy( void* ext,
PFace face )
PFace font )
{
HB_GDEFHeader* gdef = (HB_GDEFHeader*)ext;
@ -154,11 +154,11 @@ HB_Error HB_New_GDEF_Table( HB_GDEFHeader** retptr )
}
HB_Error HB_Load_GDEF_Table( FT_Face face,
HB_Error HB_Load_GDEF_Table( HB_Font font,
HB_GDEFHeader** retptr )
{
HB_Error error;
HB_Stream stream = face->stream;
HB_Stream stream = font->stream;
HB_UInt cur_offset, new_offset, base_offset;
HB_GDEFHeader* gdef;

View File

@ -80,7 +80,7 @@ struct HB_GDEFHeader_
{
HB_UInt offset;
FT_Fixed Version;
HB_16Dot16 Version;
HB_ClassDefinition GlyphClassDef;
HB_AttachList AttachList;
@ -99,7 +99,7 @@ typedef struct HB_GDEFHeader_* HB_GDEF;
HB_Error HB_New_GDEF_Table( HB_GDEFHeader** retptr );
HB_Error HB_Load_GDEF_Table( FT_Face face,
HB_Error HB_Load_GDEF_Table( HB_Font font,
HB_GDEFHeader** gdef );

View File

@ -1,7 +1,5 @@
/*******************************************************************
*
* Copyright 1996-2000 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
* Copyright 2007 Trolltech ASA
* Copyright 2007 Behdad Esfahbod
*
@ -27,6 +25,9 @@
HB_BEGIN_HEADER
#define HB_MAKE_TAG(a,b,c,d) FT_MAKE_TAG(a,b,c,d)
typedef FT_Pos HB_Fixed; /* 26.6 */
typedef FT_Fixed HB_16Dot16; /* 16.6 */
typedef FT_Face HB_Font;
typedef unsigned char HB_Byte;
typedef signed char HB_Char;

View File

@ -19,15 +19,15 @@
struct GPOS_Instance_
{
HB_GPOSHeader* gpos;
FT_Face face;
HB_Font font;
HB_Bool dvi;
HB_UShort load_flags; /* how the glyph should be loaded */
HB_Bool r2l;
HB_UShort last; /* the last valid glyph -- used
with cursive positioning */
FT_Pos anchor_x; /* the coordinates of the anchor point */
FT_Pos anchor_y; /* of the last valid glyph */
HB_Fixed anchor_x; /* the coordinates of the anchor point */
HB_Fixed anchor_y; /* of the last valid glyph */
};
typedef struct GPOS_Instance_ GPOS_Instance;
@ -44,12 +44,12 @@ static HB_Error GPOS_Do_Glyph_Lookup( GPOS_Instance* gpi,
/* the client application must replace this with something more
meaningful if multiple master fonts are to be supported. */
static HB_Error default_mmfunc( FT_Face face,
static HB_Error default_mmfunc( HB_Font font,
HB_UShort metric_id,
FT_Pos* metric_value,
HB_Fixed* metric_value,
void* data )
{
HB_UNUSED(face);
HB_UNUSED(font);
HB_UNUSED(metric_id);
HB_UNUSED(metric_value);
HB_UNUSED(data);
@ -58,7 +58,7 @@ static HB_Error default_mmfunc( FT_Face face,
HB_Error HB_Load_GPOS_Table( FT_Face face,
HB_Error HB_Load_GPOS_Table( HB_Font font,
HB_GPOSHeader** retptr,
HB_GDEFHeader* gdef )
{
@ -66,7 +66,7 @@ HB_Error HB_Load_GPOS_Table( FT_Face face,
HB_GPOSHeader* gpos;
HB_Stream stream = face->stream;
HB_Stream stream = font->stream;
HB_Error error;
@ -442,22 +442,22 @@ static HB_Error Get_ValueRecord( GPOS_Instance* gpi,
HB_UShort format,
HB_Position gd )
{
FT_Pos value;
HB_Fixed value;
HB_Short pixel_value;
HB_Error error = HB_Err_Ok;
HB_GPOSHeader* gpos = gpi->gpos;
HB_UShort x_ppem, y_ppem;
FT_Fixed x_scale, y_scale;
HB_16Dot16 x_scale, y_scale;
if ( !format )
return HB_Err_Ok;
x_ppem = gpi->face->size->metrics.x_ppem;
y_ppem = gpi->face->size->metrics.y_ppem;
x_scale = gpi->face->size->metrics.x_scale;
y_scale = gpi->face->size->metrics.y_scale;
x_ppem = gpi->font->size->metrics.x_ppem;
y_ppem = gpi->font->size->metrics.y_ppem;
x_scale = gpi->font->size->metrics.x_scale;
y_scale = gpi->font->size->metrics.y_scale;
/* design units -> fractional pixel */
@ -500,7 +500,7 @@ static HB_Error Get_ValueRecord( GPOS_Instance* gpi,
if ( format & HB_GPOS_FORMAT_HAVE_X_ID_PLACEMENT )
{
error = (gpos->mmfunc)( gpi->face, vr->XIdPlacement,
error = (gpos->mmfunc)( gpi->font, vr->XIdPlacement,
&value, gpos->data );
if ( error )
return error;
@ -508,7 +508,7 @@ static HB_Error Get_ValueRecord( GPOS_Instance* gpi,
}
if ( format & HB_GPOS_FORMAT_HAVE_Y_ID_PLACEMENT )
{
error = (gpos->mmfunc)( gpi->face, vr->YIdPlacement,
error = (gpos->mmfunc)( gpi->font, vr->YIdPlacement,
&value, gpos->data );
if ( error )
return error;
@ -516,7 +516,7 @@ static HB_Error Get_ValueRecord( GPOS_Instance* gpi,
}
if ( format & HB_GPOS_FORMAT_HAVE_X_ID_ADVANCE )
{
error = (gpos->mmfunc)( gpi->face, vr->XIdAdvance,
error = (gpos->mmfunc)( gpi->font, vr->XIdAdvance,
&value, gpos->data );
if ( error )
return error;
@ -524,7 +524,7 @@ static HB_Error Get_ValueRecord( GPOS_Instance* gpi,
}
if ( format & HB_GPOS_FORMAT_HAVE_Y_ID_ADVANCE )
{
error = (gpos->mmfunc)( gpi->face, vr->YIdAdvance,
error = (gpos->mmfunc)( gpi->font, vr->YIdAdvance,
&value, gpos->data );
if ( error )
return error;
@ -670,8 +670,8 @@ static void Free_Anchor( HB_Anchor* an )
static HB_Error Get_Anchor( GPOS_Instance* gpi,
HB_Anchor* an,
HB_UShort glyph_index,
FT_Pos* x_value,
FT_Pos* y_value )
HB_Fixed* x_value,
HB_Fixed* y_value )
{
HB_Error error = HB_Err_Ok;
@ -683,13 +683,13 @@ static HB_Error Get_Anchor( GPOS_Instance* gpi,
HB_UShort load_flags;
HB_UShort x_ppem, y_ppem;
FT_Fixed x_scale, y_scale;
HB_16Dot16 x_scale, y_scale;
x_ppem = gpi->face->size->metrics.x_ppem;
y_ppem = gpi->face->size->metrics.y_ppem;
x_scale = gpi->face->size->metrics.x_scale;
y_scale = gpi->face->size->metrics.y_scale;
x_ppem = gpi->font->size->metrics.x_ppem;
y_ppem = gpi->font->size->metrics.y_ppem;
x_scale = gpi->font->size->metrics.x_scale;
y_scale = gpi->font->size->metrics.y_scale;
switch ( an->PosFormat )
{
@ -711,21 +711,19 @@ static HB_Error Get_Anchor( GPOS_Instance* gpi,
if ( !gpi->dvi )
{
error = (gpos->gfunc)( gpi->face, glyph_index, load_flags );
error = (gpos->gfunc)( gpi->font, glyph_index, load_flags );
if ( error )
return error;
if ( gpi->face->glyph->format != ft_glyph_format_outline )
if ( gpi->font->glyph->format != ft_glyph_format_outline )
return ERR(HB_Err_Invalid_SubTable);
ap = an->af.af2.AnchorPoint;
outline = gpi->face->glyph->outline;
/* if outline.n_points is set to zero by gfunc(), we use the
design coordinate value pair. This can happen e.g. for
sbit glyphs */
outline = gpi->font->glyph->outline;
/* if n_points is set to zero, we use the design coordinate value pair.
* This can happen e.g. for sbit glyphs. */
if ( !outline.n_points )
goto no_contour_point;
@ -759,12 +757,12 @@ static HB_Error Get_Anchor( GPOS_Instance* gpi,
break;
case 4:
error = (gpos->mmfunc)( gpi->face, an->af.af4.XIdAnchor,
error = (gpos->mmfunc)( gpi->font, an->af.af4.XIdAnchor,
x_value, gpos->data );
if ( error )
return error;
error = (gpos->mmfunc)( gpi->face, an->af.af4.YIdAnchor,
error = (gpos->mmfunc)( gpi->font, an->af.af4.YIdAnchor,
y_value, gpos->data );
if ( error )
return error;
@ -1767,8 +1765,8 @@ static HB_Error Lookup_CursivePos( GPOS_Instance* gpi,
HB_CursivePos* cp = &st->cursive;
HB_EntryExitRecord* eer;
FT_Pos entry_x, entry_y;
FT_Pos exit_x, exit_y;
HB_Fixed entry_x, entry_y;
HB_Fixed exit_x, exit_y;
HB_UNUSED(nesting_level);
@ -2201,7 +2199,7 @@ static HB_Error Lookup_MarkBasePos( GPOS_Instance* gpi,
int nesting_level )
{
HB_UShort i, j, mark_index, base_index, property, class;
FT_Pos x_mark_value, y_mark_value, x_base_value, y_base_value;
HB_Fixed x_mark_value, y_mark_value, x_base_value, y_base_value;
HB_Error error;
HB_GPOSHeader* gpos = gpi->gpos;
HB_MarkBasePos* mbp = &st->markbase;
@ -2609,7 +2607,7 @@ static HB_Error Lookup_MarkLigPos( GPOS_Instance* gpi,
{
HB_UShort i, j, mark_index, lig_index, property, class;
HB_UShort mark_glyph;
FT_Pos x_mark_value, y_mark_value, x_lig_value, y_lig_value;
HB_Fixed x_mark_value, y_mark_value, x_lig_value, y_lig_value;
HB_Error error;
HB_GPOSHeader* gpos = gpi->gpos;
HB_MarkLigPos* mlp = &st->marklig;
@ -2949,7 +2947,7 @@ static HB_Error Lookup_MarkMarkPos( GPOS_Instance* gpi,
int nesting_level )
{
HB_UShort i, j, mark1_index, mark2_index, property, class;
FT_Pos x_mark1_value, y_mark1_value,
HB_Fixed x_mark1_value, y_mark1_value,
x_mark2_value, y_mark2_value;
HB_Error error;
HB_GPOSHeader* gpos = gpi->gpos;
@ -6058,7 +6056,7 @@ HB_Error HB_GPOS_Register_MM_Function( HB_GPOSHeader* gpos,
tables are ignored -- you will get device independent values. */
HB_Error HB_GPOS_Apply_String( FT_Face face,
HB_Error HB_GPOS_Apply_String( HB_Font font,
HB_GPOSHeader* gpos,
HB_UShort load_flags,
HB_Buffer buffer,
@ -6069,13 +6067,13 @@ HB_Error HB_GPOS_Apply_String( FT_Face face,
GPOS_Instance gpi;
int i, j, lookup_count, num_features;
if ( !face || !gpos || !buffer )
if ( !font || !gpos || !buffer )
return ERR(HB_Err_Invalid_Argument);
if ( buffer->in_length == 0 )
return HB_Err_Not_Covered;
gpi.face = face;
gpi.font = font;
gpi.gpos = gpos;
gpi.load_flags = load_flags;
gpi.r2l = r2l;

View File

@ -45,7 +45,7 @@ HB_BEGIN_HEADER
_glyph = HANDLE_Glyph( glyph ) */
typedef HB_Error (*HB_GlyphFunction)(FT_Face face,
typedef HB_Error (*HB_GlyphFunction)(HB_Font font,
HB_UInt glyphIndex,
HB_Int loadFlags );
@ -61,15 +61,15 @@ typedef HB_Error (*HB_GlyphFunction)(FT_Face face,
`metric_value' must be returned as a scaled value (but shouldn't
be rounded). */
typedef HB_Error (*HB_MMFunction)(FT_Face face,
typedef HB_Error (*HB_MMFunction)(HB_Font font,
HB_UShort metric_id,
FT_Pos* metric_value,
HB_Fixed* metric_value,
void* data );
struct HB_GPOSHeader_
{
FT_Fixed Version;
HB_16Dot16 Version;
HB_ScriptList ScriptList;
HB_FeatureList FeatureList;
@ -94,7 +94,7 @@ typedef struct HB_GPOSHeader_ HB_GPOSHeader;
typedef HB_GPOSHeader* HB_GPOS;
HB_Error HB_Load_GPOS_Table( FT_Face face,
HB_Error HB_Load_GPOS_Table( HB_Font font,
HB_GPOSHeader** gpos,
HB_GDEFHeader* gdef );
@ -151,7 +151,7 @@ HB_Error HB_GPOS_Register_MM_Function( HB_GPOSHeader* gpos,
tables are ignored -- you will get device independent values. */
HB_Error HB_GPOS_Apply_String( FT_Face face,
HB_Error HB_GPOS_Apply_String( HB_Font font,
HB_GPOSHeader* gpos,
HB_UShort load_flags,
HB_Buffer buffer,

View File

@ -30,11 +30,11 @@ static HB_Error GSUB_Do_Glyph_Lookup( HB_GSUBHeader* gsub,
HB_Error HB_Load_GSUB_Table( FT_Face face,
HB_Error HB_Load_GSUB_Table( HB_Font font,
HB_GSUBHeader** retptr,
HB_GDEFHeader* gdef )
{
HB_Stream stream = face->stream;
HB_Stream stream = font->stream;
HB_Error error;
HB_UInt cur_offset, new_offset, base_offset;

View File

@ -49,7 +49,7 @@ struct HB_GSUBHeader_
{
HB_UInt offset;
FT_Fixed Version;
HB_16Dot16 Version;
HB_ScriptList ScriptList;
HB_FeatureList FeatureList;
@ -68,7 +68,7 @@ typedef struct HB_GSUBHeader_ HB_GSUBHeader;
typedef HB_GSUBHeader* HB_GSUB;
HB_Error HB_Load_GSUB_Table( FT_Face face,
HB_Error HB_Load_GSUB_Table( HB_Font font,
HB_GSUBHeader** gsub,
HB_GDEFHeader* gdef );

View File

@ -34,14 +34,14 @@ HB_INTERNAL void
_hb_stream_frame_exit( HB_Stream stream );
HB_INTERNAL HB_Error
_hb_face_goto_table( FT_Face face,
_hb_font_goto_table( HB_Font font,
HB_UInt tag );
/* convenience macros */
#define SET_ERR(c) ( (error = (c)) != 0 )
#define GOTO_Table(tag) SET_ERR( _hb_face_goto_table( face, tag ) )
#define GOTO_Table(tag) SET_ERR( _hb_font_goto_table( font, tag ) )
#define FILE_Pos() _hb_stream_pos( stream )
#define FILE_Seek(pos) SET_ERR( _hb_stream_seek( stream, pos ) )
#define ACCESS_Frame(size) SET_ERR( _hb_stream_frame_enter( stream, size ) )

View File

@ -145,24 +145,24 @@ _hb_stream_frame_exit( HB_Stream stream )
HB_INTERNAL HB_Error
_hb_face_goto_table( FT_Face face,
_hb_font_goto_table( HB_Font font,
HB_UInt the_tag )
{
HB_Stream stream = face->stream;
HB_Stream stream = font->stream;
HB_Error error;
LOG(( "_hb_face_goto_table( %p, %c%c%c%c, %p )\n",
face,
LOG(( "_hb_font_goto_table( %p, %c%c%c%c, %p )\n",
font,
(int)((the_tag >> 24) & 0xFF),
(int)((the_tag >> 16) & 0xFF),
(int)((the_tag >> 8) & 0xFF),
(int)(the_tag & 0xFF),
stream ));
if ( !FT_IS_SFNT(face) )
if ( !FT_IS_SFNT(font) )
{
LOG(( "not a SFNT face !!\n" ));
LOG(( "not a SFNT font !!\n" ));
error = ERR(HB_Err_Invalid_Argument);
}
else
@ -173,12 +173,12 @@ _hb_face_goto_table( FT_Face face,
HB_UInt offset = 0;
HB_UInt count, nn;
if ( face->num_faces > 1 )
if ( font->num_faces > 1 )
{
/* deal with TrueType collections */
LOG(( ">> This is a TrueType Collection\n" ));
if ( FILE_Seek( 12 + face->face_index*4 ) ||
if ( FILE_Seek( 12 + font->face_index*4 ) ||
ACCESS_Frame( 4 ) )
goto Exit;