w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

otfopen.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <config.h>
#include "otf.h"
#include "internal.h"
#include <FT_TRUETYPE_TABLES_H>
Include dependency graph for otfopen.c:

Go to the source code of this file.

Classes

struct  OTF_Stream
 
struct  OTF_MemoryRecord
 
struct  _OTF_TableInfo
 
struct  _OTF_ApplicationData
 
struct  OTF_InternalData
 

Macros

#define SAVE_STREAM(stream, state)   ((state) = (stream)->pos)
 
#define RESTORE_STREAM(stream, state)   ((stream)->pos = (state))
 
#define SEEK_STREAM(stream, offset)   ((stream)->pos = (offset))
 
#define STREAM_CHECK_SIZE(stream, size)
 
#define READ_USHORT(stream, var)
 
#define READ_SHORT(stream, var)
 
#define READ_UINT24(stream, var)
 
#define READ_ULONG(stream, var)
 
#define READ_LONG(stream, var)
 
#define READ_FIXED(stream, fixed)
 
#define READ_BYTES(stream, p, nbytes)
 
#define READ_TAG   READ_ULONG
 
#define READ_OFFSET   READ_USHORT
 
#define READ_UINT16   READ_USHORT
 
#define READ_INT16   READ_SHORT
 
#define READ_GLYPHID   READ_USHORT
 
#define OTF_MEMORY_RECORD_SIZE   1024
 
#define OTF_MALLOC(p, size, arg)
 
#define OTF_CALLOC(p, size, arg)
 

Typedefs

typedef long OTF_StreamState
 
typedef struct OTF_MemoryRecord OTF_MemoryRecord
 
typedef struct _OTF_TableInfo OTF_TableInfo
 
typedef struct _OTF_ApplicationData OTF_ApplicationData
 

Enumerations

enum  OTF_TableType {
  OTF_TABLE_TYPE_HEAD , OTF_TABLE_TYPE_NAME , OTF_TABLE_TYPE_CMAP , OTF_TABLE_TYPE_GDEF ,
  OTF_TABLE_TYPE_GSUB , OTF_TABLE_TYPE_GPOS , OTF_TABLE_TYPE_MAX
}
 
enum  OTF_ReaderFlag { OTF_READ_FULL , OTF_READ_SCRIPTS , OTF_READ_FEATURES , OTF_READ_MAX }
 

Functions

static void set_debug_flag ()
 
static OTF_Streammake_stream (const char *name)
 
static int setup_stream (OTF_Stream *stream, FILE *fp, long offset, int nbytes)
 
static OTF_Streammake_stream_from_ft_face (FT_Face face, const char *name)
 
static void free_stream (OTF_Stream *stream)
 
static OTF_MemoryRecordallocate_memory_record (OTF *otf)
 
static voidread_head_table (OTF *otf, OTF_TableInfo *table, enum OTF_ReaderFlag flag)
 
static int read_name (OTF *otf, OTF_Stream *stream, OTF_NameRecord *rec)
 
static voidread_name_table (OTF *otf, OTF_TableInfo *table, enum OTF_ReaderFlag flag)
 
static OTF_EncodingSubtable14read_cmap_uvs_table (OTF *otf, OTF_Stream *stream, OTF_Offset offset)
 
static voidread_cmap_table (OTF *otf, OTF_TableInfo *table, enum OTF_ReaderFlag flag)
 
static int read_glyph_ids (OTF *otf, OTF_Stream *stream, OTF_GlyphID **ids, int minus, int count)
 
static unsigned read_range_records (OTF *otf, OTF_Stream *stream, OTF_RangeRecord **record)
 
static int read_coverage (OTF *otf, OTF_Stream *stream, long offset, OTF_Coverage *coverage)
 
static int read_coverage_list (OTF *otf, OTF_Stream *stream, long offset, OTF_Coverage **coverage, int count)
 
static int read_class_def_without_offset (OTF *otf, OTF_Stream *stream, OTF_ClassDef *class)
 
static int read_class_def (OTF *otf, OTF_Stream *stream, long offset, OTF_ClassDef *class)
 
static int read_device_table (OTF *otf, OTF_Stream *stream, long offset, OTF_DeviceTable *table)
 
static int read_attach_list (OTF *otf, OTF_Stream *stream, long offset, OTF_AttachList *list)
 
static int read_caret_value (OTF *otf, OTF_Stream *stream, long offset, OTF_CaretValue *caret)
 
static int read_lig_caret_list (OTF *otf, OTF_Stream *stream, long offset, OTF_LigCaretList *list)
 
static int read_gdef_header (OTF_Stream *stream, OTF_GDEFHeader *header)
 
static voidread_gdef_table (OTF *otf, OTF_TableInfo *table, enum OTF_ReaderFlag flag)
 
static int read_script_list (OTF *otf, OTF_Stream *stream, long offset, OTF_ScriptList *list)
 
static int read_feature_list (OTF *otf, OTF_Stream *stream, long offset, OTF_FeatureList *list)
 
static int read_lookup_subtable_gsub (OTF *otf, OTF_Stream *stream, long offset, unsigned type, OTF_LookupSubTableGSUB *subtable)
 
