3 /* written 2011 by Werner Lemberg <wl@gnu.org> */
9 TA_sfnt_compute_global_hints(SFNT
* sfnt
,
13 FT_Face face
= sfnt
->face
;
17 static const FT_Encoding latin_encs
[] =
20 FT_ENCODING_APPLE_ROMAN
,
21 FT_ENCODING_ADOBE_STANDARD
,
22 FT_ENCODING_ADOBE_LATIN_1
,
24 FT_ENCODING_NONE
/* end of list */
28 error
= ta_loader_init(font
->loader
);
32 /* try to select a latin charmap */
33 for (enc
= 0; latin_encs
[enc
] != FT_ENCODING_NONE
; enc
++)
35 error
= FT_Select_Charmap(face
, latin_encs
[enc
]);
40 /* load latin glyph `a' to trigger all initializations */
41 idx
= FT_Get_Char_Index(face
, 'a');
42 error
= ta_loader_load_glyph(font
->loader
, face
, idx
, 0);
49 TA_table_build_cvt(FT_Byte
** cvt
,
66 error
= TA_sfnt_compute_global_hints(sfnt
, font
);
70 haxis
= &((TA_LatinMetrics
)font
->loader
->hints
.metrics
)->axis
[0];
71 vaxis
= &((TA_LatinMetrics
)font
->loader
->hints
.metrics
)->axis
[1];
76 + 2 * vaxis
->blue_count
);
78 /* buffer length must be a multiple of four */
79 len
= (buf_len
+ 3) & ~3;
80 buf
= (FT_Byte
*)malloc(len
);
82 return FT_Err_Out_Of_Memory
;
84 /* pad end of buffer with zeros */
91 if (haxis
->width_count
> 0)
93 *(buf_p
++) = HIGH(haxis
->widths
[0].org
);
94 *(buf_p
++) = LOW(haxis
->widths
[0].org
);
101 if (vaxis
->width_count
> 0)
103 *(buf_p
++) = HIGH(vaxis
->widths
[0].org
);
104 *(buf_p
++) = LOW(vaxis
->widths
[0].org
);
112 for (i
= 0; i
< haxis
->width_count
; i
++)
114 if (haxis
->widths
[i
].org
> 0xFFFF)
116 *(buf_p
++) = HIGH(haxis
->widths
[i
].org
);
117 *(buf_p
++) = LOW(haxis
->widths
[i
].org
);
120 for (i
= 0; i
< vaxis
->width_count
; i
++)
122 if (vaxis
->widths
[i
].org
> 0xFFFF)
124 *(buf_p
++) = HIGH(vaxis
->widths
[i
].org
);
125 *(buf_p
++) = LOW(vaxis
->widths
[i
].org
);
128 for (i
= 0; i
< vaxis
->blue_count
; i
++)
130 if (vaxis
->blues
[i
].ref
.org
> 0xFFFF)
132 *(buf_p
++) = HIGH(vaxis
->blues
[i
].ref
.org
);
133 *(buf_p
++) = LOW(vaxis
->blues
[i
].ref
.org
);
136 for (i
= 0; i
< vaxis
->blue_count
; i
++)
138 if (vaxis
->blues
[i
].shoot
.org
> 0xFFFF)
140 *(buf_p
++) = HIGH(vaxis
->blues
[i
].shoot
.org
);
141 *(buf_p
++) = LOW(vaxis
->blues
[i
].shoot
.org
);
145 TA_LOG(("--------------------------------------------------\n"));
146 TA_LOG(("glyph %d:\n", idx
));
147 ta_glyph_hints_dump_edges(_ta_debug_hints
);
148 ta_glyph_hints_dump_segments(_ta_debug_hints
);
149 ta_glyph_hints_dump_points(_ta_debug_hints
);
159 return TA_Err_Hinter_Overflow
;
164 TA_sfnt_build_cvt_table(SFNT
* sfnt
,
173 error
= TA_sfnt_add_table_info(sfnt
);
177 error
= TA_table_build_cvt(&cvt_buf
, &cvt_len
, sfnt
, font
);
181 /* in case of success, `cvt_buf' gets linked */
182 /* and is eventually freed in `TA_font_unload' */
183 error
= TA_font_add_table(font
,
184 &sfnt
->table_infos
[sfnt
->num_table_infos
- 1],
185 TTAG_cvt
, cvt_len
, cvt_buf
);