LibreOffice Module vcl (master) 1
cff.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <cstdio>
21#include <cstring>
22#include <vector>
23#include <assert.h>
24
25#include <fontsubset.hxx>
26
28#include <o3tl/safeint.hxx>
29#include <o3tl/sprintf.hxx>
30#include <rtl/math.hxx>
31#include <rtl/strbuf.hxx>
32#include <rtl/string.hxx>
33#include <strhelper.hxx>
34#include <sal/log.hxx>
35#include <tools/stream.hxx>
36
37typedef sal_uInt8 U8;
38typedef sal_uInt16 U16;
39typedef sal_Int64 S64;
40
41typedef double RealType;
43
44constexpr OStringLiteral tok_notdef = ".notdef";
45constexpr OStringLiteral tok_space = "space";
46constexpr OStringLiteral tok_exclam = "exclam";
47constexpr OStringLiteral tok_quotedbl = "quotedbl";
48constexpr OStringLiteral tok_numbersign = "numbersign";
49constexpr OStringLiteral tok_dollar = "dollar";
50constexpr OStringLiteral tok_percent = "percent";
51constexpr OStringLiteral tok_ampersand = "ampersand";
52constexpr OStringLiteral tok_quoteright = "quoteright";
53constexpr OStringLiteral tok_parenleft = "parenleft";
54constexpr OStringLiteral tok_parenright = "parenright";
55constexpr OStringLiteral tok_asterisk = "asterisk";
56constexpr OStringLiteral tok_plus = "plus";
57constexpr OStringLiteral tok_comma = "comma";
58constexpr OStringLiteral tok_hyphen = "hyphen";
59constexpr OStringLiteral tok_period = "period";
60constexpr OStringLiteral tok_slash = "slash";
61constexpr OStringLiteral tok_zero = "zero";
62constexpr OStringLiteral tok_one = "one";
63constexpr OStringLiteral tok_two = "two";
64constexpr OStringLiteral tok_three = "three";
65constexpr OStringLiteral tok_four = "four";
66constexpr OStringLiteral tok_five = "five";
67constexpr OStringLiteral tok_six = "six";
68constexpr OStringLiteral tok_seven = "seven";
69constexpr OStringLiteral tok_eight = "eight";
70constexpr OStringLiteral tok_nine = "nine";
71constexpr OStringLiteral tok_colon = "colon";
72constexpr OStringLiteral tok_semicolon = "semicolon";
73constexpr OStringLiteral tok_less = "less";
74constexpr OStringLiteral tok_equal = "equal";
75constexpr OStringLiteral tok_greater = "greater";
76constexpr OStringLiteral tok_question = "question";
77constexpr OStringLiteral tok_at = "at";
78constexpr OStringLiteral tok_A = "A";
79constexpr OStringLiteral tok_B = "B";
80constexpr OStringLiteral tok_C = "C";
81constexpr OStringLiteral tok_D = "D";
82constexpr OStringLiteral tok_E = "E";
83constexpr OStringLiteral tok_F = "F";
84constexpr OStringLiteral tok_G = "G";
85constexpr OStringLiteral tok_H = "H";
86constexpr OStringLiteral tok_I = "I";
87constexpr OStringLiteral tok_J = "J";
88constexpr OStringLiteral tok_K = "K";
89constexpr OStringLiteral tok_L = "L";
90constexpr OStringLiteral tok_M = "M";
91constexpr OStringLiteral tok_N = "N";
92constexpr OStringLiteral tok_O = "O";
93constexpr OStringLiteral tok_P = "P";
94constexpr OStringLiteral tok_Q = "Q";
95constexpr OStringLiteral tok_R = "R";
96constexpr OStringLiteral tok_S = "S";
97constexpr OStringLiteral tok_T = "T";
98constexpr OStringLiteral tok_U = "U";
99constexpr OStringLiteral tok_V = "V";
100constexpr OStringLiteral tok_W = "W";
101constexpr OStringLiteral tok_X = "X";
102constexpr OStringLiteral tok_Y = "Y";
103constexpr OStringLiteral tok_Z = "Z";
104constexpr OStringLiteral tok_bracketleft = "bracketleft";
105constexpr OStringLiteral tok_backslash = "backslash";
106constexpr OStringLiteral tok_bracketright = "bracketright";
107constexpr OStringLiteral tok_asciicircum = "asciicircum";
108constexpr OStringLiteral tok_underscore = "underscore";
109constexpr OStringLiteral tok_quoteleft = "quoteleft";
110constexpr OStringLiteral tok_a = "a";
111constexpr OStringLiteral tok_b = "b";
112constexpr OStringLiteral tok_c = "c";
113constexpr OStringLiteral tok_d = "d";
114constexpr OStringLiteral tok_e = "e";
115constexpr OStringLiteral tok_f = "f";
116constexpr OStringLiteral tok_g = "g";
117constexpr OStringLiteral tok_h = "h";
118constexpr OStringLiteral tok_i = "i";
119constexpr OStringLiteral tok_j = "j";
120constexpr OStringLiteral tok_k = "k";
121constexpr OStringLiteral tok_l = "l";
122constexpr OStringLiteral tok_m = "m";
123constexpr OStringLiteral tok_n = "n";
124constexpr OStringLiteral tok_o = "o";
125constexpr OStringLiteral tok_p = "p";
126constexpr OStringLiteral tok_q = "q";
127constexpr OStringLiteral tok_r = "r";
128constexpr OStringLiteral tok_s = "s";
129constexpr OStringLiteral tok_t = "t";
130constexpr OStringLiteral tok_u = "u";
131constexpr OStringLiteral tok_v = "v";
132constexpr OStringLiteral tok_w = "w";
133constexpr OStringLiteral tok_x = "x";
134constexpr OStringLiteral tok_y = "y";
135constexpr OStringLiteral tok_z = "z";
136constexpr OStringLiteral tok_braceleft = "braceleft";
137constexpr OStringLiteral tok_bar = "bar";
138constexpr OStringLiteral tok_braceright = "braceright";
139constexpr OStringLiteral tok_asciitilde = "asciitilde";
140constexpr OStringLiteral tok_exclamdown = "exclamdown";
141constexpr OStringLiteral tok_cent = "cent";
142constexpr OStringLiteral tok_sterlin = "sterlin";
143constexpr OStringLiteral tok_fraction = "fraction";
144constexpr OStringLiteral tok_yen = "yen";
145constexpr OStringLiteral tok_florin = "florin";
146constexpr OStringLiteral tok_section = "section";
147constexpr OStringLiteral tok_currency = "currency";
148constexpr OStringLiteral tok_quotesingle = "quotesingle";
149constexpr OStringLiteral tok_quotedblleft = "quotedblleft";
150constexpr OStringLiteral tok_guillemotleft = "guillemotleft";
151constexpr OStringLiteral tok_guilsinglleft = "guilsinglleft";
152constexpr OStringLiteral tok_guilsinglright = "guilsinglright";
153constexpr OStringLiteral tok_fi = "fi";
154constexpr OStringLiteral tok_fl = "fl";
155constexpr OStringLiteral tok_endash = "endash";
156constexpr OStringLiteral tok_dagger = "dagger";
157constexpr OStringLiteral tok_daggerdbl = "daggerdbl";
158constexpr OStringLiteral tok_periodcentered = "periodcentered";
159constexpr OStringLiteral tok_paragraph = "paragraph";
160constexpr OStringLiteral tok_bullet = "bullet";
161constexpr OStringLiteral tok_quotesinglbase = "quotesinglbase";
162constexpr OStringLiteral tok_quotedblbase = "quotedblbase";
163constexpr OStringLiteral tok_quotedblright = "quotedblright";
164constexpr OStringLiteral tok_guillemotright = "guillemotright";
165constexpr OStringLiteral tok_ellipsis = "ellipsis";
166constexpr OStringLiteral tok_perthousand = "perthousand";
167constexpr OStringLiteral tok_questiondown = "questiondown";
168constexpr OStringLiteral tok_grave = "grave";
169constexpr OStringLiteral tok_acute = "acute";
170constexpr OStringLiteral tok_circumflex = "circumflex";
171constexpr OStringLiteral tok_tilde = "tilde";
172constexpr OStringLiteral tok_macron = "macron";
173constexpr OStringLiteral tok_breve = "breve";
174constexpr OStringLiteral tok_dotaccent = "dotaccent";
175constexpr OStringLiteral tok_dieresis = "dieresis";
176constexpr OStringLiteral tok_ring = "ring";
177constexpr OStringLiteral tok_cedilla = "cedilla";
178constexpr OStringLiteral tok_hungarumlaut = "hungarumlaut";
179constexpr OStringLiteral tok_ogonek = "ogonek";
180constexpr OStringLiteral tok_caron = "caron";
181constexpr OStringLiteral tok_emdash = "emdash";
182constexpr OStringLiteral tok_AE = "AE";
183constexpr OStringLiteral tok_ordfeminine = "ordfeminine";
184constexpr OStringLiteral tok_Lslash = "Lslash";
185constexpr OStringLiteral tok_Oslash = "Oslash";
186constexpr OStringLiteral tok_OE = "OE";
187constexpr OStringLiteral tok_ordmasculine = "ordmasculine";
188constexpr OStringLiteral tok_ae = "ae";
189constexpr OStringLiteral tok_dotlessi = "dotlessi";
190constexpr OStringLiteral tok_lslash = "lslash";
191constexpr OStringLiteral tok_oslash = "oslash";
192constexpr OStringLiteral tok_oe = "oe";
193constexpr OStringLiteral tok_germandbls = "germandbls";
194constexpr OStringLiteral tok_onesuperior = "onesuperior";
195constexpr OStringLiteral tok_logicalnot = "logicalnot";
196constexpr OStringLiteral tok_mu = "mu";
197constexpr OStringLiteral tok_trademark = "trademark";
198constexpr OStringLiteral tok_Eth = "Eth";
199constexpr OStringLiteral tok_onehalf = "onehalf";
200constexpr OStringLiteral tok_plusminus = "plusminus";
201constexpr OStringLiteral tok_Thorn = "Thorn";
202constexpr OStringLiteral tok_onequarter = "onequarter";
203constexpr OStringLiteral tok_divide = "divide";
204constexpr OStringLiteral tok_brokenbar = "brokenbar";
205constexpr OStringLiteral tok_degree = "degree";
206constexpr OStringLiteral tok_thorn = "thorn";
207constexpr OStringLiteral tok_threequarters = "threequarters";
208constexpr OStringLiteral tok_twosuperior = "twosuperior";
209constexpr OStringLiteral tok_registered = "registered";
210constexpr OStringLiteral tok_minus = "minus";
211constexpr OStringLiteral tok_eth = "eth";
212constexpr OStringLiteral tok_multiply = "multiply";
213constexpr OStringLiteral tok_threesuperior = "threesuperior";
214constexpr OStringLiteral tok_copyright = "copyright";
215constexpr OStringLiteral tok_Aacute = "Aacute";
216constexpr OStringLiteral tok_Acircumflex = "Acircumflex";
217constexpr OStringLiteral tok_Adieresis = "Adieresis";
218constexpr OStringLiteral tok_Agrave = "Agrave";
219constexpr OStringLiteral tok_Aring = "Aring";
220constexpr OStringLiteral tok_Atilde = "Atilde";
221constexpr OStringLiteral tok_Ccedilla = "Ccedilla";
222constexpr OStringLiteral tok_Eacute = "Eacute";
223constexpr OStringLiteral tok_Ecircumflex = "Ecircumflex";
224constexpr OStringLiteral tok_Edieresis = "Edieresis";
225constexpr OStringLiteral tok_Egrave = "Egrave";
226constexpr OStringLiteral tok_Iacute = "Iacute";
227constexpr OStringLiteral tok_Icircumflex = "Icircumflex";
228constexpr OStringLiteral tok_Idieresis = "Idieresis";
229constexpr OStringLiteral tok_Igrave = "Igrave";
230constexpr OStringLiteral tok_Ntilde = "Ntilde";
231constexpr OStringLiteral tok_Oacute = "Oacute";
232constexpr OStringLiteral tok_Ocircumflex = "Ocircumflex";
233constexpr OStringLiteral tok_Odieresis = "Odieresis";
234constexpr OStringLiteral tok_Ograve = "Ograve";
235constexpr OStringLiteral tok_Otilde = "Otilde";
236constexpr OStringLiteral tok_Scaron = "Scaron";
237constexpr OStringLiteral tok_Uacute = "Uacute";
238constexpr OStringLiteral tok_Ucircumflex = "Ucircumflex";
239constexpr OStringLiteral tok_Udieresis = "Udieresis";
240constexpr OStringLiteral tok_Ugrave = "Ugrave";
241constexpr OStringLiteral tok_Yacute = "Yacute";
242constexpr OStringLiteral tok_Ydieresis = "Ydieresis";
243constexpr OStringLiteral tok_Zcaron = "Zcaron";
244constexpr OStringLiteral tok_aacute = "aacute";
245constexpr OStringLiteral tok_acircumflex = "acircumflex";
246constexpr OStringLiteral tok_adieresis = "adieresis";
247constexpr OStringLiteral tok_agrave = "agrave";
248constexpr OStringLiteral tok_aring = "aring";
249constexpr OStringLiteral tok_atilde = "atilde";
250constexpr OStringLiteral tok_ccedilla = "ccedilla";
251constexpr OStringLiteral tok_eacute = "eacute";
252constexpr OStringLiteral tok_ecircumflex = "ecircumflex";
253constexpr OStringLiteral tok_edieresis = "edieresis";
254constexpr OStringLiteral tok_egrave = "egrave";
255constexpr OStringLiteral tok_iacute = "iacute";
256constexpr OStringLiteral tok_icircumflex = "icircumflex";
257constexpr OStringLiteral tok_idieresis = "idieresis";
258constexpr OStringLiteral tok_igrave = "igrave";
259constexpr OStringLiteral tok_ntilde = "ntilde";
260constexpr OStringLiteral tok_oacute = "oacute";
261constexpr OStringLiteral tok_ocircumflex = "ocircumflex";
262constexpr OStringLiteral tok_odieresis = "odieresis";
263constexpr OStringLiteral tok_ograve = "ograve";
264constexpr OStringLiteral tok_otilde = "otilde";
265constexpr OStringLiteral tok_scaron = "scaron";
266constexpr OStringLiteral tok_uacute = "uacute";
267constexpr OStringLiteral tok_ucircumflex = "ucircumflex";
268constexpr OStringLiteral tok_udieresis = "udieresis";
269constexpr OStringLiteral tok_ugrave = "ugrave";
270constexpr OStringLiteral tok_yacute = "yacute";
271constexpr OStringLiteral tok_ydieresis = "ydieresis";
272constexpr OStringLiteral tok_zcaron = "zcaron";
273constexpr OStringLiteral tok_exclamsmall = "exclamsmall";
274constexpr OStringLiteral tok_Hungarumlautsmall = "Hungarumlautsmall";
275constexpr OStringLiteral tok_dollaroldstyle = "dollaroldstyle";
276constexpr OStringLiteral tok_dollarsuperior = "dollarsuperior";
277constexpr OStringLiteral tok_ampersandsmall = "ampersandsmall";
278constexpr OStringLiteral tok_Acutesmall = "Acutesmall";
279constexpr OStringLiteral tok_parenleftsuperior = "parenleftsuperior";
280constexpr OStringLiteral tok_parenrightsuperior = "parenrightsuperior";
281constexpr OStringLiteral tok_twodotenleader = "twodotenleader";
282constexpr OStringLiteral tok_onedotenleader = "onedotenleader";
283constexpr OStringLiteral tok_zerooldstyle = "zerooldstyle";
284constexpr OStringLiteral tok_oneoldstyle = "oneoldstyle";
285constexpr OStringLiteral tok_twooldstyle = "twooldstyle";
286constexpr OStringLiteral tok_threeoldstyle = "threeoldstyle";
287constexpr OStringLiteral tok_fouroldstyle = "fouroldstyle";
288constexpr OStringLiteral tok_fiveoldstyle = "fiveoldstyle";
289constexpr OStringLiteral tok_sixoldstyle = "sixoldstyle";
290constexpr OStringLiteral tok_sevenoldstyle = "sevenoldstyle";
291constexpr OStringLiteral tok_eightoldstyle = "eightoldstyle";
292constexpr OStringLiteral tok_nineoldstile = "nineoldstile";
293constexpr OStringLiteral tok_commasuperior = "commasuperior";
294constexpr OStringLiteral tok_threequartersemdash = "threequartersemdash";
295constexpr OStringLiteral tok_periodsuperior = "periodsuperior";
296constexpr OStringLiteral tok_questionsmall = "questionsmall";
297constexpr OStringLiteral tok_asuperior = "asuperior";
298constexpr OStringLiteral tok_bsuperior = "bsuperior";
299constexpr OStringLiteral tok_centsuperior = "centsuperior";
300constexpr OStringLiteral tok_dsuperior = "dsuperior";
301constexpr OStringLiteral tok_esuperior = "esuperior";
302constexpr OStringLiteral tok_isuperior = "isuperior";
303constexpr OStringLiteral tok_lsuperior = "lsuperior";
304constexpr OStringLiteral tok_msuperior = "msuperior";
305constexpr OStringLiteral tok_nsuperior = "nsuperior";
306constexpr OStringLiteral tok_osuperior = "osuperior";
307constexpr OStringLiteral tok_rsuperior = "rsuperior";
308constexpr OStringLiteral tok_ssuperior = "ssuperior";
309constexpr OStringLiteral tok_tsuperior = "tsuperior";
310constexpr OStringLiteral tok_ff = "ff";
311constexpr OStringLiteral tok_ffi = "ffi";
312constexpr OStringLiteral tok_ffl = "ffl";
313constexpr OStringLiteral tok_parenleftinferior = "parenleftinferior";
314constexpr OStringLiteral tok_parenrightinferior = "parenrightinferior";
315constexpr OStringLiteral tok_Circumflexsmall = "Circumflexsmall";
316constexpr OStringLiteral tok_hyphensuperior = "hyphensuperior";
317constexpr OStringLiteral tok_Gravesmall = "Gravesmall";
318constexpr OStringLiteral tok_Asmall = "Asmall";
319constexpr OStringLiteral tok_Bsmall = "Bsmall";
320constexpr OStringLiteral tok_Csmall = "Csmall";
321constexpr OStringLiteral tok_Dsmall = "Dsmall";
322constexpr OStringLiteral tok_Esmall = "Esmall";
323constexpr OStringLiteral tok_Fsmall = "Fsmall";
324constexpr OStringLiteral tok_Gsmall = "Gsmall";
325constexpr OStringLiteral tok_Hsmall = "Hsmall";
326constexpr OStringLiteral tok_Ismall = "Ismall";
327constexpr OStringLiteral tok_Jsmall = "Jsmall";
328constexpr OStringLiteral tok_Ksmall = "Ksmall";
329constexpr OStringLiteral tok_Lsmall = "Lsmall";
330constexpr OStringLiteral tok_Msmall = "Msmall";
331constexpr OStringLiteral tok_Nsmall = "Nsmall";
332constexpr OStringLiteral tok_Osmall = "Osmall";
333constexpr OStringLiteral tok_Psmall = "Psmall";
334constexpr OStringLiteral tok_Qsmall = "Qsmall";
335constexpr OStringLiteral tok_Rsmall = "Rsmall";
336constexpr OStringLiteral tok_Ssmall = "Ssmall";
337constexpr OStringLiteral tok_Tsmall = "Tsmall";
338constexpr OStringLiteral tok_Usmall = "Usmall";
339constexpr OStringLiteral tok_Vsmall = "Vsmall";
340constexpr OStringLiteral tok_Wsmall = "Wsmall";
341constexpr OStringLiteral tok_Xsmall = "Xsmall";
342constexpr OStringLiteral tok_Ysmall = "Ysmall";
343constexpr OStringLiteral tok_Zsmall = "Zsmall";
344constexpr OStringLiteral tok_colonmonetary = "colonmonetary";
345constexpr OStringLiteral tok_onefitted = "onefitted";
346constexpr OStringLiteral tok_rupia = "rupia";
347constexpr OStringLiteral tok_Tildesmall = "Tildesmall";
348constexpr OStringLiteral tok_exclamdownsmall = "exclamdownsmall";
349constexpr OStringLiteral tok_centoldstyle = "centoldstyle";
350constexpr OStringLiteral tok_Lslashsmall = "Lslashsmall";
351constexpr OStringLiteral tok_Scaronsmall = "Scaronsmall";
352constexpr OStringLiteral tok_Zcaronsmall = "Zcaronsmall";
353constexpr OStringLiteral tok_Dieresissmall = "Dieresissmall";
354constexpr OStringLiteral tok_Brevesmall = "Brevesmall";
355constexpr OStringLiteral tok_Caronsmall = "Caronsmall";
356constexpr OStringLiteral tok_Dotaccentsmall = "Dotaccentsmall";
357constexpr OStringLiteral tok_Macronsmall = "Macronsmall";
358constexpr OStringLiteral tok_figuredash = "figuredash";
359constexpr OStringLiteral tok_hypheninferior = "hypheninferior";
360constexpr OStringLiteral tok_Ogoneksmall = "Ogoneksmall";
361constexpr OStringLiteral tok_Ringsmall = "Ringsmall";
362constexpr OStringLiteral tok_Cedillasmall = "Cedillasmall";
363constexpr OStringLiteral tok_questiondownsmall = "questiondownsmall";
364constexpr OStringLiteral tok_oneeight = "oneeight";
365constexpr OStringLiteral tok_threeeights = "threeeights";
366constexpr OStringLiteral tok_fiveeights = "fiveeights";
367constexpr OStringLiteral tok_seveneights = "seveneights";
368constexpr OStringLiteral tok_onethird = "onethird";
369constexpr OStringLiteral tok_twothirds = "twothirds";
370constexpr OStringLiteral tok_zerosuperior = "zerosuperior";
371constexpr OStringLiteral tok_foursuperior = "foursuperior";
372constexpr OStringLiteral tok_fivesuperior = "fivesuperior";
373constexpr OStringLiteral tok_sixsuperior = "sixsuperior";
374constexpr OStringLiteral tok_sevensuperior = "sevensuperior";
375constexpr OStringLiteral tok_eightsuperior = "eightsuperior";
376constexpr OStringLiteral tok_ninesuperior = "ninesuperior";
377constexpr OStringLiteral tok_zeroinferior = "zeroinferior";
378constexpr OStringLiteral tok_oneinferior = "oneinferior";
379constexpr OStringLiteral tok_twoinferior = "twoinferior";
380constexpr OStringLiteral tok_threeinferior = "threeinferior";
381constexpr OStringLiteral tok_fourinferior = "fourinferior";
382constexpr OStringLiteral tok_fiveinferior = "fiveinferior";
383constexpr OStringLiteral tok_sixinferior = "sixinferior";
384constexpr OStringLiteral tok_seveninferior = "seveninferior";
385constexpr OStringLiteral tok_eightinferior = "eightinferior";
386constexpr OStringLiteral tok_nineinferior = "nineinferior";
387constexpr OStringLiteral tok_centinferior = "centinferior";
388constexpr OStringLiteral tok_dollarinferior = "dollarinferior";
389constexpr OStringLiteral tok_periodinferior = "periodinferior";
390constexpr OStringLiteral tok_commainferior = "commainferior";
391constexpr OStringLiteral tok_Agravesmall = "Agravesmall";
392constexpr OStringLiteral tok_Aacutesmall = "Aacutesmall";
393constexpr OStringLiteral tok_Acircumflexsmall = "Acircumflexsmall";
394constexpr OStringLiteral tok_Atildesmall = "Atildesmall";
395constexpr OStringLiteral tok_Adieresissmall = "Adieresissmall";
396constexpr OStringLiteral tok_Aringsmall = "Aringsmall";
397constexpr OStringLiteral tok_AEsmall = "AEsmall";
398constexpr OStringLiteral tok_Ccedillasmall = "Ccedillasmall";
399constexpr OStringLiteral tok_Egravesmall = "Egravesmall";
400constexpr OStringLiteral tok_Eacutesmall = "Eacutesmall";
401constexpr OStringLiteral tok_Ecircumflexsmall = "Ecircumflexsmall";
402constexpr OStringLiteral tok_Edieresissmall = "Edieresissmall";
403constexpr OStringLiteral tok_Igravesmall = "Igravesmall";
404constexpr OStringLiteral tok_Iacutesmall = "Iacutesmall";
405constexpr OStringLiteral tok_Icircumflexsmall = "Icircumflexsmall";
406constexpr OStringLiteral tok_Idieresissmall = "Idieresissmall";
407constexpr OStringLiteral tok_Ethsmall = "Ethsmall";
408constexpr OStringLiteral tok_Ntildesmall = "Ntildesmall";
409constexpr OStringLiteral tok_Ogravesmall = "Ogravesmall";
410constexpr OStringLiteral tok_Oacutesmall = "Oacutesmall";
411constexpr OStringLiteral tok_Ocircumflexsmall = "Ocircumflexsmall";
412constexpr OStringLiteral tok_Otildesmall = "Otildesmall";
413constexpr OStringLiteral tok_Odieressissmall = "Odieressissmall";
414constexpr OStringLiteral tok_OEsmall = "OEsmall";
415constexpr OStringLiteral tok_Oslashsmall = "Oslashsmall";
416constexpr OStringLiteral tok_Ugravesmall = "Ugravesmall";
417constexpr OStringLiteral tok_Uacutesmall = "Uacutesmall";
418constexpr OStringLiteral tok_Ucircumflexsmall = "Ucircumflexsmall";
419constexpr OStringLiteral tok_Udieresissmall = "Udieresissmall";
420constexpr OStringLiteral tok_Yacutesmall = "Yacutesmall";
421constexpr OStringLiteral tok_Thornsmall = "Thornsmall";
422constexpr OStringLiteral tok_Ydieresissmall = "Ydieresissmall";
423constexpr OStringLiteral tok_001_000 = "001.000";
424constexpr OStringLiteral tok_001_001 = "001.001";
425constexpr OStringLiteral tok_001_002 = "001.002";
426constexpr OStringLiteral tok_001_003 = "001.003";
427constexpr OStringLiteral tok_Black = "Black";
428constexpr OStringLiteral tok_Bold = "Bold";
429constexpr OStringLiteral tok_Book = "Book";
430constexpr OStringLiteral tok_Light = "Light";
431constexpr OStringLiteral tok_Medium = "Medium";
432constexpr OStringLiteral tok_Regular = "Regular";
433constexpr OStringLiteral tok_Roman = "Roman";
434constexpr OStringLiteral tok_Semibold = "Semibold";
435
436static rtl::OStringConstExpr pStringIds[] = {
449/*48*/ tok_O, tok_P, tok_Q, tok_R,
457/*80*/ tok_o, tok_p, tok_q, tok_r,
535};
536
537// TOP DICT keywords (also covers PRIV DICT keywords)
538static const char* pDictOps[] = {
539 "sVersion", "sNotice", "sFullName", "sFamilyName",
540 "sWeight", "aFontBBox", "dBlueValues", "dOtherBlues",
541 "dFamilyBlues", "dFamilyOtherBlues", "nStdHW", "nStdVW",
542 "xESC", "nUniqueID", "aXUID", "nCharset",
543 "nEncoding", "nCharStrings", "PPrivate", "nSubrs",
544 "nDefaultWidthX", "nNominalWidthX", nullptr, nullptr,
545 nullptr, nullptr, nullptr, nullptr,
546 "shortint", "longint", "BCD", nullptr
547};
548
549// TOP DICT escapes (also covers PRIV DICT escapes)
550static const char* pDictEscs[] = {
551 "sCopyright", "bIsFixedPitch", "nItalicAngle", "nUnderlinePosition",
552 "nUnderlineThickness", "nPaintType", "tCharstringType", "aFontMatrix",
553 "nStrokeWidth", "nBlueScale", "nBlueShift", "nBlueFuzz",
554 "dStemSnapH", "dStemSnapV", "bForceBold", nullptr,
555 nullptr, "nLanguageGroup", "nExpansionFactor", "nInitialRandomSeed",
556 "nSyntheticBase", "sPostScript", "sBaseFontName", "dBaseFontBlend",
557 nullptr, nullptr, nullptr, nullptr,
558 nullptr, nullptr, "rROS", "nCIDFontVersion",
559 "nCIDFontRevision", "nCIDFontType", "nCIDCount", "nUIDBase",
560 "nFDArray", "nFDSelect", "sFontName"
561};
562
563static const char* pStandardEncoding[] = {
564 ".notdef", ".notdef", ".notdef", ".notdef", ".notdef",
565 ".notdef", ".notdef", ".notdef", ".notdef", ".notdef",
566 ".notdef", ".notdef", ".notdef", ".notdef", ".notdef",
567 ".notdef", ".notdef", ".notdef", ".notdef", ".notdef",
568 ".notdef", ".notdef", ".notdef", ".notdef", ".notdef",
569 ".notdef", ".notdef", ".notdef", ".notdef", ".notdef",
570 ".notdef", ".notdef", "space", "exclam", "quotedbl",
571 "numbersign", "dollar", "percent", "ampersand",
572 "quoteright", "parenleft", "parenright", "asterisk", "plus",
573 "comma", "hyphen", "period", "slash", "zero", "one", "two",
574 "three", "four", "five", "six", "seven", "eight", "nine",
575 "colon", "semicolon", "less", "equal", "greater",
576 "question", "at", "A", "B", "C", "D", "E", "F", "G", "H",
577 "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T",
578 "U", "V", "W", "X", "Y", "Z", "bracketleft", "backslash",
579 "bracketright", "asciicircum", "underscore", "quoteleft",
580 "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l",
581 "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x",
582 "y", "z", "braceleft", "bar", "braceright", "asciitilde",
583 ".notdef", ".notdef", ".notdef", ".notdef", ".notdef",
584 ".notdef", ".notdef", ".notdef", ".notdef", ".notdef",
585 ".notdef", ".notdef", ".notdef", ".notdef", ".notdef",
586 ".notdef", ".notdef", ".notdef", ".notdef", ".notdef",
587 ".notdef", ".notdef", ".notdef", ".notdef", ".notdef",
588 ".notdef", ".notdef", ".notdef", ".notdef", ".notdef",
589 ".notdef", ".notdef", ".notdef", ".notdef", "exclamdown",
590 "cent", "sterling", "fraction", "yen", "florin", "section",
591 "currency", "quotesingle", "quotedblleft", "guillemotleft",
592 "guilsinglleft", "guilsinglright", "fi", "fl", ".notdef",
593 "endash", "dagger", "daggerdbl", "periodcentered",
594 ".notdef", "paragraph", "bullet", "quotesinglbase",
595 "quotedblbase", "quotedblright", "guillemotright",
596 "ellipsis", "perthousand", ".notdef", "questiondown",
597 ".notdef", "grave", "acute", "circumflex", "tilde",
598 "macron", "breve", "dotaccent", "dieresis", ".notdef",
599 "ring", "cedilla", ".notdef", "hungarumlaut", "ogonek",
600 "caron", "emdash", ".notdef", ".notdef", ".notdef",
601 ".notdef", ".notdef", ".notdef", ".notdef", ".notdef",
602 ".notdef", ".notdef", ".notdef", ".notdef", ".notdef",
603 ".notdef", ".notdef", ".notdef", "AE", ".notdef",
604 "ordfeminine", ".notdef", ".notdef", ".notdef", ".notdef",
605 "Lslash", "Oslash", "OE", "ordmasculine", ".notdef",
606 ".notdef", ".notdef", ".notdef", ".notdef", "ae", ".notdef",
607 ".notdef", ".notdef", "dotlessi", ".notdef", ".notdef",
608 "lslash", "oslash", "oe", "germandbls", ".notdef",
609 ".notdef", ".notdef", ".notdef"
610};
611
612namespace {
613
614namespace TYPE1OP
615{
616 enum OPS
617 {
618 HSTEM=1, VSTEM=3, VMOVETO=4, RLINETO=5,
619 HLINETO=6, VLINETO=7, RCURVETO=8, CLOSEPATH=9,
620 CALLSUBR=10, RETURN=11, T1ESC=12, HSBW=13,
621 ENDCHAR=14, RMOVETO=21, HMOVETO=22, VHCURVETO=30,
622 HVCURVETO=31
623 };
624
625 enum ESCS
626 {
627 DOTSECTION=0, VSTEM3=1, HSTEM3=2, SEAC=6,
628 SBW=7, ABS=9, ADD=10, SUB=11,
629 DIV=12, CALLOTHERSUBR=16, POP=17, SETCURRENTPOINT=33
630 };
631}
632
633namespace TYPE2OP
634{
635 enum OPS
636 {
637 HSTEM=1, VSTEM=3, VMOVETO=4, RLINETO=5,
638 HLINETO=6, VLINETO=7, RCURVETO=8, CALLSUBR=10,
639 RETURN=11, T2ESC=12, ENDCHAR=14, HSTEMHM=18,
640 HINTMASK=19, CNTRMASK=20, RMOVETO=21, HMOVETO=22,
641 VSTEMHM=23, RCURVELINE=24, RLINECURVE=25, VVCURVETO=26,
642 HHCURVETO=27, SHORTINT=28, CALLGSUBR=29, VHCURVETO=30,
643 HVCURVETO=31
644 };
645
646 enum ESCS
647 {
648 AND=3, OR=4, NOT=5, ABS=9,
649 ADD=10, SUB=11, DIV=12, NEG=14,
650 EQ=15, DROP=18, PUT=20, GET=21,
651 IFELSE=22, RANDOM=23, MUL=24, SQRT=26,
652 DUP=27, EXCH=28, INDEX=29, ROLL=30,
653 HFLEX=34, FLEX=35, HFLEX1=36, FLEX1=37
654 };
655}
656
657struct CffGlobal
658{
659 explicit CffGlobal();
660
661 int mnNameIdxBase;
662 int mnStringIdxBase;
663 bool mbCIDFont;
664 int mnCharStrBase;
665 int mnCharStrCount;
666 int mnCharsetBase;
667 int mnGlobalSubrBase;
668 int mnGlobalSubrCount;
669 int mnGlobalSubrBias;
670 int mnFDSelectBase;
671 int mnFontDictBase;
672 int mnFDAryCount;
673
674 std::vector<ValType> maFontBBox;
675 std::vector<ValType> maFontMatrix;
676
677 int mnFontNameSID;
678 int mnFullNameSID;
679};
680
681struct CffLocal
682{
683 explicit CffLocal();
684
685 int mnPrivDictBase;
686 int mnPrivDictSize;
687 int mnLocalSubrOffs;
688 int mnLocalSubrBase;
689 int mnLocalSubrBias;
690
691 ValType maNominalWidth;
692 ValType maDefaultWidth;
693
694 // ATM hinting related values
695 ValType maStemStdHW;
696 ValType maStemStdVW;
697 std::vector<ValType> maStemSnapH;
698 std::vector<ValType> maStemSnapV;
699 std::vector<ValType> maBlueValues;
700 std::vector<ValType> maOtherBlues;
701 std::vector<ValType> maFamilyBlues;
702 std::vector<ValType> maFamilyOtherBlues;
703 RealType mfBlueScale;
704 RealType mfBlueShift;
705 RealType mfBlueFuzz;
706 RealType mfExpFactor;
707 int mnLangGroup;
708 bool mbForceBold;
709};
710
711const int MAX_T1OPS_SIZE = 81920; // TODO: use dynamic value
712
713struct CharString
714{
715 int nLen;
716 U8 aOps[MAX_T1OPS_SIZE];
717 int nCffGlyphId;
718};
719
720
721class CffSubsetterContext
722: private CffGlobal
723{
724public:
725 static const int NMAXSTACK = 48; // see CFF.appendixB
726 static const int NMAXHINTS = 2*96; // see CFF.appendixB
727 static const int NMAXTRANS = 32; // see CFF.appendixB
728
729 explicit CffSubsetterContext( const U8* pBasePtr, int nBaseLen);
730
731 bool initialCffRead();
732 void emitAsType1( class Type1Emitter&,
733 const sal_GlyphId* pGlyphIds, const U8* pEncoding,
734 int nGlyphCount, FontSubsetInfo& );
735
736private:
737 void convertCharStrings(const sal_GlyphId* pGlyphIds, int nGlyphCount,
738 std::vector<CharString>& rCharStrings);
739 int convert2Type1Ops( CffLocal*, const U8* pType2Ops, int nType2Len, U8* pType1Ops);
740 void convertOneTypeOp();
741 void convertOneTypeEsc();
742 void callType2Subr( bool bGlobal, int nSubrNumber);
743 sal_Int32 getReadOfs() const { return static_cast<sal_Int32>(mpReadPtr - mpBasePtr);}
744
745 const U8* mpBasePtr;
746 const U8* mpBaseEnd;
747
748 const U8* mpReadPtr;
749 const U8* mpReadEnd;
750
751 U8* mpWritePtr;
752 bool mbNeedClose;
753 bool mbIgnoreHints;
754 sal_Int32 mnCntrMask;
755
756 int seekIndexData( int nIndexBase, int nDataIndex);
757 void seekIndexEnd( int nIndexBase);
758
759 CffLocal maCffLocal[256];
760 CffLocal* mpCffLocal;
761
762 void readDictOp();
763 RealType readRealVal();
764 OString getString( int nStringID);
765 int getFDSelect( int nGlyphIndex) const;
766 int getGlyphSID( int nGlyphIndex) const;
767 OString getGlyphName( int nGlyphIndex);
768 bool getBaseAccent(ValType aBase, ValType aAccent, int* nBase, int* nAccent);
769
770 void read2push();
771 void writeType1Val( ValType);
772 void writeTypeOp( int nTypeOp);
773 void writeTypeEsc( int nTypeOp);
774 void writeCurveTo( int nStackPos, int nIX1, int nIY1, int nIX2, int nIY2, int nIX3, int nIY3);
775 void pop2MultiWrite( int nArgsPerTypo, int nTypeOp, int nTypeXor=0);
776 void popAll2Write( int nTypeOp);
777
778public: // TODO: is public really needed?
779 // accessing the value stack
780 // TODO: add more checks
781 void push( ValType nVal) { mnValStack[ mnStackIdx++] = nVal;}
782 ValType popVal() { return ((mnStackIdx>0) ? mnValStack[ --mnStackIdx] : 0);}
783 ValType getVal( int nIndex) const { return mnValStack[ nIndex];}
784 int popInt();
785 int size() const { return mnStackIdx;}
786 void clear() { mnStackIdx = 0;}
787
788 // accessing the charstring hints
789 void addHints( bool bVerticalHints);
790
791 // accessing other charstring specifics
792 void updateWidth( bool bUseFirstVal);
793
794private:
795 // typeop execution context
796 int mnStackIdx;
797 ValType mnValStack[ NMAXSTACK+4];
798 ValType mnTransVals[ NMAXTRANS];
799
800 int mnHintSize;
801 int mnHorzHintSize;
802 ValType mnHintStack[ NMAXHINTS];
803
804 ValType maCharWidth;
805
806 bool mbDoSeac;
807 std::vector<sal_GlyphId> maExtraGlyphIds;
808};
809
810}
811
812CffSubsetterContext::CffSubsetterContext( const U8* pBasePtr, int nBaseLen)
813 : mpBasePtr( pBasePtr)
814 , mpBaseEnd( pBasePtr+nBaseLen)
815 , mpReadPtr(nullptr)
816 , mpReadEnd(nullptr)
817 , mpWritePtr(nullptr)
818 , mbNeedClose(false)
819 , mbIgnoreHints(false)
820 , mnCntrMask(0)
821 , mnStackIdx(0)
822 , mnValStack{}
823 , mnTransVals{}
824 , mnHintSize(0)
825 , mnHorzHintSize(0)
826 , mnHintStack{}
827 , maCharWidth(-1)
828 , mbDoSeac(true)
829{
830// setCharStringType( 1);
831 // TODO: new CffLocal[ mnFDAryCount];
832 mpCffLocal = &maCffLocal[0];
833}
834
835inline int CffSubsetterContext::popInt()
836{
837 const ValType aVal = popVal();
838 const int nInt = static_cast<int>(aVal);
839 assert( nInt == aVal);
840 return nInt;
841}
842
843inline void CffSubsetterContext::updateWidth( bool bUseFirstVal)
844{
845 // the first value is not a hint but the charwidth
846 if( maCharWidth>0 )
847 return;
848
849 if( bUseFirstVal) {
850 maCharWidth = mpCffLocal->maNominalWidth + mnValStack[0];
851 // remove bottom stack entry
852 --mnStackIdx;
853 for( int i = 0; i < mnStackIdx; ++i)
854 mnValStack[ i] = mnValStack[ i+1];
855 } else {
856 maCharWidth = mpCffLocal->maDefaultWidth;
857 }
858}
859
860void CffSubsetterContext::addHints( bool bVerticalHints)
861{
862 // the first charstring value may a charwidth instead of a charwidth
863 updateWidth( (mnStackIdx & 1) != 0);
864 // return early (e.g. no implicit hints for hintmask)
865 if( !mnStackIdx)
866 return;
867
868 // copy the remaining values to the hint arrays
869 // assert( (mnStackIdx & 1) == 0); // depends on called subrs
870 if( mnStackIdx & 1) --mnStackIdx;//#######
871 // TODO: if( !bSubr) assert( mnStackIdx >= 2);
872
873 assert( (mnHintSize + mnStackIdx) <= 2*NMAXHINTS);
874
875 ValType nHintOfs = 0;
876 for( int i = 0; i < mnStackIdx; ++i) {
877 nHintOfs += mnValStack[ i ];
878 mnHintStack[ mnHintSize++] = nHintOfs;
879 }
880
881 if( !bVerticalHints)
882 mnHorzHintSize = mnHintSize;
883
884 // clear all values from the stack
885 mnStackIdx = 0;
886}
887
888void CffSubsetterContext::readDictOp()
889{
890 const U8 c = *mpReadPtr;
891 if( c <= 21 ) {
892 int nOpId = *(mpReadPtr++);
893 const char* pCmdName = nullptr;
894 if( nOpId != 12)
895 pCmdName = pDictOps[nOpId];
896 else {
897 const U8 nExtId = *(mpReadPtr++);
898 if (nExtId < 39)
899 pCmdName = pDictEscs[nExtId];
900 nOpId = 900 + nExtId;
901 }
902
903 if (!pCmdName) // skip reserved operators
904 return;
905
906 //TODO: if( nStackIdx > 0)
907 int nInt = 0;
908 switch( *pCmdName) {
909 default: SAL_WARN("vcl.fonts", "unsupported DictOp.type='" << *pCmdName << "'."); break;
910 case 'b': // bool
911 nInt = popInt();
912 switch( nOpId) {
913 case 915: mpCffLocal->mbForceBold = nInt; break; // "ForceBold"
914 default: break; // TODO: handle more boolean dictops?
915 }
916 break;
917 case 'n': { // dict-op number
918 ValType nVal = popVal();
919 nInt = static_cast<int>(nVal);
920 switch( nOpId) {
921 case 10: mpCffLocal->maStemStdHW = nVal; break; // "StdHW"
922 case 11: mpCffLocal->maStemStdVW = nVal; break; // "StdVW"
923 case 15: mnCharsetBase = nInt; break; // "charset"
924 case 16: break; // "nEncoding"
925 case 17: mnCharStrBase = nInt; break; // "nCharStrings"
926 case 19: mpCffLocal->mnLocalSubrOffs = nInt; break;// "nSubrs"
927 case 20: mpCffLocal->maDefaultWidth = nVal; break; // "defaultWidthX"
928 case 21: mpCffLocal->maNominalWidth = nVal; break; // "nominalWidthX"
929 case 909: mpCffLocal->mfBlueScale = nVal; break; // "BlueScale"
930 case 910: mpCffLocal->mfBlueShift = nVal; break; // "BlueShift"
931 case 911: mpCffLocal->mfBlueFuzz = nVal; break; // "BlueFuzz"
932 case 912: mpCffLocal->mfExpFactor = nVal; break; // "ExpansionFactor"
933 case 917: mpCffLocal->mnLangGroup = nInt; break; // "LanguageGroup"
934 case 936: mnFontDictBase = nInt; break; // "nFDArray"
935 case 937: mnFDSelectBase = nInt; break; // "nFDSelect"
936 default: break; // TODO: handle more numeric dictops?
937 }
938 } break;
939 case 'a': { // array
940 switch( nOpId) {
941 case 5: maFontBBox.clear(); break; // "FontBBox"
942 case 907: maFontMatrix.clear(); break; // "FontMatrix"
943 default: break; // TODO: reset other arrays?
944 }
945 for( int i = 0; i < size(); ++i ) {
946 ValType nVal = getVal(i);
947 switch( nOpId) {
948 case 5: maFontBBox.push_back( nVal); break; // "FontBBox"
949 case 907: maFontMatrix.push_back( nVal); break; // "FontMatrix"
950 default: break; // TODO: handle more array dictops?
951 }
952 }
953 clear();
954 } break;
955 case 'd': { // delta array
956 ValType nVal = 0;
957 for( int i = 0; i < size(); ++i ) {
958 nVal += getVal(i);
959 switch( nOpId) {
960 case 6: mpCffLocal->maBlueValues.push_back( nVal); break; // "BlueValues"
961 case 7: mpCffLocal->maOtherBlues.push_back( nVal); break; // "OtherBlues"
962 case 8: mpCffLocal->maFamilyBlues.push_back( nVal); break; // "FamilyBlues"
963 case 9: mpCffLocal->maFamilyOtherBlues.push_back( nVal); break;// "FamilyOtherBlues"
964 case 912: mpCffLocal->maStemSnapH.push_back( nVal); break; // "StemSnapH"
965 case 913: mpCffLocal->maStemSnapV.push_back( nVal); break; // "StemSnapV"
966 default: break; // TODO: handle more delta-array dictops?
967 }
968 }
969 clear();
970 } break;
971 case 's': // stringid (SID)
972 nInt = popInt();
973 switch( nOpId ) {
974 case 2: mnFullNameSID = nInt; break; // "FullName"
975 case 3: break; // "FamilyName"
976 case 938: mnFontNameSID = nInt; break; // "FontName"
977 default: break; // TODO: handle more string dictops?
978 }
979 break;
980 case 'P': // private dict
981 mpCffLocal->mnPrivDictBase = popInt();
982 mpCffLocal->mnPrivDictSize = popInt();
983 break;
984 case 'r': { // ROS operands
985 popInt(); // TODO: use sid1
986 popInt(); // TODO: use sid2
987 popVal();
988 mbCIDFont = true;
989 } break;
990 case 't': // CharstringType
991 popInt();
992 break;
993 }
994 } else if( (c >= 32) || (c == 28) ) {
995// --mpReadPtr;
996 read2push();
997 } else if( c == 29 ) { // longint
998 ++mpReadPtr; // skip 29
999 sal_Int32 nS32 = mpReadPtr[0] << 24;
1000 nS32 += mpReadPtr[1] << 16;
1001 nS32 += mpReadPtr[2] << 8;
1002 nS32 += mpReadPtr[3] << 0;
1003 mpReadPtr += 4;
1004 ValType nVal = static_cast<ValType>(nS32);
1005 push( nVal );
1006 } else if( c == 30) { // real number
1007 ++mpReadPtr; // skip 30
1008 const RealType fReal = readRealVal();
1009 // push value onto stack
1010 ValType nVal = fReal;
1011 push( nVal);
1012 }
1013}
1014
1015void CffSubsetterContext::read2push()
1016{
1017 ValType aVal = 0;
1018
1019 const U8*& p = mpReadPtr;
1020 const U8 c = *p;
1021 if( c == 28 ) {
1022 sal_Int16 nS16 = (p[1] << 8) + p[2];
1023 aVal = nS16;
1024 p += 3;
1025 } else if( c <= 246 ) { // -107..+107
1026 aVal = static_cast<ValType>(p[0] - 139);
1027 p += 1;
1028 } else if( c <= 250 ) { // +108..+1131
1029 aVal = static_cast<ValType>(((p[0] << 8) + p[1]) - 63124);
1030 p += 2;
1031 } else if( c <= 254 ) { // -108..-1131
1032 aVal = static_cast<ValType>(64148 - ((p[0] << 8) + p[1]));
1033 p += 2;
1034 } else /*if( c == 255)*/ { // Fixed16.16
1035 int nS32 = (p[1] << 24) + (p[2] << 16) + (p[3] << 8) + p[4];
1036 if( (sizeof(nS32) != 2) && (nS32 & (1U<<31)))
1037 nS32 |= (~0U) << 31; // assuming 2s complement
1038 aVal = static_cast<ValType>(nS32 * (1.0 / 0x10000));
1039 p += 5;
1040 }
1041
1042 push( aVal);
1043}
1044
1045void CffSubsetterContext::writeType1Val( ValType aVal)
1046{
1047 U8* pOut = mpWritePtr;
1048
1049 // tdf#126242
1050 // Type2 has 16.16 fixed numbers, but Type1 does not. To represent values
1051 // with fractions we multiply it by a factor then use “div” operator to
1052 // divide it back and keep the fractions.
1053 // Code Adapted from:
1054 // https://github.com/fontforge/fontforge/blob/f152f12e567ea5bd737a2907c318ae26cfaabd08/fontforge/splinesave.c#L378
1055 int nDiv = 0;
1056 aVal = rint(aVal * 1024) / 1024;
1057 if (aVal != floor(aVal))
1058 {
1059 if (aVal == rint(aVal * 64) / 64)
1060 nDiv = 64;
1061 else
1062 nDiv = 1024;
1063 aVal *= nDiv;
1064 }
1065
1066 int nInt = static_cast<int>(rint(aVal));
1067 if (nDiv && floor(nInt) / nDiv == floor(nInt / nDiv))
1068 {
1069 nInt = rint(nInt / nDiv);
1070 nDiv = 0;
1071 }
1072
1073 if( (nInt >= -107) && (nInt <= +107)) {
1074 *(pOut++) = static_cast<U8>(nInt + 139); // -107..+107
1075 } else if( (nInt >= -1131) && (nInt <= +1131)) {
1076 if( nInt >= 0)
1077 nInt += 63124; // +108..+1131
1078 else
1079 nInt = 64148 - nInt; // -108..-1131
1080 *(pOut++) = static_cast<U8>(nInt >> 8);
1081 *(pOut++) = static_cast<U8>(nInt);
1082 } else {
1083 // numtype==255 means int32 for Type1, but 16.16 for Type2 charstrings!!!
1084 *(pOut++) = 255;
1085 *(pOut++) = static_cast<U8>(nInt >> 24);
1086 *(pOut++) = static_cast<U8>(nInt >> 16);
1087 *(pOut++) = static_cast<U8>(nInt >> 8);
1088 *(pOut++) = static_cast<U8>(nInt);
1089 }
1090
1091 mpWritePtr = pOut;
1092
1093 if (nDiv)
1094 {
1095 writeType1Val(nDiv);
1096 writeTypeEsc(TYPE1OP::DIV);
1097 }
1098}
1099
1100inline void CffSubsetterContext::writeTypeOp( int nTypeOp)
1101{
1102 *(mpWritePtr++) = static_cast<U8>(nTypeOp);
1103}
1104
1105inline void CffSubsetterContext::writeTypeEsc( int nTypeEsc)
1106{
1107 *(mpWritePtr++) = TYPE1OP::T1ESC;
1108 *(mpWritePtr++) = static_cast<U8>(nTypeEsc);
1109}
1110
1111void CffSubsetterContext::pop2MultiWrite( int nArgsPerTypo, int nTypeOp, int nTypeXor)
1112{
1113 for( int i = 0; i < mnStackIdx;) {
1114 for( int j = 0; j < nArgsPerTypo; ++j) {
1115 const ValType aVal = mnValStack[i+j];
1116 writeType1Val( aVal);
1117 }
1118 i += nArgsPerTypo;
1119 writeTypeOp( nTypeOp);
1120 nTypeOp ^= nTypeXor; // for toggling vlineto/hlineto
1121 }
1122 clear();
1123}
1124
1125void CffSubsetterContext::popAll2Write( int nTypeOp)
1126{
1127 // pop in reverse order, then write
1128 for( int i = 0; i < mnStackIdx; ++i) {
1129 const ValType aVal = mnValStack[i];
1130 writeType1Val( aVal);
1131 }
1132 clear();
1133 writeTypeOp( nTypeOp);
1134}
1135
1136void CffSubsetterContext::writeCurveTo( int nStackPos,
1137 int nIX1, int nIY1, int nIX2, int nIY2, int nIX3, int nIY3)
1138{
1139 // get the values from the stack
1140 const ValType nDX1 = nIX1 ? mnValStack[ nStackPos+nIX1 ] : 0;
1141 const ValType nDY1 = nIY1 ? mnValStack[ nStackPos+nIY1 ] : 0;
1142 const ValType nDX2 = nIX2 ? mnValStack[ nStackPos+nIX2 ] : 0;
1143 const ValType nDY2 = nIY2 ? mnValStack[ nStackPos+nIY2 ] : 0;
1144 const ValType nDX3 = nIX3 ? mnValStack[ nStackPos+nIX3 ] : 0;
1145 const ValType nDY3 = nIY3 ? mnValStack[ nStackPos+nIY3 ] : 0;
1146
1147 // emit the curveto operator and operands
1148 // TODO: determine the most efficient curveto operator
1149 // TODO: depending on type1op or type2op target
1150 writeType1Val( nDX1 );
1151 writeType1Val( nDY1 );
1152 writeType1Val( nDX2 );
1153 writeType1Val( nDY2 );
1154 writeType1Val( nDX3 );
1155 writeType1Val( nDY3 );
1156 writeTypeOp( TYPE1OP::RCURVETO );
1157}
1158
1159void CffSubsetterContext::convertOneTypeOp()
1160{
1161 const int nType2Op = *(mpReadPtr++);
1162
1163 int i, nInt; // prevent WAE for declarations inside switch cases
1164 // convert each T2op
1165 switch( nType2Op) {
1166 case TYPE2OP::T2ESC:
1167 convertOneTypeEsc();
1168 break;
1169 case TYPE2OP::HSTEM:
1170 case TYPE2OP::VSTEM:
1171 addHints( nType2Op == TYPE2OP::VSTEM );
1172 for( i = 0; i < mnHintSize; i+=2 ) {
1173 writeType1Val( mnHintStack[i]);
1174 writeType1Val( mnHintStack[i+1] - mnHintStack[i]);
1175 writeTypeOp( nType2Op );
1176 }
1177 break;
1178 case TYPE2OP::HSTEMHM:
1179 case TYPE2OP::VSTEMHM:
1180 addHints( nType2Op == TYPE2OP::VSTEMHM);
1181 break;
1182 case TYPE2OP::CNTRMASK:
1183 // TODO: replace cntrmask with vstem3/hstem3
1184 addHints( true);
1185 {
1186 U8 nMaskBit = 0;
1187 U8 nMaskByte = 0;
1188 for( i = 0; i < mnHintSize; i+=2, nMaskBit>>=1) {
1189 if( !nMaskBit) {
1190 nMaskByte = *(mpReadPtr++);
1191 nMaskBit = 0x80;
1192 }
1193 if( !(nMaskByte & nMaskBit))
1194 continue;
1195 if( i >= 8*int(sizeof(mnCntrMask)))
1196 mbIgnoreHints = true;
1197 if( mbIgnoreHints)
1198 continue;
1199 mnCntrMask |= (1U << i);
1200 }
1201 }
1202 break;
1203 case TYPE2OP::HINTMASK:
1204 addHints( true);
1205 {
1206 sal_Int32 nHintMask = 0;
1207 int nCntrBits[2] = {0,0};
1208 U8 nMaskBit = 0;
1209 U8 nMaskByte = 0;
1210 int const MASK_BITS = 8*sizeof(nHintMask);
1211 for( i = 0; i < mnHintSize; i+=2, nMaskBit>>=1) {
1212 if( !nMaskBit) {
1213 nMaskByte = *(mpReadPtr++);
1214 nMaskBit = 0x80;
1215 }
1216 if( !(nMaskByte & nMaskBit))
1217 continue;
1218 if( i >= MASK_BITS)
1219 mbIgnoreHints = true;
1220 if( mbIgnoreHints)
1221 continue;
1222 nHintMask |= (1U << i);
1223 nCntrBits[ i < mnHorzHintSize] += (mnCntrMask >> i) & 1;
1224 }
1225
1226 mbIgnoreHints |= (nCntrBits[0] && (nCntrBits[0] != 3));
1227 mbIgnoreHints |= (nCntrBits[1] && (nCntrBits[1] != 3));
1228 if( mbIgnoreHints)
1229 break;
1230
1231 for( i = 0; i < mnHintSize; i+=2) {
1232 if(i >= MASK_BITS || !(nHintMask & (1U << i)))
1233 continue;
1234 writeType1Val( mnHintStack[i]);
1235 writeType1Val( mnHintStack[i+1] - mnHintStack[i]);
1236 const bool bHorz = (i < mnHorzHintSize);
1237 if( !nCntrBits[ bHorz])
1238 writeTypeOp( bHorz ? TYPE1OP::HSTEM : TYPE1OP::VSTEM);
1239 else if( !--nCntrBits[ bHorz])
1240 writeTypeEsc( bHorz ? TYPE1OP::HSTEM3 : TYPE1OP::VSTEM3);
1241 }
1242 }
1243 break;
1244 case TYPE2OP::CALLSUBR:
1245 case TYPE2OP::CALLGSUBR:
1246 {
1247 nInt = popInt();
1248 const bool bGlobal = (nType2Op == TYPE2OP::CALLGSUBR);
1249 callType2Subr( bGlobal, nInt);
1250 }
1251 break;
1252 case TYPE2OP::RETURN:
1253 // TODO: check that we are in a subroutine
1254 return;
1255 case TYPE2OP::VMOVETO:
1256 case TYPE2OP::HMOVETO:
1257 if( mbNeedClose)
1258 writeTypeOp( TYPE1OP::CLOSEPATH);
1259 else
1260 updateWidth( size() > 1);
1261 mbNeedClose = true;
1262 pop2MultiWrite( 1, nType2Op);
1263 break;
1264 case TYPE2OP::VLINETO:
1265 case TYPE2OP::HLINETO:
1266 pop2MultiWrite( 1, nType2Op,
1267 TYPE1OP::VLINETO ^ TYPE1OP::HLINETO);
1268 break;
1269 case TYPE2OP::RMOVETO:
1270 // TODO: convert rmoveto to vlineto/hlineto if possible
1271 if( mbNeedClose)
1272 writeTypeOp( TYPE1OP::CLOSEPATH);
1273 else
1274 updateWidth( size() > 2);
1275 mbNeedClose = true;
1276 pop2MultiWrite( 2, nType2Op);
1277 break;
1278 case TYPE2OP::RLINETO:
1279 // TODO: convert rlineto to vlineto/hlineto if possible
1280 pop2MultiWrite( 2, nType2Op);
1281 break;
1282 case TYPE2OP::RCURVETO:
1283 // TODO: convert rcurveto to vh/hv/hh/vv-curveto if possible
1284 pop2MultiWrite( 6, nType2Op);
1285 break;
1286 case TYPE2OP::RCURVELINE:
1287 i = 0;
1288 while( (i += 6) <= mnStackIdx)
1289 writeCurveTo( i, -6, -5, -4, -3, -2, -1 );
1290 i -= 6;
1291 while( (i += 2) <= mnStackIdx) {
1292 writeType1Val( mnValStack[i-2]);
1293 writeType1Val( mnValStack[i-1]);
1294 writeTypeOp( TYPE2OP::RLINETO);
1295 }
1296 clear();
1297 break;
1298 case TYPE2OP::RLINECURVE:
1299 i = 0;
1300 while( (i += 2) <= mnStackIdx-6) {
1301 writeType1Val( mnValStack[i-2]);
1302 writeType1Val( mnValStack[i-1]);
1303 writeTypeOp( TYPE2OP::RLINETO);
1304 }
1305 i -= 2;
1306 while( (i += 6) <= mnStackIdx)
1307 writeCurveTo( i, -6, -5, -4, -3, -2, -1 );
1308 clear();
1309 break;
1310 case TYPE2OP::VHCURVETO:
1311 case TYPE2OP::HVCURVETO:
1312 {
1313 bool bVert = (nType2Op == TYPE2OP::VHCURVETO);
1314 i = 0;
1315 nInt = 0;
1316 if( mnStackIdx & 1 )
1317 nInt = static_cast<int>(mnValStack[ --mnStackIdx ]);
1318 while( (i += 4) <= mnStackIdx) {
1319 // TODO: use writeCurveTo()
1320 if( bVert ) writeType1Val( 0 );
1321 writeType1Val( mnValStack[i-4] );
1322 if( !bVert ) writeType1Val( 0);
1323 writeType1Val( mnValStack[i-3] );
1324 writeType1Val( mnValStack[i-2] );
1325 if( !bVert ) writeType1Val( static_cast<ValType>((i==mnStackIdx) ? nInt : 0) );
1326 writeType1Val( mnValStack[i-1] );
1327 if( bVert ) writeType1Val( static_cast<ValType>((i==mnStackIdx) ? nInt : 0) );
1328 bVert = !bVert;
1329 writeTypeOp( TYPE2OP::RCURVETO);
1330 }
1331 }
1332 clear();
1333 break;
1334 case TYPE2OP::HHCURVETO:
1335 i = (mnStackIdx & 1);
1336 while( (i += 4) <= mnStackIdx) {
1337 if( i != 5)
1338 writeCurveTo( i, -4, 0, -3, -2, -1, 0);
1339 else
1340 writeCurveTo( i, -4, -5, -3, -2, -1, 0);
1341 }
1342 clear();
1343 break;
1344 case TYPE2OP::VVCURVETO:
1345 i = (mnStackIdx & 1);
1346 while( (i += 4) <= mnStackIdx) {
1347 if( i != 5)
1348 writeCurveTo( i, 0, -4, -3, -2, 0, -1);
1349 else
1350 writeCurveTo( i, -5, -4, -3, -2, 0, -1);
1351 }
1352 clear();
1353 break;
1354 case TYPE2OP::ENDCHAR:
1355 if (size() >= 4 && mbDoSeac)
1356 {
1357 // Deprecated seac-like use of endchar (Adobe Technical Note #5177,
1358 // Appendix C).
1359 auto achar = popVal();
1360 auto bchar = popVal();
1361 auto ady = popVal();
1362 auto adx = popVal();
1363 int nBase = {}, nAccent = {};
1364 if (getBaseAccent(bchar, achar, &nBase, &nAccent))
1365 {
1366 maExtraGlyphIds.push_back(nBase);
1367 maExtraGlyphIds.push_back(nAccent);
1368 writeType1Val(0); // TODO accent sb
1369 writeType1Val(adx);
1370 writeType1Val(ady);
1371 writeType1Val(bchar);
1372 writeType1Val(achar);
1373 writeTypeEsc(TYPE1OP::SEAC);
1374 }
1375 }
1376 if( mbNeedClose)
1377 writeTypeOp( TYPE1OP::CLOSEPATH);
1378 else
1379 updateWidth( size() >= 1);
1380 // mbNeedClose = true;
1381 writeTypeOp( TYPE1OP::ENDCHAR);
1382 break;
1383 default:
1384 if( ((nType2Op >= 32) && (nType2Op <= 255)) || (nType2Op == 28)) {
1385 --mpReadPtr;
1386 read2push();
1387 } else {
1388 popAll2Write( nType2Op);
1389 assert(false && "TODO?");
1390 }
1391 break;
1392 }
1393}
1394
1395void CffSubsetterContext::convertOneTypeEsc()
1396{
1397 const int nType2Esc = *(mpReadPtr++);
1398 ValType* pTop = &mnValStack[ mnStackIdx-1];
1399 // convert each T2op
1400 switch( nType2Esc) {
1401 case TYPE2OP::AND:
1402 assert( mnStackIdx >= 2 );
1403 pTop[0] = static_cast<ValType>(static_cast<int>(pTop[0]) & static_cast<int>(pTop[-1]));
1404 --mnStackIdx;
1405 break;
1406 case TYPE2OP::OR:
1407 assert( mnStackIdx >= 2 );
1408 pTop[0] = static_cast<ValType>(static_cast<int>(pTop[0]) | static_cast<int>(pTop[-1]));
1409 --mnStackIdx;
1410 break;
1411 case TYPE2OP::NOT:
1412 assert( mnStackIdx >= 1 );
1413 pTop[0] = ValType(pTop[0] == 0);
1414 break;
1415 case TYPE2OP::ABS:
1416 assert( mnStackIdx >= 1 );
1417 if( pTop[0] >= 0)
1418 break;
1419 [[fallthrough]];
1420 case TYPE2OP::NEG:
1421 assert( mnStackIdx >= 1 );
1422 pTop[0] = -pTop[0];
1423 break;
1424 case TYPE2OP::ADD:
1425 assert( mnStackIdx >= 2 );
1426 pTop[0] += pTop[-1];
1427 --mnStackIdx;
1428 break;
1429 case TYPE2OP::SUB:
1430 assert( mnStackIdx >= 2 );
1431 pTop[0] -= pTop[-1];
1432 --mnStackIdx;
1433 break;
1434 case TYPE2OP::MUL:
1435 assert( mnStackIdx >= 2 );
1436 if( pTop[-1])
1437 pTop[0] *= pTop[-1];
1438 --mnStackIdx;
1439 break;
1440 case TYPE2OP::DIV:
1441 assert( mnStackIdx >= 2 );
1442 if( pTop[-1])
1443 pTop[0] /= pTop[-1];
1444 --mnStackIdx;
1445 break;
1446 case TYPE2OP::EQ:
1447 assert( mnStackIdx >= 2 );
1448 pTop[0] = ValType(pTop[0] == pTop[-1]);
1449 --mnStackIdx;
1450 break;
1451 case TYPE2OP::DROP:
1452 assert( mnStackIdx >= 1 );
1453 --mnStackIdx;
1454 break;
1455 case TYPE2OP::PUT: {
1456 assert( mnStackIdx >= 2 );
1457 const int nIdx = static_cast<int>(pTop[0]);
1458 assert( nIdx >= 0 );
1459 assert( nIdx < NMAXTRANS );
1460 mnTransVals[ nIdx] = pTop[-1];
1461 mnStackIdx -= 2;
1462 break;
1463 }
1464 case TYPE2OP::GET: {
1465 assert( mnStackIdx >= 1 );
1466 const int nIdx = static_cast<int>(pTop[0]);
1467 assert( nIdx >= 0 );
1468 assert( nIdx < NMAXTRANS );
1469 pTop[0] = mnTransVals[ nIdx ];
1470 break;
1471 }
1472 case TYPE2OP::IFELSE: {
1473 assert( mnStackIdx >= 4 );
1474 if( pTop[-1] > pTop[0] )
1475 pTop[-3] = pTop[-2];
1476 mnStackIdx -= 3;
1477 break;
1478 }
1479 case TYPE2OP::RANDOM:
1480 pTop[+1] = 1234; // TODO
1481 ++mnStackIdx;
1482 break;
1483 case TYPE2OP::SQRT:
1484 // TODO: implement
1485 break;
1486 case TYPE2OP::DUP:
1487 assert( mnStackIdx >= 1 );
1488 pTop[+1] = pTop[0];
1489 ++mnStackIdx;
1490 break;
1491 case TYPE2OP::EXCH: {
1492 assert( mnStackIdx >= 2 );
1493 const ValType nVal = pTop[0];
1494 pTop[0] = pTop[-1];
1495 pTop[-1] = nVal;
1496 break;
1497 }
1498 case TYPE2OP::INDEX: {
1499 assert( mnStackIdx >= 1 );
1500 const int nVal = static_cast<int>(pTop[0]);
1501 assert( nVal >= 0 );
1502 assert( nVal < mnStackIdx-1 );
1503 pTop[0] = pTop[-1-nVal];
1504 break;
1505 }
1506 case TYPE2OP::ROLL: {
1507 assert( mnStackIdx >= 1 );
1508 const int nNum = static_cast<int>(pTop[0]);
1509 assert( nNum >= 0);
1510 assert( nNum < mnStackIdx-2 );
1511 (void)nNum; // TODO: implement
1512 // TODO: implement: const int nOfs = static_cast<int>(pTop[-1]);
1513 mnStackIdx -= 2;
1514 break;
1515 }
1516 case TYPE2OP::HFLEX1: {
1517 assert( mnStackIdx == 9);
1518
1519 writeCurveTo( mnStackIdx, -9, -8, -7, -6, -5, 0);
1520 writeCurveTo( mnStackIdx, -4, 0, -3, -2, -1, 0);
1521 // TODO: emulate hflex1 using othersubr call
1522
1523 mnStackIdx -= 9;
1524 }
1525 break;
1526 case TYPE2OP::HFLEX: {
1527 assert( mnStackIdx == 7);
1528 ValType* pX = &mnValStack[ mnStackIdx];
1529
1530 pX[+1] = -pX[-5]; // temp: +dy5==-dy2
1531 writeCurveTo( mnStackIdx, -7, 0, -6, -5, -4, 0);
1532 writeCurveTo( mnStackIdx, -3, 0, -2, +1, -1, 0);
1533 // TODO: emulate hflex using othersubr call
1534
1535 mnStackIdx -= 7;
1536 }
1537 break;
1538 case TYPE2OP::FLEX: {
1539 assert( mnStackIdx == 13 );
1540 writeCurveTo( mnStackIdx, -13, -12, -11, -10, -9, -8 );
1541 writeCurveTo( mnStackIdx, -7, -6, -5, -4, -3, -2 );
1542 // ignoring ValType nFlexDepth = mnValStack[ mnStackIdx-1 ];
1543 mnStackIdx -= 13;
1544 }
1545 break;
1546 case TYPE2OP::FLEX1: {
1547 assert( mnStackIdx == 11 );
1548 // write the first part of the flex1-hinted curve
1549 writeCurveTo( mnStackIdx, -11, -10, -9, -8, -7, -6 );
1550
1551 // determine if nD6 is horizontal or vertical
1552 const int i = mnStackIdx;
1553 ValType nDeltaX = mnValStack[i-11] + mnValStack[i-9] + mnValStack[i-7] + mnValStack[i-5] + mnValStack[i-3];
1554 if( nDeltaX < 0 ) nDeltaX = -nDeltaX;
1555 ValType nDeltaY = mnValStack[i-10] + mnValStack[i-8] + mnValStack[i-6] + mnValStack[i-4] + mnValStack[i-2];
1556 if( nDeltaY < 0 ) nDeltaY = -nDeltaY;
1557 const bool bVertD6 = (nDeltaY > nDeltaX);
1558
1559 // write the second part of the flex1-hinted curve
1560 if( !bVertD6 )
1561 writeCurveTo( mnStackIdx, -5, -4, -3, -2, -1, 0);
1562 else
1563 writeCurveTo( mnStackIdx, -5, -4, -3, -2, 0, -1);
1564 mnStackIdx -= 11;
1565 }
1566 break;
1567 default:
1568 SAL_WARN("vcl.fonts", "unhandled type2esc " << nType2Esc);
1569 assert( false);
1570 break;
1571 }
1572}
1573
1574void CffSubsetterContext::callType2Subr( bool bGlobal, int nSubrNumber)
1575{
1576 const U8* const pOldReadPtr = mpReadPtr;
1577 const U8* const pOldReadEnd = mpReadEnd;
1578
1579 if( bGlobal ) {
1580 nSubrNumber += mnGlobalSubrBias;
1581 seekIndexData( mnGlobalSubrBase, nSubrNumber);
1582 } else {
1583 nSubrNumber += mpCffLocal->mnLocalSubrBias;
1584 seekIndexData( mpCffLocal->mnLocalSubrBase, nSubrNumber);
1585 }
1586
1587 while( mpReadPtr < mpReadEnd)
1588 convertOneTypeOp();
1589
1590 mpReadPtr = pOldReadPtr;
1591 mpReadEnd = pOldReadEnd;
1592}
1593
1594int CffSubsetterContext::convert2Type1Ops( CffLocal* pCffLocal, const U8* const pT2Ops, int nT2Len, U8* const pT1Ops)
1595{
1596 mpCffLocal = pCffLocal;
1597
1598 // prepare the charstring conversion
1599 mpWritePtr = pT1Ops;
1600 U8 aType1Ops[ MAX_T1OPS_SIZE];
1601 if( !pT1Ops)
1602 mpWritePtr = aType1Ops;
1603 *const_cast<U8**>(&pT1Ops) = mpWritePtr;
1604
1605 // prepend random seed for T1crypt
1606 *(mpWritePtr++) = 0x48;
1607 *(mpWritePtr++) = 0x44;
1608 *(mpWritePtr++) = 0x55;
1609 *(mpWritePtr++) = ' ';
1610
1611 // convert the Type2 charstring to Type1
1612 mpReadPtr = pT2Ops;
1613 mpReadEnd = pT2Ops + nT2Len;
1614 // prepend "hsbw" or "sbw"
1615 // TODO: only emit hsbw when charwidth is known
1616 writeType1Val(0); // TODO: aSubsetterContext.getLeftSideBearing();
1617 U8* pCharWidthPtr=mpWritePtr; // need to overwrite that later
1618 // pad out 5 bytes for the char width with default val 1000 (to be
1619 // filled with the actual value below)
1620 *(mpWritePtr++) = 255;
1621 *(mpWritePtr++) = static_cast<U8>(0);
1622 *(mpWritePtr++) = static_cast<U8>(0);
1623 *(mpWritePtr++) = static_cast<U8>(250);
1624 *(mpWritePtr++) = static_cast<U8>(124);
1625 writeTypeOp(TYPE1OP::HSBW);
1626 mbNeedClose = false;
1627 mbIgnoreHints = false;
1628 mnHintSize=mnHorzHintSize=mnStackIdx=0; maCharWidth=-1;//#######
1629 mnCntrMask = 0;
1630 while( mpReadPtr < mpReadEnd)
1631 convertOneTypeOp();
1632 if( maCharWidth != -1 )
1633 {
1634 // overwrite earlier charWidth value, which we only now have
1635 // parsed out of mpReadPtr buffer (by way of
1636 // convertOneTypeOp()s above)
1637 const int nInt = static_cast<int>(maCharWidth);
1638 *(pCharWidthPtr++) = 255;
1639 *(pCharWidthPtr++) = static_cast<U8>(nInt >> 24);
1640 *(pCharWidthPtr++) = static_cast<U8>(nInt >> 16);
1641 *(pCharWidthPtr++) = static_cast<U8>(nInt >> 8);
1642 *(pCharWidthPtr++) = static_cast<U8>(nInt);
1643 }
1644
1645 const int nType1Len = mpWritePtr - pT1Ops;
1646
1647 // encrypt the Type1 charstring
1648 unsigned nRDCryptR = 4330; // TODO: mnRDCryptSeed;
1649 for( U8* p = pT1Ops; p < mpWritePtr; ++p) {
1650 *p ^= (nRDCryptR >> 8);
1651 nRDCryptR = (*p + nRDCryptR) * 52845 + 22719;
1652 }
1653
1654 return nType1Len;
1655}
1656
1657RealType CffSubsetterContext::readRealVal()
1658{
1659 // TODO: more thorough number validity test
1660 bool bComma = false;
1661 int nExpVal = 0;
1662 int nExpSign = 0;
1663 S64 nNumber = 0;
1664 RealType fReal = +1.0;
1665 for(;;){
1666 const U8 c = *(mpReadPtr++); // read nibbles
1667 // parse high nibble
1668 const U8 nH = c >> 4U;
1669 if( nH <= 9) {
1670 nNumber = nNumber * 10 + nH;
1671 --nExpVal;
1672 } else if( nH == 10) { // comma
1673 nExpVal = 0;
1674 bComma = true;
1675 } else if( nH == 11) { // +exp
1676 fReal *= nNumber;
1677 nExpSign = +1;
1678 nNumber = 0;
1679 } else if( nH == 12) { // -exp
1680 fReal *= nNumber;
1681 nExpSign = -1;
1682 nNumber = 0;
1683 } else if( nH == 13) { // reserved
1684 // TODO: ignore or error?
1685 } else if( nH == 14) // minus
1686 fReal = -fReal;
1687 else if( nH == 15) // end
1688 break;
1689 // parse low nibble
1690 const U8 nL = c & 0x0F;
1691 if( nL <= 9) {
1692 nNumber = nNumber * 10 + nL;
1693 --nExpVal;
1694 } else if( nL == 10) { // comma
1695 nExpVal = 0;
1696 bComma = true;
1697 } else if( nL == 11) { // +exp
1698 fReal *= nNumber;
1699 nNumber = 0;
1700 nExpSign = +1;
1701 } else if( nL == 12) { // -exp
1702 fReal *= nNumber;
1703 nNumber = 0;
1704 nExpSign = -1;
1705 } else if( nL == 13) { // reserved
1706 // TODO: ignore or error?
1707 } else if( nL == 14) // minus
1708 fReal = -fReal;
1709 else if( nL == 15) // end
1710 break;
1711 }
1712
1713 // merge exponents
1714 if( !bComma)
1715 nExpVal = 0;
1716 if( !nExpSign) { fReal *= nNumber;}
1717 else if( nExpSign > 0) { nExpVal += static_cast<int>(nNumber);}
1718 else if( nExpSign < 0) { nExpVal -= static_cast<int>(nNumber);}
1719
1720 // apply exponents
1721 if( !nExpVal) { /*nothing to apply*/}
1722 else if( nExpVal > 0) { while( --nExpVal >= 0) fReal *= 10.0;}
1723 else if( nExpVal < 0) { while( ++nExpVal <= 0) fReal /= 10.0;}
1724 return fReal;
1725}
1726
1727// prepare to access an element inside a CFF/CID index table
1728int CffSubsetterContext::seekIndexData( int nIndexBase, int nDataIndex)
1729{
1730 assert( (nIndexBase > 0) && (mpBasePtr + nIndexBase + 3 <= mpBaseEnd));
1731 if( nDataIndex < 0)
1732 return -1;
1733 mpReadPtr = mpBasePtr + nIndexBase;
1734 const int nDataCount = (mpReadPtr[0]<<8) + mpReadPtr[1];
1735 if( nDataIndex >= nDataCount)
1736 return -1;
1737 const int nDataOfsSz = mpReadPtr[2];
1738 mpReadPtr += 3 + (nDataOfsSz * nDataIndex);
1739 int nOfs1 = 0;
1740 switch( nDataOfsSz) {
1741 default: SAL_WARN("vcl.fonts", "\tINVALID nDataOfsSz=" << nDataOfsSz); return -1;
1742 case 1: nOfs1 = mpReadPtr[0]; break;
1743 case 2: nOfs1 = (mpReadPtr[0]<<8) + mpReadPtr[1]; break;
1744 case 3: nOfs1 = (mpReadPtr[0]<<16) + (mpReadPtr[1]<<8) + mpReadPtr[2]; break;
1745 case 4: nOfs1 = (mpReadPtr[0]<<24) + (mpReadPtr[1]<<16) + (mpReadPtr[2]<<8) + mpReadPtr[3]; break;
1746 }
1747 mpReadPtr += nDataOfsSz;
1748
1749 int nOfs2 = 0;
1750 switch( nDataOfsSz) {
1751 case 1: nOfs2 = mpReadPtr[0]; break;
1752 case 2: nOfs2 = (mpReadPtr[0]<<8) + mpReadPtr[1]; break;
1753 case 3: nOfs2 = (mpReadPtr[0]<<16) + (mpReadPtr[1]<<8) + mpReadPtr[2]; break;
1754 case 4: nOfs2 = (mpReadPtr[0]<<24) + (mpReadPtr[1]<<16) + (mpReadPtr[2]<<8) + mpReadPtr[3]; break;
1755 }
1756
1757 mpReadPtr = mpBasePtr + (nIndexBase + 2) + nDataOfsSz * (nDataCount + 1) + nOfs1;
1758 mpReadEnd = mpReadPtr + (nOfs2 - nOfs1);
1759 assert( nOfs1 >= 0);
1760 assert( nOfs2 >= nOfs1);
1761 assert( mpReadPtr <= mpBaseEnd);
1762 assert( mpReadEnd <= mpBaseEnd);
1763 return (nOfs2 - nOfs1);
1764}
1765
1766// skip over a CFF/CID index table
1767void CffSubsetterContext::seekIndexEnd( int nIndexBase)
1768{
1769 assert( (nIndexBase > 0) && (mpBasePtr + nIndexBase + 3 <= mpBaseEnd));
1770 mpReadPtr = mpBasePtr + nIndexBase;
1771 const int nDataCount = (mpReadPtr[0]<<8) + mpReadPtr[1];
1772 const int nDataOfsSz = mpReadPtr[2];
1773 mpReadPtr += 3 + nDataOfsSz * nDataCount;
1774 assert( mpReadPtr <= mpBaseEnd);
1775 int nEndOfs = 0;
1776 switch( nDataOfsSz) {
1777 default: SAL_WARN("vcl.fonts", "\tINVALID nDataOfsSz=" << nDataOfsSz); return;
1778 case 1: nEndOfs = mpReadPtr[0]; break;
1779 case 2: nEndOfs = (mpReadPtr[0]<<8) + mpReadPtr[1]; break;
1780 case 3: nEndOfs = (mpReadPtr[0]<<16) + (mpReadPtr[1]<<8) + mpReadPtr[2];break;
1781 case 4: nEndOfs = (mpReadPtr[0]<<24) + (mpReadPtr[1]<<16) + (mpReadPtr[2]<<8) + mpReadPtr[3]; break;
1782 }
1783 mpReadPtr += nDataOfsSz;
1784 mpReadPtr += nEndOfs - 1;
1785 mpReadEnd = mpBaseEnd;
1786 assert( nEndOfs >= 0);
1787 assert( mpReadEnd <= mpBaseEnd);
1788}
1789
1790// initialize FONTDICT specific values
1791CffLocal::CffLocal()
1792: mnPrivDictBase( 0)
1793, mnPrivDictSize( 0)
1794, mnLocalSubrOffs( 0)
1795, mnLocalSubrBase( 0)
1796, mnLocalSubrBias( 0)
1797, maNominalWidth( 0)
1798, maDefaultWidth( 0)
1799, maStemStdHW( 0)
1800, maStemStdVW( 0)
1801, mfBlueScale( 0.0)
1802, mfBlueShift( 0.0)
1803, mfBlueFuzz( 0.0)
1804, mfExpFactor( 0.0)
1805, mnLangGroup( 0)
1806, mbForceBold( false)
1807{
1808}
1809
1810CffGlobal::CffGlobal()
1811: mnNameIdxBase( 0)
1812, mnStringIdxBase( 0)
1813, mbCIDFont( false)
1814, mnCharStrBase( 0)
1815, mnCharStrCount( 0)
1816, mnCharsetBase( 0)
1817, mnGlobalSubrBase( 0)
1818, mnGlobalSubrCount( 0)
1819, mnGlobalSubrBias( 0)
1820, mnFDSelectBase( 0)
1821, mnFontDictBase( 0)
1822, mnFDAryCount( 1)
1823, mnFontNameSID( 0)
1824, mnFullNameSID( 0)
1825{
1826}
1827
1828bool CffSubsetterContext::initialCffRead()
1829{
1830 // get the CFFHeader
1831 mpReadPtr = mpBasePtr;
1832 const U8 nVerMajor = *(mpReadPtr++);
1833 const U8 nVerMinor = *(mpReadPtr++);
1834 const U8 nHeaderSize = *(mpReadPtr++);
1835 const U8 nOffsetSize = *(mpReadPtr++);
1836 // TODO: is the version number useful for anything else?
1837 assert( (nVerMajor == 1) && (nVerMinor == 0));
1838 (void)(nVerMajor + nVerMinor + nOffsetSize); // avoid compiler warnings
1839
1840 // prepare access to the NameIndex
1841 mnNameIdxBase = nHeaderSize;
1842 mpReadPtr = mpBasePtr + nHeaderSize;
1843 seekIndexEnd( mnNameIdxBase);
1844
1845 // get the TopDict index
1846 const sal_Int32 nTopDictBase = getReadOfs();
1847 const int nTopDictCount = (mpReadPtr[0]<<8) + mpReadPtr[1];
1848 if( nTopDictCount) {
1849 for( int i = 0; i < nTopDictCount; ++i) {
1850 seekIndexData( nTopDictBase, i);
1851 while( mpReadPtr < mpReadEnd)
1852 readDictOp();
1853 assert( mpReadPtr == mpReadEnd);
1854 }
1855 }
1856
1857 // prepare access to the String index
1858 mnStringIdxBase = getReadOfs();
1859 seekIndexEnd( mnStringIdxBase);
1860
1861 // prepare access to the GlobalSubr index
1862 mnGlobalSubrBase = getReadOfs();
1863 mnGlobalSubrCount = (mpReadPtr[0]<<8) + mpReadPtr[1];
1864 mnGlobalSubrBias = (mnGlobalSubrCount<1240)?107:(mnGlobalSubrCount<33900)?1131:32768;
1865 // skip past the last GlobalSubr entry
1866// seekIndexEnd( mnGlobalSubrBase);
1867
1868 // get/skip the Encodings (we got mnEncodingBase from TOPDICT)
1869// seekEncodingsEnd( mnEncodingBase);
1870 // get/skip the Charsets (we got mnCharsetBase from TOPDICT)
1871// seekCharsetsEnd( mnCharStrBase);
1872 // get/skip FDSelect (CID only) data
1873
1874 // prepare access to the CharStrings index (we got the base from TOPDICT)
1875 mpReadPtr = mpBasePtr + mnCharStrBase;
1876 mnCharStrCount = (mpReadPtr[0]<<8) + mpReadPtr[1];
1877// seekIndexEnd( mnCharStrBase);
1878
1879 // read the FDArray index (CID only)
1880 if( mbCIDFont) {
1881// assert( mnFontDictBase == tellRel());
1882 mpReadPtr = mpBasePtr + mnFontDictBase;
1883 mnFDAryCount = (mpReadPtr[0]<<8) + mpReadPtr[1];
1884 if (o3tl::make_unsigned(mnFDAryCount) >= SAL_N_ELEMENTS(maCffLocal))
1885 {
1886 SAL_INFO("vcl.fonts", "CffSubsetterContext: too many CFF in font");
1887 return false;
1888 }
1889
1890 // read FDArray details to get access to the PRIVDICTs
1891 for( int i = 0; i < mnFDAryCount; ++i) {
1892 mpCffLocal = &maCffLocal[i];
1893 seekIndexData( mnFontDictBase, i);
1894 while( mpReadPtr < mpReadEnd)
1895 readDictOp();
1896 assert( mpReadPtr == mpReadEnd);
1897 }
1898 }
1899
1900 for( int i = 0; i < mnFDAryCount; ++i) {
1901 mpCffLocal = &maCffLocal[i];
1902
1903 // get the PrivateDict index
1904 // (we got mnPrivDictSize and mnPrivDictBase from TOPDICT or FDArray)
1905 if( mpCffLocal->mnPrivDictSize != 0) {
1906 assert( mpCffLocal->mnPrivDictSize > 0);
1907 // get the PrivDict data
1908 mpReadPtr = mpBasePtr + mpCffLocal->mnPrivDictBase;
1909 mpReadEnd = mpReadPtr + mpCffLocal->mnPrivDictSize;
1910 assert( mpReadEnd <= mpBaseEnd);
1911 // read PrivDict details
1912 while( mpReadPtr < mpReadEnd)
1913 readDictOp();
1914 }
1915
1916 // prepare access to the LocalSubrs (we got mnLocalSubrOffs from PRIVDICT)
1917 if( mpCffLocal->mnLocalSubrOffs) {
1918 // read LocalSubrs summary
1919 mpCffLocal->mnLocalSubrBase = mpCffLocal->mnPrivDictBase + mpCffLocal->mnLocalSubrOffs;
1920 mpReadPtr = mpBasePtr + mpCffLocal->mnLocalSubrBase;
1921 const int nSubrCount = (mpReadPtr[0] << 8) + mpReadPtr[1];
1922 mpCffLocal->mnLocalSubrBias = (nSubrCount<1240)?107:(nSubrCount<33900)?1131:32768;
1923// seekIndexEnd( mpCffLocal->mnLocalSubrBase);
1924 }
1925 }
1926
1927 // ignore the Notices info
1928
1929 return true;
1930}
1931
1932// get a cstring from a StringID
1933OString CffSubsetterContext::getString( int nStringID)
1934{
1935 // get a standard string if possible
1936 const static int nStdStrings = SAL_N_ELEMENTS(pStringIds);
1937 if( (nStringID >= 0) && (nStringID < nStdStrings))
1938 return pStringIds[ nStringID];
1939
1940 // else get the string from the StringIndex table
1941 comphelper::ValueRestorationGuard pReadPtr(mpReadPtr);
1942 comphelper::ValueRestorationGuard pReadEnd(mpReadEnd);
1943 nStringID -= nStdStrings;
1944 int nLen = seekIndexData( mnStringIdxBase, nStringID);
1945 // assert( nLen >= 0);
1946 // TODO: just return the undecorated name
1947 if( nLen < 0) {
1948 return "name[" + OString::number(nStringID) + "].notfound!";
1949 } else {
1950 const int nMaxLen = 2560 - 1;
1951 if( nLen >= nMaxLen)
1952 nLen = nMaxLen; // TODO: still needed?
1953 return OString(reinterpret_cast<char const *>(mpReadPtr), nLen);
1954 }
1955}
1956
1957// access a CID's FDSelect table
1958int CffSubsetterContext::getFDSelect( int nGlyphIndex) const
1959{
1960 assert( nGlyphIndex >= 0);
1961 assert( nGlyphIndex < mnCharStrCount);
1962 if( !mbCIDFont)
1963 return 0;
1964
1965 const U8* pReadPtr = mpBasePtr + mnFDSelectBase;
1966 const U8 nFDSelFormat = *(pReadPtr++);
1967 switch( nFDSelFormat) {
1968 case 0: { // FDSELECT format 0
1969 pReadPtr += nGlyphIndex;
1970 const U8 nFDIdx = *(pReadPtr++);
1971 return nFDIdx;
1972 } //break;
1973 case 3: { // FDSELECT format 3
1974 const U16 nRangeCount = (pReadPtr[0]<<8) + pReadPtr[1];
1975 assert( nRangeCount > 0);
1976 assert( nRangeCount <= mnCharStrCount);
1977 U16 nPrev = (pReadPtr[2]<<8) + pReadPtr[3];
1978 assert( nPrev == 0);
1979 (void)nPrev;
1980 pReadPtr += 4;
1981 // TODO? binary search
1982 for( int i = 0; i < nRangeCount; ++i) {
1983 const U8 nFDIdx = pReadPtr[0];
1984 const U16 nNext = (pReadPtr[1]<<8) + pReadPtr[2];
1985 assert( nPrev < nNext);
1986 if( nGlyphIndex < nNext)
1987 return nFDIdx;
1988 pReadPtr += 3;
1989 nPrev = nNext;
1990 }
1991 } break;
1992 default: // invalid FDselect format
1993 SAL_WARN("vcl.fonts", "invalid CFF.FdselType=" << nFDSelFormat);
1994 break;
1995 }
1996
1997 assert( false);
1998 return -1;
1999}
2000
2001int CffSubsetterContext::getGlyphSID( int nGlyphIndex) const
2002{
2003 if( nGlyphIndex == 0)
2004 return 0; // ".notdef"
2005 assert( nGlyphIndex >= 0);
2006 assert( nGlyphIndex < mnCharStrCount);
2007 if( (nGlyphIndex < 0) || (nGlyphIndex >= mnCharStrCount))
2008 return -1;
2009
2010 // get the SID/CID from the Charset table
2011 const U8* pReadPtr = mpBasePtr + mnCharsetBase;
2012 const U8 nCSetFormat = *(pReadPtr++);
2013 int nGlyphsToSkip = nGlyphIndex - 1;
2014 switch( nCSetFormat) {
2015 case 0: // charset format 0
2016 pReadPtr += 2 * nGlyphsToSkip;
2017 nGlyphsToSkip = 0;
2018 break;
2019 case 1: // charset format 1
2020 while( nGlyphsToSkip >= 0) {
2021 const int nLeft = pReadPtr[2];
2022 if( nGlyphsToSkip <= nLeft)
2023 break;
2024 nGlyphsToSkip -= nLeft + 1;
2025 pReadPtr += 3;
2026 }
2027 break;
2028 case 2: // charset format 2
2029 while( nGlyphsToSkip >= 0) {
2030 const int nLeft = (pReadPtr[2]<<8) + pReadPtr[3];
2031 if( nGlyphsToSkip <= nLeft)
2032 break;
2033 nGlyphsToSkip -= nLeft + 1;
2034 pReadPtr += 4;
2035 }
2036 break;
2037 default:
2038 SAL_WARN("vcl.fonts", "ILLEGAL CFF-Charset format " << nCSetFormat);
2039 return -2;
2040 }
2041
2042 int nSID = (pReadPtr[0]<<8) + pReadPtr[1];
2043 nSID += nGlyphsToSkip;
2044 // NOTE: for CID-fonts the resulting SID is interpreted as CID
2045 return nSID;
2046}
2047
2048// NOTE: the result becomes invalid with the next call to this method
2049OString CffSubsetterContext::getGlyphName( int nGlyphIndex)
2050{
2051 // the first glyph is always the .notdef glyph
2052 if( nGlyphIndex == 0)
2053 return tok_notdef;
2054
2055 // get the glyph specific name
2056 const int nSID = getGlyphSID( nGlyphIndex);
2057 if( nSID < 0) // default glyph name
2058 {
2059 char aDefaultGlyphName[64];
2060 o3tl::sprintf( aDefaultGlyphName, "gly%03d", nGlyphIndex);
2061 return aDefaultGlyphName;
2062 }
2063 else if( mbCIDFont) // default glyph name in CIDs
2064 {
2065 char aDefaultGlyphName[64];
2066 o3tl::sprintf( aDefaultGlyphName, "cid%03d", nSID);
2067 return aDefaultGlyphName;
2068 }
2069 else { // glyph name from string table
2070 auto const pSidName = getString( nSID);
2071 // check validity of glyph name
2072 const char* p = pSidName.getStr();
2073 while( (*p >= '0') && (*p <= 'z')) ++p;
2074 if( (p >= pSidName.getStr()+1) && (*p == '\0'))
2075 return pSidName;
2076 // if needed invent a fallback name
2077 char aDefaultGlyphName[64];
2078 o3tl::sprintf( aDefaultGlyphName, "bad%03d", nSID);
2079 return aDefaultGlyphName;
2080 }
2081}
2082
2083bool CffSubsetterContext::getBaseAccent(ValType aBase, ValType aAccent, int* nBase, int* nAccent)
2084{
2085 bool bBase = false, bAccent = false;
2086 for (int i = 0; i < mnCharStrCount; i++)
2087 {
2088 OString pGlyphName = getGlyphName(i);
2089 if (pGlyphName == pStandardEncoding[int(aBase)])
2090 {
2091 *nBase = i;
2092 bBase = true;
2093 }
2094 if (pGlyphName == pStandardEncoding[int(aAccent)])
2095 {
2096 *nAccent = i;
2097 bAccent = true;
2098 }
2099 if (bBase && bAccent)
2100 return true;
2101 }
2102 return false;
2103}
2104
2105namespace {
2106
2107class Type1Emitter
2108{
2109public:
2110 explicit Type1Emitter( SvStream* pOutFile, bool bPfbSubset);
2111 ~Type1Emitter();
2112 void setSubsetName( const char* );
2113
2114 size_t emitRawData( const char* pData, size_t nLength) const;
2115 void emitAllRaw();
2116 void emitAllHex();
2117 void emitAllCrypted();
2118 int tellPos() const;
2119 void updateLen( int nTellPos, size_t nLength);
2120 void emitValVector( const char* pLineHead, const char* pLineTail, const std::vector<ValType>&);
2121private:
2122 SvStream* mpFileOut;
2123 unsigned mnEECryptR;
2124public:
2125 OStringBuffer maBuffer;
2126
2127 char maSubsetName[256];
2128 bool mbPfbSubset;
2129 int mnHexLineCol;
2130};
2131
2132}
2133
2134Type1Emitter::Type1Emitter( SvStream* pOutFile, bool bPfbSubset)
2135: mpFileOut( pOutFile)
2136, mnEECryptR( 55665) // default eexec seed, TODO: mnEECryptSeed
2137, mbPfbSubset( bPfbSubset)
2138, mnHexLineCol( 0)
2139{
2140 maSubsetName[0] = '\0';
2141}
2142
2143Type1Emitter::~Type1Emitter()
2144{
2145 if( !mpFileOut)
2146 return;
2147 mpFileOut = nullptr;
2148}
2149
2150void Type1Emitter::setSubsetName( const char* pSubsetName)
2151{
2152 maSubsetName[0] = '\0';
2153 if( pSubsetName)
2154 strncpy( maSubsetName, pSubsetName, sizeof(maSubsetName) - 1);
2155 maSubsetName[sizeof(maSubsetName)-1] = '\0';
2156}
2157
2158int Type1Emitter::tellPos() const
2159{
2160 int nTellPos = mpFileOut->Tell();
2161 return nTellPos;
2162}
2163
2164void Type1Emitter::updateLen( int nTellPos, size_t nLength)
2165{
2166 // update PFB segment header length
2167 U8 cData[4];
2168 cData[0] = static_cast<U8>(nLength >> 0);
2169 cData[1] = static_cast<U8>(nLength >> 8);
2170 cData[2] = static_cast<U8>(nLength >> 16);
2171 cData[3] = static_cast<U8>(nLength >> 24);
2172 const tools::Long nCurrPos = mpFileOut->Tell();
2173 if (nCurrPos < 0)
2174 return;
2175 if (mpFileOut->Seek(nTellPos) != static_cast<sal_uInt64>(nTellPos))
2176 return;
2177 mpFileOut->WriteBytes(cData, sizeof(cData));
2178 mpFileOut->Seek(nCurrPos);
2179}
2180
2181inline size_t Type1Emitter::emitRawData(const char* pData, size_t nLength) const
2182{
2183 return mpFileOut->WriteBytes( pData, nLength );
2184}
2185
2186inline void Type1Emitter::emitAllRaw()
2187{
2188 // writeout raw data
2189 emitRawData( maBuffer.getStr(), maBuffer.getLength());
2190 // reset the raw buffer
2191 maBuffer.setLength(0);
2192}
2193
2194inline void Type1Emitter::emitAllHex()
2195{
2196 auto const end = maBuffer.getStr() + maBuffer.getLength();
2197 for( const char* p = maBuffer.getStr(); p < end;) {
2198 // convert binary chunk to hex
2199 char aHexBuf[0x4000];
2200 char* pOut = aHexBuf;
2201 while( (p < end) && (pOut < aHexBuf+sizeof(aHexBuf)-4)) {
2202 // convert each byte to hex
2203 char cNibble = (static_cast<unsigned char>(*p) >> 4) & 0x0F;
2204 cNibble += (cNibble < 10) ? '0' : 'A'-10;
2205 *(pOut++) = cNibble;
2206 cNibble = *(p++) & 0x0F;
2207 cNibble += (cNibble < 10) ? '0' : 'A'-10;
2208 *(pOut++) = cNibble;
2209 // limit the line length
2210 if( (++mnHexLineCol & 0x3F) == 0)
2211 *(pOut++) = '\n';
2212 }
2213 // writeout hex-converted chunk
2214 emitRawData( aHexBuf, pOut-aHexBuf);
2215 }
2216 // reset the raw buffer
2217 maBuffer.setLength(0);
2218}
2219
2220void Type1Emitter::emitAllCrypted()
2221{
2222 // apply t1crypt
2223 for( sal_Int32 i = 0; i < maBuffer.getLength(); ++i) {
2224 maBuffer[i] ^= (mnEECryptR >> 8);
2225 mnEECryptR = (static_cast<U8>(maBuffer[i]) + mnEECryptR) * 52845 + 22719;
2226 }
2227
2228 // emit the t1crypt result
2229 if( mbPfbSubset)
2230 emitAllRaw();
2231 else
2232 emitAllHex();
2233}
2234
2235// #i110387# quick-and-dirty double->ascii conversion
2236// also strip off trailing zeros in fraction while we are at it
2237static OString dbl2str( double fVal)
2238{
2239 return rtl::math::doubleToString(fVal, rtl_math_StringFormat_G, 6, '.', true);
2240}
2241
2242void Type1Emitter::emitValVector( const char* pLineHead, const char* pLineTail,
2243 const std::vector<ValType>& rVector)
2244{
2245 // ignore empty vectors
2246 if( rVector.empty())
2247 return;
2248
2249 // emit the line head
2250 maBuffer.append( pLineHead);
2251 // emit the vector values
2252 std::vector<ValType>::value_type aVal = 0;
2253 for( std::vector<ValType>::const_iterator it = rVector.begin();;) {
2254 aVal = *it;
2255 if( ++it == rVector.end() )
2256 break;
2257 maBuffer.append(dbl2str( aVal));
2258 maBuffer.append(' ');
2259 }
2260 // emit the last value
2261 maBuffer.append(dbl2str( aVal));
2262 // emit the line tail
2263 maBuffer.append( pLineTail);
2264}
2265
2266void CffSubsetterContext::convertCharStrings(const sal_GlyphId* pGlyphIds, int nGlyphCount,
2267 std::vector<CharString>& rCharStrings)
2268{
2269 // If we are doing extra glyphs used for seac operator, check for already
2270 // converted glyphs.
2271 bool bCheckDuplicates = !rCharStrings.empty();
2272 rCharStrings.reserve(rCharStrings.size() + nGlyphCount);
2273 for (int i = 0; i < nGlyphCount; ++i)
2274 {
2275 const int nCffGlyphId = pGlyphIds[i];
2276 assert((nCffGlyphId >= 0) && (nCffGlyphId < mnCharStrCount));
2277
2278 if (!bCheckDuplicates)
2279 {
2280 const auto& it
2281 = std::find_if(rCharStrings.begin(), rCharStrings.end(),
2282 [&](const CharString& c) { return c.nCffGlyphId == nCffGlyphId; });
2283 if (it != rCharStrings.end())
2284 continue;
2285 }
2286
2287 // get privdict context matching to the glyph
2288 const int nFDSelect = getFDSelect(nCffGlyphId);
2289 if (nFDSelect < 0)
2290 continue;
2291 mpCffLocal = &maCffLocal[nFDSelect];
2292
2293 // convert the Type2op charstring to its Type1op counterpart
2294 const int nT2Len = seekIndexData(mnCharStrBase, nCffGlyphId);
2295 assert(nT2Len > 0);
2296
2297 CharString aCharString;
2298 const int nT1Len = convert2Type1Ops(mpCffLocal, mpReadPtr, nT2Len, aCharString.aOps);
2299 aCharString.nLen = nT1Len;
2300 aCharString.nCffGlyphId = nCffGlyphId;
2301
2302 rCharStrings.push_back(aCharString);
2303 }
2304}
2305
2306void CffSubsetterContext::emitAsType1( Type1Emitter& rEmitter,
2307 const sal_GlyphId* pReqGlyphIds, const U8* pReqEncoding,
2308 int nGlyphCount, FontSubsetInfo& rFSInfo)
2309{
2310 // prepare some fontdirectory details
2311 static const int nUniqueIdBase = 4100000; // using private-interchange UniqueIds
2312 static int nUniqueId = nUniqueIdBase;
2313 ++nUniqueId;
2314
2315 char* pFontName = rEmitter.maSubsetName;
2316 if( !*pFontName ) {
2317 if( mnFontNameSID) {
2318 // get the fontname directly if available
2319 strncpy(
2320 pFontName, getString( mnFontNameSID).getStr(), sizeof(rEmitter.maSubsetName) - 1);
2321 pFontName[sizeof(rEmitter.maSubsetName) - 1] = 0;
2322 } else if( mnFullNameSID) {
2323 // approximate fontname as fullname-whitespace
2324 auto const str = getString( mnFullNameSID);
2325 const char* pI = str.getStr();
2326 char* pO = pFontName;
2327 const char* pLimit = pFontName + sizeof(rEmitter.maSubsetName) - 1;
2328 while( pO < pLimit) {
2329 const char c = *(pI++);
2330 if( c != ' ')
2331 *(pO++) = c;
2332 if( !c)
2333 break;
2334 }
2335 *pO = '\0';
2336 } else {
2337 // fallback name of last resort
2338 strncpy( pFontName, "DummyName", sizeof(rEmitter.maSubsetName));
2339 }
2340 }
2341 const char* pFullName = pFontName;
2342 const char* pFamilyName = pFontName;
2343
2344 // create a PFB+Type1 header
2345 if( rEmitter.mbPfbSubset ) {
2346 static const char aPfbHeader[] = "\x80\x01\x00\x00\x00\x00";
2347 rEmitter.emitRawData( aPfbHeader, sizeof(aPfbHeader)-1);
2348 }
2349
2350 rEmitter.maBuffer.append(
2351 "%!FontType1-1.0: " + OString::Concat(rEmitter.maSubsetName) + " 001.003\n");
2352 // emit TOPDICT
2353 rEmitter.maBuffer.append(
2354 "11 dict begin\n" // TODO: dynamic entry count for TOPDICT
2355 "/FontType 1 def\n"
2356 "/PaintType 0 def\n");
2357 rEmitter.maBuffer.append( "/FontName /" + OString::Concat(rEmitter.maSubsetName) + " def\n");
2358 rEmitter.maBuffer.append( "/UniqueID " + OString::number(nUniqueId) + " def\n");
2359 // emit FontMatrix
2360 if( maFontMatrix.size() == 6)
2361 rEmitter.emitValVector( "/FontMatrix [", "]readonly def\n", maFontMatrix);
2362 else // emit default FontMatrix if needed
2363 rEmitter.maBuffer.append( "/FontMatrix [0.001 0 0 0.001 0 0]readonly def\n");
2364
2365 // emit FontBBox
2366 ValType fXFactor = 1.0;
2367 ValType fYFactor = 1.0;
2368 if( maFontMatrix.size() >= 4) {
2369 fXFactor = 1000.0F * maFontMatrix[0];
2370 fYFactor = 1000.0F * maFontMatrix[3];
2371 }
2372
2373 auto aFontBBox = maFontBBox;
2374 if (rFSInfo.m_bFilled)
2375 aFontBBox = {
2376 rFSInfo.m_aFontBBox.Left() / fXFactor, rFSInfo.m_aFontBBox.Top() / fYFactor,
2377 rFSInfo.m_aFontBBox.Right() / fXFactor, (rFSInfo.m_aFontBBox.Bottom() + 1) / fYFactor
2378 };
2379 else if (aFontBBox.size() != 4)
2380 aFontBBox = { 0, 0, 999, 999 }; // emit default FontBBox if needed
2381 rEmitter.emitValVector( "/FontBBox {", "}readonly def\n", aFontBBox);
2382 // emit FONTINFO into TOPDICT
2383 rEmitter.maBuffer.append(
2384 "/FontInfo 2 dict dup begin\n" // TODO: check fontinfo entry count
2385 " /FullName (" + OString::Concat(pFullName) + ") readonly def\n"
2386 " /FamilyName (" + pFamilyName + ") readonly def\n"
2387 "end readonly def\n");
2388
2389 rEmitter.maBuffer.append(
2390 "/Encoding 256 array\n"
2391 "0 1 255 {1 index exch /.notdef put} for\n");
2392 for( int i = 1; (i < nGlyphCount) && (i < 256); ++i) {
2393 OString pGlyphName = getGlyphName( pReqGlyphIds[i]);
2394 rEmitter.maBuffer.append(
2395 "dup " + OString::number(pReqEncoding[i]) + " /" + pGlyphName + " put\n");
2396 }
2397 rEmitter.maBuffer.append( "readonly def\n");
2398 rEmitter.maBuffer.append(
2399 // TODO: more topdict entries
2400 "currentdict end\n"
2401 "currentfile eexec\n");
2402
2403 // emit PFB header
2404 rEmitter.emitAllRaw();
2405 if( rEmitter.mbPfbSubset) {
2406 // update PFB header segment
2407 const int nPfbHeaderLen = rEmitter.tellPos() - 6;
2408 rEmitter.updateLen( 2, nPfbHeaderLen);
2409
2410 // prepare start of eexec segment
2411 rEmitter.emitRawData( "\x80\x02\x00\x00\x00\x00", 6); // segment start
2412 }
2413 const int nEExecSegTell = rEmitter.tellPos();
2414
2415 // which always starts with a privdict
2416 // count the privdict entries
2417 int nPrivEntryCount = 9;
2418 // emit blue hints only if non-default values
2419 nPrivEntryCount += int(!mpCffLocal->maOtherBlues.empty());
2420 nPrivEntryCount += int(!mpCffLocal->maFamilyBlues.empty());
2421 nPrivEntryCount += int(!mpCffLocal->maFamilyOtherBlues.empty());
2422 nPrivEntryCount += int(mpCffLocal->mfBlueScale != 0.0);
2423 nPrivEntryCount += int(mpCffLocal->mfBlueShift != 0.0);
2424 nPrivEntryCount += int(mpCffLocal->mfBlueFuzz != 0.0);
2425 // emit stem hints only if non-default values
2426 nPrivEntryCount += int(mpCffLocal->maStemStdHW != 0);
2427 nPrivEntryCount += int(mpCffLocal->maStemStdVW != 0);
2428 nPrivEntryCount += int(!mpCffLocal->maStemSnapH.empty());
2429 nPrivEntryCount += int(!mpCffLocal->maStemSnapV.empty());
2430 // emit other hints only if non-default values
2431 nPrivEntryCount += int(mpCffLocal->mfExpFactor != 0.0);
2432 nPrivEntryCount += int(mpCffLocal->mnLangGroup != 0);
2433 nPrivEntryCount += int(mpCffLocal->mnLangGroup == 1);
2434 nPrivEntryCount += int(mpCffLocal->mbForceBold);
2435 // emit the privdict header
2436 rEmitter.maBuffer.append(
2437 "\110\104\125 "
2438 "dup\n/Private " + OString::number(nPrivEntryCount) + " dict dup begin\n"
2439 "/RD{string currentfile exch readstring pop}executeonly def\n"
2440 "/ND{noaccess def}executeonly def\n"
2441 "/NP{noaccess put}executeonly def\n"
2442 "/MinFeature{16 16}ND\n"
2443 "/password 5839 def\n"); // TODO: mnRDCryptSeed?
2444
2445 // emit blue hint related privdict entries
2446 if( !mpCffLocal->maBlueValues.empty())
2447 rEmitter.emitValVector( "/BlueValues [", "]ND\n", mpCffLocal->maBlueValues);
2448 else
2449 rEmitter.maBuffer.append( "/BlueValues []ND\n"); // default to empty BlueValues
2450 rEmitter.emitValVector( "/OtherBlues [", "]ND\n", mpCffLocal->maOtherBlues);
2451 rEmitter.emitValVector( "/FamilyBlues [", "]ND\n", mpCffLocal->maFamilyBlues);
2452 rEmitter.emitValVector( "/FamilyOtherBlues [", "]ND\n", mpCffLocal->maFamilyOtherBlues);
2453
2454 if( mpCffLocal->mfBlueScale) {
2455 rEmitter.maBuffer.append( "/BlueScale ");
2456 rEmitter.maBuffer.append(dbl2str( mpCffLocal->mfBlueScale));
2457 rEmitter.maBuffer.append( " def\n");
2458 }
2459 if( mpCffLocal->mfBlueShift) { // default BlueShift==7
2460 rEmitter.maBuffer.append( "/BlueShift ");
2461 rEmitter.maBuffer.append(dbl2str( mpCffLocal->mfBlueShift));
2462 rEmitter.maBuffer.append( " def\n");
2463 }
2464 if( mpCffLocal->mfBlueFuzz) { // default BlueFuzz==1
2465 rEmitter.maBuffer.append( "/BlueFuzz ");
2466 rEmitter.maBuffer.append(dbl2str( mpCffLocal->mfBlueFuzz));
2467 rEmitter.maBuffer.append( " def\n");
2468 }
2469
2470 // emit stem hint related privdict entries
2471 if( mpCffLocal->maStemStdHW) {
2472 rEmitter.maBuffer.append( "/StdHW [");
2473 rEmitter.maBuffer.append(dbl2str( mpCffLocal->maStemStdHW));
2474 rEmitter.maBuffer.append( "] def\n");
2475 }
2476 if( mpCffLocal->maStemStdVW) {
2477 rEmitter.maBuffer.append( "/StdVW [");
2478 rEmitter.maBuffer.append(dbl2str( mpCffLocal->maStemStdVW));
2479 rEmitter.maBuffer.append( "] def\n");
2480 }
2481 rEmitter.emitValVector( "/StemSnapH [", "]ND\n", mpCffLocal->maStemSnapH);
2482 rEmitter.emitValVector( "/StemSnapV [", "]ND\n", mpCffLocal->maStemSnapV);
2483
2484 // emit other hints
2485 if( mpCffLocal->mbForceBold)
2486 rEmitter.maBuffer.append( "/ForceBold true def\n");
2487 if( mpCffLocal->mnLangGroup != 0)
2488 rEmitter.maBuffer.append(
2489 "/LanguageGroup " + OString::number(mpCffLocal->mnLangGroup) + " def\n");
2490 if( mpCffLocal->mnLangGroup == 1) // compatibility with ancient printers
2491 rEmitter.maBuffer.append( "/RndStemUp false def\n");
2492 if( mpCffLocal->mfExpFactor) {
2493 rEmitter.maBuffer.append( "/ExpansionFactor ");
2494 rEmitter.maBuffer.append(dbl2str( mpCffLocal->mfExpFactor));
2495 rEmitter.maBuffer.append( " def\n");
2496 }
2497
2498 // emit remaining privdict entries
2499 rEmitter.maBuffer.append( "/UniqueID " + OString::number(nUniqueId) + " def\n");
2500 // TODO?: more privdict entries?
2501
2502 rEmitter.maBuffer.append(
2503 "/OtherSubrs\n"
2504 "% Dummy code for faking flex hints\n"
2505 "[ {} {} {} {systemdict /internaldict known not {pop 3}\n"
2506 "{1183615869 systemdict /internaldict get exec\n"
2507 "dup /startlock known\n"
2508 "{/startlock get exec}\n"
2509 "{dup /strtlck known\n"
2510 "{/strtlck get exec}\n"
2511 "{pop 3}\nifelse}\nifelse}\nifelse\n} executeonly\n"
2512 "] ND\n");
2513
2514 // emit used GlobalSubr charstrings
2515 // these are the just the default subrs
2516 // TODO: do we need them as the flex hints are resolved differently?
2517 rEmitter.maBuffer.append(
2518 "/Subrs 5 array\n"
2519 "dup 0 15 RD \x5F\x3D\x6B\xAC\x3C\xBD\x74\x3D\x3E\x17\xA0\x86\x58\x08\x85 NP\n"
2520 "dup 1 9 RD \x5F\x3D\x6B\xD8\xA6\xB5\x68\xB6\xA2 NP\n"
2521 "dup 2 9 RD \x5F\x3D\x6B\xAC\x39\x46\xB9\x43\xF9 NP\n"
2522 "dup 3 5 RD \x5F\x3D\x6B\xAC\xB9 NP\n"
2523 "dup 4 12 RD \x5F\x3D\x6B\xAC\x3E\x5D\x48\x54\x62\x76\x39\x03 NP\n"
2524 "ND\n");
2525
2526 // TODO: emit more GlobalSubr charstrings?
2527 // TODO: emit used LocalSubr charstrings?
2528
2529 // emit the CharStrings for the requested glyphs
2530 std::vector<CharString> aCharStrings;
2531 mbDoSeac = true;
2532 convertCharStrings(pReqGlyphIds, nGlyphCount, aCharStrings);
2533
2534 // The previous convertCharStrings might collect extra glyphs used in seac
2535 // operator, convert them as well
2536 if (!maExtraGlyphIds.empty())
2537 {
2538 mbDoSeac = false;
2539 convertCharStrings(maExtraGlyphIds.data(), maExtraGlyphIds.size(), aCharStrings);
2540 }
2541 rEmitter.maBuffer.append(
2542 "2 index /CharStrings " + OString::number(aCharStrings.size()) + " dict dup begin\n");
2543 rEmitter.emitAllCrypted();
2544 for (const auto& rCharString : aCharStrings)
2545 {
2546 // get the glyph name
2547 OString pGlyphName = getGlyphName(rCharString.nCffGlyphId);
2548 // emit the encrypted Type1op charstring
2549 rEmitter.maBuffer.append(
2550 "/" + pGlyphName + " " + OString::number(rCharString.nLen) + " RD ");
2551 rEmitter.maBuffer.append(
2552 reinterpret_cast<char const *>(rCharString.aOps), rCharString.nLen);
2553 rEmitter.maBuffer.append( " ND\n");
2554 rEmitter.emitAllCrypted();
2555 // provide individual glyphwidths if requested
2556 }
2557 rEmitter.maBuffer.append( "end end\nreadonly put\nput\n");
2558 rEmitter.maBuffer.append( "dup/FontName get exch definefont pop\n");
2559 rEmitter.maBuffer.append( "mark currentfile closefile\n");
2560 rEmitter.emitAllCrypted();
2561
2562 // mark stop of eexec encryption
2563 if( rEmitter.mbPfbSubset) {
2564 const int nEExecLen = rEmitter.tellPos() - nEExecSegTell;
2565 rEmitter.updateLen( nEExecSegTell-4, nEExecLen);
2566 }
2567
2568 // create PFB footer
2569 static const char aPfxFooter[] = "\x80\x01\x14\x02\x00\x00\n" // TODO: check segment len
2570 "0000000000000000000000000000000000000000000000000000000000000000\n"
2571 "0000000000000000000000000000000000000000000000000000000000000000\n"
2572 "0000000000000000000000000000000000000000000000000000000000000000\n"
2573 "0000000000000000000000000000000000000000000000000000000000000000\n"
2574 "0000000000000000000000000000000000000000000000000000000000000000\n"
2575 "0000000000000000000000000000000000000000000000000000000000000000\n"
2576 "0000000000000000000000000000000000000000000000000000000000000000\n"
2577 "0000000000000000000000000000000000000000000000000000000000000000\n"
2578 "cleartomark\n"
2579 "\x80\x03";
2580 if( rEmitter.mbPfbSubset)
2581 rEmitter.emitRawData( aPfxFooter, sizeof(aPfxFooter)-1);
2582 else
2583 rEmitter.emitRawData( aPfxFooter+6, sizeof(aPfxFooter)-9);
2584
2585 // provide details to the subset requesters, TODO: move into own method?
2586 // note: Top and Bottom are flipped between Type1 and VCL
2587 // note: the rest of VCL expects the details below to be scaled like for an emUnits==1000 font
2588
2589 rFSInfo.m_nFontType = rEmitter.mbPfbSubset ? FontType::TYPE1_PFB : FontType::TYPE1_PFA;
2590
2591 if (rFSInfo.m_bFilled)
2592 return;
2593
2594 rFSInfo.m_aFontBBox = { Point(static_cast<sal_Int32>(aFontBBox[0] * fXFactor),
2595 static_cast<sal_Int32>(aFontBBox[1] * fYFactor)),
2596 Point(static_cast<sal_Int32>(aFontBBox[2] * fXFactor),
2597 static_cast<sal_Int32>(aFontBBox[3] * fYFactor)) };
2598 // PDF-Spec says the values below mean the ink bounds!
2599 // TODO: use better approximations for these ink bounds
2600 rFSInfo.m_nAscent = +rFSInfo.m_aFontBBox.Bottom(); // for capital letters
2601 rFSInfo.m_nDescent = -rFSInfo.m_aFontBBox.Top(); // for all letters
2602 rFSInfo.m_nCapHeight = rFSInfo.m_nAscent; // for top-flat capital letters
2603
2604 rFSInfo.m_aPSName = OUString( rEmitter.maSubsetName, strlen(rEmitter.maSubsetName), RTL_TEXTENCODING_UTF8 );
2605}
2606
2608{
2609 CffSubsetterContext aCff( mpInFontBytes, mnInByteLength);
2610 bool bRC = aCff.initialCffRead();
2611 if (!bRC)
2612 return bRC;
2613
2614 // emit Type1 subset from the CFF input
2615 // TODO: also support CFF->CFF subsetting (when PDF-export and PS-printing need it)
2616 const bool bPfbSubset(mnReqFontTypeMask & FontType::TYPE1_PFB);
2617 Type1Emitter aType1Emitter( mpOutFile, bPfbSubset);
2618 aType1Emitter.setSubsetName( mpReqFontName);
2619 aCff.emitAsType1( aType1Emitter,
2621 mnReqGlyphCount, *this);
2622 return true;
2623}
2624
2625/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr OStringLiteral tok_Medium
Definition: cff.cxx:431
constexpr OStringLiteral tok_Agravesmall
Definition: cff.cxx:391
constexpr OStringLiteral tok_Scaron
Definition: cff.cxx:236
constexpr OStringLiteral tok_uacute
Definition: cff.cxx:266
constexpr OStringLiteral tok_eightoldstyle
Definition: cff.cxx:291
constexpr OStringLiteral tok_Lslash
Definition: cff.cxx:184
constexpr OStringLiteral tok_dagger
Definition: cff.cxx:156
static const char * pStandardEncoding[]
Definition: cff.cxx:563
constexpr OStringLiteral tok_zerosuperior
Definition: cff.cxx:370
constexpr OStringLiteral tok_dsuperior
Definition: cff.cxx:300
constexpr OStringLiteral tok_paragraph
Definition: cff.cxx:159
constexpr OStringLiteral tok_fourinferior
Definition: cff.cxx:381
constexpr OStringLiteral tok_D
Definition: cff.cxx:81
constexpr OStringLiteral tok_Ucircumflexsmall
Definition: cff.cxx:418
constexpr OStringLiteral tok_ucircumflex
Definition: cff.cxx:267
constexpr OStringLiteral tok_ring
Definition: cff.cxx:176
constexpr OStringLiteral tok_parenleft
Definition: cff.cxx:53
constexpr OStringLiteral tok_001_003
Definition: cff.cxx:426
static const char * pDictOps[]
Definition: cff.cxx:538
constexpr OStringLiteral tok_u
Definition: cff.cxx:130
constexpr OStringLiteral tok_cent
Definition: cff.cxx:141
constexpr OStringLiteral tok_egrave
Definition: cff.cxx:254
constexpr OStringLiteral tok_S
Definition: cff.cxx:96
constexpr OStringLiteral tok_Yacute
Definition: cff.cxx:241
constexpr OStringLiteral tok_Roman
Definition: cff.cxx:433
constexpr OStringLiteral tok_currency
Definition: cff.cxx:147
constexpr OStringLiteral tok_Odieresis
Definition: cff.cxx:233
constexpr OStringLiteral tok_Macronsmall
Definition: cff.cxx:357
constexpr OStringLiteral tok_ellipsis
Definition: cff.cxx:165
constexpr OStringLiteral tok_Acircumflex
Definition: cff.cxx:216
constexpr OStringLiteral tok_periodsuperior
Definition: cff.cxx:295
constexpr OStringLiteral tok_sterlin
Definition: cff.cxx:142
constexpr OStringLiteral tok_dollarinferior
Definition: cff.cxx:388
constexpr OStringLiteral tok_J
Definition: cff.cxx:87
constexpr OStringLiteral tok_colon
Definition: cff.cxx:71
constexpr OStringLiteral tok_section
Definition: cff.cxx:146
constexpr OStringLiteral tok_L
Definition: cff.cxx:89
constexpr OStringLiteral tok_ccedilla
Definition: cff.cxx:250
constexpr OStringLiteral tok_Ograve
Definition: cff.cxx:234
constexpr OStringLiteral tok_quotedblbase
Definition: cff.cxx:162
constexpr OStringLiteral tok_fivesuperior
Definition: cff.cxx:372
constexpr OStringLiteral tok_Agrave
Definition: cff.cxx:218
constexpr OStringLiteral tok_aacute
Definition: cff.cxx:244
constexpr OStringLiteral tok_nineoldstile
Definition: cff.cxx:292
constexpr OStringLiteral tok_space
Definition: cff.cxx:45
constexpr OStringLiteral tok_Semibold
Definition: cff.cxx:434
constexpr OStringLiteral tok_backslash
Definition: cff.cxx:105
constexpr OStringLiteral tok_h
Definition: cff.cxx:117
constexpr OStringLiteral tok_onehalf
Definition: cff.cxx:199
sal_uInt8 U8
Definition: cff.cxx:37
constexpr OStringLiteral tok_Ydieresis
Definition: cff.cxx:242
constexpr OStringLiteral tok_rsuperior
Definition: cff.cxx:307
constexpr OStringLiteral tok_Ugravesmall
Definition: cff.cxx:416
constexpr OStringLiteral tok_parenleftinferior
Definition: cff.cxx:313
constexpr OStringLiteral tok_numbersign
Definition: cff.cxx:48
constexpr OStringLiteral tok_igrave
Definition: cff.cxx:258
constexpr OStringLiteral tok_sevenoldstyle
Definition: cff.cxx:290
constexpr OStringLiteral tok_breve
Definition: cff.cxx:173
constexpr OStringLiteral tok_Asmall
Definition: cff.cxx:318
constexpr OStringLiteral tok_Ocircumflexsmall
Definition: cff.cxx:411
constexpr OStringLiteral tok_ecircumflex
Definition: cff.cxx:252
constexpr OStringLiteral tok_X
Definition: cff.cxx:101
constexpr OStringLiteral tok_ograve
Definition: cff.cxx:263
constexpr OStringLiteral tok_centinferior
Definition: cff.cxx:387
constexpr OStringLiteral tok_Ysmall
Definition: cff.cxx:342
constexpr OStringLiteral tok_braceleft
Definition: cff.cxx:136
constexpr OStringLiteral tok_notdef
Definition: cff.cxx:44
constexpr OStringLiteral tok_florin
Definition: cff.cxx:145
constexpr OStringLiteral tok_Otilde
Definition: cff.cxx:235
constexpr OStringLiteral tok_udieresis
Definition: cff.cxx:268
constexpr OStringLiteral tok_ff
Definition: cff.cxx:310
constexpr OStringLiteral tok_A
Definition: cff.cxx:78
constexpr OStringLiteral tok_d
Definition: cff.cxx:113
constexpr OStringLiteral tok_Black
Definition: cff.cxx:427
constexpr OStringLiteral tok_Hungarumlautsmall
Definition: cff.cxx:274
constexpr OStringLiteral tok_Zcaronsmall
Definition: cff.cxx:352
constexpr OStringLiteral tok_four
Definition: cff.cxx:65
constexpr OStringLiteral tok_parenleftsuperior
Definition: cff.cxx:279
constexpr OStringLiteral tok_W
Definition: cff.cxx:100
constexpr OStringLiteral tok_quoteleft
Definition: cff.cxx:109
constexpr OStringLiteral tok_parenrightinferior
Definition: cff.cxx:314
constexpr OStringLiteral tok_exclamdown
Definition: cff.cxx:140
constexpr OStringLiteral tok_threequartersemdash
Definition: cff.cxx:294
constexpr OStringLiteral tok_threequarters
Definition: cff.cxx:207
constexpr OStringLiteral tok_Thornsmall
Definition: cff.cxx:421
constexpr OStringLiteral tok_hungarumlaut
Definition: cff.cxx:178
constexpr OStringLiteral tok_copyright
Definition: cff.cxx:214
double RealType
Definition: cff.cxx:41
constexpr OStringLiteral tok_Adieresissmall
Definition: cff.cxx:395
constexpr OStringLiteral tok_Ringsmall
Definition: cff.cxx:361
constexpr OStringLiteral tok_Udieresis
Definition: cff.cxx:239
constexpr OStringLiteral tok_germandbls
Definition: cff.cxx:193
constexpr OStringLiteral tok_commainferior
Definition: cff.cxx:390
constexpr OStringLiteral tok_Aacute
Definition: cff.cxx:215
constexpr OStringLiteral tok_edieresis
Definition: cff.cxx:253
constexpr OStringLiteral tok_scaron
Definition: cff.cxx:265
constexpr OStringLiteral tok_i
Definition: cff.cxx:118
constexpr OStringLiteral tok_Ksmall
Definition: cff.cxx:328
constexpr OStringLiteral tok_j
Definition: cff.cxx:119
constexpr OStringLiteral tok_period
Definition: cff.cxx:59
constexpr OStringLiteral tok_e
Definition: cff.cxx:114
constexpr OStringLiteral tok_Ecircumflexsmall
Definition: cff.cxx:401
constexpr OStringLiteral tok_t
Definition: cff.cxx:129
constexpr OStringLiteral tok_ninesuperior
Definition: cff.cxx:376
constexpr OStringLiteral tok_T
Definition: cff.cxx:97
constexpr OStringLiteral tok_Ismall
Definition: cff.cxx:326
constexpr OStringLiteral tok_tilde
Definition: cff.cxx:171
constexpr OStringLiteral tok_commasuperior
Definition: cff.cxx:293
constexpr OStringLiteral tok_Q
Definition: cff.cxx:94
constexpr OStringLiteral tok_at
Definition: cff.cxx:77
constexpr OStringLiteral tok_quotedblleft
Definition: cff.cxx:149
constexpr OStringLiteral tok_sevensuperior
Definition: cff.cxx:374
constexpr OStringLiteral tok_AE
Definition: cff.cxx:182
constexpr OStringLiteral tok_tsuperior
Definition: cff.cxx:309
constexpr OStringLiteral tok_Usmall
Definition: cff.cxx:338
constexpr OStringLiteral tok_N
Definition: cff.cxx:91
constexpr OStringLiteral tok_twoinferior
Definition: cff.cxx:379
constexpr OStringLiteral tok_thorn
Definition: cff.cxx:206
constexpr OStringLiteral tok_six
Definition: cff.cxx:67
constexpr OStringLiteral tok_Icircumflex
Definition: cff.cxx:227
constexpr OStringLiteral tok_hyphen
Definition: cff.cxx:58
constexpr OStringLiteral tok_Brevesmall
Definition: cff.cxx:354
constexpr OStringLiteral tok_zerooldstyle
Definition: cff.cxx:283
constexpr OStringLiteral tok_percent
Definition: cff.cxx:50
constexpr OStringLiteral tok_Ntilde
Definition: cff.cxx:230
constexpr OStringLiteral tok_logicalnot
Definition: cff.cxx:195
constexpr OStringLiteral tok_exclamdownsmall
Definition: cff.cxx:348
constexpr OStringLiteral tok_Osmall
Definition: cff.cxx:332
constexpr OStringLiteral tok_lslash
Definition: cff.cxx:190
constexpr OStringLiteral tok_esuperior
Definition: cff.cxx:301
constexpr OStringLiteral tok_Ssmall
Definition: cff.cxx:336
constexpr OStringLiteral tok_quotedblright
Definition: cff.cxx:163
constexpr OStringLiteral tok_001_001
Definition: cff.cxx:424
constexpr OStringLiteral tok_threeoldstyle
Definition: cff.cxx:286
constexpr OStringLiteral tok_Ogoneksmall
Definition: cff.cxx:360
constexpr OStringLiteral tok_Idieresissmall
Definition: cff.cxx:406
constexpr OStringLiteral tok_Ntildesmall
Definition: cff.cxx:408
constexpr OStringLiteral tok_rupia
Definition: cff.cxx:346
constexpr OStringLiteral tok_seveninferior
Definition: cff.cxx:384
constexpr OStringLiteral tok_acircumflex
Definition: cff.cxx:245
constexpr OStringLiteral tok_Igravesmall
Definition: cff.cxx:403
constexpr OStringLiteral tok_Csmall
Definition: cff.cxx:320
constexpr OStringLiteral tok_degree
Definition: cff.cxx:205
constexpr OStringLiteral tok_C
Definition: cff.cxx:80
constexpr OStringLiteral tok_l
Definition: cff.cxx:121
constexpr OStringLiteral tok_bracketleft
Definition: cff.cxx:104
constexpr OStringLiteral tok_brokenbar
Definition: cff.cxx:204
constexpr OStringLiteral tok_k
Definition: cff.cxx:120
constexpr OStringLiteral tok_twothirds
Definition: cff.cxx:369
constexpr OStringLiteral tok_q
Definition: cff.cxx:126
constexpr OStringLiteral tok_onethird
Definition: cff.cxx:368
constexpr OStringLiteral tok_registered
Definition: cff.cxx:209
constexpr OStringLiteral tok_yacute
Definition: cff.cxx:270
constexpr OStringLiteral tok_bar
Definition: cff.cxx:137
constexpr OStringLiteral tok_dollar
Definition: cff.cxx:49
constexpr OStringLiteral tok_n
Definition: cff.cxx:123
constexpr OStringLiteral tok_oacute
Definition: cff.cxx:260
constexpr OStringLiteral tok_parenright
Definition: cff.cxx:54
constexpr OStringLiteral tok_multiply
Definition: cff.cxx:212
constexpr OStringLiteral tok_comma
Definition: cff.cxx:57
constexpr OStringLiteral tok_F
Definition: cff.cxx:83
constexpr OStringLiteral tok_sixoldstyle
Definition: cff.cxx:289
constexpr OStringLiteral tok_msuperior
Definition: cff.cxx:304
static OString dbl2str(double fVal)
Definition: cff.cxx:2237
constexpr OStringLiteral tok_fiveinferior
Definition: cff.cxx:382
constexpr OStringLiteral tok_oneinferior
Definition: cff.cxx:378
constexpr OStringLiteral tok_m
Definition: cff.cxx:122
constexpr OStringLiteral tok_daggerdbl
Definition: cff.cxx:157
constexpr OStringLiteral tok_ampersandsmall
Definition: cff.cxx:277
constexpr OStringLiteral tok_Dsmall
Definition: cff.cxx:321
constexpr OStringLiteral tok_Thorn
Definition: cff.cxx:201
constexpr OStringLiteral tok_Acircumflexsmall
Definition: cff.cxx:393
constexpr OStringLiteral tok_Oslash
Definition: cff.cxx:185
constexpr OStringLiteral tok_oneeight
Definition: cff.cxx:364
constexpr OStringLiteral tok_Ecircumflex
Definition: cff.cxx:223
constexpr OStringLiteral tok_lsuperior
Definition: cff.cxx:303
constexpr OStringLiteral tok_dollarsuperior
Definition: cff.cxx:276
constexpr OStringLiteral tok_Gsmall
Definition: cff.cxx:324
constexpr OStringLiteral tok_atilde
Definition: cff.cxx:249
constexpr OStringLiteral tok_Idieresis
Definition: cff.cxx:228
constexpr OStringLiteral tok_dotlessi
Definition: cff.cxx:189
constexpr OStringLiteral tok_eightinferior
Definition: cff.cxx:385
constexpr OStringLiteral tok_Egrave
Definition: cff.cxx:225
constexpr OStringLiteral tok_Ccedillasmall
Definition: cff.cxx:398
constexpr OStringLiteral tok_fiveeights
Definition: cff.cxx:366
constexpr OStringLiteral tok_Aacutesmall
Definition: cff.cxx:392
constexpr OStringLiteral tok_a
Definition: cff.cxx:110
constexpr OStringLiteral tok_r
Definition: cff.cxx:127
constexpr OStringLiteral tok_aring
Definition: cff.cxx:248
constexpr OStringLiteral tok_semicolon
Definition: cff.cxx:72
constexpr OStringLiteral tok_Ydieresissmall
Definition: cff.cxx:422
sal_Int64 S64
Definition: cff.cxx:39
constexpr OStringLiteral tok_onesuperior
Definition: cff.cxx:194
constexpr OStringLiteral tok_divide
Definition: cff.cxx:203
constexpr OStringLiteral tok_quotesingle
Definition: cff.cxx:148
constexpr OStringLiteral tok_y
Definition: cff.cxx:134
constexpr OStringLiteral tok_guilsinglleft
Definition: cff.cxx:151
constexpr OStringLiteral tok_colonmonetary
Definition: cff.cxx:344
constexpr OStringLiteral tok_perthousand
Definition: cff.cxx:166
constexpr OStringLiteral tok_guillemotright
Definition: cff.cxx:164
constexpr OStringLiteral tok_bsuperior
Definition: cff.cxx:298
constexpr OStringLiteral tok_fouroldstyle
Definition: cff.cxx:287
constexpr OStringLiteral tok_slash
Definition: cff.cxx:60
constexpr OStringLiteral tok_cedilla
Definition: cff.cxx:177
constexpr OStringLiteral tok_E
Definition: cff.cxx:82
constexpr OStringLiteral tok_onequarter
Definition: cff.cxx:202
constexpr OStringLiteral tok_Circumflexsmall
Definition: cff.cxx:315
sal_uInt16 U16
Definition: cff.cxx:38
constexpr OStringLiteral tok_periodcentered
Definition: cff.cxx:158
constexpr OStringLiteral tok_g
Definition: cff.cxx:116
constexpr OStringLiteral tok_Dieresissmall
Definition: cff.cxx:353
constexpr OStringLiteral tok_hyphensuperior
Definition: cff.cxx:316
constexpr OStringLiteral tok_K
Definition: cff.cxx:88
constexpr OStringLiteral tok_Lslashsmall
Definition: cff.cxx:350
constexpr OStringLiteral tok_ampersand
Definition: cff.cxx:51
constexpr OStringLiteral tok_trademark
Definition: cff.cxx:197
constexpr OStringLiteral tok_guilsinglright
Definition: cff.cxx:152
constexpr OStringLiteral tok_fraction
Definition: cff.cxx:143
constexpr OStringLiteral tok_Edieresissmall
Definition: cff.cxx:402
constexpr OStringLiteral tok_Gravesmall
Definition: cff.cxx:317
constexpr OStringLiteral tok_x
Definition: cff.cxx:133
constexpr OStringLiteral tok_Zcaron
Definition: cff.cxx:243
constexpr OStringLiteral tok_Atilde
Definition: cff.cxx:220
constexpr OStringLiteral tok_Eacute
Definition: cff.cxx:222
constexpr OStringLiteral tok_Lsmall
Definition: cff.cxx:329
constexpr OStringLiteral tok_yen
Definition: cff.cxx:144
constexpr OStringLiteral tok_questionsmall
Definition: cff.cxx:296
constexpr OStringLiteral tok_question
Definition: cff.cxx:76
constexpr OStringLiteral tok_five
Definition: cff.cxx:66
constexpr OStringLiteral tok_Hsmall
Definition: cff.cxx:325
constexpr OStringLiteral tok_Ocircumflex
Definition: cff.cxx:232
constexpr OStringLiteral tok_c
Definition: cff.cxx:112
constexpr OStringLiteral tok_Adieresis
Definition: cff.cxx:217
constexpr OStringLiteral tok_twosuperior
Definition: cff.cxx:208
ESCS
Definition: cff.cxx:626
constexpr OStringLiteral tok_threesuperior
Definition: cff.cxx:213
constexpr OStringLiteral tok_V
Definition: cff.cxx:99
constexpr OStringLiteral tok_caron
Definition: cff.cxx:180
constexpr OStringLiteral tok_O
Definition: cff.cxx:92
constexpr OStringLiteral tok_ffl
Definition: cff.cxx:312
constexpr OStringLiteral tok_z
Definition: cff.cxx:135
constexpr OStringLiteral tok_eth
Definition: cff.cxx:211
constexpr OStringLiteral tok_sixsuperior
Definition: cff.cxx:373
constexpr OStringLiteral tok_Iacute
Definition: cff.cxx:226
constexpr OStringLiteral tok_Ogravesmall
Definition: cff.cxx:409
constexpr OStringLiteral tok_ae
Definition: cff.cxx:188
constexpr OStringLiteral tok_hypheninferior
Definition: cff.cxx:359
constexpr OStringLiteral tok_Ugrave
Definition: cff.cxx:240
constexpr OStringLiteral tok_less
Definition: cff.cxx:73
constexpr OStringLiteral tok_Qsmall
Definition: cff.cxx:334
constexpr OStringLiteral tok_nsuperior
Definition: cff.cxx:305
constexpr OStringLiteral tok_eight
Definition: cff.cxx:69
constexpr OStringLiteral tok_bullet
Definition: cff.cxx:160
constexpr OStringLiteral tok_H
Definition: cff.cxx:85
constexpr OStringLiteral tok_p
Definition: cff.cxx:125
constexpr OStringLiteral tok_isuperior
Definition: cff.cxx:302
constexpr OStringLiteral tok_Esmall
Definition: cff.cxx:322
constexpr OStringLiteral tok_eightsuperior
Definition: cff.cxx:375
constexpr OStringLiteral tok_Tildesmall
Definition: cff.cxx:347
constexpr OStringLiteral tok_U
Definition: cff.cxx:98
constexpr OStringLiteral tok_oneoldstyle
Definition: cff.cxx:284
constexpr OStringLiteral tok_Ccedilla
Definition: cff.cxx:221
constexpr OStringLiteral tok_Cedillasmall
Definition: cff.cxx:362
constexpr OStringLiteral tok_Oacute
Definition: cff.cxx:231
static rtl::OStringConstExpr pStringIds[]
Definition: cff.cxx:436
constexpr OStringLiteral tok_f
Definition: cff.cxx:115
constexpr OStringLiteral tok_G
Definition: cff.cxx:84
constexpr OStringLiteral tok_P
Definition: cff.cxx:93
constexpr OStringLiteral tok_bracketright
Definition: cff.cxx:106
constexpr OStringLiteral tok_Wsmall
Definition: cff.cxx:340
constexpr OStringLiteral tok_asuperior
Definition: cff.cxx:297
constexpr OStringLiteral tok_seven
Definition: cff.cxx:68
constexpr OStringLiteral tok_dollaroldstyle
Definition: cff.cxx:275
constexpr OStringLiteral tok_Edieresis
Definition: cff.cxx:224
constexpr OStringLiteral tok_fl
Definition: cff.cxx:154
constexpr OStringLiteral tok_001_002
Definition: cff.cxx:425
constexpr OStringLiteral tok_agrave
Definition: cff.cxx:247
constexpr OStringLiteral tok_onefitted
Definition: cff.cxx:345
constexpr OStringLiteral tok_greater
Definition: cff.cxx:75
constexpr OStringLiteral tok_otilde
Definition: cff.cxx:264
constexpr OStringLiteral tok_Aringsmall
Definition: cff.cxx:396
constexpr OStringLiteral tok_Udieresissmall
Definition: cff.cxx:419
constexpr OStringLiteral tok_ugrave
Definition: cff.cxx:269
constexpr OStringLiteral tok_osuperior
Definition: cff.cxx:306
constexpr OStringLiteral tok_o
Definition: cff.cxx:124
constexpr OStringLiteral tok_figuredash
Definition: cff.cxx:358
constexpr OStringLiteral tok_Egravesmall
Definition: cff.cxx:399
constexpr OStringLiteral tok_sixinferior
Definition: cff.cxx:383
constexpr OStringLiteral tok_icircumflex
Definition: cff.cxx:256
constexpr OStringLiteral tok_Oacutesmall
Definition: cff.cxx:410
constexpr OStringLiteral tok_Igrave
Definition: cff.cxx:229
static const char * pDictEscs[]
Definition: cff.cxx:550
OPS
Definition: cff.cxx:617
constexpr OStringLiteral tok_Regular
Definition: cff.cxx:432
constexpr OStringLiteral tok_braceright
Definition: cff.cxx:138
constexpr OStringLiteral tok_twodotenleader
Definition: cff.cxx:281
constexpr OStringLiteral tok_odieresis
Definition: cff.cxx:262
constexpr OStringLiteral tok_v
Definition: cff.cxx:131
constexpr OStringLiteral tok_001_000
Definition: cff.cxx:423
constexpr OStringLiteral tok_minus
Definition: cff.cxx:210
constexpr OStringLiteral tok_Eacutesmall
Definition: cff.cxx:400
constexpr OStringLiteral tok_iacute
Definition: cff.cxx:255
constexpr OStringLiteral tok_quotesinglbase
Definition: cff.cxx:161
constexpr OStringLiteral tok_Xsmall
Definition: cff.cxx:341
constexpr OStringLiteral tok_questiondownsmall
Definition: cff.cxx:363
constexpr OStringLiteral tok_questiondown
Definition: cff.cxx:167
constexpr OStringLiteral tok_plus
Definition: cff.cxx:56
constexpr OStringLiteral tok_Odieressissmall
Definition: cff.cxx:413
constexpr OStringLiteral tok_oe
Definition: cff.cxx:192
constexpr OStringLiteral tok_eacute
Definition: cff.cxx:251
constexpr OStringLiteral tok_Otildesmall
Definition: cff.cxx:412
constexpr OStringLiteral tok_Acutesmall
Definition: cff.cxx:278
constexpr OStringLiteral tok_asciitilde
Definition: cff.cxx:139
constexpr OStringLiteral tok_Nsmall
Definition: cff.cxx:331
constexpr OStringLiteral tok_acute
Definition: cff.cxx:169
constexpr OStringLiteral tok_Z
Definition: cff.cxx:103
constexpr OStringLiteral tok_w
Definition: cff.cxx:132
constexpr OStringLiteral tok_I
Definition: cff.cxx:86
constexpr OStringLiteral tok_Yacutesmall
Definition: cff.cxx:420
constexpr OStringLiteral tok_nineinferior
Definition: cff.cxx:386
constexpr OStringLiteral tok_foursuperior
Definition: cff.cxx:371
constexpr OStringLiteral tok_asciicircum
Definition: cff.cxx:107
constexpr OStringLiteral tok_AEsmall
Definition: cff.cxx:397
constexpr OStringLiteral tok_equal
Definition: cff.cxx:74
constexpr OStringLiteral tok_OE
Definition: cff.cxx:186
constexpr OStringLiteral tok_ffi
Definition: cff.cxx:311
constexpr OStringLiteral tok_Jsmall
Definition: cff.cxx:327
constexpr OStringLiteral tok_Y
Definition: cff.cxx:102
constexpr OStringLiteral tok_Dotaccentsmall
Definition: cff.cxx:356
constexpr OStringLiteral tok_two
Definition: cff.cxx:63
constexpr OStringLiteral tok_parenrightsuperior
Definition: cff.cxx:280
constexpr OStringLiteral tok_Msmall
Definition: cff.cxx:330
constexpr OStringLiteral tok_Bsmall
Definition: cff.cxx:319
constexpr OStringLiteral tok_one
Definition: cff.cxx:62
constexpr OStringLiteral tok_mu
Definition: cff.cxx:196
constexpr OStringLiteral tok_circumflex
Definition: cff.cxx:170
constexpr OStringLiteral tok_Fsmall
Definition: cff.cxx:323
constexpr OStringLiteral tok_Bold
Definition: cff.cxx:428
constexpr OStringLiteral tok_exclam
Definition: cff.cxx:46
constexpr OStringLiteral tok_centoldstyle
Definition: cff.cxx:349
constexpr OStringLiteral tok_guillemotleft
Definition: cff.cxx:150
constexpr OStringLiteral tok_twooldstyle
Definition: cff.cxx:285
constexpr OStringLiteral tok_adieresis
Definition: cff.cxx:246
constexpr OStringLiteral tok_Uacutesmall
Definition: cff.cxx:417
constexpr OStringLiteral tok_Caronsmall
Definition: cff.cxx:355
constexpr OStringLiteral tok_underscore
Definition: cff.cxx:108
constexpr OStringLiteral tok_Book
Definition: cff.cxx:429
constexpr OStringLiteral tok_Rsmall
Definition: cff.cxx:335
constexpr OStringLiteral tok_fi
Definition: cff.cxx:153
constexpr OStringLiteral tok_threeinferior
Definition: cff.cxx:380
constexpr OStringLiteral tok_Vsmall
Definition: cff.cxx:339
constexpr OStringLiteral tok_ordmasculine
Definition: cff.cxx:187
constexpr OStringLiteral tok_Tsmall
Definition: cff.cxx:337
constexpr OStringLiteral tok_quoteright
Definition: cff.cxx:52
constexpr OStringLiteral tok_idieresis
Definition: cff.cxx:257
constexpr OStringLiteral tok_dotaccent
Definition: cff.cxx:174
constexpr OStringLiteral tok_ntilde
Definition: cff.cxx:259
constexpr OStringLiteral tok_oslash
Definition: cff.cxx:191
constexpr OStringLiteral tok_Eth
Definition: cff.cxx:198
constexpr OStringLiteral tok_dieresis
Definition: cff.cxx:175
constexpr OStringLiteral tok_fiveoldstyle
Definition: cff.cxx:288
constexpr OStringLiteral tok_nine
Definition: cff.cxx:70
constexpr OStringLiteral tok_s
Definition: cff.cxx:128
constexpr OStringLiteral tok_grave
Definition: cff.cxx:168
constexpr OStringLiteral tok_Psmall
Definition: cff.cxx:333
constexpr OStringLiteral tok_onedotenleader
Definition: cff.cxx:282
constexpr OStringLiteral tok_Ucircumflex
Definition: cff.cxx:238
constexpr OStringLiteral tok_Icircumflexsmall
Definition: cff.cxx:405
constexpr OStringLiteral tok_seveneights
Definition: cff.cxx:367
constexpr OStringLiteral tok_OEsmall
Definition: cff.cxx:414
constexpr OStringLiteral tok_Atildesmall
Definition: cff.cxx:394
constexpr OStringLiteral tok_Ethsmall
Definition: cff.cxx:407
constexpr OStringLiteral tok_ordfeminine
Definition: cff.cxx:183
constexpr OStringLiteral tok_asterisk
Definition: cff.cxx:55
constexpr OStringLiteral tok_plusminus
Definition: cff.cxx:200
constexpr OStringLiteral tok_Zsmall
Definition: cff.cxx:343
constexpr OStringLiteral tok_Oslashsmall
Definition: cff.cxx:415
constexpr OStringLiteral tok_emdash
Definition: cff.cxx:181
constexpr OStringLiteral tok_threeeights
Definition: cff.cxx:365
constexpr OStringLiteral tok_periodinferior
Definition: cff.cxx:389
constexpr OStringLiteral tok_macron
Definition: cff.cxx:172
constexpr OStringLiteral tok_zcaron
Definition: cff.cxx:272
constexpr OStringLiteral tok_centsuperior
Definition: cff.cxx:299
constexpr OStringLiteral tok_R
Definition: cff.cxx:95
constexpr OStringLiteral tok_Scaronsmall
Definition: cff.cxx:351
constexpr OStringLiteral tok_ogonek
Definition: cff.cxx:179
constexpr OStringLiteral tok_quotedbl
Definition: cff.cxx:47
constexpr OStringLiteral tok_zeroinferior
Definition: cff.cxx:377
constexpr OStringLiteral tok_ocircumflex
Definition: cff.cxx:261
constexpr OStringLiteral tok_ssuperior
Definition: cff.cxx:308
constexpr OStringLiteral tok_zero
Definition: cff.cxx:61
constexpr OStringLiteral tok_three
Definition: cff.cxx:64
constexpr OStringLiteral tok_M
Definition: cff.cxx:90
constexpr OStringLiteral tok_Light
Definition: cff.cxx:430
constexpr OStringLiteral tok_Uacute
Definition: cff.cxx:237
constexpr OStringLiteral tok_ydieresis
Definition: cff.cxx:271
RealType ValType
Definition: cff.cxx:42
constexpr OStringLiteral tok_Aring
Definition: cff.cxx:219
constexpr OStringLiteral tok_Iacutesmall
Definition: cff.cxx:404
constexpr OStringLiteral tok_B
Definition: cff.cxx:79
constexpr OStringLiteral tok_endash
Definition: cff.cxx:155
constexpr OStringLiteral tok_exclamsmall
Definition: cff.cxx:273
constexpr OStringLiteral tok_b
Definition: cff.cxx:111
tools::Rectangle m_aFontBBox
Definition: fontsubset.hxx:71
SvStream * mpOutFile
Definition: fontsubset.hxx:84
OUString m_aPSName
Definition: fontsubset.hxx:67
const char * mpReqFontName
Definition: fontsubset.hxx:85
FontType m_nFontType
font-type of subset result
Definition: fontsubset.hxx:72
unsigned const char * mpInFontBytes
Definition: fontsubset.hxx:77
const sal_GlyphId * mpReqGlyphIds
Definition: fontsubset.hxx:86
bool CreateFontSubsetFromCff()
Definition: cff.cxx:2607
const sal_uInt8 * mpReqEncodedIds
Definition: fontsubset.hxx:87
FontType mnReqFontTypeMask
allowed subset-target font types
Definition: fontsubset.hxx:83
int m_nAscent
all metrics in PS font units
Definition: fontsubset.hxx:68
constexpr tools::Long Top() const
constexpr tools::Long Right() const
constexpr tools::Long Left() const
constexpr tools::Long Bottom() const
@ TYPE1_PFB
PSType1 Postscript Font Binary.
@ TYPE1_PFA
PSType1 Postscript Font Ascii.
uint32_t sal_GlyphId
Definition: glyphid.hxx:24
sal_Int32 nIndex
void * p
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
#define SAL_N_ELEMENTS(arr)
Definition: cff.cxx:615
Definition: cff.cxx:634
size
OUString getString(const Any &_rAny)
int i
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
int sprintf(char(&s)[N], char const *format, T &&... arguments)
end
long Long
const wchar_t *typedef int(__stdcall *DllNativeUnregProc)(int
#define PUT(p, e, t, m)
NOT
MUL
GET
SUB
RETURN
DIV
AND
OR
EQ
RANDOM
NEG
unsigned char sal_uInt8
oslFileHandle & pOut
sal_Int32 nLength