static int read_lookup_subtable_gpos (OTF *otf, OTF_Stream *stream, long offset, unsigned type, OTF_LookupSubTableGPOS *subtable)
 
static int read_lookup_list (OTF *otf, OTF_Stream *stream, long offset, OTF_LookupList *list, int gsubp)
 
static int read_lookup_record_list (OTF *otf, OTF_Stream *stream, OTF_LookupRecord **record, int count)
 
static unsigned read_rule_list (OTF *otf, OTF_Stream *stream, long offset, OTF_Rule **rule)
 
static unsigned read_rule_set_list (OTF *otf, OTF_Stream *stream, long offset, OTF_RuleSet **set)
 
static unsigned read_class_rule_list (OTF *otf, OTF_Stream *stream, long offset, OTF_ClassRule **rule)
 
static unsigned read_class_set_list (OTF *otf, OTF_Stream *stream, long offset, OTF_ClassSet **set)
 
static unsigned read_chain_rule_list (OTF *otf, OTF_Stream *stream, long offset, OTF_ChainRule **rule)
 
static unsigned read_chain_rule_set_list (OTF *otf, OTF_Stream *stream, long offset, OTF_ChainRuleSet **set)
 
static unsigned read_chain_class_rule_list (OTF *otf, OTF_Stream *stream, long offset, OTF_ChainClassRule **rule)
 
static unsigned read_chain_class_set_list (OTF *otf, OTF_Stream *stream, long offset, OTF_ChainClassSet **set)
 
static int read_context1 (OTF *otf, OTF_Stream *stream, long offset, OTF_Coverage *coverage, OTF_Context1 *context1)
 
static int read_context2 (OTF *otf, OTF_Stream *stream, long offset, OTF_Coverage *coverage, OTF_Context2 *context2)
 
static int read_context3 (OTF *otf, OTF_Stream *stream, long offset, OTF_Coverage *coverage, OTF_Context3 *context3)
 
static int read_chain_context1 (OTF *otf, OTF_Stream *stream, long offset, OTF_Coverage *coverage, OTF_ChainContext1 *chain_context1)
 
static int read_chain_context2 (OTF *otf, OTF_Stream *stream, long offset, OTF_Coverage *coverage, OTF_ChainContext2 *chain_context2)
 
static int read_chain_context3 (OTF *otf, OTF_Stream *stream, long offset, OTF_Coverage *coverage, OTF_ChainContext3 *chain_context3)
 
static voidread_gsub_gpos_table (OTF *otf, OTF_TableInfo *table, int gsubp, enum OTF_ReaderFlag flag)
 
static unsigned read_sequence (OTF *otf, OTF_Stream *stream, long offset, OTF_Sequence **seq)
 
static int read_ligature (OTF *otf, OTF_Stream *stream, long offset, OTF_Ligature **ligature)
 
static unsigned read_ligature_set_list (OTF *otf, OTF_Stream *stream, long offset, OTF_LigatureSet **ligset)
 
static unsigned read_alternate_set_list (OTF *otf, OTF_Stream *stream, long offset, OTF_AlternateSet **altset)
 
static int read_reverse_chain1 (OTF *otf, OTF_Stream *stream, long offset, OTF_Coverage *coverage, OTF_GSUB_ReverseChain1 *reverse_chain)
 
static voidread_gsub_table (OTF *otf, OTF_TableInfo *table, enum OTF_ReaderFlag flag)
 
static int read_value_record (OTF *otf, OTF_Stream *stream, long offset, enum OTF_ValueFormat bit, OTF_ValueRecord *value_record)
 
static int read_anchor (OTF *otf, OTF_Stream *stream, long offset, OTF_Anchor *anchor)
 
static int read_mark_array (OTF *otf, OTF_Stream *stream, long offset, OTF_MarkArray *array)
 
static int read_anchor_array (OTF *otf, OTF_Stream *stream, long offset, unsigned ClassCount, OTF_AnchorArray *array)
 
static OTF_PairSetread_pair_set_list (OTF *otf, OTF_Stream *stream, long offset, unsigned num, enum OTF_ValueFormat bit1, enum OTF_ValueFormat bit2)
 
static OTF_Class1Recordread_class1_record_list (OTF *otf, OTF_Stream *stream, long offset, unsigned num1, enum OTF_ValueFormat bit1, unsigned num2, enum OTF_ValueFormat bit2)
 
static unsigned read_entry_exit_list (OTF *otf, OTF_Stream *stream, long offset, OTF_EntryExitRecord **rec)
 
static int read_ligature_attach (OTF *otf, OTF_Stream *stream, long offset, unsigned ClassCount, OTF_LigatureAttach *attach)
 
static int read_ligature_array (OTF *otf, OTF_Stream *stream, long offset, unsigned class_count, OTF_LigatureArray *array)
 
static voidread_gpos_table (OTF *otf, OTF_TableInfo *table, enum OTF_ReaderFlag flag)
 
static int read_offset_table (OTF *otf, OTF_Stream *stream, OTF_OffsetTable *table)
 
static OTF_Tag read_table_directory (OTF_Stream *stream, OTF_TableDirectory *table)
 
static int read_header_part (OTF *otf, FILE *fp, FT_Face face)
 
