4 * Copyright (C) 2011-2012 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
;
29 error
= ta_loader_init(font
);
33 error
= FT_Select_Charmap(face
, FT_ENCODING_UNICODE
);
38 error
= FT_Select_Charmap(face
, FT_ENCODING_MS_SYMBOL
);
40 return TA_Err_Missing_Symbol_CMap
;
43 return TA_Err_Missing_Unicode_CMap
;
50 /* load glyph `o' to trigger all initializations */
51 /* XXX make this configurable for non-latin scripts */
52 /* XXX make this configurable to use a different letter */
53 idx
= FT_Get_Char_Index(face
, 'o');
55 return TA_Err_Missing_Glyph
;
58 load_flags
= 1 << 29; /* vertical hinting only */
59 error
= ta_loader_load_glyph(font
, face
, idx
, load_flags
);
66 TA_table_build_cvt(FT_Byte
** cvt
,
87 error
= TA_sfnt_compute_global_hints(sfnt
, font
);
91 if (font
->loader
->hints
.metrics
->clazz
->script
== TA_SCRIPT_NONE
)
102 haxis
= &((TA_LatinMetrics
)font
->loader
->hints
.metrics
)->axis
[0];
103 vaxis
= &((TA_LatinMetrics
)font
->loader
->hints
.metrics
)->axis
[1];
105 hwidth_count
= haxis
->width_count
;
106 vwidth_count
= vaxis
->width_count
;
107 blue_count
= vaxis
->blue_count
;
110 buf_len
= 2 * (cvtl_max_runtime
/* runtime values */
111 + 2 /* vertical and horizontal standard width */
116 /* buffer length must be a multiple of four */
117 len
= (buf_len
+ 3) & ~3;
118 buf
= (FT_Byte
*)malloc(len
);
120 return FT_Err_Out_Of_Memory
;
122 /* pad end of buffer with zeros */
129 /* some CVT values are initialized (and modified) at runtime; */
130 /* see the `cvtl_xxx' macros in tabytecode.h */
131 for (i
= 0; i
< cvtl_max_runtime
; i
++)
137 if (hwidth_count
> 0)
139 *(buf_p
++) = HIGH(haxis
->widths
[0].org
);
140 *(buf_p
++) = LOW(haxis
->widths
[0].org
);
147 if (vwidth_count
> 0)
149 *(buf_p
++) = HIGH(vaxis
->widths
[0].org
);
150 *(buf_p
++) = LOW(vaxis
->widths
[0].org
);
158 for (i
= 0; i
< hwidth_count
; i
++)
160 if (haxis
->widths
[i
].org
> 0xFFFF)
162 *(buf_p
++) = HIGH(haxis
->widths
[i
].org
);
163 *(buf_p
++) = LOW(haxis
->widths
[i
].org
);
166 for (i
= 0; i
< vwidth_count
; i
++)
168 if (vaxis
->widths
[i
].org
> 0xFFFF)
170 *(buf_p
++) = HIGH(vaxis
->widths
[i
].org
);
171 *(buf_p
++) = LOW(vaxis
->widths
[i
].org
);
174 for (i
= 0; i
< blue_count
; i
++)
176 if (vaxis
->blues
[i
].ref
.org
> 0xFFFF)
178 *(buf_p
++) = HIGH(vaxis
->blues
[i
].ref
.org
);
179 *(buf_p
++) = LOW(vaxis
->blues
[i
].ref
.org
);
182 for (i
= 0; i
< blue_count
; i
++)
184 if (vaxis
->blues
[i
].shoot
.org
> 0xFFFF)
186 *(buf_p
++) = HIGH(vaxis
->blues
[i
].shoot
.org
);
187 *(buf_p
++) = LOW(vaxis
->blues
[i
].shoot
.org
);
197 return TA_Err_Hinter_Overflow
;
202 TA_sfnt_build_cvt_table(SFNT
* sfnt
,
211 error
= TA_sfnt_add_table_info(sfnt
);
215 error
= TA_table_build_cvt(&cvt_buf
, &cvt_len
, sfnt
, font
);
219 /* in case of success, `cvt_buf' gets linked */
220 /* and is eventually freed in `TA_font_unload' */
221 error
= TA_font_add_table(font
,
222 &sfnt
->table_infos
[sfnt
->num_table_infos
- 1],
223 TTAG_cvt
, cvt_len
, cvt_buf
);