exit (1);
}
- otf = otf_open (argv[1]);
+ otf = OTF_open (argv[1]);
if (! otf)
{
- otf_perror ("otfdraw");
+ OTF_perror ("otfdraw");
exit (1);
}
gstring.size = 10;
gstring.glyphs[gstring.used++].c = 0x947;
gstring.glyphs[gstring.used++].c = 0x915;
#endif
- otf_drive_cmap (otf, &gstring);
- otf_drive_gdef (otf, &gstring);
+ OTF_drive_cmap (otf, &gstring);
+ OTF_drive_gdef (otf, &gstring);
otf_dump_gstring (&gstring);
- if (otf_drive_gsub (otf, &gstring, "deva", NULL, NULL) < 0)
+ if (OTF_drive_gsub (otf, &gstring, "deva", NULL, NULL) < 0)
printf ("otf_gsub error\n");
else
printf ("RESULT of GSUB\n");
otf_dump_gstring (&gstring);
- if (otf_drive_gpos (otf, &gstring, "deva", NULL, NULL) < 0)
+ if (OTF_drive_gpos (otf, &gstring, "deva", NULL, NULL) < 0)
printf ("otf_gsub error\n");
else
printf ("RESULT of GPOS\n");
}
- otf_close (otf);
+ OTF_close (otf);
exit (0);
}
exit (1);
}
- otf = otf_open (argv[1]);
+ otf = OTF_open (argv[1]);
if (! otf)
{
- otf_perror ("otfdump");
+ OTF_perror ("otfdump");
exit (1);
}
- otf_get_table (otf, "head");
- otf_get_table (otf, "name");
- otf_get_table (otf, "cmap");
- otf_get_table (otf, "GDEF");
- otf_get_table (otf, "GSUB");
- otf_get_table (otf, "GPOS");
+ OTF_get_table (otf, "head");
+ OTF_get_table (otf, "name");
+ OTF_get_table (otf, "cmap");
+ OTF_get_table (otf, "GDEF");
+ OTF_get_table (otf, "GSUB");
+ OTF_get_table (otf, "GPOS");
#if 0
- otf_get_table (otf, "BASE");
- otf_get_table (otf, "JSTF");
+ OTF_get_table (otf, "BASE");
+ OTF_get_table (otf, "JSTF");
#endif
otf_dump (otf);
- otf_close (otf);
+ OTF_close (otf);
exit (0);
}
exit (1);
}
- otf = otf_open (argv[1]);
+ otf = OTF_open (argv[1]);
if (! otf)
{
- otf_perror ("otfview");
+ OTF_perror ("otfview");
exit (1);
}
update_mask = 0;
}
- otf_close (otf);
+ OTF_close (otf);
exit (0);
}
(1-9) Structure for OTF
(2) APIs for reading OTF
- (2-1) otf_open()
- (2-2) otf_close()
- (2-3) otf_get_table()
+ (2-1) OTF_open()
+ (2-2) OTF_close()
+ (2-3) OTF_get_table()
(3) APIs for driving OTF
(3-1) Structure for glyph string
- (3-2) otf_drive_cmap()
- (3-3) otf_drive_gdef()
- (3-4) otf_drive_gsub()
- (3-5) otf_drive_gpos()
- (3-6) otf_drive_tables()
+ (3-2) OTF_drive_cmap()
+ (3-3) OTF_drive_gdef()
+ (3-4) OTF_drive_gsub()
+ (3-5) OTF_drive_gpos()
+ (3-6) OTF_drive_tables()
(4) APIs for error handling
(4-1) Error codes
- (4-2) otf_perror()
+ (4-2) OTF_perror()
(5) APIs miscellaneous
/***
Open OpenType font
- The otf_open() function reads the OpenType font file whose name is
+ The OTF_open() function reads the OpenType font file whose name is
$NAME, and return a pointer to the structure of type OTF.
It setups these member of the structure OTF:
filename, offset_table, table_dirs
If the file can't be read or the file contains invalid data, NULL
- is returned, and the variable otf_error is set to one of the
+ is returned, and the variable OTF_error is set to one of the
following values.
OTF_ERROR_MEMORY
OTF_ERROR_FILE
OTF_ERROR_TABLE
- See also otf_get_table() and otf_close(). */
+ See also OTF_get_table() and OTF_close(). */
-extern OTF *otf_open (char *name);
+extern OTF *OTF_open (char *name);
-/*** (2-2) otf_close () */
+/*** (2-2) OTF_close () */
/***
Close OpenType font
- The otf_close() function closes the OpenType font pointed by $OTF
- which must be what the otf_open() returned.
+ The OTF_close() function closes the OpenType font pointed by $OTF
+ which must be what the OTF_open() returned.
- See also otf_open(). */
+ See also OTF_open(). */
-extern void otf_close (OTF *otf);
+extern void OTF_close (OTF *otf);
-/*** (2-3) otf_get_table () */
+/*** (2-3) OTF_get_table () */
/***
Get OpenType font table
- The otf_get_table() function setups one of the OTF tables
+ The OTF_get_table() function setups one of the OTF tables
specified by $NAME in the structure pointed by $OTF.
$NAME must be one of "head", "name", "cmap", "GDEF", "GSUB", and
"GPOS", and a member of the same name is setup.
If the table is successfully setup, return 0. Otherwise, return
- -1, and set the variable otf_error to OTF_ERROR_TABLE.
+ -1, and set the variable OTF_error to OTF_ERROR_TABLE.
- See also otf_open(). */
+ See also OTF_open(). */
-extern int otf_get_table (OTF *otf, char *name);
+extern int OTF_get_table (OTF *otf, char *name);
/*** (3) APIs for driving OTF */
{
/* Character code of the glyph. This is the only member that a
client has to set before calling the function
- otf_drive_XXX(). */
+ OTF_drive_XXX(). */
int c;
/* Glyph ID of the glyph. */
} OTF_GlyphString;
-/*** (3-2) otf_drive_cmap() */
+/*** (3-2) OTF_drive_cmap() */
/***
Process glyph string by cmap table.
- The otf_drive_cmap() function looks up the cmap table of OpenType
+ 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. */
-extern int otf_drive_cmap (OTF *otf, OTF_GlyphString *gstring);
+extern int OTF_drive_cmap (OTF *otf, OTF_GlyphString *gstring);
-/*** (3-3) otf_drive_gdef() */
+/*** (3-3) OTF_drive_gdef() */
/***
Process glyph string by GDEF table.
- The otf_drive_gdef() function looks up the GDEF table of OpenType
+ The OTF_drive_gdef() function looks up the GDEF table of OpenType
font $OTF, and setup members <GlyphClass> and <MarkAttachClass> of
all glhphs in the glyph string $GSTRING. */
-extern int otf_drive_gdef (OTF *otf, OTF_GlyphString *gstring);
+extern int OTF_drive_gdef (OTF *otf, OTF_GlyphString *gstring);
-/*** (3-4) otf_drive_gsub() */
+/*** (3-4) OTF_drive_gsub() */
/***
Process glyph string by GSUB table.
- The otf_drive_gsub() function looks up the GSUB table of OpenType
+ The OTF_drive_gsub() function looks up the GSUB table of OpenType
font $OTF, and by using features the font has for script $SCRIPT
and language system $LANGSYS, update member <glyphs> of the glyph
string $GSTRING. It may substitute, delete, insert glyphs in that
array. */
-extern int otf_drive_gsub (OTF *otf, OTF_GlyphString *gstring,
+extern int OTF_drive_gsub (OTF *otf, OTF_GlyphString *gstring,
char *script, char *language, char *features);
-/*** (3-5) otf_drive_gpos() */
+/*** (3-5) OTF_drive_gpos() */
/***
Process glyph string by GPOS table.
- The otf_drive_gdef() function looks up the GPOS table of $OTF of
+ The OTF_drive_gdef() function looks up the GPOS table of $OTF of
OpenType font $OTF, and by using features the font has for script
$SCRIPT and language system $LANGSYS, setup members
<positioning_type> and <f> of all glhphs in the glyph string
$GSTRING. */
-extern int otf_drive_gpos (OTF *otf, OTF_GlyphString *gstring,
+extern int OTF_drive_gpos (OTF *otf, OTF_GlyphString *gstring,
char *script, char *language, char *features);
-/*** (3-6) otf_drive_tables() */
+/*** (3-6) OTF_drive_tables() */
/***
Process glyph string by cmap, GDEF, GSUB, and GPOS tables.
- The otf_drive_tables() function calls otf_drive_cmap(),
- otf_drive_gdef(), otf_drive_gsub(), and otf_drive_gpos() in this
+ The OTF_drive_tables() function calls OTF_drive_cmap(),
+ OTF_drive_gdef(), OTF_drive_gsub(), and OTF_drive_gpos() in this
order, and update the glyphs string GSTRING. */
-extern int otf_drive_tables (OTF *otf, OTF_GlyphString *gstring,
+extern int OTF_drive_tables (OTF *otf, OTF_GlyphString *gstring,
char *script, char *language,
char *gsub_features, char *gpos_features);
/***
Global variable holding an error code.
- The variable otf_error is set to one of OTF_ERROR_XXX macros when
+ The variable OTF_error is set to one of OTF_ERROR_XXX macros when
an error is detected in the OTF library. */
-extern int otf_error;
+extern int OTF_error;
/***
Memory allocation error
/***
GDEF driving error
- See the function otf_drive_gdef() for more detail. */
+ See the function OTF_drive_gdef() for more detail. */
#define OTF_ERROR_GDEF_DRIVE 5
/***
GSUB driving error
- See the function otf_drive_gsub() for more detail. */
+ See the function OTF_drive_gsub() for more detail. */
#define OTF_ERROR_GSUB_DRIVE 6
/***
GPOS driving error
- See the function otf_drive_gpos() for more detail. */
+ See the function OTF_drive_gpos() for more detail. */
#define OTF_ERROR_GPOS_DRIVE 7
-/*** (4-2) otf_perror() */
+/*** (4-2) OTF_perror() */
/***
Print an OTF error message
- The otf_perror() function produces a message on the standard error
+ The OTF_perror() function produces a message on the standard error
output, describing the last error encountered during a call to the
OTF library function. If $PREFIX is not NULL, is is printed
first, followed by a colon and a blank. Then the message and a
newline. */
-extern void otf_perror (char *prefix);
+extern void OTF_perror (char *prefix);
/*** (5) APIs miscellaneous ***/
/***
Return OTF tag of a specified name string.
- The otf_tag() function returns OTF tag of name $NAME. If $NAME is
+ The OTF_tag() function returns OTF tag of name $NAME. If $NAME is
NULL, return 0. Otherwise, $NAME must be at least 4-byte length.
Only the first 4 characters are took into an account. */
-extern OTF_Tag otf_tag (char *name);
+extern OTF_Tag OTF_tag (char *name);
/***
Convert OTF tag to name string.
- The otf_tag_name() function converts OTF tag $TAG to a 5-byte
+ The OTF_tag_name() function converts OTF tag $TAG to a 5-byte
name string (including the terminating NUL), and store it in
$NAME. At least 5-byte space must be at $NAME. */
-extern void otf_tag_name (OTF_Tag tag, char *name);
+extern void OTF_tag_name (OTF_Tag tag, char *name);
#endif /* not _OTF_H_ */
get_langsys (OTF_ScriptList *script_list, char *script, char *language)
{
- OTF_Tag script_tag = otf_tag (script);
- OTF_Tag langsys_tag = otf_tag (language);
+ OTF_Tag script_tag = OTF_tag (script);
+ OTF_Tag langsys_tag = OTF_tag (language);
int i, j;
for (i = 0; i < script_list->ScriptCount; i++)
while (len > 0)
{
int this_len = strlen (p0) + 1;
- OTF_Tag tag = otf_tag (p0);
+ OTF_Tag tag = OTF_tag (p0);
if (tag)
{
/* APIs */
int
-otf_drive_cmap (OTF *otf, OTF_GlyphString *gstring)
+OTF_drive_cmap (OTF *otf, OTF_GlyphString *gstring)
{
OTF_cmap *cmap;
int i;
if (! otf->cmap
- && otf_get_table (otf, "cmap") < 0)
+ && OTF_get_table (otf, "cmap") < 0)
return -1;
cmap = otf->cmap;
int
-otf_drive_gdef (OTF *otf, OTF_GlyphString *gstring)
+OTF_drive_gdef (OTF *otf, OTF_GlyphString *gstring)
{
OTF_GDEF *gdef;
int i;
if (! otf->gdef
- && otf_get_table (otf, "GDEF") < 0)
+ && OTF_get_table (otf, "GDEF") < 0)
return -1;
gdef = otf->gdef;
int
-otf_drive_gsub (OTF *otf, OTF_GlyphString *gstring,
+OTF_drive_gsub (OTF *otf, OTF_GlyphString *gstring,
char *script, char *language, char *features)
{
char *errfmt = "GSUB driving%s";
int i, j;
if (! otf->gsub
- && otf_get_table (otf, "GSUB") < 0)
+ && OTF_get_table (otf, "GSUB") < 0)
return -1;
gsub = otf->gsub;
}
int
-otf_drive_gpos (OTF *otf, OTF_GlyphString *gstring,
+OTF_drive_gpos (OTF *otf, OTF_GlyphString *gstring,
char *script, char *language, char *features)
{
char *errfmt = "GPOS driving%s";
int i, j;
if (! otf->gpos
- && otf_get_table (otf, "GPOS") < 0)
+ && OTF_get_table (otf, "GPOS") < 0)
return -1;
gpos = otf->gpos;
}
int
-otf_drive_tables (OTF *otf, OTF_GlyphString *gstring,
+OTF_drive_tables (OTF *otf, OTF_GlyphString *gstring,
char *script, char *language,
char *gsub_features, char *gpos_features)
{
- if (otf_drive_cmap (otf, gstring) < 0)
+ if (OTF_drive_cmap (otf, gstring) < 0)
return -1;
- if (otf_drive_gdef (otf, gstring) < 0)
+ if (OTF_drive_gdef (otf, gstring) < 0)
return -1;
if ((! gsub_features || gsub_features[0])
- && otf_drive_gsub (otf, gstring, script, language, gsub_features) < 0)
+ && OTF_drive_gsub (otf, gstring, script, language, gsub_features) < 0)
return -1;
if ((! gpos_features || gpos_features[0])
- && otf_drive_gpos (otf, gstring, script, language, gpos_features) < 0)
+ && OTF_drive_gpos (otf, gstring, script, language, gpos_features) < 0)
return -1;
return 0;
}
#include "otf.h"
static char *error_message;
-int otf_error;
+int OTF_error;
static char *error_string[] =
{
error_message = (char *) malloc (256);
sprintf (error_message, "OTF-Error (%s): ", error_string[err]);
sprintf (error_message + strlen (error_message), fmt, arg);
- otf_error = err;
+ OTF_error = err;
return 0;
}
void
-otf_perror (char *prefix)
+OTF_perror (char *prefix)
{
- if (otf_error == 0)
+ if (OTF_error == 0)
error_message = error_string[0];
if (prefix)
fprintf (stderr, "%s: %s\n", prefix, error_message);
internal_data->table_info[OTF_TABLE_TYPE_GPOS].address = (void *) &otf->gpos;
internal_data->table_info[OTF_TABLE_TYPE_GPOS].reader = read_gpos_table;
- head_tag = otf_tag ("head");
- name_tag = otf_tag ("name");
- cmap_tag = otf_tag ("cmap");
- gdef_tag = otf_tag ("GDEF");
- gsub_tag = otf_tag ("GSUB");
- gpos_tag = otf_tag ("GPOS");
+ head_tag = OTF_tag ("head");
+ name_tag = OTF_tag ("name");
+ cmap_tag = OTF_tag ("cmap");
+ gdef_tag = OTF_tag ("GDEF");
+ gsub_tag = OTF_tag ("GSUB");
+ gpos_tag = OTF_tag ("GPOS");
stream = make_stream ();
if (! stream)
/* APIs */
OTF_Tag
-otf_tag (char *name)
+OTF_tag (char *name)
{
unsigned char *p = (unsigned char *) name;
}
void
-otf_tag_name (OTF_Tag tag, char *name)
+OTF_tag_name (OTF_Tag tag, char *name)
{
name[0] = (char) (tag >> 24);
name[1] = (char) ((tag >> 16) & 0xFF);
memory previously allocated. */
OTF *
-otf_open (char *otf_name)
+OTF_open (char *otf_name)
{
FILE *fp;
char *errfmt = "opening otf (%s)";
otf->filename = strdup (otf_name);
if (! otf->filename)
{
- otf_close (otf);
+ OTF_close (otf);
fclose (fp);
OTF_ERROR (OTF_ERROR_MEMORY, "filename allocation");
}
if (read_header_part (otf, fp) < 0)
{
- otf_close (otf);
+ OTF_close (otf);
fclose (fp);
return NULL;
}
void
-otf_close (OTF *otf)
+OTF_close (OTF *otf)
{
OTF_InternalData *internal_data = otf->internal_data;
int i;
int
-otf_get_table (OTF *otf, char *name)
+OTF_get_table (OTF *otf, char *name)
{
char *errfmt = "OTF Table Read";
int errret = -1;
OTF_InternalData *internal_data = otf->internal_data;
OTF_TableInfo *table_info;
- OTF_Tag tag = otf_tag (name);
+ OTF_Tag tag = OTF_tag (name);
if (! tag)
OTF_ERROR (OTF_ERROR_TABLE, " (unknown)");
- if (tag == otf_tag ("head"))
+ if (tag == OTF_tag ("head"))
table_info = internal_data->table_info + OTF_TABLE_TYPE_HEAD;
- else if (tag == otf_tag ("name"))
+ else if (tag == OTF_tag ("name"))
table_info = internal_data->table_info + OTF_TABLE_TYPE_NAME;
- else if (tag == otf_tag ("cmap"))
+ else if (tag == OTF_tag ("cmap"))
table_info = internal_data->table_info + OTF_TABLE_TYPE_CMAP;
- else if (tag == otf_tag ("GDEF"))
+ else if (tag == OTF_tag ("GDEF"))
table_info = internal_data->table_info + OTF_TABLE_TYPE_GDEF;
- else if (tag == otf_tag ("GSUB"))
+ else if (tag == OTF_tag ("GSUB"))
table_info = internal_data->table_info + OTF_TABLE_TYPE_GSUB;
- else if (tag == otf_tag ("GPOS"))
+ else if (tag == OTF_tag ("GPOS"))
table_info = internal_data->table_info + OTF_TABLE_TYPE_GPOS;
else
OTF_ERROR (OTF_ERROR_TABLE, " (unsupported)");