diff options
author | Jonathan Kew <jfkthame@googlemail.com> | 2008-05-21 13:19:17 +0000 |
---|---|---|
committer | Jonathan Kew <jfkthame@googlemail.com> | 2008-05-21 13:19:17 +0000 |
commit | ebdcfba2fc6c9bf4db2008a00058f3422a9d1da8 (patch) | |
tree | 52772b6cbe81d9ca8b67d3990ea033a27d432916 /Build/source/texk/xdvipdfmx/src/sfnt.c | |
parent | 246e3a9180a28cb419402687d2005bdfb5313774 (diff) |
update to xdvipdfmx 0.7, from xetex svn r.688
git-svn-id: svn://tug.org/texlive/trunk@8272 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/xdvipdfmx/src/sfnt.c')
-rw-r--r-- | Build/source/texk/xdvipdfmx/src/sfnt.c | 68 |
1 files changed, 63 insertions, 5 deletions
diff --git a/Build/source/texk/xdvipdfmx/src/sfnt.c b/Build/source/texk/xdvipdfmx/src/sfnt.c index daef0193c9e..0c2195ee679 100644 --- a/Build/source/texk/xdvipdfmx/src/sfnt.c +++ b/Build/source/texk/xdvipdfmx/src/sfnt.c @@ -1,4 +1,4 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/sfnt.c,v 1.12 2004/09/11 14:50:29 hirata Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/sfnt.c,v 1.13 2008/05/08 18:51:59 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. @@ -135,8 +135,9 @@ sfnt_open (FT_Face face, int accept_types) sfont = NEW(1, sfnt); sfont->ft_face = face; - sfont->loc = 0; sfont->type = 0; + sfont->loc = 0; + sfont->offset = 0; type = sfnt_get_ulong(sfont); @@ -155,8 +156,6 @@ sfnt_open (FT_Face face, int accept_types) return NULL; } - sfont->loc = 0; - sfont->directory = NULL; return sfont; @@ -191,6 +190,64 @@ sfnt_open (FILE *fp) rewind(sfont->stream); sfont->directory = NULL; + sfont->offset = 0UL; + + return sfont; +} + +sfnt * +dfont_open (FILE *fp, int index) +{ + sfnt *sfont; + ULONG rdata_pos, map_pos, tags_pos, types_pos, res_pos, tag, type; + USHORT tags_num, types_num, i; + + ASSERT(fp); + + rewind(fp); + + sfont = NEW(1, sfnt); + + sfont->stream = fp; + + rdata_pos = sfnt_get_ulong(sfont); + map_pos = sfnt_get_ulong(sfont); + sfnt_seek_set(sfont, map_pos + 0x18); + tags_pos = map_pos + sfnt_get_ushort(sfont); + sfnt_seek_set(sfont, tags_pos); + tags_num = sfnt_get_ushort(sfont); + + for (i = 0; i <= tags_num; i++) { + tag = sfnt_get_ulong(sfont); /* tag name */ + types_num = sfnt_get_ushort(sfont); /* typefaces number */ + types_pos = tags_pos + sfnt_get_ushort(sfont); /* typefaces position */ + if (tag == 0x73666e74UL) /* "sfnt" */ + break; + } + + if (i > tags_num) { + RELEASE(sfont); + return NULL; + } + + sfnt_seek_set(sfont, types_pos); + if (index > types_num) { + ERROR("Invalid index %d for dfont.", index); + } + + for (i = 0; i <= types_num; i++) { + sfnt_get_ushort(sfont); /* resource id */ + sfnt_get_ushort(sfont); /* resource name position from name_list */ + res_pos = sfnt_get_ulong(sfont); /* resource flag (byte) + resource offset */ + sfnt_get_ulong(sfont); /* mbz */ + if (i == index) break; + } + + rewind(sfont->stream); + + sfont->type = SFNT_TYPE_DFONT; + sfont->directory = NULL; + sfont->offset = (res_pos & 0x00ffffffUL) + rdata_pos + 4; return sfont; } @@ -443,9 +500,10 @@ sfnt_read_table_directory (sfnt *sfont, ULONG offset) convert_tag(td->tables[i].tag, u_tag); td->tables[i].check_sum = sfnt_get_ulong(sfont); - td->tables[i].offset = sfnt_get_ulong(sfont); + td->tables[i].offset = sfnt_get_ulong(sfont) + sfont->offset; td->tables[i].length = sfnt_get_ulong(sfont); td->tables[i].data = NULL; +//fprintf(stderr, "[%4s:%x]", td->tables[i].tag, td->tables[i].offset); td->flags[i] = 0; } |