-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)
#####################################################################
# 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?
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.
#include <otf.h>
+/* 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)
{
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++)
#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:
/*** (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 <glyhph_id> 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 <glyhph_id> 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 <glyhph_id> 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() */
/***
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;
+}
+
\f
/* API */
}
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