From a2e98c266eec50dfa04991c86d365015530b2635 Mon Sep 17 00:00:00 2001 From: handa Date: Wed, 5 May 2004 23:32:48 +0000 Subject: [PATCH] *** empty log message *** --- README | 4 +- configure.ac | 4 +- example/otflist.c | 37 ++++++++++++++++-- src/otf.h | 32 ++++++++++++--- src/otfdrive.c | 113 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 177 insertions(+), 13 deletions(-) diff --git a/README b/README index 98b0dda..a730ee5 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -This directory tree holds version 0.9 of the otf library. -*- text -*- +This directory tree holds version 0.9.1 of the otf library. -*- text -*- Copyright (C) 2003, 2004 National Institute of Advanced Industrial Science and Technology (AIST) @@ -9,7 +9,7 @@ See the end for copying conditions. ##################################################################### # libotf -- A Library for handling OpenType Font (OTF) # # # -# Ver.0.9 (2004.2.1) # +# Ver.0.9.1 (2004.5.1) # ##################################################################### (1) What is libotf? diff --git a/configure.ac b/configure.ac index ceca494..45c0d7b 100644 --- a/configure.ac +++ b/configure.ac @@ -23,8 +23,8 @@ dnl License along with this library, in a file named COPYING; if not, dnl write to the Free Software Foundation, Inc., 59 Temple Place, Suite dnl 330, Boston, MA 02111-1307, USA. -AC_INIT(libotf, 0.9, handa@m17n.org) -AM_INIT_AUTOMAKE(libotf, 0.9) +AC_INIT(libotf, 0.9.1, handa@m17n.org) +AM_INIT_AUTOMAKE(libotf, 0.9.1) AM_CONFIG_HEADER(src/config.h) # Checks for programs. diff --git a/example/otflist.c b/example/otflist.c index 85ff998..e21dec5 100644 --- a/example/otflist.c +++ b/example/otflist.c @@ -31,6 +31,26 @@ write to the Free Software Foundation, Inc., 59 Temple Place, Suite #include +/* Format MSG by FMT and print the result to the stderr, and exit. */ + +#define FATAL_ERROR(fmt, arg) \ + do { \ + fprintf (stderr, fmt, arg); \ + exit (1); \ + } while (0) + +void +help_and_exit (char *prog) +{ + printf ("otflist %s\n", LIBOTF_VERSION); + printf ("Usage: %s [-l] [-h] [DIR]\n", prog); + printf ("List information about OpenType font files in the directory DIR.\n"); + printf ("It actually lists all fonts that can be handled by Freetype.\n"); + printf (" -h print this help, then exit\n"); + printf (" -l use a long listing mode\n"); + exit (0); +} + int filter (const struct dirent *direntry) { @@ -51,17 +71,28 @@ filter (const struct dirent *direntry) int main (int argc, char **argv) { + FT_Library ft_library; + FT_Face face; + int long_format = 0; struct dirent **namelist; int n; int i, j; - FT_Library ft_library; - FT_Face face; if (FT_Init_FreeType (&ft_library)) exit (1); + if (argc > 1) + { + if (! strcmp (argv[1], "-h") || ! strcmp (argv[1], "--help")) + help_and_exit (argv[0]); + if (! strcmp (argv[1], "-l")) + long_format = 1, argc--, argv++; + } if (argc == 2) - chdir (argv[1]); + { + if (chdir (argv[1]) < 0) + FATAL_ERROR ("Can't change directory to %s\n", argv[1]); + } n = scandir (".", &namelist, filter, alphasort); for (i = 0; i < n; i++) diff --git a/src/otf.h b/src/otf.h index 6991ce7..7e2e238 100644 --- a/src/otf.h +++ b/src/otf.h @@ -24,8 +24,15 @@ write to the Free Software Foundation, Inc., 59 Temple Place, Suite #ifndef _OTF_H_ #define _OTF_H_ -/* Version number of this library. */ -#define LIBOTF_VERSION "0.9" +/* Version name of this library. */ +#define LIBOTF_VERSION "0.9.1" + +/* Major version number. */ +#define LIBOTF_MAJOR_VERSION 0 +/* Minor version number. */ +#define LIBOTF_MINOR_VERSION 9 +/* Release (i.e. patch level) number. */ +#define LIBOTF_RELEASE_NUMBER 1 /*** Table of contents: @@ -1183,14 +1190,27 @@ typedef struct /*** (3-2) OTF_drive_cmap() */ /*** - Process glyph string by cmap table. + Process glyph string by Unicode-based cmap table. - The OTF_drive_cmap() function looks up the cmap table of OpenType - font $OTF, and setup the member of all glhphs in the - glyph string $GSTRING if the value of the member is not zero. */ + The OTF_drive_cmap() function looks up a Unicode-based cmap table + of OpenType font $OTF, and setup the member of all + glhphs in the glyph string $GSTRING if the value of the member is + not zero. */ extern int OTF_drive_cmap (OTF *otf, OTF_GlyphString *gstring); +/*** + Process glyph string by a specific cmap table. + + The OTF_drive_cmap2() function looks up a cmap table (whose + Platform-ID is $PLATFORM_ID an Encoding-ID is $ENCODING_ID) of + OpenType font $OTF, and setup the member of all glhphs + in the glyph string $GSTRING if the value of the member is not + zero. */ + +extern int OTF_drive_cmap2 (OTF *otf, OTF_GlyphString *gstring, + int platform_id, int encoding_id); + /*** (3-3) OTF_drive_gdef() */ /*** diff --git a/src/otfdrive.c b/src/otfdrive.c index b28fe3d..5e5d612 100644 --- a/src/otfdrive.c +++ b/src/otfdrive.c @@ -927,6 +927,83 @@ lookup_gpos (OTF_LookupList *lookup_list, unsigned lookup_list_index, return gidx; } +static int +lookup_encoding_0 (OTF_EncodingSubtable0 *sub0, OTF_GlyphString *gstring) +{ + int i, c; + + for (i = 0; i < gstring->used; i++) + { + c = gstring->glyphs[i].c; + if (c < 0 || c >= 256) + gstring->glyphs[i].glyph_id = 0; + else + gstring->glyphs[i].glyph_id = sub0->glyphIdArray[c]; + } + return 0; +} + +static int +lookup_encoding_2 (OTF_EncodingSubtable2 *sub2, OTF_GlyphString *gstring) +{ + return 0; +} + +static int +lookup_encoding_4 (OTF_EncodingSubtable4 *sub4, OTF_GlyphString *gstring) +{ + int i, j, c; + int segCount = sub4->segCountX2 / 2; + + for (i = 0; i < gstring->used; i++) + { + c = gstring->glyphs[i].c; + if (c < 0) + gstring->glyphs[i].glyph_id = 0; + for (j = 0; j < segCount; j++) + { + OTF_cmapSegument *seg = sub4->segments + i; + + if (c >= seg->startCount && c <= seg->endCount) + { + if (seg->idRangeOffset == 0xFFFF) + gstring->glyphs[i].glyph_id = c + seg->idDelta; + else + gstring->glyphs[i].glyph_id + = sub4->glyphIdArray[seg->idRangeOffset + + (c - seg->startCount)]; + break; + } + } + } + + return 0; +} + +static int +lookup_encoding_6 (OTF_EncodingSubtable6 *sub6, OTF_GlyphString *gstring) +{ + return 0; +} + +static int +lookup_encoding_8 (OTF_EncodingSubtable8 *sub8, OTF_GlyphString *gstring) +{ + return 0; +} + +static int +lookup_encoding_10 (OTF_EncodingSubtable10 *sub10, OTF_GlyphString *gstring) +{ + return 0; +} + +static int +lookup_encoding_12 (OTF_EncodingSubtable12 *sub12, OTF_GlyphString *gstring) +{ + return 0; +} + /* API */ @@ -955,6 +1032,42 @@ OTF_drive_cmap (OTF *otf, OTF_GlyphString *gstring) } int +OTF_drive_cmap2 (OTF *otf, OTF_GlyphString *gstring, + int platform_id, int encoding_id) +{ + OTF_cmap *cmap; + int i; + char *errfmt = "CMAP Looking up%s"; + int errret = -1; + OTF_EncodingRecord *enc; + + if (! otf->cmap + && OTF_get_table (otf, "cmap") < 0) + return -1; + + cmap = otf->cmap; + for (i = 0; i < cmap->numTables; i++) + if (cmap->EncodingRecord[i].platformID == platform_id + && cmap->EncodingRecord[i].encodingID == encoding_id) + break; + if (i == cmap->numTables) + OTF_ERROR (OTF_ERROR_CMAP_DRIVE, " (unknown platformID/encodingID)"); + enc = cmap->EncodingRecord + i; + switch (enc->subtable.format) + { + case 0: return lookup_encoding_0 (enc->subtable.f.f0, gstring); + case 2: return lookup_encoding_2 (enc->subtable.f.f2, gstring); + case 4: return lookup_encoding_4 (enc->subtable.f.f4, gstring); + case 6: return lookup_encoding_6 (enc->subtable.f.f6, gstring); + case 8: return lookup_encoding_8 (enc->subtable.f.f8, gstring); + case 10: return lookup_encoding_10 (enc->subtable.f.f10, gstring); + case 12: return lookup_encoding_12 (enc->subtable.f.f12, gstring); + } + OTF_ERROR (OTF_ERROR_CMAP_DRIVE, " (invalid format)"); +} + + +int OTF_get_unicode (OTF *otf, OTF_GlyphID code) { if (! otf->cmap -- 1.7.10.4