# included from harfbuzz.c
INCLUDEDSOURCES = \
- ftglue.c \
harfbuzz-buffer.c \
harfbuzz-gdef.c \
harfbuzz-gpos.c \
harfbuzz-gsub.c \
+ harfbuzz-impl.c \
harfbuzz-open.c
PUBLICHEADERS = \
harfbuzz-open.h
PRIVATEHEADERS = \
- ftglue.h \
harfbuzz-impl.h \
harfbuzz-buffer-private.h \
harfbuzz-gdef-private.h \
+++ /dev/null
-/* ftglue.h: 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 FTGLUE_H
-#define FTGLUE_H
-
-#include <ft2build.h>
-#include FT_FREETYPE_H
-
-#include "harfbuzz-open.h"
-#include "harfbuzz-impl.h"
-
-HB_BEGIN_HEADER
-
-
-/* utility macros */
-
-#ifndef HB_Error
-#define HB_Error FT_Error
-#endif
-
-#define SET_ERR(c) ( (error = (c)) != 0 )
-
-/* stream macros used by the OpenType parser */
-#define FILE_Pos() _hb_ftglue_stream_pos( stream )
-#define FILE_Seek(pos) SET_ERR( _hb_ftglue_stream_seek( stream, pos ) )
-#define ACCESS_Frame(size) SET_ERR( _hb_ftglue_stream_frame_enter( stream, size ) )
-#define FORGET_Frame() _hb_ftglue_stream_frame_exit( stream )
-
-#define GET_Byte() (*stream->cursor++)
-#define GET_Short() (stream->cursor += 2, (HB_Short)( \
- (*(((FT_Byte*)stream->cursor)-2) << 8) | \
- *(((FT_Byte*)stream->cursor)-1) \
- ))
-#define GET_Long() (stream->cursor += 4, (HB_Int)( \
- (*(((FT_Byte*)stream->cursor)-4) << 24) | \
- (*(((FT_Byte*)stream->cursor)-3) << 16) | \
- (*(((FT_Byte*)stream->cursor)-2) << 8) | \
- *(((FT_Byte*)stream->cursor)-1) \
- ))
-
-
-#define GET_Char() ((FT_Char)GET_Byte())
-#define GET_UShort() ((HB_UShort)GET_Short())
-#define GET_ULong() ((HB_UInt)GET_Long())
-#define GET_Tag4() GET_ULong()
-
-HB_INTERNAL HB_Int
-_hb_ftglue_stream_pos( FT_Stream stream );
-
-HB_INTERNAL HB_Error
-_hb_ftglue_stream_seek( FT_Stream stream,
- HB_Int pos );
-
-HB_INTERNAL HB_Error
-_hb_ftglue_stream_frame_enter( FT_Stream stream,
- HB_UInt size );
-
-HB_INTERNAL void
-_hb_ftglue_stream_frame_exit( FT_Stream stream );
-
-HB_INTERNAL HB_Error
-_hb_ftglue_face_goto_table( FT_Face face,
- HB_UInt tag,
- FT_Stream stream );
-
-/* memory macros used by the OpenType parser */
-#define ALLOC(_ptr,_size) \
- ( (_ptr) = _hb_ftglue_alloc( _size, &error ), error != 0 )
-
-#define REALLOC(_ptr,_newsz) \
- ( (_ptr) = _hb_ftglue_realloc( (_ptr), (_newsz), &error ), error != 0 )
-
-#define FREE(_ptr) \
- do { \
- if ( (_ptr) ) \
- { \
- _hb_ftglue_free( _ptr ); \
- _ptr = NULL; \
- } \
- } while (0)
-
-#define ALLOC_ARRAY(_ptr,_count,_type) \
- ALLOC(_ptr,(_count)*sizeof(_type))
-
-#define REALLOC_ARRAY(_ptr,_newcnt,_type) \
- REALLOC(_ptr,(_newcnt)*sizeof(_type))
-
-#define MEM_Copy(dest,source,count) memcpy( (char*)(dest), (const char*)(source), (size_t)(count) )
-
-
-HB_INTERNAL FT_Pointer
-_hb_ftglue_alloc( HB_UInt size,
- HB_Error *perror_ );
-
-HB_INTERNAL FT_Pointer
-_hb_ftglue_realloc( FT_Pointer block,
- HB_UInt new_size,
- HB_Error *perror_ );
-
-HB_INTERNAL void
-_hb_ftglue_free( FT_Pointer block );
-
-/* abuse these private header/source files */
-
-/* helper func to set a breakpoint on */
-HB_INTERNAL HB_Error
-_hb_err (HB_Error code);
-
-HB_END_HEADER
-
-#endif /* FTGLUE_H */
}
static void
-select_cmap (FT_Face face)
-{
- HB_UShort i;
- FT_CharMap cmap = NULL;
-
- for (i = 0; i < face->num_charmaps; i++)
- {
- if (face->charmaps[i]->platform_id == 3 && face->charmaps[i]->encoding_id == 1)
- {
- cmap = face->charmaps[i];
- break;
- }
- }
-
- /* we try only pid/eid (0,0) if no (3,1) map is found -- many Windows
- fonts have only rudimentary (0,0) support. */
-
- if (!cmap)
- for (i = 0; i < face->num_charmaps; i++)
- {
- if (face->charmaps[i]->platform_id == 3 && face->charmaps[i]->encoding_id == 1)
- {
- cmap = face->charmaps[i];
- break;
- }
- }
-
- if (cmap)
- FT_Set_Charmap (face, cmap);
- else
- {
- fprintf (stderr, "Sorry, but this font doesn't contain"
- " any Unicode mapping table.\n");
- exit (1);
- }
-}
-
-static void
add_features (HB_GSUB gsub)
{
HB_Error error;
- HB_UInt tag = FT_MAKE_TAG ('a', 'r', 'a', 'b');
+ HB_UInt tag = HB_MAKE_TAG ('a', 'r', 'a', 'b');
HB_UShort script_index;
error = HB_GSUB_Select_Script (gsub, tag, &script_index);
croak ("HB_GSUB_Select_Script", error);
}
- maybe_add_feature (gsub, script_index, FT_MAKE_TAG ('i', 'n', 'i', 't'), I);
- maybe_add_feature (gsub, script_index, FT_MAKE_TAG ('m', 'e', 'd', 'i'), M);
- maybe_add_feature (gsub, script_index, FT_MAKE_TAG ('f', 'i', 'n', 'a'), F);
- maybe_add_feature (gsub, script_index, FT_MAKE_TAG ('l', 'i', 'g', 'a'), L);
+ maybe_add_feature (gsub, script_index, HB_MAKE_TAG ('i', 'n', 'i', 't'), I);
+ maybe_add_feature (gsub, script_index, HB_MAKE_TAG ('m', 'e', 'd', 'i'), M);
+ maybe_add_feature (gsub, script_index, HB_MAKE_TAG ('f', 'i', 'n', 'a'), F);
+ maybe_add_feature (gsub, script_index, HB_MAKE_TAG ('l', 'i', 'g', 'a'), L);
}
#endif
{
int i;
- FT_UNUSED(hb_type);
+ HB_UNUSED(hb_type);
DUMP_FUINT (LangSys, LookupOrderOffset);
DUMP_FUINT (LangSys, ReqFeatureIndex);
{
int i;
- FT_UNUSED(hb_type);
+ HB_UNUSED(hb_type);
DUMP_FUINT (Feature, FeatureParams);
DUMP_FUINT (Feature, LookupListCount);
DEF_DUMP (MarkRecord)
{
- FT_UNUSED(hb_type);
+ HB_UNUSED(hb_type);
DUMP_FUINT (MarkRecord, Class);
DUMP1("<Anchor>%d</Anchor>\n", MarkRecord->MarkAnchor.PosFormat );
DEF_DUMP (Coverage)
{
- FT_UNUSED(hb_type);
+ HB_UNUSED(hb_type);
DUMP_FUINT (Coverage, CoverageFormat);
DEF_DUMP (ClassRangeRecord)
{
- FT_UNUSED(hb_type);
+ HB_UNUSED(hb_type);
DUMP_FGLYPH (ClassRangeRecord, Start);
DUMP_FGLYPH (ClassRangeRecord, End);
DEF_DUMP (ClassDefinition)
{
- FT_UNUSED(hb_type);
+ HB_UNUSED(hb_type);
DUMP_FUINT( ClassDefinition, ClassFormat);
DUMP_FUINT( ClassDefinition, loaded);
DEF_DUMP (SubstLookupRecord)
{
- FT_UNUSED(hb_type);
+ HB_UNUSED(hb_type);
DUMP_FUINT (SubstLookupRecord, SequenceIndex);
DUMP_FUINT (SubstLookupRecord, LookupListIndex);
{
int i;
- FT_UNUSED(hb_type);
+ HB_UNUSED(hb_type);
DUMP_FGLYPH (Ligature, LigGlyph);
DUMP_FUINT (Ligature, ComponentCount);
DEF_DUMP (ContextSubstFormat1)
{
- FT_UNUSED(hb_type);
- FT_UNUSED(ContextSubstFormat1);
+ HB_UNUSED(hb_type);
+ HB_UNUSED(ContextSubstFormat1);
DUMP("<!-- Not implemented!!! -->\n");
DEF_DUMP (ContextSubstFormat3)
{
- FT_UNUSED(hb_type);
- FT_UNUSED(ContextSubstFormat3);
+ HB_UNUSED(hb_type);
+ HB_UNUSED(ContextSubstFormat3);
DUMP("<!-- Not implemented!!! -->\n");
}
DEF_DUMP (ChainContextSubstFormat1)
{
- FT_UNUSED(hb_type);
- FT_UNUSED(ChainContextSubstFormat1);
+ HB_UNUSED(hb_type);
+ HB_UNUSED(ChainContextSubstFormat1);
DUMP("<!-- Not implemented!!! -->\n");
}
int n_per;
unsigned int mask;
- FT_UNUSED(hb_type);
+ HB_UNUSED(hb_type);
DUMP_FUINT (Device, StartSize);
DUMP_FUINT (Device, EndSize);
#include "harfbuzz-open-private.h"
static HB_Error Load_AttachList( HB_AttachList* al,
- FT_Stream stream );
+ HB_Stream stream );
static HB_Error Load_LigCaretList( HB_LigCaretList* lcl,
- FT_Stream stream );
+ HB_Stream stream );
static void Free_AttachList( HB_AttachList* al );
static void Free_LigCaretList( HB_LigCaretList* lcl );
HB_GDEFHeader** retptr )
{
HB_Error error;
- FT_Stream stream = face->stream;
+ HB_Stream stream = face->stream;
HB_UInt cur_offset, new_offset, base_offset;
HB_GDEFHeader* gdef;
if ( !retptr )
return HB_Err_Invalid_Argument;
- if (( error = _hb_ftglue_face_goto_table( face, TTAG_GDEF, stream ) ))
+ if ( GOTO_Table( TTAG_GDEF ) )
return error;
if (( error = HB_New_GDEF_Table ( &gdef ) ))
/* AttachPoint */
static HB_Error Load_AttachPoint( HB_AttachPoint* ap,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
/* AttachList */
static HB_Error Load_AttachList( HB_AttachList* al,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
/* CaretValueFormat4 */
static HB_Error Load_CaretValue( HB_CaretValue* cv,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
/* LigGlyph */
static HB_Error Load_LigGlyph( HB_LigGlyph* lg,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
/* LigCaretList */
static HB_Error Load_LigCaretList( HB_LigCaretList* lcl,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
typedef signed int HB_Int;
typedef int HB_Bool;
+
+/* compatible with FT_Error */
+typedef enum {
+ HB_Err_Invalid_Argument = FT_Err_Invalid_Argument,
+ HB_Err_Invalid_Face_Handle = FT_Err_Invalid_Face_Handle,
+ HB_Err_Invalid_Stream_Operation = FT_Err_Invalid_Stream_Operation,
+ HB_Err_Empty_Script = 0x1005,
+
+ HB_Err_Ok = FT_Err_Ok,
+ HB_Err_Not_Covered = 0x1002,
+ HB_Err_Out_Of_Memory = FT_Err_Out_Of_Memory,
+ HB_Err_Table_Missing = FT_Err_Table_Missing,
+ HB_Err_Invalid_SubTable_Format = 0x1000,
+ HB_Err_Invalid_SubTable = 0x1001,
+ HB_Err_Too_Many_Nested_Contexts = 0x1003,
+ HB_Err_No_MM_Interpreter = 0x1004
+} HB_Error;
+
HB_END_HEADER
#endif
HB_INTERNAL HB_Error
_HB_GPOS_Load_SubTable( HB_GPOS_SubTable* st,
- FT_Stream stream,
+ HB_Stream stream,
HB_UShort lookup_type );
HB_INTERNAL void
FT_Pos* metric_value,
void* data )
{
- FT_UNUSED(face);
- FT_UNUSED(metric_id);
- FT_UNUSED(metric_value);
- FT_UNUSED(data);
+ HB_UNUSED(face);
+ HB_UNUSED(metric_id);
+ HB_UNUSED(metric_value);
+ HB_UNUSED(data);
return _hb_err(HB_Err_No_MM_Interpreter);
}
HB_GPOSHeader* gpos;
HB_Lookup* lo;
- FT_Stream stream = face->stream;
+ HB_Stream stream = face->stream;
HB_Error error;
if ( !retptr )
return HB_Err_Invalid_Argument;
- if (( error = _hb_ftglue_face_goto_table( face, TTAG_GPOS, stream ) ))
+ if ( GOTO_Table( TTAG_GPOS ) )
return error;
base_offset = FILE_Pos();
static HB_Error Load_ValueRecord( HB_ValueRecord* vr,
HB_UShort format,
HB_UInt base_offset,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
/* AnchorFormat4 */
static HB_Error Load_Anchor( HB_Anchor* an,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
/* MarkArray */
static HB_Error Load_MarkArray ( HB_MarkArray* ma,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
/* SinglePosFormat2 */
static HB_Error Load_SinglePos( HB_GPOS_SubTable* st,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
HB_SinglePos* sp = &st->single;
HB_GPOSHeader* gpos = gpi->gpos;
HB_SinglePos* sp = &st->single;
- FT_UNUSED(nesting_level);
+ HB_UNUSED(nesting_level);
if ( context_length != 0xFFFF && context_length < 1 )
return HB_Err_Not_Covered;
static HB_Error Load_PairSet ( HB_PairSet* ps,
HB_UShort format1,
HB_UShort format2,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
static HB_Error Load_PairPos1( HB_PairPosFormat1* ppf1,
HB_UShort format1,
HB_UShort format2,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
static HB_Error Load_PairPos2( HB_PairPosFormat2* ppf2,
HB_UShort format1,
HB_UShort format2,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
static HB_Error Load_PairPos( HB_GPOS_SubTable* st,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
HB_PairPos* pp = &st->pair;
HB_GPOSHeader* gpos = gpi->gpos;
HB_PairPos* pp = &st->pair;
- FT_UNUSED(nesting_level);
+ HB_UNUSED(nesting_level);
if ( buffer->in_pos >= buffer->in_length - 1 )
return HB_Err_Not_Covered; /* Not enough glyphs in stream */
/* CursivePosFormat1 */
static HB_Error Load_CursivePos( HB_GPOS_SubTable* st,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
HB_CursivePos* cp = &st->cursive;
FT_Pos entry_x, entry_y;
FT_Pos exit_x, exit_y;
- FT_UNUSED(nesting_level);
+ HB_UNUSED(nesting_level);
if ( context_length != 0xFFFF && context_length < 1 )
{
static HB_Error Load_BaseArray( HB_BaseArray* ba,
HB_UShort num_classes,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
/* MarkBasePosFormat1 */
static HB_Error Load_MarkBasePos( HB_GPOS_SubTable* st,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
HB_MarkBasePos* mbp = &st->markbase;
HB_Position o;
- FT_UNUSED(nesting_level);
+ HB_UNUSED(nesting_level);
if ( context_length != 0xFFFF && context_length < 1 )
return HB_Err_Not_Covered;
static HB_Error Load_LigatureAttach( HB_LigatureAttach* lat,
HB_UShort num_classes,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
static HB_Error Load_LigatureArray( HB_LigatureArray* la,
HB_UShort num_classes,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
/* MarkLigPosFormat1 */
static HB_Error Load_MarkLigPos( HB_GPOS_SubTable* st,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
HB_MarkLigPos* mlp = &st->marklig;
HB_Position o;
- FT_UNUSED(nesting_level);
+ HB_UNUSED(nesting_level);
if ( context_length != 0xFFFF && context_length < 1 )
return HB_Err_Not_Covered;
static HB_Error Load_Mark2Array( HB_Mark2Array* m2a,
HB_UShort num_classes,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
/* MarkMarkPosFormat1 */
static HB_Error Load_MarkMarkPos( HB_GPOS_SubTable* st,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
HB_MarkMarkPos* mmp = &st->markmark;
HB_Position o;
- FT_UNUSED(nesting_level);
+ HB_UNUSED(nesting_level);
if ( context_length != 0xFFFF && context_length < 1 )
return HB_Err_Not_Covered;
/* PosRule */
static HB_Error Load_PosRule( HB_PosRule* pr,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
/* PosRuleSet */
static HB_Error Load_PosRuleSet( HB_PosRuleSet* prs,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
/* ContextPosFormat1 */
static HB_Error Load_ContextPos1( HB_ContextPosFormat1* cpf1,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
static HB_Error Load_PosClassRule( HB_ContextPosFormat2* cpf2,
HB_PosClassRule* pcr,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
static HB_Error Load_PosClassSet( HB_ContextPosFormat2* cpf2,
HB_PosClassSet* pcs,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
/* ContextPosFormat2 */
static HB_Error Load_ContextPos2( HB_ContextPosFormat2* cpf2,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
/* ContextPosFormat3 */
static HB_Error Load_ContextPos3( HB_ContextPosFormat3* cpf3,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
/* ContextPos */
static HB_Error Load_ContextPos( HB_GPOS_SubTable* st,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
HB_ContextPos* cp = &st->context;
/* ChainPosRule */
static HB_Error Load_ChainPosRule( HB_ChainPosRule* cpr,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
/* ChainPosRuleSet */
static HB_Error Load_ChainPosRuleSet( HB_ChainPosRuleSet* cprs,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
/* ChainContextPosFormat1 */
static HB_Error Load_ChainContextPos1( HB_ChainContextPosFormat1* ccpf1,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
static HB_Error Load_ChainPosClassRule(
HB_ChainContextPosFormat2* ccpf2,
HB_ChainPosClassRule* cpcr,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
static HB_Error Load_ChainPosClassSet(
HB_ChainContextPosFormat2* ccpf2,
HB_ChainPosClassSet* cpcs,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
/* ChainContextPosFormat2 */
static HB_Error Load_ChainContextPos2( HB_ChainContextPosFormat2* ccpf2,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
/* ChainContextPosFormat3 */
static HB_Error Load_ChainContextPos3( HB_ChainContextPosFormat3* ccpf3,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
/* ChainContextPos */
static HB_Error Load_ChainContextPos( HB_GPOS_SubTable* st,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
HB_ChainContextPos* ccp = &st->chain;
HB_INTERNAL HB_Error
_HB_GPOS_Load_SubTable( HB_GPOS_SubTable* st,
- FT_Stream stream,
+ HB_Stream stream,
HB_UShort lookup_type )
{
switch ( lookup_type ) {
HB_INTERNAL HB_Error
_HB_GSUB_Load_SubTable( HB_GSUB_SubTable* st,
- FT_Stream stream,
+ HB_Stream stream,
HB_UShort lookup_type );
HB_INTERNAL void
HB_GSUBHeader** retptr,
HB_GDEFHeader* gdef )
{
- FT_Stream stream = face->stream;
+ HB_Stream stream = face->stream;
HB_Error error;
HB_UInt cur_offset, new_offset, base_offset;
if ( !retptr )
return HB_Err_Invalid_Argument;
- if (( error = _hb_ftglue_face_goto_table( face, TTAG_GSUB, stream ) ))
+ if ( GOTO_Table( TTAG_GSUB ) )
return error;
base_offset = FILE_Pos();
/* SingleSubstFormat2 */
static HB_Error Load_SingleSubst( HB_GSUB_SubTable* st,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
HB_SingleSubst* ss = &st->single;
HB_SingleSubst* ss = &st->single;
HB_GDEFHeader* gdef = gsub->gdef;
- FT_UNUSED(nesting_level);
+ HB_UNUSED(nesting_level);
if ( context_length != 0xFFFF && context_length < 1 )
return HB_Err_Not_Covered;
/* Sequence */
static HB_Error Load_Sequence( HB_Sequence* s,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
/* MultipleSubstFormat1 */
static HB_Error Load_MultipleSubst( HB_GSUB_SubTable* st,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
HB_MultipleSubst* ms = &st->multiple;
HB_MultipleSubst* ms = &st->multiple;
HB_GDEFHeader* gdef = gsub->gdef;
- FT_UNUSED(nesting_level);
+ HB_UNUSED(nesting_level);
if ( context_length != 0xFFFF && context_length < 1 )
return HB_Err_Not_Covered;
/* AlternateSet */
static HB_Error Load_AlternateSet( HB_AlternateSet* as,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
/* AlternateSubstFormat1 */
static HB_Error Load_AlternateSubst( HB_GSUB_SubTable* st,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
HB_AlternateSubst* as = &st->alternate;
HB_GDEFHeader* gdef = gsub->gdef;
HB_AlternateSet aset;
- FT_UNUSED(nesting_level);
+ HB_UNUSED(nesting_level);
if ( context_length != 0xFFFF && context_length < 1 )
return HB_Err_Not_Covered;
/* Ligature */
static HB_Error Load_Ligature( HB_Ligature* l,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
/* LigatureSet */
static HB_Error Load_LigatureSet( HB_LigatureSet* ls,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
/* LigatureSubstFormat1 */
static HB_Error Load_LigatureSubst( HB_GSUB_SubTable* st,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
HB_LigatureSubst* ls = &st->ligature;
HB_Ligature* lig;
- FT_UNUSED(nesting_level);
+ HB_UNUSED(nesting_level);
if ( CHECK_Property( gdef, IN_CURITEM(), flags, &property ) )
return error;
/* SubRule */
static HB_Error Load_SubRule( HB_SubRule* sr,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
/* SubRuleSet */
static HB_Error Load_SubRuleSet( HB_SubRuleSet* srs,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
/* ContextSubstFormat1 */
static HB_Error Load_ContextSubst1( HB_ContextSubstFormat1* csf1,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
static HB_Error Load_SubClassRule( HB_ContextSubstFormat2* csf2,
HB_SubClassRule* scr,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
static HB_Error Load_SubClassSet( HB_ContextSubstFormat2* csf2,
HB_SubClassSet* scs,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
/* ContextSubstFormat2 */
static HB_Error Load_ContextSubst2( HB_ContextSubstFormat2* csf2,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
/* ContextSubstFormat3 */
static HB_Error Load_ContextSubst3( HB_ContextSubstFormat3* csf3,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
/* ContextSubst */
static HB_Error Load_ContextSubst( HB_GSUB_SubTable* st,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
HB_ContextSubst* cs = &st->context;
/* ChainSubRule */
static HB_Error Load_ChainSubRule( HB_ChainSubRule* csr,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
/* ChainSubRuleSet */
static HB_Error Load_ChainSubRuleSet( HB_ChainSubRuleSet* csrs,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
static HB_Error Load_ChainContextSubst1(
HB_ChainContextSubstFormat1* ccsf1,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
static HB_Error Load_ChainSubClassRule(
HB_ChainContextSubstFormat2* ccsf2,
HB_ChainSubClassRule* cscr,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
static HB_Error Load_ChainSubClassSet(
HB_ChainContextSubstFormat2* ccsf2,
HB_ChainSubClassSet* cscs,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
static HB_Error Load_ChainContextSubst2(
HB_ChainContextSubstFormat2* ccsf2,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
static HB_Error Load_ChainContextSubst3(
HB_ChainContextSubstFormat3* ccsf3,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
/* ChainContextSubst */
static HB_Error Load_ChainContextSubst( HB_GSUB_SubTable* st,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
HB_ChainContextSubst* ccs = &st->chain;
static HB_Error Load_ReverseChainContextSubst( HB_GSUB_SubTable* st,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
HB_ReverseChainContextSubst* rccs = &st->reverse;
HB_INTERNAL HB_Error
_HB_GSUB_Load_SubTable( HB_GSUB_SubTable* st,
- FT_Stream stream,
+ HB_Stream stream,
HB_UShort lookup_type )
{
switch (lookup_type) {
-/* 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"
+#include "harfbuzz-impl.h"
#if 0
#include <stdio.h>
-#define LOG(x) _hb_ftglue_log x
+#define LOG(x) _hb_log x
static void
-_hb_ftglue_log( const char* format, ... )
+_hb_log( const char* format, ... )
{
va_list ap;
/* only used internally */
static FT_Pointer
-_hb_ftglue_qalloc( HB_UInt size,
- HB_Error *perror )
+_hb_qalloc( HB_UInt size,
+ HB_Error *perror )
{
HB_Error error = 0;
FT_Pointer block = NULL;
}
#undef QALLOC /* just in case */
-#define QALLOC(ptr,size) ( (ptr) = _hb_ftglue_qalloc( (size), &error ), error != 0 )
+#define QALLOC(ptr,size) ( (ptr) = _hb_qalloc( (size), &error ), error != 0 )
HB_INTERNAL FT_Pointer
-_hb_ftglue_alloc( HB_UInt size,
- HB_Error *perror )
+_hb_alloc( HB_UInt size,
+ HB_Error *perror )
{
HB_Error error = 0;
FT_Pointer block = NULL;
HB_INTERNAL FT_Pointer
-_hb_ftglue_realloc( FT_Pointer block,
- HB_UInt new_size,
- HB_Error *perror )
+_hb_realloc( FT_Pointer block,
+ HB_UInt new_size,
+ HB_Error *perror )
{
FT_Pointer block2 = NULL;
HB_Error error = 0;
HB_INTERNAL void
-_hb_ftglue_free( FT_Pointer block )
+_hb_free( FT_Pointer block )
{
if ( block )
free( block );
HB_INTERNAL HB_Int
-_hb_ftglue_stream_pos( FT_Stream stream )
+_hb_stream_pos( HB_Stream stream )
{
- LOG(( "ftglue:stream:pos() -> %ld\n", stream->pos ));
+ LOG(( "_hb_stream_pos() -> %ld\n", stream->pos ));
return stream->pos;
}
HB_INTERNAL HB_Error
-_hb_ftglue_stream_seek( FT_Stream stream,
- HB_Int pos )
+_hb_stream_seek( HB_Stream stream,
+ HB_Int pos )
{
HB_Error error = 0;
else if ( pos > (HB_Int)stream->size )
error = HB_Err_Invalid_Stream_Operation;
- LOG(( "ftglue:stream:seek(%ld) -> %d\n", pos, error ));
+ LOG(( "_hb_stream_seek(%ld) -> %d\n", pos, error ));
return error;
}
HB_INTERNAL HB_Error
-_hb_ftglue_stream_frame_enter( FT_Stream stream,
- HB_UInt count )
+_hb_stream_frame_enter( HB_Stream stream,
+ HB_UInt count )
{
HB_Error error = HB_Err_Ok;
HB_UInt read_bytes;
}
Exit:
- LOG(( "ftglue:stream:frame_enter(%ld) -> %d\n", count, error ));
+ LOG(( "_hb_stream_frame_enter(%ld) -> %d\n", count, error ));
return error;
}
HB_INTERNAL void
-_hb_ftglue_stream_frame_exit( FT_Stream stream )
+_hb_stream_frame_exit( HB_Stream stream )
{
if ( stream->read )
{
stream->cursor = NULL;
stream->limit = NULL;
- LOG(( "ftglue:stream:frame_exit()\n" ));
+ LOG(( "_hb_stream_frame_exit()\n" ));
}
HB_INTERNAL HB_Error
-_hb_ftglue_face_goto_table( FT_Face face,
- HB_UInt the_tag,
- FT_Stream stream )
+_hb_face_goto_table( FT_Face face,
+ HB_UInt the_tag,
+ HB_Stream stream )
{
HB_Error error;
- LOG(( "_hb_ftglue_face_goto_table( %p, %c%c%c%c, %p )\n",
+ LOG(( "_hb_face_goto_table( %p, %c%c%c%c, %p )\n",
face,
(int)((the_tag >> 24) & 0xFF),
(int)((the_tag >> 16) & 0xFF),
HB_UInt start = GET_ULong();
HB_UInt size = GET_ULong();
- FT_UNUSED(checksum);
- FT_UNUSED(size);
+ HB_UNUSED(checksum);
+ HB_UNUSED(size);
if ( tag == the_tag )
{
LOG(( "TrueType table (start: %ld) (size: %ld)\n", start, size ));
- error = _hb_ftglue_stream_seek( stream, start );
+ error = _hb_stream_seek( stream, start );
goto FoundIt;
}
}
HB_BEGIN_HEADER
+/***********************************************************************/
+/************************ remaining freetype bits **********************/
+/***********************************************************************/
+
+typedef FT_Stream HB_Stream;
+#define HB_MAKE_TAG(a,b,c,d) FT_MAKE_TAG(a,b,c,d)
+
+/***********************************************************************/
+/***********************************************************************/
+/***********************************************************************/
+
#ifndef HB_INTERNAL
# define HB_INTERNAL
#endif
#endif
#ifndef TTAG_GDEF
-# define TTAG_GDEF FT_MAKE_TAG( 'G', 'D', 'E', 'F' )
+# define TTAG_GDEF HB_MAKE_TAG( 'G', 'D', 'E', 'F' )
#endif
#ifndef TTAG_GPOS
-# define TTAG_GPOS FT_MAKE_TAG( 'G', 'P', 'O', 'S' )
+# define TTAG_GPOS HB_MAKE_TAG( 'G', 'P', 'O', 'S' )
#endif
#ifndef TTAG_GSUB
-# define TTAG_GSUB FT_MAKE_TAG( 'G', 'S', 'U', 'B' )
+# define TTAG_GSUB HB_MAKE_TAG( 'G', 'S', 'U', 'B' )
#endif
-#ifndef FT_UNUSED
-# define FT_UNUSED(arg) ((arg) = (arg))
+#ifndef HB_UNUSED
+# define HB_UNUSED(arg) ((arg) = (arg))
#endif
#define HB_LIKELY(cond) (cond)
#define HB_UNLIKELY(cond) (cond)
-#include "ftglue.h"
-
#define ARRAY_LEN(Array) ((int)(sizeof (Array) / sizeof (Array)[0]))
+/* memory and stream management */
+
+#define SET_ERR(c) ( (error = (c)) != 0 )
+
+/* stream macros used by the OpenType parser */
+#define GOTO_Table(tag) SET_ERR( _hb_face_goto_table( face, tag, stream ) )
+#define FILE_Pos() _hb_stream_pos( stream )
+#define FILE_Seek(pos) SET_ERR( _hb_stream_seek( stream, pos ) )
+#define ACCESS_Frame(size) SET_ERR( _hb_stream_frame_enter( stream, size ) )
+#define FORGET_Frame() _hb_stream_frame_exit( stream )
+
+#define GET_Byte() (*stream->cursor++)
+#define GET_Short() (stream->cursor += 2, (HB_Short)( \
+ (*(((FT_Byte*)stream->cursor)-2) << 8) | \
+ *(((FT_Byte*)stream->cursor)-1) \
+ ))
+#define GET_Long() (stream->cursor += 4, (HB_Int)( \
+ (*(((FT_Byte*)stream->cursor)-4) << 24) | \
+ (*(((FT_Byte*)stream->cursor)-3) << 16) | \
+ (*(((FT_Byte*)stream->cursor)-2) << 8) | \
+ *(((FT_Byte*)stream->cursor)-1) \
+ ))
+
+
+#define GET_Char() ((FT_Char)GET_Byte())
+#define GET_UShort() ((HB_UShort)GET_Short())
+#define GET_ULong() ((HB_UInt)GET_Long())
+#define GET_Tag4() GET_ULong()
+
+
+HB_INTERNAL HB_Int
+_hb_stream_pos( HB_Stream stream );
+
+HB_INTERNAL HB_Error
+_hb_stream_seek( HB_Stream stream,
+ HB_Int pos );
+
+HB_INTERNAL HB_Error
+_hb_stream_frame_enter( HB_Stream stream,
+ HB_UInt size );
+
+HB_INTERNAL void
+_hb_stream_frame_exit( HB_Stream stream );
+
+HB_INTERNAL HB_Error
+_hb_face_goto_table( FT_Face face,
+ HB_UInt tag,
+ HB_Stream stream );
+
+#define ALLOC(_ptr,_size) \
+ ( (_ptr) = _hb_alloc( _size, &error ), error != 0 )
+
+#define REALLOC(_ptr,_newsz) \
+ ( (_ptr) = _hb_realloc( (_ptr), (_newsz), &error ), error != 0 )
+
+#define FREE(_ptr) \
+ do { \
+ if ( (_ptr) ) \
+ { \
+ _hb_free( _ptr ); \
+ _ptr = NULL; \
+ } \
+ } while (0)
+
+#define ALLOC_ARRAY(_ptr,_count,_type) \
+ ALLOC(_ptr,(_count)*sizeof(_type))
+
+#define REALLOC_ARRAY(_ptr,_newcnt,_type) \
+ REALLOC(_ptr,(_newcnt)*sizeof(_type))
+
+#define MEM_Copy(dest,source,count) memcpy( (char*)(dest), (const char*)(source), (size_t)(count) )
+
+
+HB_INTERNAL FT_Pointer
+_hb_alloc( HB_UInt size,
+ HB_Error *perror_ );
+
+HB_INTERNAL FT_Pointer
+_hb_realloc( FT_Pointer block,
+ HB_UInt new_size,
+ HB_Error *perror_ );
+
+HB_INTERNAL void
+_hb_free( FT_Pointer block );
+
+
+/* helper func to set a breakpoint on */
+HB_INTERNAL HB_Error
+_hb_err (HB_Error code);
+
+/* buffer access macros */
#define IN_GLYPH( pos ) (buffer->in_string[(pos)].gindex)
#define IN_ITEM( pos ) (&buffer->in_string[(pos)])
HB_INTERNAL HB_Error
_HB_OPEN_Load_ScriptList( HB_ScriptList* sl,
- FT_Stream stream );
+ HB_Stream stream );
HB_INTERNAL HB_Error
_HB_OPEN_Load_FeatureList( HB_FeatureList* fl,
- FT_Stream input );
+ HB_Stream input );
HB_INTERNAL HB_Error
_HB_OPEN_Load_LookupList( HB_LookupList* ll,
- FT_Stream input,
+ HB_Stream input,
HB_Type type );
HB_INTERNAL HB_Error
_HB_OPEN_Load_Coverage( HB_Coverage* c,
- FT_Stream input );
+ HB_Stream input );
HB_INTERNAL HB_Error
_HB_OPEN_Load_ClassDefinition( HB_ClassDefinition* cd,
HB_UShort limit,
- FT_Stream input );
+ HB_Stream input );
HB_INTERNAL HB_Error
_HB_OPEN_Load_EmptyOrClassDefinition( HB_ClassDefinition* cd,
HB_UShort limit,
HB_UInt class_offset,
HB_UInt base_offset,
- FT_Stream stream );
+ HB_Stream stream );
HB_INTERNAL HB_Error
_HB_OPEN_Load_Device( HB_Device* d,
- FT_Stream input );
+ HB_Stream input );
HB_INTERNAL void _HB_OPEN_Free_ScriptList( HB_ScriptList* sl );
HB_INTERNAL void _HB_OPEN_Free_FeatureList( HB_FeatureList* fl );
/* LangSys */
static HB_Error Load_LangSys( HB_LangSys* ls,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
HB_UShort n, count;
/* Script */
static HB_Error Load_Script( HB_Script* s,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
HB_UShort n, m, count;
HB_INTERNAL HB_Error
_HB_OPEN_Load_ScriptList( HB_ScriptList* sl,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
/* Feature */
static HB_Error Load_Feature( HB_Feature* f,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
HB_INTERNAL HB_Error
_HB_OPEN_Load_FeatureList( HB_FeatureList* fl,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
/* SubTable */
static HB_Error Load_SubTable( HB_SubTable* st,
- FT_Stream stream,
+ HB_Stream stream,
HB_Type table_type,
HB_UShort lookup_type )
{
/* Lookup */
static HB_Error Load_Lookup( HB_Lookup* l,
- FT_Stream stream,
+ HB_Stream stream,
HB_Type type )
{
HB_Error error;
HB_INTERNAL HB_Error
_HB_OPEN_Load_LookupList( HB_LookupList* ll,
- FT_Stream stream,
+ HB_Stream stream,
HB_Type type )
{
HB_Error error;
/* CoverageFormat1 */
static HB_Error Load_Coverage1( HB_CoverageFormat1* cf1,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
/* CoverageFormat2 */
static HB_Error Load_Coverage2( HB_CoverageFormat2* cf2,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
HB_INTERNAL HB_Error
_HB_OPEN_Load_Coverage( HB_Coverage* c,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
static HB_Error Load_ClassDef1( HB_ClassDefinition* cd,
HB_UShort limit,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
static HB_Error Load_ClassDef2( HB_ClassDefinition* cd,
HB_UShort limit,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
HB_INTERNAL HB_Error
_HB_OPEN_Load_ClassDefinition( HB_ClassDefinition* cd,
HB_UShort limit,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
HB_UShort limit,
HB_UInt class_offset,
HB_UInt base_offset,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
HB_UInt cur_offset;
HB_INTERNAL HB_Error
_HB_OPEN_Load_Device( HB_Device* d,
- FT_Stream stream )
+ HB_Stream stream )
{
HB_Error error;
#define HB_MAX_NESTING_LEVEL 100
-typedef FT_Error HB_Error;
-
-#define HB_Err_Invalid_Argument FT_Err_Invalid_Argument
-#define HB_Err_Invalid_Face_Handle FT_Err_Invalid_Face_Handle
-#define HB_Err_Invalid_Stream_Operation FT_Err_Invalid_Stream_Operation
-#define HB_Err_Empty_Script 0x1005
-
-#define HB_Err_Ok FT_Err_Ok
-#define HB_Err_Not_Covered 0x1002
-#define HB_Err_Out_Of_Memory FT_Err_Out_Of_Memory
-#define HB_Err_Table_Missing FT_Err_Table_Missing
-#define HB_Err_Invalid_SubTable_Format 0x1000
-#define HB_Err_Invalid_SubTable 0x1001
-#define HB_Err_Too_Many_Nested_Contexts 0x1003
-#define HB_Err_No_MM_Interpreter 0x1004
-
/* Script list related structures */
*
******************************************************************/
#define HB_INTERNAL static
-#include "ftglue.c"
-#include "harfbuzz-open.c"
#include "harfbuzz-buffer.c"
#include "harfbuzz-gdef.c"
#include "harfbuzz-gsub.c"
#include "harfbuzz-gpos.c"
+#include "harfbuzz-impl.c"
+#include "harfbuzz-open.c"