beta-0.89.2
[luatex.git] / source / texk / web2c / luatexdir / luafontloader / fontforge / fontforge / splinefont.h
blob5c432cb7db8ebbc6a27284f6870de0903c62ea8f
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:
6 * Redistributions of source code must retain the above copyright notice, this
7 * list of conditions and the following disclaimer.
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.
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.
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.
27 #ifndef _SPLINEFONT_H
28 #define _SPLINEFONT_H
30 #include "basics.h"
31 #include "configure-pfaedit.h"
32 #ifdef HAVE_ICONV_H
33 # include <iconv.h>
34 /* libiconv.h defines iconv as taking a const pointer for inbuf. iconv doesn't*/
35 # ifdef _LIBICONV_VERSION
36 # define ICONV_CONST const
37 # else
38 # define ICONV_CONST
39 # endif
40 #else
41 # include <gwwiconv.h>
42 # define ICONV_CONST
43 #endif
45 #if defined( FONTFORGE_CONFIG_USE_LONGDOUBLE )
46 # define real long double
47 # define bigreal long double
48 #elif defined( FONTFORGE_CONFIG_USE_DOUBLE )
49 # define real double
50 # define bigreal double
51 #else
52 # define real float
53 # define bigreal double
54 #endif
56 #if defined( HAVE_LONG_DOUBLE ) && defined( This_does_not_seem_to_make_a_difference )
57 # define extended long double
58 # define CheckExtremaForSingleBitErrors(sp,t) (t)
59 # define EXTENDED_IS_LONG_DOUBLE 1
60 #else
61 # define extended double
62 #endif
63 /* Solaris wants to define extended to be unsigned [3] unless we do this*/
64 #define _EXTENDED
66 #define CHR(ch1,ch2,ch3,ch4) (((ch1)<<24)|((ch2)<<16)|((ch3)<<8)|(ch4))
68 #define MmMax 16 /* PS says at most this many instances for type1/2 mm fonts */
70 typedef struct ipoint {
71 int x;
72 int y;
73 } IPoint;
75 typedef struct basepoint {
76 real x;
77 real y;
78 } BasePoint;
80 typedef struct dbasepoint {
81 bigreal x;
82 bigreal y;
83 } DBasePoint;
85 typedef struct tpoint {
86 real x;
87 real y;
88 real t;
89 } TPoint;
91 typedef struct dbounds {
92 real minx, maxx;
93 real miny, maxy;
94 } DBounds;
96 typedef struct ibounds {
97 int minx, maxx;
98 int miny, maxy;
99 } IBounds;
101 typedef struct val {
102 enum val_type { v_int, v_real, v_str, v_unicode, v_lval, v_arr, v_arrfree,
103 v_int32pt, v_int16pt, v_int8pt, v_void } type;
104 union {
105 int ival;
106 real fval;
107 char *sval;
108 struct val *lval;
109 struct array *aval;
110 uint32 *u32ptval;
111 uint16 *u16ptval;
112 uint8 *u8ptval;
113 } u;
114 } Val; /* Used by scripting */
116 struct psdict {
117 int cnt, next;
118 char **keys;
119 char **values;
122 struct pschars {
123 int cnt, next;
124 char **keys;
125 uint8 **values;
126 int *lens;
127 int bias; /* for type2 strings */
130 enum linejoin {
131 lj_miter, /* Extend lines until they meet */
132 lj_round, /* circle centered at the join of expand radius */
133 lj_bevel, /* Straight line between the ends of next and prev */
134 lj_inherited
136 enum linecap {
137 lc_butt, /* equiv to lj_bevel, straight line extends from one side to other */
138 lc_round, /* semi-circle */
139 lc_square, /* Extend lines by radius, then join them */
140 lc_inherited
142 enum spreadMethod {
143 sm_pad, sm_reflect, sm_repeat
145 #define COLOR_INHERITED 0xfffffffe
146 struct gradient {
147 BasePoint start; /* focal of a radial gradient, start of a linear */
148 BasePoint stop; /* center of a radial gradient, end of a linear */
149 real radius; /* 0=>linear gradient, else radius of a radial gradient */
150 enum spreadMethod sm;
151 int stop_cnt;
152 struct grad_stops {
153 real offset;
154 uint32 col;
155 real opacity;
156 } *grad_stops;
159 struct pattern {
160 char *pattern;
161 real width, height; /* Pattern is scaled to be repeated every width/height (in user coordinates) */
162 real transform[6];
163 /* Used during rasterization process */
164 struct bdfchar *pat;
165 real invtrans[6];
166 int bminx, bminy, bwidth, bheight; /* of the pattern at bdfchar scale */
169 struct brush {
170 uint32 col;
171 float opacity; /* number between [0,1], only for svg/pdf */
172 struct pattern *pattern; /* A pattern to be tiled */
173 struct gradient *gradient; /* A gradient fill */
175 #define WIDTH_INHERITED (-1)
176 #define DASH_INHERITED 255 /* if the dashes[0]==0 && dashes[1]==DASH_INHERITED */
177 #define DASH_MAX 8
178 typedef unsigned char DashType;
179 struct pen {
180 struct brush brush;
181 uint8 linejoin;
182 uint8 linecap;
183 float width;
184 real trans[4];
185 DashType dashes[DASH_MAX];
188 struct spline;
189 enum si_type { si_std, si_caligraphic, si_elipse, si_centerline };
190 /* If you change this structure you may need to update MakeStrokeDlg */
191 /* and cvpalettes.c both contain statically initialized StrokeInfos */
192 typedef struct strokeinfo {
193 real radius; /* or major axis of pen */
194 enum linejoin join;
195 enum linecap cap;
196 enum si_type stroke_type;
197 unsigned int toobigwarn: 1;
198 unsigned int removeinternal: 1;
199 unsigned int removeexternal: 1;
200 unsigned int removeoverlapifneeded: 1;
201 unsigned int gottoobig: 1;
202 unsigned int gottoobiglocal: 1;
203 real penangle;
204 real ratio; /* ratio of minor pen axis to major */
205 /* For eplipse */
206 real minorradius;
207 /* For freehand tool */
208 real radius2;
209 int pressure1, pressure2;
210 /* End freehand tool */
211 bigreal c,s;
212 real xoff[8], yoff[8];
213 void *data;
214 bigreal (*factor)(void *data,struct spline *spline,real t);
215 } StrokeInfo;
217 enum overlap_type { over_remove, over_rmselected, over_intersect, over_intersel,
218 over_exclude, over_findinter, over_fisel };
220 enum simpify_flags { sf_cleanup=-1, sf_normal=0, sf_ignoreslopes=1,
221 sf_ignoreextremum=2, sf_smoothcurves=4, sf_choosehv=8,
222 sf_forcelines=0x10, sf_nearlyhvlines=0x20,
223 sf_mergelines=0x40, sf_setstart2extremum=0x80,
224 sf_rmsingletonpoints=0x100 };
225 struct simplifyinfo {
226 int flags;
227 bigreal err;
228 bigreal tan_bounds;
229 bigreal linefixup;
230 bigreal linelenmax; /* Don't simplify any straight lines longer than this */
231 int set_as_default;
232 int check_selected_contours;
235 typedef struct italicinfo {
236 double italic_angle;
237 double xheight_percent;
238 struct hsquash { double lsb_percent, stem_percent, counter_percent, rsb_percent; }
239 lc, uc, neither;
240 enum { srf_flat, srf_simpleslant, srf_complexslant } secondary_serif;
241 /* | | (flat) | | (simple) | | (complex) */
242 /* | | | / | / */
243 /* | | | / | / */
244 /* +----+ |/ \ / */
246 unsigned int transform_bottom_serifs: 1;
247 unsigned int transform_top_xh_serifs: 1; /* Those at x-height */
248 unsigned int transform_top_as_serifs: 1; /* Those at ascender-height */
249 unsigned int transform_diagon_serifs: 1; /* Those at baseline/xheight */
251 unsigned int a_from_d: 1; /* replace the "a" glyph with the variant which looks like a "d" without an ascender */
252 /* When I say "f" I also mean "f_f" ligature, "longs", cyrillic phi and other things shaped like "f" */
253 unsigned int f_long_tail: 1; /* Some Italic fonts have the "f" grow an extension of the main stem below the baseline */
254 unsigned int f_rotate_top: 1; /* Most Italic fonts take the top curve of the "f", rotate it 180 and attach to the bottom */
255 unsigned int pq_deserif: 1; /* Remove a serif from the descender of p or q and replace with a secondary serif as above */
257 /* Unsupported */
258 /* e becomes rounder, cross bar slightly slanted */
259 /* g closed counter at bottom */
260 /* k closed counter at top */
261 /* v-z diagonal stems become more curvatious */
263 unsigned int cyrl_phi: 1; /* Gains an "f" like top, bottom treated like "f" */
264 unsigned int cyrl_i: 1; /* Turns into a latin u */
265 unsigned int cyrl_pi: 1; /* Turns into a latin n */
266 unsigned int cyrl_te: 1; /* Turns into a latin m */
267 unsigned int cyrl_sha: 1; /* Turns into a latin m rotated 180 */
268 unsigned int cyrl_dje: 1; /* Turns into a latin smallcaps T */
269 unsigned int cyrl_dzhe: 1; /* Turns into a latin u */
270 /* Is there a difference between dzhe and i? both look like u to me */
272 /* Unsupported */
273 /* u432 curved B */
274 /* u433 strange gamma */
275 /* u434 normal delta */
276 /* u436 */
277 /* u43b lambda ? */
278 /* u43c */
279 /* u446 */
280 /* u449 */
281 /* u449 */
282 /* u44a */
284 /* This half of the structure gets filled in later */
285 double tan_ia;
286 double x_height;
287 double pq_depth;
288 double ascender_height;
289 double emsize;
290 int order2;
291 struct splinefont *sf;
292 int layer;
293 double serif_extent, serif_height;
294 struct splinepoint *f_start, *f_end; /* start has next pointing into the f head and up */
295 struct splinepoint *ff_start1, *ff_end1, *ff_start2, *ff_end2;
296 double f_height, ff_height;
297 } ItalicInfo;
299 typedef struct bluedata {
300 real xheight, xheighttop; /* height of "x" and "o" (u,v,w,x,y,z) */
301 real caph, caphtop; /* height of "I" and "O" */
302 real base, basebelow; /* bottom of "I" and "O" */
303 real ascent; /* height of "l" */
304 real descent; /* depth of "p" */
305 real numh, numhtop; /* height of "7" and "8" */ /* numbers with ascenders */
306 int bluecnt; /* If the private dica contains bluevalues... */
307 real blues[12][2]; /* 7 pairs from bluevalues, 5 from otherblues */
308 } BlueData;
310 typedef struct bdffloat {
311 int16 xmin,xmax,ymin,ymax;
312 int16 bytes_per_line;
313 unsigned int byte_data:1;
314 uint8 depth;
315 uint8 *bitmap;
316 } BDFFloat;
318 /* OpenType does not document 'dflt' as a language, but we'll use it anyway. */
319 /* (Adobe uses it too) we'll turn it into a default entry when we output it. */
320 #define DEFAULT_LANG CHR('d','f','l','t')
321 /* The OpenType spec says in one place that the default script is 'dflt' and */
322 /* in another that it is 'DFLT'. 'DFLT' is correct */
323 #define DEFAULT_SCRIPT CHR('D','F','L','T')
324 #define REQUIRED_FEATURE CHR(' ','R','Q','D')
326 enum otlookup_type {
327 ot_undef = 0, /* Not a lookup type */
328 gsub_start = 0x000, /* Not a lookup type */
329 gsub_single = 0x001,
330 gsub_multiple = 0x002,
331 gsub_alternate = 0x003,
332 gsub_ligature = 0x004,
333 gsub_context = 0x005,
334 gsub_contextchain = 0x006,
335 /* GSUB extension 7 */
336 gsub_reversecchain = 0x008,
337 /* ********************* */
338 gpos_start = 0x100, /* Not a lookup type */
340 gpos_single = 0x101,
341 gpos_pair = 0x102,
342 gpos_cursive = 0x103,
343 gpos_mark2base = 0x104,
344 gpos_mark2ligature = 0x105,
345 gpos_mark2mark = 0x106,
346 gpos_context = 0x107,
347 gpos_contextchain = 0x108,
348 /* GPOS extension 9 */
350 /* otlookup&0xff == lookup type for the appropriate table */
351 /* otlookup>>8: 0=>GSUB, 1=>GPOS */
354 enum otlookup_typemasks {
355 gsub_single_mask = 0x00001,
356 gsub_multiple_mask = 0x00002,
357 gsub_alternate_mask = 0x00004,
358 gsub_ligature_mask = 0x00008,
359 gsub_context_mask = 0x00010,
360 gsub_contextchain_mask = 0x00020,
361 gsub_reversecchain_mask = 0x00040,
362 /* ********************* */
363 gpos_single_mask = 0x00400,
364 gpos_pair_mask = 0x00800,
365 gpos_cursive_mask = 0x01000,
366 gpos_mark2base_mask = 0x02000,
367 gpos_mark2ligature_mask = 0x04000,
368 gpos_mark2mark_mask = 0x08000,
369 gpos_context_mask = 0x10000,
370 gpos_contextchain_mask = 0x20000,
373 #define MAX_LANG 4 /* If more than this we allocate more_langs in chunks of MAX_LANG */
374 struct scriptlanglist {
375 uint32 script;
376 uint32 langs[MAX_LANG];
377 uint32 *morelangs;
378 int lang_cnt;
379 struct scriptlanglist *next;
382 extern struct opentype_feature_friendlynames {
383 uint32 tag;
384 char *tagstr;
385 char *friendlyname;
386 int masks;
387 } friendlies[];
389 typedef struct featurescriptlanglist {
390 uint32 featuretag;
391 struct scriptlanglist *scripts;
392 struct featurescriptlanglist *next;
393 } FeatureScriptLangList;
395 enum pst_flags { pst_r2l=1, pst_ignorebaseglyphs=2, pst_ignoreligatures=4,
396 pst_ignorecombiningmarks=8 };
398 typedef struct otlookup {
399 struct otlookup *next;
400 enum otlookup_type lookup_type;
401 uint16 lookup_flags;
402 char *lookup_name;
403 FeatureScriptLangList *features;
404 struct lookup_subtable {
405 char *subtable_name;
406 char *suffix; /* for gsub_single, used to find a default replacement */
407 struct otlookup *lookup;
408 unsigned int unused: 1;
409 unsigned int per_glyph_pst_or_kern: 1;
410 unsigned int anchor_classes: 1;
411 unsigned int vertical_kerning: 1;
412 unsigned int ticked: 1;
413 struct kernclass *kc;
414 struct generic_fpst *fpst;
415 /* Each time an item is added to a lookup we must place it into a */
416 /* subtable. If it's a kerning class, fpst or state machine it has */
417 /* a subtable all to itself. If it's an anchor class it can share */
418 /* a subtable with other anchor classes (merge with). If it's a glyph */
419 /* PST it may share a subtable with other PSTs */
420 /* Note items may only be placed in lookups in which they fit. Can't */
421 /* put kerning data in a gpos_single lookup, etc. */
422 struct lookup_subtable *next;
423 int32 subtable_offset;
424 int32 *extra_subtables;
425 /* If a kerning subtable has too much stuff in it, we are prepared to */
426 /* break it up into several smaller subtables, each of which has */
427 /* an offset in this list (extra-subtables[0]==subtable_offset) */
428 /* the list is terminated by an entry of -1 */
429 } *subtables;
430 unsigned int unused: 1; /* No subtable is used (call SFFindUnusedLookups before examining) */
431 unsigned int empty: 1; /* No subtable is used, and no anchor classes are used */
432 unsigned int store_in_afm: 1; /* Used for ligatures, some get stored */
433 /* 'liga' generally does, but 'frac' doesn't */
434 unsigned int needs_extension: 1; /* Used during opentype generation */
435 unsigned int temporary_kern: 1; /* Used when decomposing kerning classes into kern pairs for older formats */
436 unsigned int def_lang_checked: 1;
437 unsigned int def_lang_found: 1;
438 unsigned int ticked: 1;
439 int16 subcnt; /* Actual number of subtables we will output */
440 /* Some of our subtables may contain no data */
441 /* Some may be too big and need to be broken up.*/
442 /* So this field may be different than just counting the subtables */
443 int lookup_index; /* used during opentype generation */
444 uint32 lookup_offset;
445 uint32 lookup_length;
446 char *tempname;
447 } OTLookup;
449 #ifdef FONTFORGE_CONFIG_DEVICETABLES
450 typedef struct devicetab {
451 uint16 first_pixel_size, last_pixel_size; /* A range of point sizes to which this table applies */
452 int8 *corrections; /* a set of pixel corrections, one for each point size */
453 } DeviceTable;
455 typedef struct valdev { /* Value records can have four associated device tables */
456 DeviceTable xadjust;
457 DeviceTable yadjust;
458 DeviceTable xadv;
459 DeviceTable yadv;
460 } ValDevTab;
461 #endif
463 enum anchorclass_type { act_mark, act_mkmk, act_curs, act_mklg };
464 typedef struct anchorclass {
465 char *name; /* in utf8 */
466 struct lookup_subtable *subtable;
467 uint8 type; /* anchorclass_type */
468 uint8 has_base;
469 uint8 processed, has_mark, matches, ac_num;
470 uint8 ticked;
471 struct anchorclass *next;
472 } AnchorClass;
474 enum anchor_type { at_mark, at_basechar, at_baselig, at_basemark, at_centry, at_cexit, at_max };
475 typedef struct anchorpoint {
476 AnchorClass *anchor;
477 BasePoint me;
478 #ifdef FONTFORGE_CONFIG_DEVICETABLES
479 DeviceTable xadjust, yadjust;
480 #endif
481 unsigned int type: 4;
482 unsigned int selected: 1;
483 unsigned int ticked: 1;
484 unsigned int has_ttf_pt: 1;
485 uint16 ttf_pt_index;
486 int16 lig_index;
487 struct anchorpoint *next;
488 } AnchorPoint;
490 typedef struct kernpair {
491 struct lookup_subtable *subtable;
492 struct splinechar *sc;
493 int16 off;
494 uint16 kcid; /* temporary value */
495 #ifdef FONTFORGE_CONFIG_DEVICETABLES
496 DeviceTable *adjust; /* Only adjustment in one dimen, if more needed use pst */
497 #endif
498 struct kernpair *next;
499 } KernPair;
501 typedef struct kernclass {
502 int first_cnt, second_cnt; /* Count of classes for first and second chars */
503 char **firsts; /* list of a space seperated list of char names */
504 char **seconds; /* one entry for each class. Entry 0 is null */
505 /* and means everything not specified elsewhere */
506 struct lookup_subtable *subtable;
507 uint16 kcid; /* Temporary value, used for many things briefly */
508 int16 *offsets; /* array of first_cnt*second_cnt entries */
509 #ifdef FONTFORGE_CONFIG_DEVICETABLES
510 DeviceTable *adjusts; /* array of first_cnt*second_cnt entries */
511 #endif
512 struct kernclass *next;
513 } KernClass;
515 enum possub_type { pst_null, pst_position, pst_pair,
516 pst_substitution, pst_alternate,
517 pst_multiple, pst_ligature,
518 pst_lcaret /* must be pst_max-1, see charinfo.c*/,
519 pst_max,
520 /* These are not psts but are related so it's handly to have values for them */
521 pst_kerning = pst_max, pst_vkerning, pst_anchors,
522 /* And these are fpsts */
523 pst_contextpos, pst_contextsub, pst_chainpos, pst_chainsub,
524 pst_reversesub, fpst_max,
525 /* And these are used to specify a kerning pair where the current */
526 /* char is the final glyph rather than the initial one */
527 /* A kludge used when cutting and pasting features */
528 pst_kernback, pst_vkernback
531 struct vr {
532 int16 xoff, yoff, h_adv_off, v_adv_off;
533 #ifdef FONTFORGE_CONFIG_DEVICETABLES
534 ValDevTab *adjust;
535 #endif
538 typedef struct generic_pst {
539 unsigned int ticked: 1;
540 unsigned int temporary: 1; /* Used in afm ligature closure */
541 /* enum possub_type*/ uint8 type;
542 struct lookup_subtable *subtable;
543 struct generic_pst *next;
544 union {
545 struct vr pos;
546 struct { char *paired; struct vr *vr; } pair;
547 struct { char *variant; } subs;
548 struct { char *components; } mult, alt;
549 struct { char *components; struct splinechar *lig; } lig;
550 struct { int16 *carets; int cnt; } lcaret; /* Ligature caret positions */
551 } u;
552 } PST;
554 typedef struct liglist {
555 PST *lig;
556 struct splinechar *first; /* First component */
557 struct splinecharlist *components; /* Other than the first */
558 struct liglist *next;
559 int ccnt; /* Component count. (includes first component) */
560 } LigList;
562 enum fpossub_format { pst_glyphs, pst_class, pst_coverage,
563 pst_reversecoverage, pst_formatmax };
565 typedef struct generic_fpst {
566 uint16 /*enum sfpossub_type*/ type;
567 uint16 /*enum fpossub_format*/ format;
568 struct lookup_subtable *subtable;
569 struct generic_fpst *next;
570 uint16 nccnt, bccnt, fccnt;
571 uint16 rule_cnt;
572 char **nclass, **bclass, **fclass;
573 struct fpst_rule {
574 union {
575 struct fpg { char *names, *back, *fore; } glyph;
576 struct fpc { int ncnt, bcnt, fcnt; uint16 *nclasses, *bclasses, *fclasses, *allclasses; } class;
577 struct fpv { int ncnt, bcnt, fcnt; char **ncovers, **bcovers, **fcovers; } coverage;
578 struct fpr { int always1, bcnt, fcnt; char **ncovers, **bcovers, **fcovers; char *replacements; } rcoverage;
579 } u;
580 int lookup_cnt;
581 struct seqlookup {
582 int seq;
583 struct otlookup *lookup;
584 } *lookups;
585 } *rules;
586 uint8 ticked;
587 uint8 effectively_by_glyphs;
588 } FPST;
590 struct opentype_str {
591 struct splinechar *sc;
592 struct vr vr; /* Scaled and rounded gpos modifications (device table info included in xoff, etc. not in adjusts) */
593 struct kernpair *kp;
594 struct kernclass *kc;
595 int16 advance_width; /* Basic advance, modifications in vr, scaled and rounded */
596 int16 kc_index;
597 int16 lig_pos; /* when skipping marks to form a ligature keep track of what ligature element a mark was attached to */
598 int16 context_pos; /* When doing a contextual match remember which glyphs are used, and where in the match they occur. Skipped glyphs have -1 */
599 int32 orig_index;
600 void *fl;
601 unsigned int line_break_after: 1;
602 unsigned int r2l: 1;
603 int16 bsln_off;
606 /* Wow, the GPOS 'size' feature stores a string in the name table just as mac */
607 /* features do */
608 struct otfname {
609 struct otfname *next;
610 uint16 lang; /* windows language code */
611 char *name; /* utf8 */
614 typedef struct undoes {
615 struct undoes *next;
616 enum undotype { ut_none=0, ut_state, ut_tstate, ut_statehint, ut_statename,
617 ut_statelookup,
618 ut_anchors,
619 ut_width, ut_vwidth, ut_lbearing, ut_rbearing, ut_possub,
620 ut_hints, ut_bitmap, ut_bitmapsel, ut_composit, ut_multiple, ut_layers,
621 ut_noop } undotype;
622 unsigned int was_modified: 1;
623 unsigned int was_order2: 1;
624 union {
625 struct {
626 int16 width, vwidth;
627 int16 lbearingchange;
628 int unicodeenc; /* only for ut_statename */
629 char *charname; /* only for ut_statename */
630 char *comment; /* in utf8 */
631 PST *possub; /* only for ut_statename */
632 struct splinepointlist *splines;
633 struct refchar *refs;
635 struct imagelist *images;
636 void *hints; /* ut_statehint, ut_statename */
637 uint8 *instrs;
638 int instrs_len;
639 AnchorPoint *anchor;
640 #ifdef FONTFORGE_CONFIG_TYPE3
641 struct brush fill_brush;
642 struct pen stroke_pen;
643 unsigned int dofill: 1;
644 unsigned int dostroke: 1;
645 unsigned int fillfirst: 1;
646 #endif
647 } state;
648 int width; /* used by both ut_width and ut_vwidth */
649 int lbearing; /* used by ut_lbearing */
650 int rbearing; /* used by ut_rbearing */
651 struct {
652 int16 width; /* width should be controled by postscript, but people don't like that */
653 int16 xmin,xmax,ymin,ymax;
654 int16 bytes_per_line;
655 int16 pixelsize;
656 int16 depth;
657 uint8 *bitmap;
658 BDFFloat *selection;
659 } bmpstate;
660 struct { /* copy contains an outline state and a set of bitmap states */
661 struct undoes *state;
662 struct undoes *bitmaps;
663 } composit;
664 struct {
665 struct undoes *mult; /* copy contains several sub copies (composits, or states or widths or...) */
666 /* Also used for ut_layers, each sub copy is a state (first is ly_fore, next ly_fore+1...) */
667 } multiple;
668 struct {
669 enum possub_type pst;
670 char **data; /* First 4 bytes is tag, then space then data */
671 struct undoes *more_pst;
672 short cnt,max; /* Not always set */
673 } possub;
674 uint8 *bitmap;
675 } u;
676 struct splinefont *copied_from;
677 } Undoes;
679 typedef struct bdfchar {
680 struct splinechar *sc;
681 int16 xmin,xmax,ymin,ymax;
682 int16 width;
683 int16 bytes_per_line;
684 uint8 *bitmap;
685 int orig_pos;
686 struct bitmapview *views;
687 Undoes *undoes;
688 Undoes *redoes;
689 unsigned int changed: 1;
690 unsigned int byte_data: 1; /* for anti-aliased chars entries are grey-scale bytes not bw bits */
691 unsigned int widthgroup: 1; /* for ttf bitmap output */
692 unsigned int isreference: 1; /* for ttf bitmap input, */
693 unsigned int ticked: 1;
694 uint8 depth; /* for ttf bitmap output */
695 uint16 vwidth;
696 BDFFloat *selection;
697 } BDFChar;
699 typedef struct enc {
700 char *enc_name;
701 int char_cnt; /* Size of the next two arrays */
702 int32 *unicode; /* unicode value for each encoding point */
703 char **psnames; /* optional postscript name for each encoding point */
704 struct enc *next;
705 unsigned int builtin: 1;
706 unsigned int hidden: 1;
707 unsigned int only_1byte: 1;
708 unsigned int has_1byte: 1;
709 unsigned int has_2byte: 1;
710 unsigned int is_unicodebmp: 1;
711 unsigned int is_unicodefull: 1;
712 unsigned int is_custom: 1;
713 unsigned int is_original: 1;
714 unsigned int is_compact: 1;
715 unsigned int is_japanese: 1;
716 unsigned int is_korean: 1;
717 unsigned int is_tradchinese: 1;
718 unsigned int is_simplechinese: 1;
719 char iso_2022_escape[8];
720 int iso_2022_escape_len;
721 int low_page, high_page;
722 char *iconv_name; /* For compatibility to old versions we might use a different name from that used by iconv. */
723 iconv_t *tounicode;
724 iconv_t *fromunicode;
725 int (*tounicode_func)(int);
726 int (*fromunicode_func)(int);
727 unsigned int is_temporary: 1; /* freed when the map gets freed */
728 int char_max; /* Used by temporary encodings */
729 } Encoding;
731 typedef struct namelist {
732 struct namelist *basedon;
733 char *title;
734 const char ***unicode[17];
735 struct namelist *next;
736 struct renames { char *from; char *to; } *renames;
737 int uses_unicode;
738 char *a_utf8_name;
739 } NameList;
741 enum uni_interp { ui_unset= -1, ui_none, ui_adobe, ui_greek, ui_japanese,
742 ui_trad_chinese, ui_simp_chinese, ui_korean, ui_ams };
744 struct remap { uint32 firstenc, lastenc; int32 infont; };
746 typedef struct encmap { /* A per-font map of encoding to glyph id */
747 int32 *map; /* Map from encoding to glyphid */
748 int32 *backmap; /* Map from glyphid to encoding */
749 int enccount; /* used size of the map array */
750 /* strictly speaking this might include */
751 /* glyphs that are not encoded, but which */
752 /* are displayed after the proper encoding */
753 int encmax; /* allocated size of the map array */
754 int backmax; /* allocated size of the backmap array */
755 struct remap *remap;
756 Encoding *enc;
757 unsigned int ticked: 1;
758 } EncMap;
760 enum property_type { prt_string, prt_atom, prt_int, prt_uint, prt_property=0x10 };
762 typedef struct bdfprops {
763 char *name; /* These include both properties (like SLANT) and non-properties (like FONT) */
764 int type;
765 union {
766 char *str;
767 char *atom;
768 int val;
769 } u;
770 } BDFProperties;
772 typedef struct bdffont {
773 struct splinefont *sf;
774 int glyphcnt, glyphmax,glyphmin; /* used & allocated sizes of glyphs array */
775 BDFChar **glyphs; /* an array of charcnt entries */
776 int16 pixelsize;
777 int16 ascent, descent;
778 int16 layer; /* for piecemeal fonts */
779 unsigned int piecemeal: 1;
780 unsigned int bbsized: 1;
781 unsigned int ticked: 1;
782 unsigned int unhinted_freetype: 1;
783 struct bdffont *next;
784 struct clut *clut;
785 char *foundry;
786 int res;
787 void *freetype_context;
788 uint16 truesize; /* for bbsized fonts */
789 int16 prop_cnt;
790 int16 prop_max; /* only used within bdfinfo dlg */
791 BDFProperties *props;
792 } BDFFont;
794 #define HntMax 96 /* PS says at most 96 hints */
795 typedef uint8 HintMask[HntMax/8];
797 enum pointtype { pt_curve, pt_corner, pt_tangent, pt_hvcurve };
798 typedef struct splinepoint {
799 BasePoint me;
800 BasePoint nextcp; /* control point */
801 BasePoint prevcp; /* control point */
802 unsigned int nonextcp:1;
803 unsigned int noprevcp:1;
804 unsigned int nextcpdef:1;
805 unsigned int prevcpdef:1;
806 unsigned int selected:1; /* for UI */
807 unsigned int pointtype:2;
808 unsigned int isintersection: 1;
809 unsigned int flexy: 1;
810 unsigned int flexx: 1;
811 unsigned int roundx: 1; /* For true type hinting */
812 unsigned int roundy: 1; /* For true type hinting */
813 unsigned int dontinterpolate: 1; /* in ttf, don't imply point by interpolating between cps */
814 unsigned int ticked: 1;
815 unsigned int watched: 1;
816 /* 1 bits left... */
817 uint16 ptindex; /* Temporary value used by metafont routine */
818 uint16 ttfindex; /* Truetype point index */
819 /* Special values 0xffff => point implied by averaging control points */
820 /* 0xfffe => point created with no real number yet */
821 /* (or perhaps point in context where no number is possible as in a glyph with points & refs) */
822 uint16 nextcpindex; /* Truetype point index */
823 struct spline *next;
824 struct spline *prev;
825 HintMask *hintmask;
826 } SplinePoint;
828 typedef struct linelist {
829 IPoint here;
830 struct linelist *next;
831 /* The first two fields are constant for the linelist, the next ones */
832 /* refer to a particular screen. If some portion of the line from */
833 /* this point to the next one is on the screen then set cvli_onscreen */
834 /* if this point needs to be clipped then set cvli_clipped */
835 /* asend and asstart are the actual screen locations where this point */
836 /* intersects the clip edge. */
837 enum { cvli_onscreen=0x1, cvli_clipped=0x2 } flags;
838 IPoint asend, asstart;
839 } LineList;
841 typedef struct linearapprox {
842 real scale;
843 unsigned int oneline: 1;
844 unsigned int onepoint: 1;
845 unsigned int any: 1; /* refers to a particular screen */
846 struct linelist *lines;
847 struct linearapprox *next;
848 } LinearApprox;
850 typedef struct spline1d {
851 real a, b, c, d;
852 } Spline1D;
854 typedef struct spline {
855 unsigned int islinear: 1; /* No control points */
856 unsigned int isquadratic: 1; /* probably read in from ttf */
857 unsigned int isticked: 1;
858 unsigned int isneeded: 1; /* Used in remove overlap */
859 unsigned int isunneeded: 1; /* Used in remove overlap */
860 unsigned int exclude: 1; /* Used in remove overlap varient: exclude */
861 unsigned int ishorvert: 1;
862 unsigned int knowncurved: 1; /* We know that it curves */
863 unsigned int knownlinear: 1; /* it might have control points, but still traces out a line */
864 /* If neither knownlinear nor curved then we haven't checked */
865 unsigned int order2: 1; /* It's a bezier curve with only one cp */
866 unsigned int touched: 1;
867 unsigned int leftedge: 1;
868 unsigned int rightedge: 1;
869 unsigned int acceptableextrema: 1; /* This spline has extrema, but we don't care */
870 SplinePoint *from, *to;
871 Spline1D splines[2]; /* splines[0] is the x spline, splines[1] is y */
872 struct linearapprox *approx;
873 /* Posible optimizations:
874 Precalculate bounding box
875 Precalculate min/max/ points of inflection
877 } Spline;
880 typedef struct splinepointlist {
881 SplinePoint *first, *last;
882 struct splinepointlist *next;
883 uint8 ticked;
884 uint8 beziers_need_optimizer; /* If the spiros have changed in spiro mode, then reverting to bezier mode might, someday, run a simplifier */
885 uint8 is_clip_path; /* In type3/svg fonts */
886 char *contour_name;
887 } SplinePointList, SplineSet;
889 typedef struct imagelist {
890 struct gimage *image;
891 real xoff, yoff; /* position in character space of upper left corner of image */
892 real xscale, yscale; /* scale to convert one pixel of image to one unit of character space */
893 DBounds bb;
894 struct imagelist *next;
895 unsigned int selected: 1;
896 } ImageList;
898 typedef struct refchar {
899 unsigned int checked: 1;
900 unsigned int selected: 1;
901 unsigned int point_match: 1; /* match_pt* are point indexes */
902 /* and need to be converted to a */
903 /* translation after truetype readin */
904 unsigned int encoded: 1; /* orig_pos is actually an encoded value, used for old sfd files */
905 unsigned int justtranslated: 1; /* The transformation matrix specifies a translation (or is identity) */
906 unsigned int use_my_metrics: 1; /* Retain the ttf "use_my_metrics" info. */
907 /* important for glyphs with instructions which change the width used */
908 /* inside composites */
909 unsigned int round_translation_to_grid: 1; /* Retain the ttf "round_to_grid" info. */
910 unsigned int point_match_out_of_date: 1; /* Someone has edited a base glyph */
911 int16 adobe_enc;
912 int orig_pos;
913 int unicode_enc; /* used by paste */
914 real transform[6]; /* transformation matrix (first 2 rows of a 3x3 matrix, missing row is 0,0,1) */
915 struct reflayer {
916 unsigned int background: 1;
917 unsigned int order2: 1;
918 unsigned int anyflexes: 1;
919 #ifdef FONTFORGE_CONFIG_TYPE3
920 unsigned int dofill: 1;
921 unsigned int dostroke: 1;
922 unsigned int fillfirst: 1;
923 struct brush fill_brush;
924 struct pen stroke_pen;
925 #endif
926 SplinePointList *splines;
927 ImageList *images; /* Only in background or type3 layer(s) */
928 } *layers;
929 int layer_cnt;
930 struct refchar *next;
931 DBounds bb;
932 struct splinechar *sc;
933 BasePoint top;
934 uint16 match_pt_base, match_pt_ref;
935 } RefChar;
937 /* Some stems may appear, disappear, reapear several times */
938 /* Serif stems on I which appear at 0, disappear, reappear at top */
939 /* Or the major vertical stems on H which disappear at the cross bar */
940 typedef struct hintinstance {
941 real begin; /* location in the non-major direction*/
942 real end; /* width/height in non-major direction*/
943 unsigned int closed: 1;
944 short int counternumber;
945 struct hintinstance *next;
946 } HintInstance;
948 enum hinttypes { ht_unspecified=0, ht_h, ht_v, ht_d };
949 typedef real _MMArray[2][MmMax];
951 typedef struct steminfo {
952 struct steminfo *next;
953 unsigned int hinttype: 2; /* Only used by undoes */
954 unsigned int ghost: 1; /* this is a ghost stem hint. As such truetype should ignore it, type2 output should negate it, and type1 should use as is */
955 /* stored width will be either 20 or 21 */
956 /* Type2 says: -20 is "width" of top edge, -21 is "width" of bottom edge, type1 accepts either */
957 unsigned int haspointleft:1;
958 unsigned int haspointright:1;
959 unsigned int hasconflicts:1;/* Does this stem have conflicts within its cluster? */
960 unsigned int used: 1; /* Temporary for counter hints or hint substitution */
961 unsigned int tobeused: 1; /* Temporary for counter hints or hint substitution */
962 unsigned int active: 1; /* Currently active hint in Review Hints dlg */
963 /* displayed differently in char display */
964 unsigned int enddone: 1; /* Used by ttf instructing, indicates a prev */
965 /* hint had the same end as this one (so */
966 /* the points on the end line have been */
967 /* instructed already */
968 unsigned int startdone: 1; /* Used by ttf instructing */
969 /*unsigned int backwards: 1;*/ /* If we think this hint is better done with a negative width */
970 unsigned int reordered: 1; /* In AutoHinting. Means we changed the start of the hint, need to test for out of order */
971 unsigned int pendingpt: 1; /* A pending stem creation, not a true stem */
972 unsigned int linearedges: 1;/* If we have a nice rectangle then we aren't */
973 /* interested in the orientation which is */
974 /* wider than long */
975 int16 hintnumber; /* when dumping out hintmasks we need to know */
976 /* what bit to set for this hint */
977 union {
978 int mask; /* Mask of all references that use this hint */
979 /* in type2 output */
980 _MMArray *unblended /*[2][MmMax]*/; /* Used when reading in type1 mm hints */
981 } u;
982 real start; /* location at which the stem starts */
983 real width; /* or height */
984 HintInstance *where; /* location(s) in the other coord */
985 } StemInfo;
987 typedef struct dsteminfo {
988 struct dsteminfo *next; /* First two fields match those in steminfo */
989 unsigned int hinttype: 2; /* Only used by undoes */
990 unsigned int used: 1; /* used only by tottf.c:gendinstrs, metafont.c to mark a hint that has been dealt with */
991 BasePoint left, right, unit;
992 HintInstance *where; /* location(s) along the unit vector */
993 } DStemInfo;
995 typedef struct minimumdistance {
996 /* If either point is NULL it will be assumed to mean either the origin */
997 /* or the width point (depending on which is closer). This allows user */
998 /* to control metrics... */
999 SplinePoint *sp1, *sp2;
1000 unsigned int x: 1;
1001 unsigned int done: 1;
1002 struct minimumdistance *next;
1003 } MinimumDistance;
1005 typedef struct layer /* : reflayer */{
1006 unsigned int background: 1;
1007 unsigned int order2: 1;
1008 unsigned int anyflexes: 1;
1009 #ifdef FONTFORGE_CONFIG_TYPE3
1010 unsigned int dofill: 1;
1011 unsigned int dostroke: 1;
1012 unsigned int fillfirst: 1;
1013 struct brush fill_brush;
1014 struct pen stroke_pen;
1015 #endif
1016 SplinePointList *splines;
1017 ImageList *images; /* Only in background or type3 layer(s) */
1018 RefChar *refs; /* Only in foreground layer(s) */
1019 Undoes *undoes;
1020 Undoes *redoes;
1021 uint32 validation_state;
1022 uint32 old_vs;
1023 } Layer;
1025 enum layer_type { ly_all=-2, ly_grid= -1, ly_back=0, ly_fore=1,
1026 /* Possibly other foreground layers for type3 things */
1027 /* Possibly other background layers for normal fonts */
1028 ly_none = -3
1031 /* For the 'MATH' table (and for TeX) */
1032 struct glyphvariants {
1033 char *variants; /* Space separated list of glyph names */
1034 /* Glyph assembly */
1035 int16 italic_correction; /* Of the composed glyph */
1036 #ifdef FONTFORGE_CONFIG_DEVICETABLES
1037 DeviceTable *italic_adjusts;
1038 #endif
1039 int part_cnt;
1040 struct gv_part {
1041 char *component;
1042 unsigned int is_extender: 1; /* This component may be skipped or repeated */
1043 uint16 startConnectorLength;
1044 uint16 endConnectorLength;
1045 uint16 fullAdvance;
1046 } *parts;
1049 /* For the 'MATH' table */
1050 struct mathkernvertex {
1051 int cnt; /* There is one more kern entry than height entry */
1052 /* So the last mkd should have its height ignored */
1053 /* The MATH table stores the height count, I think the kern count */
1054 /* is more useful. They differ by 1 */
1055 struct mathkerndata {
1056 int16 height,kern;
1057 #ifdef FONTFORGE_CONFIG_DEVICETABLES
1058 DeviceTable *height_adjusts;
1059 DeviceTable *kern_adjusts;
1060 #endif
1061 } *mkd;
1064 struct mathkern {
1065 struct mathkernvertex top_right;
1066 struct mathkernvertex top_left;
1067 struct mathkernvertex bottom_right;
1068 struct mathkernvertex bottom_left;
1071 enum privatedict_state {
1072 pds_odd = 0x1, /* Odd number of entries */
1073 pds_outoforder = 0x2, /* Bluevalues should be listed in order */
1074 pds_toomany = 0x4, /* arrays are of limited sizes */
1075 pds_tooclose = 0x8, /* adjacent zones must not be within 2*bluefuzz+1 (or 3, if bluefuzz omitted) */
1076 pds_notintegral= 0x10, /* Must be integers */
1077 pds_toobig = 0x20, /* within pair difference have some relation to BlueScale but the docs make no sense to me */
1078 pds_shift = 8, /* BlueValues/OtherBlues, unshifted, FamilyBlues/FamilyOtherBlues shifted once */
1080 pds_missingblue = 0x010000,
1081 pds_badbluefuzz = 0x020000,
1082 pds_badbluescale = 0x040000,
1083 pds_badstdhw = 0x080000,
1084 pds_badstdvw = 0x100000,
1085 pds_badstemsnaph = 0x200000,
1086 pds_badstemsnapv = 0x400000,
1087 pds_stemsnapnostdh = 0x0800000,
1088 pds_stemsnapnostdv = 0x1000000,
1089 pds_badblueshift = 0x2000000
1093 enum validation_state { vs_unknown = 0,
1094 vs_known=0x01, /* It has been validated */
1095 vs_opencontour=0x02,
1096 vs_selfintersects=0x04,
1097 vs_wrongdirection=0x08,
1098 vs_flippedreferences=0x10, /* special case of wrong direction */
1099 vs_missingextrema=0x20,
1100 vs_missingglyphnameingsub=0x40,
1101 /* Next few are postscript only */
1102 vs_toomanypoints=0x80,
1103 vs_toomanyhints=0x100,
1104 vs_badglyphname=0x200,
1105 /* Next few are only for fontlint */
1106 /* These are relative to maxp values which ff would fix on generating a font */
1107 vs_maxp_toomanypoints =0x400,
1108 vs_maxp_toomanypaths =0x800,
1109 vs_maxp_toomanycomppoints=0x1000,
1110 vs_maxp_toomanycomppaths =0x2000,
1111 vs_maxp_instrtoolong =0x4000,
1112 vs_maxp_toomanyrefs =0x8000,
1113 vs_maxp_refstoodeep =0x10000,
1114 /* vs_maxp_prepfpgmtoolong=0x20000, */ /* I think I was wrong about this "error" */
1115 /* Oops, we need another one, two, for the glyphs */
1116 vs_pointstoofarapart = 0x40000,
1117 vs_nonintegral = 0x80000, /* This will never be interesting in a real font, but might be in an sfd file */
1118 vs_missinganchor = 0x100000,
1119 vs_dupname = 0x200000,
1120 vs_dupunicode = 0x400000,
1122 vs_last = vs_dupunicode,
1123 vs_maskps = 0x3fe | vs_pointstoofarapart | vs_missinganchor | vs_dupname | vs_dupunicode,
1124 vs_maskcid = 0x1fe | vs_pointstoofarapart | vs_missinganchor | vs_dupname,
1125 vs_maskttf = 0x7e | vs_pointstoofarapart | vs_nonintegral | vs_missinganchor | vs_dupunicode,
1126 vs_maskfindproblems = 0x1be | vs_pointstoofarapart | vs_nonintegral | vs_missinganchor
1129 typedef struct splinechar {
1130 char *name;
1131 int unicodeenc;
1132 int orig_pos; /* Original position in the glyph list */
1133 int16 width, vwidth, tsb;
1134 int16 xmin, ymin, xmax, ymax;
1135 int16 lsidebearing; /* only used when reading in a type1 font */
1136 /* Or an otf font where it is the subr number of a refered character */
1137 /* or a ttf font without bit 1 of head.flags set */
1138 /* or (once upon a time, but no longer) a ttf font with vert metrics where it is the ymax value when we had a font-wide vertical offset */
1139 /* Always a temporary value */
1140 int ttf_glyph; /* only used when writing out a ttf or otf font */
1141 Layer *layers; /* layer[0] is background, layer[1] foreground */
1142 /* In type3 fonts 2-n are also foreground, otherwise also background */
1143 int layer_cnt;
1144 StemInfo *hstem; /* hstem hints have a vertical offset but run horizontally */
1145 StemInfo *vstem; /* vstem hints have a horizontal offset but run vertically */
1146 DStemInfo *dstem; /* diagonal hints for ttf */
1147 MinimumDistance *md;
1148 struct charviewbase *views;
1149 struct charinfo *charinfo;
1150 struct splinefont *parent;
1151 unsigned int changed: 1;
1152 unsigned int changedsincelasthinted: 1;
1153 unsigned int manualhints: 1;
1154 unsigned int ticked: 1; /* For reference character processing */
1155 /* And fontview processing */
1156 unsigned int changed_since_autosave: 1;
1157 unsigned int widthset: 1; /* needed so an emspace char doesn't disappear */
1158 unsigned int vconflicts: 1; /* Any hint overlaps in the vstem list? */
1159 unsigned int hconflicts: 1; /* Any hint overlaps in the hstem list? */
1160 unsigned int searcherdummy: 1;
1161 unsigned int changed_since_search: 1;
1162 unsigned int wasopen: 1;
1163 unsigned int namechanged: 1;
1164 unsigned int blended: 1; /* An MM blended character */
1165 unsigned int ticked2: 1;
1166 unsigned int glyph_class: 3; /* 0=> fontforge determines class automagically, else one more than the class value in gdef so 2+1=>lig, 3+1=>mark */
1167 unsigned int numberpointsbackards: 1;
1168 unsigned int instructions_out_of_date: 1;
1169 unsigned int complained_about_ptnums: 1;
1170 unsigned int vs_open: 1;
1171 unsigned int unlink_rm_ovrlp_save_undo: 1;
1172 unsigned int inspiro: 1;
1173 unsigned int lig_caret_cnt_fixed: 1;
1174 /* 6 bits left (one more if we ignore compositionunit below) */
1175 #if HANYANG
1176 unsigned int compositionunit: 1;
1177 int16 jamo, varient;
1178 #endif
1179 struct splinecharlist { struct splinechar *sc; struct splinecharlist *next;} *dependents;
1180 /* The dependents list is a list of all characters which refenence*/
1181 /* the current character directly */
1182 KernPair *kerns;
1183 KernPair *vkerns;
1184 PST *possub; /* If we are a ligature then this tells us what */
1185 /* It may also contain a bunch of other stuff now */
1186 LigList *ligofme; /* If this is the first character of a ligature then this gives us the list of possible ones */
1187 /* this field must be regenerated before the font is saved */
1188 char *comment; /* in utf8 */
1189 uint32 /*Color*/ color;
1190 AnchorPoint *anchor;
1191 uint8 *ttf_instrs;
1192 int16 ttf_instrs_len;
1193 int16 countermask_cnt;
1194 HintMask *countermasks;
1195 struct altuni { struct altuni *next; int unienc, vs, fid; } *altuni;
1196 /* vs is the "variation selector" a unicode codepoint which modifieds */
1197 /* the code point before it. If vs is -1 then unienc is just an */
1198 /* alternate encoding (greek Alpha and latin A), but if vs is one */
1199 /* of unicode's variation selectors then this glyph is somehow a */
1200 /* variant shape. The specifics depend on the selector and script */
1201 /* fid is currently unused, but may, someday, be used to do ttcs */
1202 /* NOTE: GlyphInfo displays vs==-1 as vs==0, and fixes things up */
1203 /* for TeX */
1204 int16 tex_height, tex_depth;
1205 /* TeX also uses italic_correction and glyph variants below */
1206 /* For the 'MATH' table (and for TeX) */
1207 unsigned int is_extended_shape: 1;
1208 int16 italic_correction;
1209 int16 top_accent_horiz; /* MATH table allows you to specific a*/
1210 /* horizontal anchor for accent attachments, vertical */
1211 /* positioning is done elsewhere */
1212 #ifdef FONTFORGE_CONFIG_DEVICETABLES
1213 DeviceTable *italic_adjusts;
1214 DeviceTable *top_accent_adjusts;
1215 #endif
1216 struct glyphvariants *vert_variants;
1217 struct glyphvariants *horiz_variants;
1218 struct mathkern *mathkern;
1219 /* End of MATH/TeX fields */
1220 #ifndef _NO_PYTHON
1221 void *python_sc_object;
1222 void *python_temporary;
1223 #endif
1224 void *python_persistent; /* If python this will hold a python object, if not python this will hold a string containing a pickled object. We do nothing with it (if not python) except save it back out unchanged */
1225 #ifdef FONTFORGE_CONFIG_TYPE3
1226 /* If the glyph is used as a tile pattern, then the next two values */
1227 /* determine the amount of white space around the tile. If extra is*/
1228 /* non-zero then we add it to the max components of the bbox and */
1229 /* subtract it from the min components. If extra is 0 then tile_bounds*/
1230 /* will be used. If tile_bounds is all zeros then the glyph's bbox */
1231 /* will be used. */
1232 real tile_margin; /* If the glyph is used as a tile */
1233 DBounds tile_bounds;
1234 #endif
1235 } SplineChar;
1237 #define TEX_UNDEF 0x7fff
1239 enum ttfnames { ttf_copyright=0, ttf_family, ttf_subfamily, ttf_uniqueid,
1240 ttf_fullname, ttf_version, ttf_postscriptname, ttf_trademark,
1241 ttf_manufacturer, ttf_designer, ttf_descriptor, ttf_venderurl,
1242 ttf_designerurl, ttf_license, ttf_licenseurl, ttf_idontknow/*reserved*/,
1243 ttf_preffamilyname, ttf_prefmodifiers, ttf_compatfull, ttf_sampletext,
1244 ttf_cidfindfontname, ttf_wwsfamily, ttf_wwssubfamily, ttf_namemax };
1245 struct ttflangname {
1246 int lang;
1247 char *names[ttf_namemax]; /* in utf8 */
1248 int frommac[(ttf_namemax+31)/32]; /* Used when parsing the 'name' table */
1249 struct ttflangname *next;
1252 #ifdef FONTFORGE_CONFIG_DEVICETABLES
1253 struct MATH {
1254 /* From the MATH Constants subtable (constants for positioning glyphs. Not PI)*/
1255 int16 ScriptPercentScaleDown;
1256 int16 ScriptScriptPercentScaleDown;
1257 uint16 DelimitedSubFormulaMinHeight;
1258 uint16 DisplayOperatorMinHeight;
1259 int16 MathLeading;
1260 DeviceTable *MathLeading_adjust;
1261 int16 AxisHeight;
1262 DeviceTable *AxisHeight_adjust;
1263 int16 AccentBaseHeight;
1264 DeviceTable *AccentBaseHeight_adjust;
1265 int16 FlattenedAccentBaseHeight;
1266 DeviceTable *FlattenedAccentBaseHeight_adjust;
1267 int16 SubscriptShiftDown;
1268 DeviceTable *SubscriptShiftDown_adjust;
1269 int16 SubscriptTopMax;
1270 DeviceTable *SubscriptTopMax_adjust;
1271 int16 SubscriptBaselineDropMin;
1272 DeviceTable *SubscriptBaselineDropMin_adjust;
1273 int16 SuperscriptShiftUp;
1274 DeviceTable *SuperscriptShiftUp_adjust;
1275 int16 SuperscriptShiftUpCramped;
1276 DeviceTable *SuperscriptShiftUpCramped_adjust;
1277 int16 SuperscriptBottomMin;
1278 DeviceTable *SuperscriptBottomMin_adjust;
1279 int16 SuperscriptBaselineDropMax;
1280 DeviceTable *SuperscriptBaselineDropMax_adjust;
1281 int16 SubSuperscriptGapMin;
1282 DeviceTable *SubSuperscriptGapMin_adjust;
1283 int16 SuperscriptBottomMaxWithSubscript;
1284 DeviceTable *SuperscriptBottomMaxWithSubscript_adjust;
1285 int16 SpaceAfterScript;
1286 DeviceTable *SpaceAfterScript_adjust;
1287 int16 UpperLimitGapMin;
1288 DeviceTable *UpperLimitGapMin_adjust;
1289 int16 UpperLimitBaselineRiseMin;
1290 DeviceTable *UpperLimitBaselineRiseMin_adjust;
1291 int16 LowerLimitGapMin;
1292 DeviceTable *LowerLimitGapMin_adjust;
1293 int16 LowerLimitBaselineDropMin;
1294 DeviceTable *LowerLimitBaselineDropMin_adjust;
1295 int16 StackTopShiftUp;
1296 DeviceTable *StackTopShiftUp_adjust;
1297 int16 StackTopDisplayStyleShiftUp;
1298 DeviceTable *StackTopDisplayStyleShiftUp_adjust;
1299 int16 StackBottomShiftDown;
1300 DeviceTable *StackBottomShiftDown_adjust;
1301 int16 StackBottomDisplayStyleShiftDown;
1302 DeviceTable *StackBottomDisplayStyleShiftDown_adjust;
1303 int16 StackGapMin;
1304 DeviceTable *StackGapMin_adjust;
1305 int16 StackDisplayStyleGapMin;
1306 DeviceTable *StackDisplayStyleGapMin_adjust;
1307 int16 StretchStackTopShiftUp;
1308 DeviceTable *StretchStackTopShiftUp_adjust;
1309 int16 StretchStackBottomShiftDown;
1310 DeviceTable *StretchStackBottomShiftDown_adjust;
1311 int16 StretchStackGapAboveMin;
1312 DeviceTable *StretchStackGapAboveMin_adjust;
1313 int16 StretchStackGapBelowMin;
1314 DeviceTable *StretchStackGapBelowMin_adjust;
1315 int16 FractionNumeratorShiftUp;
1316 DeviceTable *FractionNumeratorShiftUp_adjust;
1317 int16 FractionNumeratorDisplayStyleShiftUp;
1318 DeviceTable *FractionNumeratorDisplayStyleShiftUp_adjust;
1319 int16 FractionDenominatorShiftDown;
1320 DeviceTable *FractionDenominatorShiftDown_adjust;
1321 int16 FractionDenominatorDisplayStyleShiftDown;
1322 DeviceTable *FractionDenominatorDisplayStyleShiftDown_adjust;
1323 int16 FractionNumeratorGapMin;
1324 DeviceTable *FractionNumeratorGapMin_adjust;
1325 int16 FractionNumeratorDisplayStyleGapMin;
1326 DeviceTable *FractionNumeratorDisplayStyleGapMin_adjust;
1327 int16 FractionRuleThickness;
1328 DeviceTable *FractionRuleThickness_adjust;
1329 int16 FractionDenominatorGapMin;
1330 DeviceTable *FractionDenominatorGapMin_adjust;
1331 int16 FractionDenominatorDisplayStyleGapMin;
1332 DeviceTable *FractionDenominatorDisplayStyleGapMin_adjust;
1333 int16 SkewedFractionHorizontalGap;
1334 DeviceTable *SkewedFractionHorizontalGap_adjust;
1335 int16 SkewedFractionVerticalGap;
1336 DeviceTable *SkewedFractionVerticalGap_adjust;
1337 int16 OverbarVerticalGap;
1338 DeviceTable *OverbarVerticalGap_adjust;
1339 int16 OverbarRuleThickness;
1340 DeviceTable *OverbarRuleThickness_adjust;
1341 int16 OverbarExtraAscender;
1342 DeviceTable *OverbarExtraAscender_adjust;
1343 int16 UnderbarVerticalGap;
1344 DeviceTable *UnderbarVerticalGap_adjust;
1345 int16 UnderbarRuleThickness;
1346 DeviceTable *UnderbarRuleThickness_adjust;
1347 int16 UnderbarExtraDescender;
1348 DeviceTable *UnderbarExtraDescender_adjust;
1349 int16 RadicalVerticalGap;
1350 DeviceTable *RadicalVerticalGap_adjust;
1351 int16 RadicalDisplayStyleVerticalGap;
1352 DeviceTable *RadicalDisplayStyleVerticalGap_adjust;
1353 int16 RadicalRuleThickness;
1354 DeviceTable *RadicalRuleThickness_adjust;
1355 int16 RadicalExtraAscender;
1356 DeviceTable *RadicalExtraAscender_adjust;
1357 int16 RadicalKernBeforeDegree;
1358 DeviceTable *RadicalKernBeforeDegree_adjust;
1359 int16 RadicalKernAfterDegree;
1360 DeviceTable *RadicalKernAfterDegree_adjust;
1361 uint16 RadicalDegreeBottomRaisePercent;
1362 /* Global constants from other subtables */
1363 uint16 MinConnectorOverlap; /* in the math variants sub-table */
1365 #else
1366 struct MATH {
1367 /* From the MATH Constants subtable (constants for positioning glyphs. Not PI)*/
1368 int16 ScriptPercentScaleDown;
1369 int16 ScriptScriptPercentScaleDown;
1370 uint16 DelimitedSubFormulaMinHeight;
1371 uint16 DisplayOperatorMinHeight;
1372 int16 MathLeading;
1373 int16 AxisHeight;
1374 int16 AccentBaseHeight;
1375 int16 FlattenedAccentBaseHeight;
1376 int16 SubscriptShiftDown;
1377 int16 SubscriptTopMax;
1378 int16 SubscriptBaselineDropMin;
1379 int16 SuperscriptShiftUp;
1380 int16 SuperscriptShiftUpCramped;
1381 int16 SuperscriptBottomMin;
1382 int16 SuperscriptBaselineDropMax;
1383 int16 SubSuperscriptGapMin;
1384 int16 SuperscriptBottomMaxWithSubscript;
1385 int16 SpaceAfterScript;
1386 int16 UpperLimitGapMin;
1387 int16 UpperLimitBaselineRiseMin;
1388 int16 LowerLimitGapMin;
1389 int16 LowerLimitBaselineDropMin;
1390 int16 StackTopShiftUp;
1391 int16 StackTopDisplayStyleShiftUp;
1392 int16 StackBottomShiftDown;
1393 int16 StackBottomDisplayStyleShiftDown;
1394 int16 StackGapMin;
1395 int16 StackDisplayStyleGapMin;
1396 int16 StretchStackTopShiftUp;
1397 int16 StretchStackBottomShiftDown;
1398 int16 StretchStackGapAboveMin;
1399 int16 StretchStackGapBelowMin;
1400 int16 FractionNumeratorShiftUp;
1401 int16 FractionNumeratorDisplayStyleShiftUp;
1402 int16 FractionDenominatorShiftDown;
1403 int16 FractionDenominatorDisplayStyleShiftDown;
1404 int16 FractionNumeratorGapMin;
1405 int16 FractionNumeratorDisplayStyleGapMin;
1406 int16 FractionRuleThickness;
1407 int16 FractionDenominatorGapMin;
1408 int16 FractionDenominatorDisplayStyleGapMin;
1409 int16 SkewedFractionHorizontalGap;
1410 int16 SkewedFractionVerticalGap;
1411 int16 OverbarVerticalGap;
1412 int16 OverbarRuleThickness;
1413 int16 OverbarExtraAscender;
1414 int16 UnderbarVerticalGap;
1415 int16 UnderbarRuleThickness;
1416 int16 UnderbarExtraDescender;
1417 int16 RadicalVerticalGap;
1418 int16 RadicalDisplayStyleVerticalGap;
1419 int16 RadicalRuleThickness;
1420 int16 RadicalExtraAscender;
1421 int16 RadicalKernBeforeDegree;
1422 int16 RadicalKernAfterDegree;
1423 uint16 RadicalDegreeBottomRaisePercent;
1424 /* Global constants from other subtables */
1425 uint16 MinConnectorOverlap; /* in the math variants sub-table */
1427 #endif
1429 enum backedup_state { bs_dontknow=0, bs_not=1, bs_backedup=2 };
1430 enum loadvalidation_state {
1431 lvs_bad_ps_fontname = 0x001,
1432 lvs_bad_glyph_table = 0x002,
1433 lvs_bad_cff_table = 0x004,
1434 lvs_bad_metrics_table = 0x008,
1435 lvs_bad_cmap_table = 0x010,
1436 lvs_bad_bitmaps_table = 0x020,
1437 lvs_bad_gx_table = 0x040,
1438 lvs_bad_ot_table = 0x080,
1439 lvs_bad_os2_version = 0x100,
1440 lvs_bad_sfnt_header = 0x200
1443 typedef struct layerinfo {
1444 char *name;
1445 unsigned int background: 1; /* Layer is to be treated as background: No width, images, not worth outputting */
1446 unsigned int order2: 1; /* Layer's data are order 2 bezier splines (truetype) rather than order 3 (postscript) */
1447 /* In all glyphs in the font */
1448 unsigned int ticked: 1;
1449 } LayerInfo;
1451 /* Baseline data from the 'BASE' table */
1452 struct baselangextent {
1453 uint32 lang; /* also used for feature tag */
1454 struct baselangextent *next;
1455 int16 ascent, descent;
1456 struct baselangextent *features;
1459 struct basescript {
1460 uint32 script;
1461 struct basescript *next;
1462 int def_baseline; /* index [0-baseline_cnt) */
1463 int16 *baseline_pos; /* baseline_cnt of these */
1464 struct baselangextent *langs; /* Language specific extents (may be NULL) */
1465 /* The default one has the tag DEFAULT_LANG */
1468 struct Base {
1469 int baseline_cnt;
1470 uint32 *baseline_tags;
1471 /* A font does not need to provide info on all baselines, but if one script */
1472 /* talks about a baseline, then all must. So the set of baselines is global*/
1473 struct basescript *scripts;
1476 typedef struct splinefont {
1477 char *fontname, *fullname, *familyname, *weight;
1478 char *copyright;
1479 char *filename; /* sfd name. NULL if we open a font, that's origname */
1480 char *defbasefilename;
1481 char *version;
1482 real italicangle, upos, uwidth; /* In font info */
1483 int units_per_em;
1484 struct splinefont *next;
1485 int ascent, descent;
1486 int uniqueid; /* Not copied when reading in!!!! */
1487 int glyphcnt, glyphmax,glyphmin; /* allocated size of glyphs array */
1488 SplineChar **glyphs;
1489 unsigned int changed: 1;
1490 unsigned int changed_since_autosave: 1;
1491 unsigned int changed_since_xuidchanged: 1;
1492 unsigned int display_antialias: 1;
1493 unsigned int display_bbsized: 1;
1494 unsigned int dotlesswarn: 1; /* User warned that font doesn't have a dotless i character */
1495 unsigned int onlybitmaps: 1; /* it's a bdf editor, not a postscript editor */
1496 unsigned int serifcheck: 1; /* Have we checked to see if we have serifs? */
1497 unsigned int issans: 1; /* We have no serifs */
1498 unsigned int isserif: 1; /* We have serifs. If neither set then we don't know. */
1499 unsigned int hasvmetrics: 1; /* We've got vertical metric data and should output vhea/vmtx/VORG tables */
1500 unsigned int loading_cid_map: 1;
1501 unsigned int dupnamewarn: 1; /* Warn about duplicate names when loading bdf font */
1502 unsigned int encodingchanged: 1; /* Font's encoding has changed since it was loaded */
1503 unsigned int multilayer: 1; /* only applies if TYPE3 is set, means this font can contain strokes & fills */
1504 /* I leave it in so as to avoid cluttering up code with #ifdefs */
1505 unsigned int strokedfont: 1;
1506 unsigned int new: 1; /* A new and unsaved font */
1507 unsigned int compacted: 1; /* only used when opening a font */
1508 unsigned int backedup: 2; /* 0=>don't know, 1=>no, 2=>yes */
1509 unsigned int use_typo_metrics: 1; /* The standard says to. But MS */
1510 /* seems to feel that isn't good */
1511 /* enough and has created a bit */
1512 /* to mean "really use them" */
1513 unsigned int weight_width_slope_only: 1; /* This bit seems stupid to me */
1514 unsigned int save_to_dir: 1; /* Loaded from an sfdir collection rather than a simple sfd file */
1515 unsigned int head_optimized_for_cleartype: 1;/* Bit in the 'head' flags field, if unset "East Asian fonts in the Windows Presentation Framework (Avalon) will not be hinted" */
1516 unsigned int ticked: 1;
1517 unsigned int internal_temp: 1; /* Internal temporary font to be passed to freetype for rasterizing. Don't complain about oddities */
1518 unsigned int complained_about_spiros: 1;
1519 unsigned int use_xuid: 1; /* Adobe has deprecated these two */
1520 unsigned int use_uniqueid: 1; /* fields. Mostly we don't want to use them */
1521 /* 2 bits left */
1522 struct fontviewbase *fv;
1523 struct metricsview *metrics;
1524 enum uni_interp uni_interp;
1525 NameList *for_new_glyphs;
1526 EncMap *map; /* only used when opening a font to provide original default encoding */
1527 Layer grid;
1528 BDFFont *bitmaps;
1529 char *origname; /* filename of font file (ie. if not an sfd) */
1530 char *autosavename;
1531 int display_size; /* a val <0 => Generate our own images from splines, a value >0 => find a bdf font of that size */
1532 struct psdict *private; /* read in from type1 file or provided by user */
1533 char *xuid;
1534 struct pfminfo { /* A misnomer now. OS/2 info would be more accurate, but that's stuff in here from all over ttf files */
1535 unsigned int pfmset: 1;
1536 unsigned int winascent_add: 1;
1537 unsigned int windescent_add: 1;
1538 unsigned int hheadascent_add: 1;
1539 unsigned int hheaddescent_add: 1;
1540 unsigned int typoascent_add: 1;
1541 unsigned int typodescent_add: 1;
1542 unsigned int subsuper_set: 1;
1543 unsigned int panose_set: 1;
1544 unsigned int hheadset: 1;
1545 unsigned int vheadset: 1;
1546 unsigned int hascodepages: 1;
1547 unsigned int hasunicoderanges: 1;
1548 unsigned char pfmfamily;
1549 int16 weight;
1550 int16 width;
1551 char panose[10];
1552 int16 fstype;
1553 int16 linegap; /* from hhea */
1554 int16 vlinegap; /* from vhea */
1555 int16 hhead_ascent, hhead_descent;
1556 int16 os2_typoascent, os2_typodescent, os2_typolinegap;
1557 int16 os2_winascent, os2_windescent;
1558 int16 os2_subxsize, os2_subysize, os2_subxoff, os2_subyoff;
1559 int16 os2_supxsize, os2_supysize, os2_supxoff, os2_supyoff;
1560 int16 os2_strikeysize, os2_strikeypos;
1561 char os2_vendor[4];
1562 int16 os2_family_class;
1563 uint32 codepages[2];
1564 uint32 unicoderanges[4];
1565 uint16 avgwidth;
1566 uint16 firstchar;
1567 uint16 lastchar;
1568 int16 os2_xheight;
1569 int16 os2_capheight;
1570 uint16 os2_defaultchar;
1571 uint16 os2_breakchar;
1572 } pfminfo;
1573 struct ttflangname *names;
1574 char *cidregistry, *ordering;
1575 int supplement;
1576 int subfontcnt;
1577 struct splinefont **subfonts;
1578 struct splinefont *cidmaster; /* Top level cid font */
1579 float cidversion;
1580 #if HANYANG
1581 struct compositionrules *rules;
1582 #endif
1583 char *comments; /* Used to be restricted to ASCII, now utf8 */
1584 char *fontlog;
1585 int tempuniqueid;
1586 int top_enc;
1587 uint16 desired_row_cnt, desired_col_cnt;
1588 struct glyphnamehash *glyphnames;
1589 struct ttf_table {
1590 uint32 tag;
1591 int32 len, maxlen;
1592 uint8 *data;
1593 struct ttf_table *next;
1594 FILE *temp; /* Temporary storage used during generation */
1595 } *ttf_tables, *ttf_tab_saved;
1596 /* We copy: fpgm, prep, cvt, maxp (into ttf_tables) user can ask for others, into saved*/
1597 char **cvt_names;
1598 /* The end of this array is marked by a special entry: */
1599 #define END_CVT_NAMES ((char *) (~(intpt) 0))
1600 struct instrdata *instr_dlgs; /* Pointer to all table and character instruction dlgs in this font */
1601 struct shortview *cvt_dlg;
1602 struct kernclasslistdlg *kcld, *vkcld;
1603 struct kernclassdlg *kcd;
1604 struct texdata {
1605 enum { tex_unset, tex_text, tex_math, tex_mathext } type;
1606 int32 params[22]; /* param[6] has different meanings in normal and math fonts */
1607 } texdata;
1608 OTLookup *gsub_lookups, *gpos_lookups;
1609 AnchorClass *anchor;
1610 KernClass *kerns, *vkerns;
1611 FPST *possub;
1612 char *chosenname; /* Set for files with multiple fonts in them */
1613 struct mmset *mm; /* If part of a multiple master set */
1614 int16 macstyle;
1615 char *fondname; /* For use in generating mac families */
1616 /* from the GPOS 'size' feature. design_size, etc. are measured in tenths of a point */
1617 /* bottom is exclusive, top is inclusive */
1618 /* if any field is 0, it is undefined. All may be undefined, All may be */
1619 /* defined, or design_size may be defined without any of the others */
1620 /* but we can't define the range without defining the other junk */
1621 /* Name must contain an English language name, may contain others */
1622 uint16 design_size;
1623 uint16 fontstyle_id;
1624 struct otfname *fontstyle_name;
1625 uint16 design_range_bottom, design_range_top;
1626 real strokewidth;
1627 /* For GDEF Mark Attachment Class -- used in lookup flags */
1628 /* As usual, class 0 is unused */
1629 int mark_class_cnt;
1630 char **mark_classes; /* glyph name list */
1631 char **mark_class_names; /* used within ff, utf8 (the name we've given to this class of marks) */
1632 #ifdef _HAS_LONGLONG
1633 long long creationtime; /* seconds since 1970 */
1634 long long modificationtime;
1635 #else
1636 long creationtime;
1637 long modificationtime;
1638 #endif
1639 short os2_version; /* 0 means default rather than the real version 0 */
1640 short compression; /* If we opened a compressed sfd file, then save it out compressed too */
1641 short gasp_version; /* 0/1 currently */
1642 short gasp_cnt;
1643 struct gasp {
1644 uint16 ppem;
1645 uint16 flags;
1646 } *gasp;
1647 struct MATH *MATH;
1648 float sfd_version; /* Used only when reading in an sfd file */
1649 struct gfi_data *fontinfo;
1650 struct val_data *valwin;
1651 void *python_temporary;
1652 void *python_persistent; /* If python this will hold a python object, if not python this will hold a string containing a pickled object. We do nothing with it (if not python) except save it back out unchanged */
1653 enum loadvalidation_state loadvalidation_state;
1654 LayerInfo *layers;
1655 int layer_cnt;
1656 int display_layer;
1657 struct Base *horiz_base, *vert_base;
1658 int extrema_bound; /* Splines do not count for extrema complaints when the distance between the endpoints is less than or equal to this */
1659 } SplineFont;
1661 /* I am going to simplify my life and not encourage intermediate designs */
1662 /* this means I can easily calculate ConvertDesignVector, and don't have */
1663 /* to bother the user with specifying it. */
1664 /* (NormalizeDesignVector is fairly basic and shouldn't need user help ever) */
1665 /* (As long as they want piecewise linear) */
1666 typedef struct mmset {
1667 int axis_count;
1668 char *axes[4];
1669 int instance_count;
1670 SplineFont **instances;
1671 SplineFont *normal;
1672 real *positions; /* array[instance][axis] saying where each instance lies on each axis */
1673 real *defweights; /* array[instance] saying how much of each instance makes the normal font */
1674 struct axismap {
1675 int points; /* size of the next two arrays */
1676 real *blends; /* between [0,1] ordered so that blend[0]<blend[1]<... */
1677 real *designs; /* between the design ranges for this axis, typically [1,999] or [6,72] */
1678 real min, def, max; /* For mac */
1679 } *axismaps; /* array[axis] */
1680 char *cdv, *ndv; /* for adobe */
1681 unsigned int changed: 1;
1682 } MMSet;
1684 /* mac styles. Useful idea we'll just steal it */
1685 enum style_flags { sf_bold = 1, sf_italic = 2, sf_underline = 4, sf_outline = 8,
1686 sf_shadow = 0x10, sf_condense = 0x20, sf_extend = 0x40 };
1688 struct sflist {
1689 SplineFont *sf;
1690 int32 *sizes;
1691 FILE *tempttf; /* For ttf */
1692 int id; /* For ttf */
1693 int* ids; /* One for each size */
1694 BDFFont **bdfs; /* Ditto */
1695 EncMap *map;
1696 struct sflist *next;
1697 char **former_names;
1700 /* Used for drawing text with mark to base anchors */
1701 typedef struct anchorpos {
1702 SplineChar *sc; /* This is the mark being positioned */
1703 int x,y; /* Its origin should be shifted this much relative to that of the original base char */
1704 AnchorPoint *apm; /* The anchor point in sc used to position it */
1705 AnchorPoint *apb; /* The anchor point in the base character against which we are positioned */
1706 int base_index; /* Index in this array to the base character (-1=> original base char) */
1707 unsigned int ticked: 1; /* Used as a mark to mark */
1708 } AnchorPos;
1710 enum ttf_flags { ttf_flag_shortps = 1, ttf_flag_nohints = 2,
1711 ttf_flag_applemode=4,
1712 ttf_flag_pfed_comments=8, ttf_flag_pfed_colors=0x10,
1713 ttf_flag_otmode=0x20,
1714 ttf_flag_glyphmap=0x40,
1715 ttf_flag_TeXtable=0x80,
1716 ttf_flag_ofm=0x100,
1717 ttf_flag_oldkern=0x200, /* never set in conjunction with applemode */
1718 ttf_flag_brokensize=0x400, /* Adobe originally issued fonts with a bug in the size feature. They now claim (Aug 2006) that this has been fixed. Legacy programs will do the wrong thing with the fixed feature though */
1719 ttf_flag_pfed_lookupnames=0x800,
1720 ttf_flag_pfed_guides=0x1000,
1721 ttf_flag_pfed_layers=0x2000,
1722 ttf_flag_symbol=0x4000,
1723 ttf_flag_dummyDSIG=0x8000
1725 enum openflags { of_fstypepermitted=1, of_askcmap=2, of_all_glyphs_in_ttc=4,
1726 of_fontlint=8, of_hidewindow=0x10 };
1727 enum ps_flags { ps_flag_nohintsubs = 0x10000, ps_flag_noflex=0x20000,
1728 ps_flag_nohints = 0x40000, ps_flag_restrict256=0x80000,
1729 ps_flag_afm = 0x100000, ps_flag_pfm = 0x200000,
1730 ps_flag_tfm = 0x400000,
1731 ps_flag_round = 0x800000,
1732 /* CFF fonts are wrapped up in some postscript sugar -- unless they are to */
1733 /* go into a pdf file or an otf font */
1734 ps_flag_nocffsugar = 0x1000000,
1735 /* in type42 cid fonts we sometimes want an identity map from gid to cid */
1736 ps_flag_identitycidmap = 0x2000000,
1737 ps_flag_afmwithmarks = 0x4000000,
1738 ps_flag_noseac = 0x8000000,
1739 ps_flag_outputfontlog = 0x10000000,
1740 ps_flag_mask = (ps_flag_nohintsubs|ps_flag_noflex|
1741 ps_flag_afm|ps_flag_pfm|ps_flag_tfm|ps_flag_round)
1744 struct compressors { char *ext, *decomp, *recomp; };
1745 struct archivers {
1746 char *ext, *unarchive, *archive, *listargs, *extractargs, *appendargs;
1747 enum archive_list_style { ars_tar, ars_zip } ars;
1750 struct fontdict;
1751 struct pschars;
1752 struct findsel;
1753 struct charprocs;
1754 struct enc;
1756 /* extern void *chunkalloc(int size); */
1757 /* extern void chunkfree(void *, int size); */
1759 #define chunkalloc(size) gcalloc(1,size)
1760 #define chunkfree(item,size) free(item)
1762 extern char *strconcat(const char *str, const char *str2);
1763 extern char *strconcat3(const char *str, const char *str2, const char *str3);
1765 extern char *XUIDFromFD(int xuid[20]);
1766 extern SplineFont *SplineFontFromPSFont(struct fontdict *fd);
1767 extern int CheckAfmOfPostscript(SplineFont *sf, const char *psname,EncMap *map);
1768 extern int LoadKerningDataFromAmfm(SplineFont *sf, char *filename, EncMap *map);
1769 extern int LoadKerningDataFromAfm(SplineFont *sf, char *filename, EncMap *map);
1770 extern int LoadKerningDataFromTfm(SplineFont *sf, char *filename, EncMap *map);
1771 extern int LoadKerningDataFromOfm(SplineFont *sf, char *filename, EncMap *map);
1772 extern int LoadKerningDataFromPfm(SplineFont *sf, char *filename, EncMap *map);
1773 extern int LoadKerningDataFromMacFOND(SplineFont *sf, char *filename, EncMap *map);
1774 extern int LoadKerningDataFromMetricsFile(SplineFont *sf, char *filename, EncMap *map);
1775 extern void FeatDumpFontLookups(FILE *out,SplineFont *sf);
1776 extern void FeatDumpOneLookup(FILE *out,SplineFont *sf, OTLookup *otl);
1777 extern void SFApplyFeatureFile(SplineFont *sf,FILE *file,char *filename);
1778 extern void SFApplyFeatureFilename(SplineFont *sf,char *filename);
1779 extern void SubsNew(SplineChar *to,enum possub_type type,int tag,char *components,
1780 SplineChar *default_script);
1781 extern void PosNew(SplineChar *to,int tag,int dx, int dy, int dh, int dv);
1782 extern int SFOneWidth(SplineFont *sf);
1783 extern int CIDOneWidth(SplineFont *sf);
1784 extern int SFOneHeight(SplineFont *sf);
1785 extern int SFIsCJK(SplineFont *sf,EncMap *map);
1786 extern void CIDMasterAsDes(SplineFont *sf);
1787 enum fontformat { ff_pfa, ff_pfb, ff_pfbmacbin, ff_multiple, ff_mma, ff_mmb,
1788 ff_ptype3, ff_ptype0, ff_cid, ff_cff, ff_cffcid,
1789 ff_type42, ff_type42cid,
1790 ff_ttf, ff_ttfsym, ff_ttfmacbin, ff_ttfdfont, ff_otf, ff_otfdfont,
1791 ff_otfcid, ff_otfciddfont, ff_svg, ff_ufo, ff_none };
1792 extern struct pschars *SplineFont2ChrsSubrs(SplineFont *sf, int iscjk,
1793 struct pschars *subrs,int flags,enum fontformat format,int layer);
1794 extern int CanonicalCombiner(int uni);
1795 struct cidbytes;
1796 struct fd2data;
1797 struct ttfinfo;
1798 struct alltabs;
1799 struct growbuf;
1800 struct glyphdata;
1801 extern int UnitsParallel(BasePoint *u1,BasePoint *u2,int strict);
1802 extern int CvtPsStem3(struct growbuf *gb, SplineChar *scs[MmMax], int instance_count,
1803 int ishstem, int round);
1804 extern struct pschars *SplineFont2ChrsSubrs2(SplineFont *sf, int nomwid,
1805 int defwid, const int *bygid, int cnt, int flags,
1806 struct pschars **_subrs,int layer);
1807 extern struct pschars *CID2ChrsSubrs2(SplineFont *cidmaster,struct fd2data *fds,
1808 int flags, struct pschars **_glbls,int layer);
1809 enum bitmapformat { bf_bdf, bf_ttf, bf_sfnt_dfont, bf_sfnt_ms, bf_otb,
1810 bf_nfntmacbin, /*bf_nfntdfont, */bf_fon, bf_fnt, bf_palm,
1811 bf_ptype3,
1812 bf_none };
1813 extern const char *GetAuthor(void);
1814 extern SplineChar *SFFindExistingCharMac(SplineFont *,EncMap *map, int unienc);
1815 extern void SC_PSDump(void (*dumpchar)(int ch,void *data), void *data,
1816 SplineChar *sc, int refs_to_splines, int pdfopers,int layer );
1817 extern int _WritePSFont(FILE *out,SplineFont *sf,enum fontformat format,int flags,EncMap *enc,SplineFont *fullsf,int layer);
1818 extern int WritePSFont(char *fontname,SplineFont *sf,enum fontformat format,int flags,EncMap *enc,SplineFont *fullsf,int layer);
1819 extern int WriteMacPSFont(char *fontname,SplineFont *sf,enum fontformat format,
1820 int flags,EncMap *enc,int layer);
1821 extern int _WriteTTFFont(FILE *ttf,SplineFont *sf, enum fontformat format,
1822 int32 *bsizes, enum bitmapformat bf,int flags,EncMap *enc,int layer);
1823 extern int WriteTTFFont(char *fontname,SplineFont *sf, enum fontformat format,
1824 int32 *bsizes, enum bitmapformat bf,int flags,EncMap *enc,int layer);
1825 extern int _WriteType42SFNTS(FILE *type42,SplineFont *sf,enum fontformat format,
1826 int flags,EncMap *enc,int layer);
1827 extern int WriteMacTTFFont(char *fontname,SplineFont *sf, enum fontformat format,
1828 int32 *bsizes, enum bitmapformat bf,int flags,EncMap *enc,int layer);
1829 extern int WriteMacBitmaps(char *filename,SplineFont *sf, int32 *sizes,
1830 int is_dfont,EncMap *enc);
1831 extern int WritePalmBitmaps(char *filename,SplineFont *sf, int32 *sizes,EncMap *enc);
1832 extern int WriteMacFamily(char *filename,struct sflist *sfs,enum fontformat format,
1833 enum bitmapformat bf,int flags,EncMap *enc,int layer);
1834 extern long mactime(void);
1835 extern int WriteSVGFont(char *fontname,SplineFont *sf,enum fontformat format,int flags,EncMap *enc,int layer);
1836 extern int WriteUFOFont(char *fontname,SplineFont *sf,enum fontformat format,int flags,EncMap *enc,int layer);
1837 extern void SfListFree(struct sflist *sfs);
1838 extern void DefaultTTFEnglishNames(struct ttflangname *dummy, SplineFont *sf);
1839 extern void TeXDefaultParams(SplineFont *sf);
1840 extern int AlreadyMSSymbolArea(SplineFont *sf,EncMap *map);
1841 extern void OS2FigureCodePages(SplineFont *sf, uint32 CodePage[2]);
1842 extern void OS2FigureUnicodeRanges(SplineFont *sf, uint32 Ranges[4]);
1843 extern void SFDefaultOS2Info(struct pfminfo *pfminfo,SplineFont *sf,char *fontname);
1844 extern void SFDefaultOS2Simple(struct pfminfo *pfminfo,SplineFont *sf);
1845 extern void SFDefaultOS2SubSuper(struct pfminfo *pfminfo,int emsize,double italicangle);
1846 extern void VerifyLanguages(SplineFont *sf);
1847 extern int ScriptIsRightToLeft(uint32 script);
1848 extern void ScriptMainRange(uint32 script, int *start, int *end);
1849 extern uint32 ScriptFromUnicode(int u,SplineFont *sf);
1850 extern uint32 SCScriptFromUnicode(SplineChar *sc);
1851 extern int SCRightToLeft(SplineChar *sc);
1852 extern int SLIContainsR2L(SplineFont *sf,int sli);
1853 extern void SFFindNearTop(SplineFont *);
1854 extern void SFRestoreNearTop(SplineFont *);
1855 extern int SFForceEncoding(SplineFont *sf,EncMap *old,Encoding *new_map);
1856 extern int CountOfEncoding(Encoding *encoding_name);
1857 extern void SFMatchGlyphs(SplineFont *sf,SplineFont *target,int addempties);
1858 extern void MMMatchGlyphs(MMSet *mm);
1859 extern char *_GetModifiers(char *fontname, char *familyname,char *weight);
1860 extern char *SFGetModifiers(SplineFont *sf);
1861 extern const unichar_t *_uGetModifiers(const unichar_t *fontname, const unichar_t *familyname,
1862 const unichar_t *weight);
1863 extern void SFSetFontName(SplineFont *sf, char *family, char *mods, char *full);
1864 extern void ttfdumpbitmap(SplineFont *sf,struct alltabs *at,int32 *sizes);
1865 extern void ttfdumpbitmapscaling(SplineFont *sf,struct alltabs *at,int32 *sizes);
1866 extern void SplineFontSetUnChanged(SplineFont *sf);
1868 extern int RealNear(real a,real b);
1869 extern int RealNearish(real a,real b);
1870 extern int RealApprox(real a,real b);
1871 extern int RealWithin(real a,real b,real fudge);
1872 extern int RealRatio(real a,real b,real fudge);
1874 extern int PointsDiagonalable(SplineFont *sf,BasePoint **bp,BasePoint *unit);
1875 extern int MergeDStemInfo(SplineFont *sf,DStemInfo **ds, DStemInfo *test);
1877 extern void LineListFree(LineList *ll);
1878 extern void LinearApproxFree(LinearApprox *la);
1879 extern void SplineFree(Spline *spline);
1880 extern SplinePoint *SplinePointCreate(real x, real y);
1881 extern void SplinePointFree(SplinePoint *sp);
1882 extern void SplinePointMDFree(SplineChar *sc,SplinePoint *sp);
1883 extern void SplinePointsFree(SplinePointList *spl);
1884 extern void SplinePointListFree(SplinePointList *spl);
1885 extern void SplinePointListMDFree(SplineChar *sc,SplinePointList *spl);
1886 extern void SplinePointListsMDFree(SplineChar *sc,SplinePointList *spl);
1887 extern void SplinePointListsFree(SplinePointList *head);
1888 extern void SplineSetBeziersClear(SplineSet *spl);
1889 extern void RefCharFree(RefChar *ref);
1890 extern void RefCharsFree(RefChar *ref);
1891 extern void RefCharsFreeRef(RefChar *ref);
1892 extern void CopyBufferFree(void);
1893 extern void CopyBufferClearCopiedFrom(SplineFont *dying);
1894 extern void UndoesFree(Undoes *undo);
1895 extern void StemInfosFree(StemInfo *h);
1896 extern void StemInfoFree(StemInfo *h);
1897 extern void DStemInfosFree(DStemInfo *h);
1898 extern void DStemInfoFree(DStemInfo *h);
1899 extern void KernPairsFree(KernPair *kp);
1900 extern void SCOrderAP(SplineChar *sc);
1901 extern void AnchorPointsFree(AnchorPoint *ap);
1902 extern AnchorPoint *AnchorPointsCopy(AnchorPoint *alist);
1903 extern void SFRemoveAnchorClass(SplineFont *sf,AnchorClass *an);
1904 extern int AnchorClassesNextMerge(AnchorClass *ac);
1905 extern int IsAnchorClassUsed(SplineChar *sc,AnchorClass *an);
1906 extern AnchorPoint *APAnchorClassMerge(AnchorPoint *anchors,AnchorClass *into,AnchorClass *from);
1907 extern void AnchorClassMerge(SplineFont *sf,AnchorClass *into,AnchorClass *from);
1908 extern void AnchorClassesFree(AnchorClass *kp);
1909 extern void TtfTablesFree(struct ttf_table *tab);
1910 extern void SFRemoveSavedTable(SplineFont *sf, uint32 tag);
1911 extern AnchorClass *AnchorClassMatch(SplineChar *sc1,SplineChar *sc2,
1912 AnchorClass *restrict_, AnchorPoint **_ap1,AnchorPoint **_ap2 );
1913 extern AnchorClass *AnchorClassMkMkMatch(SplineChar *sc1,SplineChar *sc2,
1914 AnchorPoint **_ap1,AnchorPoint **_ap2 );
1915 extern AnchorClass *AnchorClassCursMatch(SplineChar *sc1,SplineChar *sc2,
1916 AnchorPoint **_ap1,AnchorPoint **_ap2 );
1917 extern void SCInsertPST(SplineChar *sc,PST *new);
1918 #ifdef FONTFORGE_CONFIG_DEVICETABLES
1919 extern void ValDevFree(ValDevTab *adjust);
1920 extern ValDevTab *ValDevTabCopy(ValDevTab *orig);
1921 extern void DeviceTableFree(DeviceTable *adjust);
1922 extern DeviceTable *DeviceTableCopy(DeviceTable *orig);
1923 extern void DeviceTableSet(DeviceTable *adjust, int size, int correction);
1924 #endif
1925 extern void PSTFree(PST *lig);
1926 extern uint16 PSTDefaultFlags(enum possub_type type,SplineChar *sc );
1927 extern int PSTContains(const char *components,const char *name);
1928 extern StemInfo *StemInfoCopy(StemInfo *h);
1929 extern DStemInfo *DStemInfoCopy(DStemInfo *h);
1930 extern MinimumDistance *MinimumDistanceCopy(MinimumDistance *h);
1931 extern void SPChangePointType(SplinePoint *sp, int pointtype);
1932 struct sfmergecontext {
1933 SplineFont *sf_from, *sf_to;
1934 int lcnt;
1935 struct lookup_cvt { OTLookup *from, *to; int old;} *lks;
1936 int scnt;
1937 struct sub_cvt { struct lookup_subtable *from, *to; int old;} *subs;
1938 int acnt;
1939 struct ac_cvt { AnchorClass *from, *to; int old;} *acs;
1940 char *prefix;
1941 int preserveCrossFontKerning;
1942 int lmax;
1944 extern PST *PSTCopy(PST *base,SplineChar *sc,struct sfmergecontext *mc);
1945 extern struct lookup_subtable *MCConvertSubtable(struct sfmergecontext *mc,struct lookup_subtable *sub);
1946 extern AnchorClass *MCConvertAnchorClass(struct sfmergecontext *mc,AnchorClass *ac);
1947 extern void SFFinishMergeContext(struct sfmergecontext *mc);
1948 extern SplineChar *SplineCharCopy(SplineChar *sc,SplineFont *into,struct sfmergecontext *);
1949 extern BDFChar *BDFCharCopy(BDFChar *bc);
1950 extern void BCFlattenFloat(BDFChar *bc);
1951 extern void BitmapsCopy(SplineFont *to, SplineFont *from, int to_index, int from_index );
1952 extern struct gimage *ImageAlterClut(struct gimage *image);
1953 extern void ImageListsFree(ImageList *imgs);
1954 extern void TTFLangNamesFree(struct ttflangname *l);
1955 extern void AltUniFree(struct altuni *altuni);
1956 extern void AltUniRemove(SplineChar *sc,int uni);
1957 extern void MinimumDistancesFree(MinimumDistance *md);
1958 extern void LayerDefault(Layer *);
1959 extern SplineChar *SplineCharCreate(int layer_cnt);
1960 extern SplineChar *SFSplineCharCreate(SplineFont *sf);
1961 extern RefChar *RefCharCreate(void);
1962 extern RefChar *RefCharsCopy(RefChar *ref); /* Still needs to be instanciated and have the dependency list adjusted */
1963 extern void SCAddRef(SplineChar *sc,SplineChar *rsc,int layer, real xoff, real yoff);
1964 extern void _SCAddRef(SplineChar *sc,SplineChar *rsc,int layer, real transform[6]);
1965 extern KernClass *KernClassCopy(KernClass *kc);
1966 extern void KernClassFreeContents(KernClass *kc);
1967 extern void KernClassListFree(KernClass *kc);
1968 extern int KernClassContains(KernClass *kc, char *name1, char *name2, int ordered );
1969 extern void OTLookupFree(OTLookup *lookup);
1970 extern void OTLookupListFree(OTLookup *lookup );
1971 extern FPST *FPSTCopy(FPST *fpst);
1972 extern void FPSTRuleContentsFree(struct fpst_rule *r, enum fpossub_format format);
1973 extern void FPSTRulesFree(struct fpst_rule *r, enum fpossub_format format, int rcnt);
1974 extern void FPSTFree(FPST *fpst);
1975 extern void GlyphVariantsFree(struct glyphvariants *gv);
1976 extern void MathKernVContentsFree(struct mathkernvertex *mk);
1977 extern void MathKernFree(struct mathkern *mk);
1978 extern struct mathkern *MathKernCopy(struct mathkern *mk);
1979 extern void SplineCharListsFree(struct splinecharlist *dlist);
1980 extern void LayerFreeContents(SplineChar *sc, int layer);
1981 extern void SplineCharFreeContents(SplineChar *sc);
1982 extern void SplineCharFree(SplineChar *sc);
1983 extern void EncMapFree(EncMap *map);
1984 extern EncMap *EncMapFromEncoding(SplineFont *sf,Encoding *enc);
1985 extern EncMap *CompactEncMap(EncMap *map, SplineFont *sf);
1986 extern EncMap *EncMapNew(int encmax, int backmax, Encoding *enc);
1987 extern EncMap *EncMap1to1(int enccount);
1988 extern EncMap *EncMapCopy(EncMap *map);
1989 extern void SFExpandGlyphCount(SplineFont *sf, int newcnt);
1990 extern void ScriptLangListFree(struct scriptlanglist *sl);
1991 extern void FeatureScriptLangListFree(FeatureScriptLangList *fl);
1992 extern void SFBaseSort(SplineFont *sf);
1993 extern struct baselangextent *BaseLangCopy(struct baselangextent *extent);
1994 extern void BaseLangFree(struct baselangextent *extent);
1995 extern void BaseScriptFree(struct basescript *bs);
1996 extern void BaseFree(struct Base *base);
1997 extern void SplineFontFree(SplineFont *sf);
1998 extern void MATHFree(struct MATH *math);
1999 extern struct MATH *MathTableNew(SplineFont *sf);
2000 extern void OtfNameListFree(struct otfname *on);
2001 extern void MarkClassFree(int cnt,char **classes,char **names);
2002 extern void MMSetFreeContents(MMSet *mm);
2003 extern void MMSetFree(MMSet *mm);
2004 extern void SFRemoveUndoes(SplineFont *sf,uint8 *selected,EncMap *map);
2005 extern void SplineRefigure3(Spline *spline);
2006 extern void SplineRefigure(Spline *spline);
2007 extern Spline *SplineMake3(SplinePoint *from, SplinePoint *to);
2008 extern LinearApprox *SplineApproximate(Spline *spline, real scale);
2009 extern int SplinePointListIsClockwise(const SplineSet *spl);
2010 extern void SplineSetFindBounds(const SplinePointList *spl, DBounds *bounds);
2011 extern void SplineCharLayerFindBounds(SplineChar *sc,int layer,DBounds *bounds);
2012 extern void SplineCharFindBounds(SplineChar *sc,DBounds *bounds);
2013 extern void SplineFontLayerFindBounds(SplineFont *sf,int layer,DBounds *bounds);
2014 extern void SplineFontFindBounds(SplineFont *sf,DBounds *bounds);
2015 extern void CIDLayerFindBounds(SplineFont *sf,int layer,DBounds *bounds);
2016 extern void SplineSetQuickBounds(SplineSet *ss,DBounds *b);
2017 extern void SplineCharQuickBounds(SplineChar *sc, DBounds *b);
2018 extern void SplineSetQuickConservativeBounds(SplineSet *ss,DBounds *b);
2019 extern void SplineCharQuickConservativeBounds(SplineChar *sc, DBounds *b);
2020 extern void SplineFontQuickConservativeBounds(SplineFont *sf,DBounds *b);
2021 extern void SplinePointCatagorize(SplinePoint *sp);
2022 extern int SplinePointIsACorner(SplinePoint *sp);
2023 extern void SPLCatagorizePoints(SplinePointList *spl);
2024 extern void SCCatagorizePoints(SplineChar *sc);
2025 extern SplinePointList *SplinePointListCopy1(const SplinePointList *spl);
2026 extern SplinePointList *SplinePointListCopy(const SplinePointList *base);
2027 extern SplinePointList *SplinePointListCopySelected(SplinePointList *base);
2028 extern ImageList *ImageListCopy(ImageList *cimg);
2029 extern ImageList *ImageListTransform(ImageList *cimg,real transform[6]);
2030 extern void ApTransform(AnchorPoint *ap, real transform[6]);
2031 extern SplinePointList *SplinePointListTransform(SplinePointList *base, real transform[6], int allpoints );
2032 extern SplinePointList *SplinePointListShift(SplinePointList *base, real xoff, int allpoints );
2033 extern HintMask *HintMaskFromTransformedRef(RefChar *ref,BasePoint *trans,
2034 SplineChar *basesc,HintMask *hm);
2035 extern SplinePointList *SPLCopyTranslatedHintMasks(SplinePointList *base,
2036 SplineChar *basesc, SplineChar *subsc, BasePoint *trans);
2037 extern SplinePointList *SPLCopyTransformedHintMasks(RefChar *r,
2038 SplineChar *basesc, BasePoint *trans,int layer);
2039 extern SplinePointList *SplinePointListRemoveSelected(SplineChar *sc,SplinePointList *base);
2040 extern void SplinePointListSet(SplinePointList *tobase, SplinePointList *frombase);
2041 extern void SplinePointListSelect(SplinePointList *spl,int sel);
2042 extern void SCRefToSplines(SplineChar *sc,RefChar *rf,int layer);
2043 extern void RefCharFindBounds(RefChar *rf);
2044 extern void SCReinstanciateRefChar(SplineChar *sc,RefChar *rf,int layer);
2045 extern void SCReinstanciateRef(SplineChar *sc,SplineChar *rsc,int layer);
2046 extern void SFReinstanciateRefs(SplineFont *sf);
2047 extern void SFInstanciateRefs(SplineFont *sf);
2048 extern SplineChar *MakeDupRef(SplineChar *base, int local_enc, int uni_enc);
2049 extern void SCRemoveDependent(SplineChar *dependent,RefChar *rf,int layer);
2050 extern void SCRemoveLayerDependents(SplineChar *dependent,int layer);
2051 extern void SCRemoveDependents(SplineChar *dependent);
2052 extern int SCDependsOnSC(SplineChar *parent, SplineChar *child);
2053 extern void BCCompressBitmap(BDFChar *bdfc);
2054 extern void BCRegularizeBitmap(BDFChar *bdfc);
2055 extern void BCRegularizeGreymap(BDFChar *bdfc);
2056 extern void BCPasteInto(BDFChar *bc,BDFChar *rbc,int ixoff,int iyoff, int invert, int cleartoo);
2057 extern void BCRotateCharForVert(BDFChar *bc,BDFChar *from, BDFFont *frombdf);
2058 extern int GradientHere(double scale,DBounds *bbox,int iy,int ix,
2059 struct gradient *grad,struct pattern *pat, int defgrey);
2060 extern void PatternPrep(SplineChar *sc,struct brush *brush,double scale);
2061 extern BDFChar *SplineCharRasterize(SplineChar *sc, int layer, double pixelsize);
2062 extern BDFFont *SplineFontToBDFHeader(SplineFont *_sf, int pixelsize, int indicate);
2063 extern BDFFont *SplineFontRasterize(SplineFont *sf, int layer, int pixelsize, int indicate);
2064 extern void BDFCAntiAlias(BDFChar *bc, int linear_scale);
2065 extern BDFChar *SplineCharAntiAlias(SplineChar *sc, int layer, int pixelsize,int linear_scale);
2066 extern BDFFont *SplineFontAntiAlias(SplineFont *sf, int layer, int pixelsize,int linear_scale);
2067 extern struct clut *_BDFClut(int linear_scale);
2068 extern void BDFClut(BDFFont *bdf, int linear_scale);
2069 extern int BDFDepth(BDFFont *bdf);
2070 extern BDFChar *BDFPieceMeal(BDFFont *bdf, int index);
2071 extern BDFChar *BDFPieceMealCheck(BDFFont *bdf, int index);
2072 enum piecemeal_flags { pf_antialias=1, pf_bbsized=2, pf_ft_nohints=4 };
2073 extern BDFFont *SplineFontPieceMeal(SplineFont *sf,int layer,int pixelsize,int flags,void *freetype_context);
2074 extern void BDFCharFindBounds(BDFChar *bc,IBounds *bb);
2075 extern BDFFont *BitmapFontScaleTo(BDFFont *old, int to);
2076 extern void BDFCharFree(BDFChar *bdfc);
2077 extern void BDFPropsFree(BDFFont *bdf);
2078 extern void BDFFontFree(BDFFont *bdf);
2079 extern void SFDefaultAscent(SplineFont *sf);
2080 extern int PSBitmapDump(char *filename,BDFFont *font, EncMap *map);
2081 extern int BDFFontDump(char *filename,BDFFont *font, EncMap *map, int res);
2082 extern int FNTFontDump(char *filename,BDFFont *font, EncMap *map, int res);
2083 extern int FONFontDump(char *filename,SplineFont *sf, int32 *sizes,int res,
2084 EncMap *map);
2085 extern void SFReplaceEncodingBDFProps(SplineFont *sf,EncMap *map);
2086 extern void SFReplaceFontnameBDFProps(SplineFont *sf);
2087 extern int IsUnsignedBDFKey(char *key);
2088 extern int BdfPropHasInt(BDFFont *font,const char *key, int def );
2089 extern char *BdfPropHasString(BDFFont *font,const char *key, char *def );
2090 extern void def_Charset_Enc(EncMap *map,char *reg,char *enc);
2091 extern void Default_XLFD(BDFFont *bdf,EncMap *map, int res);
2092 extern void Default_Properties(BDFFont *bdf,EncMap *map,char *onlyme);
2093 extern void BDFDefaultProps(BDFFont *bdf, EncMap *map, int res);
2094 extern BDFProperties *BdfPropsCopy(BDFProperties *props, int cnt );
2095 struct xlfd_components {
2096 char foundry[80];
2097 char family[100];
2098 char weight[80];
2099 char slant[40];
2100 char setwidth[50];
2101 char add_style[50];
2102 int pixel_size;
2103 int point_size;
2104 int res_x;
2105 int res_y;
2106 char spacing[40];
2107 int avg_width;
2108 char cs_reg[80]; /* encoding */
2109 char cs_enc[80]; /* encoding version? */
2110 int char_cnt;
2112 struct std_bdf_props {
2113 char *name;
2114 int type;
2115 int defaultable;
2117 extern void XLFD_GetComponents(char *xlfd,struct xlfd_components *comp);
2118 extern void XLFD_CreateComponents(BDFFont *bdf,EncMap *map,int res,struct xlfd_components *comp);
2119 /* Two lines intersect in at most 1 point */
2120 /* Two quadratics intersect in at most 4 points */
2121 /* Two cubics intersect in at most 9 points */ /* Plus an extra space for a trailing -1 */
2122 extern int SplinesIntersect(const Spline *s1, const Spline *s2, BasePoint pts[9],
2123 extended t1s[10], extended t2s[10]);
2124 extern SplineSet *LayerAllSplines(Layer *layer);
2125 extern SplineSet *LayerUnAllSplines(Layer *layer);
2126 extern int SplineSetIntersect(SplineSet *spl, Spline **_spline, Spline **_spline2 );
2127 extern int LineTangentToSplineThroughPt(Spline *s, BasePoint *pt, extended ts[4],
2128 extended tmin, extended tmax);
2129 extern int CubicSolve(const Spline1D *sp,extended ts[3]);
2130 extern extended IterateSplineSolve(const Spline1D *sp, extended tmin, extended tmax, extended sought_y, double err);
2131 extern extended SplineSolve(const Spline1D *sp, real tmin, real tmax, extended sought_y, real err);
2132 extern int SplineSolveFull(const Spline1D *sp,extended val, extended ts[3]);
2133 extern void SplineFindExtrema(const Spline1D *sp, extended *_t1, extended *_t2 );
2135 SplineSet *SplineSetsInterpolate(SplineSet *base, SplineSet *other, real amount, SplineChar *sc);
2136 SplineChar *SplineCharInterpolate(SplineChar *base, SplineChar *other, real amount);
2137 extern SplineFont *InterpolateFont(SplineFont *base, SplineFont *other, real amount, Encoding *enc);
2139 double SFSerifHeight(SplineFont *sf);
2141 extern void DumpPfaEditEncodings(void);
2142 extern void ParseEncodingFile(char *filename);
2143 extern void LoadPfaEditEncodings(void);
2145 extern int GenerateScript(SplineFont *sf,char *filename,char *bitmaptype,
2146 int fmflags,int res, char *subfontdirectory,struct sflist *sfs,
2147 EncMap *map,NameList *rename_to,int layer);
2149 extern void _SCAutoTrace(SplineChar *sc, int layer, char **args);
2150 extern char **AutoTraceArgs(int ask);
2152 #define CURVATURE_ERROR -1e9
2153 extern double SplineCurvature(Spline *s, double t);
2155 #ifndef EXTENDED_IS_LONG_DOUBLE
2156 extern double CheckExtremaForSingleBitErrors(const Spline1D *sp, double t);
2157 #define esqrt(d) sqrt(d)
2158 #else
2159 extern extended esqrt(extended e);
2160 #endif
2161 extern int Spline2DFindExtrema(const Spline *sp, extended extrema[4] );
2162 extern int Spline2DFindPointsOfInflection(const Spline *sp, extended poi[2] );
2163 extern int SplineAtInflection(Spline1D *sp, double t );
2164 extern int SplineAtMinMax(Spline1D *sp, double t );
2165 extern void SplineRemoveExtremaTooClose(Spline1D *sp, extended *_t1, extended *_t2 );
2166 extern int NearSpline(struct findsel *fs, Spline *spline);
2167 extern real SplineNearPoint(Spline *spline, BasePoint *bp, real fudge);
2168 extern void SCMakeDependent(SplineChar *dependent,SplineChar *base);
2169 extern SplinePoint *SplineBisect(Spline *spline, extended t);
2170 extern Spline *SplineSplit(Spline *spline, extended ts[3]);
2171 extern Spline *ApproximateSplineFromPoints(SplinePoint *from, SplinePoint *to,
2172 TPoint *mid, int cnt,int order2);
2173 extern Spline *ApproximateSplineFromPointsSlopes(SplinePoint *from, SplinePoint *to,
2174 TPoint *mid, int cnt,int order2);
2175 extern double SplineLength(Spline *spline);
2176 extern double SplineLengthRange(Spline *spline, real from_t, real to_t);
2177 extern double PathLength(SplineSet *ss);
2178 extern Spline *PathFindDistance(SplineSet *path,double d,double *_t);
2179 extern SplineSet *SplineSetBindToPath(SplineSet *ss,int doscale, int glyph_as_unit,
2180 int align,real offset, SplineSet *path);
2181 extern int SplineIsLinear(Spline *spline);
2182 extern int SplineIsLinearMake(Spline *spline);
2183 extern int SSPointWithin(SplineSet *spl,BasePoint *pt);
2184 extern SplineSet *SSRemoveZeroLengthSplines(SplineSet *base);
2185 extern void SSRemoveStupidControlPoints(SplineSet *base);
2186 extern void SSOverlapClusterCpAngles(SplineSet *base,double within);
2187 extern void SplinesRemoveBetween(SplineChar *sc, SplinePoint *from, SplinePoint *to,int type);
2188 extern void SplineCharMerge(SplineChar *sc,SplineSet **head,int type);
2189 extern void SPLNearlyHvCps(SplineChar *sc,SplineSet *ss,double err);
2190 extern void SPLNearlyHvLines(SplineChar *sc,SplineSet *ss,double err);
2191 extern int SPLNearlyLines(SplineChar *sc,SplineSet *ss,double err);
2192 extern int SPInterpolate(SplinePoint *sp);
2193 extern void SplinePointListSimplify(SplineChar *sc,SplinePointList *spl,
2194 struct simplifyinfo *smpl);
2195 extern SplineSet *SplineCharSimplify(SplineChar *sc,SplineSet *head,
2196 struct simplifyinfo *smpl);
2197 extern void SPLStartToLeftmost(SplineChar *sc,SplinePointList *spl, int *changed);
2198 extern void SPLsStartToLeftmost(SplineChar *sc,int layer);
2199 extern void CanonicalContours(SplineChar *sc,int layer);
2200 extern void SplineSetJoinCpFixup(SplinePoint *sp);
2201 extern SplineSet *SplineSetJoin(SplineSet *start,int doall,real fudge,int *changed);
2202 enum ae_type { ae_all, ae_between_selected, ae_only_good, ae_only_good_rm_later };
2203 extern Spline *SplineAddExtrema(Spline *s,int always,real lenbound,
2204 real offsetbound,DBounds *b);
2205 extern void SplineSetAddExtrema(SplineChar *sc,SplineSet *ss,enum ae_type between_selected, int emsize);
2206 extern void SplineCharAddExtrema(SplineChar *sc,SplineSet *head,enum ae_type between_selected,int emsize);
2207 extern SplineSet *SplineCharRemoveTiny(SplineChar *sc,SplineSet *head);
2208 extern SplineFont *SplineFontNew(void);
2209 extern char *GetNextUntitledName(void);
2210 extern SplineFont *SplineFontEmpty(void);
2211 extern SplineFont *SplineFontBlank(int charcnt);
2212 extern void SFIncrementXUID(SplineFont *sf);
2213 extern void SFRandomChangeXUID(SplineFont *sf);
2214 extern SplineSet *SplineSetReverse(SplineSet *spl);
2215 extern SplineSet *SplineSetsExtractOpen(SplineSet **tbase);
2216 extern void SplineSetsInsertOpen(SplineSet **tbase,SplineSet *open);
2217 extern SplineSet *SplineSetsCorrect(SplineSet *base,int *changed);
2218 extern SplineSet *SplineSetsAntiCorrect(SplineSet *base);
2219 extern SplineSet *SplineSetsDetectDir(SplineSet **_base, int *lastscan);
2220 extern void SPAverageCps(SplinePoint *sp);
2221 extern void SPLAverageCps(SplinePointList *spl);
2222 extern void SPWeightedAverageCps(SplinePoint *sp);
2223 extern void SplineCharDefaultPrevCP(SplinePoint *base);
2224 extern void SplineCharDefaultNextCP(SplinePoint *base);
2225 extern void SplineCharTangentNextCP(SplinePoint *sp);
2226 extern void SplineCharTangentPrevCP(SplinePoint *sp);
2227 extern void SPHVCurveForce(SplinePoint *sp);
2228 extern void SPSmoothJoint(SplinePoint *sp);
2229 extern int PointListIsSelected(SplinePointList *spl);
2230 extern void SCSplinePointsUntick(SplineChar *sc,int layer);
2231 extern void SFOrderBitmapList(SplineFont *sf);
2232 extern int KernThreshold(SplineFont *sf, int cnt);
2233 extern real SFGuessItalicAngle(SplineFont *sf);
2235 extern SplinePoint *SplineTtfApprox(Spline *ps);
2236 extern SplineSet *SSttfApprox(SplineSet *ss);
2237 extern SplineSet *SplineSetsTTFApprox(SplineSet *ss);
2238 extern SplineSet *SSPSApprox(SplineSet *ss);
2239 extern SplineSet *SplineSetsPSApprox(SplineSet *ss);
2240 extern SplineSet *SplineSetsConvertOrder(SplineSet *ss, int to_order2);
2241 extern void SplineRefigure2(Spline *spline);
2242 extern void SplineRefigureFixup(Spline *spline);
2243 extern Spline *SplineMake2(SplinePoint *from, SplinePoint *to);
2244 extern Spline *SplineMake(SplinePoint *from, SplinePoint *to, int order2);
2245 extern Spline *SFSplineMake(SplineFont *sf,SplinePoint *from, SplinePoint *to);
2246 extern void SCConvertToOrder2(SplineChar *sc);
2247 extern void SFConvertToOrder2(SplineFont *sf);
2248 extern void SCConvertToOrder3(SplineChar *sc);
2249 extern void SFConvertToOrder3(SplineFont *sf);
2250 extern void SFConvertGridToOrder2(SplineFont *_sf);
2251 extern void SCConvertLayerToOrder2(SplineChar *sc,int layer);
2252 extern void SFConvertLayerToOrder2(SplineFont *sf,int layer);
2253 extern void SFConvertGridToOrder3(SplineFont *_sf);
2254 extern void SCConvertLayerToOrder3(SplineChar *sc,int layer);
2255 extern void SFConvertLayerToOrder3(SplineFont *sf,int layer);
2256 extern void SCConvertOrder(SplineChar *sc, int to_order2);
2257 extern void SplinePointPrevCPChanged2(SplinePoint *sp);
2258 extern void SplinePointNextCPChanged2(SplinePoint *sp);
2259 extern int IntersectLines(BasePoint *inter,
2260 BasePoint *line1_1, BasePoint *line1_2,
2261 BasePoint *line2_1, BasePoint *line2_2);
2262 extern int IntersectLinesClip(BasePoint *inter,
2263 BasePoint *line1_1, BasePoint *line1_2,
2264 BasePoint *line2_1, BasePoint *line2_2);
2266 #if 0
2267 extern void SSBisectTurners(SplineSet *spl);
2268 #endif
2269 extern SplineSet *SplineSetStroke(SplineSet *spl,StrokeInfo *si,SplineChar *sc);
2270 extern SplineSet *SSStroke(SplineSet *spl,StrokeInfo *si,SplineChar *sc);
2271 extern SplineSet *SplineSetRemoveOverlap(SplineChar *sc,SplineSet *base,enum overlap_type);
2272 extern SplineSet *SSShadow(SplineSet *spl,real angle, real outline_width,
2273 real shadow_length,SplineChar *sc, int wireframe);
2275 extern double BlueScaleFigureForced(struct psdict *private,real bluevalues[], real otherblues[]);
2276 extern double BlueScaleFigure(struct psdict *private,real bluevalues[], real otherblues[]);
2277 extern void FindBlues( SplineFont *sf, int layer, real blues[14], real otherblues[10]);
2278 extern void QuickBlues(SplineFont *sf, int layer, BlueData *bd);
2279 extern void FindHStems( SplineFont *sf, real snaps[12], real cnt[12]);
2280 extern void FindVStems( SplineFont *sf, real snaps[12], real cnt[12]);
2281 extern double SFStdVW(SplineFont *sf);
2282 extern int SplineCharIsFlexible(SplineChar *sc,int layer);
2283 extern void SCGuessHintInstancesList(SplineChar *sc,int layer,StemInfo *hstem,StemInfo *vstem,DStemInfo *dstem,int hvforce,int dforce);
2284 extern void SCGuessDHintInstances(SplineChar *sc, int layer,DStemInfo *ds );
2285 extern void SCGuessHHintInstancesAndAdd(SplineChar *sc, int layer,StemInfo *stem, real guess1, real guess2);
2286 extern void SCGuessVHintInstancesAndAdd(SplineChar *sc, int layer,StemInfo *stem, real guess1, real guess2);
2287 extern void SCGuessHHintInstancesList(SplineChar *sc, int layer);
2288 extern void SCGuessVHintInstancesList(SplineChar *sc, int layer);
2289 extern real HIlen( StemInfo *stems);
2290 extern real HIoverlap( HintInstance *mhi, HintInstance *thi);
2291 extern int StemInfoAnyOverlaps(StemInfo *stems);
2292 extern int StemListAnyConflicts(StemInfo *stems);
2293 extern HintInstance *HICopyTrans(HintInstance *hi, real mul, real offset);
2294 extern void MDAdd(SplineChar *sc, int x, SplinePoint *sp1, SplinePoint *sp2);
2295 extern int SFNeedsAutoHint( SplineFont *_sf,int layer);
2297 typedef struct bluezone {
2298 real base;
2299 int cvtindex;
2300 real family_base; /* NaN if none */
2301 int family_cvtindex;
2302 real overshoot; /* relative to baseline, NOT to base */
2303 int highest; /* used in autoinstructing for HStem positioning */
2304 int lowest; /* as above */
2305 } BlueZone;
2307 typedef struct stdstem {
2308 real width; /* -1 if none */
2309 int cvtindex;
2310 struct stdstem *snapto;/* NULL means stem isn't snapped to any other */
2311 int stopat; /* at which ppem stop snapping to snapto */
2312 } StdStem;
2314 typedef struct globalinstrct {
2315 SplineFont *sf;
2316 int layer;
2317 BlueData *bd;
2318 double fudge;
2320 /* Did we initialize the tables needed? 'maxp' is skipped because */
2321 /* its initialization always succeeds. */
2322 int cvt_done;
2323 int fpgm_done;
2324 int prep_done;
2326 /* PS private data with truetype-specific information added */
2327 BlueZone blues[12]; /* like in BlueData */
2328 int bluecnt;
2329 StdStem stdhw;
2330 StdStem *stemsnaph; /* StdHW excluded */
2331 int stemsnaphcnt;
2332 StdStem stdvw;
2333 StdStem *stemsnapv; /* StdVW excluded */
2334 int stemsnapvcnt;
2335 } GlobalInstrCt;
2337 extern void InitGlobalInstrCt( GlobalInstrCt *gic,SplineFont *sf,int layer,
2338 BlueData *bd );
2339 extern void FreeGlobalInstrCt( GlobalInstrCt *gic );
2340 extern void NowakowskiSCAutoInstr( GlobalInstrCt *gic,SplineChar *sc );
2341 extern void CVT_ImportPrivate(SplineFont *sf);
2343 extern void SCModifyHintMasksAdd(SplineChar *sc,int layer,StemInfo *new);
2344 extern void SCClearHints(SplineChar *sc);
2345 extern void SCClearHintMasks(SplineChar *sc,int layer,int counterstoo);
2346 extern void SCFigureVerticalCounterMasks(SplineChar *sc);
2347 extern void SCFigureCounterMasks(SplineChar *sc);
2348 extern void SCFigureHintMasks(SplineChar *sc,int layer);
2349 extern void _SplineCharAutoHint( SplineChar *sc, int layer, BlueData *bd, struct glyphdata *gd2, int gen_undoes );
2350 extern void SplineCharAutoHint( SplineChar *sc,int layer, BlueData *bd);
2351 extern void SFSCAutoHint( SplineChar *sc,int layer,BlueData *bd);
2352 extern void SplineFontAutoHint( SplineFont *sf, int layer);
2353 extern void SplineFontAutoHintRefs( SplineFont *sf, int layer);
2354 extern StemInfo *HintCleanup(StemInfo *stem,int dosort,int instance_count);
2355 extern int SplineFontIsFlexible(SplineFont *sf,int layer, int flags);
2356 extern int SCDrawsSomething(SplineChar *sc);
2357 #define SCWorthOutputting(a) 1
2358 extern int SFFindNotdef(SplineFont *sf, int fixed);
2359 extern int doesGlyphExpandHorizontally(SplineChar *sc);
2360 extern int IsntBDFChar(BDFChar *bdfc);
2361 extern int CIDWorthOutputting(SplineFont *cidmaster, int enc); /* Returns -1 on failure, font number on success */
2362 extern int AmfmSplineFont(FILE *afm, MMSet *mm,int formattype,EncMap *map,int layer);
2363 extern int AfmSplineFont(FILE *afm, SplineFont *sf,int formattype,EncMap *map, int docc, SplineFont *fullsf,int layer);
2364 extern int PfmSplineFont(FILE *pfm, SplineFont *sf,int type0,EncMap *map,int layer);
2365 extern int TfmSplineFont(FILE *afm, SplineFont *sf,int formattype,EncMap *map,int layer);
2366 extern int OfmSplineFont(FILE *afm, SplineFont *sf,int formattype,EncMap *map,int layer);
2367 extern char *EncodingName(Encoding *map);
2368 extern char *SFEncodingName(SplineFont *sf,EncMap *map);
2369 extern void SFLigaturePrepare(SplineFont *sf);
2370 extern void SFLigatureCleanup(SplineFont *sf);
2371 extern void SFKernClassTempDecompose(SplineFont *sf,int isv);
2372 extern void SFKernCleanup(SplineFont *sf,int isv);
2373 extern int SCSetMetaData(SplineChar *sc,char *name,int unienc,
2374 const char *comment);
2376 extern enum uni_interp interp_from_encoding(Encoding *enc,enum uni_interp interp);
2377 extern const char *EncName(Encoding *encname);
2378 extern const char*FindUnicharName(void);
2379 extern Encoding *_FindOrMakeEncoding(const char *name,int make_it);
2380 extern Encoding *FindOrMakeEncoding(const char *name);
2381 extern int SFDWrite(char *filename,SplineFont *sf,EncMap *map,EncMap *normal, int todir);
2382 extern int SFDWriteBak(SplineFont *sf,EncMap *map,EncMap *normal);
2383 extern SplineFont *SFDRead(char *filename);
2384 extern SplineFont *_SFDRead(char *filename,FILE *sfd);
2385 extern SplineFont *SFDirRead(char *filename);
2386 extern SplineChar *SFDReadOneChar(SplineFont *sf,const char *name);
2387 extern char *TTFGetFontName(FILE *ttf,int32 offset,int32 off2);
2388 extern char *TTFGetPSFontName(FILE *ttf,int32 offset,int32 off2);
2389 extern void TTFLoadBitmaps(FILE *ttf,struct ttfinfo *info, int onlyone);
2390 enum ttfflags { ttf_onlystrikes=1, ttf_onlyonestrike=2, ttf_onlykerns=4, ttf_onlynames=8 };
2391 extern SplineFont *_SFReadTTF(FILE *ttf,int flags,enum openflags openflags,
2392 char *filename,struct fontdict *fd);
2393 extern SplineFont *SFReadTTF(char *filename,int flags,enum openflags openflags);
2394 extern SplineFont *SFReadSVG(char *filename,int flags);
2395 extern SplineFont *SFReadUFO(char *filename,int flags);
2396 extern SplineFont *_CFFParse(FILE *temp,int len,char *fontsetname);
2397 extern SplineFont *CFFParse(char *filename);
2398 extern SplineFont *SFReadMacBinary(char *filename,int flags,enum openflags openflags);
2399 extern SplineFont *SFReadWinFON(char *filename,int toback);
2400 extern SplineFont *SFReadPalmPdb(char *filename,int toback);
2401 extern SplineFont *LoadSplineFont(char *filename,enum openflags);
2402 extern SplineFont *_ReadSplineFont(FILE *file,char *filename, enum openflags openflags);
2403 extern SplineFont *ReadSplineFont(char *filename,enum openflags); /* Don't use this, use LoadSF instead */
2404 extern FILE *URLToTempFile(char *url,void *lock);
2405 extern int URLFromFile(char *url,FILE *from);
2406 extern int HttpGetBuf(char *url, char *databuf, int *datalen, void *mutex);
2407 extern void ArchiveCleanup(char *archivedir);
2408 extern char *Unarchive(char *name, char **_archivedir);
2409 extern char *Decompress(char *name, int compression);
2410 extern SplineFont *SFFromBDF(char *filename,int ispk,int toback);
2411 extern SplineFont *SFFromMF(char *filename);
2412 extern void SFCheckPSBitmap(SplineFont *sf);
2413 extern uint16 _MacStyleCode( char *styles, SplineFont *sf, uint16 *psstyle );
2414 extern uint16 MacStyleCode( SplineFont *sf, uint16 *psstyle );
2415 extern SplineFont *SFReadIkarus(char *fontname);
2416 extern SplineFont *_SFReadPdfFont(FILE *ttf,char *filename,char *select_this_font, enum openflags openflags);
2417 extern SplineFont *SFReadPdfFont(char *filename, enum openflags openflags);
2418 extern char **GetFontNames(char *filename);
2419 extern char **NamesReadSFD(char *filename);
2420 extern char **NamesReadTTF(char *filename);
2421 extern char **NamesReadCFF(char *filename);
2422 extern char **NamesReadPostscript(char *filename);
2423 extern char **_NamesReadPostscript(FILE *ps);
2424 extern char **NamesReadSVG(char *filename);
2425 extern char **NamesReadUFO(char *filename);
2426 extern char **NamesReadMacBinary(char *filename);
2428 extern void SFSetOrder(SplineFont *sf,int order2);
2429 extern int SFFindOrder(SplineFont *sf);
2431 extern const char *UnicodeRange(int unienc);
2432 extern SplineChar *SCBuildDummy(SplineChar *dummy,SplineFont *sf,EncMap *map,int i);
2433 extern SplineChar *SFMakeChar(SplineFont *sf,EncMap *map,int i);
2434 extern char *AdobeLigatureFormat(char *name);
2435 extern uint32 LigTagFromUnicode(int uni);
2436 extern void SCLigCaretheck(SplineChar *sc,int clean);
2437 extern BDFChar *BDFMakeGID(BDFFont *bdf,int gid);
2438 extern BDFChar *BDFMakeChar(BDFFont *bdf,EncMap *map,int enc);
2440 extern RefChar *RefCharsCopyState(SplineChar *sc,int layer);
2441 extern int SCWasEmpty(SplineChar *sc, int skip_this_layer);
2442 extern void SCUndoSetLBearingChange(SplineChar *sc,int lb);
2443 extern Undoes *SCPreserveHints(SplineChar *sc,int layer);
2444 extern Undoes *SCPreserveLayer(SplineChar *sc,int layer,int dohints);
2445 extern Undoes *SCPreserveState(SplineChar *sc,int dohints);
2446 extern Undoes *SCPreserveBackground(SplineChar *sc);
2447 extern Undoes *SFPreserveGuide(SplineFont *sf);
2448 extern Undoes *SCPreserveWidth(SplineChar *sc);
2449 extern Undoes *SCPreserveVWidth(SplineChar *sc);
2450 extern Undoes *BCPreserveState(BDFChar *bc);
2451 extern void BCDoRedo(BDFChar *bc);
2452 extern void BCDoUndo(BDFChar *bc);
2454 extern int isaccent(int uni);
2455 extern int SFIsCompositBuildable(SplineFont *sf,int unicodeenc,SplineChar *sc, int layer);
2456 extern int SFIsSomethingBuildable(SplineFont *sf,SplineChar *sc, int layer,int onlyaccents);
2457 extern int SFIsRotatable(SplineFont *sf,SplineChar *sc, int layer);
2458 extern int SCMakeDotless(SplineFont *sf, SplineChar *dotless, int layer, int copybmp, int doit);
2459 extern void SCBuildComposit(SplineFont *sf, SplineChar *sc, int layer, int copybmp);
2460 extern int SCAppendAccent(SplineChar *sc,int layer, char *glyph_name,int uni,int pos);
2461 extern const unichar_t *SFGetAlternate(SplineFont *sf, int base,SplineChar *sc,int nocheck);
2463 extern int getAdobeEnc(char *name);
2465 extern void SFSplinesFromLayers(SplineFont *sf,int tostroke);
2466 extern void SFSetLayerWidthsStroked(SplineFont *sf, real strokewidth);
2467 extern SplineSet *SplinePointListInterpretSVG(char *filename,char *memory, int memlen, int em_size, int ascent,int stroked);
2468 extern SplineSet *SplinePointListInterpretGlif(char *filename,char *memory, int memlen, int em_size, int ascent,int stroked);
2469 #define UNDEFINED_WIDTH -999999
2470 extern SplinePointList *SplinePointListInterpretPS(FILE *ps,int flags,int stroked,int *width);
2471 extern void PSFontInterpretPS(FILE *ps,struct charprocs *cp,char **encoding);
2472 extern struct enc *PSSlurpEncodings(FILE *file);
2473 extern int EvaluatePS(char *str,real *stack,int size);
2474 struct pscontext {
2475 int is_type2;
2476 int painttype;
2477 int instance_count;
2478 real blend_values[17];
2479 int blend_warn;
2481 extern int UnblendedCompare(real u1[MmMax], real u2[MmMax], int cnt);
2482 extern SplineChar *PSCharStringToSplines(uint8 *type1, int len, struct pscontext *context,
2483 struct pschars *subrs, struct pschars *gsubrs, const char *name);
2484 extern SplineChar *PSCharStringToBB(uint8 *type1, int len, struct pscontext *context,
2485 struct pschars *subrs, struct pschars *gsubrs, const char *name);
2486 extern void MatMultiply(real m1[6], real m2[6], real to[6]);
2488 extern int NameToEncoding(SplineFont *sf,EncMap *map,const char *uname);
2489 extern void GlyphHashFree(SplineFont *sf);
2490 extern void SFHashGlyph(SplineFont *sf,SplineChar *sc);
2491 extern SplineChar *SFHashName(SplineFont *sf,const char *name);
2492 extern int SFFindGID(SplineFont *sf, int unienc, const char *name );
2493 extern int SFFindSlot(SplineFont *sf, EncMap *map, int unienc, const char *name );
2494 extern int SFCIDFindCID(SplineFont *sf, int unienc, const char *name );
2495 extern SplineChar *SFGetChar(SplineFont *sf, int unienc, const char *name );
2496 extern int SFHasChar(SplineFont *sf, int unienc, const char *name );
2497 extern SplineChar *SFGetOrMakeChar(SplineFont *sf, int unienc, const char *name );
2498 extern int SFFindExistingSlot(SplineFont *sf, int unienc, const char *name );
2499 extern int SFCIDFindExistingChar(SplineFont *sf, int unienc, const char *name );
2500 extern int SFHasCID(SplineFont *sf, int cid);
2502 extern char *getPfaEditDir(char *buffer);
2503 extern void _DoAutoSaves(struct fontviewbase *);
2504 extern void CleanAutoRecovery(void);
2505 extern int DoAutoRecovery(int);
2506 extern SplineFont *SFRecoverFile(char *autosavename,int inquire, int *state);
2507 extern void SFAutoSave(SplineFont *sf,EncMap *map);
2508 extern void SFClearAutoSave(SplineFont *sf);
2510 extern void PSCharsFree(struct pschars *chrs);
2511 extern void PSDictFree(struct psdict *chrs);
2512 extern struct psdict *PSDictCopy(struct psdict *dict);
2513 extern int PSDictFindEntry(struct psdict *dict, char *key);
2514 extern char *PSDictHasEntry(struct psdict *dict, char *key);
2515 extern int PSDictRemoveEntry(struct psdict *dict, char *key);
2516 extern int PSDictChangeEntry(struct psdict *dict, char *key, char *newval);
2517 extern int SFPrivateGuess(SplineFont *sf,int layer, struct psdict *private,
2518 char *name, int onlyone);
2520 extern void SFRemoveLayer(SplineFont *sf,int l);
2521 extern void SFAddLayer(SplineFont *sf,char *name,int order2, int background);
2522 extern void SFLayerSetBackground(SplineFont *sf,int layer,int is_back);
2524 extern void SplineSetsRound2Int(SplineSet *spl,real factor,int inspiro,int onlysel);
2525 extern void SCRound2Int(SplineChar *sc,int layer, real factor);
2526 extern int SCRoundToCluster(SplineChar *sc,int layer,int sel,double within,double max);
2527 extern int SplineSetsRemoveAnnoyingExtrema(SplineSet *ss,double err);
2528 extern int hascomposing(SplineFont *sf,int u,SplineChar *sc);
2529 #if 0
2530 extern void SFFigureGrid(SplineFont *sf);
2531 #endif
2533 struct cidmap; /* private structure to encoding.c */
2534 extern int CIDFromName(char *name,SplineFont *cidmaster);
2535 extern int CID2Uni(struct cidmap *map,int cid);
2536 extern int CID2NameUni(struct cidmap *map,int cid, char *buffer, int len);
2537 extern int NameUni2CID(struct cidmap *map,int uni, const char *name);
2538 extern int MaxCID(struct cidmap *map);
2539 extern struct cidmap *FindCidMap(char *registry,char *ordering,int supplement,
2540 SplineFont *sf);
2541 extern void SFEncodeToMap(SplineFont *sf,struct cidmap *map);
2542 extern SplineFont *CIDFlatten(SplineFont *cidmaster,SplineChar **chars,int charcnt);
2543 extern void SFFlatten(SplineFont *cidmaster);
2544 extern int SFFlattenByCMap(SplineFont *sf,char *cmapname);
2545 extern SplineFont *MakeCIDMaster(SplineFont *sf,EncMap *oldmap,int bycmap,char *cmapfilename,struct cidmap *cidmap);
2547 int getushort(FILE *ttf);
2548 int32 getlong(FILE *ttf);
2549 int get3byte(FILE *ttf);
2550 real getfixed(FILE *ttf);
2551 real get2dot14(FILE *ttf);
2552 void putshort(FILE *file,int sval);
2553 void putlong(FILE *file,int val);
2554 void putfixed(FILE *file,real dval);
2555 int ttfcopyfile(FILE *ttf, FILE *other, int pos, char *table_name);
2557 extern void SCCopyLayerToLayer(SplineChar *sc, int from, int to,int doclear);
2559 extern int hasFreeType(void);
2560 extern int hasFreeTypeDebugger(void);
2561 extern int hasFreeTypeByteCode(void);
2562 extern int FreeTypeAtLeast(int major, int minor, int patch);
2563 extern void doneFreeType(void);
2564 extern void *_FreeTypeFontContext(SplineFont *sf,SplineChar *sc,struct fontviewbase *fv,
2565 int layer, enum fontformat ff,int flags,void *shared_ftc);
2566 extern void *FreeTypeFontContext(SplineFont *sf,SplineChar *sc,struct fontviewbase *fv,int layer);
2567 extern BDFFont *SplineFontFreeTypeRasterize(void *freetypecontext,int pixelsize,int depth);
2568 extern BDFChar *SplineCharFreeTypeRasterize(void *freetypecontext,int gid,
2569 int pixelsize,int depth);
2570 extern void FreeTypeFreeContext(void *freetypecontext);
2571 extern SplineSet *FreeType_GridFitChar(void *single_glyph_context,
2572 int enc, real ptsizey, real ptsizex, int dpi, uint16 *width, SplineChar *sc, int depth);
2573 extern struct freetype_raster *FreeType_GetRaster(void *single_glyph_context,
2574 int enc, real ptsizey, real ptsizex, int dpi,int depth);
2575 extern BDFChar *SplineCharFreeTypeRasterizeNoHints(SplineChar *sc,int layer,
2576 int pixelsize,int depth);
2577 extern BDFFont *SplineFontFreeTypeRasterizeNoHints(SplineFont *sf,int layer,
2578 int pixelsize,int depth);
2579 extern void FreeType_FreeRaster(struct freetype_raster *raster);
2580 struct TT_ExecContextRec_;
2581 extern struct freetype_raster *DebuggerCurrentRaster(struct TT_ExecContextRec_ *exc,int depth);
2583 extern int UniFromName(const char *name,enum uni_interp interp, Encoding *encname);
2584 extern const char *StdGlyphName(char *buffer, int uni, enum uni_interp interp, NameList *for_this_font);
2585 extern char **AllGlyphNames(int uni, NameList *for_this_font,SplineChar *sc/* May be NULL*/);
2586 extern char **AllNamelistNames(void);
2587 extern NameList *DefaultNameListForNewFonts(void);
2588 extern NameList *NameListByName(char *name);
2589 extern NameList *LoadNamelist(char *filename);
2590 extern void LoadNamelistDir(char *dir);
2591 extern const char *RenameGlyphToNamelist(char *buffer, SplineChar *sc,NameList *old,NameList *new);
2592 extern void SFRenameGlyphsToNamelist(SplineFont *sf,NameList *new);
2593 extern char **SFTemporaryRenameGlyphsToNamelist(SplineFont *sf,NameList *new);
2594 extern void SFTemporaryRestoreGlyphNames(SplineFont *sf,char **former);
2596 extern void doversion(const char *);
2598 extern AnchorPos *AnchorPositioning(SplineChar *sc,unichar_t *ustr,SplineChar **sstr );
2599 extern void AnchorPosFree(AnchorPos *apos);
2601 extern int SF_CloseAllInstrs(SplineFont *sf);
2602 extern int SSTtfNumberPoints(SplineSet *ss);
2603 extern int SCNumberPoints(SplineChar *sc,int layer);
2604 extern int SCPointsNumberedProperly(SplineChar *sc,int layer);
2605 extern int ttfFindPointInSC(SplineChar *sc,int layer,int pnum,BasePoint *pos,
2606 RefChar *bound);
2608 int SFFigureDefWidth(SplineFont *sf, int *_nomwid);
2610 extern int SFRenameTheseFeatureTags(SplineFont *sf, uint32 tag, int sli, int flags,
2611 uint32 totag, int tosli, int toflags, int ismac);
2612 extern int SFRemoveUnusedNestedFeatures(SplineFont *sf);
2614 extern char *utf8_verify_copy(const char *str);
2616 extern char *MacStrToUtf8(const char *str,int macenc,int maclang);
2617 extern char *Utf8ToMacStr(const char *ustr,int macenc,int maclang);
2618 extern uint8 MacEncFromMacLang(int maclang);
2619 extern uint16 WinLangFromMac(int maclang);
2620 extern uint16 WinLangToMac(int winlang);
2621 extern int CanEncodingWinLangAsMac(int winlang);
2622 extern const int32 *MacEncToUnicode(int script,int lang);
2623 extern int MacLangFromLocale(void);
2624 extern char *MacLanguageFromCode(int code);
2626 extern int32 UniFromEnc(int enc, Encoding *encname);
2627 extern int32 EncFromUni(int32 uni, Encoding *encname);
2628 extern int32 EncFromName(const char *name,enum uni_interp interp,Encoding *encname);
2630 extern void MatInverse(real into[6], real orig[6]);
2632 extern int BpColinear(BasePoint *first, BasePoint *mid, BasePoint *last);
2634 enum psstrokeflags { sf_toobigwarn=1, sf_removeoverlap=2, sf_handle_eraser=4,
2635 sf_correctdir=8, sf_clearbeforeinput=16 };
2637 extern char *MMAxisAbrev(char *axis_name);
2638 extern char *MMMakeMasterFontname(MMSet *mm,int ipos,char **fullname);
2639 extern char *MMGuessWeight(MMSet *mm,int ipos,char *def);
2640 extern char *MMExtractNth(char *pt,int ipos);
2641 extern char *MMExtractArrayNth(char *pt,int ipos);
2642 extern int MMValid(MMSet *mm,int complain);
2643 extern void MMKern(SplineFont *sf,SplineChar *first,SplineChar *second,int diff,
2644 struct lookup_subtable *sub,KernPair *oldkp);
2645 extern char *MMBlendChar(MMSet *mm, int gid);
2647 extern char *EnforcePostScriptName(char *old);
2649 extern char *ToAbsolute(char *filename);
2651 enum Compare_Ret { SS_DiffContourCount = 1,
2652 SS_MismatchOpenClosed = 2,
2653 SS_DisorderedContours = 4,
2654 SS_DisorderedStart = 8,
2655 SS_DisorderedDirection = 16,
2656 SS_PointsMatch = 32,
2657 SS_ContourMatch = 64,
2658 SS_NoMatch = 128,
2659 SS_RefMismatch = 256,
2660 SS_WidthMismatch = 512,
2661 SS_VWidthMismatch = 1024,
2662 SS_HintMismatch = 2048,
2663 SS_HintMaskMismatch = 4096,
2664 SS_LayerCntMismatch = 8192,
2665 SS_ContourMismatch = 16384,
2666 SS_UnlinkRefMatch = 32768,
2668 BC_DepthMismatch = 1<<16,
2669 BC_BoundingBoxMismatch = 2<<16,
2670 BC_BitmapMismatch = 4<<16,
2671 BC_NoMatch = 8<<16,
2672 BC_Match = 16<<16,
2674 SS_RefPtMismatch = 32<<16
2677 extern enum Compare_Ret BitmapCompare(BDFChar *bc1, BDFChar *bc2, int err, int bb_err);
2678 extern enum Compare_Ret SSsCompare(const SplineSet *ss1, const SplineSet *ss2,
2679 real pt_err, real spline_err, SplinePoint **hmfail);
2680 enum font_compare_flags { fcf_outlines=1, fcf_exact=2, fcf_warn_not_exact=4,
2681 fcf_hinting=8, fcf_hintmasks=0x10, fcf_hmonlywithconflicts=0x20,
2682 fcf_warn_not_ref_exact=0x40,
2683 fcf_bitmaps=0x80, fcf_names = 0x100, fcf_gpos=0x200, fcf_gsub=0x400,
2684 fcf_adddiff2sf1=0x800, fcf_addmissing=0x1000 };
2685 extern int CompareFonts(SplineFont *sf1, EncMap *map1, SplineFont *sf2,
2686 FILE *diffs, int flags);
2687 extern int LayersSimilar(Layer *ly1, Layer *ly2, double spline_err);
2690 # if HANYANG
2691 extern void SFDDumpCompositionRules(FILE *sfd,struct compositionrules *rules);
2692 extern struct compositionrules *SFDReadCompositionRules(FILE *sfd);
2693 extern void SFModifyComposition(SplineFont *sf);
2694 extern void SFBuildSyllables(SplineFont *sf);
2695 # endif
2697 extern void DefaultOtherSubrs(void);
2698 extern int ReadOtherSubrsFile(char *filename);
2700 extern char *utf8toutf7_copy(const char *_str);
2701 extern char *utf7toutf8_copy(const char *_str);
2703 extern void SFSetModTime(SplineFont *sf);
2704 extern void SFTimesFromFile(SplineFont *sf,FILE *);
2706 extern int SFHasInstructions(SplineFont *sf);
2707 extern int RefDepth(RefChar *ref,int layer);
2709 extern SplineChar *SCHasSubs(SplineChar *sc,uint32 tag);
2711 extern char *TagFullName(SplineFont *sf,uint32 tag, int onlyifknown);
2713 extern uint32 *SFScriptsInLookups(SplineFont *sf,int gpos);
2714 extern uint32 *SFLangsInScript(SplineFont *sf,int gpos,uint32 script);
2715 extern uint32 *SFFeaturesInScriptLang(SplineFont *sf,int gpos,uint32 script,uint32 lang);
2716 extern OTLookup **SFLookupsInScriptLangFeature(SplineFont *sf,int gpos,uint32 script,uint32 lang, uint32 feature);
2717 extern SplineChar **SFGlyphsWithPSTinSubtable(SplineFont *sf,struct lookup_subtable *subtable);
2718 extern SplineChar **SFGlyphsWithLigatureinLookup(SplineFont *sf,struct lookup_subtable *subtable);
2719 extern void SFFindUnusedLookups(SplineFont *sf);
2720 extern void SFFindClearUnusedLookupBits(SplineFont *sf);
2721 extern int LookupUsedNested(SplineFont *sf,OTLookup *checkme);
2722 extern void SFRemoveUnusedLookupSubTables(SplineFont *sf,
2723 int remove_incomplete_anchorclasses,
2724 int remove_unused_lookups);
2725 extern void SFRemoveLookupSubTable(SplineFont *sf,struct lookup_subtable *sub);
2726 extern void SFRemoveLookup(SplineFont *sf,OTLookup *otl);
2727 extern struct lookup_subtable *SFFindLookupSubtable(SplineFont *sf,char *name);
2728 extern struct lookup_subtable *SFFindLookupSubtableAndFreeName(SplineFont *sf,char *name);
2729 extern OTLookup *SFFindLookup(SplineFont *sf,char *name);
2730 extern void NameOTLookup(OTLookup *otl,SplineFont *sf);
2731 extern void FListAppendScriptLang(FeatureScriptLangList *fl,uint32 script_tag,uint32 lang_tag);
2732 extern void FListsAppendScriptLang(FeatureScriptLangList *fl,uint32 script_tag,uint32 lang_tag);
2733 struct scriptlanglist *SLCopy(struct scriptlanglist *sl);
2734 struct scriptlanglist *SListCopy(struct scriptlanglist *sl);
2735 extern FeatureScriptLangList *FeatureListCopy(FeatureScriptLangList *fl);
2736 extern void SLMerge(FeatureScriptLangList *into, struct scriptlanglist *fsl);
2737 extern void FLMerge(OTLookup *into, OTLookup *from);
2738 extern FeatureScriptLangList *FLOrder(FeatureScriptLangList *fl);
2739 extern int FeatureScriptTagInFeatureScriptList(uint32 tag, uint32 script, FeatureScriptLangList *fl);
2740 extern FeatureScriptLangList *FindFeatureTagInFeatureScriptList(uint32 tag, FeatureScriptLangList *fl);
2741 extern int FeatureTagInFeatureScriptList(uint32 tag, FeatureScriptLangList *fl);
2742 extern int DefaultLangTagInOneScriptList(struct scriptlanglist *sl);
2743 extern struct scriptlanglist *DefaultLangTagInScriptList(struct scriptlanglist *sl, int DFLT_ok);
2744 extern int ScriptInFeatureScriptList(uint32 script, FeatureScriptLangList *fl);
2745 extern int _FeatureOrderId( int isgpos,uint32 tag );
2746 extern int FeatureOrderId( int isgpos,FeatureScriptLangList *fl );
2747 extern void SFSubTablesMerge(SplineFont *_sf,struct lookup_subtable *subfirst,
2748 struct lookup_subtable *subsecond);
2749 extern struct lookup_subtable *SFSubTableFindOrMake(SplineFont *sf,uint32 tag,uint32 script,
2750 int lookup_type );
2751 extern struct lookup_subtable *SFSubTableMake(SplineFont *sf,uint32 tag,uint32 script,
2752 int lookup_type );
2753 extern OTLookup *OTLookupCopyInto(SplineFont *into_sf,SplineFont *from_sf, OTLookup *from_otl);
2754 extern void OTLookupsCopyInto(SplineFont *into_sf,SplineFont *from_sf,
2755 OTLookup **from_list, OTLookup *before);
2756 extern struct opentype_str *ApplyTickedFeatures(SplineFont *sf,uint32 *flist, uint32 script, uint32 lang,
2757 int pixelsize, SplineChar **glyphs);
2758 extern int VerticalKernFeature(SplineFont *sf, OTLookup *otl, int ask);
2760 struct sllk { uint32 script; int cnt, max; OTLookup **lookups; int lcnt, lmax; uint32 *langs; };
2761 extern void SllkFree(struct sllk *sllk,int sllk_cnt);
2762 extern struct sllk *AddOTLToSllks( OTLookup *otl, struct sllk *sllk,
2763 int *_sllk_cnt, int *_sllk_max );
2764 extern OTLookup *NewAALTLookup(SplineFont *sf,struct sllk *sllk, int sllk_cnt, int i);
2765 extern void AddNewAALTFeatures(SplineFont *sf);
2767 extern void SplinePointRound(SplinePoint *,real);
2769 extern int KCFindName(char *name, char **classnames, int cnt );
2770 extern int KCFindIndex(KernClass *kc,char *name1, char *name2);
2771 extern KernClass *SFFindKernClass(SplineFont *sf,SplineChar *first,SplineChar *last,
2772 int *index,int allow_zero);
2773 extern KernClass *SFFindVKernClass(SplineFont *sf,SplineChar *first,SplineChar *last,
2774 int *index,int allow_zero);
2776 extern void SCClearRounds(SplineChar *sc,int layer);
2777 extern void MDReplace(MinimumDistance *md,SplineSet *old,SplineSet *rpl);
2778 extern void SCSynchronizeWidth(SplineChar *sc,real newwidth, real oldwidth,struct fontviewbase *fv);
2779 extern RefChar *HasUseMyMetrics(SplineChar *sc,int layer);
2780 extern void SCSynchronizeLBearing(SplineChar *sc,real off,int layer);
2781 extern void RevertedGlyphReferenceFixup(SplineChar *sc, SplineFont *sf);
2783 extern void SFUntickAll(SplineFont *sf);
2785 extern void BDFOrigFixup(BDFFont *bdf,int orig_cnt,SplineFont *sf);
2787 extern int HasSVG(void);
2788 extern void SCImportSVG(SplineChar *sc,int layer,char *path,char *memory, int memlen,int doclear);
2789 extern int HasUFO(void);
2790 extern void SCImportGlif(SplineChar *sc,int layer,char *path,char *memory, int memlen,int doclear);
2791 extern void SCImportPS(SplineChar *sc,int layer,char *path,int doclear, int flags);
2792 extern void SCImportPSFile(SplineChar *sc,int layer,FILE *ps,int doclear,int flags);
2793 extern void SCImportPDF(SplineChar *sc,int layer,char *path,int doclear, int flags);
2794 extern void SCImportPDFFile(SplineChar *sc,int layer,FILE *ps,int doclear,int flags);
2795 extern void SCImportPlateFile(SplineChar *sc,int layer,FILE *plate,int doclear,int flags);
2796 extern void SCAddScaleImage(SplineChar *sc,struct gimage *image,int doclear,int layer);
2797 extern void SCInsertImage(SplineChar *sc,struct gimage *image,real scale,real yoff, real xoff, int layer);
2798 extern void SCImportFig(SplineChar *sc,int layer,char *path,int doclear);
2800 extern int _ExportPlate(FILE *pdf,SplineChar *sc,int layer);
2801 extern int _ExportPDF(FILE *pdf,SplineChar *sc,int layer);
2802 extern int _ExportEPS(FILE *eps,SplineChar *sc,int layer, int gen_preview);
2803 extern int _ExportSVG(FILE *svg,SplineChar *sc,int layer);
2804 extern int _ExportGlif(FILE *glif,SplineChar *sc,int layer);
2805 extern int ExportEPS(char *filename,SplineChar *sc,int layer);
2806 extern int ExportPDF(char *filename,SplineChar *sc,int layer);
2807 extern int ExportPlate(char *filename,SplineChar *sc,int layer);
2808 extern int ExportSVG(char *filename,SplineChar *sc,int layer);
2809 extern int ExportGlif(char *filename,SplineChar *sc,int layer);
2810 extern int ExportFig(char *filename,SplineChar *sc,int layer);
2811 extern int BCExportXBM(char *filename,BDFChar *bdfc, int format);
2812 extern int ExportImage(char *filename,SplineChar *sc, int layer, int format, int pixelsize, int bitsperpixel);
2813 extern void ScriptExport(SplineFont *sf, BDFFont *bdf, int format, int gid,
2814 char *format_spec, EncMap *map);
2816 extern EncMap *EncMapFromEncoding(SplineFont *sf,Encoding *enc);
2817 extern void SFRemoveGlyph(SplineFont *sf,SplineChar *sc, int *flags);
2818 extern void SFAddEncodingSlot(SplineFont *sf,int gid);
2819 extern void SFAddGlyphAndEncode(SplineFont *sf,SplineChar *sc,EncMap *basemap, int baseenc);
2820 extern void SCDoRedo(SplineChar *sc,int layer);
2821 extern void SCDoUndo(SplineChar *sc,int layer);
2822 extern void SCCopyWidth(SplineChar *sc,enum undotype);
2823 extern void SCAppendPosSub(SplineChar *sc,enum possub_type type, char **d,SplineFont *copied_from);
2824 extern void SCClearBackground(SplineChar *sc);
2825 extern void BackgroundImageTransform(SplineChar *sc, ImageList *img,real transform[6]);
2826 extern int SFIsDuplicatable(SplineFont *sf, SplineChar *sc);
2828 extern void DoAutoSaves(void);
2830 extern void SCClearLayer(SplineChar *sc,int layer);
2831 extern void SCClearContents(SplineChar *sc,int layer);
2832 extern void SCClearAll(SplineChar *sc,int layer);
2833 extern void BCClearAll(BDFChar *bc);
2835 #if !defined(_NO_PYTHON)
2836 extern void FontForge_PythonInit(void);
2837 extern void PyFF_ErrorString(const char *msg,const char *str);
2838 extern void PyFF_ErrorF3(const char *frmt, const char *str, int size, int depth);
2839 extern void PyFF_Stdin(void);
2840 extern void PyFF_Main(int argc,char **argv,int start);
2841 extern void PyFF_ScriptFile(struct fontviewbase *fv,SplineChar *sc,char *filename);
2842 extern void PyFF_ScriptString(struct fontviewbase *fv,SplineChar *sc,int layer,char *str);
2843 extern void PyFF_FreeFV(struct fontviewbase *fv);
2844 extern void PyFF_FreeSC(SplineChar *sc);
2845 extern void PyFF_FreeSF(SplineFont *sf);
2846 extern void PyFF_ProcessInitFiles(void);
2847 extern char *PyFF_PickleMeToString(void *pydata);
2848 extern void *PyFF_UnPickleMeToObjects(char *str);
2849 struct _object; /* Python Object */
2850 extern void PyFF_CallDictFunc(struct _object *dict,char *key,char *argtypes, ... );
2851 extern void ff_init(void);
2852 #endif
2853 extern void doinitFontForgeMain(void);
2855 extern void InitSimpleStuff(void);
2857 extern int SSExistsInLayer(SplineSet *ss,SplineSet *lots );
2858 extern int SplineExistsInSS(Spline *s,SplineSet *ss);
2859 extern int SpExistsInSS(SplinePoint *sp,SplineSet *ss);
2861 extern int MSLanguageFromLocale(void);
2863 extern struct math_constants_descriptor {
2864 char *ui_name;
2865 char *script_name;
2866 int offset;
2867 int devtab_offset;
2868 char *message;
2869 int new_page;
2870 } math_constants_descriptor[];
2872 extern int BPTooFar(BasePoint *bp1, BasePoint *bp2);
2873 extern char *VSErrorsFromMask(int mask,int private_mask);
2874 extern int SCValidate(SplineChar *sc, int layer, int force);
2875 extern AnchorClass *SCValidateAnchors(SplineChar *sc);
2876 extern void SCTickValidationState(SplineChar *sc,int layer);
2877 extern int ValidatePrivate(SplineFont *sf);
2878 extern int SFValidate(SplineFont *sf, int layer, int force);
2879 extern int VSMaskFromFormat(SplineFont *sf, int layer, enum fontformat format);
2881 struct lang_frequencies;
2882 extern unichar_t *PrtBuildDef( SplineFont *sf, void *tf,
2883 void (*langsyscallback)(void *tf, int end, uint32 script, uint32 lang) );
2884 extern char *RandomParaFromScriptLang(uint32 script, uint32 lang, SplineFont *sf,
2885 struct lang_frequencies *freq);
2886 extern char *RandomParaFromScript(uint32 script, uint32 *lang, SplineFont *sf);
2887 extern int SF2Scripts(SplineFont *sf,uint32 scripts[100]);
2888 extern char **SFScriptLangs(SplineFont *sf,struct lang_frequencies ***freq);
2890 extern int SSHasClip(SplineSet *ss);
2891 extern int SSHasDrawn(SplineSet *ss);
2892 extern struct gradient *GradientCopy(struct gradient *old);
2893 extern void GradientFree(struct gradient *grad);
2894 extern struct pattern *PatternCopy(struct pattern *old);
2895 extern void PatternFree(struct pattern *pat);
2896 extern void BrushCopy(struct brush *into, struct brush *from);
2897 extern void PenCopy(struct pen *into, struct pen *from);
2898 extern void PatternSCBounds(SplineChar *sc,DBounds *b);
2900 extern char *SFDefaultImage(SplineFont *sf,char *filename);
2901 extern void SCClearInstrsOrMark(SplineChar *sc, int layer, int complain);
2902 extern void instrcheck(SplineChar *sc,int layer);
2903 extern void TTFPointMatches(SplineChar *sc,int layer,int top);
2905 #ifdef LUA_FF_LIB
2906 extern SplineFont *ReadSplineFontInfo(char *filename,enum openflags openflags); /* splinefont.c */
2907 extern SplineFont *SFReadTTFInfo(char *filename, int flags, enum openflags openflags); /* parsettf.c */
2908 extern SplineFont *SFReadMacBinaryInfo(char *filename,int flags,enum openflags openflags); /* macbinary.c */
2909 #endif
2913 #endif