static OTF_TableInfoget_table_info (OTF *otf, const char *name)
 
OTFOTF_open (const char *otf_name)
 
OTFOTF_open_ft_face (FT_Face face)
 
void OTF_close (OTF *otf)
 
int OTF_get_table (OTF *otf, const char *name)
 
int OTF_check_table (OTF *otf, const char *name)
 
int OTF_get_scripts (OTF *otf, int gsubp)
 
int OTF_get_features (OTF *otf, int gsubp)
 
int OTF_check_features (OTF *otf, int gsubp, OTF_Tag script, OTF_Tag language, const OTF_Tag *features, int n_features)
 
OTF_Tag OTF_tag (const char *name)
 
void OTF_tag_name (OTF_Tag tag, char *name)
 
int OTF_put_data (OTF *otf, char *id, void *data, void(*freer)(void *data))
 
voidOTF_get_data (OTF *otf, char *id)
 

Variables

int debug_flag = -1
 

Macro Definition Documentation

◆ OTF_CALLOC

#define OTF_CALLOC (   p,
  size,
  arg 
)
Value:
do { \
if (size == 0) \
(p) = NULL; \
else \
{ \
OTF_MemoryRecord *memrec \
= ((OTF_InternalData *) otf->internal_data)->memory_record; \
(p) = calloc ((size), sizeof (*(p))); \
if (! (p) \
|| (memrec->used >= OTF_MEMORY_RECORD_SIZE \
&& ! (memrec = allocate_memory_record (otf)))) \
OTF_ERROR (OTF_ERROR_MEMORY, (arg)); \
memrec->memory[memrec->used++] = (p); \
} \
} while (0)
#define NULL
Definition: ftobjs.h:61
small capitals from c petite p
Definition: afcover.h:72
voidp calloc()
#define OTF_ERROR_MEMORY
Definition: otf.h:1621
#define OTF_MEMORY_RECORD_SIZE
Definition: otfopen.c:279
static OTF_MemoryRecord * allocate_memory_record(OTF *otf)
Definition: otfopen.c:337
static int size
Definition: ppmlabel.c:24

Definition at line 370 of file otfopen.c.

◆ OTF_MALLOC

#define OTF_MALLOC (   p,
  size,
  arg 
)
Value:
do { \
if (size == 0) \
(p) = NULL; \
else \
{ \
OTF_MemoryRecord *memrec \
= ((OTF_InternalData *) otf->internal_data)->memory_record; \
(p) = malloc (sizeof (*(p)) * (size)); \
if (! (p) \
|| (memrec->used >= OTF_MEMORY_RECORD_SIZE \
&& ! (memrec = allocate_memory_record (otf)))) \
OTF_ERROR (OTF_ERROR_MEMORY, (arg)); \
memrec->memory[memrec->used++] = (p); \
} \
} while (0)
#define malloc
Definition: alloca.c:91

Definition at line 352 of file otfopen.c.

◆ OTF_MEMORY_RECORD_SIZE

#define OTF_MEMORY_RECORD_SIZE   1024

Definition at line 279 of file otfopen.c.

◆ READ_BYTES

#define READ_BYTES (   stream,
  p,
  nbytes 
)
Value:
do { \
STREAM_CHECK_SIZE ((stream), (nbytes)); \
memcpy ((p), (stream)->buf + (stream)->pos, (nbytes)); \
(stream)->pos += (nbytes); \
} while (0)
unsigned nbytes
Definition: in_pcx.cpp:355
#define buf
const int * pos
Definition: combiners.h:905
struct stream_s stream
Definition: pts_fax.h:93

Definition at line 249 of file otfopen.c.

◆ READ_FIXED

#define READ_FIXED (   stream,
  fixed 
)
Value:
do { \
READ_USHORT ((stream), (fixed).high); \
READ_USHORT ((stream), (fixed).low); \
} while (0)
int low
Definition: combiners.h:904
int high
Definition: combiners.h:904
le_int32 fixed
Definition: sfnt.h:144

Definition at line 242 of file otfopen.c.

◆ READ_GLYPHID

#define READ_GLYPHID   READ_USHORT

Definition at line 261 of file otfopen.c.

◆ READ_INT16

#define READ_INT16   READ_SHORT

Definition at line 260 of file otfopen.c.

◆ READ_LONG

#define READ_LONG (   stream,
  var 
)
Value:
do { \
STREAM_CHECK_SIZE ((stream), 4); \
(var) = (int) (((stream)->buf[(stream)->pos] << 24) \
| ((stream)->buf[(stream)->pos + 1] << 16) \
| ((stream)->buf[(stream)->pos + 2] << 8) \
| (stream)->buf[(stream)->pos + 3]); \
(stream)->pos += 4; \
} while (0)
Definition: sh.h:1782

Definition at line 231 of file otfopen.c.

◆ READ_OFFSET

#define READ_OFFSET   READ_USHORT

Definition at line 258 of file otfopen.c.

◆ READ_SHORT

#define READ_SHORT (   stream,
  var 
)
Value:
do { \
STREAM_CHECK_SIZE ((stream), 2); \
(var) = (short) (((stream)->buf[(stream)->pos] << 8) \
| (stream)->buf[(stream)->pos + 1]); \
(stream)->pos += 2; \
} while (0)

