#include <string.h>
#include "otf.h"
-#include "otfutil.h"
+#include "otferror.h"
/* OTF_Stream
static int read_lookup_subtable_gsub (OTF *otf, OTF_Stream *stream,
long offset, unsigned type,
- OTF_LookupSubTable *subtable);
+ OTF_LookupSubTableGSUB *subtable);
static int read_lookup_subtable_gpos (OTF *otf, OTF_Stream *stream,
long offset, unsigned type,
- OTF_LookupSubTable *subtable);
+ OTF_LookupSubTableGPOS *subtable);
static int
read_lookup_list (OTF *otf, OTF_Stream *stream, long offset,
READ_UINT16 (stream, lookup->SubTableCount);
OTF_MALLOC (lookup->SubTableOffset, lookup->SubTableCount,
" (SubTableOffset)");
- OTF_CALLOC (lookup->SubTable, lookup->SubTableCount,
- " (SubTable)");
+ if (gsub)
+ OTF_CALLOC (lookup->SubTable.gsub, lookup->SubTableCount,
+ " (SubTable)");
+ else
+ OTF_CALLOC (lookup->SubTable.gpos, lookup->SubTableCount,
+ " (SubTable)");
for (j = 0; j < lookup->SubTableCount; j++)
READ_OFFSET (stream, lookup->SubTableOffset[j]);
- if (gsub)
- for (j = 0; j < lookup->SubTableCount; j++)
- {
- long this_offset
- = offset + lookup->offset + lookup->SubTableOffset[j];
+ for (j = 0; j < lookup->SubTableCount; j++)
+ {
+ long this_offset
+ = offset + lookup->offset + lookup->SubTableOffset[j];
- if (read_lookup_subtable_gsub (otf, stream, this_offset,
+ if (gsub
+ ? read_lookup_subtable_gsub (otf, stream, this_offset,
lookup->LookupType,
- lookup->SubTable + j) < 0)
- return errret;
- }
- else
- for (j = 0; j < lookup->SubTableCount; j++)
- {
- long this_offset
- = offset + lookup->offset + lookup->SubTableOffset[j];
-
- if (read_lookup_subtable_gpos (otf, stream, this_offset,
+ lookup->SubTable.gsub + j) < 0
+ : read_lookup_subtable_gpos (otf, stream, this_offset,
lookup->LookupType,
- lookup->SubTable + j) < 0)
- return errret;
- }
+ lookup->SubTable.gpos + j) < 0)
+ return errret;
+ }
}
return 0;
static int
read_lookup_subtable_gsub (OTF *otf, OTF_Stream *stream, long offset,
- unsigned type, OTF_LookupSubTable *subtable)
+ unsigned type, OTF_LookupSubTableGSUB *subtable)
{
char *errfmt = "GSUB LookupSubTable%s";
int errret = -1;
{
if (read_coverage (otf, stream, offset, &subtable->Coverage) < 0)
return -1;
- READ_INT16 (stream, subtable->sub.gsub.single1.DeltaGlyphID);
+ READ_INT16 (stream, subtable->u.single1.DeltaGlyphID);
}
else if (subtable->Format == 2)
{
if (read_coverage (otf, stream, offset, &subtable->Coverage) < 0)
return -1;
- subtable->sub.gsub.single2.GlyphCount
- = read_glyph_ids (otf, stream, &subtable->sub.gsub.single2.Substitute,
+ subtable->u.single2.GlyphCount
+ = read_glyph_ids (otf, stream, &subtable->u.single2.Substitute,
0);
- if (! subtable->sub.gsub.single2.GlyphCount)
+ if (! subtable->u.single2.GlyphCount)
return -1;
}
else
if (subtable->Format == 1)
{
read_coverage (otf, stream, offset, &subtable->Coverage);
- subtable->sub.gsub.multiple1.SequenceCount
+ subtable->u.multiple1.SequenceCount
= read_sequence (otf, stream, offset,
- &subtable->sub.gsub.multiple1.Sequence);
+ &subtable->u.multiple1.Sequence);
}
else
OTF_ERROR (OTF_ERROR_TABLE, " (Invalid SubFormat)");
read_coverage (otf, stream, offset, &subtable->Coverage);
count = (read_ligature_set
(otf, stream, offset,
- &subtable->sub.gsub.ligature1.LigatureSet));
+ &subtable->u.ligature1.LigatureSet));
if (count < 0)
return -1;
- subtable->sub.gsub.ligature1.LigSetCount = (unsigned) count;
+ subtable->u.ligature1.LigSetCount = (unsigned) count;
}
else
OTF_ERROR (OTF_ERROR_TABLE, " (Invalid SubFormat)");
if (subtable->Format == 1)
{
read_coverage (otf, stream, offset, &subtable->Coverage);
- subtable->sub.gsub.chain_context1.ChainSubRuleSetCount
+ subtable->u.chain_context1.ChainSubRuleSetCount
= (read_chain_subrule_set
(otf, stream, offset,
- &subtable->sub.gsub.chain_context1.ChainSubRuleSet));
+ &subtable->u.chain_context1.ChainSubRuleSet));
}
else if (subtable->Format == 2)
{
read_coverage (otf, stream, offset, &subtable->Coverage);
read_class_def (otf, stream, offset,
- &subtable->sub.gsub.chain_context2.Backtrack);
+ &subtable->u.chain_context2.Backtrack);
read_class_def (otf, stream, offset,
- &subtable->sub.gsub.chain_context2.Input);
+ &subtable->u.chain_context2.Input);
read_class_def (otf, stream, offset,
- &subtable->sub.gsub.chain_context2.LookAhead);
- subtable->sub.gsub.chain_context2.ChainSubClassSetCnt
+ &subtable->u.chain_context2.LookAhead);
+ subtable->u.chain_context2.ChainSubClassSetCnt
= (read_chain_subclass_set
(otf, stream, offset,
- &subtable->sub.gsub.chain_context2.ChainSubClassSet));
+ &subtable->u.chain_context2.ChainSubClassSet));
}
else if (subtable->Format == 3)
{
count = (read_coverage_list
(otf, stream, offset,
- &subtable->sub.gsub.chain_context3.Backtrack));
+ &subtable->u.chain_context3.Backtrack));
if (count < 0)
return -1;
- subtable->sub.gsub.chain_context3.BacktrackGlyphCount
+ subtable->u.chain_context3.BacktrackGlyphCount
= (unsigned) count;
count = (read_coverage_list
(otf, stream, offset,
- &subtable->sub.gsub.chain_context3.Input));
+ &subtable->u.chain_context3.Input));
if (count <= 0)
return -1;
- subtable->sub.gsub.chain_context3.InputGlyphCount
+ subtable->u.chain_context3.InputGlyphCount
= (unsigned) count;
- subtable->Coverage = subtable->sub.gsub.chain_context3.Input[0];
+ subtable->Coverage = subtable->u.chain_context3.Input[0];
count = (read_coverage_list
(otf, stream, offset,
- &subtable->sub.gsub.chain_context3.LookAhead));
- subtable->sub.gsub.chain_context3.LookaheadGlyphCount
+ &subtable->u.chain_context3.LookAhead));
+ subtable->u.chain_context3.LookaheadGlyphCount
= (unsigned) count;
- subtable->sub.gsub.chain_context3.SubstCount
+ subtable->u.chain_context3.SubstCount
= (read_subst_lookup_record
(otf, stream,
- &subtable->sub.gsub.chain_context3.SubstLookupRecord));
+ &subtable->u.chain_context3.SubstLookupRecord));
}
else
OTF_ERROR (OTF_ERROR_TABLE, " (Invalid SubFormat)");
static int
read_lookup_subtable_gpos (OTF *otf, OTF_Stream *stream,
long offset, unsigned type,
- OTF_LookupSubTable *subtable)
+ OTF_LookupSubTableGPOS *subtable)
{
char *errfmt = "GPOS LookupSubTable%s";
int errret = -1;
if (subtable->Format == 1)
{
read_coverage (otf, stream, offset, &subtable->Coverage);
- subtable->sub.gsub.single1.DeltaGlyphID = READ_INT16 (stream);
+ subtable->u.single1.DeltaGlyphID = READ_INT16 (stream);
}
else if (subtable->Format == 2)
{
read_coverage (otf, stream, offset, &subtable->Coverage);
- subtable->sub.gsub.single2.GlyphCount
+ subtable->u.single2.GlyphCount
= read_glyph_ids (otf, stream,
- &subtable->sub.gsub.single2.Substitute, 0);
+ &subtable->u.single2.Substitute, 0);
}
else
OTF_ERROR (OTF_ERROR_TABLE, " (Invalid SubFormat)");
{
SEEK_STREAM (stream, offset + 2);
read_coverage (otf, stream, offset, &subtable->Coverage);
- READ_UINT16 (stream, subtable->sub.gpos.pair2.ValueFormat1);
- READ_UINT16 (stream, subtable->sub.gpos.pair2.ValueFormat2);
+ READ_UINT16 (stream, subtable->u.pair2.ValueFormat1);
+ READ_UINT16 (stream, subtable->u.pair2.ValueFormat2);
read_class_def (otf, stream, offset,
- &subtable->sub.gpos.pair2.ClassDef1);
+ &subtable->u.pair2.ClassDef1);
read_class_def (otf, stream, offset,
- &subtable->sub.gpos.pair2.ClassDef2);
- READ_UINT16 (stream, subtable->sub.gpos.pair2.Class1Count);
- READ_UINT16 (stream, subtable->sub.gpos.pair2.Class2Count);
- subtable->sub.gpos.pair2.Class1Record
+ &subtable->u.pair2.ClassDef2);
+ READ_UINT16 (stream, subtable->u.pair2.Class1Count);
+ READ_UINT16 (stream, subtable->u.pair2.Class2Count);
+ subtable->u.pair2.Class1Record
= read_class1_record_list (otf, stream, offset,
- subtable->sub.gpos.pair2.Class1Count,
- subtable->sub.gpos.pair2.ValueFormat1,
- subtable->sub.gpos.pair2.Class2Count,
- subtable->sub.gpos.pair2.ValueFormat2);
+ subtable->u.pair2.Class1Count,
+ subtable->u.pair2.ValueFormat1,
+ subtable->u.pair2.Class2Count,
+ subtable->u.pair2.ValueFormat2);
}
else
OTF_ERROR (OTF_ERROR_TABLE, " (Invalid SubFormat)");
{
read_coverage (otf, stream, offset, &subtable->Coverage);
read_coverage (otf, stream, offset,
- &subtable->sub.gpos.mark_base1.BaseCoverage);
- READ_UINT16 (stream, subtable->sub.gpos.mark_base1.ClassCount);
+ &subtable->u.mark_base1.BaseCoverage);
+ READ_UINT16 (stream, subtable->u.mark_base1.ClassCount);
read_mark_array (otf, stream, offset,
- &subtable->sub.gpos.mark_base1.MarkArray);
+ &subtable->u.mark_base1.MarkArray);
read_base_array (otf, stream, offset,
- subtable->sub.gpos.mark_base1.ClassCount,
- &subtable->sub.gpos.mark_base1.BaseArray);
+ subtable->u.mark_base1.ClassCount,
+ &subtable->u.mark_base1.BaseArray);
}
else
OTF_ERROR (OTF_ERROR_TABLE, " (Invalid SubFormat)");
if (subtable->Format == 1)
{
read_coverage (otf, stream, offset,
- &subtable->sub.gsub.chain_context1.Coverage);
- subtable->sub.gsub.chain_context1.ChainSubRuleSetCount
+ &subtable->u.chain_context1.Coverage);
+ subtable->u.chain_context1.ChainSubRuleSetCount
= (read_chain_subrule_set
(otf, stream, offset,
- &subtable->sub.gsub.chain_context1.ChainSubRuleSet));
+ &subtable->u.chain_context1.ChainSubRuleSet));
}
else if (subtable->Format == 2)
{
read_coverage (otf, stream, offset,
- &subtable->sub.gsub.chain_context2.Coverage);
+ &subtable->u.chain_context2.Coverage);
read_class_def (otf, stream, offset,
- &subtable->sub.gsub.chain_context2.Backtrack);
+ &subtable->u.chain_context2.Backtrack);
read_class_def (otf, stream, offset,
- &subtable->sub.gsub.chain_context2.Input);
+ &subtable->u.chain_context2.Input);
read_class_def (otf, stream, offset,
- &subtable->sub.gsub.chain_context2.LookAhead);
- subtable->sub.gsub.chain_context2.ChainSubClassSetCnt
+ &subtable->u.chain_context2.LookAhead);
+ subtable->u.chain_context2.ChainSubClassSetCnt
= (read_chain_subclass_set
(otf, stream, offset,
- &subtable->sub.gsub.chain_context2.ChainSubClassSet));
+ &subtable->u.chain_context2.ChainSubClassSet));
}
else if (subtable->Format == 3)
{
- subtable->sub.gsub.chain_context3.BacktrackGlyphCount
+ subtable->u.chain_context3.BacktrackGlyphCount
= (read_coverage_list
(otf, stream, offset,
- &subtable->sub.gsub.chain_context3.Backtrack));
- subtable->sub.gsub.chain_context3.InputGlyphCount
+ &subtable->u.chain_context3.Backtrack));
+ subtable->u.chain_context3.InputGlyphCount
= (read_coverage_list
(otf, stream, offset,
- &subtable->sub.gsub.chain_context3.Input));
- subtable->sub.gsub.chain_context3.LookaheadGlyphCount
+ &subtable->u.chain_context3.Input));
+ subtable->u.chain_context3.LookaheadGlyphCount
= (read_coverage_list
(otf, stream, offset,
- &subtable->sub.gsub.chain_context3.LookAhead));
- subtable->sub.gsub.chain_context3.SubstCount
+ &subtable->u.chain_context3.LookAhead));
+ subtable->u.chain_context3.SubstCount
= (read_subst_lookup_record
(otf, stream,
- &subtable->sub.gsub.chain_context3.SubstLookupRecord));
+ &subtable->u.chain_context3.SubstLookupRecord));
}
else
OTF_ERROR (OTF_ERROR_TABLE, " (Invalid SubFormat)");
OTF_InternalData *internal_data = otf->internal_data;
int i;
- //if (otf->filename)
- //free (otf->filename);
if (internal_data)
{
OTF_MemoryRecord *memrec = internal_data->memory_record;
}
free (internal_data);
}
+ free (otf);
}