1 /* Copyright (C) 2000-2008 by George Williams */
2 /*
3  * Redistribution and use in source and binary forms, with or without
4  * modification, are permitted provided that the following conditions are met:
5 
6  * Redistributions of source code must retain the above copyright notice, this
7  * list of conditions and the following disclaimer.
8 
9  * Redistributions in binary form must reproduce the above copyright notice,
10  * this list of conditions and the following disclaimer in the documentation
11  * and/or other materials provided with the distribution.
12 
13  * The name of the author may not be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15 
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19  * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 #ifndef _SFD1_H
28 #define _SFD1_H
29 /* This file contains the data structures needed to read in an old sfd file */
30 /* features and lookups and scripts are handled differently. That means that */
31 /* the KernPair, KernClass, PST, FPST, AnchorClass, StateMachine data structures */
32 /* are organized differently. Also we've got a script language list which */
33 /* doesn't exist in the new format and we don't have OTLookup */
34 
35 #include "splinefont.h"
36 
37 #define SLI_UNKNOWN		0xffff
38 #define SLI_NESTED		0xfffe
39 
40 typedef struct anchorclass1 {
41     AnchorClass ac;
42     uint32 feature_tag;
43     uint16 script_lang_index;
44     uint16 flags;
45     uint16 merge_with;
46     uint8 has_bases;
47     uint8 has_ligatures;
48 } AnchorClass1;
49 
50 typedef struct kernpair1 {
51     KernPair kp;
52     uint16 sli, flags;
53 } KernPair1;
54 
55 typedef struct kernclass1 {
56     KernClass kc;
57     uint16 sli;
58     uint16 flags;
59 } KernClass1;
60 
61 typedef struct generic_pst1 {
62     PST pst;
63     uint16 flags;
64     uint16 script_lang_index;		/* 0xffff means none */
65     uint32 tag;
66 } PST1;
67 
68 typedef struct generic_fpst1 {
69     FPST fpst;
70     uint16 script_lang_index;
71     uint16 flags;
72     uint32 tag;
73 } FPST1;
74 
75 typedef struct splinefont1 {
76     SplineFont sf;
77 
78     struct table_ordering { uint32 table_tag; uint32 *ordered_features; struct table_ordering *next; } *orders;
79 
80     /* Any GPOS/GSUB entry (PST, AnchorClass, kerns, FPST */
81     /*  Has an entry saying what scripts/languages it should appear it */
82     /*  Things like fractions will appear in almost all possible script/lang */
83     /*  combinations, while alphabetic ligatures will only live in one script */
84     /* Rather than store the complete list of possibilities in each PST we */
85     /*  store all choices used here, and just store an index into this list */
86     /*  in the PST. All lists are terminated by a 0 entry */
87     struct script_record {
88 	uint32 script;
89 	uint32 *langs;
90     } **script_lang;
91     int16 sli_cnt;
92 
93     struct gentagtype {
94 	uint16 tt_cur, tt_max;
95 	struct tagtype {
96 	    enum possub_type type;
97 	    uint32 tag;
98 	} *tagtype;
99     } gentags;
100 } SplineFont1;
101 
102 extern int SFFindBiggestScriptLangIndex(SplineFont *_sf,uint32 script,uint32 lang);
103 extern int SFAddScriptIndex(SplineFont1 *sf,uint32 *scripts,int scnt);
104 extern void SFD_AssignLookups(SplineFont1 *sf);
105 #endif		/* _SFD1_H */
106