date: 2001/08/08 19:28:55; author: werner; state: Exp; lines: +6 -2 Updated GPOS and GSUB support to OpenType 1.3 -- this also fixes a problem with cursive connections (there were incorrect vertical offsets). . OT 1.3 reintroduced the RIGHT_TO_LEFT lookup flag (but with a new meaning). A new member `first' has been added to the GPOS_Instance structure; it marks the beginning of a chain of valid cursive connections. If the chain has ended, and if this flag is set, all vertical offsets are shifted upwards so that the last glyph of the chain is on the baseline. . Extension lookups (for both GSUB and GPOS) are now implemented. Index: ftxgpos.c =================================================================== RCS file: /cvs/freetype/freetype/lib/extend/ftxgpos.c,v retrieving revision 1.12 retrieving revision 1.13 diff -u -p -r1.12 -r1.13 --- ftxgpos.c 2001/03/29 13:20:12 1.12 +++ ftxgpos.c 2001/08/08 19:28:53 1.13 @@ -40,6 +40,8 @@ UShort load_flags; /* how the glyph should be loaded */ TT_Bool r2l; + UShort first; /* the first glyph in a chain of + cursive connections */ UShort last; /* the last valid glyph -- used with cursive positioning */ TT_Pos anchor_x; /* the coordinates of the anchor point */ @@ -2069,6 +2071,8 @@ gpi->last = 0xFFFF; else { + if ( gpi->first == 0xFFFF ) + gpi->first = in->pos; gpi->last = in->pos; gpi->anchor_x = exit_x; gpi->anchor_y = exit_y; @@ -6014,9 +6018,12 @@ UShort* p_in = in->properties; int nesting_level = 0; + UShort i; + TT_Pos offset; - gpi->last = 0xFFFF; /* no last valid glyph for cursive pos. */ + gpi->first = 0xFFFF; + gpi->last = 0xFFFF; /* no last valid glyph for cursive pos. */ in->pos = 0; @@ -6045,6 +6052,22 @@ gpi->last = 0xFFFF; error = TTO_Err_Not_Covered; + } + + /* test whether we have to adjust the offsets for cursive connections */ + + if ( gpi->first != 0xFFFF && gpi->last == 0xFFFF && + gpos->LookupList.Lookup[lookup_index].LookupFlag & RIGHT_TO_LEFT ) + { + offset = out[in->pos].y_pos; + + /* no horizontal offsets (for vertical writing direction) + supported yet */ + + for ( i = gpi->first; i <= in->pos; i++ ) + out[i].y_pos -= offset; + + gpi->first = 0xFFFF; } if ( error == TTO_Err_Not_Covered ) Index: ftxgpos.h =================================================================== RCS file: /cvs/freetype/freetype/lib/extend/ftxgpos.h,v retrieving revision 1.13 retrieving revision 1.14 diff -u -p -r1.13 -r1.14 --- ftxgpos.h 2001/03/06 13:55:38 1.13 +++ ftxgpos.h 2001/08/08 19:28:55 1.14 @@ -34,14 +34,15 @@ extern "C" { /* Lookup types for glyph positioning */ -#define GPOS_LOOKUP_SINGLE 1 -#define GPOS_LOOKUP_PAIR 2 -#define GPOS_LOOKUP_CURSIVE 3 -#define GPOS_LOOKUP_MARKBASE 4 -#define GPOS_LOOKUP_MARKLIG 5 -#define GPOS_LOOKUP_MARKMARK 6 -#define GPOS_LOOKUP_CONTEXT 7 -#define GPOS_LOOKUP_CHAIN 8 +#define GPOS_LOOKUP_SINGLE 1 +#define GPOS_LOOKUP_PAIR 2 +#define GPOS_LOOKUP_CURSIVE 3 +#define GPOS_LOOKUP_MARKBASE 4 +#define GPOS_LOOKUP_MARKLIG 5 +#define GPOS_LOOKUP_MARKMARK 6 +#define GPOS_LOOKUP_CONTEXT 7 +#define GPOS_LOOKUP_CHAIN 8 +#define GPOS_LOOKUP_EXTENSION 9 /* A pointer to a function which loads a glyph. Its parameters are Index: ftxgsub.h =================================================================== RCS file: /cvs/freetype/freetype/lib/extend/ftxgsub.h,v retrieving revision 1.29 retrieving revision 1.30 diff -u -p -r1.29 -r1.30 --- ftxgsub.h 2001/03/06 13:55:38 1.29 +++ ftxgsub.h 2001/08/08 19:28:55 1.30 @@ -40,6 +40,7 @@ extern "C" { #define GSUB_LOOKUP_LIGATURE 4 #define GSUB_LOOKUP_CONTEXT 5 #define GSUB_LOOKUP_CHAIN 6 +#define GSUB_LOOKUP_EXTENSION 7 /* Use this if a feature applies to all glyphs */ Index: ftxopen.c =================================================================== RCS file: /cvs/freetype/freetype/lib/extend/ftxopen.c,v retrieving revision 1.19 retrieving revision 1.20 diff -u -p -r1.19 -r1.20 --- ftxopen.c 2000/01/05 01:16:06 1.19 +++ ftxopen.c 2001/08/08 19:28:55 1.20 @@ -561,7 +561,9 @@ TTO_SubTable* st; + Bool is_extension = FALSE; + base_offset = FILE_Pos(); if ( ACCESS_Frame( 6L ) ) @@ -580,6 +582,10 @@ st = l->SubTable; + if ( ( type == GSUB && l->LookupType == GSUB_LOOKUP_EXTENSION ) || + ( type == GPOS && l->LookupType == GPOS_LOOKUP_EXTENSION ) ) + is_extension = TRUE; + for ( n = 0; n < count; n++ ) { if ( ACCESS_Frame( 2L ) ) @@ -590,6 +596,19 @@ FORGET_Frame(); cur_offset = FILE_Pos(); + + if ( is_extension ) + { + if ( FILE_Seek( new_offset ) || ACCESS_Frame( 8L ) ) + goto Fail; + + (void)GET_UShort(); /* format should be 1 */ + l->LookupType = GET_UShort(); + new_offset = GET_ULong() + base_offset; + + FORGET_Frame(); + } + if ( FILE_Seek( new_offset ) || ( error = Load_SubTable( &st[n], input, type, l->LookupType ) ) != TT_Err_Ok ) Index: ftxopen.h =================================================================== RCS file: /cvs/freetype/freetype/lib/extend/ftxopen.h,v retrieving revision 1.18 retrieving revision 1.19 diff -u -p -r1.18 -r1.19 --- ftxopen.h 2001/08/06 19:25:51 1.18 +++ ftxopen.h 2001/08/08 19:28:55 1.19 @@ -143,9 +143,13 @@ extern "C" { } TTO_LookupList; -/* Possible LookupFlag bit masks. `IGNORE_SPECIAL_MARKS' comes from the - OpenType 1.2 specification. */ + /* Possible LookupFlag bit masks. `IGNORE_SPECIAL_MARKS' comes from the + OpenType 1.2 specification; RIGHT_TO_LEFT has been (re)introduced in + OpenType 1.3 -- if set, the last glyph in a cursive attachment + sequence has to be positioned on the baseline -- regardless of the + writing direction. */ +#define RIGHT_TO_LEFT 0x0001 #define IGNORE_BASE_GLYPHS 0x0002 #define IGNORE_LIGATURES 0x0004 #define IGNORE_MARKS 0x0008