/
splinefont.h
3559 lines (3245 loc) · 151 KB
/
splinefont.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* Copyright (C) 2000-2012 by George Williams */
/*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _SPLINEFONT_H
#define _SPLINEFONT_H
#include <basics.h>
#include <dlist.h>
#include "configure-fontforge.h"
#ifdef HAVE_ICONV
# include <iconv.h>
#else
# include <gwwiconv.h>
#endif
#include "locale.h"
#include <gnetwork.h>
#ifdef FONTFORGE_CONFIG_USE_DOUBLE
# define real double
# define bigreal double
#else
# define real float
# define bigreal double
#endif
#define extended double
/* Solaris wants to define extended to be unsigned [3] unless we do this*/
#define _EXTENDED
#define CHR(ch1,ch2,ch3,ch4) (((ch1)<<24)|((ch2)<<16)|((ch3)<<8)|(ch4))
#define MmMax 16 /* PS says at most this many instances for type1/2 mm fonts */
#define AppleMmMax 26 /* Apple sort of has a limit of 4095, but we only support this many */
typedef struct ipoint {
int x;
int y;
} IPoint;
#define IPOINT_EMPTY { 0, 0 }
typedef struct basepoint {
real x;
real y;
} BasePoint;
#define BASEPOINT_EMPTY { (real)0.0, (real)0.0 }
typedef struct dbasepoint {
bigreal x;
bigreal y;
} DBasePoint;
#define DBASEPOINT_EMPTY { (bigreal)0.0, (bigreal)0.0 }
typedef struct tpoint {
real x;
real y;
real t;
} TPoint;
#define TPOINT_EMPTY { (real)0.0, (real)0.0, (real)0.0 }
typedef struct dbounds {
real minx, maxx;
real miny, maxy;
} DBounds;
#define DBOUNDS_EMPTY { (real)0.0, (real)0.0, (real)0.0, (real)0.0 }
typedef struct ibounds {
int minx, maxx;
int miny, maxy;
} IBounds;
#define IBOUNDS_EMPTY { 0, 0, 0, 0 }
enum val_type { v_int, v_real, v_str, v_unicode, v_lval, v_arr, v_arrfree,
v_int32pt, v_int16pt, v_int8pt, v_void };
typedef struct val {
enum val_type type;
union {
int ival;
real fval;
char *sval;
struct val *lval;
struct array *aval;
uint32 *u32ptval;
uint16 *u16ptval;
uint8 *u8ptval;
} u;
} Val; /* Used by scripting */
struct psdict {
int cnt; /* *key[0..cnt] and *values[0..cnt] currently available */
int next; /* **key[0..next] and **values[0..next] currently used */
char **keys;
char **values;
};
struct pschars {
int cnt, next;
char **keys;
uint8 **values;
int *lens;
int bias; /* for type2 strings */
};
enum linejoin {
lj_miter, /* Extend lines until they meet */
lj_round, /* circle centered at the join of expand radius */
lj_bevel, /* Straight line between the ends of next and prev */
lj_inherited
};
enum linecap {
lc_butt, /* equiv to lj_bevel, straight line extends from one side to other */
lc_round, /* semi-circle */
lc_square, /* Extend lines by radius, then join them */
lc_inherited
};
enum spreadMethod {
sm_pad, sm_reflect, sm_repeat
};
#define COLOR_INHERITED 0xfffffffe
struct grad_stops {
real offset;
uint32 col;
real opacity;
};
struct gradient {
BasePoint start; /* focal of a radial gradient, start of a linear */
BasePoint stop; /* center of a radial gradient, end of a linear */
real radius; /* 0=>linear gradient, else radius of a radial gradient */
enum spreadMethod sm;
int stop_cnt;
struct grad_stops *grad_stops;
};
struct pattern {
char *pattern;
real width, height; /* Pattern is scaled to be repeated every width/height (in user coordinates) */
real transform[6];
/* Used during rasterization process */
struct bdfchar *pat;
real invtrans[6];
int bminx, bminy, bwidth, bheight; /* of the pattern at bdfchar scale */
};
struct brush {
uint32 col;
float opacity; /* number between [0,1], only for svg/pdf */
struct pattern *pattern; /* A pattern to be tiled */
struct gradient *gradient; /* A gradient fill */
};
#define WIDTH_INHERITED (-1)
#define DASH_INHERITED 255 /* if the dashes[0]==0 && dashes[1]==DASH_INHERITED */
#define DASH_MAX 8
typedef unsigned char DashType;
struct pen {
struct brush brush;
uint8 linejoin;
uint8 linecap;
float width;
real trans[4];
DashType dashes[DASH_MAX];
};
struct spline;
enum si_type { si_std, si_caligraphic, si_poly, si_centerline };
/* If you change this structure you may need to update MakeStrokeDlg */
/* and cvpalettes.c both contain statically initialized StrokeInfos */
typedef struct strokeinfo {
real radius; /* or major axis of pen */
enum linejoin join;
enum linecap cap;
enum si_type stroke_type;
unsigned int removeinternal: 1;
unsigned int removeexternal: 1;
unsigned int leave_users_center: 1; /* Don't move the pen so its center is at the origin */
real penangle;
real minorradius;
struct splinepointlist *poly;
real resolution;
/* For freehand tool */
real radius2;
int pressure1, pressure2;
/* End freehand tool */
void *data;
bigreal (*factor)(void *data,struct spline *spline,real t);
} StrokeInfo;
enum PolyType { Poly_Convex, Poly_Concave, Poly_PointOnEdge,
Poly_TooFewPoints, Poly_Line };
enum overlap_type { over_remove, over_rmselected, over_intersect, over_intersel,
over_exclude, over_findinter, over_fisel };
enum simpify_flags { sf_cleanup=-1, sf_normal=0, sf_ignoreslopes=1,
sf_ignoreextremum=2, sf_smoothcurves=4, sf_choosehv=8,
sf_forcelines=0x10, sf_nearlyhvlines=0x20,
sf_mergelines=0x40, sf_setstart2extremum=0x80,
sf_rmsingletonpoints=0x100 };
struct simplifyinfo {
int flags;
bigreal err;
bigreal tan_bounds;
bigreal linefixup;
bigreal linelenmax; /* Don't simplify any straight lines longer than this */
int set_as_default;
int check_selected_contours;
};
struct hsquash { double lsb_percent, stem_percent, counter_percent, rsb_percent; };
enum serif_type { srf_flat, srf_simpleslant, srf_complexslant };
/* | | (flat) | | (simple) | | (complex) */
/* | | | / | / */
/* | | | / | / */
/* +----+ |/ \ / */
typedef struct italicinfo {
double italic_angle;
double xheight_percent;
struct hsquash lc, uc, neither;
enum serif_type secondary_serif;
unsigned int transform_bottom_serifs: 1;
unsigned int transform_top_xh_serifs: 1; /* Those at x-height */
unsigned int transform_top_as_serifs: 1; /* Those at ascender-height */
unsigned int transform_diagon_serifs: 1; /* Those at baseline/xheight */
unsigned int a_from_d: 1; /* replace the "a" glyph with the variant which looks like a "d" without an ascender */
/* When I say "f" I also mean "f_f" ligature, "longs", cyrillic phi and other things shaped like "f" */
unsigned int f_long_tail: 1; /* Some Italic fonts have the "f" grow an extension of the main stem below the baseline */
unsigned int f_rotate_top: 1; /* Most Italic fonts take the top curve of the "f", rotate it 180 and attach to the bottom */
unsigned int pq_deserif: 1; /* Remove a serif from the descender of p or q and replace with a secondary serif as above */
/* Unsupported */
/* e becomes rounder, cross bar slightly slanted */
/* g closed counter at bottom */
/* k closed counter at top */
/* v-z diagonal stems become more curvatious */
unsigned int cyrl_phi: 1; /* Gains an "f" like top, bottom treated like "f" */
unsigned int cyrl_i: 1; /* Turns into a latin u */
unsigned int cyrl_pi: 1; /* Turns into a latin n */
unsigned int cyrl_te: 1; /* Turns into a latin m */
unsigned int cyrl_sha: 1; /* Turns into a latin m rotated 180 */
unsigned int cyrl_dje: 1; /* Turns into a latin smallcaps T */
unsigned int cyrl_dzhe: 1; /* Turns into a latin u */
/* Is there a difference between dzhe and i? both look like u to me */
/* Unsupported */
/* u432 curved B */
/* u433 strange gamma */
/* u434 normal delta */
/* u436 */
/* u43b lambda ? */
/* u43c */
/* u446 */
/* u449 */
/* u449 */
/* u44a */
/* This half of the structure gets filled in later - see ITALICINFO_REMAINDER */
double tan_ia;
double x_height;
double pq_depth;
double ascender_height;
double emsize;
int order2;
struct splinefont *sf;
int layer;
double serif_extent, serif_height;
struct splinepoint *f_start, *f_end; /* start has next pointing into the f head and up */
struct splinepoint *ff_start1, *ff_end1, *ff_start2, *ff_end2;
double f_height, ff_height;
} ItalicInfo;
#define ITALICINFO_REMAINDER 0, 0, 0, 0, 0, 0, NULL, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0
typedef struct bluedata {
real xheight, xheighttop; /* height of "x" and "o" (u,v,w,x,y,z) */
real caph, caphtop; /* height of "I" and "O" */
real base, basebelow; /* bottom of "I" and "O" */
real ascent; /* height of "l" */
real descent; /* depth of "p" */
real numh, numhtop; /* height of "7" and "8" */ /* numbers with ascenders */
int bluecnt; /* If the private dica contains bluevalues... */
real blues[12][2]; /* 7 pairs from bluevalues, 5 from otherblues */
} BlueData;
#define BLUEDATA_EMPTY { \
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, \
{ { 0.0, 0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, \
{ 0.0, 0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 } \
} \
}
typedef struct bdffloat {
int16 xmin,xmax,ymin,ymax;
int16 bytes_per_line;
unsigned int byte_data:1;
uint8 depth;
uint8 *bitmap;
} BDFFloat;
/* OpenType does not document 'dflt' as a language, but we'll use it anyway. */
/* (Adobe uses it too) we'll turn it into a default entry when we output it. */
#define DEFAULT_LANG CHR('d','f','l','t')
/* The OpenType spec says in one place that the default script is 'dflt' and */
/* in another that it is 'DFLT'. 'DFLT' is correct */
#define DEFAULT_SCRIPT CHR('D','F','L','T')
#define REQUIRED_FEATURE CHR(' ','R','Q','D')
enum otlookup_type {
ot_undef = 0, /* Not a lookup type */
gsub_start = 0x000, /* Not a lookup type */
gsub_single = 0x001,
gsub_multiple = 0x002,
gsub_alternate = 0x003,
gsub_ligature = 0x004,
gsub_context = 0x005,
gsub_contextchain = 0x006,
/* GSUB extension 7 */
gsub_reversecchain = 0x008,
/* mac state machines */
morx_indic = 0x0fd,
morx_context = 0x0fe,
morx_insert = 0x0ff,
/* ********************* */
gpos_start = 0x100, /* Not a lookup type */
gpos_single = 0x101,
gpos_pair = 0x102,
gpos_cursive = 0x103,
gpos_mark2base = 0x104,
gpos_mark2ligature = 0x105,
gpos_mark2mark = 0x106,
gpos_context = 0x107,
gpos_contextchain = 0x108,
/* GPOS extension 9 */
kern_statemachine = 0x1ff
/* otlookup&0xff == lookup type for the appropriate table */
/* otlookup>>8: 0=>GSUB, 1=>GPOS */
};
enum otlookup_typemasks {
gsub_single_mask = 0x00001,
gsub_multiple_mask = 0x00002,
gsub_alternate_mask = 0x00004,
gsub_ligature_mask = 0x00008,
gsub_context_mask = 0x00010,
gsub_contextchain_mask = 0x00020,
gsub_reversecchain_mask = 0x00040,
morx_indic_mask = 0x00080,
morx_context_mask = 0x00100,
morx_insert_mask = 0x00200,
/* ********************* */
gpos_single_mask = 0x00400,
gpos_pair_mask = 0x00800,
gpos_cursive_mask = 0x01000,
gpos_mark2base_mask = 0x02000,
gpos_mark2ligature_mask = 0x04000,
gpos_mark2mark_mask = 0x08000,
gpos_context_mask = 0x10000,
gpos_contextchain_mask = 0x20000,
kern_statemachine_mask = 0x40000
};
#define MAX_LANG 4 /* If more than this we allocate more_langs in chunks of MAX_LANG */
struct scriptlanglist {
uint32 script;
uint32 langs[MAX_LANG];
uint32 *morelangs;
int lang_cnt;
struct scriptlanglist *next;
};
extern struct opentype_feature_friendlynames {
uint32 tag;
char *tagstr;
char *friendlyname;
int masks;
} friendlies[];
#define OPENTYPE_FEATURE_FRIENDLYNAMES_EMPTY { 0, NULL, NULL, 0 }
typedef struct featurescriptlanglist {
uint32 featuretag;
struct scriptlanglist *scripts;
struct featurescriptlanglist *next;
unsigned int ismac: 1; /* treat the featuretag as a mac feature/setting */
} FeatureScriptLangList;
enum pst_flags { pst_r2l=1, pst_ignorebaseglyphs=2, pst_ignoreligatures=4,
pst_ignorecombiningmarks=8, pst_usemarkfilteringset=0x10,
pst_markclass=0xff00, pst_markset=0xffff0000 };
struct lookup_subtable {
char *subtable_name;
char *suffix; /* for gsub_single, used to find a default replacement */
int16 separation, minkern; /* for gpos_pair, used to guess default kerning values */
struct otlookup *lookup;
unsigned int unused: 1;
unsigned int per_glyph_pst_or_kern: 1;
unsigned int anchor_classes: 1;
unsigned int vertical_kerning: 1;
unsigned int ticked: 1;
unsigned int kerning_by_touch: 1; /* for gpos_pair, calculate kerning so that glyphs will touch */
unsigned int onlyCloser: 1; /* for kerning classes */
unsigned int dontautokern: 1; /* for kerning classes */
struct kernclass *kc;
struct generic_fpst *fpst;
struct generic_asm *sm;
/* Each time an item is added to a lookup we must place it into a */
/* subtable. If it's a kerning class, fpst or state machine it has */
/* a subtable all to itself. If it's an anchor class it can share */
/* a subtable with other anchor classes (merge with). If it's a glyph */
/* PST it may share a subtable with other PSTs */
/* Note items may only be placed in lookups in which they fit. Can't */
/* put kerning data in a gpos_single lookup, etc. */
struct lookup_subtable *next;
int32 subtable_offset;
int32 *extra_subtables;
/* If a kerning subtable has too much stuff in it, we are prepared to */
/* break it up into several smaller subtables, each of which has */
/* an offset in this list (extra-subtables[0]==subtable_offset) */
/* the list is terminated by an entry of -1 */
};
typedef struct otlookup {
struct otlookup *next;
enum otlookup_type lookup_type;
uint32 lookup_flags; /* Low order: traditional flags, High order: markset index, only meaningful if pst_usemarkfilteringset set */
char *lookup_name;
FeatureScriptLangList *features;
struct lookup_subtable *subtables;
unsigned int unused: 1; /* No subtable is used (call SFFindUnusedLookups before examining) */
unsigned int empty: 1; /* No subtable is used, and no anchor classes are used */
unsigned int store_in_afm: 1; /* Used for ligatures, some get stored */
/* 'liga' generally does, but 'frac' doesn't */
unsigned int needs_extension: 1; /* Used during opentype generation */
unsigned int temporary_kern: 1; /* Used when decomposing kerning classes into kern pairs for older formats */
unsigned int def_lang_checked: 1;
unsigned int def_lang_found: 1;
unsigned int ticked: 1;
unsigned int in_gpos: 1;
unsigned int in_jstf: 1;
unsigned int only_jstf: 1;
int16 subcnt; /* Actual number of subtables we will output */
/* Some of our subtables may contain no data */
/* Some may be too big and need to be broken up.*/
/* So this field may be different than just counting the subtables */
int lookup_index; /* used during opentype generation */
uint32 lookup_offset;
uint32 lookup_length;
char *tempname;
} OTLookup;
#define LOOKUP_SUBTABLE_EMPTY { NULL, NULL, 0, 0, NULL, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, 0, NULL }
#define OTLOOKUP_EMPTY { NULL, 0, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL }
typedef struct devicetab {
uint16 first_pixel_size, last_pixel_size; /* A range of point sizes to which this table applies */
int8 *corrections; /* a set of pixel corrections, one for each point size */
} DeviceTable;
typedef struct valdev { /* Value records can have four associated device tables */
DeviceTable xadjust;
DeviceTable yadjust;
DeviceTable xadv;
DeviceTable yadv;
} ValDevTab;
enum anchorclass_type { act_mark, act_mkmk, act_curs, act_mklg, act_unknown };
typedef struct anchorclass {
char *name; /* in utf8 */
struct lookup_subtable *subtable;
uint8 type; /* anchorclass_type */
uint8 has_base;
uint8 processed, has_mark, matches, ac_num;
uint8 ticked;
struct anchorclass *next;
} AnchorClass;
enum anchor_type { at_mark, at_basechar, at_baselig, at_basemark, at_centry, at_cexit, at_max };
typedef struct anchorpoint {
AnchorClass *anchor;
BasePoint me;
DeviceTable xadjust, yadjust;
unsigned int type: 4;
unsigned int selected: 1;
unsigned int ticked: 1;
unsigned int has_ttf_pt: 1;
uint16 ttf_pt_index;
int16 lig_index;
struct anchorpoint *next;
} AnchorPoint;
typedef struct kernpair {
// Note that the left character in the pair has the reference to the kerning pair, which in turn references the right character.
struct lookup_subtable *subtable;
struct splinechar *sc;
int16 off;
uint16 kcid; /* temporary value */
DeviceTable *adjust; /* Only adjustment in one dimen, if more needed use pst */
struct kernpair *next;
} KernPair;
#define FF_KERNCLASS_FLAG_NATIVE 2 // If set, the class goes into groups.plist or kerning.plist.
#define FF_KERNCLASS_FLAG_FEATURE 4 // If set, the class or rule goes into the feature file. In the present configuration, this ought to be zero always.
#define FF_KERNCLASS_FLAG_NAMETYPE 8 // If unset (default), the class has a standard name, which translates to a U. F. O. name starting in public.kern, which may be illegal in the feature file. If set, it has a name like @MMK_.
#define FF_KERNCLASS_FLAG_NAMELEGACY 16 // If set, the class has a U. F. O. name starting in @kc as FontForge liked to do in the past.
#define FF_KERNCLASS_FLAG_VIRTUAL 32 // If unset (default), the class is a real character class and does not conflict with same-sided classes. If set, FontForge mostly ignores the class except for U. F. O. input/output.
#define FF_KERNCLASS_FLAG_FLATTEN 64 // If unset (default), the class gets exported as a class. If set, it gets exported as its first member (in order to support class-character kerns).
#define FF_KERNCLASS_FLAG_SINGLECHAR (FF_KERNCLASS_FLAG_VIRTUAL | FF_KERNCLASS_FLAG_FLATTEN) // We expect to see these used together.
typedef struct kernclass {
int first_cnt, second_cnt; /* Count of classes for first and second chars */
char **firsts; /* list of a space separated list of char names */
char **seconds; /* one entry for each class. Entry 0 is null */
/* and means everything not specified elsewhere */
char **firsts_names; // We need to track the names of the classes in order to round-trip U. F. O. data.
char **seconds_names;
int *firsts_flags; // This tracks the storage format of the class in U. F. O. (groups.plist or features.fea) and whether it's a single-character class.
int *seconds_flags; // We also track the name format (@MMK or public.kern).
struct lookup_subtable *subtable;
uint16 kcid; /* Temporary value, used for many things briefly */
int16 *offsets; /* array of first_cnt*second_cnt entries with 0 representing no data */
int *offsets_flags;
DeviceTable *adjusts; /* array of first_cnt*second_cnt entries representing resolution-specific adjustments */
struct kernclass *next; // Note that, in most cases, a typeface needs only one struct kernclass since it can contain all classes.
int feature; // This indicates whether the kerning class came from a feature file. This is important during export.
} KernClass;
enum possub_type { pst_null, pst_position, pst_pair,
pst_substitution, pst_alternate,
pst_multiple, pst_ligature,
pst_lcaret /* must be pst_max-1, see charinfo.c*/,
pst_max,
/* These are not psts but are related so it's handly to have values for them */
pst_kerning = pst_max, pst_vkerning, pst_anchors,
/* And these are fpsts */
pst_contextpos, pst_contextsub, pst_chainpos, pst_chainsub,
pst_reversesub, fpst_max,
/* And these are used to specify a kerning pair where the current */
/* char is the final glyph rather than the initial one */
/* A kludge used when cutting and pasting features */
pst_kernback, pst_vkernback
};
struct vr {
int16 xoff, yoff, h_adv_off, v_adv_off;
ValDevTab *adjust;
};
typedef struct generic_pst {
unsigned int ticked: 1;
unsigned int temporary: 1; /* Used in afm ligature closure */
/* enum possub_type*/ uint8 type;
struct lookup_subtable *subtable;
struct generic_pst *next;
union {
struct vr pos;
struct { char *paired; struct vr *vr; } pair;
struct { char *variant; } subs;
struct { char *components; } mult, alt;
struct { char *components; struct splinechar *lig; } lig;
struct { int16 *carets; int cnt; } lcaret; /* Ligature caret positions */
} u;
} PST;
typedef struct liglist {
PST *lig;
struct splinechar *first; /* First component */
struct splinecharlist *components; /* Other than the first */
struct liglist *next;
int ccnt; /* Component count. (includes first component) */
} LigList;
enum fpossub_format { pst_glyphs, pst_class, pst_coverage,
pst_reversecoverage, pst_formatmax };
struct seqlookup {
int seq;
struct otlookup *lookup;
};
struct fpg { char *names, *back, *fore; };
struct fpc { int ncnt, bcnt, fcnt; uint16 *nclasses, *bclasses, *fclasses, *allclasses; };
struct fpv { int ncnt, bcnt, fcnt; char **ncovers, **bcovers, **fcovers; };
struct fpr { int always1, bcnt, fcnt; char **ncovers, **bcovers, **fcovers; char *replacements; };
struct fpst_rule {
union {
/* Note: Items in backtrack area are in reverse order because that's how the OT wants them */
/* they need to be reversed again to be displayed to the user */
struct fpg glyph;
struct fpc class;
struct fpv coverage;
struct fpr rcoverage;
} u;
int lookup_cnt;
struct seqlookup *lookups;
};
typedef struct generic_fpst {
uint16 /*enum possub_type*/ type;
uint16 /*enum fpossub_format*/ format;
struct lookup_subtable *subtable;
struct generic_fpst *next;
uint16 nccnt, bccnt, fccnt;
uint16 rule_cnt;
char **nclass, **bclass, **fclass;
struct fpst_rule *rules;
uint8 ticked;
uint8 effectively_by_glyphs;
char **nclassnames, **bclassnames, **fclassnames;
} FPST;
enum asm_type { asm_indic, asm_context, asm_lig, asm_simple=4, asm_insert,
asm_kern=0x11 };
enum asm_flags { asm_vert=0x8000, asm_descending=0x4000, asm_always=0x2000 };
struct asm_state {
uint16 next_state;
uint16 flags;
union {
struct {
struct otlookup *mark_lookup; /* for contextual glyph subs (tag of a nested lookup) */
struct otlookup *cur_lookup; /* for contextual glyph subs */
} context;
struct {
char *mark_ins;
char *cur_ins;
} insert;
struct {
int16 *kerns;
int kcnt;
} kern;
} u;
};
typedef struct generic_asm { /* Apple State Machine */
struct generic_asm *next;
uint16 /*enum asm_type*/ type;
struct lookup_subtable *subtable; /* Lookup contains feature setting info */
uint16 flags; /* 0x8000=>vert, 0x4000=>r2l, 0x2000=>hor&vert */
uint8 ticked;
uint16 class_cnt, state_cnt;
char **classes;
struct asm_state *state;
} ASM;
/* State Flags:
Indic:
0x8000 mark current glyph as first in rearrangement
0x4000 don't advance to next glyph
0x2000 mark current glyph as last
0x000f verb
0 = no change 8 = AxCD => CDxA
1 = Ax => xA 9 = AxCD => DCxA
2 = xD => Dx a = ABxD => DxAB
3 = AxD => DxA b = ABxD => DxBA
4 = ABx => xAB c = ABxCD => CDxAB
5 = ABx => xBA d = ABxCD => CDxBA
6 = xCD => CDx e = ABxCD => DCxAB
7 = xCD => DCx f = ABxCD => DCxBA
Contextual:
0x8000 mark current glyph
0x4000 don't advance to next glyph
Insert:
0x8000 mark current glyph
0x4000 don't advance to next glyph
0x2000 current is Kashida like
0x1000 mark is Kashida like
0x0800 current insert before
0x0400 mark insert before
0x03e0 count of chars to be inserted at current (31 max)
0x001f count of chars to be inserted at mark (31 max)
Kern:
0x8000 add current glyph to kerning stack
0x4000 don't advance to next glyph
0x3fff value offset
*/
struct jstf_prio {
OTLookup **enableShrink; /* Points to an array of lookups (GSUB or GPOS)*/
OTLookup **disableShrink; /* NULL terminated */
OTLookup **maxShrink; /* Array of GPOS like lookups */
OTLookup **enableExtend;
OTLookup **disableExtend;
OTLookup **maxExtend;
};
struct jstf_lang {
uint32 lang;
struct jstf_lang *next;
int cnt;
struct jstf_prio *prios;
};
typedef struct jstf_script {
uint32 script;
struct jstf_script *next;
char *extenders; /* list of glyph names */
struct jstf_lang *langs;
} Justify;
struct opentype_str {
struct splinechar *sc;
struct vr vr; /* Scaled and rounded gpos modifications (device table info included in xoff, etc. not in adjusts) */
struct kernpair *kp;
struct kernclass *kc;
unsigned int prev_kc0: 1;
unsigned int next_kc0: 1;
int16 advance_width; /* Basic advance, modifications in vr, scaled and rounded */
/* Er... not actually set by ApplyLookups, but somewhere the caller */
/* can stash info. (Extract width from hinted bdf if possible, tt */
/* instructions can change it from the expected value) */
int16 kc_index;
int16 lig_pos; /* when skipping marks to form a ligature keep track of what ligature element a mark was attached to */
int16 context_pos; /* When doing a contextual match remember which glyphs are used, and where in the match they occur. Skipped glyphs have -1 */
int32 orig_index;
void *fl;
unsigned int line_break_after: 1;
unsigned int r2l: 1;
int16 bsln_off;
};
struct macname {
struct macname *next;
uint16 enc; /* Platform specific encoding. 0=>mac roman, 1=>sjis, 7=>russian */
uint16 lang; /* Mac languages 0=>english, 1=>french, 2=>german */
char *name; /* Not a unicode string, uninterpreted mac encoded string */
};
/* Wow, the GPOS 'size' feature stores a string in the name table just as mac */
/* features do */
/* And now (OTF 1.6) GSUB 'ss01'-'ss20' do too */
struct otfname {
struct otfname *next;
uint16 lang; /* windows language code */
char *name; /* utf8 */
};
struct otffeatname {
uint32 tag; /* Feature tag */
struct otfname *names;
struct otffeatname *next;
uint16 nid; /* temporary value */
};
struct macsetting {
struct macsetting *next;
uint16 setting;
uint16 strid;
struct macname *setname;
unsigned int initially_enabled: 1;
};
typedef struct macfeat {
struct macfeat *next;
uint16 feature;
uint8 ismutex;
uint8 default_setting; /* Apple's docs say both that this is a byte and a short. It's a byte */
uint16 strid; /* Temporary value, used when reading in */
struct macname *featname;
struct macsetting *settings;
} MacFeat;
typedef struct refbdfc {
unsigned int checked: 1;
unsigned int selected: 1;
int8 xoff;
int8 yoff;
uint16 gid;
struct refbdfc *next;
struct bdfchar *bdfc;
} BDFRefChar;
struct bdfcharlist {
struct bdfchar *bc;
struct bdfcharlist *next;
};
typedef struct bdfchar {
struct splinechar *sc;
int16 xmin,xmax,ymin,ymax;
int16 width;
int16 bytes_per_line;
uint8 *bitmap;
struct refbdfc *refs;
int orig_pos;
int16 pixelsize; /* for undoes */
struct bitmapview *views;
struct undoes *undoes;
struct undoes *redoes;
unsigned int changed: 1;
unsigned int byte_data: 1; /* for anti-aliased chars entries are grey-scale bytes not bw bits */
unsigned int widthgroup: 1; /* for ttf bitmap output */
unsigned int isreference: 1; /* for ttf bitmap input, */
unsigned int ticked: 1;
uint8 depth; /* for ttf bitmap output */
uint16 vwidth;
BDFFloat *selection;
BDFFloat *backup;
struct bdfcharlist *dependents;
} BDFChar;
enum undotype { ut_none=0, ut_state, ut_tstate, ut_statehint, ut_statename,
ut_statelookup,
ut_anchors,
ut_width, ut_vwidth, ut_lbearing, ut_rbearing, ut_possub,
ut_hints, ut_bitmap, ut_bitmapsel, ut_composit, ut_multiple, ut_layers,
ut_noop };
#define UNDO_LAYER_UNKNOWN -1
typedef struct undoes {
struct undoes *next;
enum undotype undotype;
unsigned int was_modified: 1;
unsigned int was_order2: 1;
int layer; /* the layer the undo is assoicated with or -1 if unknown */
union {
struct {
int16 width, vwidth;
int16 lbearingchange;
int unicodeenc; /* only for ut_statename */
char *charname; /* only for ut_statename */
char *comment; /* in utf8 */
PST *possub; /* only for ut_statename */
struct splinepointlist *splines;
struct refchar *refs;
struct imagelist *images;
void *hints; /* ut_statehint, ut_statename */
uint8 *instrs;
int instrs_len;
AnchorPoint *anchor;
struct brush fill_brush;
struct pen stroke_pen;
unsigned int dofill: 1;
unsigned int dostroke: 1;
unsigned int fillfirst: 1;
} state;
int width; /* used by both ut_width and ut_vwidth */
int lbearing; /* used by ut_lbearing */
int rbearing; /* used by ut_rbearing */
BDFChar bmpstate;
struct { /* copy contains an outline state and a set of bitmap states */
struct undoes *state;
struct undoes *bitmaps;
} composit;
struct {
struct undoes *mult; /* copy contains several sub copies (composits, or states or widths or...) */
/* Also used for ut_layers, each sub copy is a state (first is ly_fore, next ly_fore+1...) */
} multiple;
struct {
enum possub_type pst;
char **data; /* First 4 bytes is tag, then space then data */
struct undoes *more_pst;
short cnt,max; /* Not always set */
} possub;
uint8 *bitmap;
} u;
struct splinefont *copied_from;
} Undoes;
enum sfundotype
{
sfut_none=0,
sfut_lookups,
sfut_lookups_kerns,
sfut_fontinfo,
sfut_noop
};
/**
* A spline font level undo stack. undoes are doubly linked using the
* 'ln' member and carry some user presentable description of what the
* undo relates to in 'msg'.
*
* The sfdchunk is a pointer to an SFD fragment which will apply the
* undo to the current state. For example, it might contain
* information about the old value of kerning pairs which can be used
* to restore state to how it was. Note that the sfdchunk might only
* be partial, containing only enough information to restore the state
* which changed when the undo was created.
*/
typedef struct sfundoes {
struct dlistnode ln;
char* msg;
enum sfundotype type;
union {
int dummy;
} u;
char* sfdchunk;
} SFUndoes;
typedef struct enc {
char *enc_name;
int char_cnt; /* Size of the next two arrays */
int32 *unicode; /* unicode value for each encoding point */
char **psnames; /* optional postscript name for each encoding point */
struct enc *next;
unsigned int builtin: 1;
unsigned int hidden: 1;
unsigned int only_1byte: 1;
unsigned int has_1byte: 1;
unsigned int has_2byte: 1;
unsigned int is_unicodebmp: 1;
unsigned int is_unicodefull: 1;
unsigned int is_custom: 1;
unsigned int is_original: 1;
unsigned int is_compact: 1;
unsigned int is_japanese: 1;
unsigned int is_korean: 1;
unsigned int is_tradchinese: 1;
unsigned int is_simplechinese: 1;
char iso_2022_escape[8];
int iso_2022_escape_len;
int low_page, high_page;
char *iconv_name; /* For compatibility to old versions we might use a different name from that used by iconv. */
iconv_t *tounicode;
iconv_t *fromunicode;
int (*tounicode_func)(int);
int (*fromunicode_func)(int);
unsigned int is_temporary: 1; /* freed when the map gets freed */
int char_max; /* Used by temporary encodings */
} Encoding;
struct renames { char *from; char *to; };
typedef struct namelist {
struct namelist *basedon;
char *title;
const char ***unicode[17];
struct namelist *next;
struct renames *renames;
int uses_unicode;
char *a_utf8_name;
} NameList;
enum uni_interp { ui_unset= -1, ui_none, ui_adobe, ui_greek, ui_japanese,
ui_trad_chinese, ui_simp_chinese, ui_korean, ui_ams };
struct remap { uint32 firstenc, lastenc; int32 infont; };
typedef struct encmap { /* A per-font map of encoding to glyph id */
int32 *map; /* Map from encoding to glyphid */
int32 *backmap; /* Map from glyphid to encoding */
int enccount; /* used size of the map array */
/* strictly speaking this might include */
/* glyphs that are not encoded, but which */
/* are displayed after the proper encoding */
int encmax; /* allocated size of the map array */
int backmax; /* allocated size of the backmap array */