Definition at line 204 of file otfopen.c.

◆ READ_TAG

#define READ_TAG   READ_ULONG

Definition at line 257 of file otfopen.c.

◆ READ_UINT16

#define READ_UINT16   READ_USHORT

Definition at line 259 of file otfopen.c.

◆ READ_UINT24

#define READ_UINT24 (   stream,
  var 
)
Value:
do { \
STREAM_CHECK_SIZE ((stream), 3); \
(var) = (((stream)->buf[(stream)->pos ] << 16) \
| ((stream)->buf[(stream)->pos + 1] << 8) \
| (stream)->buf[(stream)->pos + 2]); \
(stream)->pos += 3; \
} while (0)

Definition at line 212 of file otfopen.c.

◆ READ_ULONG

#define READ_ULONG (   stream,
  var 
)
Value:
do { \
STREAM_CHECK_SIZE ((stream), 4); \
(var) = (((stream)->buf[(stream)->pos] << 24) \
| ((stream)->buf[(stream)->pos + 1] << 16) \
| ((stream)->buf[(stream)->pos + 2] << 8) \
| (stream)->buf[(stream)->pos + 3]); \
(stream)->pos += 4; \
} while (0)

Definition at line 221 of file otfopen.c.

◆ READ_USHORT

#define READ_USHORT (   stream,
  var 
)
Value:
do { \
STREAM_CHECK_SIZE ((stream), 2); \
(var) = (((stream)->buf[(stream)->pos] << 8) \
| (stream)->buf[(stream)->pos + 1]); \
(stream)->pos += 2; \
} while (0)

Definition at line 196 of file otfopen.c.

◆ RESTORE_STREAM

#define RESTORE_STREAM (   stream,
  state 
)    ((stream)->pos = (state))

Definition at line 182 of file otfopen.c.

◆ SAVE_STREAM

#define SAVE_STREAM (   stream,
  state 
)    ((state) = (stream)->pos)

Definition at line 181 of file otfopen.c.

◆ SEEK_STREAM

#define SEEK_STREAM (   stream,
  offset 
)    ((stream)->pos = (offset))

Definition at line 183 of file otfopen.c.

◆ STREAM_CHECK_SIZE

#define STREAM_CHECK_SIZE (   stream,
  size 
)
Value:
if ((stream)->pos + (size) > (stream)->bufsize) \
{ \
char *errfmt = "buffer overrun in %s"; \
return errret; \
} \
else
#define name
#define bufsize
#define OTF_ERROR_TABLE
Definition: otf.h:1634
#define OTF_ERROR(err, arg)
Definition: internal.h:35

Definition at line 185 of file otfopen.c.

Typedef Documentation

◆ OTF_ApplicationData

Definition at line 174 of file otfopen.c.

◆ OTF_MemoryRecord

Definition at line 174 of file otfopen.c.

◆ OTF_StreamState

typedef long OTF_StreamState

Definition at line 101 of file otfopen.c.

◆ OTF_TableInfo

typedef struct _OTF_TableInfo OTF_TableInfo

Definition at line 174 of file otfopen.c.

Enumeration Type Documentation

◆ OTF_ReaderFlag

Enumerator
OTF_READ_FULL 
OTF_READ_SCRIPTS 
OTF_READ_FEATURES 
OTF_READ_MAX 

Definition at line 290 of file otfopen.c.

◆ OTF_TableType

Enumerator
OTF_TABLE_TYPE_HEAD 
OTF_TABLE_TYPE_NAME 
OTF_TABLE_TYPE_CMAP 
OTF_TABLE_TYPE_GDEF 
OTF_TABLE_TYPE_GSUB 
OTF_TABLE_TYPE_GPOS 
OTF_TABLE_TYPE_MAX 

Definition at line 268 of file otfopen.c.

Function Documentation

◆ allocate_memory_record()

static OTF_MemoryRecord* allocate_memory_record ( OTF otf)
static

Definition at line 337 of file otfopen.c.

References OTF::internal_data, malloc, OTF_InternalData::memory_record, and NULL.

Referenced by OTF_open(), and OTF_open_ft_face().

◆ free_stream()

static void free_stream ( OTF_Stream stream)
static

Definition at line 174 of file otfopen.c.

References free.

Referenced by OTF_close(), OTF_get_table(), and read_header_part().

◆ get_table_info()

◆ make_stream()

static OTF_Stream* make_stream ( const char *  name)
static

Definition at line 104 of file otfopen.c.

References calloc(), name, NULL, OTF_ERROR, and OTF_ERROR_MEMORY.

Referenced by make_stream_from_ft_face(), and read_header_part().

◆ make_stream_from_ft_face()

static OTF_Stream* make_stream_from_ft_face ( FT_Face  face,
const char *  name 
)
static

◆ OTF_check_features()

int OTF_check_features ( OTF otf,
int  gsubp,
OTF_Tag  script,
OTF_Tag  language,
const OTF_Tag features,
int  n_features 
)

Check supported features.

The OTF_check_features() function checks whether or not the OpenType font $OTF has, for $SCRIPT and $LANGUAGE, all features in the array $FEATURES. The array size is $N_FEATURES. If $LANGUAGE is zero or $OTF doesn't have LangSys for $SCRIPT, the default LangSys is checked.

