diff -urN qt-x11-free-3.3.5/src/3rdparty/opentype/disasm.c qt-x11-3/src/3rdparty/opentype/disasm.c --- qt-x11-free-3.3.5/src/3rdparty/opentype/disasm.c 2004-01-07 14:43:34.000000000 +0200 +++ qt-x11-3/src/3rdparty/opentype/disasm.c 1970-01-01 02:00:00.000000000 +0200 @@ -1,685 +0,0 @@ -/* Pango - * disasm.c: Dump OpenType layout tables - * - * Copyright (C) 2000 Red Hat Software - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include - -#include "disasm.h" - -#define G_HAVE_GNUC_VARARGS -#ifdef G_HAVE_ISO_VARARGS -#define DUMP(...) dump (stream, indent, __VA_ARGS__) -#elif defined (G_HAVE_GNUC_VARARGS) -#define DUMP(args...) dump (stream, indent, args) -#endif -#define DUMP_FINT(strct,fld) dump (stream, indent, "<" #fld ">%d\n", (strct)->fld) -#define DUMP_FUINT(strct,fld) dump (stream, indent, "<" #fld ">%u\n", (strct)->fld) -#define DUMP_FGLYPH(strct,fld) dump (stream, indent, "<" #fld ">%#4x\n", (strct)->fld) - -#define DEF_DUMP(type) static void Dump_ ## type (TTO_ ## type *type, FILE *stream, int indent, FT_Bool is_gsub) -#define RECURSE(name, type, val) do { DUMP ("<" #name ">\n"); Dump_ ## type (val, stream, indent + 1, is_gsub); DUMP ("\n"); } while (0) -#define RECURSE_NUM(name, i, type, val) do { DUMP ("<" #name "> \n", i); Dump_ ## type (val, stream, indent + 1, is_gsub); DUMP ("\n"); } while (0) -#define DUMP_VALUE_RECORD(val, frmt) do { DUMP ("\n"); Dump_ValueRecord (val, stream, indent + 1, is_gsub, frmt); DUMP ("\n"); } while (0) - -static void -do_indent (FILE *stream, int indent) -{ - int i; - - for (i = 0; i < indent * 3; i++) - fputc (' ', stream); -} - -static void -dump (FILE *stream, int indent, const char *format, ...) -{ - va_list list; - - do_indent (stream, indent); - - va_start (list, format); - vfprintf (stream, format, list); - va_end (list); -} - -static void -Print_Tag (FT_ULong tag, FILE *stream) -{ - fprintf (stream, "%c%c%c%c", - (unsigned char)(tag >> 24), - (unsigned char)((tag & 0xff0000) >> 16), - (unsigned char)((tag & 0xff00) >> 8), - (unsigned char)(tag & 0xff)); -} - -DEF_DUMP (LangSys) -{ - int i; - - DUMP_FUINT (LangSys, LookupOrderOffset); - DUMP_FUINT (LangSys, ReqFeatureIndex); - DUMP_FUINT (LangSys, FeatureCount); - - for (i=0; i < LangSys->FeatureCount; i++) - DUMP("%d\n", LangSys->FeatureIndex[i]); -} - -DEF_DUMP (Script) -{ - int i; - - RECURSE (DefaultLangSys, LangSys, &Script->DefaultLangSys); - - DUMP_FUINT (Script, LangSysCount); - - for (i=0; i < Script->LangSysCount; i++) - { - do_indent (stream, indent); - fprintf (stream, ""); - Print_Tag (Script->LangSysRecord[i].LangSysTag, stream); - fprintf (stream, "\n"); - RECURSE_NUM (LangSys, i, LangSys, &Script->LangSysRecord[i].LangSys); - } -} - -DEF_DUMP (ScriptList) -{ - int i; - - DUMP_FUINT (ScriptList, ScriptCount); - - for (i=0; i < ScriptList->ScriptCount; i++) - { - do_indent (stream, indent); - fprintf (stream, ""); - Print_Tag (ScriptList->ScriptRecord[i].ScriptTag, stream); - fprintf (stream, "\n"); - RECURSE_NUM (Script, i, Script, &ScriptList->ScriptRecord[i].Script); - } -} - -DEF_DUMP (Feature) -{ - int i; - - DUMP_FUINT (Feature, FeatureParams); - DUMP_FUINT (Feature, LookupListCount); - - for (i=0; i < Feature->LookupListCount; i++) - DUMP("%d\n", Feature->LookupListIndex[i]); -} - -DEF_DUMP (MarkArray) -{ - int i; - - DUMP_FUINT (MarkArray, MarkCount); - - for (i=0; i < MarkArray->MarkCount; i++) { - TTO_MarkRecord *r = &MarkArray->MarkRecord[i]; - DUMP(" \n", i); - DUMP(" %d\n", r->Class ); - DUMP(" %d\n", r->MarkAnchor.PosFormat ); - DUMP("\n"); - } -} - -DEF_DUMP (FeatureList) -{ - int i; - - DUMP_FUINT (FeatureList, FeatureCount); - - for (i=0; i < FeatureList->FeatureCount; i++) - { - do_indent (stream, indent); - fprintf (stream, "", i); - Print_Tag (FeatureList->FeatureRecord[i].FeatureTag, stream); - fprintf (stream, "\n"); - RECURSE_NUM (Feature, i, Feature, &FeatureList->FeatureRecord[i].Feature); - } -} - -DEF_DUMP (Coverage) -{ - DUMP_FUINT (Coverage, CoverageFormat); - - if (Coverage->CoverageFormat == 1) { - int i; - DUMP_FUINT (&Coverage->cf.cf1, GlyphCount); - - for (i = 0; i < Coverage->cf.cf1.GlyphCount; i++) - DUMP("%#4x \n", Coverage->cf.cf1.GlyphArray[i], i); - } else { - int i; - TTO_CoverageFormat2 *cf2 = &Coverage->cf.cf2; - for ( i = 0; i < cf2->RangeCount; i++ ) { - DUMP("%4x - %4x\n", cf2->RangeRecord[i].Start, cf2->RangeRecord[i].End ); - } - } -} - -DEF_DUMP (ClassDefinition) -{ - DUMP_FUINT( ClassDefinition, ClassFormat ); - DUMP_FUINT( ClassDefinition, loaded ); - - - if (ClassDefinition->ClassFormat == 1) { - int i; - TTO_ClassDefFormat1 *ClassDefFormat1 = &ClassDefinition->cd.cd1; - DUMP("\n"); - DUMP_FUINT( ClassDefFormat1, StartGlyph ); - DUMP_FUINT( ClassDefFormat1, GlyphCount ); - for ( i = 0; i < ClassDefFormat1->GlyphCount; i++ ) { - DUMP(" %d ", ClassDefFormat1->ClassValueArray[i], - ClassDefFormat1->StartGlyph+i ); - } - } - else if (ClassDefinition->ClassFormat == 2) { - int i; - TTO_ClassDefFormat2 *ClassDefFormat2 = &ClassDefinition->cd.cd2; - DUMP_FUINT (ClassDefFormat2, ClassRangeCount); - - for (i = 0; i < ClassDefFormat2->ClassRangeCount; i++) { - DUMP(" \n", i); - DUMP(" %#4x \n", ClassDefFormat2->ClassRangeRecord[i].Start); - DUMP(" %#4x\n", ClassDefFormat2->ClassRangeRecord[i].End); - DUMP(" %#4x\n", ClassDefFormat2->ClassRangeRecord[i].Class); - DUMP("\n"); - } - } else { - printf("invalid class def table!!!\n"); - } -} - -DEF_DUMP (ChainSubClassSet) -{ - int i; - DUMP("\n"); - DUMP_FUINT( ChainSubClassSet, ChainSubClassRuleCount ); - indent++; - for ( i = 0; i < ChainSubClassSet->ChainSubClassRuleCount; i++ ) { - int j; - TTO_ChainSubClassRule *rule = &ChainSubClassSet->ChainSubClassRule[i]; - DUMP(" \n", i ); - indent++; - DUMP(" \n", rule->BacktrackGlyphCount ); - for ( j = 0; j < rule->BacktrackGlyphCount; j++ ) - DUMP(" %d\n", (int)(FT_UShort) rule->Backtrack[j] ); - DUMP("\n"); - DUMP(" \n", rule->InputGlyphCount ); - for ( j = 0; j < rule->InputGlyphCount-1; j++ ) - DUMP(" %d\n", (int)(FT_UShort) rule->Input[j] ); - DUMP("\n"); - DUMP(" \n", rule->LookaheadGlyphCount ); - for ( j = 0; j < rule->LookaheadGlyphCount; j++ ) - DUMP(" %d\n", (int) (FT_UShort) rule->Lookahead[j] ); - DUMP("\n"); - for ( j = 0; j < rule->SubstCount; j++ ) { - TTO_SubstLookupRecord *r = &rule->SubstLookupRecord[j]; - DUMP(" \n", j); - indent++; - DUMP_FUINT( r, SequenceIndex ); - DUMP_FUINT( r, LookupListIndex ); - indent--; - DUMP("\n"); - } - indent--; - DUMP("\n"); - } - indent--; - DUMP("\n"); -} - - -static void -Dump_GSUB_Lookup_Single (TTO_SubTable *subtable, FILE *stream, int indent, FT_Bool is_gsub) -{ - TTO_SingleSubst *SingleSubst = &subtable->st.gsub.single; - - DUMP_FUINT (SingleSubst, SubstFormat); - RECURSE (Coverage, Coverage, &SingleSubst->Coverage); - - if (SingleSubst->SubstFormat == 1) - { - DUMP_FINT (&SingleSubst->ssf.ssf1, DeltaGlyphID); - } - else - { - int i; - - DUMP_FINT (&SingleSubst->ssf.ssf2, GlyphCount); - for (i=0; i < SingleSubst->ssf.ssf2.GlyphCount; i++) - DUMP("%#4x \n", SingleSubst->ssf.ssf2.Substitute[i], i); - } -} - -DEF_DUMP (Ligature) -{ - int i; - - DUMP_FGLYPH (Ligature, LigGlyph); - DUMP_FUINT (Ligature, ComponentCount); - - for (i=0; i < Ligature->ComponentCount - 1; i++) - DUMP("%#4x\n", Ligature->Component[i]); -} - -DEF_DUMP (LigatureSet) -{ - int i; - - DUMP_FUINT (LigatureSet, LigatureCount); - - for (i=0; i < LigatureSet->LigatureCount; i++) - RECURSE_NUM (Ligature, i, Ligature, &LigatureSet->Ligature[i]); -} - -static void -Dump_GSUB_Lookup_Ligature (TTO_SubTable *subtable, FILE *stream, int indent, FT_Bool is_gsub) -{ - int i; - TTO_LigatureSubst *LigatureSubst = &subtable->st.gsub.ligature; - - DUMP_FUINT (LigatureSubst, SubstFormat); - RECURSE (Coverage, Coverage, &LigatureSubst->Coverage); - - DUMP_FUINT (LigatureSubst, LigatureSetCount); - - for (i=0; i < LigatureSubst->LigatureSetCount; i++) - RECURSE_NUM (LigatureSet, i, LigatureSet, &LigatureSubst->LigatureSet[i]); -} - -static void -Dump_GSUB_Lookup_ContextSubst1 (TTO_ContextSubstFormat1 *csf, FILE *stream, int indent, FT_Bool is_gsub) -{ - DUMP("Not implemented!!!\n"); -} - - -static void -Dump_GSUB_Lookup_ContextSubst2 (TTO_ContextSubstFormat2 *csf, FILE *stream, int indent, FT_Bool is_gsub) -{ - DUMP_FUINT( csf, MaxContextLength ); - RECURSE (Coverage, Coverage, &csf->Coverage); - RECURSE( ClassDefinition, ClassDefinition, &csf->ClassDef ); -} - -static void -Dump_GSUB_Lookup_ContextSubst3 (TTO_ContextSubstFormat3 *csf, FILE *stream, int indent, FT_Bool is_gsub) -{ - DUMP("Not implemented!!!\n"); -} - -static void -Dump_GSUB_Lookup_Context (TTO_SubTable *subtable, FILE *stream, int indent, FT_Bool is_gsub) -{ - int i; - TTO_ContextSubst *ContextSubst = &subtable->st.gsub.context; - - DUMP_FUINT (ContextSubst, SubstFormat); - switch( ContextSubst->SubstFormat ) { - case 1: - Dump_GSUB_Lookup_ContextSubst1 (&ContextSubst->csf.csf1, stream, indent+2, is_gsub); - break; - case 2: - Dump_GSUB_Lookup_ContextSubst2 (&ContextSubst->csf.csf2, stream, indent+2, is_gsub); - break; - case 3: - Dump_GSUB_Lookup_ContextSubst3 (&ContextSubst->csf.csf3, stream, indent+2, is_gsub); - break; - default: - printf("invalid subformat!!!!!\n"); - } -} - -static void -Dump_GSUB_Lookup_ChainSubst1 (TTO_ChainContextSubstFormat1 *csf, FILE *stream, int indent, FT_Bool is_gsub) -{ - DUMP("Not implemented!!!\n"); -} -static void -Dump_GSUB_Lookup_ChainSubst2 (TTO_ChainContextSubstFormat2 *csf, FILE *stream, int indent, FT_Bool is_gsub) -{ - int i; - RECURSE (Coverage, Coverage, &csf->Coverage); - DUMP_FUINT( csf, MaxBacktrackLength ); - RECURSE( ClassDefinition, ClassDefinition, &csf->BacktrackClassDef ); - DUMP_FUINT( csf, MaxInputLength ); - RECURSE( ClassDefinition, ClassDefinition, &csf->InputClassDef ); - DUMP_FUINT( csf, MaxLookaheadLength ); - RECURSE( ClassDefinition, ClassDefinition, &csf->LookaheadClassDef ); - - DUMP_FUINT( csf, ChainSubClassSetCount ); - for ( i = 0; i < csf->ChainSubClassSetCount; i++ ) - RECURSE( ChainSubClassSet, ChainSubClassSet, &csf->ChainSubClassSet[i] ); -} -static void -Dump_GSUB_Lookup_ChainSubst3 (TTO_ChainContextSubstFormat3 *csf, FILE *stream, int indent, FT_Bool is_gsub) -{ - DUMP("Not implemented!!!\n"); -} - -static void -Dump_GSUB_Lookup_Chain (TTO_SubTable *subtable, FILE *stream, int indent, FT_Bool is_gsub) -{ - int i; - TTO_ChainContextSubst *chain = &subtable->st.gsub.chain; - - DUMP_FUINT (chain, SubstFormat); - switch( chain->SubstFormat ) { - case 1: - Dump_GSUB_Lookup_ChainSubst1 (&chain->ccsf.ccsf1, stream, indent+2, is_gsub); - break; - case 2: - Dump_GSUB_Lookup_ChainSubst2 (&chain->ccsf.ccsf2, stream, indent+2, is_gsub); - break; - case 3: - Dump_GSUB_Lookup_ChainSubst3 (&chain->ccsf.ccsf3, stream, indent+2, is_gsub); - break; - default: - printf("invalid subformat!!!!!\n"); - } -} - - -static void -Dump_Device (TTO_Device *Device, FILE *stream, int indent, FT_Bool is_gsub) -{ - int i; - int bits = 0; - int n_per; - unsigned int mask; - - DUMP_FUINT (Device, StartSize); - DUMP_FUINT (Device, EndSize); - DUMP_FUINT (Device, DeltaFormat); - switch (Device->DeltaFormat) - { - case 1: - bits = 2; - break; - case 2: - bits = 4; - break; - case 3: - bits = 8; - break; - } - - n_per = 16 / bits; - mask = (1 << bits) - 1; - mask = mask << (16 - bits); - - DUMP (""); - for (i = Device->StartSize; i <= Device->EndSize ; i++) - { - FT_UShort val = Device->DeltaValue[i / n_per]; - FT_Short signed_val = ((val << ((i % n_per) * bits)) & mask); - dump (stream, indent, "%d", signed_val >> (16 - bits)); - if (i != Device->EndSize) - DUMP (", "); - } - DUMP ("\n"); -} - -static void -Dump_ValueRecord (TTO_ValueRecord *ValueRecord, FILE *stream, int indent, FT_Bool is_gsub, FT_UShort value_format) -{ - if (value_format & HAVE_X_PLACEMENT) - DUMP_FINT (ValueRecord, XPlacement); - if (value_format & HAVE_Y_PLACEMENT) - DUMP_FINT (ValueRecord, YPlacement); - if (value_format & HAVE_X_ADVANCE) - DUMP_FINT (ValueRecord, XAdvance); - if (value_format & HAVE_Y_ADVANCE) - DUMP_FINT (ValueRecord, XAdvance); - if (value_format & HAVE_X_PLACEMENT_DEVICE) - RECURSE (Device, Device, &ValueRecord->XPlacementDevice); - if (value_format & HAVE_Y_PLACEMENT_DEVICE) - RECURSE (Device, Device, &ValueRecord->YPlacementDevice); - if (value_format & HAVE_X_ADVANCE_DEVICE) - RECURSE (Device, Device, &ValueRecord->XAdvanceDevice); - if (value_format & HAVE_Y_ADVANCE_DEVICE) - RECURSE (Device, Device, &ValueRecord->YAdvanceDevice); - if (value_format & HAVE_X_ID_PLACEMENT) - DUMP_FUINT (ValueRecord, XIdPlacement); - if (value_format & HAVE_Y_ID_PLACEMENT) - DUMP_FUINT (ValueRecord, YIdPlacement); - if (value_format & HAVE_X_ID_ADVANCE) - DUMP_FUINT (ValueRecord, XIdAdvance); - if (value_format & HAVE_Y_ID_ADVANCE) - DUMP_FUINT (ValueRecord, XIdAdvance); -} - -static void -Dump_GPOS_Lookup_Single (TTO_SubTable *subtable, FILE *stream, int indent, FT_Bool is_gsub) -{ - TTO_SinglePos *SinglePos = &subtable->st.gpos.single; - - DUMP_FUINT (SinglePos, PosFormat); - RECURSE (Coverage, Coverage, &SinglePos->Coverage); - - DUMP_FUINT (SinglePos, ValueFormat); - - if (SinglePos->PosFormat == 1) - { - DUMP_VALUE_RECORD (&SinglePos->spf.spf1.Value, SinglePos->ValueFormat); - } - else - { - int i; - - DUMP_FUINT (&SinglePos->spf.spf2, ValueCount); - for (i = 0; i < SinglePos->spf.spf2.ValueCount; i++) - DUMP_VALUE_RECORD (&SinglePos->spf.spf2.Value[i], SinglePos->ValueFormat); - } -} - -static void -Dump_PairValueRecord (TTO_PairValueRecord *PairValueRecord, FILE *stream, int indent, FT_Bool is_gsub, FT_UShort ValueFormat1, FT_UShort ValueFormat2) -{ - DUMP_FUINT (PairValueRecord, SecondGlyph); - DUMP_VALUE_RECORD (&PairValueRecord->Value1, ValueFormat1); - DUMP_VALUE_RECORD (&PairValueRecord->Value2, ValueFormat2); -} - -static void -Dump_PairSet (TTO_PairSet *PairSet, FILE *stream, int indent, FT_Bool is_gsub, FT_UShort ValueFormat1, FT_UShort ValueFormat2) -{ - int i; - DUMP_FUINT (PairSet, PairValueCount); - - for (i = 0; i < PairSet->PairValueCount; i++) - { - DUMP ("\n"); - Dump_PairValueRecord (&PairSet->PairValueRecord[i], stream, indent + 1, is_gsub, ValueFormat1, ValueFormat2); - DUMP ("\n"); - } -} - -static void -Dump_GPOS_Lookup_Pair (TTO_SubTable *subtable, FILE *stream, int indent, FT_Bool is_gsub) -{ - TTO_PairPos *PairPos = &subtable->st.gpos.pair; - - DUMP_FUINT (PairPos, PosFormat); - RECURSE (Coverage, Coverage, &PairPos->Coverage); - - DUMP_FUINT (PairPos, ValueFormat1); - DUMP_FUINT (PairPos, ValueFormat2); - - if (PairPos->PosFormat == 1) - { - int i; - - DUMP_FUINT (&PairPos->ppf.ppf1, PairSetCount); - for (i = 0; i < PairPos->ppf.ppf1.PairSetCount; i++) - { - DUMP ("\n"); - Dump_PairSet (&PairPos->ppf.ppf1.PairSet[i], stream, indent + 1, is_gsub, PairPos->ValueFormat1, PairPos->ValueFormat2); - DUMP ("\n"); - } - } - else - { - } -} - -static void -Dump_GPOS_Lookup_Markbase (TTO_SubTable *subtable, FILE *stream, int indent, FT_Bool is_gsub) -{ - int i; - TTO_MarkBasePos *markbase = &subtable->st.gpos.markbase; - - DUMP_FUINT( markbase, PosFormat ); - RECURSE( Coverage, Coverage, &markbase->MarkCoverage ); - RECURSE( Coverage, Coverage, &markbase->BaseCoverage ); - DUMP_FUINT( markbase, ClassCount ); - RECURSE( MarkArray, MarkArray, &markbase->MarkArray ); - - DUMP("\n"); - indent++; - for ( i = 0; i < markbase->BaseArray.BaseCount; i++ ) { - int j; - TTO_BaseRecord *r = &markbase->BaseArray.BaseRecord[i]; - DUMP(" \n", i); - for ( j = 0; j < markbase->ClassCount; j++ ) { - DUMP(" %d\n", r->BaseAnchor->PosFormat ); - } - DUMP("\n" ); - } - indent--; - DUMP("\n"); -} - - -DEF_DUMP (Lookup) -{ - int i; - const char *lookup_name = NULL; - void (*lookup_func) (TTO_SubTable *subtable, FILE *stream, int indent, FT_Bool is_gsub) = NULL; - - if (is_gsub) - { - switch (Lookup->LookupType) - { - case GSUB_LOOKUP_SINGLE: - lookup_name = "SINGLE"; - lookup_func = Dump_GSUB_Lookup_Single; - break; - case GSUB_LOOKUP_MULTIPLE: - lookup_name = "MULTIPLE"; - break; - case GSUB_LOOKUP_ALTERNATE: - lookup_name = "ALTERNATE"; - break; - case GSUB_LOOKUP_LIGATURE: - lookup_name = "LIGATURE"; - lookup_func = Dump_GSUB_Lookup_Ligature; - break; - case GSUB_LOOKUP_CONTEXT: - lookup_name = "CONTEXT"; - lookup_func = Dump_GSUB_Lookup_Context; - break; - case GSUB_LOOKUP_CHAIN: - lookup_name = "CHAIN"; - lookup_func = Dump_GSUB_Lookup_Chain; - break; - } - } - else - { - switch (Lookup->LookupType) - { - case GPOS_LOOKUP_SINGLE: - lookup_name = "SINGLE"; - lookup_func = Dump_GPOS_Lookup_Single; - break; - case GPOS_LOOKUP_PAIR: - lookup_name = "PAIR"; - lookup_func = Dump_GPOS_Lookup_Pair; - break; - case GPOS_LOOKUP_CURSIVE: - lookup_name = "CURSIVE"; - break; - case GPOS_LOOKUP_MARKBASE: - lookup_name = "MARKBASE"; - lookup_func = Dump_GPOS_Lookup_Markbase; - break; - case GPOS_LOOKUP_MARKLIG: - lookup_name = "MARKLIG"; - break; - case GPOS_LOOKUP_MARKMARK: - lookup_name = "MARKMARK"; - lookup_func = Dump_GPOS_Lookup_Markbase; - break; - case GPOS_LOOKUP_CONTEXT: - lookup_name = "CONTEXT"; - break; - case GPOS_LOOKUP_CHAIN: - lookup_name = "CHAIN"; - break; - } - } - - DUMP("%s\n", lookup_name); - - for (i=0; i < Lookup->SubTableCount; i++) - { - DUMP ("\n"); - if (lookup_func) - (*lookup_func) (&Lookup->SubTable[i], stream, indent + 1, is_gsub); - DUMP ("\n"); - } -} - -DEF_DUMP (LookupList) -{ - int i; - - DUMP_FUINT (LookupList, LookupCount); - - for (i=0; i < LookupList->LookupCount; i++) - RECURSE_NUM (Lookup, i, Lookup, &LookupList->Lookup[i]); -} - -void -TT_Dump_GSUB_Table (TTO_GSUB gsub, FILE *stream) -{ - int indent = 0; - FT_Bool is_gsub = 1; - - RECURSE (ScriptList, ScriptList, &gsub->ScriptList); - RECURSE (FeatureList, FeatureList, &gsub->FeatureList); - RECURSE (LookupList, LookupList, &gsub->LookupList); -} - -void -TT_Dump_GPOS_Table (TTO_GPOS gpos, FILE *stream) -{ - int indent = 0; - FT_Bool is_gsub = 0; - - RECURSE (ScriptList, ScriptList, &gpos->ScriptList); - RECURSE (FeatureList, FeatureList, &gpos->FeatureList); - RECURSE (LookupList, LookupList, &gpos->LookupList); -} diff -urN qt-x11-free-3.3.5/src/3rdparty/opentype/disasm.h qt-x11-3/src/3rdparty/opentype/disasm.h --- qt-x11-free-3.3.5/src/3rdparty/opentype/disasm.h 2003-04-09 12:30:31.000000000 +0300 +++ qt-x11-3/src/3rdparty/opentype/disasm.h 1970-01-01 02:00:00.000000000 +0200 @@ -1,26 +0,0 @@ -/* Pango - * disasm.h: Dump OpenType layout tables - * - * Copyright (C) 2000 Red Hat Software - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include -#include "ftxopen.h" - -void TT_Dump_GSUB_Table (TTO_GSUB gsub, FILE *stream); -void TT_Dump_GPOS_Table (TTO_GPOS gpos, FILE *stream); diff -urN qt-x11-free-3.3.5/src/3rdparty/opentype/fterrcompat.h qt-x11-3/src/3rdparty/opentype/fterrcompat.h --- qt-x11-free-3.3.5/src/3rdparty/opentype/fterrcompat.h 2003-04-09 12:30:31.000000000 +0300 +++ qt-x11-3/src/3rdparty/opentype/fterrcompat.h 1970-01-01 02:00:00.000000000 +0200 @@ -1,49 +0,0 @@ - -#ifndef FTERRCOMPAT_H -#define FTERRCOMPAT_H - -#ifdef HAVE_FREETYPE_2_0_3 -#include -#else -#define TT_Err_Ok FT_Err_Ok -#define TT_Err_Invalid_Argument FT_Err_Invalid_Argument -#define TT_Err_Invalid_Face_Handle FT_Err_Invalid_Face_Handle -#define TT_Err_Table_Missing FT_Err_Table_Missing -#endif /* HAVE_FREETYPE_2_0_3 */ - -/* Compat macros for name changes in FreeType 2.1.0 - */ -#if (FREETYPE_MAJOR == 2) && (FREETYPE_MINOR >= 1) - -#define FILE_Pos() FT_STREAM_POS() -#define FILE_Seek( position ) FT_STREAM_SEEK( position) - -#define ACCESS_Frame( size ) FT_FRAME_ENTER( size ) -#define FORGET_Frame() FT_FRAME_EXIT() - -#define GET_Char() FT_GET_CHAR() -#define GET_Byte() FT_GET_BYTE() -#define GET_Short() FT_GET_SHORT() -#define GET_UShort() FT_GET_USHORT() -#define GET_Offset() FT_GET_OFF3() -#define GET_UOffset() FT_GET_UOFF3() -#define GET_Long() FT_GET_LONG() -#define GET_ULong() FT_GET_ULONG() -#define GET_Tag4() FT_GET_TAG4() - -#define ALLOC_ARRAY( _pointer_, _count_, _type_ ) \ - FT_SET_ERROR (FT_MEM_ALLOC_ARRAY( _pointer_, _count_, _type_)) - -/* FT_MEM_REALLOC macro broken in 2.1.0 */ -#define REALLOC_ARRAY( _pointer_, _old_, _new_, _type_ ) \ - FT_SET_ERROR ( FT_MEM_REALLOC( _pointer_, (_old_) * sizeof ( _type_ ), \ - (_new_) * sizeof ( _type_ ) ) ) - -#define ALLOC( _pointer_, _size_ ) FT_ALLOC( _pointer_, _size_ ) -#define FREE( _pointer_ ) FT_FREE( _pointer_ ) - -#define MEM_Copy( dest, source, count ) FT_MEM_COPY( dest, source, count ) - -#endif /* >= 2.1.0 */ - -#endif /* FTERRCOMPAT_H */ diff -urN qt-x11-free-3.3.5/src/3rdparty/opentype/ftglue.c qt-x11-3/src/3rdparty/opentype/ftglue.c --- qt-x11-free-3.3.5/src/3rdparty/opentype/ftglue.c 1970-01-01 02:00:00.000000000 +0200 +++ qt-x11-3/src/3rdparty/opentype/ftglue.c 2005-10-17 10:33:52.000000000 +0300 @@ -0,0 +1,349 @@ +/* ftglue.c: Glue code for compiling the OpenType code from + * FreeType 1 using only the public API of FreeType 2 + * + * By David Turner, The FreeType Project (www.freetype.org) + * + * This code is explicitely put in the public domain + * + * See ftglue.h for more information. + */ + +#include "ftglue.h" + +#if 0 +#include +#define LOG(x) ftglue_log x + +static void +ftglue_log( const char* format, ... ) +{ + va_list ap; + + va_start( ap, format ); + vfprintf( stderr, format, ap ); + va_end( ap ); +} + +#else +#define LOG(x) do {} while (0) +#endif + +/* only used internally */ +static FT_Pointer +ftglue_qalloc( FT_Memory memory, + FT_ULong size, + FT_Error *perror ) +{ + FT_Error error = 0; + FT_Pointer block = NULL; + + if ( size > 0 ) + { + block = memory->alloc( memory, size ); + if ( !block ) + error = FT_Err_Out_Of_Memory; + } + + *perror = error; + return block; +} + +#undef QALLOC /* just in case */ +#define QALLOC(ptr,size) ( (ptr) = ftglue_qalloc( memory, (size), &error ), error != 0 ) + + +FTGLUE_APIDEF( FT_Pointer ) +ftglue_alloc( FT_Memory memory, + FT_ULong size, + FT_Error *perror ) +{ + FT_Error error = 0; + FT_Pointer block = NULL; + + if ( size > 0 ) + { + block = memory->alloc( memory, size ); + if ( !block ) + error = FT_Err_Out_Of_Memory; + else + memset( (char*)block, 0, (size_t)size ); + } + + *perror = error; + return block; +} + + +FTGLUE_APIDEF( FT_Pointer ) +ftglue_realloc( FT_Memory memory, + FT_Pointer block, + FT_ULong old_size, + FT_ULong new_size, + FT_Error *perror ) +{ + FT_Pointer block2 = NULL; + FT_Error error = 0; + + if ( old_size == 0 || block == NULL ) + { + block2 = ftglue_alloc( memory, new_size, &error ); + } + else if ( new_size == 0 ) + { + ftglue_free( memory, block ); + } + else + { + block2 = memory->realloc( memory, old_size, new_size, block ); + if ( block2 == NULL ) + error = FT_Err_Out_Of_Memory; + else if ( new_size > old_size ) + memset( (char*)block2 + old_size, 0, (size_t)(new_size - old_size) ); + } + + if ( !error ) + block = block2; + + *perror = error; + return block; +} + + +FTGLUE_APIDEF( void ) +ftglue_free( FT_Memory memory, + FT_Pointer block ) +{ + if ( block ) + memory->free( memory, block ); +} + + +FTGLUE_APIDEF( FT_Long ) +ftglue_stream_pos( FT_Stream stream ) +{ + LOG(( "ftglue:stream:pos() -> %ld\n", stream->pos )); + return stream->pos; +} + + +FTGLUE_APIDEF( FT_Error ) +ftglue_stream_seek( FT_Stream stream, + FT_Long pos ) +{ + FT_Error error = 0; + + stream->pos = pos; + if ( stream->read ) + { + if ( stream->read( stream, pos, 0, 0 ) ) + error = FT_Err_Invalid_Stream_Operation; + } + else if ( pos > (FT_Long)stream->size ) + error = FT_Err_Invalid_Stream_Operation; + + LOG(( "ftglue:stream:seek(%ld) -> %d\n", pos, error )); + return error; +} + + +FTGLUE_APIDEF( FT_Error ) +ftglue_stream_frame_enter( FT_Stream stream, + FT_ULong count ) +{ + FT_Error error = FT_Err_Ok; + FT_ULong read_bytes; + + if ( stream->read ) + { + /* allocate the frame in memory */ + FT_Memory memory = stream->memory; + + + if ( QALLOC( stream->base, count ) ) + goto Exit; + + /* read it */ + read_bytes = stream->read( stream, stream->pos, + stream->base, count ); + if ( read_bytes < count ) + { + FREE( stream->base ); + error = FT_Err_Invalid_Stream_Operation; + } + stream->cursor = stream->base; + stream->limit = stream->cursor + count; + stream->pos += read_bytes; + } + else + { + /* check current and new position */ + if ( stream->pos >= stream->size || + stream->pos + count > stream->size ) + { + error = FT_Err_Invalid_Stream_Operation; + goto Exit; + } + + /* set cursor */ + stream->cursor = stream->base + stream->pos; + stream->limit = stream->cursor + count; + stream->pos += count; + } + +Exit: + LOG(( "ftglue:stream:frame_enter(%ld) -> %d\n", count, error )); + return error; +} + + +FTGLUE_APIDEF( void ) +ftglue_stream_frame_exit( FT_Stream stream ) +{ + if ( stream->read ) + { + FT_Memory memory = stream->memory; + + FREE( stream->base ); + } + stream->cursor = 0; + stream->limit = 0; + + LOG(( "ftglue:stream:frame_exit()\n" )); +} + + +FTGLUE_APIDEF( FT_Byte ) +ftglue_stream_get_byte( FT_Stream stream ) +{ + FT_Byte result = 0; + + if ( stream->cursor < stream->limit ) + result = *stream->cursor++; + + return result; +} + + +FTGLUE_APIDEF( FT_Short ) +ftglue_stream_get_short( FT_Stream stream ) +{ + FT_Byte* p; + FT_Short result = 0; + + p = stream->cursor; + if ( p + 2 <= stream->limit ) + { + result = (FT_Short)((p[0] << 8) | p[1]); + stream->cursor = p+2; + } + return result; +} + + +FTGLUE_APIDEF( FT_Long ) +ftglue_stream_get_long( FT_Stream stream ) +{ + FT_Byte* p; + FT_Long result = 0; + + p = stream->cursor; + if ( p + 4 <= stream->limit ) + { + result = (FT_Long)(((FT_Long)p[0] << 24) | + ((FT_Long)p[1] << 16) | + ((FT_Long)p[2] << 8) | + p[3] ); + stream->cursor = p+4; + } + return result; +} + + +FTGLUE_APIDEF( FT_Error ) +ftglue_face_goto_table( FT_Face face, + FT_ULong the_tag, + FT_Stream stream ) +{ + FT_Error error; + + LOG(( "ftglue_face_goto_table( %p, %c%c%c%c, %p )\n", + face, + (int)((the_tag >> 24) & 0xFF), + (int)((the_tag >> 16) & 0xFF), + (int)((the_tag >> 8) & 0xFF), + (int)(the_tag & 0xFF), + stream )); + + if ( !FT_IS_SFNT(face) ) + { + LOG(( "not a SFNT face !!\n" )); + error = FT_Err_Invalid_Face_Handle; + } + else + { + /* parse the directory table directly, without using + * FreeType's built-in data structures + */ + FT_ULong offset = 0; + FT_UInt count, nn; + + if ( face->num_faces > 1 ) + { + /* deal with TrueType collections */ + FT_ULong offset; + + LOG(( ">> This is a TrueType Collection\n" )); + + if ( FILE_Seek( 12 + face->face_index*4 ) || + ACCESS_Frame( 4 ) ) + goto Exit; + + offset = GET_ULong(); + + FORGET_Frame(); + } + + LOG(( "TrueType offset = %ld\n", offset )); + + if ( FILE_Seek( offset+4 ) || + ACCESS_Frame( 2 ) ) + goto Exit; + + count = GET_UShort(); + + FORGET_Frame(); + + if ( FILE_Seek( offset+12 ) || + ACCESS_Frame( count*16 ) ) + goto Exit; + + for ( nn = 0; nn < count; nn++ ) + { + FT_ULong tag = GET_ULong(); + FT_ULong checksum = GET_ULong(); + FT_ULong start = GET_ULong(); + FT_ULong size = GET_ULong(); + + FT_UNUSED(checksum); + FT_UNUSED(size); + + if ( tag == the_tag ) + { + LOG(( "TrueType table (start: %ld) (size: %ld)\n", start, size )); + error = ftglue_stream_seek( stream, offset+start ); + goto FoundIt; + } + } + error = TT_Err_Table_Missing; + + FoundIt: + FORGET_Frame(); + } + +Exit: + LOG(( "TrueType error=%d\n", error )); + + return error; +} + +#undef QALLOC diff -urN qt-x11-free-3.3.5/src/3rdparty/opentype/ftglue.h qt-x11-3/src/3rdparty/opentype/ftglue.h --- qt-x11-free-3.3.5/src/3rdparty/opentype/ftglue.h 1970-01-01 02:00:00.000000000 +0200 +++ qt-x11-3/src/3rdparty/opentype/ftglue.h 2005-10-17 10:33:52.000000000 +0300 @@ -0,0 +1,162 @@ +/* ftglue.c: Glue code for compiling the OpenType code from + * FreeType 1 using only the public API of FreeType 2 + * + * By David Turner, The FreeType Project (www.freetype.org) + * + * This code is explicitely put in the public domain + * + * ========================================================================== + * + * the OpenType parser codes was originally written as an extension to + * FreeType 1.x. As such, its source code was embedded within the library, + * and used many internal FreeType functions to deal with memory and + * stream i/o. + * + * When it was 'salvaged' for Pango and Qt, the code was "ported" to FreeType 2, + * which basically means that some macro tricks were performed in order to + * directly access FT2 _internal_ functions. + * + * these functions were never part of FT2 public API, and _did_ change between + * various releases. This created chaos for many users: when they upgraded the + * FreeType library on their system, they couldn't run Gnome anymore since + * Pango refused to link. + * + * Very fortunately, it's possible to completely avoid this problem because + * the FT_StreamRec and FT_MemoryRec structure types, which describe how + * memory and stream implementations interface with the rest of the font + * library, have always been part of the public API, and never changed. + * + * What we do thus is re-implement, within the OpenType parser, the few + * functions that depend on them. This only adds one or two kilobytes of + * code, and ensures that the parser can work with _any_ version + * of FreeType installed on your system. How sweet... ! + * + * Note that we assume that Pango doesn't use any other internal functions + * from FreeType. It used to in old versions, but this should no longer + * be the case. (crossing my fingers). + * + * - David Turner + * - The FreeType Project (www.freetype.org) + * + * PS: This "glue" code is explicitely put in the public domain + */ +#ifndef __OPENTYPE_FTGLUE_H__ +#define __OPENTYPE_FTGLUE_H__ + +#include +#include FT_FREETYPE_H + +FT_BEGIN_HEADER + +#ifndef FALSE +#define FALSE 0 +#endif +#ifndef TRUE +#define TRUE 1 +#endif + +/* utility macros */ +#define TT_Err_Ok FT_Err_Ok +#define TT_Err_Invalid_Argument FT_Err_Invalid_Argument +#define TT_Err_Invalid_Face_Handle FT_Err_Invalid_Face_Handle +#define TT_Err_Table_Missing FT_Err_Table_Missing + +#define SET_ERR(c) ( (error = (c)) != 0 ) + +#ifndef FTGLUE_API +#define FTGLUE_API(x) extern x +#endif + +#ifndef FTGLUE_APIDEF +#define FTGLUE_APIDEF(x) x +#endif + +/* stream macros used by the OpenType parser */ +#define FILE_Pos() ftglue_stream_pos( stream ) +#define FILE_Seek(pos) SET_ERR( ftglue_stream_seek( stream, pos ) ) +#define ACCESS_Frame(size) SET_ERR( ftglue_stream_frame_enter( stream, size ) ) +#define FORGET_Frame() ftglue_stream_frame_exit( stream ) + +#define GET_Byte() ftglue_stream_get_byte( stream ) +#define GET_Short() ftglue_stream_get_short( stream ) +#define GET_Long() ftglue_stream_get_long( stream ) + +#define GET_Char() ((FT_Char)GET_Byte()) +#define GET_UShort() ((FT_UShort)GET_Short()) +#define GET_ULong() ((FT_ULong)GET_Long()) +#define GET_Tag4() GET_ULong() + +FTGLUE_API( FT_Long ) +ftglue_stream_pos( FT_Stream stream ); + +FTGLUE_API( FT_Error ) +ftglue_stream_seek( FT_Stream stream, + FT_Long pos ); + +FTGLUE_API( FT_Error ) +ftglue_stream_frame_enter( FT_Stream stream, + FT_ULong size ); + +FTGLUE_API( void ) +ftglue_stream_frame_exit( FT_Stream stream ); + +FTGLUE_API( FT_Byte ) +ftglue_stream_get_byte( FT_Stream stream ); + +FTGLUE_API( FT_Short ) +ftglue_stream_get_short( FT_Stream stream ); + +FTGLUE_API( FT_Long ) +ftglue_stream_get_long( FT_Stream stream ); + +FTGLUE_API( FT_Error ) +ftglue_face_goto_table( FT_Face face, + FT_ULong tag, + FT_Stream stream ); + +/* memory macros used by the OpenType parser */ +#define ALLOC(_ptr,_size) \ + ( (_ptr) = ftglue_alloc( memory, _size, &error ), error != 0 ) + +#define REALLOC(_ptr,_oldsz,_newsz) \ + ( (_ptr) = ftglue_realloc( memory, (_ptr), (_oldsz), (_newsz), &error ), error != 0 ) + +#define FREE(_ptr) \ + do { \ + if ( (_ptr) ) \ + { \ + ftglue_free( memory, _ptr ); \ + _ptr = NULL; \ + } \ + } while (0) + +#define ALLOC_ARRAY(_ptr,_count,_type) \ + ALLOC(_ptr,(_count)*sizeof(_type)) + +#define REALLOC_ARRAY(_ptr,_oldcnt,_newcnt,_type) \ + REALLOC(_ptr,(_oldcnt)*sizeof(_type),(_newcnt)*sizeof(_type)) + +#define MEM_Copy(dest,source,count) memcpy( (char*)(dest), (const char*)(source), (size_t)(count) ) + + +FTGLUE_API( FT_Pointer ) +ftglue_alloc( FT_Memory memory, + FT_ULong size, + FT_Error *perror_ ); + +FTGLUE_API( FT_Pointer ) +ftglue_realloc( FT_Memory memory, + FT_Pointer block, + FT_ULong old_size, + FT_ULong new_size, + FT_Error *perror_ ); + +FTGLUE_API( void ) +ftglue_free( FT_Memory memory, + FT_Pointer block ); + +/* */ + +FT_END_HEADER + +#endif /* __OPENTYPE_FTGLUE_H__ */ diff -urN qt-x11-free-3.3.5/src/3rdparty/opentype/FT-license.txt qt-x11-3/src/3rdparty/opentype/FT-license.txt --- qt-x11-free-3.3.5/src/3rdparty/opentype/FT-license.txt 1970-01-01 02:00:00.000000000 +0200 +++ qt-x11-3/src/3rdparty/opentype/FT-license.txt 2005-10-17 10:33:52.000000000 +0300 @@ -0,0 +1,28 @@ + +The FreeType 2 font engine is copyrighted work and cannot be used +legally without a software license. In order to make this project +usable to a vast majority of developers, we distribute it under two +mutually exclusive open-source licenses. + +This means that *you* must choose *one* of the two licenses described +below, then obey all its terms and conditions when using FreeType 2 in +any of your projects or products. + + - The FreeType License, found in the file `FTL.TXT', which is similar + to the original BSD license *with* an advertising clause that forces + you to explicitly cite the FreeType project in your product's + documentation. All details are in the license file. This license + is suited to products which don't use the GNU General Public + License. + + - The GNU General Public License version 2, found in `GPL.TXT' (any + later version can be used also), for programs which already use the + GPL. Note that the FTL is incompatible with the GPL due to its + advertisement clause. + +The contributed PCF driver comes with a license similar to that of the X +Window System. It is compatible to the above two licenses (see file +src/pcf/readme). + + +--- end of LICENSE.TXT --- diff -urN qt-x11-free-3.3.5/src/3rdparty/opentype/FTL.TXT qt-x11-3/src/3rdparty/opentype/FTL.TXT --- qt-x11-free-3.3.5/src/3rdparty/opentype/FTL.TXT 1970-01-01 02:00:00.000000000 +0200 +++ qt-x11-3/src/3rdparty/opentype/FTL.TXT 2005-10-17 10:33:52.000000000 +0300 @@ -0,0 +1,174 @@ + The FreeType Project LICENSE + ---------------------------- + + 2002-Apr-11 + + Copyright 1996-2002 by + David Turner, Robert Wilhelm, and Werner Lemberg + + + +Introduction +============ + + The FreeType Project is distributed in several archive packages; + some of them may contain, in addition to the FreeType font engine, + various tools and contributions which rely on, or relate to, the + FreeType Project. + + This license applies to all files found in such packages, and + which do not fall under their own explicit license. The license + affects thus the FreeType font engine, the test programs, + documentation and makefiles, at the very least. + + This license was inspired by the BSD, Artistic, and IJG + (Independent JPEG Group) licenses, which all encourage inclusion + and use of free software in commercial and freeware products + alike. As a consequence, its main points are that: + + o We don't promise that this software works. However, we will be + interested in any kind of bug reports. (`as is' distribution) + + o You can use this software for whatever you want, in parts or + full form, without having to pay us. (`royalty-free' usage) + + o You may not pretend that you wrote this software. If you use + it, or only parts of it, in a program, you must acknowledge + somewhere in your documentation that you have used the + FreeType code. (`credits') + + We specifically permit and encourage the inclusion of this + software, with or without modifications, in commercial products. + We disclaim all warranties covering The FreeType Project and + assume no liability related to The FreeType Project. + + + Finally, many people asked us for a preferred form for a + credit/disclaimer to use in compliance with this license. We thus + encourage you to use the following text: + + """ + Portions of this software are copyright © 1996-2002 The FreeType + Project (www.freetype.org). All rights reserved. + """ + + +Legal Terms +=========== + +0. Definitions +-------------- + + Throughout this license, the terms `package', `FreeType Project', + and `FreeType archive' refer to the set of files originally + distributed by the authors (David Turner, Robert Wilhelm, and + Werner Lemberg) as the `FreeType Project', be they named as alpha, + beta or final release. + + `You' refers to the licensee, or person using the project, where + `using' is a generic term including compiling the project's source + code as well as linking it to form a `program' or `executable'. + This program is referred to as `a program using the FreeType + engine'. + + This license applies to all files distributed in the original + FreeType Project, including all source code, binaries and + documentation, unless otherwise stated in the file in its + original, unmodified form as distributed in the original archive. + If you are unsure whether or not a particular file is covered by + this license, you must contact us to verify this. + + The FreeType Project is copyright (C) 1996-2000 by David Turner, + Robert Wilhelm, and Werner Lemberg. All rights reserved except as + specified below. + +1. No Warranty +-------------- + + THE FREETYPE PROJECT IS PROVIDED `AS IS' WITHOUT WARRANTY OF ANY + KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + PURPOSE. IN NO EVENT WILL ANY OF THE AUTHORS OR COPYRIGHT HOLDERS + BE LIABLE FOR ANY DAMAGES CAUSED BY THE USE OR THE INABILITY TO + USE, OF THE FREETYPE PROJECT. + +2. Redistribution +----------------- + + This license grants a worldwide, royalty-free, perpetual and + irrevocable right and license to use, execute, perform, compile, + display, copy, create derivative works of, distribute and + sublicense the FreeType Project (in both source and object code + forms) and derivative works thereof for any purpose; and to + authorize others to exercise some or all of the rights granted + herein, subject to the following conditions: + + o Redistribution of source code must retain this license file + (`FTL.TXT') unaltered; any additions, deletions or changes to + the original files must be clearly indicated in accompanying + documentation. The copyright notices of the unaltered, + original files must be preserved in all copies of source + files. + + o Redistribution in binary form must provide a disclaimer that + states that the software is based in part of the work of the + FreeType Team, in the distribution documentation. We also + encourage you to put an URL to the FreeType web page in your + documentation, though this isn't mandatory. + + These conditions apply to any software derived from or based on + the FreeType Project, not just the unmodified files. If you use + our work, you must acknowledge us. However, no fee need be paid + to us. + +3. Advertising +-------------- + + Neither the FreeType authors and contributors nor you shall use + the name of the other for commercial, advertising, or promotional + purposes without specific prior written permission. + + We suggest, but do not require, that you use one or more of the + following phrases to refer to this software in your documentation + or advertising materials: `FreeType Project', `FreeType Engine', + `FreeType library', or `FreeType Distribution'. + + As you have not signed this license, you are not required to + accept it. However, as the FreeType Project is copyrighted + material, only this license, or another one contracted with the + authors, grants you the right to use, distribute, and modify it. + Therefore, by using, distributing, or modifying the FreeType + Project, you indicate that you understand and accept all the terms + of this license. + +4. Contacts +----------- + + There are two mailing lists related to FreeType: + + o freetype@freetype.org + + Discusses general use and applications of FreeType, as well as + future and wanted additions to the library and distribution. + If you are looking for support, start in this list if you + haven't found anything to help you in the documentation. + + o devel@freetype.org + + Discusses bugs, as well as engine internals, design issues, + specific licenses, porting, etc. + + o http://www.freetype.org + + Holds the current FreeType web page, which will allow you to + download our latest development version and read online + documentation. + + You can also contact us individually at: + + David Turner + Robert Wilhelm + Werner Lemberg + + +--- end of FTL.TXT --- diff -urN qt-x11-free-3.3.5/src/3rdparty/opentype/ftxgdef.c qt-x11-3/src/3rdparty/opentype/ftxgdef.c --- qt-x11-free-3.3.5/src/3rdparty/opentype/ftxgdef.c 2004-07-29 19:35:59.000000000 +0300 +++ qt-x11-3/src/3rdparty/opentype/ftxgdef.c 2005-10-17 10:33:52.000000000 +0300 @@ -15,17 +15,13 @@ * ******************************************************************/ -#include - -#include -#include -#include - -#include "fterrcompat.h" - #include "ftxopen.h" #include "ftxopenf.h" +#include "ftglue.h" + +#include FT_TRUETYPE_TAGS_H + #define TTAG_GDEF FT_MAKE_TAG( 'G', 'D', 'E', 'F' ) static FT_Error Load_AttachList( TTO_AttachList* al, @@ -41,13 +37,6 @@ static void Free_NewGlyphClasses( TTO_GDEFHeader* gdef, FT_Memory memory ); -/* GDEF glyph classes */ - -#define UNCLASSIFIED_GLYPH 0 -#define SIMPLE_GLYPH 1 -#define LIGATURE_GLYPH 2 -#define MARK_GLYPH 3 -#define COMPONENT_GLYPH 4 /********************** @@ -140,13 +129,43 @@ #endif EXPORT_FUNC + FT_Error TT_New_GDEF_Table( FT_Face face, + TTO_GDEFHeader** retptr ) + { + FT_Error error; + FT_Memory memory = face->memory; + + TTO_GDEFHeader* gdef; + + if ( !retptr ) + return TT_Err_Invalid_Argument; + + if ( ALLOC( gdef, sizeof( *gdef ) ) ) + return error; + + gdef->memory = face->memory; + + gdef->GlyphClassDef.loaded = FALSE; + gdef->AttachList.loaded = FALSE; + gdef->LigCaretList.loaded = FALSE; + gdef->MarkAttachClassDef_offset = 0; + gdef->MarkAttachClassDef.loaded = FALSE; + + gdef->LastGlyph = 0; + gdef->NewGlyphClasses = NULL; + + *retptr = gdef; + + return TT_Err_Ok; + } + + EXPORT_FUNC FT_Error TT_Load_GDEF_Table( FT_Face face, TTO_GDEFHeader** retptr ) { FT_Error error; FT_Memory memory = face->memory; FT_Stream stream = face->stream; - TT_Face tt_face = (TT_Face)face; FT_ULong cur_offset, new_offset, base_offset; TTO_GDEFHeader* gdef; @@ -155,14 +174,12 @@ if ( !retptr ) return TT_Err_Invalid_Argument; - if (( error = tt_face->goto_table( tt_face, TTAG_GDEF, stream, 0 ) )) + if (( error = ftglue_face_goto_table( face, TTAG_GDEF, stream ) )) return error; - if ( ALLOC( gdef, sizeof( *gdef ) ) ) + if (( error = TT_New_GDEF_Table ( face, &gdef ) )) return error; - gdef->memory = face->memory; - base_offset = FILE_Pos(); /* skip version */ @@ -190,8 +207,6 @@ goto Fail0; (void)FILE_Seek( cur_offset ); } - else - gdef->GlyphClassDef.loaded = FALSE; if ( ACCESS_Frame( 2L ) ) goto Fail1; @@ -211,8 +226,6 @@ goto Fail1; (void)FILE_Seek( cur_offset ); } - else - gdef->AttachList.loaded = FALSE; if ( ACCESS_Frame( 2L ) ) goto Fail2; @@ -232,8 +245,6 @@ goto Fail2; (void)FILE_Seek( cur_offset ); } - else - gdef->LigCaretList.loaded = FALSE; /* OpenType 1.2 has introduced the `MarkAttachClassDef' field. We first have to scan the LookupFlag values to find out whether we @@ -251,18 +262,13 @@ else gdef->MarkAttachClassDef_offset = 0; - gdef->MarkAttachClassDef.loaded = FALSE; - - gdef->LastGlyph = 0; - gdef->NewGlyphClasses = NULL; - *retptr = gdef; return TT_Err_Ok; Fail3: Free_LigCaretList( &gdef->LigCaretList, memory ); - + Fail2: Free_AttachList( &gdef->AttachList, memory ); @@ -276,17 +282,19 @@ } EXPORT_FUNC - FT_Error TT_Done_GDEF_Table ( TTO_GDEFHeader* gdef ) + FT_Error TT_Done_GDEF_Table ( TTO_GDEFHeader* gdef ) { FT_Memory memory = gdef->memory; - + Free_LigCaretList( &gdef->LigCaretList, memory ); Free_AttachList( &gdef->AttachList, memory ); Free_ClassDefinition( &gdef->GlyphClassDef, memory ); Free_ClassDefinition( &gdef->MarkAttachClassDef, memory ); - + Free_NewGlyphClasses( gdef, memory ); + FREE( gdef ); + return TT_Err_Ok; } @@ -733,9 +741,9 @@ FT_UShort glyphID, FT_UShort index ) { - FT_UShort glyph_index, array_index; + FT_UShort glyph_index, array_index, count; FT_UShort byte, bits; - + TTO_ClassRangeRecord* gcrr; FT_UShort** ngc; @@ -743,12 +751,13 @@ if ( glyphID >= gdef->LastGlyph ) return 0; + count = gdef->GlyphClassDef.cd.cd2.ClassRangeCount; gcrr = gdef->GlyphClassDef.cd.cd2.ClassRangeRecord; ngc = gdef->NewGlyphClasses; - if ( glyphID < gcrr[index].Start ) + if ( index < count && glyphID < gcrr[index].Start ) { - array_index = 0; + array_index = index; if ( index == 0 ) glyph_index = glyphID; else @@ -760,7 +769,7 @@ glyph_index = glyphID - gcrr[index].End - 1; } - byte = ngc[array_index][glyph_index / 4 + 1]; + byte = ngc[array_index][glyph_index / 4]; bits = byte >> ( 16 - ( glyph_index % 4 + 1 ) * 4 ); return bits & 0x000F; @@ -772,14 +781,7 @@ FT_UShort glyphID, FT_UShort* property ) { - const FT_UShort class2glyphProp[5] = { - 0, /* UNCLASSIFIED_GLYPH */ - TTO_BASE_GLYPH, /* SIMPLE_GLYPH 1 */ - TTO_LIGATURE, /* LIGATURE_GLYPH 2 */ - TTO_MARK, /* MARK_GLYPH 3 */ - TTO_COMPONENT /* COMPONENT_GLYPH 4 */ - }; - FT_UShort klass, index; + FT_UShort class, index; FT_Error error; @@ -791,35 +793,48 @@ if ( gdef->MarkAttachClassDef.loaded ) { - error = Get_Class( &gdef->MarkAttachClassDef, glyphID, &klass, &index ); + error = Get_Class( &gdef->MarkAttachClassDef, glyphID, &class, &index ); if ( error && error != TTO_Err_Not_Covered ) return error; if ( !error ) { - *property = klass << 8; + *property = class << 8; return TT_Err_Ok; } } - if ( gdef->GlyphClassDef.loaded ) - { - error = Get_Class( &gdef->GlyphClassDef, glyphID, &klass, &index ); - if ( error && error != TTO_Err_Not_Covered ) - return error; - } - else - { - klass = 0; - index = 0; - } + error = Get_Class( &gdef->GlyphClassDef, glyphID, &class, &index ); + if ( error && error != TTO_Err_Not_Covered ) + return error; /* if we have a constructed class table, check whether additional values have been assigned */ if ( error == TTO_Err_Not_Covered && gdef->NewGlyphClasses ) - klass = Get_New_Class( gdef, glyphID, index ); + class = Get_New_Class( gdef, glyphID, index ); + + switch ( class ) + { + case UNCLASSIFIED_GLYPH: + *property = 0; + break; - *property = class2glyphProp[klass]; + case SIMPLE_GLYPH: + *property = TTO_BASE_GLYPH; + break; + + case LIGATURE_GLYPH: + *property = TTO_LIGATURE; + break; + + case MARK_GLYPH: + *property = TTO_MARK; + break; + + case COMPONENT_GLYPH: + *property = TTO_COMPONENT; + break; + } return TT_Err_Ok; } @@ -828,7 +843,7 @@ static FT_Error Make_ClassRange( TTO_ClassDefinition* cd, FT_UShort start, FT_UShort end, - FT_UShort klass, + FT_UShort class, FT_Memory memory ) { FT_Error error; @@ -853,9 +868,9 @@ crr[index].Start = start; crr[index].End = end; - crr[index].Class = klass; + crr[index].Class = class; - cd->Defined[klass] = TRUE; + cd->Defined[class] = TRUE; return TT_Err_Ok; } @@ -980,7 +995,7 @@ if ( ALLOC_ARRAY( gdef->NewGlyphClasses, gcd->cd.cd2.ClassRangeCount + 1, FT_UShort* ) ) - goto Fail2; + goto Fail3; count = gcd->cd.cd2.ClassRangeCount; gcrr = gcd->cd.cd2.ClassRangeRecord; @@ -989,34 +1004,46 @@ /* We allocate arrays for all glyphs not covered by the class range records. Each element holds four class values. */ - if ( gcrr[0].Start ) - { - if ( ALLOC_ARRAY( ngc[0], gcrr[0].Start / 4 + 1, FT_UShort ) ) - goto Fail1; - } - - for ( n = 1; n < count; n++ ) + if ( count > 0 ) { - if ( gcrr[n].Start - gcrr[n - 1].End > 1 ) - if ( ALLOC_ARRAY( ngc[n], - ( gcrr[n].Start - gcrr[n - 1].End - 1 ) / 4 + 1, - FT_UShort ) ) - goto Fail1; + if ( gcrr[0].Start ) + { + if ( ALLOC_ARRAY( ngc[0], ( gcrr[0].Start + 3 ) / 4, FT_UShort ) ) + goto Fail2; + } + + for ( n = 1; n < count; n++ ) + { + if ( gcrr[n].Start - gcrr[n - 1].End > 1 ) + if ( ALLOC_ARRAY( ngc[n], + ( gcrr[n].Start - gcrr[n - 1].End + 2 ) / 4, + FT_UShort ) ) + goto Fail1; + } + + if ( gcrr[count - 1].End != num_glyphs - 1 ) + { + if ( ALLOC_ARRAY( ngc[count], + ( num_glyphs - gcrr[count - 1].End + 2 ) / 4, + FT_UShort ) ) + goto Fail1; + } + } + else if ( num_glyphs > 0 ) + { + if ( ALLOC_ARRAY( ngc[count], + ( num_glyphs + 3 ) / 4, + FT_UShort ) ) + goto Fail2; } - - if ( gcrr[count - 1].End != num_glyphs - 1 ) - { - if ( ALLOC_ARRAY( ngc[count], - ( num_glyphs - gcrr[count - 1].End - 1 ) / 4 + 1, - FT_UShort ) ) - goto Fail1; - } - + gdef->LastGlyph = num_glyphs - 1; gdef->MarkAttachClassDef_offset = 0L; gdef->MarkAttachClassDef.loaded = FALSE; + gcd->loaded = TRUE; + return TT_Err_Ok; Fail1: @@ -1060,25 +1087,18 @@ FT_UShort property ) { FT_Error error; - FT_UShort klass, new_class, index; + FT_UShort class, new_class, index; FT_UShort byte, bits, mask; - FT_UShort array_index, glyph_index; + FT_UShort array_index, glyph_index, count; TTO_ClassRangeRecord* gcrr; FT_UShort** ngc; - if ( gdef->GlyphClassDef.loaded ) - { - error = Get_Class( &gdef->GlyphClassDef, glyphID, &klass, &index ); - if ( error && error != TTO_Err_Not_Covered ) - return error; - } - else - { - klass = 0; - index = 0; - } + error = Get_Class( &gdef->GlyphClassDef, glyphID, &class, &index ); + if ( error && error != TTO_Err_Not_Covered ) + return error; + /* we don't accept glyphs covered in `GlyphClassDef' */ if ( !error ) @@ -1110,12 +1130,13 @@ return TT_Err_Invalid_Argument; } + count = gdef->GlyphClassDef.cd.cd2.ClassRangeCount; gcrr = gdef->GlyphClassDef.cd.cd2.ClassRangeRecord; ngc = gdef->NewGlyphClasses; - if ( glyphID < gcrr[index].Start ) + if ( index < count && glyphID < gcrr[index].Start ) { - array_index = 0; + array_index = index; if ( index == 0 ) glyph_index = glyphID; else @@ -1127,41 +1148,45 @@ glyph_index = glyphID - gcrr[index].End - 1; } - byte = ngc[array_index][glyph_index / 4 + 1]; + byte = ngc[array_index][glyph_index / 4]; bits = byte >> ( 16 - ( glyph_index % 4 + 1 ) * 4 ); - klass = bits & 0x000F; + class = bits & 0x000F; /* we don't overwrite existing entries */ - if ( !klass ) + if ( !class ) { bits = new_class << ( 16 - ( glyph_index % 4 + 1 ) * 4 ); mask = ~( 0x000F << ( 16 - ( glyph_index % 4 + 1 ) * 4 ) ); - ngc[array_index][glyph_index / 4 + 1] &= mask; - ngc[array_index][glyph_index / 4 + 1] |= bits; + ngc[array_index][glyph_index / 4] &= mask; + ngc[array_index][glyph_index / 4] |= bits; } return TT_Err_Ok; } - inline FT_Error Check_Property( TTO_GDEFHeader* gdef, - FT_UShort index, + FT_Error Check_Property( TTO_GDEFHeader* gdef, + OTL_GlyphItem gitem, FT_UShort flags, FT_UShort* property ) { FT_Error error; - if ( gdef ) { FT_UShort basic_glyph_class; FT_UShort desired_attachment_class; - error = TT_GDEF_Get_Glyph_Property( gdef, index, property ); - if ( error ) - return error; + if ( gitem->gproperties == OTL_GLYPH_PROPERTIES_UNKNOWN ) + { + error = TT_GDEF_Get_Glyph_Property( gdef, gitem->gindex, &gitem->gproperties ); + if ( error ) + return error; + } + + *property = gitem->gproperties; /* If the glyph was found in the MarkAttachmentClass table, * then that class value is the high byte of the result, @@ -1178,19 +1203,18 @@ */ if ( flags & basic_glyph_class ) return TTO_Err_Not_Covered; - + /* The high byte of LookupFlags has the meaning * "ignore marks of attachment type different than * the attachment type specified." */ desired_attachment_class = flags & IGNORE_SPECIAL_MARKS; - if ( desired_attachment_class && (*property & IGNORE_SPECIAL_MARKS) ) + if ( desired_attachment_class ) { - if ( *property != desired_attachment_class ) + if ( basic_glyph_class == TTO_MARK && + *property != desired_attachment_class ) return TTO_Err_Not_Covered; } - } else { - *property = 0; } return TT_Err_Ok; diff -urN qt-x11-free-3.3.5/src/3rdparty/opentype/ftxgdef.h qt-x11-3/src/3rdparty/opentype/ftxgdef.h --- qt-x11-free-3.3.5/src/3rdparty/opentype/ftxgdef.h 2003-04-09 12:30:31.000000000 +0300 +++ qt-x11-3/src/3rdparty/opentype/ftxgdef.h 2005-10-17 10:33:52.000000000 +0300 @@ -30,6 +30,14 @@ #define TTO_Err_Invalid_GDEF_SubTable 0x1031 +/* GDEF glyph classes */ + +#define UNCLASSIFIED_GLYPH 0 +#define SIMPLE_GLYPH 1 +#define LIGATURE_GLYPH 2 +#define MARK_GLYPH 3 +#define COMPONENT_GLYPH 4 + /* GDEF glyph properties, corresponding to class values 1-4. Note that TTO_COMPONENT has no corresponding flag in the LookupFlag field. */ @@ -183,6 +191,10 @@ /* EXPORT_DEF FT_Error TT_Init_GDEF_Extension( TT_Engine engine ); */ + EXPORT_FUNC + FT_Error TT_New_GDEF_Table( FT_Face face, + TTO_GDEFHeader** retptr ); + EXPORT_DEF FT_Error TT_Load_GDEF_Table( FT_Face face, TTO_GDEFHeader** gdef ); diff -urN qt-x11-free-3.3.5/src/3rdparty/opentype/ftxgpos.c qt-x11-3/src/3rdparty/opentype/ftxgpos.c --- qt-x11-free-3.3.5/src/3rdparty/opentype/ftxgpos.c 2004-03-05 17:01:18.000000000 +0200 +++ qt-x11-3/src/3rdparty/opentype/ftxgpos.c 2005-10-17 10:33:52.000000000 +0300 @@ -21,20 +21,14 @@ sharing as much as possible with extensive use of macros. This is something for a volunteer :-) */ -#define TTAG_GPOS FT_MAKE_TAG( 'G', 'P', 'O', 'S' ) - -#include - -#include -#include -#include - -#include "fterrcompat.h" - #include "ftxopen.h" -#include "ftxgsub.h" #include "ftxopenf.h" +#include "ftglue.h" + +#include FT_TRUETYPE_TAGS_H + +#define TTAG_GPOS FT_MAKE_TAG( 'G', 'P', 'O', 'S' ) struct GPOS_Instance_ { @@ -44,8 +38,6 @@ FT_UShort load_flags; /* how the glyph should be loaded */ FT_Bool r2l; - FT_UShort first; /* the first glyph in a chain of - cursive connections */ FT_UShort last; /* the last valid glyph -- used with cursive positioning */ FT_Pos anchor_x; /* the coordinates of the anchor point */ @@ -56,133 +48,46 @@ static FT_Error GPos_Do_Glyph_Lookup( GPOS_Instance* gpi, - FT_UShort lookup_index, - TTO_GSUB_String* in, - TTO_GPOS_Data* out, - FT_UShort context_length, - int nesting_level ); - - - /* the client application must replace this with something more - meaningful if multiple master fonts are to be supported. */ -static FT_Error default_mmfunc( FT_Face face, - FT_UShort metric_id, - FT_Pos* metric_value, - void* data ) -{ - (void)face; - (void)metric_id; - (void)metric_value; - (void)data; - return TTO_Err_No_MM_Interpreter; -} - - -#if 0 -#define GPOS_ID Build_Extension_ID( 'G', 'P', 'O', 'S' ) - - /********************** - * Extension Functions - **********************/ - - static FT_Error GPOS_Create( void* ext, - FT_Stream stream ) - { - FT_Error error; - FT_Memory memory = stream->memory; - - TTO_GPOSHeader* gpos = (TTO_GPOSHeader*)ext; - FT_Long table; - - - /* by convention */ - - if ( !gpos ) - return TT_Err_Ok; - - /* a null offset indicates that there is no GPOS table */ + FT_UShort lookup_index, + OTL_Buffer buffer, + FT_UShort context_length, + int nesting_level ); - gpos->offset = 0; - /* we store the start offset and the size of the subtable */ +// #define IN_GLYPH( pos ) (buffer->in_string[(pos)].gindex) +// #define IN_ITEM( pos ) (&buffer->in_string[(pos)]) +// #define IN_CURGLYPH() (buffer->in_string[buffer->in_pos].gindex) +// #define IN_CURITEM() (&buffer->in_string[buffer->in_pos]) +// #define IN_PROPERTIES( pos ) (buffer->in_string[(pos)].properties) +// #define IN_LIGID( pos ) (buffer->in_string[(pos)].ligID) +// #define IN_COMPONENT( pos ) (buffer->in_string[(pos)].component) - table = face->lookup_table ( face, TTAG_GPOS ); - if ( table < 0 ) - return TT_Err_Ok; /* The table is optional */ - - if ( FILE_Seek( face->dirTables[table].Offset ) || - ACCESS_Frame( 4L ) ) - return error; - - gpos->offset = FILE_Pos() - 4L; /* undo ACCESS_Frame() */ - gpos->Version = GET_ULong(); - - FORGET_Frame(); - - /* a default mmfunc() handler which just returns an error */ - - gpos->mmfunc = default_mmfunc; - - /* the default glyph function is TT_Load_Glyph() */ - - gpos->gfunc = FT_Load_Glyph; - - gpos->loaded = FALSE; - - return TT_Err_Ok; - } - - - static FT_Error GPOS_Destroy( void* ext, - PFace face ) - { - TTO_GPOSHeader* gpos = (TTO_GPOSHeader*)ext; - - - /* by convention */ - - if ( !gpos ) - return TT_Err_Ok; - - if ( gpos->loaded ) - { - Free_LookupList( &gpos->LookupList, GPOS ); - Free_FeatureList( &gpos->FeatureList ); - Free_ScriptList( &gpos->ScriptList ); - } +/* the client application must replace this with something more + meaningful if multiple master fonts are to be supported. */ - return TT_Err_Ok; + static FT_Error default_mmfunc( FT_Face face, + FT_UShort metric_id, + FT_Pos* metric_value, + void* data ) + { + FT_UNUSED(face); + FT_UNUSED(metric_id); + FT_UNUSED(metric_value); + FT_UNUSED(data); + return TTO_Err_No_MM_Interpreter; } EXPORT_FUNC - FT_Error TT_Init_GPOS_Extension( TT_Engine engine ) - { - PEngine_Instance _engine = HANDLE_Engine( engine ); - - - if ( !_engine ) - return TT_Err_Invalid_Engine; - - return TT_Register_Extension( _engine, - GPOS_ID, - sizeof ( TTO_GPOSHeader ), - GPOS_Create, - GPOS_Destroy ); - } -#endif - - EXPORT_FUNC FT_Error TT_Load_GPOS_Table( FT_Face face, TTO_GPOSHeader** retptr, TTO_GDEFHeader* gdef ) { FT_ULong cur_offset, new_offset, base_offset; - /* FT_UShort i, num_lookups; */ + FT_UShort i, num_lookups; TTO_GPOSHeader* gpos; - /* TTO_Lookup* lo; */ - TT_Face tt_face = (TT_Face)face; + TTO_Lookup* lo; FT_Stream stream = face->stream; FT_Error error; @@ -195,7 +100,7 @@ if ( !stream ) return TT_Err_Invalid_Face_Handle; - if (( error = tt_face->goto_table( tt_face, TTAG_GPOS, stream, 0 ) )) + if (( error = ftglue_face_goto_table( face, TTAG_GPOS, stream ) )) return error; base_offset = FILE_Pos(); @@ -262,7 +167,6 @@ `MarkAttachClassDef_offset' is not zero (nevertheless, a build of a constructed mark attach table is not supported currently). */ -#if 0 if ( gdef && gdef->MarkAttachClassDef_offset && !gdef->MarkAttachClassDef.loaded ) { @@ -274,19 +178,6 @@ if ( lo[i].LookupFlag & IGNORE_SPECIAL_MARKS ) { if ( FILE_Seek( gdef->MarkAttachClassDef_offset ) || - ACCESS_Frame( 2L ) ) - goto Fail1; - - new_offset = GET_UShort(); - - FORGET_Frame(); - - if ( !new_offset ) - return TTO_Err_Invalid_GDEF_SubTable; - - new_offset += base_offset; - - if ( FILE_Seek( new_offset ) || ( error = Load_ClassDefinition( &gdef->MarkAttachClassDef, 256, stream ) ) != TT_Err_Ok ) goto Fail1; @@ -295,15 +186,13 @@ } } } -#endif + *retptr = gpos; return TT_Err_Ok; -#if 0 Fail1: Free_LookupList( &gpos->LookupList, GPOS, memory ); -#endif Fail2: Free_FeatureList( &gpos->FeatureList, memory ); @@ -321,7 +210,7 @@ FT_Error TT_Done_GPOS_Table( TTO_GPOSHeader* gpos ) { FT_Memory memory = gpos->memory; - + Free_LookupList( &gpos->LookupList, GPOS, memory ); Free_FeatureList( &gpos->FeatureList, memory ); Free_ScriptList( &gpos->ScriptList, memory ); @@ -349,7 +238,7 @@ { FT_Error error; FT_Memory memory = stream->memory; - + FT_ULong cur_offset, new_offset; @@ -605,7 +494,7 @@ static FT_Error Get_ValueRecord( GPOS_Instance* gpi, TTO_ValueRecord* vr, FT_UShort format, - TTO_GPOS_Data* gd ) + OTL_Position gd ) { FT_Pos value; FT_Short pixel_value; @@ -772,7 +661,7 @@ { an->af.af3.XDeviceTable.StartSize = 0; an->af.af3.XDeviceTable.EndSize = 0; - an->af.af3.XDeviceTable.DeltaValue = 0; + an->af.af3.XDeviceTable.DeltaValue = NULL; } if ( ACCESS_Frame( 2L ) ) @@ -797,7 +686,7 @@ { an->af.af3.YDeviceTable.StartSize = 0; an->af.af3.YDeviceTable.EndSize = 0; - an->af.af3.YDeviceTable.DeltaValue = 0; + an->af.af3.YDeviceTable.DeltaValue = NULL; } break; @@ -882,10 +771,10 @@ return error; if ( gpi->face->glyph->format != ft_glyph_format_outline ) - return TTO_Err_Invalid_GPOS_SubTable; + return TTO_Err_Invalid_GPOS_SubTable; ap = an->af.af2.AnchorPoint; - + outline = gpi->face->glyph->outline; /* if outline.n_points is set to zero by gfunc(), we use the @@ -961,7 +850,7 @@ return error; count = ma->MarkCount = GET_UShort(); - + FORGET_Frame(); ma->MarkRecord = NULL; @@ -1144,8 +1033,7 @@ static FT_Error Lookup_SinglePos( GPOS_Instance* gpi, TTO_SinglePos* sp, - TTO_GSUB_String* in, - TTO_GPOS_Data* out, + OTL_Buffer buffer, FT_UShort flags, FT_UShort context_length ) { @@ -1157,10 +1045,10 @@ if ( context_length != 0xFFFF && context_length < 1 ) return TTO_Err_Not_Covered; - if ( CHECK_Property( gpos->gdef, in->string[in->pos], flags, &property ) ) + if ( CHECK_Property( gpos->gdef, IN_CURITEM(), flags, &property ) ) return error; - error = Coverage_Index( &sp->Coverage, in->string[in->pos], &index ); + error = Coverage_Index( &sp->Coverage, IN_CURGLYPH(), &index ); if ( error ) return error; @@ -1168,7 +1056,7 @@ { case 1: error = Get_ValueRecord( gpi, &sp->spf.spf1.Value, - sp->ValueFormat, &out[in->pos] ); + sp->ValueFormat, POSITION( buffer->in_pos ) ); if ( error ) return error; break; @@ -1177,7 +1065,7 @@ if ( index >= sp->spf.spf2.ValueCount ) return TTO_Err_Invalid_GPOS_SubTable; error = Get_ValueRecord( gpi, &sp->spf.spf2.Value[index], - sp->ValueFormat, &out[in->pos] ); + sp->ValueFormat, POSITION( buffer->in_pos ) ); if ( error ) return error; break; @@ -1186,7 +1074,7 @@ return TTO_Err_Invalid_GPOS_SubTable; } - (in->pos)++; + (buffer->in_pos)++; return TT_Err_Ok; } @@ -1216,7 +1104,7 @@ return error; count = ps->PairValueCount = GET_UShort(); - + FORGET_Frame(); ps->PairValueRecord = NULL; @@ -1458,7 +1346,7 @@ if ( error ) { if ( format1 ) - Free_ValueRecord( &c2r[n].Value1, format1, memory ); + Free_ValueRecord( &c2r[n].Value1, format1, memory ); goto Fail0; } } @@ -1627,8 +1515,7 @@ static FT_Error Lookup_PairPos1( GPOS_Instance* gpi, TTO_PairPosFormat1* ppf1, - TTO_GSUB_String* in, - TTO_GPOS_Data* out, + OTL_Buffer buffer, FT_UShort first_pos, FT_UShort index, FT_UShort format1, @@ -1647,7 +1534,7 @@ if ( !pvr ) return TTO_Err_Invalid_GPOS_SubTable; - glyph2 = in->string[in->pos]; + glyph2 = IN_CURGLYPH(); for ( numpvr = ppf1->PairSet[index].PairValueCount; numpvr; @@ -1656,11 +1543,11 @@ if ( glyph2 == pvr->SecondGlyph ) { error = Get_ValueRecord( gpi, &pvr->Value1, format1, - &out[first_pos] ); + POSITION( first_pos ) ); if ( error ) return error; return Get_ValueRecord( gpi, &pvr->Value2, format2, - &out[in->pos] ); + POSITION( buffer->in_pos ) ); } } @@ -1670,8 +1557,7 @@ static FT_Error Lookup_PairPos2( GPOS_Instance* gpi, TTO_PairPosFormat2* ppf2, - TTO_GSUB_String* in, - TTO_GPOS_Data* out, + OTL_Buffer buffer, FT_UShort first_pos, FT_UShort format1, FT_UShort format2 ) @@ -1683,11 +1569,11 @@ TTO_Class2Record* c2r; - error = Get_Class( &ppf2->ClassDef1, in->string[first_pos], + error = Get_Class( &ppf2->ClassDef1, IN_GLYPH( first_pos ), &cl1, NULL ); if ( error && error != TTO_Err_Not_Covered ) return error; - error = Get_Class( &ppf2->ClassDef2, in->string[in->pos], + error = Get_Class( &ppf2->ClassDef2, IN_CURGLYPH(), &cl2, NULL ); if ( error && error != TTO_Err_Not_Covered ) return error; @@ -1697,17 +1583,16 @@ return TTO_Err_Invalid_GPOS_SubTable; c2r = &c1r->Class2Record[cl2]; - error = Get_ValueRecord( gpi, &c2r->Value1, format1, &out[first_pos] ); + error = Get_ValueRecord( gpi, &c2r->Value1, format1, POSITION( first_pos ) ); if ( error ) return error; - return Get_ValueRecord( gpi, &c2r->Value2, format2, &out[in->pos] ); + return Get_ValueRecord( gpi, &c2r->Value2, format2, POSITION( buffer->in_pos ) ); } static FT_Error Lookup_PairPos( GPOS_Instance* gpi, TTO_PairPos* pp, - TTO_GSUB_String* in, - TTO_GPOS_Data* out, + OTL_Buffer buffer, FT_UShort flags, FT_UShort context_length ) { @@ -1716,50 +1601,56 @@ TTO_GPOSHeader* gpos = gpi->gpos; - if ( in->pos >= in->length - 1 ) + if ( buffer->in_pos >= buffer->in_length - 1 ) return TTO_Err_Not_Covered; /* Not enough glyphs in stream */ if ( context_length != 0xFFFF && context_length < 2 ) return TTO_Err_Not_Covered; - error = Coverage_Index( &pp->Coverage, in->string[in->pos], &index ); - if ( error ) + if ( CHECK_Property( gpos->gdef, IN_CURITEM(), flags, &property ) ) return error; - if ( CHECK_Property( gpos->gdef, in->string[in->pos], flags, &property ) ) + error = Coverage_Index( &pp->Coverage, IN_CURGLYPH(), &index ); + if ( error ) return error; /* second glyph */ - first_pos = in->pos; - (in->pos)++; + first_pos = buffer->in_pos; + (buffer->in_pos)++; - while ( CHECK_Property( gpos->gdef, in->string[in->pos], + while ( CHECK_Property( gpos->gdef, IN_CURITEM(), flags, &property ) ) { if ( error && error != TTO_Err_Not_Covered ) return error; - if ( in->pos < in->length ) - (in->pos)++; - else - break; + if ( buffer->in_pos == buffer->in_length ) + return TTO_Err_Not_Covered; + (buffer->in_pos)++; } - if ( pp->PosFormat == 1 ) - error = Lookup_PairPos1( gpi, &pp->ppf.ppf1, in, out, + switch ( pp->PosFormat ) + { + case 1: + error = Lookup_PairPos1( gpi, &pp->ppf.ppf1, buffer, first_pos, index, pp->ValueFormat1, pp->ValueFormat2 ); - else if ( pp->PosFormat == 2 ) - error = Lookup_PairPos2( gpi, &pp->ppf.ppf2, in, out, first_pos, + break; + + case 2: + error = Lookup_PairPos2( gpi, &pp->ppf.ppf2, buffer, first_pos, pp->ValueFormat1, pp->ValueFormat2 ); - else + break; + + default: return TTO_Err_Invalid_GPOS_SubTable_Format; + } /* adjusting the `next' glyph */ if ( pp->ValueFormat2 ) - (in->pos)++; + (buffer->in_pos)++; return error; } @@ -1814,7 +1705,7 @@ for ( n = 0; n < count; n++ ) { FT_ULong entry_offset; - + if ( ACCESS_Frame( 2L ) ) return error; @@ -1907,8 +1798,7 @@ static FT_Error Lookup_CursivePos( GPOS_Instance* gpi, TTO_CursivePos* cp, - TTO_GSUB_String* in, - TTO_GPOS_Data* out, + OTL_Buffer buffer, FT_UShort flags, FT_UShort context_length ) { @@ -1927,20 +1817,10 @@ return TTO_Err_Not_Covered; } - error = Coverage_Index( &cp->Coverage, in->string[in->pos], &index ); - if ( error ) - { - gpi->last = 0xFFFF; - return error; - } - - if ( index >= cp->EntryExitCount ) - return TTO_Err_Invalid_GPOS_SubTable; - /* Glyphs not having the right GDEF properties will be ignored, i.e., gpi->last won't be reset (contrary to user defined properties). */ - if ( CHECK_Property( gpos->gdef, in->string[in->pos], flags, &property ) ) + if ( CHECK_Property( gpos->gdef, IN_CURITEM(), flags, &property ) ) return error; /* We don't handle mark glyphs here. According to Andrei, this isn't @@ -1952,6 +1832,15 @@ return TTO_Err_Not_Covered; } + error = Coverage_Index( &cp->Coverage, IN_CURGLYPH(), &index ); + if ( error ) + { + gpi->last = 0xFFFF; + return error; + } + + if ( index >= cp->EntryExitCount ) + return TTO_Err_Invalid_GPOS_SubTable; eer = &cp->EntryExitRecord[index]; @@ -2078,7 +1967,7 @@ /* Get_Anchor() returns TTO_Err_Not_Covered if there is no anchor table. */ - error = Get_Anchor( gpi, &eer->EntryAnchor, in->string[in->pos], + error = Get_Anchor( gpi, &eer->EntryAnchor, IN_CURGLYPH(), &entry_x, &entry_y ); if ( error == TTO_Err_Not_Covered ) goto end; @@ -2087,34 +1976,41 @@ if ( gpi->r2l ) { - out[in->pos].x_advance = entry_x - gpi->anchor_x; - out[in->pos].new_advance = TRUE; + POSITION( buffer->in_pos )->x_advance = entry_x - gpi->anchor_x; + POSITION( buffer->in_pos )->new_advance = TRUE; } else { - out[gpi->last].x_advance = gpi->anchor_x - entry_x; - out[gpi->last].new_advance = TRUE; + POSITION( gpi->last )->x_advance = gpi->anchor_x - entry_x; + POSITION( gpi->last )->new_advance = TRUE; } - out[in->pos].y_pos = gpi->anchor_y - entry_y + out[gpi->last].y_pos; + if ( flags & RIGHT_TO_LEFT ) + { + POSITION( gpi->last )->cursive_chain = gpi->last - buffer->in_pos; + POSITION( gpi->last )->y_pos = entry_y - gpi->anchor_y; + } + else + { + POSITION( buffer->in_pos )->cursive_chain = buffer->in_pos - gpi->last; + POSITION( buffer->in_pos )->y_pos = gpi->anchor_y - entry_y; + } end: - error = Get_Anchor( gpi, &eer->ExitAnchor, in->string[in->pos], + error = Get_Anchor( gpi, &eer->ExitAnchor, IN_CURGLYPH(), &exit_x, &exit_y ); if ( error == TTO_Err_Not_Covered ) gpi->last = 0xFFFF; else { - if ( gpi->first == 0xFFFF ) - gpi->first = in->pos; - gpi->last = in->pos; + gpi->last = buffer->in_pos; gpi->anchor_x = exit_x; gpi->anchor_y = exit_y; } if ( error ) return error; - (in->pos)++; + (buffer->in_pos)++; return TT_Err_Ok; } @@ -2144,7 +2040,7 @@ return error; count = ba->BaseCount = GET_UShort(); - + FORGET_Frame(); ba->BaseRecord = NULL; @@ -2192,7 +2088,7 @@ for ( k = 0; k < m; k++ ) { ban = br[k].BaseAnchor; - + for ( n = 0; n < num_classes; n++ ) Free_Anchor( &ban[n], memory ); @@ -2327,12 +2223,11 @@ static FT_Error Lookup_MarkBasePos( GPOS_Instance* gpi, TTO_MarkBasePos* mbp, - TTO_GSUB_String* in, - TTO_GPOS_Data* out, + OTL_Buffer buffer, FT_UShort flags, FT_UShort context_length ) { - FT_UShort i, j, mark_index, base_index, property, klass; + FT_UShort i, j, mark_index, base_index, property, class; FT_Pos x_mark_value, y_mark_value, x_base_value, y_base_value; FT_Error error; TTO_GPOSHeader* gpos = gpi->gpos; @@ -2343,7 +2238,7 @@ TTO_Anchor* mark_anchor; TTO_Anchor* base_anchor; - TTO_GPOS_Data* o; + OTL_Position o; if ( context_length != 0xFFFF && context_length < 1 ) @@ -2352,23 +2247,23 @@ if ( flags & IGNORE_BASE_GLYPHS ) return TTO_Err_Not_Covered; - error = Coverage_Index( &mbp->MarkCoverage, in->string[in->pos], - &mark_index ); - if ( error ) + if ( CHECK_Property( gpos->gdef, IN_CURITEM(), + flags, &property ) ) return error; - if ( CHECK_Property( gpos->gdef, in->string[in->pos], - flags, &property ) ) + error = Coverage_Index( &mbp->MarkCoverage, IN_CURGLYPH(), + &mark_index ); + if ( error ) return error; /* now we search backwards for a non-mark glyph */ i = 1; - j = in->pos - 1; + j = buffer->in_pos - 1; - while ( i <= in->pos ) + while ( i <= buffer->in_pos ) { - error = TT_GDEF_Get_Glyph_Property( gpos->gdef, in->string[j], + error = TT_GDEF_Get_Glyph_Property( gpos->gdef, IN_GLYPH( j ), &property ); if ( error ) return error; @@ -2386,10 +2281,10 @@ return TTO_Err_Not_Covered; #endif - if ( i > in->pos ) + if ( i > buffer->in_pos ) return TTO_Err_Not_Covered; - error = Coverage_Index( &mbp->BaseCoverage, in->string[j], + error = Coverage_Index( &mbp->BaseCoverage, IN_GLYPH( j ), &base_index ); if ( error ) return error; @@ -2399,10 +2294,10 @@ if ( mark_index >= ma->MarkCount ) return TTO_Err_Invalid_GPOS_SubTable; - klass = ma->MarkRecord[mark_index].Class; + class = ma->MarkRecord[mark_index].Class; mark_anchor = &ma->MarkRecord[mark_index].MarkAnchor; - if ( klass >= mbp->ClassCount ) + if ( class >= mbp->ClassCount ) return TTO_Err_Invalid_GPOS_SubTable; ba = &mbp->BaseArray; @@ -2411,20 +2306,21 @@ return TTO_Err_Invalid_GPOS_SubTable; br = &ba->BaseRecord[base_index]; - base_anchor = &br->BaseAnchor[klass]; + base_anchor = &br->BaseAnchor[class]; - error = Get_Anchor( gpi, mark_anchor, in->string[in->pos], + error = Get_Anchor( gpi, mark_anchor, IN_CURGLYPH(), &x_mark_value, &y_mark_value ); if ( error ) return error; - error = Get_Anchor( gpi, base_anchor, in->string[j], + + error = Get_Anchor( gpi, base_anchor, IN_GLYPH( j ), &x_base_value, &y_base_value ); if ( error ) return error; /* anchor points are not cumulative */ - o = &out[in->pos]; + o = POSITION( buffer->in_pos ); o->x_pos = x_base_value - x_mark_value; o->y_pos = y_base_value - y_mark_value; @@ -2432,7 +2328,7 @@ o->y_advance = 0; o->back = i; - (in->pos)++; + (buffer->in_pos)++; return TT_Err_Ok; } @@ -2462,7 +2358,7 @@ return error; count = lat->ComponentCount = GET_UShort(); - + FORGET_Frame(); lat->ComponentRecord = NULL; @@ -2517,7 +2413,7 @@ for ( k = 0; k < m; k++ ) { lan = cr[k].LigatureAnchor; - + for ( n = 0; n < num_classes; n++ ) Free_Anchor( &lan[n], memory ); @@ -2734,12 +2630,11 @@ static FT_Error Lookup_MarkLigPos( GPOS_Instance* gpi, TTO_MarkLigPos* mlp, - TTO_GSUB_String* in, - TTO_GPOS_Data* out, + OTL_Buffer buffer, FT_UShort flags, FT_UShort context_length ) { - FT_UShort i, j, mark_index, lig_index, property, klass; + FT_UShort i, j, mark_index, lig_index, property, class; FT_UShort mark_glyph; FT_Pos x_mark_value, y_mark_value, x_lig_value, y_lig_value; FT_Error error; @@ -2753,7 +2648,7 @@ TTO_Anchor* mark_anchor; TTO_Anchor* lig_anchor; - TTO_GPOS_Data* o; + OTL_Position o; if ( context_length != 0xFFFF && context_length < 1 ) @@ -2762,23 +2657,23 @@ if ( flags & IGNORE_LIGATURES ) return TTO_Err_Not_Covered; - mark_glyph = in->string[in->pos]; + mark_glyph = IN_CURGLYPH(); - error = Coverage_Index( &mlp->MarkCoverage, mark_glyph, &mark_index ); - if ( error ) + if ( CHECK_Property( gpos->gdef, IN_CURITEM(), flags, &property ) ) return error; - if ( CHECK_Property( gpos->gdef, mark_glyph, flags, &property ) ) + error = Coverage_Index( &mlp->MarkCoverage, mark_glyph, &mark_index ); + if ( error ) return error; /* now we search backwards for a non-mark glyph */ i = 1; - j = in->pos - 1; + j = buffer->in_pos - 1; - while ( i <= in->pos ) + while ( i <= buffer->in_pos ) { - error = TT_GDEF_Get_Glyph_Property( gpos->gdef, in->string[j], + error = TT_GDEF_Get_Glyph_Property( gpos->gdef, IN_GLYPH( j ), &property ); if ( error ) return error; @@ -2797,10 +2692,10 @@ return TTO_Err_Not_Covered; #endif - if ( i > in->pos ) + if ( i > buffer->in_pos ) return TTO_Err_Not_Covered; - error = Coverage_Index( &mlp->LigatureCoverage, in->string[j], + error = Coverage_Index( &mlp->LigatureCoverage, IN_GLYPH( j ), &lig_index ); if ( error ) return error; @@ -2810,10 +2705,10 @@ if ( mark_index >= ma->MarkCount ) return TTO_Err_Invalid_GPOS_SubTable; - klass = ma->MarkRecord[mark_index].Class; + class = ma->MarkRecord[mark_index].Class; mark_anchor = &ma->MarkRecord[mark_index].MarkAnchor; - if ( klass >= mlp->ClassCount ) + if ( class >= mlp->ClassCount ) return TTO_Err_Invalid_GPOS_SubTable; la = &mlp->LigatureArray; @@ -2823,32 +2718,35 @@ lat = &la->LigatureAttach[lig_index]; - /* Use the component id if defined. If not we simply attach the - mark glyph to the last component of the ligature */ - - comp_index = in->glyph_properties[in->pos].component; + /* We must now check whether the ligature ID of the current mark glyph + is identical to the ligature ID of the found ligature. If yes, we + can directly use the component index. If not, we attach the mark + glyph to the last component of the ligature. */ - /* ###### why the hell doesn't this compile? - if (comp_index == MAX_COMPONENT_INDEX) - comp_index = lat->ComponentCount - 1; */ - if ( comp_index >= lat->ComponentCount ) + if ( IN_LIGID( j ) == IN_LIGID( buffer->in_pos) ) + { + comp_index = IN_COMPONENT( buffer->in_pos ); + if ( comp_index >= lat->ComponentCount ) return TTO_Err_Not_Covered; + } + else + comp_index = lat->ComponentCount - 1; cr = &lat->ComponentRecord[comp_index]; - lig_anchor = &cr->LigatureAnchor[klass]; + lig_anchor = &cr->LigatureAnchor[class]; - error = Get_Anchor( gpi, mark_anchor, in->string[in->pos], + error = Get_Anchor( gpi, mark_anchor, IN_CURGLYPH(), &x_mark_value, &y_mark_value ); if ( error ) return error; - error = Get_Anchor( gpi, lig_anchor, in->string[j], + error = Get_Anchor( gpi, lig_anchor, IN_GLYPH( j ), &x_lig_value, &y_lig_value ); if ( error ) return error; /* anchor points are not cumulative */ - o = &out[in->pos]; + o = POSITION( buffer->in_pos ); o->x_pos = x_lig_value - x_mark_value; o->y_pos = y_lig_value - y_mark_value; @@ -2856,7 +2754,7 @@ o->y_advance = 0; o->back = i; - (in->pos)++; + (buffer->in_pos)++; return TT_Err_Ok; } @@ -2886,7 +2784,7 @@ return error; count = m2a->Mark2Count = GET_UShort(); - + FORGET_Frame(); m2a->Mark2Record = NULL; @@ -2934,7 +2832,7 @@ for ( k = 0; k < m; k++ ) { m2an = m2r[k].Mark2Anchor; - + for ( n = 0; n < num_classes; n++ ) Free_Anchor( &m2an[n], memory ); @@ -3071,12 +2969,11 @@ static FT_Error Lookup_MarkMarkPos( GPOS_Instance* gpi, TTO_MarkMarkPos* mmp, - TTO_GSUB_String* in, - TTO_GPOS_Data* out, + OTL_Buffer buffer, FT_UShort flags, FT_UShort context_length ) { - FT_UShort j, mark1_index, mark2_index, property, klass; + FT_UShort j, mark1_index, mark2_index, property, class; FT_Pos x_mark1_value, y_mark1_value, x_mark2_value, y_mark2_value; FT_Error error; @@ -3088,7 +2985,7 @@ TTO_Anchor* mark1_anchor; TTO_Anchor* mark2_anchor; - TTO_GPOS_Data* o; + OTL_Position o; if ( context_length != 0xFFFF && context_length < 1 ) @@ -3097,24 +2994,23 @@ if ( flags & IGNORE_MARKS ) return TTO_Err_Not_Covered; - error = Coverage_Index( &mmp->Mark1Coverage, in->string[in->pos], - &mark1_index ); - if ( error ) - return error; - - if ( CHECK_Property( gpos->gdef, in->string[in->pos], + if ( CHECK_Property( gpos->gdef, IN_CURITEM(), flags, &property ) ) return error; + error = Coverage_Index( &mmp->Mark1Coverage, IN_CURGLYPH(), + &mark1_index ); + if ( error ) + return error; /* now we check the preceding glyph whether it is a suitable mark glyph */ - if ( in->pos == 0 ) + if ( buffer->in_pos == 0 ) return TTO_Err_Not_Covered; - j = in->pos - 1; - error = TT_GDEF_Get_Glyph_Property( gpos->gdef, in->string[j], + j = buffer->in_pos - 1; + error = TT_GDEF_Get_Glyph_Property( gpos->gdef, IN_GLYPH( j ), &property ); if ( error ) return error; @@ -3130,7 +3026,7 @@ return TTO_Err_Not_Covered; } - error = Coverage_Index( &mmp->Mark2Coverage, in->string[j], + error = Coverage_Index( &mmp->Mark2Coverage, IN_GLYPH( j ), &mark2_index ); if ( error ) return error; @@ -3140,10 +3036,10 @@ if ( mark1_index >= ma1->MarkCount ) return TTO_Err_Invalid_GPOS_SubTable; - klass = ma1->MarkRecord[mark1_index].Class; + class = ma1->MarkRecord[mark1_index].Class; mark1_anchor = &ma1->MarkRecord[mark1_index].MarkAnchor; - if ( klass >= mmp->ClassCount ) + if ( class >= mmp->ClassCount ) return TTO_Err_Invalid_GPOS_SubTable; ma2 = &mmp->Mark2Array; @@ -3152,20 +3048,20 @@ return TTO_Err_Invalid_GPOS_SubTable; m2r = &ma2->Mark2Record[mark2_index]; - mark2_anchor = &m2r->Mark2Anchor[klass]; + mark2_anchor = &m2r->Mark2Anchor[class]; - error = Get_Anchor( gpi, mark1_anchor, in->string[in->pos], + error = Get_Anchor( gpi, mark1_anchor, IN_CURGLYPH(), &x_mark1_value, &y_mark1_value ); if ( error ) return error; - error = Get_Anchor( gpi, mark2_anchor, in->string[j], + error = Get_Anchor( gpi, mark2_anchor, IN_GLYPH( j ), &x_mark2_value, &y_mark2_value ); if ( error ) return error; /* anchor points are not cumulative */ - o = &out[in->pos]; + o = POSITION( buffer->in_pos ); o->x_pos = x_mark2_value - x_mark1_value; o->y_pos = y_mark2_value - y_mark1_value; @@ -3173,7 +3069,7 @@ o->y_advance = 0; o->back = 1; - (in->pos)++; + (buffer->in_pos)++; return TT_Err_Ok; } @@ -3187,8 +3083,7 @@ FT_UShort GlyphCount, FT_UShort PosCount, TTO_PosLookupRecord* pos, - TTO_GSUB_String* in, - TTO_GPOS_Data* out, + OTL_Buffer buffer, int nesting_level ) { FT_Error error; @@ -3201,24 +3096,24 @@ { if ( PosCount && i == pos->SequenceIndex ) { - old_pos = in->pos; + old_pos = buffer->in_pos; /* Do a positioning */ - error = GPos_Do_Glyph_Lookup( gpi, pos->LookupListIndex, in, out, - GlyphCount, nesting_level ); + error = GPos_Do_Glyph_Lookup( gpi, pos->LookupListIndex, buffer, + GlyphCount, nesting_level ); if ( error ) return error; pos++; PosCount--; - i += in->pos - old_pos; + i += buffer->in_pos - old_pos; } else { i++; - (in->pos)++; + (buffer->in_pos)++; } } @@ -3457,7 +3352,7 @@ } - static void GPos_Free_Context1( TTO_ContextPosFormat1* cpf1, + static void Gpos_Free_Context1( TTO_ContextPosFormat1* cpf1, FT_Memory memory ) { FT_UShort n, count; @@ -3527,10 +3422,8 @@ /* We check whether the specific class is used at all. If not, class 0 is used instead. */ - /* - if ( !d[c[n]] ) - c[n] = 0; - */ + if ( !d[c[n]] ) + c[n] = 0; } FORGET_Frame(); @@ -3754,7 +3647,7 @@ } - static void GPos_Free_Context2( TTO_ContextPosFormat2* cpf2, + static void Gpos_Free_Context2( TTO_ContextPosFormat2* cpf2, FT_Memory memory ) { FT_UShort n, count; @@ -3862,7 +3755,7 @@ } - static void GPos_Free_Context3( TTO_ContextPosFormat3* cpf3, + static void Gpos_Free_Context3( TTO_ContextPosFormat3* cpf3, FT_Memory memory ) { FT_UShort n, count; @@ -3925,15 +3818,15 @@ switch ( cp->PosFormat ) { case 1: - GPos_Free_Context1( &cp->cpf.cpf1, memory ); + Gpos_Free_Context1( &cp->cpf.cpf1, memory ); break; case 2: - GPos_Free_Context2( &cp->cpf.cpf2, memory ); + Gpos_Free_Context2( &cp->cpf.cpf2, memory ); break; case 3: - GPos_Free_Context3( &cp->cpf.cpf3, memory ); + Gpos_Free_Context3( &cp->cpf.cpf3, memory ); break; } } @@ -3941,28 +3834,27 @@ static FT_Error Lookup_ContextPos1( GPOS_Instance* gpi, TTO_ContextPosFormat1* cpf1, - TTO_GSUB_String* in, - TTO_GPOS_Data* out, + OTL_Buffer buffer, FT_UShort flags, FT_UShort context_length, int nesting_level ) { FT_UShort index, property; - FT_UShort i, j, k, numpr; + FT_Int i, j, k, numpr; FT_Error error; - FT_UShort* s_in; TTO_GPOSHeader* gpos = gpi->gpos; TTO_PosRule* pr; TTO_GDEFHeader* gdef; - error = Coverage_Index( &cpf1->Coverage, in->string[in->pos], &index ); - if ( error ) - return error; gdef = gpos->gdef; - if ( CHECK_Property( gdef, in->string[in->pos], flags, &property ) ) + if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) ) + return error; + + error = Coverage_Index( &cpf1->Coverage, IN_CURGLYPH(), &index ); + if ( error ) return error; pr = cpf1->PosRuleSet[index].PosRule; @@ -3971,35 +3863,34 @@ for ( k = 0; k < numpr; k++ ) { if ( context_length != 0xFFFF && context_length < pr[k].GlyphCount ) - continue; - - if ( in->pos + pr[k].GlyphCount > in->length ) - continue; /* context is too long */ + goto next_posrule; - s_in = &in->string[in->pos]; + if ( buffer->in_pos + pr[k].GlyphCount > buffer->in_length ) + goto next_posrule; /* context is too long */ - for ( i = 1, j = 1; i < pr[k].GlyphCount; i++, j++ ) + for ( i = 1, j = buffer->in_pos + 1; i < pr[k].GlyphCount; i++, j++ ) { - while ( CHECK_Property( gdef, s_in[j], flags, &property ) ) + while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) ) { if ( error && error != TTO_Err_Not_Covered ) return error; - if ( in->pos + j < in->length ) - j++; - else - break; + if ( j + pr[k].GlyphCount - i == (FT_Int)buffer->in_length ) + goto next_posrule; + j++; } - if ( s_in[j] != pr[k].Input[i - 1] ) - break; + if ( IN_GLYPH( j ) != pr[k].Input[i - 1] ) + goto next_posrule; } - if ( i == pr[k].GlyphCount ) - return Do_ContextPos( gpi, pr[k].GlyphCount, - pr[k].PosCount, pr[k].PosLookupRecord, - in, out, - nesting_level ); + return Do_ContextPos( gpi, pr[k].GlyphCount, + pr[k].PosCount, pr[k].PosLookupRecord, + buffer, + nesting_level ); + + next_posrule: + ; } return TTO_Err_Not_Covered; @@ -4008,8 +3899,7 @@ static FT_Error Lookup_ContextPos2( GPOS_Instance* gpi, TTO_ContextPosFormat2* cpf2, - TTO_GSUB_String* in, - TTO_GPOS_Data* out, + OTL_Buffer buffer, FT_UShort flags, FT_UShort context_length, int nesting_level ) @@ -4020,7 +3910,6 @@ FT_UShort i, j, k, known_classes; FT_UShort* classes; - FT_UShort* s_in; FT_UShort* cl; TTO_GPOSHeader* gpos = gpi->gpos; @@ -4028,23 +3917,24 @@ TTO_PosClassRule* pr; TTO_GDEFHeader* gdef; + + gdef = gpos->gdef; + + if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) ) + return error; + /* Note: The coverage table in format 2 doesn't give an index into anything. It just lets us know whether or not we need to do any lookup at all. */ - error = Coverage_Index( &cpf2->Coverage, in->string[in->pos], &index ); + error = Coverage_Index( &cpf2->Coverage, IN_CURGLYPH(), &index ); if ( error ) return error; - gdef = gpos->gdef; - - if ( CHECK_Property( gdef, in->string[in->pos], flags, &property ) ) - return error; - if ( ALLOC_ARRAY( classes, cpf2->MaxContextLength, FT_UShort ) ) return error; - error = Get_Class( &cpf2->ClassDef, in->string[in->pos], + error = Get_Class( &cpf2->ClassDef, IN_CURGLYPH(), &classes[0], NULL ); if ( error && error != TTO_Err_Not_Covered ) goto End; @@ -4062,51 +3952,49 @@ pr = &pcs->PosClassRule[k]; if ( context_length != 0xFFFF && context_length < pr->GlyphCount ) - continue; + goto next_posclassrule; - if ( in->pos + pr->GlyphCount > in->length ) - continue; /* context is too long */ + if ( buffer->in_pos + pr->GlyphCount > buffer->in_length ) + goto next_posclassrule; /* context is too long */ - s_in = &in->string[in->pos]; cl = pr->Class; /* Start at 1 because [0] is implied */ - for ( i = 1, j = 1; i < pr->GlyphCount; i++, j++ ) + for ( i = 1, j = buffer->in_pos + 1; i < pr->GlyphCount; i++, j++ ) { - while ( CHECK_Property( gdef, s_in[j], flags, &property ) ) + while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) ) { if ( error && error != TTO_Err_Not_Covered ) goto End; - if ( in->pos + j < in->length ) - j++; - else - break; + if ( j + pr->GlyphCount - i == (FT_Int)buffer->in_length ) + goto next_posclassrule; + j++; } if ( i > known_classes ) { /* Keeps us from having to do this for each rule */ - error = Get_Class( &cpf2->ClassDef, s_in[j], &classes[i], NULL ); + error = Get_Class( &cpf2->ClassDef, IN_GLYPH( j ), &classes[i], NULL ); if ( error && error != TTO_Err_Not_Covered ) goto End; known_classes = i; } if ( cl[i - 1] != classes[i] ) - break; + goto next_posclassrule; } - if ( i == pr->GlyphCount ) - { - error = Do_ContextPos( gpi, pr->GlyphCount, - pr->PosCount, pr->PosLookupRecord, - in, out, - nesting_level ); - goto End; - } + error = Do_ContextPos( gpi, pr->GlyphCount, + pr->PosCount, pr->PosLookupRecord, + buffer, + nesting_level ); + goto End; + + next_posclassrule: + ; } error = TTO_Err_Not_Covered; @@ -4119,15 +4007,13 @@ static FT_Error Lookup_ContextPos3( GPOS_Instance* gpi, TTO_ContextPosFormat3* cpf3, - TTO_GSUB_String* in, - TTO_GPOS_Data* out, + OTL_Buffer buffer, FT_UShort flags, FT_UShort context_length, int nesting_level ) { FT_Error error; FT_UShort index, i, j, property; - FT_UShort* s_in; TTO_GPOSHeader* gpos = gpi->gpos; TTO_Coverage* c; @@ -4136,47 +4022,44 @@ gdef = gpos->gdef; + if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) ) + return error; + if ( context_length != 0xFFFF && context_length < cpf3->GlyphCount ) return TTO_Err_Not_Covered; - if ( in->pos + cpf3->GlyphCount > in->length ) + if ( buffer->in_pos + cpf3->GlyphCount > buffer->in_length ) return TTO_Err_Not_Covered; /* context is too long */ - if ( CHECK_Property( gdef, in->string[in->pos], flags, &property ) ) - return error; - - s_in = &in->string[in->pos]; c = cpf3->Coverage; for ( i = 1, j = 1; i < cpf3->GlyphCount; i++, j++ ) { - while ( CHECK_Property( gdef, s_in[j], flags, &property ) ) + while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) ) { if ( error && error != TTO_Err_Not_Covered ) return error; - if ( in->pos + j < in->length ) - j++; - else + if ( j + cpf3->GlyphCount - i == (FT_Int)buffer->in_length ) return TTO_Err_Not_Covered; + j++; } - error = Coverage_Index( &c[i], s_in[j], &index ); + error = Coverage_Index( &c[i], IN_GLYPH( j ), &index ); if ( error ) return error; } return Do_ContextPos( gpi, cpf3->GlyphCount, cpf3->PosCount, cpf3->PosLookupRecord, - in, out, + buffer, nesting_level ); } static FT_Error Lookup_ContextPos( GPOS_Instance* gpi, TTO_ContextPos* cp, - TTO_GSUB_String* in, - TTO_GPOS_Data* out, + OTL_Buffer buffer, FT_UShort flags, FT_UShort context_length, int nesting_level ) @@ -4184,15 +4067,15 @@ switch ( cp->PosFormat ) { case 1: - return Lookup_ContextPos1( gpi, &cp->cpf.cpf1, in, out, + return Lookup_ContextPos1( gpi, &cp->cpf.cpf1, buffer, flags, context_length, nesting_level ); case 2: - return Lookup_ContextPos2( gpi, &cp->cpf.cpf2, in, out, + return Lookup_ContextPos2( gpi, &cp->cpf.cpf2, buffer, flags, context_length, nesting_level ); case 3: - return Lookup_ContextPos3( gpi, &cp->cpf.cpf3, in, out, + return Lookup_ContextPos3( gpi, &cp->cpf.cpf3, buffer, flags, context_length, nesting_level ); default: @@ -4337,7 +4220,7 @@ } - static void Free_ChainPosRule( TTO_ChainPosRule* cpr, + static void Gpos_Free_ChainPosRule( TTO_ChainPosRule* cpr, FT_Memory memory ) { FREE( cpr->PosLookupRecord ); @@ -4397,14 +4280,14 @@ Fail: for ( m = 0; m < n; m++ ) - Free_ChainPosRule( &cpr[m], memory ); + Gpos_Free_ChainPosRule( &cpr[m], memory ); FREE( cpr ); return error; } - static void Free_ChainPosRuleSet( TTO_ChainPosRuleSet* cprs, + static void Gpos_Free_ChainPosRuleSet( TTO_ChainPosRuleSet* cprs, FT_Memory memory ) { FT_UShort n, count; @@ -4418,7 +4301,7 @@ cpr = cprs->ChainPosRule; for ( n = 0; n < count; n++ ) - Free_ChainPosRule( &cpr[n], memory ); + Gpos_Free_ChainPosRule( &cpr[n], memory ); FREE( cpr ); } @@ -4488,7 +4371,7 @@ Fail1: for ( m = 0; m < n; m++ ) - Free_ChainPosRuleSet( &cprs[m], memory ); + Gpos_Free_ChainPosRuleSet( &cprs[m], memory ); FREE( cprs ); @@ -4498,7 +4381,7 @@ } - static void GPos_Free_ChainContext1( TTO_ChainContextPosFormat1* ccpf1, + static void Gpos_Free_ChainContext1( TTO_ChainContextPosFormat1* ccpf1, FT_Memory memory ) { FT_UShort n, count; @@ -4512,7 +4395,7 @@ cprs = ccpf1->ChainPosRuleSet; for ( n = 0; n < count; n++ ) - Free_ChainPosRuleSet( &cprs[n], memory ); + Gpos_Free_ChainPosRuleSet( &cprs[n], memory ); FREE( cprs ); } @@ -4569,10 +4452,9 @@ /* We check whether the specific class is used at all. If not, class 0 is used instead. */ - /* - if ( !d[b[n]] ) - b[n] = 0; - */ + + if ( !d[b[n]] ) + b[n] = 0; } FORGET_Frame(); @@ -4604,10 +4486,8 @@ { i[n] = GET_UShort(); - /* - if ( !d[i[n]] ) - i[n] = 0; - */ + if ( !d[i[n]] ) + i[n] = 0; } FORGET_Frame(); @@ -4639,10 +4519,8 @@ { l[n] = GET_UShort(); - /* - if ( !d[l[n]] ) - l[n] = 0; - */ + if ( !d[l[n]] ) + l[n] = 0; } FORGET_Frame(); @@ -4691,7 +4569,7 @@ } - static void Free_ChainPosClassRule( TTO_ChainPosClassRule* cpcr, + static void Gpos_Free_ChainPosClassRule( TTO_ChainPosClassRule* cpcr, FT_Memory memory ) { FREE( cpcr->PosLookupRecord ); @@ -4755,14 +4633,14 @@ Fail: for ( m = 0; m < n; m++ ) - Free_ChainPosClassRule( &cpcr[m], memory ); + Gpos_Free_ChainPosClassRule( &cpcr[m], memory ); FREE( cpcr ); return error; } - static void Free_ChainPosClassSet( TTO_ChainPosClassSet* cpcs, + static void Gpos_Free_ChainPosClassSet( TTO_ChainPosClassSet* cpcs, FT_Memory memory ) { FT_UShort n, count; @@ -4776,14 +4654,14 @@ cpcr = cpcs->ChainPosClassRule; for ( n = 0; n < count; n++ ) - Free_ChainPosClassRule( &cpcr[n], memory ); + Gpos_Free_ChainPosClassRule( &cpcr[n], memory ); FREE( cpcr ); } } - static FT_Error Load_EmptyOrClassDefinition( TTO_ClassDefinition* cd, + static FT_Error Gpos_Load_EmptyOrClassDefinition( TTO_ClassDefinition* cd, FT_UShort limit, FT_ULong class_offset, FT_ULong base_offset, @@ -4846,21 +4724,22 @@ lookahead_offset = GET_UShort(); /* `ChainPosClassSetCount' is the upper limit for input class values, - thus we read it now to make an additional safety check. */ + thus we read it now to make an additional safety check. No limit + is known or needed for the other two class definitions */ count = ccpf2->ChainPosClassSetCount = GET_UShort(); FORGET_Frame(); - if ( ( error = Load_EmptyOrClassDefinition( &ccpf2->BacktrackClassDef, count, + if ( ( error = Gpos_Load_EmptyOrClassDefinition( &ccpf2->BacktrackClassDef, 65535, backtrack_offset, base_offset, stream ) ) != TT_Err_Ok ) goto Fail5; - if ( ( error = Load_EmptyOrClassDefinition( &ccpf2->InputClassDef, count, + if ( ( error = Gpos_Load_EmptyOrClassDefinition( &ccpf2->InputClassDef, count, input_offset, base_offset, stream ) ) != TT_Err_Ok ) goto Fail4; - if ( ( error = Load_EmptyOrClassDefinition( &ccpf2->LookaheadClassDef, count, + if ( ( error = Gpos_Load_EmptyOrClassDefinition( &ccpf2->LookaheadClassDef, 65535, lookahead_offset, base_offset, stream ) ) != TT_Err_Ok ) goto Fail3; @@ -4906,7 +4785,7 @@ Fail1: for ( m = 0; m < n; m++ ) - Free_ChainPosClassSet( &cpcs[m], memory ); + Gpos_Free_ChainPosClassSet( &cpcs[m], memory ); FREE( cpcs ); @@ -4925,7 +4804,7 @@ } - static void GPos_Free_ChainContext2( TTO_ChainContextPosFormat2* ccpf2, + static void Gpos_Free_ChainContext2( TTO_ChainContextPosFormat2* ccpf2, FT_Memory memory ) { FT_UShort n, count; @@ -4939,7 +4818,7 @@ cpcs = ccpf2->ChainPosClassSet; for ( n = 0; n < count; n++ ) - Free_ChainPosClassSet( &cpcs[n], memory ); + Gpos_Free_ChainPosClassSet( &cpcs[n], memory ); FREE( cpcs ); } @@ -5123,7 +5002,7 @@ } - static void GPos_Free_ChainContext3( TTO_ChainContextPosFormat3* ccpf3, + static void Gpos_Free_ChainContext3( TTO_ChainContextPosFormat3* ccpf3, FT_Memory memory ) { FT_UShort n, count; @@ -5208,15 +5087,15 @@ switch ( ccp->PosFormat ) { case 1: - GPos_Free_ChainContext1( &ccp->ccpf.ccpf1, memory ); + Gpos_Free_ChainContext1( &ccp->ccpf.ccpf1, memory ); break; case 2: - GPos_Free_ChainContext2( &ccp->ccpf.ccpf2, memory ); + Gpos_Free_ChainContext2( &ccp->ccpf.ccpf2, memory ); break; case 3: - GPos_Free_ChainContext3( &ccp->ccpf.ccpf3, memory ); + Gpos_Free_ChainContext3( &ccp->ccpf.ccpf3, memory ); break; } } @@ -5225,17 +5104,15 @@ static FT_Error Lookup_ChainContextPos1( GPOS_Instance* gpi, TTO_ChainContextPosFormat1* ccpf1, - TTO_GSUB_String* in, - TTO_GPOS_Data* out, + OTL_Buffer buffer, FT_UShort flags, FT_UShort context_length, int nesting_level ) { FT_UShort index, property; - FT_UShort i, j, k, num_cpr, curr_pos; + FT_UShort i, j, k, num_cpr; FT_UShort bgc, igc, lgc; FT_Error error; - FT_UShort* s_in; TTO_GPOSHeader* gpos = gpi->gpos; TTO_ChainPosRule* cpr; @@ -5243,13 +5120,13 @@ TTO_GDEFHeader* gdef; - error = Coverage_Index( &ccpf1->Coverage, in->string[in->pos], &index ); - if ( error ) - return error; - gdef = gpos->gdef; - if ( CHECK_Property( gdef, in->string[in->pos], flags, &property ) ) + if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) ) + return error; + + error = Coverage_Index( &ccpf1->Coverage, IN_CURGLYPH(), &index ); + if ( error ) return error; cpr = ccpf1->ChainPosRuleSet[index].ChainPosRule; @@ -5263,32 +5140,28 @@ lgc = curr_cpr.LookaheadGlyphCount; if ( context_length != 0xFFFF && context_length < igc ) - continue; + goto next_chainposrule; /* check whether context is too long; it is a first guess only */ - if ( bgc > in->pos || in->pos + igc + lgc > in->length ) - continue; + if ( bgc > buffer->in_pos || buffer->in_pos + igc + lgc > buffer->in_length ) + goto next_chainposrule; if ( bgc ) { /* Since we don't know in advance the number of glyphs to inspect, we search backwards for matches in the backtrack glyph array */ - curr_pos = 0; - s_in = &in->string[curr_pos]; - - for ( i = 0, j = in->pos - 1; i < bgc; i++, j-- ) + for ( i = 0, j = buffer->in_pos - 1; i < bgc; i++, j-- ) { - while ( CHECK_Property( gdef, s_in[j], flags, &property ) ) + while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) ) { if ( error && error != TTO_Err_Not_Covered ) return error; - if ( j > curr_pos ) - j--; - else - break; + if ( j + 1 == bgc - i ) + goto next_chainposrule; + j--; } /* In OpenType 1.3, it is undefined whether the offsets of @@ -5301,68 +5174,56 @@ Backtrack offsets - 3 2 1 0 Lookahead offsets - 0 1 2 3 */ - if ( s_in[j] != curr_cpr.Backtrack[i] ) - break; + if ( IN_GLYPH( j ) != curr_cpr.Backtrack[i] ) + goto next_chainposrule; } - - if ( i != bgc ) - continue; } - curr_pos = in->pos; - s_in = &in->string[curr_pos]; - /* Start at 1 because [0] is implied */ - for ( i = 1, j = 1; i < igc; i++, j++ ) + for ( i = 1, j = buffer->in_pos + 1; i < igc; i++, j++ ) { - while ( CHECK_Property( gdef, s_in[j], flags, &property ) ) + while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) ) { if ( error && error != TTO_Err_Not_Covered ) return error; - if ( curr_pos + j < (int)in->length ) - j++; - else - break; + if ( j + igc - i + lgc == (FT_Int)buffer->in_length ) + goto next_chainposrule; + j++; } - if ( s_in[j] != curr_cpr.Input[i - 1] ) - break; + if ( IN_GLYPH( j ) != curr_cpr.Input[i - 1] ) + goto next_chainposrule; } - if ( i != igc ) - continue; - /* we are starting to check for lookahead glyphs right after the last context glyph */ - curr_pos += j; - s_in = &in->string[curr_pos]; - - for ( i = 0, j = 0; i < lgc; i++, j++ ) + for ( i = 0; i < lgc; i++, j++ ) { - while ( CHECK_Property( gdef, s_in[j], flags, &property ) ) + while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) ) { if ( error && error != TTO_Err_Not_Covered ) return error; - if ( curr_pos + j < (int)in->length ) - j++; - else - break; + if ( j + lgc - i == (FT_Int)buffer->in_length ) + goto next_chainposrule; + j++; } - if ( s_in[j] != curr_cpr.Lookahead[i] ) - break; + if ( IN_GLYPH( j ) != curr_cpr.Lookahead[i] ) + goto next_chainposrule; } - if ( i == lgc ) - return Do_ContextPos( gpi, igc, - curr_cpr.PosCount, - curr_cpr.PosLookupRecord, - in, out, - nesting_level ); + return Do_ContextPos( gpi, igc, + curr_cpr.PosCount, + curr_cpr.PosLookupRecord, + buffer, + nesting_level ); + + next_chainposrule: + ; } return TTO_Err_Not_Covered; @@ -5372,8 +5233,7 @@ static FT_Error Lookup_ChainContextPos2( GPOS_Instance* gpi, TTO_ChainContextPosFormat2* ccpf2, - TTO_GSUB_String* in, - TTO_GPOS_Data* out, + OTL_Buffer buffer, FT_UShort flags, FT_UShort context_length, int nesting_level ) @@ -5381,7 +5241,7 @@ FT_UShort index, property; FT_Memory memory = gpi->face->memory; FT_Error error; - FT_UShort i, j, k, curr_pos; + FT_UShort i, j, k; FT_UShort bgc, igc, lgc; FT_UShort known_backtrack_classes, known_input_classes, @@ -5391,8 +5251,6 @@ FT_UShort* input_classes; FT_UShort* lookahead_classes; - FT_UShort* s_in; - FT_UShort* bc; FT_UShort* ic; FT_UShort* lc; @@ -5405,17 +5263,17 @@ gdef = gpos->gdef; + if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) ) + return error; + /* Note: The coverage table in format 2 doesn't give an index into anything. It just lets us know whether or not we need to do any lookup at all. */ - error = Coverage_Index( &ccpf2->Coverage, in->string[in->pos], &index ); + error = Coverage_Index( &ccpf2->Coverage, IN_CURGLYPH(), &index ); if ( error ) return error; - if ( CHECK_Property( gdef, in->string[in->pos], flags, &property ) ) - return error; - if ( ALLOC_ARRAY( backtrack_classes, ccpf2->MaxBacktrackLength, FT_UShort ) ) return error; known_backtrack_classes = 0; @@ -5428,7 +5286,7 @@ goto End2; known_lookahead_classes = 0; - error = Get_Class( &ccpf2->InputClassDef, in->string[in->pos], + error = Get_Class( &ccpf2->InputClassDef, IN_CURGLYPH(), &input_classes[0], NULL ); if ( error && error != TTO_Err_Not_Covered ) goto End1; @@ -5448,12 +5306,12 @@ lgc = cpcr.LookaheadGlyphCount; if ( context_length != 0xFFFF && context_length < igc ) - continue; + goto next_chainposclassrule; /* check whether context is too long; it is a first guess only */ - if ( bgc > in->pos || in->pos + igc + lgc > in->length ) - continue; + if ( bgc > buffer->in_pos || buffer->in_pos + igc + lgc > buffer->in_length ) + goto next_chainposclassrule; if ( bgc ) { @@ -5461,28 +5319,25 @@ we search backwards for matches in the backtrack glyph array. Note that `known_backtrack_classes' starts at index 0. */ - curr_pos = 0; - s_in = &in->string[curr_pos]; bc = cpcr.Backtrack; - for ( i = 0, j = in->pos - 1; i < bgc; i++, j-- ) + for ( i = 0, j = buffer->in_pos - 1; i < bgc; i++, j-- ) { - while ( CHECK_Property( gdef, s_in[j], flags, &property ) ) + while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) ) { if ( error && error != TTO_Err_Not_Covered ) goto End1; - if ( j > curr_pos ) - j--; - else - break; + if ( j + 1 == bgc - i ) + goto next_chainposclassrule; + j++; } if ( i >= known_backtrack_classes ) { /* Keeps us from having to do this for each rule */ - error = Get_Class( &ccpf2->BacktrackClassDef, s_in[j], + error = Get_Class( &ccpf2->BacktrackClassDef, IN_GLYPH( j ), &backtrack_classes[i], NULL ); if ( error && error != TTO_Err_Not_Covered ) goto End1; @@ -5490,35 +5345,29 @@ } if ( bc[i] != backtrack_classes[i] ) - break; + goto next_chainposclassrule; } - - if ( i != bgc ) - continue; } - curr_pos = in->pos; - s_in = &in->string[curr_pos]; ic = cpcr.Input; /* Start at 1 because [0] is implied */ - for ( i = 1, j = 1; i < igc; i++, j++ ) + for ( i = 1, j = buffer->in_pos + 1; i < igc; i++, j++ ) { - while ( CHECK_Property( gdef, s_in[j], flags, &property ) ) + while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) ) { if ( error && error != TTO_Err_Not_Covered ) goto End1; - if ( curr_pos + j < (int)in->length ) - j++; - else - break; + if ( j + igc - i + lgc == (FT_Int)buffer->in_length ) + goto next_chainposclassrule; + j++; } if ( i >= known_input_classes ) { - error = Get_Class( &ccpf2->InputClassDef, s_in[j], + error = Get_Class( &ccpf2->InputClassDef, IN_GLYPH( j ), &input_classes[i], NULL ); if ( error && error != TTO_Err_Not_Covered ) goto End1; @@ -5526,35 +5375,29 @@ } if ( ic[i - 1] != input_classes[i] ) - break; + goto next_chainposclassrule; } - if ( i != igc ) - continue; - /* we are starting to check for lookahead glyphs right after the last context glyph */ - curr_pos += j; - s_in = &in->string[curr_pos]; lc = cpcr.Lookahead; - for ( i = 0, j = 0; i < lgc; i++, j++ ) + for ( i = 0; i < lgc; i++, j++ ) { - while ( CHECK_Property( gdef, s_in[j], flags, &property ) ) + while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) ) { if ( error && error != TTO_Err_Not_Covered ) goto End1; - if ( curr_pos + j < (int)in->length ) - j++; - else - break; + if ( j + lgc - i == (FT_Int)buffer->in_length ) + goto next_chainposclassrule; + j++; } if ( i >= known_lookahead_classes ) { - error = Get_Class( &ccpf2->LookaheadClassDef, s_in[j], + error = Get_Class( &ccpf2->LookaheadClassDef, IN_GLYPH( j ), &lookahead_classes[i], NULL ); if ( error && error != TTO_Err_Not_Covered ) goto End1; @@ -5562,18 +5405,18 @@ } if ( lc[i] != lookahead_classes[i] ) - break; + goto next_chainposclassrule; } - if ( i == lgc ) - { - error = Do_ContextPos( gpi, igc, - cpcr.PosCount, - cpcr.PosLookupRecord, - in, out, - nesting_level ); - goto End1; - } + error = Do_ContextPos( gpi, igc, + cpcr.PosCount, + cpcr.PosLookupRecord, + buffer, + nesting_level ); + goto End1; + + next_chainposclassrule: + ; } error = TTO_Err_Not_Covered; @@ -5593,16 +5436,14 @@ static FT_Error Lookup_ChainContextPos3( GPOS_Instance* gpi, TTO_ChainContextPosFormat3* ccpf3, - TTO_GSUB_String* in, - TTO_GPOS_Data* out, + OTL_Buffer buffer, FT_UShort flags, FT_UShort context_length, int nesting_level ) { - FT_UShort index, i, j, curr_pos, property; + FT_UShort index, i, j, property; FT_UShort bgc, igc, lgc; FT_Error error; - FT_UShort* s_in; TTO_GPOSHeader* gpos = gpi->gpos; TTO_Coverage* bc; @@ -5611,6 +5452,11 @@ TTO_GDEFHeader* gdef; + gdef = gpos->gdef; + + if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) ) + return error; + bgc = ccpf3->BacktrackGlyphCount; igc = ccpf3->InputGlyphCount; lgc = ccpf3->LookaheadGlyphCount; @@ -5620,61 +5466,50 @@ /* check whether context is too long; it is a first guess only */ - if ( bgc > in->pos || in->pos + igc + lgc > in->length ) + if ( bgc > buffer->in_pos || buffer->in_pos + igc + lgc > buffer->in_length ) return TTO_Err_Not_Covered; - gdef = gpos->gdef; - - if ( CHECK_Property( gdef, in->string[in->pos], flags, &property ) ) - return error; - if ( bgc ) { /* Since we don't know in advance the number of glyphs to inspect, we search backwards for matches in the backtrack glyph array */ - curr_pos = 0; - s_in = &in->string[curr_pos]; bc = ccpf3->BacktrackCoverage; - for ( i = 0, j = in->pos - 1; i < bgc; i++, j-- ) + for ( i = 0, j = buffer->in_pos - 1; i < bgc; i++, j-- ) { - while ( CHECK_Property( gdef, s_in[j], flags, &property ) ) + while ( CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) ) { if ( error && error != TTO_Err_Not_Covered ) return error; - if ( j > curr_pos ) - j--; - else + if ( j + 1 == bgc - i ) return TTO_Err_Not_Covered; + j--; } - error = Coverage_Index( &bc[i], s_in[j], &index ); + error = Coverage_Index( &bc[i], IN_GLYPH( j ), &index ); if ( error ) return error; } } - curr_pos = in->pos; - s_in = &in->string[curr_pos]; ic = ccpf3->InputCoverage; - for ( i = 0, j = 0; i < igc; i++, j++ ) + for ( i = 0, j = buffer->in_pos; i < igc; i++, j++ ) { - /* We already called CHECK_Property for s_in[0] */ - while ( j > 0 && CHECK_Property( gdef, s_in[j], flags, &property ) ) + /* We already called CHECK_Property for IN_GLYPH ( buffer->in_pos ) */ + while ( j > buffer->in_pos && CHECK_Property( gdef, IN_ITEM( j ), flags, &property ) ) { if ( error && error != TTO_Err_Not_Covered ) return error; - if ( curr_pos + j < (int)in->length ) - j++; - else + if ( j + igc - i + lgc == (FT_Int)buffer->in_length ) return TTO_Err_Not_Covered; + j++; } - error = Coverage_Index( &ic[i], s_in[j], &index ); + error = Coverage_Index( &ic[i], IN