4 * Copyright (C) 2011 by Werner Lemberg.
6 * This file is part of the ttfautohint library, and may only be used,
7 * modified, and distributed under the terms given in `COPYING'. By
8 * continuing to use, modify, or distribute this file you indicate that you
9 * have read `COPYING' and understand and accept it fully.
11 * The file `COPYING' mentioned in the previous paragraph is distributed
12 * with the ttfautohint library.
20 TA_sfnt_compute_global_hints(SFNT
* sfnt
,
24 FT_Face face
= sfnt
->face
;
28 static const FT_Encoding latin_encs
[] =
31 FT_ENCODING_APPLE_ROMAN
,
32 FT_ENCODING_ADOBE_STANDARD
,
33 FT_ENCODING_ADOBE_LATIN_1
,
35 FT_ENCODING_NONE
/* end of list */
39 error
= ta_loader_init(font
->loader
);
43 /* try to select a latin charmap */
44 for (enc
= 0; latin_encs
[enc
] != FT_ENCODING_NONE
; enc
++)
46 error
= FT_Select_Charmap(face
, latin_encs
[enc
]);
51 /* load latin glyph `a' to trigger all initializations */
52 idx
= FT_Get_Char_Index(face
, 'a');
53 error
= ta_loader_load_glyph(font
->loader
, face
, idx
,
54 font
->fallback_script
<< 30);
61 TA_table_build_cvt(FT_Byte
** cvt
,
78 error
= TA_sfnt_compute_global_hints(sfnt
, font
);
82 haxis
= &((TA_LatinMetrics
)font
->loader
->hints
.metrics
)->axis
[0];
83 vaxis
= &((TA_LatinMetrics
)font
->loader
->hints
.metrics
)->axis
[1];
85 buf_len
= 2 * (cvtl_max_runtime
/* runtime values */
86 + 2 /* vertical and horizontal standard width */
89 + 2 * vaxis
->blue_count
);
91 /* buffer length must be a multiple of four */
92 len
= (buf_len
+ 3) & ~3;
93 buf
= (FT_Byte
*)malloc(len
);
95 return FT_Err_Out_Of_Memory
;
97 /* pad end of buffer with zeros */
104 /* some CVT values are initialized (and modified) at runtime; */
105 /* see the `cvtl_xxx' macros in tabytecode.h */
106 for (i
= 0; i
< cvtl_max_runtime
; i
++)
112 if (haxis
->width_count
> 0)
114 *(buf_p
++) = HIGH(haxis
->widths
[0].org
);
115 *(buf_p
++) = LOW(haxis
->widths
[0].org
);
122 if (vaxis
->width_count
> 0)
124 *(buf_p
++) = HIGH(vaxis
->widths
[0].org
);
125 *(buf_p
++) = LOW(vaxis
->widths
[0].org
);
133 for (i
= 0; i
< haxis
->width_count
; i
++)
135 if (haxis
->widths
[i
].org
> 0xFFFF)
137 *(buf_p
++) = HIGH(haxis
->widths
[i
].org
);
138 *(buf_p
++) = LOW(haxis
->widths
[i
].org
);
141 for (i
= 0; i
< vaxis
->width_count
; i
++)
143 if (vaxis
->widths
[i
].org
> 0xFFFF)
145 *(buf_p
++) = HIGH(vaxis
->widths
[i
].org
);
146 *(buf_p
++) = LOW(vaxis
->widths
[i
].org
);
149 for (i
= 0; i
< vaxis
->blue_count
; i
++)
151 if (vaxis
->blues
[i
].ref
.org
> 0xFFFF)
153 *(buf_p
++) = HIGH(vaxis
->blues
[i
].ref
.org
);
154 *(buf_p
++) = LOW(vaxis
->blues
[i
].ref
.org
);
157 for (i
= 0; i
< vaxis
->blue_count
; i
++)
159 if (vaxis
->blues
[i
].shoot
.org
> 0xFFFF)
161 *(buf_p
++) = HIGH(vaxis
->blues
[i
].shoot
.org
);
162 *(buf_p
++) = LOW(vaxis
->blues
[i
].shoot
.org
);
166 TA_LOG(("--------------------------------------------------\n"));
167 TA_LOG(("glyph %d:\n", idx
));
168 ta_glyph_hints_dump_edges(_ta_debug_hints
);
169 ta_glyph_hints_dump_segments(_ta_debug_hints
);
170 ta_glyph_hints_dump_points(_ta_debug_hints
);
180 return TA_Err_Hinter_Overflow
;
185 TA_sfnt_build_cvt_table(SFNT
* sfnt
,
194 error
= TA_sfnt_add_table_info(sfnt
);
198 error
= TA_table_build_cvt(&cvt_buf
, &cvt_len
, sfnt
, font
);
202 /* in case of success, `cvt_buf' gets linked */
203 /* and is eventually freed in `TA_font_unload' */
204 error
= TA_font_add_table(font
,
205 &sfnt
->table_infos
[sfnt
->num_table_infos
- 1],
206 TTAG_cvt
, cvt_len
, cvt_buf
);