diff options
Diffstat (limited to 'Build/source/texk/xdvipdfmx/src/tt_table.c')
-rw-r--r-- | Build/source/texk/xdvipdfmx/src/tt_table.c | 92 |
1 files changed, 57 insertions, 35 deletions
diff --git a/Build/source/texk/xdvipdfmx/src/tt_table.c b/Build/source/texk/xdvipdfmx/src/tt_table.c index e76f0554d3f..a7d1cb13063 100644 --- a/Build/source/texk/xdvipdfmx/src/tt_table.c +++ b/Build/source/texk/xdvipdfmx/src/tt_table.c @@ -1,4 +1,4 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/tt_table.c,v 1.7 2004/09/11 14:50:29 hirata Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/tt_table.c,v 1.8 2007/02/14 05:56:43 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. @@ -33,7 +33,7 @@ /* tables contains information refered by other tables maxp->numGlyphs, etc --> loca, etc - hhea->numberOfHMetrics --> hmtx + hhea->numOfLongHorMetrics --> hmtx head->indexToLocFormat --> loca head->glyphDataFormat --> glyf */ @@ -163,20 +163,21 @@ char *tt_pack_hhea_table (struct tt_hhea_table *table) p = data = NEW(TT_HHEA_TABLE_SIZE, char); p += sfnt_put_ulong(p, table->version); - p += sfnt_put_short(p, table->Ascender); - p += sfnt_put_short(p, table->Descender); - p += sfnt_put_short(p, table->LineGap); + p += sfnt_put_short(p, table->ascent); + p += sfnt_put_short(p, table->descent); + p += sfnt_put_short(p, table->lineGap); p += sfnt_put_ushort(p, table->advanceWidthMax); p += sfnt_put_short(p, table->minLeftSideBearing); p += sfnt_put_short(p, table->minRightSideBearing); p += sfnt_put_short(p, table->xMaxExtent); p += sfnt_put_short(p, table->caretSlopeRise); p += sfnt_put_short(p, table->caretSlopeRun); - for (i = 0; i < 5; i++) { + p += sfnt_put_short(p, table->caretOffset); + for (i = 0; i < 4; i++) { p += sfnt_put_short(p, table->reserved[i]); } p += sfnt_put_short(p, table->metricDataFormat); - p += sfnt_put_ushort(p, table->numberOfHMetrics); + p += sfnt_put_ushort(p, table->numOfLongHorMetrics); return data; } @@ -185,28 +186,32 @@ struct tt_hhea_table * tt_read_hhea_table (sfnt *sfont) { int i; + ULONG len; struct tt_hhea_table *table = NULL; - table = NEW(1, struct tt_hhea_table); - + len = sfnt_find_table_len(sfont, "hhea"); sfnt_locate_table(sfont, "hhea"); - table->version = sfnt_get_ulong(sfont); - table->Ascender = sfnt_get_short (sfont); - table->Descender = sfnt_get_short(sfont); - table->LineGap = sfnt_get_short(sfont); + + table = NEW(1, struct tt_hhea_table); + table->version = sfnt_get_ulong(sfont); + table->ascent = sfnt_get_short (sfont); + table->descent = sfnt_get_short(sfont); + table->lineGap = sfnt_get_short(sfont); table->advanceWidthMax = sfnt_get_ushort(sfont); table->minLeftSideBearing = sfnt_get_short(sfont); table->minRightSideBearing = sfnt_get_short(sfont); table->xMaxExtent = sfnt_get_short(sfont); table->caretSlopeRise = sfnt_get_short(sfont); table->caretSlopeRun = sfnt_get_short(sfont); - for(i = 0; i < 5; i++) { + table->caretOffset = sfnt_get_short(sfont); + for(i = 0; i < 4; i++) { table->reserved[i] = sfnt_get_short(sfont); } table->metricDataFormat = sfnt_get_short(sfont); if (table->metricDataFormat != 0) - ERROR("unknown metricDaraFormat"); - table->numberOfHMetrics = sfnt_get_ushort(sfont); + ERROR("unknown metricDataFormat"); + table->numOfLongHorMetrics = sfnt_get_ushort(sfont); + table->numOfExSideBearings = (USHORT)((len - table->numOfLongHorMetrics * 4) / 2); return table; } @@ -230,9 +235,10 @@ tt_pack_vhea_table (struct tt_vhea_table *table) p += sfnt_put_short(p, table->caretSlopeRise); p += sfnt_put_short(p, table->caretSlopeRun); p += sfnt_put_short(p, table->caretOffset); - for(i = 0; i < 5; i++) { + for(i = 0; i < 4; i++) { p += sfnt_put_short(p, table->reserved[i]); } + p += sfnt_put_short(p, table->metricDataFormat); p += sfnt_put_ushort(p, table->numOfLongVerMetrics); return data; @@ -240,11 +246,13 @@ tt_pack_vhea_table (struct tt_vhea_table *table) struct tt_vhea_table *tt_read_vhea_table (sfnt *sfont) { - int i; + int i; + ULONG len; struct tt_vhea_table *table = NULL; table = NEW(1, struct tt_vhea_table); + len = sfnt_find_table_len(sfont, "vhea"); sfnt_locate_table(sfont, "vhea"); table->version = sfnt_get_ulong(sfont); table->vertTypoAscender = sfnt_get_short (sfont); @@ -257,10 +265,12 @@ struct tt_vhea_table *tt_read_vhea_table (sfnt *sfont) table->caretSlopeRise = sfnt_get_short(sfont); table->caretSlopeRun = sfnt_get_short(sfont); table->caretOffset = sfnt_get_short(sfont); - for(i=0;i<5;i++) { + for(i = 0; i < 4; i++) { (table->reserved)[i] = sfnt_get_short(sfont); } + table->metricDataFormat = sfnt_get_short(sfont); table->numOfLongVerMetrics = sfnt_get_ushort(sfont); + table->numOfExSideBearings = (USHORT)((len - table->numOfLongVerMetrics * 4) / 2); return table; } @@ -310,17 +320,20 @@ tt_read_VORG_table (sfnt *sfont) */ struct tt_longMetrics * -tt_read_longMetrics (sfnt *sfont, USHORT numGlyphs, USHORT numLongMetrics) +tt_read_longMetrics (sfnt *sfont, USHORT numGlyphs, USHORT numLongMetrics, USHORT numExSideBearings) { struct tt_longMetrics *m; USHORT gid, last_adv = 0; + SHORT last_esb = 0; m = NEW(numGlyphs, struct tt_longMetrics); for (gid = 0; gid < numGlyphs; gid++) { if (gid < numLongMetrics) last_adv = sfnt_get_ushort(sfont); - m[gid].sideBearing = sfnt_get_short(sfont); + if (gid < numLongMetrics + numExSideBearings) + last_esb = sfnt_get_short(sfont); m[gid].advance = last_adv; + m[gid].sideBearing = last_esb; } return m; @@ -370,21 +383,30 @@ tt_read_os2__table (sfnt *sfont) table->fsSelection = sfnt_get_ushort(sfont); table->usFirstCharIndex = sfnt_get_ushort(sfont); table->usLastCharIndex = sfnt_get_ushort(sfont); - table->sTypoAscender = sfnt_get_short(sfont); - table->sTypoDescender = sfnt_get_short(sfont); - table->sTypoLineGap = sfnt_get_short(sfont); - table->usWinAscent = sfnt_get_ushort(sfont); - table->usWinDescent = sfnt_get_ushort(sfont); - table->ulCodePageRange1 = sfnt_get_ulong(sfont); - table->ulCodePageRange2 = sfnt_get_ulong(sfont); - if (table->version == 0x0002) { - table->sxHeight = sfnt_get_short(sfont); - table->sCapHeight = sfnt_get_short(sfont); - table->usDefaultChar = sfnt_get_ushort(sfont); - table->usBreakChar = sfnt_get_ushort(sfont); - table->usMaxContext = sfnt_get_ushort(sfont); + if (sfnt_find_table_len(sfont, "OS/2") >= 78) { + /* these fields are not present in the original Apple spec (68-byte table), + but Microsoft's version of "format 0" does include them... grr! */ + table->sTypoAscender = sfnt_get_short(sfont); + table->sTypoDescender = sfnt_get_short(sfont); + table->sTypoLineGap = sfnt_get_short(sfont); + table->usWinAscent = sfnt_get_ushort(sfont); + table->usWinDescent = sfnt_get_ushort(sfont); + if (table->version > 0) { + /* format 1 adds the following 2 fields */ + table->ulCodePageRange1 = sfnt_get_ulong(sfont); + table->ulCodePageRange2 = sfnt_get_ulong(sfont); + if (table->version > 1) { + /* and formats 2 and 3 (current) include 5 more.... these share the + same fields, only the precise definition of some was changed */ + table->sxHeight = sfnt_get_short(sfont); + table->sCapHeight = sfnt_get_short(sfont); + table->usDefaultChar = sfnt_get_ushort(sfont); + table->usBreakChar = sfnt_get_ushort(sfont); + table->usMaxContext = sfnt_get_ushort(sfont); + } + } } - + return table; } |