3 // Copyright (C) 2012 by Werner Lemberg.
5 // This file is part of the ttfautohint library, and may only be used,
6 // modified, and distributed under the terms given in `COPYING'. By
7 // continuing to use, modify, or distribute this file you indicate that you
8 // have read `COPYING' and understand and accept it fully.
10 // The file `COPYING' mentioned in the previous paragraph is distributed
11 // with the ttfautohint library.
22 // build string which gets appended to the `Version' field(s)
27 build_version_string(Info_Data
* idata
)
32 d
= (char*)idata
->data
;
33 d
+= sprintf(d
, "; ttfautohint (v%s)", VERSION
);
35 if (idata
->hinting_range_min
!= TA_HINTING_RANGE_MIN
)
36 d
+= sprintf(d
, " -l %d", idata
->hinting_range_min
);
37 if (idata
->hinting_range_max
!= TA_HINTING_RANGE_MAX
)
38 d
+= sprintf(d
, " -r %d", idata
->hinting_range_max
);
39 if (idata
->hinting_limit
!= TA_HINTING_LIMIT
)
40 d
+= sprintf(d
, " -G %d", idata
->hinting_limit
);
42 if (idata
->pre_hinting
)
43 d
+= sprintf(d
, " -p");
44 if (idata
->increase_x_height
)
45 d
+= sprintf(d
, " -x");
46 if (idata
->latin_fallback
)
47 d
+= sprintf(d
, " -f");
49 d
+= sprintf(d
, " -s");
51 idata
->data_len
= d
- (char*)idata
->data
;
53 // prepare UTF16-BE version data
54 d
= (char*)idata
->data
;
55 dw
= (char*)idata
->data_wide
;
56 for (unsigned short i
= 0; i
< idata
->data_len
; i
++)
61 idata
->data_wide_len
= idata
->data_len
<< 1;
66 info(unsigned short platform_id
,
67 unsigned short encoding_id
,
68 unsigned short /* language_id */,
69 unsigned short name_id
,
74 Info_Data
* idata
= (Info_Data
*)user
;
78 // if it is a version string, append our data
83 || (platform_id
== 3 && !(encoding_id
== 1
84 || encoding_id
== 10)))
86 // one-byte or multi-byte encodings
88 v_len
= idata
->data_len
;
92 // (two-byte) UTF-16BE for everything else
94 v_len
= idata
->data_wide_len
;
97 // do nothing if the string would become too long
98 if (*len
> 0xFFFF - v_len
)
101 unsigned short len_new
= *len
+ v_len
;
102 unsigned char* str_new
= (unsigned char*)realloc(*str
, len_new
);
107 memcpy(*str
+ *len
, v
, v_len
);