If $OTF has all the features, return 1. Otherwise, return 0. If an error occurs, return -1, and set the variable OTF_error to OTF_ERROR_TABLE.

Definition at line 3173 of file otfopen.c.

References OTF_FeatureList::Feature, OTF_GSUB_GPOS::FeatureList, features, OTF_Feature::FeatureTag, OTF::gpos, OTF::gsub, i, j, language, negate, NULL, OTF_get_features(), script, OTF_ScriptList::Script, OTF_ScriptList::ScriptCount, OTF_GSUB_GPOS::ScriptList, and OTF_Script::ScriptTag.

◆ OTF_check_table()

int OTF_check_table ( OTF otf,
const char *  name 
)

Check the existence of OpenType font table

The OTF_check_table() function checks if the the OTF table specified by $NAME exists in OpenType font $OTF.

If the table exists, return 0, else return -1.

See also OTF_open().

Definition at line 3111 of file otfopen.c.

References get_table_info(), and name.

◆ OTF_close()

◆ OTF_get_data()

void* OTF_get_data ( OTF otf,
char *  id 
)

Definition at line 3305 of file otfopen.c.

References OTF_InternalData::app_data, for(), OTF::internal_data, NULL, and strcmp().

◆ OTF_get_features()

int OTF_get_features ( OTF otf,
int  gsubp 
)

Get supported features.

The OTF_get_features() function setups OTF_FeatureList of GSUB (if $GSUBP is nonzero) or GPOS (if $GSUBP is zero) table of the OpenType font $OTF.

If the table is successfully setup, return 0. Otherwise, retrun -1, and set the variable OTF_error to OTF_ERROR_TABLE.

Definition at line 3144 of file otfopen.c.

References _OTF_TableInfo::address, OTF::internal_data, NULL, OTF_READ_FEATURES, OTF_TABLE_TYPE_GPOS, OTF_TABLE_TYPE_GSUB, _OTF_TableInfo::reader, _OTF_TableInfo::stream, and OTF_InternalData::table_info.

Referenced by OTF_check_features().

◆ OTF_get_scripts()

int OTF_get_scripts ( OTF otf,
int  gsubp 
)

Get supported scripts.

The OTF_get_scripts() function setups OTF_ScriptList of GSUB (if $GSUBP is nonzero) or GPOS (if $GSUBP is zero) table of the OpenType font $OTF.

If the table is successfully setup, return 0. Otherwise, retrun -1, and set the variable OTF_error to OTF_ERROR_TABLE.

Definition at line 3119 of file otfopen.c.

References OTF::internal_data, NULL, OTF_READ_SCRIPTS, OTF_TABLE_TYPE_GPOS, OTF_TABLE_TYPE_GSUB, _OTF_TableInfo::reader, _OTF_TableInfo::stream, and OTF_InternalData::table_info.

◆ OTF_get_table()

int OTF_get_table ( OTF otf,
const char *  name 
)

Get OpenType font table

The OTF_get_table() function setups one of the OTF table specified by $NAME in the OpenType font $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.

See also OTF_open().

Definition at line 3086 of file otfopen.c.

References free_stream(), get_table_info(), name, NULL, OTF_READ_FULL, _OTF_TableInfo::reader, and _OTF_TableInfo::stream.

Referenced by main(), OTF_drive_cmap(), OTF_drive_cmap2(), OTF_drive_gdef(), OTF_drive_gpos(), OTF_drive_gpos2(), OTF_drive_gpos_internal(), OTF_drive_gpos_with_log(), OTF_drive_gsub(), OTF_drive_gsub_internal(), OTF_drive_gsub_with_log(), OTF_get_unicode(), OTF_get_variation_glyphs(), and OTF_iterate_gsub_feature().

◆ OTF_open()

OTF* OTF_open ( const char *  name)

Open OpenType font

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 following values.

OTF_ERROR_MEMORY OTF_ERROR_FILE OTF_ERROR_TABLE

See also OTF_get_table() and OTF_close().

Definition at line 2953 of file otfopen.c.

References allocate_memory_record(), calloc(), debug_flag, ext, fclose, FILE, OTF::filename, fopen, fp, OTF::internal_data, len, NULL, OTF_close(), OTF_ERROR, OTF_ERROR_FILE, OTF_ERROR_MEMORY, read_header_part(), set_debug_flag(), strdup, strlen(), and strncasecmp.

Referenced by main().

◆ OTF_open_ft_face()

◆ OTF_put_data()

int OTF_put_data ( OTF otf,
char *  id,
void data,
void(*)(void *data freer 
)

◆ OTF_tag()

OTF_Tag OTF_tag ( const char *  name)

Return OTF tag of a specified name string.

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.

Definition at line 3252 of file otfopen.c.

References name, and p.

Referenced by get_langsys(), get_table_info(), read_header_part(), and setup_lookup_flags().

◆ OTF_tag_name()

void OTF_tag_name ( OTF_Tag  tag,
char *  name 
)

Convert OTF tag to name string.

The OTF_tag_name() function converts OTF tag $TAG to a 5-byte name string (including the terminating NULL), and store it in $NAME. At least 5-byte space must be at $NAME.

Definition at line 3266 of file otfopen.c.

References name.

Referenced by list_GPOS_features(), and list_GSUB_features().

◆ read_alternate_set_list()

static unsigned read_alternate_set_list ( OTF otf,
OTF_Stream stream,
long  offset,
OTF_AlternateSet **  altset 
)
static

◆ read_anchor()

◆ read_anchor_array()

static int read_anchor_array ( OTF otf,
OTF_Stream stream,
long  offset,
unsigned  ClassCount,
OTF_AnchorArray array 
)
static

◆ read_attach_list()

static int read_attach_list ( OTF otf,
OTF_Stream stream,
long  offset,
OTF_AttachList list 
)
static

Definition at line 1128 of file otfopen.c.

References count, i, j, offset, OTF_MALLOC, read_coverage(), READ_OFFSET, READ_UINT16, and SEEK_STREAM.

Referenced by read_gdef_table().

◆ read_caret_value()

◆ read_chain_class_rule_list()

static unsigned read_chain_class_rule_list ( OTF otf,
OTF_Stream stream,
long  offset,
OTF_ChainClassRule **  rule 
)
static

◆ read_chain_class_set_list()

static unsigned read_chain_class_set_list ( OTF otf,
OTF_Stream stream,
long  offset,
OTF_ChainClassSet **  set 
)
static

◆ read_chain_context1()

static int read_chain_context1 ( OTF otf,
OTF_Stream stream,
long  offset,
OTF_Coverage coverage,
OTF_ChainContext1 chain_context1 
)
static

◆ read_chain_context2()

◆ read_chain_context3()

◆ read_chain_rule_list()

static unsigned read_chain_rule_list ( OTF otf,
OTF_Stream stream,
long  offset,
OTF_ChainRule **  rule 
)
static

◆ read_chain_rule_set_list()

static unsigned read_chain_rule_set_list ( OTF otf,
OTF_Stream stream,
long  offset,
OTF_ChainRuleSet **  set 
)
static

◆ read_class1_record_list()

static OTF_Class1Record* read_class1_record_list ( OTF otf,
OTF_Stream stream,
long  offset,
unsigned  num1,
enum OTF_ValueFormat  bit1,
unsigned  num2,
enum OTF_ValueFormat  bit2 
)
static

Definition at line 2382 of file otfopen.c.

References i, j, NULL, num1, num2, offset, OTF_CALLOC, OTF_MALLOC, and read_value_record().

Referenced by read_lookup_subtable_gpos().

◆ read_class_def()

static int read_class_def ( OTF otf,
OTF_Stream stream,
long  offset,
OTF_ClassDef class 
)
static

◆ read_class_def_without_offset()

static int read_class_def_without_offset ( OTF otf,
OTF_Stream stream,
OTF_ClassDef class 
)
static

◆ read_class_rule_list()

static unsigned read_class_rule_list ( OTF otf,
OTF_Stream stream,
long  offset,
OTF_ClassRule **  rule 
)
static

◆ read_class_set_list()

static unsigned read_class_set_list ( OTF otf,
OTF_Stream stream,
long  offset,
OTF_ClassSet **  set 
)
static

◆ read_cmap_table()

◆ read_cmap_uvs_table()

◆ read_context1()

static int read_context1 ( OTF otf,
OTF_Stream stream,
long  offset,
OTF_Coverage coverage,
OTF_Context1 context1 
)
static

◆ read_context2()

static int read_context2 ( OTF otf,
OTF_Stream stream,
long  offset,
OTF_Coverage coverage,
OTF_Context2 context2 
)
static

◆ read_context3()

◆ read_coverage()

◆ read_coverage_list()

static int read_coverage_list ( OTF otf,
OTF_Stream stream,
long  offset,
OTF_Coverage **  coverage,
int  count 
)
static

Definition at line 972 of file otfopen.c.

References count, i, offset, OTF_MALLOC, read_coverage(), and READ_UINT16.

Referenced by read_chain_context3(), read_context3(), and read_reverse_chain1().

◆ read_device_table()

static int read_device_table ( OTF otf,
OTF_Stream stream,
long  offset,
OTF_DeviceTable table 
)
static

Definition at line 1060 of file otfopen.c.

References i, int8, NULL, num, offset, OTF_MALLOC, READ_UINT16, SEEK_STREAM, and val.

Referenced by read_anchor(), read_caret_value(), and read_value_record().

◆ read_entry_exit_list()

static unsigned read_entry_exit_list ( OTF otf,
OTF_Stream stream,
long  offset,
OTF_EntryExitRecord **  rec 
)
static

◆ read_feature_list()

static int read_feature_list ( OTF otf,
OTF_Stream stream,
long  offset,
OTF_FeatureList list 
)
static

Definition at line 1331 of file otfopen.c.

References i, j, offset, feature::offset, OTF_CALLOC, OTF_MALLOC, READ_OFFSET, READ_TAG, READ_UINT16, and SEEK_STREAM.

Referenced by read_gsub_gpos_table().

◆ read_gdef_header()

static int read_gdef_header ( OTF_Stream stream,
OTF_GDEFHeader header 
)
static

Definition at line 1213 of file otfopen.c.

References READ_FIXED, and READ_OFFSET.

Referenced by read_gdef_table().

◆ read_gdef_table()

◆ read_glyph_ids()

◆ read_gpos_table()

static void* read_gpos_table ( OTF otf,
OTF_TableInfo table,
enum OTF_ReaderFlag  flag 
)
static

Definition at line 2717 of file otfopen.c.

References read_gsub_gpos_table().

Referenced by read_header_part().

◆ read_gsub_gpos_table()

◆ read_gsub_table()

static void* read_gsub_table ( OTF otf,
OTF_TableInfo table,
enum OTF_ReaderFlag  flag 
)
static

Definition at line 2187 of file otfopen.c.

References read_gsub_gpos_table().

Referenced by read_header_part().

◆ read_head_table()

static void* read_head_table ( OTF otf,
OTF_TableInfo table,
enum OTF_ReaderFlag  flag 
)
static

Definition at line 391 of file otfopen.c.

References head::flags, head, NULL, OTF_CALLOC, READ_FIXED, READ_ULONG, and READ_USHORT.

Referenced by read_header_part().

◆ read_header_part()

◆ read_lig_caret_list()

static int read_lig_caret_list ( OTF otf,
OTF_Stream stream,
long  offset,
OTF_LigCaretList list 
)
static

Definition at line 1181 of file otfopen.c.

References count, i, j, offset, OTF_MALLOC, read_caret_value(), read_coverage(), READ_OFFSET, READ_UINT16, and SEEK_STREAM.

Referenced by read_gdef_table().

◆ read_ligature()

static int read_ligature ( OTF otf,
OTF_Stream stream,
long  offset,
OTF_Ligature **  ligature 
)
static

Definition at line 1918 of file otfopen.c.

References count, i, offset, OTF_MALLOC, read_glyph_ids(), READ_GLYPHID, READ_OFFSET, READ_UINT16, and SEEK_STREAM.

Referenced by read_ligature_set_list().

◆ read_ligature_array()

static int read_ligature_array ( OTF otf,
OTF_Stream stream,
long  offset,
unsigned  class_count,
OTF_LigatureArray array 
)
static

◆ read_ligature_attach()

◆ read_ligature_set_list()

static unsigned read_ligature_set_list ( OTF otf,
OTF_Stream stream,
long  offset,
OTF_LigatureSet **  ligset 
)
static

Definition at line 1945 of file otfopen.c.

References count, i, offset, OTF_MALLOC, read_ligature(), READ_OFFSET, READ_UINT16, and SEEK_STREAM.

Referenced by read_lookup_subtable_gsub().

◆ read_lookup_list()

static int read_lookup_list ( OTF otf,
OTF_Stream stream,
long  offset,
OTF_LookupList list,
int  gsubp 
)
static

◆ read_lookup_record_list()

static int read_lookup_record_list ( OTF otf,
OTF_Stream stream,
OTF_LookupRecord **  record,
int  count 
)
static

◆ read_lookup_subtable_gpos()

static int read_lookup_subtable_gpos ( OTF otf,
OTF_Stream stream,
long  offset,
unsigned  type,
OTF_LookupSubTableGPOS subtable 
)
static

Definition at line 2497 of file otfopen.c.

References OTF_GPOS_MarkBase1::BaseArray, OTF_GPOS_MarkBase1::BaseCoverage, OTF_LookupSubTableGPOS::chain_context1, OTF_LookupSubTableGPOS::chain_context2, OTF_LookupSubTableGPOS::chain_context3, OTF_GPOS_Pair2::Class1Count, OTF_GPOS_Pair2::Class1Record, OTF_GPOS_Pair2::Class2Count, OTF_GPOS_MarkBase1::ClassCount, OTF_GPOS_MarkLig1::ClassCount, OTF_GPOS_MarkMark1::ClassCount, OTF_GPOS_Pair2::ClassDef1, OTF_GPOS_Pair2::ClassDef2, OTF_LookupSubTableGPOS::context1, OTF_LookupSubTableGPOS::context2, OTF_LookupSubTableGPOS::context3, OTF_LookupSubTableGPOS::Coverage, OTF_LookupSubTableGPOS::cursive1, OTF_GPOS_Cursive1::EntryExitCount, OTF_GPOS_Cursive1::EntryExitRecord, OTF_LookupSubTableGPOS::extension1, OTF_GPOS_Extension1::ExtensionLookupType, OTF_GPOS_Extension1::ExtensionOffset, OTF_GPOS_Extension1::ExtensionSubtable, OTF_LookupSubTableGPOS::Format, i, OTF_GPOS_MarkLig1::LigatureArray, OTF_GPOS_MarkLig1::LigatureCoverage, OTF_GPOS_MarkMark1::Mark1Array, OTF_GPOS_MarkMark1::Mark2Array, OTF_GPOS_MarkMark1::Mark2Coverage, OTF_LookupSubTableGPOS::mark_base1, OTF_LookupSubTableGPOS::mark_lig1, OTF_LookupSubTableGPOS::mark_mark1, OTF_GPOS_MarkBase1::MarkArray, OTF_GPOS_MarkLig1::MarkArray, offset, OTF_CALLOC, OTF_ERROR, OTF_ERROR_TABLE, OTF_LookupSubTableGPOS::pair1, OTF_LookupSubTableGPOS::pair2, OTF_GPOS_Pair1::PairSet, OTF_GPOS_Pair1::PairSetCount, read_anchor_array(), read_chain_context1(), read_chain_context2(), read_chain_context3(), read_class1_record_list(), read_class_def(), read_context1(), read_context2(), read_context3(), read_coverage(), read_entry_exit_list(), read_ligature_array(), read_mark_array(), read_pair_set_list(), READ_UINT16, READ_ULONG, READ_USHORT, read_value_record(), SEEK_STREAM, OTF_LookupSubTableGPOS::single1, OTF_LookupSubTableGPOS::single2, sprintf, type, OTF_LookupSubTableGPOS::u, OTF_GPOS_Single1::Value, OTF_GPOS_Single2::Value, OTF_GPOS_Single2::ValueCount, OTF_GPOS_Single1::ValueFormat, OTF_GPOS_Single2::ValueFormat, OTF_GPOS_Pair1::ValueFormat1, OTF_GPOS_Pair2::ValueFormat1, OTF_GPOS_Pair1::ValueFormat2, and OTF_GPOS_Pair2::ValueFormat2.

Referenced by read_lookup_list().

◆ read_lookup_subtable_gsub()

static int read_lookup_subtable_gsub ( OTF otf,
OTF_Stream stream,
long  offset,
unsigned  type,
OTF_LookupSubTableGSUB subtable 
)
static

◆ read_mark_array()

static int read_mark_array ( OTF otf,
OTF_Stream stream,
long  offset,
OTF_MarkArray array 
)
static

◆ read_name()

◆ read_name_table()

◆ read_offset_table()

static int read_offset_table ( OTF otf,
OTF_Stream stream,
OTF_OffsetTable table 
)
static

Definition at line 2753 of file otfopen.c.

References READ_FIXED, and READ_USHORT.

Referenced by read_header_part().

◆ read_pair_set_list()

◆ read_range_records()

static unsigned read_range_records ( OTF otf,
OTF_Stream stream,
OTF_RangeRecord **  record 
)
static

Definition at line 920 of file otfopen.c.

References count, i, OTF_MALLOC, READ_GLYPHID, and READ_UINT16.

Referenced by read_class_def(), read_class_def_without_offset(), and read_coverage().

◆ read_reverse_chain1()

◆ read_rule_list()

static unsigned read_rule_list ( OTF otf,
OTF_Stream stream,
long  offset,
OTF_Rule **  rule 
)
static

◆ read_rule_set_list()

static unsigned read_rule_set_list ( OTF otf,
OTF_Stream stream,
long  offset,
OTF_RuleSet **  set 
)
static

◆ read_script_list()

static int read_script_list ( OTF otf,
OTF_Stream stream,
long  offset,
OTF_ScriptList list 
)
static

Definition at line 1265 of file otfopen.c.

References i, j, k, offset, OTF_CALLOC, OTF_MALLOC, READ_OFFSET, READ_TAG, READ_USHORT, script, and SEEK_STREAM.

Referenced by read_gsub_gpos_table().

◆ read_sequence()

static unsigned read_sequence ( OTF otf,
OTF_Stream stream,
long  offset,
OTF_Sequence **  seq 
)
static

◆ read_table_directory()

static OTF_Tag read_table_directory ( OTF_Stream stream,
OTF_TableDirectory table 
)
static

Definition at line 2766 of file otfopen.c.

References READ_TAG, READ_ULONG, tag, and table::tag.

Referenced by read_header_part().

◆ read_value_record()

◆ set_debug_flag()

static void set_debug_flag ( )
static

Definition at line 64 of file otfopen.c.

References debug_flag, getenv(), and NULL.

Referenced by OTF_open(), and OTF_open_ft_face().

◆ setup_stream()

static int setup_stream ( OTF_Stream stream,
FILE fp,
long  offset,
int  nbytes 
)
static

Definition at line 118 of file otfopen.c.

References buf, fp, fread, free, fseek, malloc, nbytes, offset, OTF_ERROR, OTF_ERROR_FILE, OTF_ERROR_MEMORY, and SEEK_SET.

Referenced by read_header_part().

Variable Documentation

◆ debug_flag

int debug_flag = -1

Table of contents (almost parallel to otf.h):

(0) Stream handler

(1) Readers for OTF Layout tables and OTF itself (1-1) Basic types and functions (1-2) "head" table (1-3) "name" table (1-4) "cmap" table (1-5) Structures common to GDEF, GSUB, and GPOS (1-6) "GDEF" table (1-7) Structures for ScriptList, FeatureList, and LookupList (1-8) Structures common to GSUB and GPOS (1-9) "GSUB" table (1-10) "GPOS" table (1-11) Structure for OTF

(2) API for reading OTF (2-1) OTF_open() (2-2) OTF_close() (2-3) OTF_get_table() (2-4) OTF_check_table()

(5) API miscellaneous

Definition at line 61 of file otfopen.c.

Referenced by lookup_gpos(), lookup_gsub(), OTF_open(), OTF_open_ft_face(), and set_debug_flag().