Debian Codegraph @

sys/Graphics_text.cpp

raw symbols SCIP
1 /* Graphics_text.cpp
2 *
3 * Copyright (C) 1992-2026 Paul Boersma, 2013 Tom Naughton, 2017 David Weenink
4 *
5 * This code is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or (at
8 * your option) any later version.
9 *
10 * This code is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this work. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 #include "../kar/UnicodeData.h"cxx . . $ `<file>/kar/UnicodeData.h`/
20 #include "GraphicsP.h"cxx . . $ `<file>/sys/GraphicsP.h`/
21 #include "../kar/longchar.h"cxx . . $ `<file>/kar/longchar.h`/
22 #include "Printer.h"cxx . . $ `<file>/sys/Printer.h`/
23
24 extern const char * ipaSerifRegularPScxx . . $ ipaSerifRegularPS. [];
25
26 /*
27 When computing the width of a text by adding the widths of the separate characters,
28 we will make a correction for systems that make slanted characters overlap the character box to their right.
29 The effect is especially strong on Mac (older versions).
30 The slant correction is taken relative to the font size.
31 */
32 #define POSTSCRIPT_SLANT_CORRECTIONcxx . . $ `sys/Graphics_text.cpp:32:9`! 0.1
33 #define SCREEN_SLANT_CORRECTIONcxx . . $ `sys/Graphics_text.cpp:33:9`! 0.05
34
35 #define HAS_FI_AND_FL_LIGATUREScxx . . $ `sys/Graphics_text.cpp:35:9`! ( mycxx . . $ `melder/melder.h:44:9`! postScript == true )
36
37 #if cairocxx . . $ `sys/GraphicsP.h:54:10`!
38 PangoFontMap *thePangoFontMapcxx . . $ thePangoFontMap.;
39 PangoContext *thePangoContextcxx . . $ thePangoContext.;
40 static bool hasTimescxx . . $ hasTimes., hasHelveticacxx . . $ hasHelvetica., hasCouriercxx . . $ hasCourier., hasPalatinocxx . . $ hasPalatino., hasDouloscxx . . $ hasDoulos., hasChariscxx . . $ hasCharis., hasIpaSerifcxx . . $ hasIpaSerif., hasCharis7cxx . . $ hasCharis7.;
41 #elif gdi
42 #define win_MAXIMUM_FONT_SIZE 500
43 static HFONT fonts [1 + (int) kGraphics_resolution::MAX] [1 + kGraphics_font_JAPANESE] [1+win_MAXIMUM_FONT_SIZE] [1 + Graphics_BOLD_ITALIC];
44 static int win_size2isize (int size) { return size > win_MAXIMUM_FONT_SIZE ? win_MAXIMUM_FONT_SIZE : size; }
45 static int win_isize2size (int isize) { return isize; }
46 static bool hasDoulos, hasCharis, hasCharis7;
47 #elif quartz
48 static bool hasTimes, hasHelvetica, hasCourier, hasPalatino, hasDoulos, hasCharis, hasIpaSerif, hasCharis7;
49 #define mac_MAXIMUM_FONT_SIZE 500
50 static CTFontRef theScreenFonts [1 + kGraphics_font_DINGBATS] [1+mac_MAXIMUM_FONT_SIZE] [1 + Graphics_BOLD_ITALIC];
51 #endif
52
53 #if gdicxx . . $ `sys/GraphicsP.h:55:10`!
54 #ifdef __CYGWIN__
55 #define FONT_TYPE_TYPE unsigned int
56 #else
57 #define FONT_TYPE_TYPE unsigned long int
58 #endif
59 static int CALLBACK fontFuncEx_charis (const LOGFONTW *oldLogFont, const TEXTMETRICW *oldTextMetric, FONT_TYPE_TYPE fontType, LPARAM lparam) {
60 const LPENUMLOGFONTW logFont = (LPENUMLOGFONTW) oldLogFont; (void) oldTextMetric; (void) fontType; (void) lparam;
61 hasCharis = true;
62 return 1;
63 }
64 static int CALLBACK fontFuncEx_doulos (const LOGFONTW *oldLogFont, const TEXTMETRICW *oldTextMetric, FONT_TYPE_TYPE fontType, LPARAM lparam) {
65 const LPENUMLOGFONTW logFont = (LPENUMLOGFONTW) oldLogFont; (void) oldTextMetric; (void) fontType; (void) lparam;
66 hasDoulos = true;
67 return 1;
68 }
69 static HFONT loadFont (GraphicsScreen me, int font, int size, int style) {
70 LOGFONTW spec;
71 static int ipaInited;
72 if (my printer || my metafile) {
73 spec. lfHeight = - win_isize2size (size) * my resolution / 72.0;
74 } else {
75 spec. lfHeight = - win_isize2size (size) * my resolution / 72.0;
76 }
77 spec. lfWidth = 0;
78 spec. lfEscapement = spec. lfOrientation = 0;
79 spec. lfWeight = style & Graphics_BOLD ? FW_BOLD : 0;
80 spec. lfItalic = style & Graphics_ITALIC ? 1 : 0;
81 spec. lfUnderline = spec. lfStrikeOut = 0;
82 spec. lfCharSet =
83 font == kGraphics_font_SYMBOL ? SYMBOL_CHARSET :
84 font == kGraphics_font_CHINESE ? DEFAULT_CHARSET :
85 font == kGraphics_font_JAPANESE ? DEFAULT_CHARSET :
86 font >= kGraphics_font_IPATIMES ? DEFAULT_CHARSET :
87 ANSI_CHARSET;
88 spec. lfOutPrecision = spec. lfClipPrecision = spec. lfQuality = 0;
89 spec. lfPitchAndFamily =
90 ( font == (int) kGraphics_font::COURIER ? FIXED_PITCH : font == kGraphics_font_IPATIMES ? DEFAULT_PITCH : VARIABLE_PITCH ) |
91 ( font == (int) kGraphics_font::HELVETICA ? FF_SWISS : font == (int) kGraphics_font::COURIER ? FF_MODERN :
92 font == kGraphics_font_CHINESE ? FF_DONTCARE :
93 font == kGraphics_font_JAPANESE ? FF_DONTCARE :
94 font >= kGraphics_font_IPATIMES ? FF_DONTCARE : FF_ROMAN );
95 if (font == kGraphics_font_IPATIMES && ! ipaInited && ! (Melder_debug == 15)) {
96 LOGFONTW logFont;
97 logFont. lfCharSet = DEFAULT_CHARSET;
98 logFont. lfPitchAndFamily = 0;
99 wcscpy (logFont. lfFaceName, L"Charis"); // try Charis 7
100 EnumFontFamiliesExW (my d_gdiGraphicsContext, & logFont, fontFuncEx_charis, 0, 0);
101 if (hasCharis) {
102 hasCharis7 = true;
103 } else {
104 wcscpy (logFont. lfFaceName, L"Charis SIL"); // try Charis 6
105 EnumFontFamiliesExW (my d_gdiGraphicsContext, & logFont, fontFuncEx_charis, 0, 0);
106 }
107 wcscpy (logFont. lfFaceName, L"Doulos SIL");
108 EnumFontFamiliesExW (my d_gdiGraphicsContext, & logFont, fontFuncEx_doulos, 0, 0);
109 ipaInited = true;
110 if (! hasCharis && ! hasDoulos) {
111 /* BUG: The next warning may cause reentry of drawing (on window exposure) and lead to crash. Some code must be non-reentrant !! */
112 Melder_warning (U"The phonetic font is not available.\n"
113 "Several characters may not look correct.\n"
114 "You can download phonetics fonts via praat.org "
115 "(go to the download page for Windows)."
116 );
117 }
118 }
119 wcscpy (spec. lfFaceName,
120 font == (int) kGraphics_font::HELVETICA ? L"Arial" :
121 font == (int) kGraphics_font::TIMES ? L"Times New Roman" :
122 font == (int) kGraphics_font::COURIER ? L"Courier New" :
123 font == (int) kGraphics_font::PALATINO ? L"Book Antiqua" :
124 font == kGraphics_font_SYMBOL ? L"Symbol" :
125 font == kGraphics_font_IPATIMES ? ( hasDoulos && style == 0 ? L"Doulos SIL"
126 : hasCharis ? ( hasCharis7 ? L"Charis" : L"Charis SIL" )
127 : L"Times New Roman"
128 ) :
129 font == kGraphics_font_DINGBATS ? L"Wingdings" :
130 font == kGraphics_font_CHINESE ? L"SimSun" :
131 font == kGraphics_font_JAPANESE ? L"MS UI Gothic" :
132 L"");
133 return CreateFontIndirectW (& spec);
134 }
135 #endif
136
137 #if cairocxx . . $ `sys/GraphicsP.h:54:10`!
138 static PangoFontDescription *PangoFontDescription_createcxx . . $ PangoFontDescription_create(450a9beac11eb0c7). (int font, _Graphics_widecharcxx . . $ _Graphics_widechar# *lc) {
139 static PangoFontDescription *fontDescriptions [1 + kGraphics_font_DINGBATScxx . . $ `sys/GraphicsP.h:41:9`!];
140 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (font >= 0 && font <= kGraphics_font_DINGBATScxx . . $ `sys/GraphicsP.h:41:9`!);
141 if (! fontDescriptions [font]) {
142 const char *fontFace =
143 font == (int) kGraphics_fontcxx . . $ kGraphics_font#::HELVETICAcxx . . $ kGraphics_font#HELVETICA. ? "Helvetica" :
144 font == (int) kGraphics_fontcxx . . $ kGraphics_font#::TIMEScxx . . $ kGraphics_font#TIMES. ? "Times" :
145 font == (int) kGraphics_fontcxx . . $ kGraphics_font#::COURIERcxx . . $ kGraphics_font#COURIER. ? "Courier New" :
146 font == (int) kGraphics_fontcxx . . $ kGraphics_font#::PALATINOcxx . . $ kGraphics_font#PALATINO. ? "Palatino" :
147 font == kGraphics_font_IPATIMEScxx . . $ `sys/GraphicsP.h:38:9`! ? "Doulos SIL" :
148 font == kGraphics_font_IPAPALATINOcxx . . $ `sys/GraphicsP.h:39:9`! ? ( hasCharis7cxx . . $ hasCharis7. ? "Charis" : "Charis SIL" ) :
149 font == kGraphics_font_DINGBATScxx . . $ `sys/GraphicsP.h:41:9`! ? "Dingbats" : "Serif";
150 fontDescriptions [font] = pango_font_description_from_string (fontFace);
151 }
152
153 PangoStyle slant = (lc -> stylecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#style. & Graphics_ITALICcxx . . $ `sys/Graphics.h:263:9`! ? PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL);
154 pango_font_description_set_style (fontDescriptions [font], slant);
155
156 PangoWeight weight = (lc -> stylecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#style. & Graphics_BOLDcxx . . $ `sys/Graphics.h:262:9`! ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL);
157 pango_font_description_set_weight (fontDescriptions [font], weight);
158 pango_font_description_set_absolute_size (fontDescriptions [font], (int) (lc -> sizecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#size. * PANGO_SCALEcxx . . $ `<external>/16549852590339199443/pango-types.h:96:9`!));
159 return fontDescriptions [font];
160 }
161 #endif
162
163 inline static bool isDiacriticcxx . . $ isDiacritic(3849ef472692fb84). (Longchar_Infocxx . . $ Longchar_Info# info, int font) {
164 if (info -> isDiacriticcxx . . $ structLongchar_Info#isDiacritic. == 0)
165 return false;
166 if (info -> isDiacriticcxx . . $ structLongchar_Info#isDiacritic. == 1)
167 return true;
168 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (info -> isDiacritic == 2); // corner
169 if (font == kGraphics_font_IPATIMEScxx . . $ `sys/GraphicsP.h:38:9`! || font == kGraphics_font_IPAPALATINOcxx . . $ `sys/GraphicsP.h:39:9`!)
170 return false; // Doulos or Charis
171 return true; // e.g. Times substitutes a zero-width corner
172 }
173
174 /*
175 Most operating systems provide automatic font substitution nowadays,
176 so that e.g. phonetic characters will be drawn recognizably even if the
177 user-preferred font is e.g. Times, Helvetica, Courier or Palatino
178 and the phonetic characters are not available in that user font.
179
180 However, on some systems the substituted font might really be a last resort
181 font that does not look at all similar to the user font. An example is
182 the use of the sans-serif font Lucida Grande for phonetic characters
183 within a stretch of a serif font such as Times or Palatino.
184
185 This is not good enough for Praat. We need more control over the shape
186 of phonetic characters. We therefore advise the use of Doulos SIL,
187 which is Times-like, or Charis, which is Palatino-like.
188 For true continuity between non-phonetic and phonetic characters it is
189 mandatory that the exact same font is used for both types of characters,
190 so we use Doulos SIL to replace Times even for non-phonetic characters,
191 and Charis to replace Palatino even for non-phonetic characters.
192 A technical issue that makes this even more important is that diacritics
193 can look really weird if at the beginning of a Praat font stretch:
194 a "b" followed by a ring below will not be aligned correctly if they
195 are part of different Praat font stretches.
196
197 Beside Praat-enforced visual font continuity, there are some more issues,
198 such as that the "/" (slash) character should extend below the baseline
199 whenever it is used in an equation or to demarcate a phonological
200 representation.
201 */
202 #if cairocxx . . $ `sys/GraphicsP.h:54:10`! || quartzcxx . . $ `sys/GraphicsP.h:57:10`!
203 inline static int chooseFontcxx . . $ chooseFont(376584643d88fb21). (Graphicscxx . . $ Graphics# me, _Graphics_widecharcxx . . $ _Graphics_widechar# *lc) {
204 /*
205 When we arrive here, the character's font is the "user-preferred font",
206 which is Courier if the user asked for code style (e.g. between "$$" and "$"),
207 or otherwise Times, Helvetica, Courier or Palatino, as chosen from a font menu.
208
209 Exception: if the character is a slash, its font has already been converted to Courier.
210 */
211 int font = lc -> fontcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#font..integer_cxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#$anonymous_type_2#integer_.;
212 Longchar_Infocxx . . $ Longchar_Info# info = lc -> karInfocxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#karInfo.;
213 int alphabet = info -> alphabetcxx . . $ structLongchar_Info#alphabet.;
214
215 if (font == (int) kGraphics_fontcxx . . $ kGraphics_font#::COURIERcxx . . $ kGraphics_font#COURIER.) {
216 constexpr bool systemSubstitutesMonospacedSerifFontForIpaCourier = (quartzcxx . . $ `sys/GraphicsP.h:57:10`!);
217 if (systemSubstitutesMonospacedSerifFontForIpaCourier) {
218 /*
219 No need to check whether the character is phonetic or not.
220 */
221 return (int) kGraphics_fontcxx . . $ kGraphics_font#::COURIERcxx . . $ kGraphics_font#COURIER.;
222 }
223 if (alphabet == Longchar_SYMBOLcxx . . $ `kar/longchar.h:44:9`! ||
224 alphabet == Longchar_PHONETICcxx . . $ `kar/longchar.h:45:9`! ||
225 lc [1]. karcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#kar. > U'\t' && lc [1]. karInfocxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#karInfo. -> isDiacriticcxx . . $ structLongchar_Info#isDiacritic.) // inspect next character to ensure diacritic continuity
226 {
227 /*
228 Serif is more important than monospaced,
229 and Charis looks slightly better within Courier than Doulos does.
230 */
231 if (hasChariscxx . . $ hasCharis.)
232 return kGraphics_font_IPAPALATINOcxx . . $ `sys/GraphicsP.h:39:9`!;
233 if (hasDouloscxx . . $ hasDoulos.)
234 return kGraphics_font_IPATIMEScxx . . $ `sys/GraphicsP.h:38:9`!;
235 }
236 return (int) kGraphics_fontcxx . . $ kGraphics_font#::COURIERcxx . . $ kGraphics_font#COURIER.;
237 }
238 font =
239 alphabet == Longchar_SYMBOLcxx . . $ `kar/longchar.h:44:9`! || // ? kGraphics_font_SYMBOL :
240 alphabet == Longchar_PHONETICcxx . . $ `kar/longchar.h:45:9`! ?
241 ( mycxx . . $ `melder/melder.h:44:9`! fontcxx . . $ structGraphics#font. == kGraphics_fontcxx . . $ kGraphics_font#::TIMEScxx . . $ kGraphics_font#TIMES. ?
242 ( hasDouloscxx . . $ hasDoulos. ?
243 ( lc -> stylecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#style. == 0 ?
244 kGraphics_font_IPATIMEScxx . . $ `sys/GraphicsP.h:38:9`! :
245 hasChariscxx . . $ hasCharis. ?
246 kGraphics_font_IPAPALATINOcxx . . $ `sys/GraphicsP.h:39:9`! : // other styles in Charis, because Doulos has no bold or italic
247 (int) kGraphics_fontcxx . . $ kGraphics_font#::TIMEScxx . . $ kGraphics_font#TIMES.
248 ) :
249 hasChariscxx . . $ hasCharis. ?
250 kGraphics_font_IPAPALATINOcxx . . $ `sys/GraphicsP.h:39:9`! :
251 (int) kGraphics_fontcxx . . $ kGraphics_font#::TIMEScxx . . $ kGraphics_font#TIMES. // on newer systems, Times and Times New Roman have a lot of phonetic characters
252 ) :
253 mycxx . . $ `melder/melder.h:44:9`! fontcxx . . $ structGraphics#font. == kGraphics_fontcxx . . $ kGraphics_font#::HELVETICAcxx . . $ kGraphics_font#HELVETICA. ?
254 (int) kGraphics_fontcxx . . $ kGraphics_font#::HELVETICAcxx . . $ kGraphics_font#HELVETICA. : // sans serif, so fall back on Lucida Grande or so for phonetic characters
255 /* my font must be kGraphics_font_PALATINO */
256 hasChariscxx . . $ hasCharis. && ! (Melder_debugcxx . . $ Melder_debug. == 900) ?
257 kGraphics_font_IPAPALATINOcxx . . $ `sys/GraphicsP.h:39:9`! :
258 hasDouloscxx . . $ hasDoulos. && ! (Melder_debugcxx . . $ Melder_debug. == 900) ?
259 ( lc -> stylecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#style. == 0 ?
260 kGraphics_font_IPATIMEScxx . . $ `sys/GraphicsP.h:38:9`! :
261 (int) kGraphics_fontcxx . . $ kGraphics_font#::TIMEScxx . . $ kGraphics_font#TIMES.
262 ) :
263 (int) kGraphics_fontcxx . . $ kGraphics_font#::PALATINOcxx . . $ kGraphics_font#PALATINO.
264 ) :
265 alphabet == Longchar_DINGBATScxx . . $ `kar/longchar.h:46:9`! ?
266 kGraphics_font_DINGBATScxx . . $ `sys/GraphicsP.h:41:9`! :
267 lc -> karcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#kar. >= 0x13A0 && lc -> karcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#kar. <= 0x13FF ?
268 kGraphics_font_CHEROKEEcxx . . $ `sys/GraphicsP.h:40:9`! :
269 mycxx . . $ `melder/melder.h:44:9`! fontcxx . . $ structGraphics#font. == kGraphics_fontcxx . . $ kGraphics_font#::TIMEScxx . . $ kGraphics_font#TIMES. ?
270 ( hasDouloscxx . . $ hasDoulos. ?
271 ( lc -> stylecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#style. == 0 ?
272 kGraphics_font_IPATIMEScxx . . $ `sys/GraphicsP.h:38:9`! :
273 lc -> stylecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#style. == Graphics_ITALICcxx . . $ `sys/Graphics.h:263:9`! ?
274 ( lc [1]. karcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#kar. > U'\t' && lc [1]. karInfocxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#karInfo. -> isDiacriticcxx . . $ structLongchar_Info#isDiacritic. && hasChariscxx . . $ hasCharis. ?
275 kGraphics_font_IPAPALATINOcxx . . $ `sys/GraphicsP.h:39:9`! : (int) kGraphics_fontcxx . . $ kGraphics_font#::TIMEScxx . . $ kGraphics_font#TIMES. ) : // correct placement of diacritics
276 hasChariscxx . . $ hasCharis. ?
277 kGraphics_font_IPAPALATINOcxx . . $ `sys/GraphicsP.h:39:9`! :
278 (int) kGraphics_fontcxx . . $ kGraphics_font#::TIMEScxx . . $ kGraphics_font#TIMES.
279 ) :
280 (int) kGraphics_fontcxx . . $ kGraphics_font#::TIMEScxx . . $ kGraphics_font#TIMES.
281 ) :
282 mycxx . . $ `melder/melder.h:44:9`! fontcxx . . $ structGraphics#font. == kGraphics_fontcxx . . $ kGraphics_font#::HELVETICAcxx . . $ kGraphics_font#HELVETICA. ?
283 (int) kGraphics_fontcxx . . $ kGraphics_font#::HELVETICAcxx . . $ kGraphics_font#HELVETICA. :
284 mycxx . . $ `melder/melder.h:44:9`! fontcxx . . $ structGraphics#font. == kGraphics_fontcxx . . $ kGraphics_font#::PALATINOcxx . . $ kGraphics_font#PALATINO. ?
285 ( hasChariscxx . . $ hasCharis. && ! (Melder_debugcxx . . $ Melder_debug. == 900) ?
286 kGraphics_font_IPAPALATINOcxx . . $ `sys/GraphicsP.h:39:9`! :
287 (int) kGraphics_fontcxx . . $ kGraphics_font#::PALATINOcxx . . $ kGraphics_font#PALATINO.
288 ) :
289 (int) mycxx . . $ `melder/melder.h:44:9`! fontcxx . . $ structGraphics#font.; // why not lc -> font.integer_?
290 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (font >= 0 && font <= kGraphics_font_DINGBATScxx . . $ `sys/GraphicsP.h:41:9`!);
291 return font;
292 }
293 #endif
294
295 static void charSizecxx . . $ charSize(a30f1ce99f0f9c5d). (Graphicscxx . . $ Graphics# anyGraphics, _Graphics_widecharcxx . . $ _Graphics_widechar# *lc) {
296 if (anyGraphics -> screencxx . . $ structGraphics#screen.) {
297 #if cairocxx . . $ `sys/GraphicsP.h:54:10`!
298 GraphicsScreencxx . . $ GraphicsScreen# me = static_cast <GraphicsScreencxx . . $ GraphicsScreen#> (anyGraphics);
299 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (mycxx . . $ `melder/melder.h:44:9`! duringXor);
300 const int normalSize = mycxx . . $ `melder/melder.h:44:9`! fontSizecxx . . $ structGraphics#fontSize. * mycxx . . $ `melder/melder.h:44:9`! resolutioncxx . . $ structGraphics#resolution. / 72.0;
301 const int smallSize = (3 * normalSize + 2) / 4;
302 const int size = ( lc -> sizecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#size. < 100 ? smallSize : normalSize );
303 lc -> widthcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#width. = 7;
304 lc -> baselinecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#baseline. *= mycxx . . $ `melder/melder.h:44:9`! fontSizecxx . . $ structGraphics#fontSize. * 0.01;
305 lc -> codecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#code. = lc -> karcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#kar.;
306 lc -> fontcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#font..stringcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#$anonymous_type_2#string. = nullptr;
307 lc -> fontcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#font..integer_cxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#$anonymous_type_2#integer_. = 0;
308 lc -> sizecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#size. = size;
309 #elif gdi
310 GraphicsScreen me = static_cast <GraphicsScreen> (anyGraphics);
311 Longchar_Info info = lc -> karInfo;
312 const int normalSize = win_size2isize (my fontSize);
313 const int smallSize = (3 * normalSize + 2) / 4;
314 int font = info -> alphabet == Longchar_SYMBOL ? kGraphics_font_SYMBOL :
315 info -> alphabet == Longchar_PHONETIC ? kGraphics_font_IPATIMES :
316 info -> alphabet == Longchar_DINGBATS ? kGraphics_font_DINGBATS : lc -> font.integer_;
317 if ((unsigned int) lc -> kar >= 0x2E80 && (unsigned int) lc -> kar <= 0x9FFF)
318 font = ( theGraphicsCjkFontStyle == kGraphics_cjkFontStyle::CHINESE ? kGraphics_font_CHINESE : kGraphics_font_JAPANESE );
319 const int size = ( lc -> size < 100 ? smallSize : normalSize );
320 const int style = lc -> style & (Graphics_ITALIC | Graphics_BOLD); // take out Graphics_CODE
321 HFONT fontInfo = fonts [(int) my resolutionNumber] [font] [size] [style];
322 if (! fontInfo) {
323 fontInfo = loadFont (me, font, size, style);
324 if (! fontInfo)
325 return;
326 fonts [(int) my resolutionNumber] [font] [size] [style] = fontInfo;
327 }
328 SIZE extent;
329 lc -> code =
330 font == kGraphics_font_IPATIMES ||
331 font == (int) kGraphics_font::TIMES ||
332 font == (int) kGraphics_font::HELVETICA ||
333 font == kGraphics_font_CHINESE ||
334 font == kGraphics_font_JAPANESE ||
335 font == (int) kGraphics_font::COURIER ? lc -> kar :
336 info -> winEncoding;
337 if (lc -> code == 0) {
338 _Graphics_widechar *lc2;
339 if (lc -> kar == UNICODE_LATIN_SMALL_LETTER_SCHWA_WITH_HOOK) {
340 info = Longchar_getInfo (U's', U'w');
341 lc -> kar = info -> unicode;
342 lc -> code = info -> winEncoding;
343 for (lc2 = lc + 1; lc2 -> kar != U'\0'; lc2 ++) { }
344 lc2 [1]. kar = U'\0';
345 while (lc2 - lc > 0) {
346 lc2 [0] = lc2 [-1];
347 lc2 --;
348 }
349 lc [1]. kar = UNICODE_MODIFIER_LETTER_RHOTIC_HOOK;
350 } else if (lc -> kar == UNICODE_LATIN_SMALL_LETTER_L_WITH_MIDDLE_TILDE) {
351 info = Longchar_getInfo (U'l', U' ');
352 lc -> kar = info -> unicode;
353 lc -> code = info -> winEncoding;
354 for (lc2 = lc + 1; lc2 -> kar != U'\0'; lc2 ++) { }
355 lc2 [1]. kar = U'\0';
356 while (lc2 - lc > 0) {
357 lc2 [0] = lc2 [-1];
358 lc2 --;
359 }
360 lc [1]. kar = UNICODE_COMBINING_TILDE_OVERLAY;
361 }
362 }
363 SelectFont (my d_gdiGraphicsContext, fontInfo);
364 if (lc -> code <= 0x00FFFF) {
365 char16 code = (char16) lc -> code;
366 GetTextExtentPoint32W (my d_gdiGraphicsContext, (WCHAR *) & code, 1, & extent);
367 } else {
368 char32 code [2] { lc -> code, U'\0' };
369 GetTextExtentPoint32W (my d_gdiGraphicsContext, Melder_peek32toW (code), 2, & extent);
370 }
371 lc -> width = extent. cx;
372 lc -> baseline *= my fontSize * 0.01 * my resolution / 72.0;
373 lc -> font.string = nullptr;
374 lc -> font.integer_ = font; // kGraphics_font_HELVETICA .. kGraphics_font_DINGBATS
375 lc -> size = size; // 0..4 instead of 10..24
376 lc -> style = style; // without Graphics_CODE
377 #elif quartz
378 #endif
379 } else if (anyGraphics -> postScriptcxx . . $ structGraphics#postScript.) {
380 GraphicsPostscriptcxx . . $ GraphicsPostscript# me = static_cast <GraphicsPostscriptcxx . . $ GraphicsPostscript#> (anyGraphics);
381 const int normalSize = (int) ((double) mycxx . . $ `melder/melder.h:44:9`! fontSizecxx . . $ structGraphics#fontSize. * (double) mycxx . . $ `melder/melder.h:44:9`! resolutioncxx . . $ structGraphics#resolution. / 72.0);
382 Longchar_Infocxx . . $ Longchar_Info# info = lc -> karInfocxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#karInfo.;
383 const int font =
384 info -> alphabetcxx . . $ structLongchar_Info#alphabet. == Longchar_SYMBOLcxx . . $ `kar/longchar.h:44:9`! ? kGraphics_font_SYMBOLcxx . . $ `sys/GraphicsP.h:37:9`! :
385 info -> alphabetcxx . . $ structLongchar_Info#alphabet. == Longchar_PHONETICcxx . . $ `kar/longchar.h:45:9`! ? kGraphics_font_IPATIMEScxx . . $ `sys/GraphicsP.h:38:9`! :
386 info -> alphabetcxx . . $ structLongchar_Info#alphabet. == Longchar_DINGBATScxx . . $ `kar/longchar.h:46:9`! ? kGraphics_font_DINGBATScxx . . $ `sys/GraphicsP.h:41:9`! :
387 lc -> fontcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#font..integer_cxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#$anonymous_type_2#integer_.
388 ;
389 const int style =
390 lc -> stylecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#style. == Graphics_ITALICcxx . . $ `sys/Graphics.h:263:9`! ? Graphics_ITALICcxx . . $ `sys/Graphics.h:263:9`! :
391 lc -> stylecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#style. == Graphics_BOLDcxx . . $ `sys/Graphics.h:262:9`! || lc -> linkcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#link. ? Graphics_BOLDcxx . . $ `sys/Graphics.h:262:9`! :
392 lc -> stylecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#style. == Graphics_BOLD_ITALICcxx . . $ `sys/Graphics.h:264:9`! ? Graphics_BOLD_ITALICcxx . . $ `sys/Graphics.h:264:9`! :
393 0
394 ;
395 if (! mycxx . . $ `melder/melder.h:44:9`! fontInfoscxx . . $ structGraphicsPostscript#fontInfos. [font] [style]) {
396 const char *fontInfo, *secondaryFontInfo = nullptr, *tertiaryFontInfo = nullptr;
397 if (font == (int) kGraphics_fontcxx . . $ kGraphics_font#::COURIERcxx . . $ kGraphics_font#COURIER.) {
398 fontInfo = style == Graphics_BOLDcxx . . $ `sys/Graphics.h:262:9`! ? "Courier-Bold" :
399 style == Graphics_ITALICcxx . . $ `sys/Graphics.h:263:9`! ? "Courier-Oblique" :
400 style == Graphics_BOLD_ITALICcxx . . $ `sys/Graphics.h:264:9`! ? "Courier-BoldOblique" : "Courier";
401 secondaryFontInfo = style == Graphics_BOLDcxx . . $ `sys/Graphics.h:262:9`! ? "CourierNewPS-BoldMT" :
402 style == Graphics_ITALICcxx . . $ `sys/Graphics.h:263:9`! ? "CourierNewPS-ItalicMT" :
403 style == Graphics_BOLD_ITALICcxx . . $ `sys/Graphics.h:264:9`! ? "CourierNewPS-BoldItalicMT" : "CourierNewPSMT";
404 tertiaryFontInfo = style == Graphics_BOLDcxx . . $ `sys/Graphics.h:262:9`! ? "CourierNew-Bold" :
405 style == Graphics_ITALICcxx . . $ `sys/Graphics.h:263:9`! ? "CourierNew-Italic" :
406 style == Graphics_BOLD_ITALICcxx . . $ `sys/Graphics.h:264:9`! ? "CourierNew-BoldItalic" : "CourierNew";
407 } else if (font == (int) kGraphics_fontcxx . . $ kGraphics_font#::TIMEScxx . . $ kGraphics_font#TIMES.) {
408 fontInfo = style == Graphics_BOLDcxx . . $ `sys/Graphics.h:262:9`! ? "Times-Bold" :
409 style == Graphics_ITALICcxx . . $ `sys/Graphics.h:263:9`! ? "Times-Italic" :
410 style == Graphics_BOLD_ITALICcxx . . $ `sys/Graphics.h:264:9`! ? "Times-BoldItalic" : "Times-Roman";
411 secondaryFontInfo = style == Graphics_BOLDcxx . . $ `sys/Graphics.h:262:9`! ? "TimesNewRomanPS-BoldMT" :
412 style == Graphics_ITALICcxx . . $ `sys/Graphics.h:263:9`! ? "TimesNewRomanPS-ItalicMT" :
413 style == Graphics_BOLD_ITALICcxx . . $ `sys/Graphics.h:264:9`! ? "TimesNewRomanPS-BoldItalicMT" : "TimesNewRomanPSMT";
414 tertiaryFontInfo = style == Graphics_BOLDcxx . . $ `sys/Graphics.h:262:9`! ? "TimesNewRoman-Bold" :
415 style == Graphics_ITALICcxx . . $ `sys/Graphics.h:263:9`! ? "TimesNewRoman-Italic" :
416 style == Graphics_BOLD_ITALICcxx . . $ `sys/Graphics.h:264:9`! ? "TimesNewRoman-BoldItalic" : "TimesNewRoman";
417 } else if (font == (int) kGraphics_fontcxx . . $ kGraphics_font#::PALATINOcxx . . $ kGraphics_font#PALATINO.) {
418 fontInfo = style == Graphics_BOLDcxx . . $ `sys/Graphics.h:262:9`! ? "Palatino-Bold" :
419 style == Graphics_ITALICcxx . . $ `sys/Graphics.h:263:9`! ? "Palatino-Italic" :
420 style == Graphics_BOLD_ITALICcxx . . $ `sys/Graphics.h:264:9`! ? "Palatino-BoldItalic" : "Palatino-Roman";
421 secondaryFontInfo = style == Graphics_BOLDcxx . . $ `sys/Graphics.h:262:9`! ? "BookAntiquaPS-BoldMT" :
422 style == Graphics_ITALICcxx . . $ `sys/Graphics.h:263:9`! ? "BookAntiquaPS-ItalicMT" :
423 style == Graphics_BOLD_ITALICcxx . . $ `sys/Graphics.h:264:9`! ? "BookAntiquaPS-BoldItalicMT" : "BookAntiquaPSMT";
424 tertiaryFontInfo = style == Graphics_BOLDcxx . . $ `sys/Graphics.h:262:9`! ? "BookAntiqua-Bold" :
425 style == Graphics_ITALICcxx . . $ `sys/Graphics.h:263:9`! ? "BookAntiqua-Italic" :
426 style == Graphics_BOLD_ITALICcxx . . $ `sys/Graphics.h:264:9`! ? "BookAntiqua-BoldItalic" : "BookAntiqua";
427 } else if (font == kGraphics_font_IPATIMEScxx . . $ `sys/GraphicsP.h:38:9`!) {
428 if (mycxx . . $ `melder/melder.h:44:9`! includeFontscxx . . $ structGraphicsPostscript#includeFonts. && ! mycxx . . $ `melder/melder.h:44:9`! loadedXipacxx . . $ structGraphicsPostscript#loadedXipa.) {
429 const char **p;
430 for (p = & ipaSerifRegularPScxx . . $ ipaSerifRegularPS. [0]; *p; p ++)
431 mycxx . . $ `melder/melder.h:44:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. (mycxx . . $ `melder/melder.h:44:9`! d_filecxx . . $ structGraphicsPostscript#d_file., "%s", *p);
432 mycxx . . $ `melder/melder.h:44:9`! loadedXipacxx . . $ structGraphicsPostscript#loadedXipa. = true;
433 }
434 fontInfo = mycxx . . $ `melder/melder.h:44:9`! useSilipaPScxx . . $ structGraphicsPostscript#useSilipaPS. ?
435 (style == Graphics_BOLDcxx . . $ `sys/Graphics.h:262:9`! || style == Graphics_BOLD_ITALICcxx . . $ `sys/Graphics.h:264:9`! ? "SILDoulosIPA93Bold" : "SILDoulosIPA93Regular") :
436 "TeX-xipa10-Praat-Regular";
437 } else if (font == kGraphics_font_SYMBOLcxx . . $ `sys/GraphicsP.h:37:9`!) {
438 fontInfo = "Symbol";
439 } else if (font == kGraphics_font_DINGBATScxx . . $ `sys/GraphicsP.h:41:9`!) {
440 fontInfo = "ZapfDingbats";
441 } else {
442 fontInfo = style == Graphics_BOLDcxx . . $ `sys/Graphics.h:262:9`! ? "Helvetica-Bold" :
443 style == Graphics_ITALICcxx . . $ `sys/Graphics.h:263:9`! ? "Helvetica-Oblique" :
444 style == Graphics_BOLD_ITALICcxx . . $ `sys/Graphics.h:264:9`! ? "Helvetica-BoldOblique" : "Helvetica";
445 secondaryFontInfo = style == Graphics_BOLDcxx . . $ `sys/Graphics.h:262:9`! ? "Arial-BoldMT" :
446 style == Graphics_ITALICcxx . . $ `sys/Graphics.h:263:9`! ? "Arial-ItalicMT" :
447 style == Graphics_BOLD_ITALICcxx . . $ `sys/Graphics.h:264:9`! ? "Arial-BoldItalicMT" : "ArialMT";
448 tertiaryFontInfo = style == Graphics_BOLDcxx . . $ `sys/Graphics.h:262:9`! ? "Arial-Bold" :
449 style == Graphics_ITALICcxx . . $ `sys/Graphics.h:263:9`! ? "Arial-Italic" :
450 style == Graphics_BOLD_ITALICcxx . . $ `sys/Graphics.h:264:9`! ? "Arial-BoldItalic" : "Arial";
451 }
452 mycxx . . $ `melder/melder.h:44:9`! fontInfoscxx . . $ structGraphicsPostscript#fontInfos. [font] [style] = Melder_malloc_fcxx . . $ `melder/melder_alloc.h:30:9`! (char, 200);
453 if (font == kGraphics_font_IPATIMEScxx . . $ `sys/GraphicsP.h:38:9`! || font == kGraphics_font_SYMBOLcxx . . $ `sys/GraphicsP.h:37:9`! || font == kGraphics_font_DINGBATScxx . . $ `sys/GraphicsP.h:41:9`!) {
454 strcpy (mycxx . . $ `melder/melder.h:44:9`! fontInfoscxx . . $ structGraphicsPostscript#fontInfos. [font] [style], fontInfo);
455 } else {
456 snprintf (mycxx . . $ `melder/melder.h:44:9`! fontInfoscxx . . $ structGraphicsPostscript#fontInfos. [font] [style],200, "%s-Praat", fontInfo);
457 if (thePrintercxx . . $ thePrinter.. fontChoiceStrategycxx . . $ Printer#fontChoiceStrategy. == kGraphicsPostscript_fontChoiceStrategycxx . . $ kGraphicsPostscript_fontChoiceStrategy#::LINOTYPEcxx . . $ kGraphicsPostscript_fontChoiceStrategy#LINOTYPE.) {
458 mycxx . . $ `melder/melder.h:44:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. (mycxx . . $ `melder/melder.h:44:9`! d_filecxx . . $ structGraphicsPostscript#d_file., "/%s /%s-Praat PraatEncode\n", fontInfo, fontInfo);
459 } else if (thePrintercxx . . $ thePrinter.. fontChoiceStrategycxx . . $ Printer#fontChoiceStrategy. == kGraphicsPostscript_fontChoiceStrategycxx . . $ kGraphicsPostscript_fontChoiceStrategy#::MONOTYPEcxx . . $ kGraphicsPostscript_fontChoiceStrategy#MONOTYPE.) {
460 mycxx . . $ `melder/melder.h:44:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. (mycxx . . $ `melder/melder.h:44:9`! d_filecxx . . $ structGraphicsPostscript#d_file., "/%s /%s-Praat PraatEncode\n", tertiaryFontInfo, fontInfo);
461 } else if (thePrintercxx . . $ thePrinter.. fontChoiceStrategycxx . . $ Printer#fontChoiceStrategy. == kGraphicsPostscript_fontChoiceStrategycxx . . $ kGraphicsPostscript_fontChoiceStrategy#::PS_MONOTYPEcxx . . $ kGraphicsPostscript_fontChoiceStrategy#PS_MONOTYPE.) {
462 mycxx . . $ `melder/melder.h:44:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. (mycxx . . $ `melder/melder.h:44:9`! d_filecxx . . $ structGraphicsPostscript#d_file., "/%s /%s-Praat PraatEncode\n", secondaryFontInfo, fontInfo);
463 } else {
464 /* Automatic font choice strategy. */
465 if (secondaryFontInfo) {
466 mycxx . . $ `melder/melder.h:44:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. (mycxx . . $ `melder/melder.h:44:9`! d_filecxx . . $ structGraphicsPostscript#d_file.,
467 "/%s /Font resourcestatus\n"
468 "{ pop pop /%s /%s-Praat PraatEncode }\n"
469 "{ /%s /%s-Praat PraatEncode }\n"
470 "ifelse\n",
471 secondaryFontInfo, secondaryFontInfo, fontInfo, fontInfo, fontInfo);
472 } else {
473 mycxx . . $ `melder/melder.h:44:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. (mycxx . . $ `melder/melder.h:44:9`! d_filecxx . . $ structGraphicsPostscript#d_file., "/%s /%s-Praat PraatEncode\n", fontInfo, fontInfo);
474 }
475 }
476 }
477 }
478 lc -> fontcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#font..integer_cxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#$anonymous_type_2#integer_. = 0;
479 lc -> fontcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#font..stringcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#$anonymous_type_2#string. = mycxx . . $ `melder/melder.h:44:9`! fontInfoscxx . . $ structGraphicsPostscript#fontInfos. [font] [style];
480
481 /*
482 * Convert size and baseline information to device coordinates.
483 */
484 lc -> sizecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#size. *= normalSize * 0.01;
485 lc -> baselinecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#baseline. *= normalSize * 0.01;
486
487 if (font == (int) kGraphics_fontcxx . . $ kGraphics_font#::COURIERcxx . . $ kGraphics_font#COURIER.) {
488 lc -> widthcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#width. = 600; // Courier
489 } else if (style == 0) {
490 if (font == (int) kGraphics_fontcxx . . $ kGraphics_font#::TIMEScxx . . $ kGraphics_font#TIMES.)
491 lc -> widthcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#width. = info -> pscxx . . $ structLongchar_Info#ps..timescxx . . $ structLongchar_Info#$anonymous_type_0#times.;
492 else if (font == (int) kGraphics_fontcxx . . $ kGraphics_font#::HELVETICAcxx . . $ kGraphics_font#HELVETICA.)
493 lc -> widthcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#width. = info -> pscxx . . $ structLongchar_Info#ps..helveticacxx . . $ structLongchar_Info#$anonymous_type_0#helvetica.;
494 else if (font == (int) kGraphics_fontcxx . . $ kGraphics_font#::PALATINOcxx . . $ kGraphics_font#PALATINO.)
495 lc -> widthcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#width. = info -> pscxx . . $ structLongchar_Info#ps..palatinocxx . . $ structLongchar_Info#$anonymous_type_0#palatino.;
496 else if (font == kGraphics_font_SYMBOLcxx . . $ `sys/GraphicsP.h:37:9`!)
497 lc -> widthcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#width. = info -> pscxx . . $ structLongchar_Info#ps..timescxx . . $ structLongchar_Info#$anonymous_type_0#times.;
498 else if (mycxx . . $ `melder/melder.h:44:9`! useSilipaPScxx . . $ structGraphicsPostscript#useSilipaPS.)
499 lc -> widthcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#width. = info -> pscxx . . $ structLongchar_Info#ps..timesItaliccxx . . $ structLongchar_Info#$anonymous_type_0#timesItalic.; // ?
500 else
501 lc -> widthcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#width. = info -> pscxx . . $ structLongchar_Info#ps..timescxx . . $ structLongchar_Info#$anonymous_type_0#times.; // XIPA
502 } else if (style == Graphics_BOLDcxx . . $ `sys/Graphics.h:262:9`!) {
503 if (font == (int) kGraphics_fontcxx . . $ kGraphics_font#::TIMEScxx . . $ kGraphics_font#TIMES.)
504 lc -> widthcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#width. = info -> pscxx . . $ structLongchar_Info#ps..timesBoldcxx . . $ structLongchar_Info#$anonymous_type_0#timesBold.;
505 else if (font == (int) kGraphics_fontcxx . . $ kGraphics_font#::HELVETICAcxx . . $ kGraphics_font#HELVETICA.)
506 lc -> widthcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#width. = info -> pscxx . . $ structLongchar_Info#ps..helveticaBoldcxx . . $ structLongchar_Info#$anonymous_type_0#helveticaBold.;
507 else if (font == (int) kGraphics_fontcxx . . $ kGraphics_font#::PALATINOcxx . . $ kGraphics_font#PALATINO.)
508 lc -> widthcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#width. = info -> pscxx . . $ structLongchar_Info#ps..palatinoBoldcxx . . $ structLongchar_Info#$anonymous_type_0#palatinoBold.;
509 else if (font == kGraphics_font_SYMBOLcxx . . $ `sys/GraphicsP.h:37:9`!)
510 lc -> widthcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#width. = info -> pscxx . . $ structLongchar_Info#ps..timescxx . . $ structLongchar_Info#$anonymous_type_0#times.;
511 else if (mycxx . . $ `melder/melder.h:44:9`! useSilipaPScxx . . $ structGraphicsPostscript#useSilipaPS.)
512 lc -> widthcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#width. = info -> pscxx . . $ structLongchar_Info#ps..timesBoldItaliccxx . . $ structLongchar_Info#$anonymous_type_0#timesBoldItalic.; // ?
513 else
514 lc -> widthcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#width. = info -> pscxx . . $ structLongchar_Info#ps..timescxx . . $ structLongchar_Info#$anonymous_type_0#times.; // Symbol, IPA
515 } else if (style == Graphics_ITALICcxx . . $ `sys/Graphics.h:263:9`!) {
516 if (font == (int) kGraphics_fontcxx . . $ kGraphics_font#::TIMEScxx . . $ kGraphics_font#TIMES.)
517 lc -> widthcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#width. = info -> pscxx . . $ structLongchar_Info#ps..timesItaliccxx . . $ structLongchar_Info#$anonymous_type_0#timesItalic.;
518 else if (font == (int) kGraphics_fontcxx . . $ kGraphics_font#::HELVETICAcxx . . $ kGraphics_font#HELVETICA.)
519 lc -> widthcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#width. = info -> pscxx . . $ structLongchar_Info#ps..helveticacxx . . $ structLongchar_Info#$anonymous_type_0#helvetica.;
520 else if (font == (int) kGraphics_fontcxx . . $ kGraphics_font#::PALATINOcxx . . $ kGraphics_font#PALATINO.)
521 lc -> widthcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#width. = info -> pscxx . . $ structLongchar_Info#ps..palatinoItaliccxx . . $ structLongchar_Info#$anonymous_type_0#palatinoItalic.;
522 else if (font == kGraphics_font_SYMBOLcxx . . $ `sys/GraphicsP.h:37:9`!)
523 lc -> widthcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#width. = info -> pscxx . . $ structLongchar_Info#ps..timescxx . . $ structLongchar_Info#$anonymous_type_0#times.;
524 else if (mycxx . . $ `melder/melder.h:44:9`! useSilipaPScxx . . $ structGraphicsPostscript#useSilipaPS.)
525 lc -> widthcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#width. = info -> pscxx . . $ structLongchar_Info#ps..timesItaliccxx . . $ structLongchar_Info#$anonymous_type_0#timesItalic.;
526 else
527 lc -> widthcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#width. = info -> pscxx . . $ structLongchar_Info#ps..timescxx . . $ structLongchar_Info#$anonymous_type_0#times.; // Symbol, IPA
528 } else if (style == Graphics_BOLD_ITALICcxx . . $ `sys/Graphics.h:264:9`!) {
529 if (font == (int) kGraphics_fontcxx . . $ kGraphics_font#::TIMEScxx . . $ kGraphics_font#TIMES.)
530 lc -> widthcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#width. = info -> pscxx . . $ structLongchar_Info#ps..timesBoldItaliccxx . . $ structLongchar_Info#$anonymous_type_0#timesBoldItalic.;
531 else if (font == (int) kGraphics_fontcxx . . $ kGraphics_font#::HELVETICAcxx . . $ kGraphics_font#HELVETICA.)
532 lc -> widthcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#width. = info -> pscxx . . $ structLongchar_Info#ps..helveticaBoldcxx . . $ structLongchar_Info#$anonymous_type_0#helveticaBold.;
533 else if (font == (int) kGraphics_fontcxx . . $ kGraphics_font#::PALATINOcxx . . $ kGraphics_font#PALATINO.)
534 lc -> widthcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#width. = info -> pscxx . . $ structLongchar_Info#ps..palatinoBoldItaliccxx . . $ structLongchar_Info#$anonymous_type_0#palatinoBoldItalic.;
535 else if (font == kGraphics_font_SYMBOLcxx . . $ `sys/GraphicsP.h:37:9`!)
536 lc -> widthcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#width. = info -> pscxx . . $ structLongchar_Info#ps..timescxx . . $ structLongchar_Info#$anonymous_type_0#times.;
537 else if (mycxx . . $ `melder/melder.h:44:9`! useSilipaPScxx . . $ structGraphicsPostscript#useSilipaPS.)
538 lc -> widthcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#width. = info -> pscxx . . $ structLongchar_Info#ps..timesBoldItaliccxx . . $ structLongchar_Info#$anonymous_type_0#timesBoldItalic.;
539 else
540 lc -> widthcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#width. = info -> pscxx . . $ structLongchar_Info#ps..timescxx . . $ structLongchar_Info#$anonymous_type_0#times.; // Symbol, IPA
541 }
542 lc -> widthcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#width. *= lc -> sizecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#size. / 1000.0;
543 lc -> codecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#code. = ( font == kGraphics_font_IPATIMEScxx . . $ `sys/GraphicsP.h:38:9`! && mycxx . . $ `melder/melder.h:44:9`! useSilipaPScxx . . $ structGraphicsPostscript#useSilipaPS. ? info -> macEncodingcxx . . $ structLongchar_Info#macEncoding. : info -> psEncodingcxx . . $ structLongchar_Info#psEncoding. );
544 if (lc -> codecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#code. == 0) {
545 _Graphics_widecharcxx . . $ _Graphics_widechar# *lc2;
546 if (lc -> karcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#kar. == UNICODE_LATIN_SMALL_LETTER_SCHWA_WITH_HOOKcxx . . $ `kar/UnicodeData.h:1204:9`!) {
547 info = Longchar_getInfocxx . . $ Longchar_getInfo(7966861fb3bf62a0). (U's', U'w');
548 lc -> karcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#kar. = info -> unicodecxx . . $ structLongchar_Info#unicode.;
549 lc -> codecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#code. = info -> macEncodingcxx . . $ structLongchar_Info#macEncoding.;
550 lc -> widthcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#width. = info -> pscxx . . $ structLongchar_Info#ps..timesItaliccxx . . $ structLongchar_Info#$anonymous_type_0#timesItalic. * lc -> sizecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#size. / 1000.0;
551 for (lc2 = lc + 1; lc2 -> karcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#kar. != U'\0'; lc2 ++) { }
552 lc2 [1]. karcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#kar. = U'\0';
553 while (lc2 - lc > 0) {
554 lc2 [0] =cxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#`operator=`(bd3c6d962306cfe8). lc2 [-1];
555 lc2 --;
556 }
557 lc [1]. karcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#kar. = UNICODE_MODIFIER_LETTER_RHOTIC_HOOKcxx . . $ `kar/UnicodeData.h:1468:9`!;
558 } else if (lc -> karcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#kar. == UNICODE_LATIN_SMALL_LETTER_L_WITH_MIDDLE_TILDEcxx . . $ `kar/UnicodeData.h:1238:9`!) {
559 info = Longchar_getInfocxx . . $ Longchar_getInfo(7966861fb3bf62a0). (U'l', U' ');
560 lc -> codecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#code. = info -> macEncodingcxx . . $ structLongchar_Info#macEncoding.;
561 lc -> karcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#kar. = info -> unicodecxx . . $ structLongchar_Info#unicode.;
562 lc -> widthcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#width. = info -> pscxx . . $ structLongchar_Info#ps..timesItaliccxx . . $ structLongchar_Info#$anonymous_type_0#timesItalic. * lc -> sizecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#size. / 1000.0;
563 for (lc2 = lc + 1; lc2 -> karcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#kar. != U'\0'; lc2 ++) { }
564 lc2 [1]. karcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#kar. = U'\0';
565 while (lc2 - lc > 0) {
566 lc2 [0] =cxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#`operator=`(bd3c6d962306cfe8). lc2 [-1];
567 lc2 --;
568 }
569 lc [1]. karcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#kar. = UNICODE_COMBINING_TILDE_OVERLAYcxx . . $ `kar/UnicodeData.h:1640:9`!;
570 }
571 }
572 }
573 }
574
575 #if quartzcxx . . $ `sys/GraphicsP.h:57:10`!
576 static conststring32 quartz_getFontName (int font, int style) {
577 if (Melder_systemVersion < 110000)
578 style = 0; // style extension in the name was not needed on macOS X
579 switch (font) {
580 case (int) kGraphics_font::TIMES:
581 return
582 style == 0 ? U"Times New Roman"
583 : style == Graphics_BOLD ? U"Times New Roman Bold"
584 : style == Graphics_ITALIC ? U"Times New Roman Italic"
585 : U"Times New Roman Bold Italic";
586 case (int) kGraphics_font::HELVETICA:
587 return
588 style == 0 ? U"Arial"
589 : style == Graphics_BOLD ? U"Arial Bold"
590 : style == Graphics_ITALIC ? U"Arial Italic"
591 : U"Arial Bold Italic";
592 case (int) kGraphics_font::COURIER:
593 return
594 style == 0 ? U"Courier New"
595 : style == Graphics_BOLD ? U"Courier New Bold"
596 : style == Graphics_ITALIC ? U"Courier New Italic"
597 : U"Courier New Bold Italic";
598 case (int) kGraphics_font::PALATINO:
599 if (Melder_debug == 900)
600 return U"DG Meta Serif Science";
601 else
602 return
603 style == 0 ? U"Palatino"
604 : style == Graphics_BOLD ? U"Palatino Bold"
605 : style == Graphics_ITALIC ? U"Palatino Italic"
606 : U"Palatino Bold Italic";
607 case kGraphics_font_SYMBOL:
608 return U"Symbol";
609 case kGraphics_font_IPATIMES:
610 return U"Doulos SIL";
611 case kGraphics_font_IPAPALATINO:
612 if (hasCharis7)
613 return
614 style == 0 ? U"Charis"
615 : style == Graphics_BOLD ? U"Charis Bold"
616 : style == Graphics_ITALIC ? U"Charis Italic"
617 : U"Charis Bold Italic";
618 else
619 return
620 style == 0 ? U"Charis SIL"
621 : style == Graphics_BOLD ? U"Charis SIL Bold"
622 : style == Graphics_ITALIC ? U"Charis SIL Italic"
623 : U"Charis SIL Bold Italic";
624 case kGraphics_font_CHEROKEE:
625 return U"Plantagenet Cherokee";
626 case kGraphics_font_DINGBATS:
627 return U"Zapf Dingbats";
628 default:
629 return nullptr;
630 }
631 }
632 static CTFontRef quartz_getFontRef (int font, int size, int style) {
633 CTFontSymbolicTraits ctStyle = ( style & Graphics_BOLD ? kCTFontBoldTrait : 0 ) | ( style & Graphics_ITALIC ? kCTFontItalicTrait : 0 );
634 #if 1
635 CFStringRef key = kCTFontSymbolicTrait;
636 CFNumberRef value = CFNumberCreate (nullptr, kCFNumberIntType, & ctStyle);
637 CFIndex numberOfValues = 1;
638 CFDictionaryRef styleDict = CFDictionaryCreate (nullptr, (const void **) & key, (const void **) & value, numberOfValues,
639 & kCFTypeDictionaryKeyCallBacks, & kCFTypeDictionaryValueCallBacks);
640 CFRelease (value);
641 CFStringRef keys [2];
642 keys [0] = kCTFontTraitsAttribute;
643 keys [1] = kCTFontNameAttribute;
644 conststring32 fontName = quartz_getFontName (font, style);
645 CFStringRef cfFont = (CFStringRef) Melder_peek32toCfstring (fontName);
646 void *values [2] = { (void *) styleDict, (void *) cfFont };
647 CFDictionaryRef attributes = CFDictionaryCreate (nullptr, (const void **) & keys, (const void **) & values, 2,
648 & kCFTypeDictionaryKeyCallBacks, & kCFTypeDictionaryValueCallBacks);
649 CFRelease (styleDict);
650 CTFontDescriptorRef ctFontDescriptor = CTFontDescriptorCreateWithAttributes (attributes);
651 CFRelease (attributes);
652 #else
653 NSMutableDictionary *styleDict = [[NSMutableDictionary alloc] initWithCapacity: 1];
654 [styleDict setObject: [NSNumber numberWithUnsignedInt: ctStyle] forKey: (id) kCTFontSymbolicTrait];
655 NSMutableDictionary *attributes = [[NSMutableDictionary alloc] initWithCapacity: 2];
656 [attributes setObject: styleDict forKey: (id) kCTFontTraitsAttribute];
657 switch (font) {
658 case (int) kGraphics_font::TIMES: { [attributes setObject: @"Times New Roman" forKey: (id) kCTFontNameAttribute]; } break;
659 case (int) kGraphics_font::HELVETICA: { [attributes setObject: @"Arial" forKey: (id) kCTFontNameAttribute]; } break;
660 case (int) kGraphics_font::COURIER: { [attributes setObject: @"Courier New" forKey: (id) kCTFontNameAttribute]; } break;
661 case (int) kGraphics_font::PALATINO: { if (Melder_debug == 900)
662 [attributes setObject: @"DG Meta Serif Science" forKey: (id) kCTFontNameAttribute];
663 else
664 [attributes setObject: @"Palatino" forKey: (id) kCTFontNameAttribute];
665 } break;
666 case kGraphics_font_SYMBOL: { [attributes setObject: @"Symbol" forKey: (id) kCTFontNameAttribute]; } break;
667 case kGraphics_font_IPATIMES: { [attributes setObject: @"Doulos SIL" forKey: (id) kCTFontNameAttribute]; } break;
668 case kGraphics_font_IPAPALATINO: { [attributes setObject: @"Charis SIL" forKey: (id) kCTFontNameAttribute]; } break; DONT USE
669 case kGraphics_font_CHEROKEE: { [attributes setObject: @"Plantagenet Cherokee" forKey: (id) kCTFontNameAttribute]; } break;
670 case kGraphics_font_DINGBATS: { [attributes setObject: @"Zapf Dingbats" forKey: (id) kCTFontNameAttribute]; } break;
671 }
672 CTFontDescriptorRef ctFontDescriptor = CTFontDescriptorCreateWithAttributes ((CFMutableDictionaryRef) attributes);
673 [styleDict release];
674 [attributes release];
675 #endif
676 CTFontRef ctFont = CTFontCreateWithFontDescriptor (ctFontDescriptor, size, nullptr);
677 CFRelease (ctFontDescriptor);
678 return ctFont;
679 }
680 #endif
681
682 static void charDrawcxx . . $ charDraw(2ddfd830792099cd). (Graphicscxx . . $ Graphics# anyGraphics, int xDC, int yDC, _Graphics_widecharcxx . . $ _Graphics_widechar# *lc,
683 const char32cxx . . $ char32# codes [], int nchars, int width)
684 {
685 tracecxx . . $ `melder/melder_debug.h:60:10`! (U"nchars ", nchars, U" first ", (int) lc->kar, U" ", (char32) lc -> kar, U" rightToLeft ", lc->rightToLeft);
686 if (anyGraphics -> postScriptcxx . . $ structGraphics#postScript.) {
687 GraphicsPostscriptcxx . . $ GraphicsPostscript# me = static_cast <GraphicsPostscriptcxx . . $ GraphicsPostscript#> (anyGraphics);
688 const bool onlyRegular = lc -> fontcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#font..stringcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#$anonymous_type_2#string. [0] == 'S' ||
689 (lc -> fontcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#font..stringcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#$anonymous_type_2#string. [0] == 'T' && lc -> fontcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#font..stringcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#$anonymous_type_2#string. [1] == 'e'); // Symbol & SILDoulos !
690 const bool slant = (lc -> stylecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#style. & Graphics_ITALICcxx . . $ `sys/Graphics.h:263:9`!) && onlyRegular;
691 const bool thick = (lc -> stylecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#style. & Graphics_BOLDcxx . . $ `sys/Graphics.h:262:9`!) && onlyRegular;
692 if (lc -> fontcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#font..stringcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#$anonymous_type_2#string. != mycxx . . $ `melder/melder.h:44:9`! lastFidcxx . . $ structGraphicsPostscript#lastFid. || lc -> sizecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#size. != mycxx . . $ `melder/melder.h:44:9`! lastSizecxx . . $ structGraphicsPostscript#lastSize.)
693 mycxx . . $ `melder/melder.h:44:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. (mycxx . . $ `melder/melder.h:44:9`! d_filecxx . . $ structGraphicsPostscript#d_file., mycxx . . $ `melder/melder.h:44:9`! languageLevelcxx . . $ structGraphicsPostscript#languageLevel. == 1 ? "/%s %d FONT\n" : "/%s %d selectfont\n",
694 mycxx . . $ `melder/melder.h:44:9`! lastFidcxx . . $ structGraphicsPostscript#lastFid. = lc -> fontcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#font..stringcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#$anonymous_type_2#string., mycxx . . $ `melder/melder.h:44:9`! lastSizecxx . . $ structGraphicsPostscript#lastSize. = lc -> sizecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#size.);
695 if (lc -> linkcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#link.)
696 mycxx . . $ `melder/melder.h:44:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. (mycxx . . $ `melder/melder.h:44:9`! d_filecxx . . $ structGraphicsPostscript#d_file., "0 0 1 setrgbcolor\n");
697 for (int i = -3; i <= 3; i ++) {
698 if (i != 0 && ! thick)
699 continue;
700 mycxx . . $ `melder/melder.h:44:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. (mycxx . . $ `melder/melder.h:44:9`! d_filecxx . . $ structGraphicsPostscript#d_file., "%d %d M ", xDC + i, yDC);
701 if (mycxx . . $ `melder/melder.h:44:9`! textRotationcxx . . $ structGraphics#textRotation. != 0.0 || slant) {
702 mycxx . . $ `melder/melder.h:44:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. (mycxx . . $ `melder/melder.h:44:9`! d_filecxx . . $ structGraphicsPostscript#d_file., "gsave currentpoint translate ");
703 if (mycxx . . $ `melder/melder.h:44:9`! textRotationcxx . . $ structGraphics#textRotation. != 0.0)
704 mycxx . . $ `melder/melder.h:44:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. (mycxx . . $ `melder/melder.h:44:9`! d_filecxx . . $ structGraphicsPostscript#d_file., "%.6g rotate 0 0 M\n", (double) mycxx . . $ `melder/melder.h:44:9`! textRotationcxx . . $ structGraphics#textRotation.);
705 if (slant)
706 mycxx . . $ `melder/melder.h:44:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. (mycxx . . $ `melder/melder.h:44:9`! d_filecxx . . $ structGraphicsPostscript#d_file., "[1 0 0.25 1 0 0] concat 0 0 M\n");
707 }
708 mycxx . . $ `melder/melder.h:44:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. (mycxx . . $ `melder/melder.h:44:9`! d_filecxx . . $ structGraphicsPostscript#d_file., "(");
709 const char32cxx . . $ char32# *p = & codes [0];
710 while (*p) {
711 if (*p == U'(' || *p == U')' || *p == U'\\') {
712 mycxx . . $ `melder/melder.h:44:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. (mycxx . . $ `melder/melder.h:44:9`! d_filecxx . . $ structGraphicsPostscript#d_file., "\\%c", (unsigned char) *p);
713 } else if (*p >= 32 && *p <= 126) {
714 mycxx . . $ `melder/melder.h:44:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. (mycxx . . $ `melder/melder.h:44:9`! d_filecxx . . $ structGraphicsPostscript#d_file., "%c", (unsigned char) *p);
715 } else {
716 mycxx . . $ `melder/melder.h:44:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. (mycxx . . $ `melder/melder.h:44:9`! d_filecxx . . $ structGraphicsPostscript#d_file., "\\%d%d%d", (unsigned char) *p / 64,
717 ((unsigned char) *p % 64) / 8, (unsigned char) *p % 8);
718 }
719 p ++;
720 }
721 mycxx . . $ `melder/melder.h:44:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. (mycxx . . $ `melder/melder.h:44:9`! d_filecxx . . $ structGraphicsPostscript#d_file., ") show\n");
722 if (mycxx . . $ `melder/melder.h:44:9`! textRotationcxx . . $ structGraphics#textRotation. != 0.0 || slant)
723 mycxx . . $ `melder/melder.h:44:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. (mycxx . . $ `melder/melder.h:44:9`! d_filecxx . . $ structGraphicsPostscript#d_file., "grestore\n");
724 }
725 if (lc -> linkcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#link.)
726 mycxx . . $ `melder/melder.h:44:9`! d_printfcxx . . $ structGraphicsPostscript#d_printf. (mycxx . . $ `melder/melder.h:44:9`! d_filecxx . . $ structGraphicsPostscript#d_file., "0 0 0 setrgbcolor\n");
727 } else if (anyGraphics -> screencxx . . $ structGraphics#screen.) {
728 GraphicsScreencxx . . $ GraphicsScreen# me = static_cast <GraphicsScreencxx . . $ GraphicsScreen#> (anyGraphics);
729 #if cairocxx . . $ `sys/GraphicsP.h:54:10`!
730 if (! mycxx . . $ `melder/melder.h:44:9`! d_cairoGraphicsContextcxx . . $ structGraphicsScreen#d_cairoGraphicsContext.)
731 return;
732 // TODO!
733 if (lc -> linkcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#link.)
734 _Graphics_setColourcxx . . $ _Graphics_setColour(eb47b9513d3f4721). (me, Melder_BLUEcxx . . $ Melder_BLUE.);
735 int font = lc -> fontcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#font..integer_cxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#$anonymous_type_2#integer_.;
736 cairo_save (mycxx . . $ `melder/melder.h:44:9`! d_cairoGraphicsContextcxx . . $ structGraphicsScreen#d_cairoGraphicsContext.);
737 cairo_translate (mycxx . . $ `melder/melder.h:44:9`! d_cairoGraphicsContextcxx . . $ structGraphicsScreen#d_cairoGraphicsContext., xDC, yDC);
738 //cairo_scale (my d_cairoGraphicsContext, 1, -1);
739 cairo_rotate (mycxx . . $ `melder/melder.h:44:9`! d_cairoGraphicsContextcxx . . $ structGraphicsScreen#d_cairoGraphicsContext., - mycxx . . $ `melder/melder.h:44:9`! textRotationcxx . . $ structGraphics#textRotation. * NUMpicxx . . $ NUMpi. / 180.0);
740 const char *codes8 = Melder_peek32to8 (codes);
741 PangoFontDescription *font_description = PangoFontDescription_createcxx . . $ PangoFontDescription_create(450a9beac11eb0c7). (font, lc);
742 PangoLayout *layout = pango_cairo_create_layout (mycxx . . $ `melder/melder.h:44:9`! d_cairoGraphicsContextcxx . . $ structGraphicsScreen#d_cairoGraphicsContext.);
743 pango_layout_set_font_description (layout, font_description);
744 pango_layout_set_text (layout, codes8, -1);
745 cairo_move_to (mycxx . . $ `melder/melder.h:44:9`! d_cairoGraphicsContextcxx . . $ structGraphicsScreen#d_cairoGraphicsContext., 0 /*xDC*/, 0 /*yDC*/);
746 // instead of pango_cairo_show_layout we use pango_cairo_show_layout_line to
747 // get the same text origin as cairo_show_text, i.e. baseline left, instead of Pango's top left!
748 pango_cairo_show_layout_line (mycxx . . $ `melder/melder.h:44:9`! d_cairoGraphicsContextcxx . . $ structGraphicsScreen#d_cairoGraphicsContext., pango_layout_get_line_readonly (layout, 0));
749 g_object_unref (layout);
750 cairo_restore (mycxx . . $ `melder/melder.h:44:9`! d_cairoGraphicsContextcxx . . $ structGraphicsScreen#d_cairoGraphicsContext.);
751 if (lc -> linkcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#link.)
752 _Graphics_setColourcxx . . $ _Graphics_setColour(eb47b9513d3f4721). (me, mycxx . . $ `melder/melder.h:44:9`! colourcxx . . $ structGraphics#colour.);
753 return;
754 #elif gdi
755 const int font = lc -> font.integer_;
756 conststringW codesW = Melder_peek32toW (codes);
757 if (my duringXor) {
758 /*
759 On GDI, SetROP2 does not influence text drawing,
760 so we have to create a bitmap in the background
761 and use BitBlt with SRCINVERT as its ROP.
762 */
763 const int descent = (1.0/216) * my fontSize * my resolution;
764 const int ascent = (1.0/72) * my fontSize * my resolution;
765 const int maxWidth = 800, maxHeight = 200;
766 const int baseline = 100, top = baseline - ascent - 1, bottom = baseline + descent + 1;
767 static bool inited = false;
768 static HDC dc;
769 static HBITMAP bitmap;
770 if (! inited) {
771 dc = CreateCompatibleDC (my d_gdiGraphicsContext);
772 bitmap = CreateCompatibleBitmap (my d_gdiGraphicsContext, maxWidth, maxHeight);
773 SelectBitmap (dc, bitmap);
774 SetBkMode (dc, TRANSPARENT); // not the default!
775 SelectPen (dc, GetStockPen (BLACK_PEN));
776 SelectBrush (dc, GetStockBrush (BLACK_BRUSH));
777 SetTextAlign (dc, TA_LEFT | TA_BASELINE | TA_NOUPDATECP); // baseline is not the default!
778 inited = true;
779 }
780 width += 4; // for slant
781 Rectangle (dc, 0, top, width, bottom);
782 SelectFont (dc, fonts [(int) my resolutionNumber] [font] [lc -> size] [lc -> style]);
783 SetTextColor (dc, my d_winForegroundColour);
784 TextOutW (dc, 0, baseline, codesW, Melder16_length ((conststring16) codesW));
785 BitBlt (my d_gdiGraphicsContext, xDC, yDC - ascent, width, bottom - top, dc, 0, top, SRCINVERT);
786 return;
787 }
788 SelectPen (my d_gdiGraphicsContext, my d_winPen);
789 SelectBrush (my d_gdiGraphicsContext, my d_winBrush);
790 if (lc -> link)
791 SetTextColor (my d_gdiGraphicsContext, RGB (0, 0, 255));
792 else
793 SetTextColor (my d_gdiGraphicsContext, my d_winForegroundColour);
794 SelectFont (my d_gdiGraphicsContext, fonts [(int) my resolutionNumber] [font] [lc -> size] [lc -> style]);
795 if (my textRotation == 0.0) {
796 TextOutW (my d_gdiGraphicsContext, xDC, yDC, codesW, Melder16_length ((const char16 *) codesW));
797 } else {
798 int restore = SaveDC (my d_gdiGraphicsContext);
799 SetGraphicsMode (my d_gdiGraphicsContext, GM_ADVANCED);
800 double a = my textRotation * NUMpi / 180.0, cosa = cos (a), sina = sin (a);
801 XFORM rotate = { (float) cosa, (float) - sina, (float) sina, (float) cosa, 0.0, 0.0 };
802 ModifyWorldTransform (my d_gdiGraphicsContext, & rotate, MWT_RIGHTMULTIPLY);
803 XFORM translate = { 1.0, 0.0, 0.0, 1.0, (float) xDC, (float) yDC };
804 ModifyWorldTransform (my d_gdiGraphicsContext, & translate, MWT_RIGHTMULTIPLY);
805 TextOutW (my d_gdiGraphicsContext, 0, 0, codesW, Melder16_length ((const char16 *) codesW));
806 RestoreDC (my d_gdiGraphicsContext, restore);
807 }
808 if (lc -> link)
809 SetTextColor (my d_gdiGraphicsContext, my d_winForegroundColour);
810 SelectPen (my d_gdiGraphicsContext, GetStockPen (BLACK_PEN)), SelectBrush (my d_gdiGraphicsContext, GetStockBrush (NULL_BRUSH));
811 return;
812 #elif quartz
813 /*
814 Determine the font family.
815 */
816 const int font = lc -> font.integer_; // the font of the first character
817
818 /*
819 Determine the style.
820 */
821 const int style = lc -> style; // the style of the first character
822
823 /*
824 Determine the font-style combination.
825 */
826 CTFontRef ctFont = theScreenFonts [font] [lc -> size] [style];
827 if (! ctFont)
828 theScreenFonts [font] [lc -> size] [style] = ctFont =
829 quartz_getFontRef (font, lc -> size, style);
830
831 const char16 *codes16 = Melder_peek32to16 (codes);
832 #if 1
833 CFStringRef s = CFStringCreateWithBytes (nullptr,
834 (const UInt8 *) codes16, Melder16_length (codes16) * 2,
835 kCFStringEncodingUTF16LE, false
836 );
837 integer length = CFStringGetLength (s);
838 #else
839 NSString *s = [[NSString alloc] initWithBytes: codes16 length: Melder16_length (codes16) * 2 encoding: NSUTF16LittleEndianStringEncoding];
840 integer length = [s length];
841 #endif
842
843 CGFloat descent = CTFontGetDescent (ctFont);
844
845 CFMutableAttributedStringRef string = CFAttributedStringCreateMutable (kCFAllocatorDefault, length);
846 CFAttributedStringReplaceString (string, CFRangeMake (0, 0), (CFStringRef) s);
847 CFRange textRange = CFRangeMake (0, length);
848 CFAttributedStringSetAttribute (string, textRange, kCTFontAttributeName, ctFont);
849
850 /*
851 We don't set kerning explicitly, so that Praat will use standard kerning.
852 */
853
854 static CTParagraphStyleRef paragraphStyle;
855 if (! paragraphStyle) {
856 CTTextAlignment textAlignment = kCTLeftTextAlignment;
857 CTParagraphStyleSetting paragraphSettings [1] = { { kCTParagraphStyleSpecifierAlignment, sizeof (CTTextAlignment), & textAlignment } };
858 paragraphStyle = CTParagraphStyleCreate (paragraphSettings, 1);
859 Melder_assert (paragraphStyle != nullptr);
860 }
861 CFAttributedStringSetAttribute (string, textRange, kCTParagraphStyleAttributeName, paragraphStyle);
862
863 MelderColour colour = lc -> link ? Melder_BLUE : my colour;
864 CGColorRef color = CGColorCreateGenericRGB (colour.red, colour.green, colour.blue, 1.0);
865 Melder_assert (color != nullptr);
866 CFAttributedStringSetAttribute (string, textRange, kCTForegroundColorAttributeName, color);
867
868 /*
869 Draw.
870 */
871
872 CGContextSetTextMatrix (my d_macGraphicsContext, CGAffineTransformIdentity); // this could set the "current context" for CoreText
873 CFRelease (color);
874
875 CGContextSaveGState (my d_macGraphicsContext);
876 CGContextTranslateCTM (my d_macGraphicsContext, xDC, yDC);
877 if (my yIsZeroAtTheTop)
878 CGContextScaleCTM (my d_macGraphicsContext, 1.0, -1.0);
879 CGContextRotateCTM (my d_macGraphicsContext, my textRotation * NUMpi / 180.0);
880
881 CTLineRef line = CTLineCreateWithAttributedString (string);
882 CTLineDraw (line, my d_macGraphicsContext);
883 CFRelease (line);
884 CGContextRestoreGState (my d_macGraphicsContext);
885
886 /*
887 Clean up.
888 */
889 CFRelease (string);
890 CFRelease (s);
891 //CFRelease (ctFont);
892 return;
893 #endif
894 }
895 }
896
897 #define MAX_LINK_LENGTHcxx . . $ `sys/Graphics_text.cpp:897:9`! 300
898
899 static integercxx . . $ integer# bufferSizecxx . . $ bufferSize.;
900 static _Graphics_widecharcxx . . $ _Graphics_widechar# *theWidecharcxx . . $ theWidechar.;
901 static char32cxx . . $ char32# *charCodescxx . . $ charCodes.;
902 static int initBuffercxx . . $ initBuffer(e049ab16a3067c7). (conststring32cxx . . $ conststring32# txt) {
903 try {
904 constexpr integercxx . . $ integer# maximumNumberOfReplacementCharactersPerCharacter = 2;
905 integercxx . . $ integer# sizeNeeded = maximumNumberOfReplacementCharactersPerCharacter * Melder_lengthcxx . . $ Melder_length(3fae411214b133ad). (txt) + 1;
906 if (sizeNeeded > bufferSizecxx . . $ bufferSize.) {
907 sizeNeeded += sizeNeeded / 2 + 100;
908 Melder_freecxx . . $ `melder/melder_alloc.h:38:9`! (theWidechar);
909 Melder_freecxx . . $ `melder/melder_alloc.h:38:9`! (charCodes);
910 theWidecharcxx . . $ theWidechar. = Melder_calloccxx . . $ `melder/melder_alloc.h:34:9`! (_Graphics_widechar, sizeNeeded);
911 charCodescxx . . $ charCodes. = Melder_calloccxx . . $ `melder/melder_alloc.h:34:9`! (char32, sizeNeeded);
912 bufferSizecxx . . $ bufferSize. = sizeNeeded;
913 }
914 return 1;
915 } catch (MelderErrorcxx . . $ MelderError#) {
916 bufferSizecxx . . $ bufferSize. = 0;
917 Melder_flushErrorcxx . . $ Melder_flushError(49f6e7a06ebc5aa8). ();
918 return 0;
919 }
920 }
921
922 static int numberOfLinkscxx . . $ numberOfLinks. = 0;
923 #define MAXIMUM_NUMBER_OF_LINKS_PER_STRINGcxx . . $ `sys/Graphics_text.cpp:923:9`! 1000
924 static Graphics_Linkcxx . . $ Graphics_Link# linkscxx . . $ links. [MAXIMUM_NUMBER_OF_LINKS_PER_STRINGcxx . . $ `sys/Graphics_text.cpp:923:9`!];
925
926 static void charSizescxx . . $ charSizes(8ed17e0125cecae0). (Graphicscxx . . $ Graphics# me, _Graphics_widecharcxx . . $ _Graphics_widechar# string [], bool measureEachCharacterSeparately) {
927 /*
928 Ideally, this function should work even in cases where there is no screen.
929 Example: a Praat script wants to draw a text inside a rectangle
930 and determines the width of the rectangle by means of the "Text width (mm)" command.
931 Ideally, this script should run correctly from the command line.
932 On the Mac, `CTFramesetterSuggestFrameSizeWithConstraints` works correctly from the command line,
933 but on Linux, `pango_layout_get_extents` does not work if there is no d_cairoGraphicsContext.
934 (last checked 2020-07-17)
935 */
936 if (mycxx . . $ `melder/melder.h:44:9`! postScriptcxx . . $ structGraphics#postScript. || (cairocxx . . $ `sys/GraphicsP.h:54:10`! && ! mycxx . . $ `melder/melder.h:44:9`! screencxx . . $ structGraphics#screen.)) { // TODO: use Pango measurements even without Cairo context (if no screen)
937 for (_Graphics_widecharcxx . . $ _Graphics_widechar# *character = string; character -> karcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#kar. > U'\t'; character ++)
938 charSizecxx . . $ charSize(a30f1ce99f0f9c5d). (me, character);
939 } else {
940 /*
941 Measure the size of each character.
942 */
943 _Graphics_widecharcxx . . $ _Graphics_widechar# *character;
944 #if quartzcxx . . $ `sys/GraphicsP.h:57:10`! || cairocxx . . $ `sys/GraphicsP.h:54:10`!
945 #if cairocxx . . $ `sys/GraphicsP.h:54:10`!
946 if (! ((GraphicsScreencxx . . $ GraphicsScreen#) me) -> d_cairoGraphicsContextcxx . . $ structGraphicsScreen#d_cairoGraphicsContext.)
947 return;
948 #endif
949 int numberOfDiacritics = 0;
950 for (_Graphics_widecharcxx . . $ _Graphics_widechar# *lc = string; lc -> karcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#kar. > U'\t'; lc ++) {
951 /*
952 Determine the font family.
953 */
954 Longchar_Infocxx . . $ Longchar_Info# info = lc -> karInfocxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#karInfo.;
955 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (info);
956 const int font = chooseFontcxx . . $ chooseFont(376584643d88fb21). (me, lc);
957 lc -> fontcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#font..stringcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#$anonymous_type_2#string. = nullptr; // this erases font.integer_!
958
959 /*
960 Determine the style.
961 */
962 int style = lc -> stylecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#style.;
963 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (style >= 0 && style <= Graphics_BOLD_ITALICcxx . . $ `sys/Graphics.h:264:9`!);
964
965 const int normalSize = mycxx . . $ `melder/melder.h:44:9`! fontSizecxx . . $ structGraphics#fontSize. * mycxx . . $ `melder/melder.h:44:9`! resolutioncxx . . $ structGraphics#resolution. / 72.0;
966 const int smallSize = (3 * normalSize + 2) / 4;
967 const int size = ( lc -> sizecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#size. < 100 ? smallSize : normalSize );
968 lc -> sizecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#size. = size;
969 lc -> baselinecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#baseline. *= 0.01 * normalSize;
970 lc -> codecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#code. = lc -> karcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#kar.;
971 lc -> fontcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#font..integer_cxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#$anonymous_type_2#integer_. = font;
972 if (Longchar_Info_isDiacriticcxx . . $ Longchar_Info_isDiacritic(30d7ddfba88eefc8). (info))
973 numberOfDiacritics ++;
974
975 #if quartzcxx . . $ `sys/GraphicsP.h:57:10`!
976 /*
977 Determine and store the font-style combination.
978 */
979 CTFontRef ctFont = theScreenFonts [font] [size] [style];
980 if (! ctFont)
981 theScreenFonts [font] [size] [style] = ctFont =
982 quartz_getFontRef (font, size, style);
983 #endif
984 }
985 int nchars = 0;
986 for (_Graphics_widecharcxx . . $ _Graphics_widechar# *lc = string; lc -> karcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#kar. > U'\t'; lc ++) {
987 charCodescxx . . $ charCodes. [nchars ++] = lc -> codecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#code.;
988 _Graphics_widecharcxx . . $ _Graphics_widechar# *next = lc + 1;
989 lc -> widthcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#width. = 0;
990 if (measureEachCharacterSeparately ||
991 next->karcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#kar. <= U' ' || next->stylecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#style. != lc->stylecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#style. ||
992 next->baselinecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#baseline. != lc->baselinecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#baseline. || next->sizecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#size. != lc->sizecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#size. || next->linkcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#link. != lc->linkcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#link. ||
993 next->fontcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#font..integer_cxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#$anonymous_type_2#integer_. != lc->fontcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#font..integer_cxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#$anonymous_type_2#integer_. || next->fontcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#font..stringcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#$anonymous_type_2#string. != lc->fontcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#font..stringcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#$anonymous_type_2#string. ||
994 next->rightToLeftcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#rightToLeft. != lc->rightToLeftcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#rightToLeft. ||
995 (mycxx . . $ `melder/melder.h:44:9`! textRotationcxx . . $ structGraphics#textRotation. != 0.0 && mycxx . . $ `melder/melder.h:44:9`! screencxx . . $ structGraphics#screen. && mycxx . . $ `melder/melder.h:44:9`! resolutioncxx . . $ structGraphics#resolution. > 150))
996 {
997 charCodescxx . . $ charCodes. [nchars] = U'\0';
998 #if cairocxx . . $ `sys/GraphicsP.h:54:10`!
999 const char *codes8 = Melder_peek32to8 (charCodescxx . . $ charCodes.);
1000 int length = strlen (codes8); // TODO: integer overflow
1001 PangoFontDescription *fontDescription = PangoFontDescription_createcxx . . $ PangoFontDescription_create(450a9beac11eb0c7). (lc -> fontcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#font..integer_cxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#$anonymous_type_2#integer_., lc);
1002
1003 /*
1004 Measuring the width of a text with a homogeneous Praat font
1005 should still allow for Pango's font substitution.
1006 Low-level sequences such as `pango_itemize--pango_shape--pango_glyph_string_get_width`
1007 or `pango_itemize--pango_shape--pango_font_map_load_font--pango_glyph_string_extents`
1008 don't accomplish this: they seem to compute the width solely on the
1009 basis of the (perhaps substituted) font of the *first* glyph. By contrast, a PangoLayout
1010 performs font substitution when drawing with `pango_cairo_show_layout_line`,
1011 and also when measuring the width with `pango_layout_get_extents`.
1012 Fortunately, a PangoLayout is 1.5 to 2 times faster than the two low-level methods
1013 (measured 20170527).
1014 */
1015 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (mycxx . . $ `melder/melder.h:44:9`! screen);
1016 PangoLayout *layout = pango_cairo_create_layout (((GraphicsScreencxx . . $ GraphicsScreen#) me) -> d_cairoGraphicsContextcxx . . $ structGraphicsScreen#d_cairoGraphicsContext.);
1017 pango_layout_set_font_description (layout, fontDescription);
1018 pango_layout_set_text (layout, codes8, -1);
1019 PangoRectangle inkRect, logicalRect;
1020 pango_layout_get_extents (layout, & inkRect, & logicalRect);
1021 lc -> widthcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#width. = logicalRect. widthcxx . . $ _PangoRectangle#width. / PANGO_SCALEcxx . . $ `<external>/16549852590339199443/pango-types.h:96:9`!;
1022 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (logicalRect.x == 0);
1023 g_object_unref (layout);
1024 #elif quartz
1025 const conststring16 codes16 = Melder_peek32to16 (charCodes);
1026 const integer length = Melder16_length (codes16);
1027
1028 NSString *s = [[NSString alloc]
1029 initWithBytes: codes16
1030 length: (NSUInteger) (length * 2)
1031 encoding: NSUTF16LittleEndianStringEncoding // BUG: should be NSUTF16NativeStringEncoding, except that that doesn't exist
1032 ];
1033
1034 CFRange textRange = CFRangeMake (0, (CFIndex) [s length]);
1035
1036 CFMutableAttributedStringRef cfstring =
1037 CFAttributedStringCreateMutable (kCFAllocatorDefault, (CFIndex) [s length]);
1038 CFAttributedStringReplaceString (cfstring, CFRangeMake (0, 0), (CFStringRef) s);
1039 CFAttributedStringSetAttribute (cfstring, textRange, kCTFontAttributeName, theScreenFonts [lc -> font.integer_] [lc -> size] [lc -> style]);
1040
1041 /*
1042 Measure.
1043 */
1044
1045 // Create a path to render text in
1046 CGMutablePathRef path = CGPathCreateMutable ();
1047 NSRect measureRect = NSMakeRect (0, 0, CGFLOAT_MAX, CGFLOAT_MAX);
1048 CGPathAddRect (path, nullptr, (CGRect) measureRect);
1049
1050 CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString ((CFAttributedStringRef) cfstring);
1051 CFRange fitRange;
1052 CGSize targetSize = CGSizeMake (lc -> width, CGFLOAT_MAX);
1053 CGSize frameSize = CTFramesetterSuggestFrameSizeWithConstraints (framesetter, textRange, nullptr, targetSize, & fitRange);
1054 CFRelease (framesetter);
1055 CFRelease (cfstring);
1056 [s release];
1057 CFRelease (path);
1058 //Longchar_Info info = lc -> karInfo;
1059 //bool isDiacritic = ( info -> ps.times == 0 );
1060 //lc -> width = ( isDiacritic ? 0.0 : frameSize.width * lc -> size / 100.0 );
1061 lc -> width = frameSize.width /* * lc -> size / 100.0 */;
1062 if (Melder_systemVersion >= 101100) {
1063 /*
1064 If the text ends in a space, CTFramesetterSuggestFrameSizeWithConstraints() ignores the space.
1065 we correct for this.
1066 */
1067 if (codes16 [length - 1] == u' ')
1068 lc -> width += ( lc->font.integer_ == (int) kGraphics_font::COURIER || lc->style == Graphics_CODE ? 60.0 :
1069 next->font.integer_ == (int) kGraphics_font::COURIER || next->style == Graphics_CODE ? 37.5 : 25.0 ) * lc -> size / 100.0;
1070 }
1071 #endif
1072 nchars = 0;
1073 }
1074 }
1075 #else
1076 for (character = string; character -> kar > U'\t'; character ++)
1077 charSize (me, character);
1078 #endif
1079 }
1080 /*
1081 Each character has been garnished with information about the character's width.
1082 Make a correction for systems that make slanted characters overlap the character box to their right.
1083 We must do this after the previous loop, because we query the size of the *next* character.
1084
1085 Keep this in SYNC with psTextWidth.
1086 */
1087 for (_Graphics_widecharcxx . . $ _Graphics_widechar# *character = string; character -> karcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#kar. > U'\t'; character ++) {
1088 if ((character -> stylecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#style. & Graphics_ITALICcxx . . $ `sys/Graphics.h:263:9`!) != 0) {
1089 _Graphics_widecharcxx . . $ _Graphics_widechar# *nextCharacter = character + 1;
1090 if (nextCharacter -> karcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#kar. <= U'\t') {
1091 character -> widthcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#width. += SCREEN_SLANT_CORRECTIONcxx . . $ `sys/Graphics_text.cpp:33:9`! / 72 * mycxx . . $ `melder/melder.h:44:9`! fontSizecxx . . $ structGraphics#fontSize. * mycxx . . $ `melder/melder.h:44:9`! resolutioncxx . . $ structGraphics#resolution.;
1092 } else if (((nextCharacter -> stylecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#style. & Graphics_ITALICcxx . . $ `sys/Graphics.h:263:9`!) == 0 && nextCharacter -> baselinecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#baseline. >= character -> baselinecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#baseline.)
1093 || (character -> baselinecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#baseline. == 0 && nextCharacter -> baselinecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#baseline. > 0))
1094 {
1095 if (nextCharacter -> karcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#kar. == U'.' || nextCharacter -> karcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#kar. == U',')
1096 character -> widthcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#width. += SCREEN_SLANT_CORRECTIONcxx . . $ `sys/Graphics_text.cpp:33:9`! / 144 * mycxx . . $ `melder/melder.h:44:9`! fontSizecxx . . $ structGraphics#fontSize. * mycxx . . $ `melder/melder.h:44:9`! resolutioncxx . . $ structGraphics#resolution.;
1097 else
1098 character -> widthcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#width. += SCREEN_SLANT_CORRECTIONcxx . . $ `sys/Graphics_text.cpp:33:9`! / 72 * mycxx . . $ `melder/melder.h:44:9`! fontSizecxx . . $ structGraphics#fontSize. * mycxx . . $ `melder/melder.h:44:9`! resolutioncxx . . $ structGraphics#resolution.;
1099 }
1100 }
1101 }
1102 }
1103
1104 /*
1105 The function textWidth() determines the fractional width of a text, in device coordinates.
1106 */
1107 static double textWidthcxx . . $ textWidth(131b51753e5bda34). (_Graphics_widecharcxx . . $ _Graphics_widechar# string []) {
1108 double width = 0.0;
1109 for (_Graphics_widecharcxx . . $ _Graphics_widechar# *character = string; character -> karcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#kar. > U'\t'; character ++)
1110 width += character -> widthcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#width.;
1111 return width;
1112 }
1113
1114 static void drawOneCellcxx . . $ drawOneCell(51d9098c32a45804). (Graphicscxx . . $ Graphics# me, int xDC, int yDC, _Graphics_widecharcxx . . $ _Graphics_widechar# lc []) {
1115 int nchars = 0;
1116 const double width = textWidthcxx . . $ textWidth(131b51753e5bda34). (lc);
1117 /*
1118 We must continue even if width is zero (for adjusting textY).
1119 */
1120 _Graphics_widecharcxx . . $ _Graphics_widechar# *plc, *lastlc;
1121 bool inLink = false;
1122 double dx, dy;
1123 switch (mycxx . . $ `melder/melder.h:44:9`! horizontalTextAlignmentcxx . . $ structGraphics#horizontalTextAlignment.) {
1124 case (int) Graphics_LEFTcxx . . $ `sys/Graphics.h:249:9`!: dx = 1.0 + (0.1/72.0) * mycxx . . $ `melder/melder.h:44:9`! fontSizecxx . . $ structGraphics#fontSize. * mycxx . . $ `melder/melder.h:44:9`! resolutioncxx . . $ structGraphics#resolution.; break;
1125 case (int) Graphics_CENTREcxx . . $ `sys/Graphics.h:250:9`!: dx = - width / 2.0; break;
1126 case (int) Graphics_RIGHTcxx . . $ `sys/Graphics.h:251:9`!: dx = ( width != 0.0 ? - width - (0.1/72.0) * mycxx . . $ `melder/melder.h:44:9`! fontSizecxx . . $ structGraphics#fontSize. * mycxx . . $ `melder/melder.h:44:9`! resolutioncxx . . $ structGraphics#resolution. : 0 ); break; // if width is zero, do not step left
1127 default: dx = 1 + (0.1/72.0) * mycxx . . $ `melder/melder.h:44:9`! fontSizecxx . . $ structGraphics#fontSize. * mycxx . . $ `melder/melder.h:44:9`! resolutioncxx . . $ structGraphics#resolution.; break;
1128 }
1129 switch (mycxx . . $ `melder/melder.h:44:9`! verticalTextAlignmentcxx . . $ structGraphics#verticalTextAlignment.) {
1130 case Graphics_BOTTOMcxx . . $ `sys/Graphics.h:252:9`!: dy = (0.4/72.0) * mycxx . . $ `melder/melder.h:44:9`! fontSizecxx . . $ structGraphics#fontSize. * mycxx . . $ `melder/melder.h:44:9`! resolutioncxx . . $ structGraphics#resolution.; break;
1131 case Graphics_HALFcxx . . $ `sys/Graphics.h:253:9`!: dy = (-0.3/72.0) * mycxx . . $ `melder/melder.h:44:9`! fontSizecxx . . $ structGraphics#fontSize. * mycxx . . $ `melder/melder.h:44:9`! resolutioncxx . . $ structGraphics#resolution.; break;
1132 case Graphics_TOPcxx . . $ `sys/Graphics.h:254:9`!: dy = (-1.0/72.0) * mycxx . . $ `melder/melder.h:44:9`! fontSizecxx . . $ structGraphics#fontSize. * mycxx . . $ `melder/melder.h:44:9`! resolutioncxx . . $ structGraphics#resolution.; break;
1133 case Graphics_BASELINEcxx . . $ `sys/Graphics.h:255:9`!: dy = 0.0; break;
1134 default: dy = 0.0; break;
1135 }
1136 if (mycxx . . $ `melder/melder.h:44:9`! textRotationcxx . . $ structGraphics#textRotation. != 0.0) {
1137 double xbegin = dx, x = xbegin, cosa, sina;
1138 if (mycxx . . $ `melder/melder.h:44:9`! textRotationcxx . . $ structGraphics#textRotation. == 90.0f) {
1139 cosa = 0.0;
1140 sina = 1.0;
1141 } else if (mycxx . . $ `melder/melder.h:44:9`! textRotationcxx . . $ structGraphics#textRotation. == 270.0f) {
1142 cosa = 0.0;
1143 sina = -1.0;
1144 } else {
1145 const double angle = mycxx . . $ `melder/melder.h:44:9`! textRotationcxx . . $ structGraphics#textRotation. * NUMpicxx . . $ NUMpi. / 180.0;
1146 cosa = coscxx . . $ cos(fee4f1d22bc8e617). (angle);
1147 sina = sincxx . . $ sin(fee4f1d22bc8e617). (angle);
1148 }
1149 for (plc = lc; plc -> karcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#kar. > U'\t'; plc ++) {
1150 _Graphics_widecharcxx . . $ _Graphics_widechar# *next = plc + 1;
1151 charCodescxx . . $ charCodes. [nchars ++] = plc -> codecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#code.; // buffer...
1152 x += plc -> widthcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#width.;
1153 /*
1154 We can draw stretches of characters:
1155 they have different styles, baselines, sizes, or fonts,
1156 or if there is a break between them,
1157 or if we cannot rotate multiple characters,
1158 which is the case on bitmap printers.
1159 */
1160 if (next->karcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#kar. < U' ' || next->stylecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#style. != plc->stylecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#style. ||
1161 next->baselinecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#baseline. != plc->baselinecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#baseline. || next->sizecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#size. != plc->sizecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#size. ||
1162 next->fontcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#font..integer_cxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#$anonymous_type_2#integer_. != plc->fontcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#font..integer_cxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#$anonymous_type_2#integer_. || next->fontcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#font..stringcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#$anonymous_type_2#string. != plc->fontcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#font..stringcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#$anonymous_type_2#string. ||
1163 next->rightToLeftcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#rightToLeft. != plc->rightToLeftcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#rightToLeft. ||
1164 (mycxx . . $ `melder/melder.h:44:9`! screencxx . . $ structGraphics#screen. && mycxx . . $ `melder/melder.h:44:9`! resolutioncxx . . $ structGraphics#resolution. > 150))
1165 {
1166 const double dy2 = dy + plc -> baselinecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#baseline.;
1167 const double xr = cosa * xbegin - sina * dy2;
1168 const double yr = sina * xbegin + cosa * dy2;
1169 charCodescxx . . $ charCodes. [nchars] = U'\0'; // ...and flush
1170 charDrawcxx . . $ charDraw(2ddfd830792099cd). (me, xDC + xr, mycxx . . $ `melder/melder.h:44:9`! yIsZeroAtTheTopcxx . . $ structGraphics#yIsZeroAtTheTop. ? yDC - yr : yDC + yr,
1171 plc, charCodescxx . . $ charCodes., nchars, x - xbegin);
1172 nchars = 0;
1173 xbegin = x;
1174 }
1175 }
1176 } else {
1177 double xbegin = xDC + dx, x = xbegin, y = ( mycxx . . $ `melder/melder.h:44:9`! yIsZeroAtTheTopcxx . . $ structGraphics#yIsZeroAtTheTop. ? yDC - dy : yDC + dy ); // all mutable
1178 lastlc = lc;
1179 if (mycxx . . $ `melder/melder.h:44:9`! wrapWidthcxx . . $ structGraphics#wrapWidth. != 0.0) {
1180 /*
1181 Replace some spaces with new-line symbols.
1182 */
1183 const int xmax = xDC + mycxx . . $ `melder/melder.h:44:9`! wrapWidthcxx . . $ structGraphics#wrapWidth. * mycxx . . $ `melder/melder.h:44:9`! scaleXcxx . . $ structGraphics#scaleX.;
1184 for (plc = lc; plc -> karcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#kar. >= U' '; plc ++) {
1185 x += plc -> widthcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#width.;
1186 if (x > xmax) { // wrap (if wrapWidth is too small, each word will be on a separate line)
1187 while (plc >= lastlc) {
1188 if (plc -> karcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#kar. == U' ' && ! plc -> linkcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#link.) // keep links contiguous
1189 break;
1190 plc --;
1191 }
1192 if (plc <= lastlc)
1193 break; // hopeless situation: no spaces; get over it
1194 lastlc = plc;
1195 plc -> karcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#kar. = U'\n'; // replace space with newline
1196 #if quartzcxx . . $ `sys/GraphicsP.h:57:10`! || cairocxx . . $ `sys/GraphicsP.h:54:10`!
1197 if (mycxx . . $ `melder/melder.h:44:9`! screencxx . . $ structGraphics#screen.) {
1198 /*
1199 This part is needed when using the non-`charSize()` variant of `charSizes()`,
1200 because otherwise you'll see extra spaces
1201 before the first font switch on each non-initial line.
1202 */
1203 _Graphics_widecharcxx . . $ _Graphics_widechar# *next = plc + 1;
1204 if (next->stylecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#style. != plc->stylecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#style. ||
1205 next->baselinecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#baseline. != plc->baselinecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#baseline. || next->sizecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#size. != plc->sizecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#size. || next->linkcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#link. != plc->linkcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#link. ||
1206 next->fontcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#font..integer_cxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#$anonymous_type_2#integer_. != plc->fontcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#font..integer_cxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#$anonymous_type_2#integer_. || next->fontcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#font..stringcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#$anonymous_type_2#string. != plc->fontcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#font..stringcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#$anonymous_type_2#string. ||
1207 next->rightToLeftcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#rightToLeft. != plc->rightToLeftcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#rightToLeft.)
1208 {
1209 // nothing
1210 } else {
1211 next -> widthcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#width. -= 0.25 * mycxx . . $ `melder/melder.h:44:9`! fontSizecxx . . $ structGraphics#fontSize. * mycxx . . $ `melder/melder.h:44:9`! resolutioncxx . . $ structGraphics#resolution. / 72.0; // subtract the width of one space
1212 }
1213 }
1214 #endif
1215 x = xDC + dx + mycxx . . $ `melder/melder.h:44:9`! secondIndentcxx . . $ structGraphics#secondIndent. * mycxx . . $ `melder/melder.h:44:9`! scaleXcxx . . $ structGraphics#scaleX.;
1216 }
1217 }
1218 xbegin = x = xDC + dx; // re-initialize for second pass
1219 }
1220 for (plc = lc; plc -> karcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#kar. > U'\t'; plc ++) {
1221 _Graphics_widecharcxx . . $ _Graphics_widechar# *next = plc + 1;
1222 if (plc -> linkcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#link.) {
1223 if (! inLink) {
1224 const double descent = ( mycxx . . $ `melder/melder.h:44:9`! yIsZeroAtTheTopcxx . . $ structGraphics#yIsZeroAtTheTop. ? -(0.3/72) : (0.3/72) ) * mycxx . . $ `melder/melder.h:44:9`! fontSizecxx . . $ structGraphics#fontSize. * mycxx . . $ `melder/melder.h:44:9`! resolutioncxx . . $ structGraphics#resolution.;
1225 ++ numberOfLinkscxx . . $ numberOfLinks.;
1226 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (numberOfLinks < MAXIMUM_NUMBER_OF_LINKS_PER_STRINGcxx . . $ `sys/Graphics_text.cpp:923:9`!);
1227 linkscxx . . $ links. [numberOfLinkscxx . . $ numberOfLinks.]. x1cxx . . $ $anonymous_type_5b6ec70e96eeadfb_3#x1. = x;
1228 linkscxx . . $ links. [numberOfLinkscxx . . $ numberOfLinks.]. y1cxx . . $ $anonymous_type_5b6ec70e96eeadfb_3#y1. = y - descent;
1229 linkscxx . . $ links. [numberOfLinkscxx . . $ numberOfLinks.]. y2cxx . . $ $anonymous_type_5b6ec70e96eeadfb_3#y2. = y + 3 * descent;
1230 inLink = true;
1231 }
1232 } else if (inLink) {
1233 linkscxx . . $ links. [numberOfLinkscxx . . $ numberOfLinks.]. x2cxx . . $ $anonymous_type_5b6ec70e96eeadfb_3#x2. = x;
1234 inLink = false;
1235 }
1236 if (plc -> karcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#kar. == U'\n') {
1237 xbegin = x = xDC + dx + mycxx . . $ `melder/melder.h:44:9`! secondIndentcxx . . $ structGraphics#secondIndent. * mycxx . . $ `melder/melder.h:44:9`! scaleXcxx . . $ structGraphics#scaleX.;
1238 y = ( mycxx . . $ `melder/melder.h:44:9`! yIsZeroAtTheTopcxx . . $ structGraphics#yIsZeroAtTheTop. ? y + (1.2/72) * mycxx . . $ `melder/melder.h:44:9`! fontSizecxx . . $ structGraphics#fontSize. * mycxx . . $ `melder/melder.h:44:9`! resolutioncxx . . $ structGraphics#resolution. : y - (1.2/72) * mycxx . . $ `melder/melder.h:44:9`! fontSizecxx . . $ structGraphics#fontSize. * mycxx . . $ `melder/melder.h:44:9`! resolutioncxx . . $ structGraphics#resolution. );
1239 } else {
1240 charCodescxx . . $ charCodes. [nchars ++] = plc -> codecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#code.; // buffer...
1241 x += plc -> widthcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#width.;
1242 if (next->karcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#kar. < U' ' || next->stylecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#style. != plc->stylecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#style. ||
1243 next->baselinecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#baseline. != plc->baselinecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#baseline. || next->sizecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#size. != plc->sizecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#size. || next->linkcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#link. != plc->linkcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#link. ||
1244 next->fontcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#font..integer_cxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#$anonymous_type_2#integer_. != plc->fontcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#font..integer_cxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#$anonymous_type_2#integer_. || next->fontcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#font..stringcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#$anonymous_type_2#string. != plc->fontcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#font..stringcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#$anonymous_type_2#string. ||
1245 next->rightToLeftcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#rightToLeft. != plc->rightToLeftcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#rightToLeft.)
1246 {
1247 charCodescxx . . $ charCodes. [nchars] = U'\0'; // ...and flush
1248 charDrawcxx . . $ charDraw(2ddfd830792099cd). (me, xbegin, mycxx . . $ `melder/melder.h:44:9`! yIsZeroAtTheTopcxx . . $ structGraphics#yIsZeroAtTheTop. ? y - plc -> baselinecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#baseline. : y + plc -> baselinecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#baseline.,
1249 plc, charCodescxx . . $ charCodes., nchars, x - xbegin);
1250 nchars = 0;
1251 xbegin = x;
1252 }
1253 }
1254 }
1255 if (inLink) {
1256 linkscxx . . $ links. [numberOfLinkscxx . . $ numberOfLinks.]. x2cxx . . $ $anonymous_type_5b6ec70e96eeadfb_3#x2. = x;
1257 inLink = false;
1258 }
1259 mycxx . . $ `melder/melder.h:44:9`! textXcxx . . $ structGraphics#textX. = (x - mycxx . . $ `melder/melder.h:44:9`! deltaXcxx . . $ structGraphics#deltaX.) / mycxx . . $ `melder/melder.h:44:9`! scaleXcxx . . $ structGraphics#scaleX.;
1260 mycxx . . $ `melder/melder.h:44:9`! textYcxx . . $ structGraphics#textY. = (( mycxx . . $ `melder/melder.h:44:9`! yIsZeroAtTheTopcxx . . $ structGraphics#yIsZeroAtTheTop. ? y + dy : y - dy ) - mycxx . . $ `melder/melder.h:44:9`! deltaYcxx . . $ structGraphics#deltaY.) / mycxx . . $ `melder/melder.h:44:9`! scaleYcxx . . $ structGraphics#scaleY.;
1261 }
1262 }
1263
1264 /*
1265 The function `drawCells` handles table and layout.
1266 */
1267 static void drawCellscxx . . $ drawCells(e1551717ffbac7ba). (Graphicscxx . . $ Graphics# me, double xWC, double yWC, _Graphics_widecharcxx . . $ _Graphics_widechar# lc []) {
1268 _Graphics_widecharcxx . . $ _Graphics_widechar# *plc;
1269 int tabWidth = 0; // only for first tab
1270 kGraphics_horizontalAlignmentcxx . . $ kGraphics_horizontalAlignment# tabAlignment = Graphics_CENTREcxx . . $ `sys/Graphics.h:250:9`!;
1271 int saveTextAlignment = mycxx . . $ `melder/melder.h:44:9`! horizontalTextAlignmentcxx . . $ structGraphics#horizontalTextAlignment.;
1272 double saveWrapWidth = mycxx . . $ `melder/melder.h:44:9`! wrapWidthcxx . . $ structGraphics#wrapWidth.;
1273 numberOfLinkscxx . . $ numberOfLinks. = 0;
1274 for (plc = lc; /* No stop condition. */ ; plc ++) {
1275 charSizescxx . . $ charSizes(8ed17e0125cecae0). (me, plc, false);
1276 drawOneCellcxx . . $ drawOneCell(51d9098c32a45804). (me, xWC * mycxx . . $ `melder/melder.h:44:9`! scaleXcxx . . $ structGraphics#scaleX. + mycxx . . $ `melder/melder.h:44:9`! deltaXcxx . . $ structGraphics#deltaX., yWC * mycxx . . $ `melder/melder.h:44:9`! scaleYcxx . . $ structGraphics#scaleY. + mycxx . . $ `melder/melder.h:44:9`! deltaYcxx . . $ structGraphics#deltaY., plc);
1277 while (plc -> karcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#kar. != U'\0' && plc -> karcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#kar. != U'\t') plc ++; // find end of cell
1278 if (plc -> karcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#kar. == U'\0') // end of text?
1279 break;
1280 if (plc -> karcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#kar. == U'\t') { // go to next cell
1281 xWC += ( tabAlignment == Graphics_LEFTcxx . . $ `sys/Graphics.h:249:9`! ? tabWidth :
1282 tabAlignment == Graphics_CENTREcxx . . $ `sys/Graphics.h:250:9`! ? 0.5 * tabWidth : 0.0 ) * mycxx . . $ `melder/melder.h:44:9`! fontSizecxx . . $ structGraphics#fontSize. / 12.0;
1283 tabWidth = 1;
1284 tabAlignment = Graphics_CENTREcxx . . $ `sys/Graphics.h:250:9`!;
1285 xWC += ( tabAlignment == Graphics_LEFTcxx . . $ `sys/Graphics.h:249:9`! ? 0 :
1286 tabAlignment == Graphics_CENTREcxx . . $ `sys/Graphics.h:250:9`! ? 0.5 * tabWidth : tabWidth ) * mycxx . . $ `melder/melder.h:44:9`! fontSizecxx . . $ structGraphics#fontSize. / 12.0;
1287 mycxx . . $ `melder/melder.h:44:9`! horizontalTextAlignmentcxx . . $ structGraphics#horizontalTextAlignment. = (int) tabAlignment;
1288 mycxx . . $ `melder/melder.h:44:9`! wrapWidthcxx . . $ structGraphics#wrapWidth. = tabWidth * mycxx . . $ `melder/melder.h:44:9`! fontSizecxx . . $ structGraphics#fontSize. / 12.0;
1289 }
1290 }
1291 mycxx . . $ `melder/melder.h:44:9`! horizontalTextAlignmentcxx . . $ structGraphics#horizontalTextAlignment. = saveTextAlignment;
1292 mycxx . . $ `melder/melder.h:44:9`! wrapWidthcxx . . $ structGraphics#wrapWidth. = saveWrapWidth;
1293 }
1294
1295 static void parseTextIntoCellsLinesRunscxx . . $ parseTextIntoCellsLinesRuns(3ddce6bcef9a19ab). (Graphicscxx . . $ Graphics# me, conststring32cxx . . $ conststring32# txt /* cattable */, _Graphics_widecharcxx . . $ _Graphics_widechar# a_widechar []) {
1296 char32cxx . . $ char32# kar;
1297 const char32cxx . . $ char32# *in = & txt [0];
1298 int nquote = 0;
1299 _Graphics_widecharcxx . . $ _Graphics_widechar# *out = & a_widechar [0];
1300 bool charSuperscript = false, charSubscript = false, charItalic = false, charBold = false;
1301 bool wordItalic = false, wordBold = false, wordCode = false, wordLink = false;
1302 bool globalSuperscript = false, globalSubscript = false, globalItalic = false, globalBold = false;
1303 bool globalCode = false, globalLink = false, verbatimLink = false;
1304 bool globalSmall = 0;
1305 numberOfLinkscxx . . $ numberOfLinks. = 0;
1306 const bool weAreInManual = ( mycxx . . $ `melder/melder.h:44:9`! dollarSignIsCodecxx . . $ structGraphics#dollarSignIsCode. ); // TODO: this is temporary
1307 const bool weAreInNotebook = ( mycxx . . $ `melder/melder.h:44:9`! backquoteIsVerbatimcxx . . $ structGraphics#backquoteIsVerbatim. ); // TODO: this is temporary
1308 const bool topDownVerbatim = ( mycxx . . $ `melder/melder.h:44:9`! fontcxx . . $ structGraphics#font. == kGraphics_fontcxx . . $ kGraphics_font#::COURIERcxx . . $ kGraphics_font#COURIER. && weAreInNotebook );
1309 bool globalVerbatim = topDownVerbatim;
1310 bool thinLink = false;
1311 while ((kar = *in++) != U'\0') {
1312 //TRACE
1313 if (kar == U'^' && mycxx . . $ `melder/melder.h:44:9`! circumflexIsSuperscriptcxx . . $ structGraphics#circumflexIsSuperscript.) {
1314 if (globalVerbatim || verbatimLink) {
1315 /*
1316 Output the caret verbatim, by falling through.
1317 */
1318 } else if (globalSuperscript) {
1319 globalSuperscript = false;
1320 wordItalic = wordBold = wordCode = false;
1321 continue;
1322 } else if (in [0] == U'^') {
1323 static integercxx . . $ integer# countGlobalSuperscript;
1324 tracecxx . . $ `melder/melder_debug.h:60:10`! (U"Global superscript: ", ++ countGlobalSuperscript, U" ", txt);
1325 globalSuperscript = true;
1326 in ++;
1327 wordItalic = wordBold = wordCode = false;
1328 continue;
1329 } else {
1330 static integercxx . . $ integer# countCharacterSuperscript;
1331 tracecxx . . $ `melder/melder_debug.h:60:10`! (U"Character superscript: ", ++ countCharacterSuperscript, U" ", txt);
1332 charSuperscript = true;
1333 wordItalic = wordBold = wordCode = false;
1334 continue;
1335 }
1336 } else if (kar == U'_' && mycxx . . $ `melder/melder.h:44:9`! underscoreIsSubscriptcxx . . $ structGraphics#underscoreIsSubscript.) {
1337 if (globalVerbatim || verbatimLink) {
1338 /*
1339 Output the underscore verbatim, by falling through.
1340 */
1341 } else if (globalSubscript) {
1342 globalSubscript = false;
1343 wordItalic = wordBold = wordCode = false;
1344 continue;
1345 } else if (in [0] == U'_') {
1346 static integercxx . . $ integer# countGlobalSubscript;
1347 tracecxx . . $ `melder/melder_debug.h:60:10`! (U"Global subscript: ", ++ countGlobalSubscript, U" ", txt);
1348 globalSubscript = true;
1349 in ++;
1350 wordItalic = wordBold = wordCode = false;
1351 continue;
1352 } else if (! weAreInManual) { // TODO: this is temporary
1353 static integercxx . . $ integer# countCharacterSubscript;
1354 tracecxx . . $ `melder/melder_debug.h:60:10`! (U"Character subscript: ", ++ countCharacterSubscript, U" ", txt);
1355 charSubscript = true;
1356 wordItalic = wordBold = wordCode = false;
1357 continue;
1358 } else if (weAreInNotebook) { // TODO: this is temporary
1359 charSubscript = true;
1360 wordItalic = wordBold = wordCode = false;
1361 continue;
1362 } else {
1363 // a normal underscore in manuals
1364 static integercxx . . $ integer# countVerbatimSubscript;
1365 tracecxx . . $ `melder/melder_debug.h:60:10`! (U"Verbatim subscript: ", ++ countVerbatimSubscript, U" ", txt);
1366 }
1367 } else if (kar == U'%' && mycxx . . $ `melder/melder.h:44:9`! percentSignIsItaliccxx . . $ structGraphics#percentSignIsItalic.) {
1368 if (globalVerbatim || verbatimLink) {
1369 /*
1370 Output the percent sign verbatim, by falling through.
1371 */
1372 } else if (globalItalic) {
1373 globalItalic = false;
1374 continue;
1375 } else if (in [0] == U'%') {
1376 static integercxx . . $ integer# countGlobalItalic;
1377 tracecxx . . $ `melder/melder_debug.h:60:10`! (U"Global italic: ", ++ countGlobalItalic, U" ", txt);
1378 globalItalic = true;
1379 in ++;
1380 continue;
1381 } else if (weAreInManual) {
1382 static integercxx . . $ integer# countWordItalic, countCharacterItalic;
1383 if (Melder_isWordCharactercxx . . $ Melder_isWordCharacter(b8d0204ce8416907). (in [0]) && Melder_isWordCharactercxx . . $ Melder_isWordCharacter(b8d0204ce8416907). (in [1]) && in [1] != U'_')
1384 tracecxx . . $ `melder/melder_debug.h:60:10`! (U"Word-italic: ", ++ countWordItalic, U" ", txt);
1385 else
1386 tracecxx . . $ `melder/melder_debug.h:60:10`! (U"Character-italic: ", ++ countCharacterItalic, U" ", txt);
1387 if (in [0] == U'`' && mycxx . . $ `melder/melder.h:44:9`! backquoteIsVerbatimcxx . . $ structGraphics#backquoteIsVerbatim.)
1388 globalItalic = true;
1389 else
1390 wordItalic = true;
1391 continue;
1392 } else if (weAreInNotebook) { // TODO: this is temporary
1393 charItalic = true;
1394 continue;
1395 } else {
1396 charItalic = true;
1397 continue;
1398 }
1399 } else if (kar == U'#' && mycxx . . $ `melder/melder.h:44:9`! numberSignIsBoldcxx . . $ structGraphics#numberSignIsBold.) {
1400 if (globalVerbatim || verbatimLink) {
1401 /*
1402 Output the hash sign verbatim, by falling through.
1403 */
1404 } else if (globalBold) {
1405 globalBold = false;
1406 continue;
1407 } else if (in [0] == U'#') {
1408 static integercxx . . $ integer# countGlobalBold;
1409 tracecxx . . $ `melder/melder_debug.h:60:10`! (U"Global bold: ", ++ countGlobalBold, U" ", txt);
1410 globalBold = true;
1411 in ++;
1412 continue;
1413 } else if (weAreInManual) {
1414 static integercxx . . $ integer# countWordBold, countCharacterBold;
1415 if (Melder_isWordCharactercxx . . $ Melder_isWordCharacter(b8d0204ce8416907). (in [0]) && Melder_isWordCharactercxx . . $ Melder_isWordCharacter(b8d0204ce8416907). (in [1]) && in [1] != U'_')
1416 tracecxx . . $ `melder/melder_debug.h:60:10`! (U"Word-bold: ", ++ countWordBold, U" ", txt);
1417 else
1418 tracecxx . . $ `melder/melder_debug.h:60:10`! (U"Character-bold: ", ++ countCharacterBold, U" ", txt);
1419 if (in [0] == U'`' && mycxx . . $ `melder/melder.h:44:9`! backquoteIsVerbatimcxx . . $ structGraphics#backquoteIsVerbatim.)
1420 globalBold = true;
1421 else
1422 wordBold = true;
1423 continue;
1424 } else {
1425 charBold = true;
1426 continue;
1427 }
1428 } else if (kar == U'`' && mycxx . . $ `melder/melder.h:44:9`! backquoteIsVerbatimcxx . . $ structGraphics#backquoteIsVerbatim. && ! topDownVerbatim) {
1429 if (verbatimLink) {
1430 verbatimLink = false;
1431 continue;
1432 } else if (globalVerbatim) {
1433 if (in [0] == U'`') // a double backquote means a backquote
1434 in ++;
1435 else {
1436 globalVerbatim = false;
1437 globalItalic = false;
1438 globalBold = false;
1439 globalLink = false;
1440 continue;
1441 }
1442 } else {
1443 globalVerbatim = true;
1444 continue;
1445 }
1446 } else if (kar == U'$' && mycxx . . $ `melder/melder.h:44:9`! dollarSignIsCodecxx . . $ structGraphics#dollarSignIsCode.) {
1447 if (globalVerbatim || verbatimLink) {
1448 /*
1449 Output the dollar sign verbatim, by falling through.
1450 */
1451 } else if (globalCode) {
1452 globalCode = false;
1453 continue;
1454 } else if (in [0] == U'$') {
1455 globalCode = true;
1456 in ++;
1457 continue;
1458 } else {
1459 wordCode = true;
1460 continue;
1461 }
1462 } else if (kar == U'@' && mycxx . . $ `melder/melder.h:44:9`! atSignIsLinkcxx . . $ structGraphics#atSignIsLink. // recognize links
1463 && mycxx . . $ `melder/melder.h:44:9`! textRotationcxx . . $ structGraphics#textRotation. == 0.0) // no links allowed in rotated text, because links are identified by 2-point rectangles
1464 {
1465 /*
1466 We will distinguish:
1467 1. The link text: the text shown to the user, drawn in blue.
1468 2. The link info: the information saved in the Graphics object when the user clicks the link;
1469 this may be a page title in a manual or any other information.
1470 The link info is equal to the link text in the following cases:
1471 1. A single-word link: "this is a @Link that consists of one word".
1472 2. Longer links without "|" in them: "@@Link with spaces@".
1473 The link info is unequal to the link text in the following case:
1474 3. Longer links with "|" in them: "@@Page linked to|Text shown in blue@"
1475 */
1476 if (globalVerbatim) {
1477 /*
1478 Output the at sign verbatim, by falling through.
1479 */
1480 } else if (globalLink) {
1481 if (topDownVerbatim) {
1482 /*
1483 Output the at sign verbatim, by falling through.
1484 */
1485 } else {
1486 /*
1487 Detected the third "@" in strings like "@@Link with spaces@".
1488 This closes the link text (which will be shown in blue).
1489 */
1490 globalLink = false; // close the drawn link text (the normal colour will take over)
1491 continue; // the "@" must not be drawn
1492 }
1493 } else if (in [0] == U'@') {
1494 /*
1495 Detected the second "@" in strings like "@@Link with spaces@".
1496 A format like "@@Page linked to|Text shown in blue@" is permitted,
1497 as is @@PointProcess: ||Draw...@.
1498 First step: collect the page text (the link information);
1499 it is everything between "@@" and "|" or "@" or end of string.
1500 */
1501 const char32cxx . . $ char32# *from = in + 1; // start with first character after "@@"
1502 ++ numberOfLinkscxx . . $ numberOfLinks.;
1503 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (numberOfLinks < MAXIMUM_NUMBER_OF_LINKS_PER_STRINGcxx . . $ `sys/Graphics_text.cpp:923:9`!);
1504 if (! linkscxx . . $ links. [numberOfLinkscxx . . $ numberOfLinks.]. namecxx . . $ $anonymous_type_5b6ec70e96eeadfb_3#name.) // make room for saving link info
1505 linkscxx . . $ links. [numberOfLinkscxx . . $ numberOfLinks.]. namecxx . . $ $anonymous_type_5b6ec70e96eeadfb_3#name. = Melder_calloc_fcxx . . $ `melder/melder_alloc.h:36:9`! (char32, MAX_LINK_LENGTHcxx . . $ `sys/Graphics_text.cpp:897:9`! + 1);
1506 char32cxx . . $ char32# *to = linkscxx . . $ links. [numberOfLinkscxx . . $ numberOfLinks.]. namecxx . . $ $anonymous_type_5b6ec70e96eeadfb_3#name.;
1507 char32cxx . . $ char32# *max = to + MAX_LINK_LENGTHcxx . . $ `sys/Graphics_text.cpp:897:9`!;
1508 while (*from && *from != U'@') { // until end-of-string or '@'...
1509 if (*from == U'|') {
1510 if (from [1] == U'|' && from [2] != U'\0' && from [2] != U'@') {
1511 /*
1512 Include the stuff after "||" into the link info.
1513 */
1514 from += 2;
1515 in += to - linkscxx . . $ links. [numberOfLinkscxx . . $ numberOfLinks.]. namecxx . . $ $anonymous_type_5b6ec70e96eeadfb_3#name. + 2; // skip head of link info as well as "||"
1516 } else {
1517 /*
1518 Second step: collect the link text that is to be drawn.
1519 Its characters will be collected during the normal cycles of the loop.
1520 If the link info is equal to the link text, no action is needed.
1521 If, on the other hand, there is a separate link info, this will have to be skipped.
1522 */
1523 in += to - linkscxx . . $ links. [numberOfLinkscxx . . $ numberOfLinks.]. namecxx . . $ $anonymous_type_5b6ec70e96eeadfb_3#name. + 1; // skip link info as well as "|"
1524 break; // ..or until single '|'...
1525 }
1526 }
1527 if (to < max)
1528 *to ++ = *from ++; // ... copy one character
1529 }
1530 *to = U'\0'; // close saved link info
1531 /*
1532 We are entering the link-text-collection mode.
1533 */
1534 globalLink = true;
1535 /*
1536 Both "@" must be skipped and must not be drawn.
1537 */
1538 in ++; // skip second '@'
1539 continue; // do not draw
1540 } else if (in [0] == U'`' && mycxx . . $ `melder/melder.h:44:9`! backquoteIsVerbatimcxx . . $ structGraphics#backquoteIsVerbatim.) {
1541 const char32cxx . . $ char32# *from = in; // start with the opening backquote
1542 ++ numberOfLinkscxx . . $ numberOfLinks.;
1543 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (numberOfLinks < MAXIMUM_NUMBER_OF_LINKS_PER_STRINGcxx . . $ `sys/Graphics_text.cpp:923:9`!);
1544 if (! linkscxx . . $ links. [numberOfLinkscxx . . $ numberOfLinks.]. namecxx . . $ $anonymous_type_5b6ec70e96eeadfb_3#name.) // make room for saving link info
1545 linkscxx . . $ links. [numberOfLinkscxx . . $ numberOfLinks.]. namecxx . . $ $anonymous_type_5b6ec70e96eeadfb_3#name. = Melder_calloc_fcxx . . $ `melder/melder_alloc.h:36:9`! (char32, MAX_LINK_LENGTHcxx . . $ `sys/Graphics_text.cpp:897:9`! + 1);
1546 char32cxx . . $ char32# *to = linkscxx . . $ links. [numberOfLinkscxx . . $ numberOfLinks.]. namecxx . . $ $anonymous_type_5b6ec70e96eeadfb_3#name.;
1547 char32cxx . . $ char32# *max = to + MAX_LINK_LENGTHcxx . . $ `sys/Graphics_text.cpp:897:9`!;
1548 *to ++ = *from++; // copy the backquote
1549 while (*from && *from != U'`' && to < max) // until end-of-verbatim...
1550 *to ++ = *from++; // ... copy one character
1551 *to ++ = U'`';
1552 *to = U'\0'; // close saved link info
1553 tracecxx . . $ `melder/melder_debug.h:60:10`! (U"Verbatim link to: ", links [numberOfLinks]. name);
1554 /*
1555 Second step: collect the link text that is to be drawn.
1556 Its characters will be collected during the normal cycles of the loop.
1557 The link info is equal to the link text, so no skipping is needed.
1558 */
1559 in ++; // skip the opening backquote
1560 verbatimLink = true; // enter the link-text-collection mode
1561 continue;
1562 } else {
1563 /*
1564 Detected a single-word link, like in "this is a @Link that consists of one word".
1565 First step: collect the page text: letters, digits, and underscores.
1566 */
1567 const char32cxx . . $ char32# *from = in; // start with first character after "@"
1568 ++ numberOfLinkscxx . . $ numberOfLinks.;
1569 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (numberOfLinks < MAXIMUM_NUMBER_OF_LINKS_PER_STRINGcxx . . $ `sys/Graphics_text.cpp:923:9`!);
1570 if (! linkscxx . . $ links. [numberOfLinkscxx . . $ numberOfLinks.]. namecxx . . $ $anonymous_type_5b6ec70e96eeadfb_3#name.) // make room for saving link info
1571 linkscxx . . $ links. [numberOfLinkscxx . . $ numberOfLinks.]. namecxx . . $ $anonymous_type_5b6ec70e96eeadfb_3#name. = Melder_calloc_fcxx . . $ `melder/melder_alloc.h:36:9`! (char32, MAX_LINK_LENGTHcxx . . $ `sys/Graphics_text.cpp:897:9`! + 1);
1572 char32cxx . . $ char32# *to = linkscxx . . $ links. [numberOfLinkscxx . . $ numberOfLinks.]. namecxx . . $ $anonymous_type_5b6ec70e96eeadfb_3#name.;
1573 char32cxx . . $ char32# *max = to + MAX_LINK_LENGTHcxx . . $ `sys/Graphics_text.cpp:897:9`!;
1574 while (*from && (Melder_isWordCharactercxx . . $ Melder_isWordCharacter(b8d0204ce8416907). (*from) || *from == U'_') && to < max) // until end-of-word...
1575 *to ++ = *from++; // ... copy one character
1576 *to = U'\0'; // close saved link info
1577 /*
1578 Second step: collect the link text that is to be drawn.
1579 Its characters will be collected during the normal cycles of the loop.
1580 The link info is equal to the link text, so no skipping is needed.
1581 */
1582 wordLink = true; // enter the single-word link-text-collection mode
1583 continue;
1584 }
1585 } else if (kar == U'\\') {
1586 /*
1587 Detected backslash sequence: backslash + kar1 + kar2...
1588 */
1589 char32cxx . . $ char32# kar1, kar2;
1590 /*
1591 ... except if kar1 or kar2 is null: in that case, draw the backslash.
1592 */
1593 if ((kar1 = in [0]) == U'\0' || (kar2 = in [1]) == U'\0') {
1594 ; // normal backslash symbol
1595 } else if (topDownVerbatim &&
1596 (kar1 == U'@' && kar2 == U'{' ||
1597 kar1 == U'`' && kar2 == U'{' ||
1598 kar1 == U'#' && kar2 == U'@' && in [2] == U'{' ||
1599 kar1 == U'#' && kar2 == U'`' && in [2] == U'{')
1600 ) {
1601 /*
1602 Detected "\@{" or "\`{" or "\#@{" or "\#`{"
1603 in strings like "\@{Link with spaces}" or "\`{writeInfoLine}".
1604 A format like "\@{Page linked to|Text shown in blue}" is permitted,
1605 as is \@{PointProcess: ||Draw}.
1606 */
1607 const bool isVerbatimLink = ( kar1 == U'`' || kar2 == U'`' );
1608 thinLink = ( kar1 != U'#' );
1609 const char32cxx . . $ char32# *from = in + 3 - thinLink; // start with first character after "\@{"
1610 ++ numberOfLinkscxx . . $ numberOfLinks.;
1611 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (numberOfLinks < MAXIMUM_NUMBER_OF_LINKS_PER_STRINGcxx . . $ `sys/Graphics_text.cpp:923:9`!);
1612 if (! linkscxx . . $ links. [numberOfLinkscxx . . $ numberOfLinks.]. namecxx . . $ $anonymous_type_5b6ec70e96eeadfb_3#name.) // make room for saving link info
1613 linkscxx . . $ links. [numberOfLinkscxx . . $ numberOfLinks.]. namecxx . . $ $anonymous_type_5b6ec70e96eeadfb_3#name. = Melder_calloc_fcxx . . $ `melder/melder_alloc.h:36:9`! (char32, MAX_LINK_LENGTHcxx . . $ `sys/Graphics_text.cpp:897:9`! + 1);
1614 char32cxx . . $ char32# *to = linkscxx . . $ links. [numberOfLinkscxx . . $ numberOfLinks.]. namecxx . . $ $anonymous_type_5b6ec70e96eeadfb_3#name.;
1615 char32cxx . . $ char32# *max = to + MAX_LINK_LENGTHcxx . . $ `sys/Graphics_text.cpp:897:9`!;
1616 if (isVerbatimLink)
1617 *to ++ = U'`';
1618 while (*from && *from != U'}') { // until end-of-string or '}' or...
1619 if (*from == U'|') {
1620 if (from [1] == U'|' && from [2] != U'\0' && from [2] != U'}') {
1621 /*
1622 Include the stuff after "||" into the link info.
1623 */
1624 from += 2;
1625 in += to - linkscxx . . $ links. [numberOfLinkscxx . . $ numberOfLinks.]. namecxx . . $ $anonymous_type_5b6ec70e96eeadfb_3#name. + 2; // skip head of link info as well as "||"
1626 } else {
1627 /*
1628 Second step: collect the link text that is to be drawn.
1629 Its characters will be collected during the normal cycles of the loop.
1630 If the link info is equal to the link text, no action is needed.
1631 If, on the other hand, there is a separate link info, this will have to be skipped.
1632 */
1633 in += to - linkscxx . . $ links. [numberOfLinkscxx . . $ numberOfLinks.]. namecxx . . $ $anonymous_type_5b6ec70e96eeadfb_3#name. + 1; // skip link info as well as "|"
1634 break; // ...or until single '|'...
1635 }
1636 }
1637 if (to < max)
1638 * to ++ = * from ++; // ... copy one character
1639 }
1640 *to = U'\0'; // close saved link info
1641 /*
1642 Replace final colon with three dots.
1643 This has to be done *after* the above increments of `in`.
1644 */
1645 if (to - linkscxx . . $ links. [numberOfLinkscxx . . $ numberOfLinks.]. namecxx . . $ $anonymous_type_5b6ec70e96eeadfb_3#name. > 0 && to [-1] == U':') {
1646 to [-1] = U'.';
1647 if (to < max)
1648 *to ++ = U'.';
1649 if (to < max)
1650 *to ++ = U'.';
1651 *to = U'\0'; // close saved link info again
1652 }
1653 if (isVerbatimLink && to < max) {
1654 *to ++ = U'`';
1655 *to = U'\0'; // close saved link info again
1656 }
1657 /*
1658 We are entering the link-text-collection mode.
1659 */
1660 globalLink = true;
1661 /*
1662 The closing "}" must be skipped and must not be drawn.
1663 */
1664 in += 3 - thinLink; // skip '}'
1665 continue; // do not draw
1666 } else if (topDownVerbatim && kar1 == U'#' && kar2 == U'{') {
1667 globalBold = true;
1668 in += 2;
1669 continue;
1670 } else if (topDownVerbatim && kar1 == U'%' && kar2 == U'{') {
1671 globalItalic = true;
1672 in += 2;
1673 continue;
1674 } else if (globalVerbatim) {
1675 ; // normal backslash symbol
1676 } else if (kar1 == U's' && kar2 == U'{') {
1677 /*
1678 Catch "\s{", which means: small characters until corresponding '}'.
1679 */
1680 globalSmall = true;
1681 in += 2;
1682 continue;
1683 } else {
1684 /*
1685 Default action: translate the backslash sequence into the long character 'kar1,kar2'.
1686 */
1687 kar = Longchar_getInfocxx . . $ Longchar_getInfo(7966861fb3bf62a0). (kar1, kar2) -> unicodecxx . . $ structLongchar_Info#unicode.;
1688 in += 2;
1689 }
1690 } else if (kar == U'\"') {
1691 if (! (mycxx . . $ `melder/melder.h:44:9`! fontcxx . . $ structGraphics#font. == kGraphics_fontcxx . . $ kGraphics_font#::COURIERcxx . . $ kGraphics_font#COURIER. || mycxx . . $ `melder/melder.h:44:9`! fontStylecxx . . $ structGraphics#fontStyle. == Graphics_CODEcxx . . $ `sys/Graphics.h:265:9`! || wordCode || globalCode))
1692 kar = ++nquote & 1 ? UNICODE_LEFT_DOUBLE_QUOTATION_MARKcxx . . $ `kar/UnicodeData.h:14778:9`! : UNICODE_RIGHT_DOUBLE_QUOTATION_MARKcxx . . $ `kar/UnicodeData.h:14780:9`!;
1693 } else if (kar == U'\'' && ! mycxx . . $ `melder/melder.h:44:9`! backquoteIsVerbatimcxx . . $ structGraphics#backquoteIsVerbatim.) {
1694 kar = UNICODE_RIGHT_SINGLE_QUOTATION_MARKcxx . . $ `kar/UnicodeData.h:14772:9`!;
1695 } else if (kar == U'`' && ! mycxx . . $ `melder/melder.h:44:9`! backquoteIsVerbatimcxx . . $ structGraphics#backquoteIsVerbatim.) {
1696 kar = UNICODE_LEFT_SINGLE_QUOTATION_MARKcxx . . $ `kar/UnicodeData.h:14770:9`!;
1697 } else if (kar >= 32 && kar <= 126) {
1698 if (kar == U'f') {
1699 if (in [0] == U'i' && HAS_FI_AND_FL_LIGATUREScxx . . $ `sys/Graphics_text.cpp:35:9`! && ! (mycxx . . $ `melder/melder.h:44:9`! fontcxx . . $ structGraphics#font. == kGraphics_fontcxx . . $ kGraphics_font#::COURIERcxx . . $ kGraphics_font#COURIER. || mycxx . . $ `melder/melder.h:44:9`! fontStylecxx . . $ structGraphics#fontStyle. == Graphics_CODEcxx . . $ `sys/Graphics.h:265:9`! || wordCode || globalCode)) {
1700 kar = UNICODE_LATIN_SMALL_LIGATURE_FIcxx . . $ `kar/UnicodeData.h:31482:9`!;
1701 in ++;
1702 } else if (in [0] == U'l' && HAS_FI_AND_FL_LIGATUREScxx . . $ `sys/Graphics_text.cpp:35:9`! && ! (mycxx . . $ `melder/melder.h:44:9`! fontcxx . . $ structGraphics#font. == kGraphics_fontcxx . . $ kGraphics_font#::COURIERcxx . . $ kGraphics_font#COURIER. || mycxx . . $ `melder/melder.h:44:9`! fontStylecxx . . $ structGraphics#fontStyle. == Graphics_CODEcxx . . $ `sys/Graphics.h:265:9`! || wordCode || globalCode)) {
1703 kar = UNICODE_LATIN_SMALL_LIGATURE_FLcxx . . $ `kar/UnicodeData.h:31484:9`!;
1704 in ++;
1705 }
1706 } else if (kar == U'}') {
1707 if (globalSmall) {
1708 globalSmall = false;
1709 continue;
1710 } else if (globalBold && topDownVerbatim) {
1711 globalBold = false;
1712 continue;
1713 } else if (globalItalic && topDownVerbatim) {
1714 globalItalic = false;
1715 continue;
1716 } else if (globalLink && topDownVerbatim) {
1717 globalLink = false;
1718 continue;
1719 }
1720 }
1721 } else if (kar == U'\t') {
1722 out -> karcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#kar. = U'\t';
1723 out -> rightToLeftcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#rightToLeft. = false;
1724 wordItalic = wordBold = wordCode = wordLink = false;
1725 globalSubscript = globalSuperscript = globalItalic = globalBold = globalCode = globalLink = verbatimLink = globalSmall = false;
1726 charItalic = charBold = charSuperscript = charSubscript = false;
1727 out ++;
1728 continue; // do not draw
1729 } else if (kar == U'\n') {
1730 kar = U' ';
1731 }
1732 if (wordItalic || wordBold || wordCode || wordLink) {
1733 if (! Melder_isWordCharactercxx . . $ Melder_isWordCharacter(b8d0204ce8416907). (kar) && kar != U'_')
1734 wordItalic = wordBold = wordCode = wordLink = false;
1735 }
1736 out -> stylecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#style. =
1737 (wordLink || globalLink || verbatimLink) && mycxx . . $ `melder/melder.h:44:9`! fontStylecxx . . $ structGraphics#fontStyle. != Graphics_CODEcxx . . $ `sys/Graphics.h:265:9`! ? (thinLink ? 0 : Graphics_BOLDcxx . . $ `sys/Graphics.h:262:9`!) :
1738 ((mycxx . . $ `melder/melder.h:44:9`! fontStylecxx . . $ structGraphics#fontStyle. & Graphics_ITALICcxx . . $ `sys/Graphics.h:263:9`!) || charItalic || wordItalic || globalItalic ? Graphics_ITALICcxx . . $ `sys/Graphics.h:263:9`! : 0) +
1739 ((mycxx . . $ `melder/melder.h:44:9`! fontStylecxx . . $ structGraphics#fontStyle. & Graphics_BOLDcxx . . $ `sys/Graphics.h:262:9`!) || charBold || wordBold || globalBold ? Graphics_BOLDcxx . . $ `sys/Graphics.h:262:9`! : 0)
1740 ;
1741 out -> fontcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#font..stringcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#$anonymous_type_2#string. = nullptr;
1742 out -> fontcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#font..integer_cxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#$anonymous_type_2#integer_. = mycxx . . $ `melder/melder.h:44:9`! fontStylecxx . . $ structGraphics#fontStyle. == Graphics_CODEcxx . . $ `sys/Graphics.h:265:9`! || wordCode || globalCode || globalVerbatim || verbatimLink ||
1743 kar == U'/' && mycxx . . $ `melder/melder.h:44:9`! fontcxx . . $ structGraphics#font. != kGraphics_fontcxx . . $ kGraphics_font#::PALATINOcxx . . $ kGraphics_font#PALATINO. ? (int) kGraphics_fontcxx . . $ kGraphics_font#::COURIERcxx . . $ kGraphics_font#COURIER. : (int) mycxx . . $ `melder/melder.h:44:9`! fontcxx . . $ structGraphics#font.;
1744 out -> linkcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#link. = wordLink || globalLink || verbatimLink;
1745 out -> baselinecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#baseline. = charSuperscript || globalSuperscript ? 34 : charSubscript || globalSubscript ? -25 : 0;
1746 out -> sizecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#size. = globalSmall || out -> baselinecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#baseline. != 0 ? 80 : 100;
1747 out -> codecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#code. = U'?'; // does this have any meaning?
1748 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (kar != U'\0');
1749 if (mycxx . . $ `melder/melder.h:44:9`! postScriptcxx . . $ structGraphics#postScript.) {
1750 if (kar == UNICODE_LATIN_SMALL_LETTER_TS_DIGRAPHcxx . . $ `kar/UnicodeData.h:1356:9`!) {
1751 kar = U't';
1752 out -> karcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#kar. = kar;
1753 out -> karInfocxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#karInfo. = Longchar_getInfoFromNativecxx . . $ Longchar_getInfoFromNative(e111517d933f6460). (kar);
1754 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (out -> karInfo);
1755 out -> rightToLeftcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#rightToLeft. = false;
1756 kar = U's';
1757 out ++;
1758 * out =cxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#`operator=`(bd3c6d962306cfe8). out [-1];
1759 } else if (kar == UNICODE_LATIN_SMALL_LETTER_TESH_DIGRAPHcxx . . $ `kar/UnicodeData.h:1358:9`!) {
1760 kar = U't';
1761 out -> karcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#kar. = kar;
1762 out -> karInfocxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#karInfo. = Longchar_getInfoFromNativecxx . . $ Longchar_getInfoFromNative(e111517d933f6460). (kar);
1763 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (out -> karInfo);
1764 out -> rightToLeftcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#rightToLeft. = false;
1765 kar = UNICODE_LATIN_SMALL_LETTER_ESHcxx . . $ `kar/UnicodeData.h:1286:9`!;
1766 out ++;
1767 * out =cxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#`operator=`(bd3c6d962306cfe8). out [-1];
1768 } else if (kar == UNICODE_MODIFIER_LETTER_SMALL_Hcxx . . $ `kar/UnicodeData.h:1376:9`!) {
1769 kar = U'h';
1770 out -> baselinecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#baseline. = 34;
1771 out -> sizecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#size. = 80;
1772 } else if (kar == UNICODE_MODIFIER_LETTER_SMALL_H_WITH_HOOKcxx . . $ `kar/UnicodeData.h:1378:9`!) {
1773 kar = UNICODE_LATIN_SMALL_LETTER_H_WITH_HOOKcxx . . $ `kar/UnicodeData.h:1228:9`!;
1774 out -> baselinecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#baseline. = 34;
1775 out -> sizecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#size. = 80;
1776 } else if (kar == UNICODE_MODIFIER_LETTER_SMALL_GAMMAcxx . . $ `kar/UnicodeData.h:1472:9`!) {
1777 kar = UNICODE_LATIN_SMALL_LETTER_GAMMAcxx . . $ `kar/UnicodeData.h:1222:9`!;
1778 out -> baselinecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#baseline. = 34;
1779 out -> sizecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#size. = 80;
1780 } else if (kar == UNICODE_MODIFIER_LETTER_SMALL_Wcxx . . $ `kar/UnicodeData.h:1390:9`!) {
1781 kar = U'w';
1782 out -> baselinecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#baseline. = 34;
1783 out -> sizecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#size. = 80;
1784 } else if (kar == UNICODE_MODIFIER_LETTER_SMALL_TURNED_Hcxx . . $ `kar/UnicodeData.h:13558:9`!) {
1785 kar = UNICODE_LATIN_SMALL_LETTER_TURNED_Hcxx . . $ `kar/UnicodeData.h:1226:9`!;
1786 out -> baselinecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#baseline. = 34;
1787 out -> sizecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#size. = 80;
1788 } else if (kar == UNICODE_MODIFIER_LETTER_GLOTTAL_STOPcxx . . $ `kar/UnicodeData.h:1408:9`!) {
1789 kar = UNICODE_LATIN_LETTER_GLOTTAL_STOPcxx . . $ `kar/UnicodeData.h:1320:9`!;
1790 out -> baselinecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#baseline. = 34;
1791 out -> sizecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#size. = 80;
1792 } else if (kar == UNICODE_MODIFIER_LETTER_REVERSED_GLOTTAL_STOPcxx . . $ `kar/UnicodeData.h:1410:9`!) {
1793 kar = UNICODE_LATIN_LETTER_PHARYNGEAL_VOICED_FRICATIVEcxx . . $ `kar/UnicodeData.h:1322:9`!;
1794 out -> baselinecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#baseline. = 34;
1795 out -> sizecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#size. = 80;
1796 } else if (kar == UNICODE_MODIFIER_LETTER_SMALL_Lcxx . . $ `kar/UnicodeData.h:1474:9`!) {
1797 kar = U'l';
1798 out -> baselinecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#baseline. = 34;
1799 out -> sizecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#size. = 80;
1800 } else if (kar == UNICODE_SUPERSCRIPT_LATIN_SMALL_LETTER_Ncxx . . $ `kar/UnicodeData.h:14970:9`!) {
1801 kar = U'n';
1802 out -> baselinecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#baseline. = 34;
1803 out -> sizecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#size. = 80;
1804 } else if (kar == UNICODE_MODIFIER_LETTER_SMALL_Mcxx . . $ `kar/UnicodeData.h:13392:9`!) {
1805 kar = U'm';
1806 out -> baselinecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#baseline. = 34;
1807 out -> sizecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#size. = 80;
1808 } else if (kar == UNICODE_MODIFIER_LETTER_SMALL_ENGcxx . . $ `kar/UnicodeData.h:13394:9`!) {
1809 kar = UNICODE_LATIN_SMALL_LETTER_ENGcxx . . $ `kar/UnicodeData.h:662:9`!;
1810 out -> baselinecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#baseline. = 34;
1811 out -> sizecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#size. = 80;
1812 } else if (kar == UNICODE_MODIFIER_LETTER_SMALL_Scxx . . $ `kar/UnicodeData.h:1476:9`!) {
1813 kar = U's';
1814 out -> baselinecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#baseline. = 34;
1815 out -> sizecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#size. = 80;
1816 } else if (kar == UNICODE_MODIFIER_LETTER_SMALL_Xcxx . . $ `kar/UnicodeData.h:1478:9`!) {
1817 kar = U'x';
1818 out -> baselinecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#baseline. = 34;
1819 out -> sizecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#size. = 80;
1820 } else if (kar == UNICODE_MODIFIER_LETTER_SMALL_Fcxx . . $ `kar/UnicodeData.h:13552:9`!) {
1821 kar = U'f';
1822 out -> baselinecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#baseline. = 34;
1823 out -> sizecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#size. = 80;
1824 } else if (kar == UNICODE_MODIFIER_LETTER_SMALL_Ycxx . . $ `kar/UnicodeData.h:1392:9`!) {
1825 kar = U'y';
1826 out -> baselinecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#baseline. = 34;
1827 out -> sizecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#size. = 80;
1828 }
1829 }
1830 out -> karcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#kar. = kar;
1831 out -> karInfocxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#karInfo. = Longchar_getInfoFromNativecxx . . $ Longchar_getInfoFromNative(e111517d933f6460). (kar);
1832 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (out -> karInfo);
1833 out -> rightToLeftcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#rightToLeft. =
1834 (kar >= 0x0590 && kar <= 0x06FF) ||
1835 (kar >= 0xFE70 && kar <= 0xFEFF) ||
1836 (kar >= 0xFB1E && kar <= 0xFDFF);
1837 charItalic = charBold = charSuperscript = charSubscript = false;
1838 out ++;
1839 }
1840 out -> karcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#kar. = U'\0'; // end of text
1841 out -> karInfocxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#karInfo. = Longchar_getInfoFromNativecxx . . $ Longchar_getInfoFromNative(e111517d933f6460). (kar);
1842 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (out -> karInfo);
1843 out -> rightToLeftcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#rightToLeft. = false;
1844 }
1845
1846 double Graphics_textWidthcxx . . $ Graphics_textWidth(c49f17072ec643bd). (Graphicscxx . . $ Graphics# me, conststring32cxx . . $ conststring32# txt) {
1847 if (! initBuffercxx . . $ initBuffer(e049ab16a3067c7). (txt))
1848 return 0.0;
1849 //Melder_casual (U"Graphics_textWidth: workstation viewport ", my d_x1DC, U" ", my d_x2DC, U" ", my d_y1DC, U" ", my d_y2DC);
1850 //Melder_casual (U"Graphics_textWidth: workstation window ", my d_x1wNDC, U" ", my d_x2wNDC, U" ", my d_y1wNDC, U" ", my d_y2wNDC);
1851 //Melder_casual (U"Graphics_textWidth: viewport ", my d_x1NDC, U" ", my d_x2NDC, U" ", my d_y1NDC, U" ", my d_y2NDC);
1852 //Melder_casual (U"Graphics_textWidth: window ", my d_x1WC, U" ", my d_x2WC, U" ", my d_y1WC, U" ", my d_y2WC);
1853 #if cairocxx . . $ `sys/GraphicsP.h:54:10`!
1854 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (Thing_isa (me, classGraphicsScreen));
1855 cairo_t *oldCairoGraphicsContext = ((GraphicsScreencxx . . $ GraphicsScreen#) me) -> d_cairoGraphicsContextcxx . . $ structGraphicsScreen#d_cairoGraphicsContext.;
1856 cairo_surface_t *cairoSurface;
1857 if (! oldCairoGraphicsContext)
1858 #ifndef NO_GUI
1859 if (((GraphicsScreencxx . . $ GraphicsScreen#) me) -> d_windowcxx . . $ structGraphicsScreen#d_window.) {
1860 //Melder_casual (U"Graphics_textWidth: creating a graphics context in an existing widget.");
1861 ((GraphicsScreencxx . . $ GraphicsScreen#) me) -> d_cairoGraphicsContextcxx . . $ structGraphicsScreen#d_cairoGraphicsContext. = gdk_cairo_create (((GraphicsScreencxx . . $ GraphicsScreen#) me) -> d_windowcxx . . $ structGraphicsScreen#d_window.);
1862 } else
1863 #endif
1864 {
1865 //Melder_casual (U"Graphics_textWidth: creating a graphics context outside any existing widget.");
1866 cairoSurface = cairo_image_surface_create (CAIRO_FORMAT_RGB24, 1/*my d_x2DC - my d_x1DC*/, 1/*my d_y2DC - my d_y1DC*/);
1867 ((GraphicsScreencxx . . $ GraphicsScreen#) me) -> d_cairoGraphicsContextcxx . . $ structGraphicsScreen#d_cairoGraphicsContext. = cairo_create (cairoSurface);
1868 }
1869 #endif
1870 parseTextIntoCellsLinesRunscxx . . $ parseTextIntoCellsLinesRuns(3ddce6bcef9a19ab). (me, txt, theWidecharcxx . . $ theWidechar.);
1871 charSizescxx . . $ charSizes(8ed17e0125cecae0). (me, theWidecharcxx . . $ theWidechar., false);
1872 const double width = textWidthcxx . . $ textWidth(131b51753e5bda34). (theWidecharcxx . . $ theWidechar.);
1873 //Melder_casual (U"Graphics_textWidth: width ", width, U", scale ", my scaleX);
1874 #if cairocxx . . $ `sys/GraphicsP.h:54:10`!
1875 if (! oldCairoGraphicsContext) {
1876 #ifndef NO_GUI
1877 if (((GraphicsScreencxx . . $ GraphicsScreen#) me) -> d_windowcxx . . $ structGraphicsScreen#d_window.) {
1878 cairo_destroy (((GraphicsScreencxx . . $ GraphicsScreen#) me) -> d_cairoGraphicsContextcxx . . $ structGraphicsScreen#d_cairoGraphicsContext.);
1879 } else
1880 #endif
1881 {
1882 cairo_destroy (((GraphicsScreencxx . . $ GraphicsScreen#) me) -> d_cairoGraphicsContextcxx . . $ structGraphicsScreen#d_cairoGraphicsContext.);
1883 cairo_surface_destroy (cairoSurface);
1884 }
1885 ((GraphicsScreencxx . . $ GraphicsScreen#) me) -> d_cairoGraphicsContextcxx . . $ structGraphicsScreen#d_cairoGraphicsContext. = nullptr;
1886 }
1887 #endif
1888 return width / mycxx . . $ `melder/melder.h:44:9`! scaleXcxx . . $ structGraphics#scaleX.;
1889 }
1890
1891 void Graphics_rectangleText_wrapAndTruncatecxx . . $ Graphics_rectangleText_wrapAndTruncate(fc0676218053a650). (Graphicscxx . . $ Graphics# me, double x1, double x2, double y1, double y2, conststring32cxx . . $ conststring32# text) {
1892 if (mycxx . . $ `melder/melder.h:44:9`! recordingcxx . . $ structGraphics#recording.) {
1893 const conststring8cxx . . $ conststring8# text_utf8 = Melder_peek32to8 (text);
1894 const integercxx . . $ integer# length = Melder8_lengthcxx . . $ Melder8_length(3c95bd14d5d5d286). (text_utf8) / (integercxx . . $ integer#) sizeof (double) + 1;
1895 opcxx . . $ `sys/GraphicsP.h:179:9`! (RECTANGLE_TEXT_WRAP_AND_TRUNCATE, 5 + length); putcxx . . $ `sys/GraphicsP.h:178:9`! (x1); putcxx . . $ `sys/GraphicsP.h:178:9`! (x2); putcxx . . $ `sys/GraphicsP.h:178:9`! (y1); putcxx . . $ `sys/GraphicsP.h:178:9`! (y2); sputcxx . . $ `sys/GraphicsP.h:181:9`! (text_utf8, length)
1896 } else {
1897 double width = 0.0, lineHeight = (1.1 / 72) * mycxx . . $ `melder/melder.h:44:9`! fontSizecxx . . $ structGraphics#fontSize. * mycxx . . $ `melder/melder.h:44:9`! resolutioncxx . . $ structGraphics#resolution.;
1898 const integercxx . . $ integer# x1DC = x1 * mycxx . . $ `melder/melder.h:44:9`! scaleXcxx . . $ structGraphics#scaleX. + mycxx . . $ `melder/melder.h:44:9`! deltaXcxx . . $ structGraphics#deltaX. + 2, x2DC = x2 * mycxx . . $ `melder/melder.h:44:9`! scaleXcxx . . $ structGraphics#scaleX. + mycxx . . $ `melder/melder.h:44:9`! deltaXcxx . . $ structGraphics#deltaX. - 2;
1899 const integercxx . . $ integer# y1DC = y1 * mycxx . . $ `melder/melder.h:44:9`! scaleYcxx . . $ structGraphics#scaleY. + mycxx . . $ `melder/melder.h:44:9`! deltaYcxx . . $ structGraphics#deltaY., y2DC = y2 * mycxx . . $ `melder/melder.h:44:9`! scaleYcxx . . $ structGraphics#scaleY. + mycxx . . $ `melder/melder.h:44:9`! deltaYcxx . . $ structGraphics#deltaY.;
1900 const int availableHeight = ( mycxx . . $ `melder/melder.h:44:9`! yIsZeroAtTheTopcxx . . $ structGraphics#yIsZeroAtTheTop. ? y1DC - y2DC : y2DC - y1DC ), availableWidth = x2DC - x1DC;
1901 const int linesAvailable = Melder_clippedLeftcxx . . $ Melder_clippedLeft(f80f7d6260b3ee3a). (1, int (availableHeight / lineHeight));
1902 if (availableWidth <= 0)
1903 return;
1904 if (! initBuffercxx . . $ initBuffer(e049ab16a3067c7). (text))
1905 return;
1906 parseTextIntoCellsLinesRunscxx . . $ parseTextIntoCellsLinesRuns(3ddce6bcef9a19ab). (me, text, theWidecharcxx . . $ theWidechar.);
1907 charSizescxx . . $ charSizes(8ed17e0125cecae0). (me, theWidecharcxx . . $ theWidechar., true);
1908 int linesNeeded = 1;
1909 for (_Graphics_widecharcxx . . $ _Graphics_widechar# *plc = theWidecharcxx . . $ theWidechar.; plc -> karcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#kar. > U'\t'; plc ++) {
1910 width += plc -> widthcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#width.;
1911 if (width > availableWidth) {
1912 if (++ linesNeeded > linesAvailable)
1913 break;
1914 width = 0.0;
1915 }
1916 }
1917 const int lines = Melder_clippedRightcxx . . $ Melder_clippedRight(f80f7d6260b3ee3a). (linesNeeded, linesAvailable);
1918 _Graphics_widecharcxx . . $ _Graphics_widechar# *startOfLine = theWidecharcxx . . $ theWidechar.;
1919 for (int iline = 1; iline <= lines; iline ++) {
1920 width = 0.0;
1921 for (_Graphics_widecharcxx . . $ _Graphics_widechar# *plc = startOfLine; plc -> karcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#kar. > U'\t'; plc ++) {
1922 bool flush = false;
1923 width += plc -> widthcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#width.;
1924 if (width > availableWidth)
1925 flush = true;
1926 /*
1927 Trick for incorporating end-of-text.
1928 */
1929 if (! flush && plc [1]. karcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#kar. <= U'\t') {
1930 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (iline == lines);
1931 plc ++; // brr
1932 flush = true;
1933 }
1934 if (flush) {
1935 const char32cxx . . $ char32# saveKar = plc -> karcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#kar.;
1936 const int direction = ( mycxx . . $ `melder/melder.h:44:9`! yIsZeroAtTheTopcxx . . $ structGraphics#yIsZeroAtTheTop. ? -1 : 1 );
1937 const int x = (
1938 mycxx . . $ `melder/melder.h:44:9`! horizontalTextAlignmentcxx . . $ structGraphics#horizontalTextAlignment. == (int) Graphics_LEFTcxx . . $ `sys/Graphics.h:249:9`! ?
1939 x1DC
1940 : mycxx . . $ `melder/melder.h:44:9`! horizontalTextAlignmentcxx . . $ structGraphics#horizontalTextAlignment. == (int) Graphics_RIGHTcxx . . $ `sys/Graphics.h:251:9`! ?
1941 x2DC
1942 :
1943 0.5 * (x1 + x2) * mycxx . . $ `melder/melder.h:44:9`! scaleXcxx . . $ structGraphics#scaleX. + mycxx . . $ `melder/melder.h:44:9`! deltaXcxx . . $ structGraphics#deltaX.
1944 );
1945 const int y = (
1946 mycxx . . $ `melder/melder.h:44:9`! verticalTextAlignmentcxx . . $ structGraphics#verticalTextAlignment. == Graphics_BOTTOMcxx . . $ `sys/Graphics.h:252:9`! ?
1947 y1DC + direction * (lines - iline) * lineHeight
1948 : mycxx . . $ `melder/melder.h:44:9`! verticalTextAlignmentcxx . . $ structGraphics#verticalTextAlignment. == Graphics_TOPcxx . . $ `sys/Graphics.h:254:9`! ?
1949 y2DC - direction * (iline - 1) * lineHeight
1950 :
1951 0.5 * (y1 + y2) * mycxx . . $ `melder/melder.h:44:9`! scaleYcxx . . $ structGraphics#scaleY. + mycxx . . $ `melder/melder.h:44:9`! deltaYcxx . . $ structGraphics#deltaY. + 0.5 * direction * (lines - iline*2 + 1) * lineHeight
1952 );
1953 plc -> karcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#kar. = U'\0';
1954 drawOneCellcxx . . $ drawOneCell(51d9098c32a45804). (me, x, y, startOfLine);
1955 plc -> karcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#kar. = saveKar;
1956 startOfLine = plc;
1957 break;
1958 }// endif flush
1959 }// next plc
1960 }// next iline
1961 }// endif my recording
1962 }
1963
1964 static void nonrecorded_Graphics_textcxx . . $ nonrecorded_Graphics_text(8e1820bb471fc8c8). (Graphicscxx . . $ Graphics# me, double xWC, double yWC, conststring32cxx . . $ conststring32# text) {
1965 if (mycxx . . $ `melder/melder.h:44:9`! wrapWidthcxx . . $ structGraphics#wrapWidth. == 0.0 && str32chrcxx . . $ str32chr(328a9ede0fba853a). (text, U'\n') && mycxx . . $ `melder/melder.h:44:9`! textRotationcxx . . $ structGraphics#textRotation. == 0.0) {
1966 const double lineSpacingWC = (1.2/72.0) * mycxx . . $ `melder/melder.h:44:9`! fontSizecxx . . $ structGraphics#fontSize. * mycxx . . $ `melder/melder.h:44:9`! resolutioncxx . . $ structGraphics#resolution. / fabscxx . . $ fabs(fee4f1d22bc8e617). (mycxx . . $ `melder/melder.h:44:9`! scaleYcxx . . $ structGraphics#scaleY.);
1967 integercxx . . $ integer# numberOfLines = 1;
1968 for (const char32cxx . . $ char32# *p = & text [0]; *p != U'\0'; p ++)
1969 if (*p == U'\n')
1970 numberOfLines ++;
1971 yWC += (
1972 mycxx . . $ `melder/melder.h:44:9`! verticalTextAlignmentcxx . . $ structGraphics#verticalTextAlignment. == Graphics_TOPcxx . . $ `sys/Graphics.h:254:9`! ?
1973 0.0
1974 : mycxx . . $ `melder/melder.h:44:9`! verticalTextAlignmentcxx . . $ structGraphics#verticalTextAlignment. == Graphics_HALFcxx . . $ `sys/Graphics.h:253:9`! ?
1975 0.5 * (numberOfLines - 1) * lineSpacingWC
1976 :
1977 (numberOfLines - 1) * lineSpacingWC
1978 );
1979 autostring32cxx . . $ autostring32# linesToDraw = Melder_dup_fcxx . . $ Melder_dup_f(87bf156b1f548402). (text);
1980 const char32cxx . . $ char32# *p = & linesToDraw [cxx . . $ _autostring#`operator[]`(b190d49faf30c5be).0];
1981 for (;;) {
1982 char32cxx . . $ char32# *const newline = str32chrcxx . . $ str32chr(328a9ede0fba853a). (p, U'\n');
1983 if (newline)
1984 *newline = U'\0';
1985 nonrecorded_Graphics_textcxx . . $ nonrecorded_Graphics_text(8e1820bb471fc8c8). (me, xWC, yWC, p); // recurse
1986 yWC -= lineSpacingWC;
1987 if (newline)
1988 p = newline + 1;
1989 else
1990 break;
1991 }
1992 return;
1993 }
1994 if (! initBuffercxx . . $ initBuffer(e049ab16a3067c7). (text))
1995 return;
1996 parseTextIntoCellsLinesRunscxx . . $ parseTextIntoCellsLinesRuns(3ddce6bcef9a19ab). (me, text, theWidecharcxx . . $ theWidechar.);
1997 drawCellscxx . . $ drawCells(e1551717ffbac7ba). (me, xWC, yWC, theWidecharcxx . . $ theWidechar.);
1998 }
1999
2000 void Graphics_textcxx . . $ Graphics_text(8e1820bb471fc8c8). (Graphicscxx . . $ Graphics# me, double xWC, double yWC, conststring32cxx . . $ conststring32# text) {
2001 if (mycxx . . $ `melder/melder.h:44:9`! recordingcxx . . $ structGraphics#recording.) {
2002 const conststring8cxx . . $ conststring8# text_utf8 = Melder_peek32to8 (text);
2003 const integercxx . . $ integer# length = Melder8_lengthcxx . . $ Melder8_length(3c95bd14d5d5d286). (text_utf8) / (integercxx . . $ integer#) sizeof (double) + 1;
2004 opcxx . . $ `sys/GraphicsP.h:179:9`! (TEXT, 3 + length); putcxx . . $ `sys/GraphicsP.h:178:9`! (xWC); putcxx . . $ `sys/GraphicsP.h:178:9`! (yWC); sputcxx . . $ `sys/GraphicsP.h:181:9`! (text_utf8, length)
2005 } else {
2006 nonrecorded_Graphics_textcxx . . $ nonrecorded_Graphics_text(8e1820bb471fc8c8). (me, xWC, yWC, text);
2007 }
2008 }
2009
2010 void Graphics_rectangleText_maximalFitcxx . . $ Graphics_rectangleText_maximalFit(b1509f86b4e96d1). (Graphicscxx . . $ Graphics# me,
2011 const double x1, const double x2, const double minimumHorizontalMargin_in_textHeights, const double minimumHorizontalMargin_mm,
2012 const double y1, const double y2, const double minimumVerticalMargin_in_textHeights, const double minimumVerticalMargin_mm,
2013 conststring32cxx . . $ conststring32# text
2014 ) {
2015 if (mycxx . . $ `melder/melder.h:44:9`! recordingcxx . . $ structGraphics#recording.) {
2016 const conststring8cxx . . $ conststring8# text_utf8 = Melder_peek32to8 (text);
2017 const integercxx . . $ integer# length = Melder8_lengthcxx . . $ Melder8_length(3c95bd14d5d5d286). (text_utf8) / (integercxx . . $ integer#) sizeof (double) + 1;
2018 opcxx . . $ `sys/GraphicsP.h:179:9`! (RECTANGLE_TEXT_MAXIMAL_FIT, 9 + length);
2019 putcxx . . $ `sys/GraphicsP.h:178:9`! (x1); putcxx . . $ `sys/GraphicsP.h:178:9`! (x2); putcxx . . $ `sys/GraphicsP.h:178:9`! (minimumHorizontalMargin_in_textHeights); putcxx . . $ `sys/GraphicsP.h:178:9`! (minimumHorizontalMargin_mm);
2020 putcxx . . $ `sys/GraphicsP.h:178:9`! (y1); putcxx . . $ `sys/GraphicsP.h:178:9`! (y2); putcxx . . $ `sys/GraphicsP.h:178:9`! (minimumVerticalMargin_in_textHeights); putcxx . . $ `sys/GraphicsP.h:178:9`! (minimumVerticalMargin_mm);
2021 sputcxx . . $ `sys/GraphicsP.h:181:9`! (text_utf8, length)
2022 } else {
2023 const double save_fontSize = mycxx . . $ `melder/melder.h:44:9`! fontSizecxx . . $ structGraphics#fontSize.;
2024 mycxx . . $ `melder/melder.h:44:9`! fontSizecxx . . $ structGraphics#fontSize. = 100;
2025 double textWidth_wc = Graphics_textWidthcxx . . $ Graphics_textWidth(c49f17072ec643bd). (me, text);
2026 double textHeight_mm = mycxx . . $ `melder/melder.h:44:9`! fontSizecxx . . $ structGraphics#fontSize. * (25.4 / 72);
2027 double textHeight_wc = Graphics_dyMMtoWCcxx . . $ Graphics_dyMMtoWC(f042c24bcd87f07e). (me, textHeight_mm);
2028 /*
2029 The number of 0.99 or 0.95 guards against rounding errors in font sizes (they may always be integers).
2030 */
2031 #ifdef macintosh
2032 const double precision = 0.99;
2033 #else
2034 const double precision = 0.95;
2035 #endif
2036 double horizontalMargin_mm =
2037 stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a). (minimumHorizontalMargin_in_textHeights * textHeight_mm, minimumHorizontalMargin_mm);
2038 double horizontalMargin_wc = Graphics_dxMMtoWCcxx . . $ Graphics_dxMMtoWC(f042c24bcd87f07e). (me, horizontalMargin_mm);
2039 double maximumHorizontalScaling = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a). (0.001, precision * (x2 - x1 - 2.0 * horizontalMargin_wc) / textWidth_wc);
2040 double verticalMargin_mm = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a). (minimumVerticalMargin_in_textHeights * textHeight_mm, minimumVerticalMargin_mm);
2041 double verticalMargin_wc = Graphics_dyMMtoWCcxx . . $ Graphics_dyMMtoWC(f042c24bcd87f07e). (me, verticalMargin_mm);
2042 double maximumVerticalScaling = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a). (0.001, (y2 - y1 - 2.0 * verticalMargin_wc) / textHeight_wc);
2043 double scaling = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a). (maximumHorizontalScaling, maximumVerticalScaling);
2044 mycxx . . $ `melder/melder.h:44:9`! fontSizecxx . . $ structGraphics#fontSize. *= scaling;
2045 for (int improvementIteration = 1; improvementIteration <= 10; improvementIteration ++) {
2046 textWidth_wc *= scaling;
2047 textHeight_mm *= scaling;
2048 textHeight_wc *= scaling;
2049 horizontalMargin_mm = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a). (minimumHorizontalMargin_in_textHeights * textHeight_mm, minimumHorizontalMargin_mm);
2050 horizontalMargin_wc = Graphics_dxMMtoWCcxx . . $ Graphics_dxMMtoWC(f042c24bcd87f07e). (me, horizontalMargin_mm);
2051 maximumHorizontalScaling = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a). (0.001, precision * (x2 - x1 - 2.0 * horizontalMargin_wc) / textWidth_wc);
2052 verticalMargin_mm = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a). (minimumVerticalMargin_in_textHeights * textHeight_mm, minimumVerticalMargin_mm);
2053 verticalMargin_wc = Graphics_dyMMtoWCcxx . . $ Graphics_dyMMtoWC(f042c24bcd87f07e). (me, verticalMargin_mm);
2054 maximumVerticalScaling = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a). (0.001, (y2 - y1 - 2.0 * verticalMargin_wc) / textHeight_wc);
2055 //maximumVerticalScaling = 0.72 * (y2 - y1) / textHeight_wc;
2056 scaling = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a). (maximumHorizontalScaling, maximumVerticalScaling);
2057 if (scaling == 1.0)
2058 break; // we have converged
2059 mycxx . . $ `melder/melder.h:44:9`! fontSizecxx . . $ structGraphics#fontSize. *= scaling;
2060 tracecxx . . $ `melder/melder_debug.h:60:10`! (improvementIteration, U" w wc ", textWidth_wc, U" h mm ", textHeight_mm, U" h wc ", textHeight_wc,
2061 U" m mm ", horizontalMargin_mm, U" scaling ", scaling, U" ", text);
2062 }
2063 if (scaling != 1.0) {
2064 //TRACE
2065 tracecxx . . $ `melder/melder_debug.h:60:10`! (U"0 w wc ", textWidth_wc, U" h mm ", textHeight_mm, U" h wc ", textHeight_wc,
2066 U" m mm ", horizontalMargin_mm, U" scaling ", scaling, U" ", text);
2067 }
2068 const double xWC =
2069 mycxx . . $ `melder/melder.h:44:9`! horizontalTextAlignmentcxx . . $ structGraphics#horizontalTextAlignment. == (int) Graphics_LEFTcxx . . $ `sys/Graphics.h:249:9`! ? x1 + horizontalMargin_wc :
2070 mycxx . . $ `melder/melder.h:44:9`! horizontalTextAlignmentcxx . . $ structGraphics#horizontalTextAlignment. == (int) Graphics_RIGHTcxx . . $ `sys/Graphics.h:251:9`! ? x2 - horizontalMargin_wc :
2071 0.5 * (x1 + x2)
2072 ;
2073 const double yWC =
2074 mycxx . . $ `melder/melder.h:44:9`! verticalTextAlignmentcxx . . $ structGraphics#verticalTextAlignment. == Graphics_BOTTOMcxx . . $ `sys/Graphics.h:252:9`! ? y1 + verticalMargin_wc :
2075 mycxx . . $ `melder/melder.h:44:9`! verticalTextAlignmentcxx . . $ structGraphics#verticalTextAlignment. == Graphics_TOPcxx . . $ `sys/Graphics.h:254:9`! ? y2 - verticalMargin_wc :
2076 0.5 * (y1 + y2)
2077 ;
2078 nonrecorded_Graphics_textcxx . . $ nonrecorded_Graphics_text(8e1820bb471fc8c8). (me, xWC, yWC, text);
2079 mycxx . . $ `melder/melder.h:44:9`! fontSizecxx . . $ structGraphics#fontSize. = save_fontSize;
2080 }
2081 }
2082
2083 double Graphics_inqTextXcxx . . $ Graphics_inqTextX(f906975acce41a59). (Graphicscxx . . $ Graphics# me) { return mycxx . . $ `melder/melder.h:44:9`! textXcxx . . $ structGraphics#textX.; }
2084 double Graphics_inqTextYcxx . . $ Graphics_inqTextY(f906975acce41a59). (Graphicscxx . . $ Graphics# me) { return mycxx . . $ `melder/melder.h:44:9`! textYcxx . . $ structGraphics#textY.; }
2085
2086 int Graphics_getLinkscxx . . $ Graphics_getLinks(52bc958f6c9f5dbe). (Graphics_Linkcxx . . $ Graphics_Link# **plinks) { *plinks = & linkscxx . . $ links. [0]; return numberOfLinkscxx . . $ numberOfLinks.; }
2087
2088 static double psTextWidthcxx . . $ psTextWidth(8ab99eaa20bf6e15). (_Graphics_widecharcxx . . $ _Graphics_widechar# string [], bool useSilipaPS) {
2089 /*
2090 The following has to be kept IN SYNC with GraphicsPostscript::charSize.
2091 */
2092 double textWidth = 0.0;
2093 for (_Graphics_widecharcxx . . $ _Graphics_widechar# *character = & string [0]; character -> karcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#kar. > U'\t'; character ++) {
2094 Longchar_Infocxx . . $ Longchar_Info# info = character -> karInfocxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#karInfo.;
2095 const int font = (
2096 info -> alphabetcxx . . $ structLongchar_Info#alphabet. == Longchar_SYMBOLcxx . . $ `kar/longchar.h:44:9`! ?
2097 kGraphics_font_SYMBOLcxx . . $ `sys/GraphicsP.h:37:9`!
2098 : info -> alphabetcxx . . $ structLongchar_Info#alphabet. == Longchar_PHONETICcxx . . $ `kar/longchar.h:45:9`! ?
2099 kGraphics_font_IPATIMEScxx . . $ `sys/GraphicsP.h:38:9`!
2100 : info -> alphabetcxx . . $ structLongchar_Info#alphabet. == Longchar_DINGBATScxx . . $ `kar/longchar.h:46:9`! ?
2101 kGraphics_font_DINGBATScxx . . $ `sys/GraphicsP.h:41:9`!
2102 :
2103 character -> fontcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#font..integer_cxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#$anonymous_type_2#integer_.
2104 );
2105 const int style = (
2106 character -> stylecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#style. == Graphics_ITALICcxx . . $ `sys/Graphics.h:263:9`! ?
2107 Graphics_ITALICcxx . . $ `sys/Graphics.h:263:9`!
2108 : character -> stylecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#style. == Graphics_BOLDcxx . . $ `sys/Graphics.h:262:9`! || character -> linkcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#link. ?
2109 Graphics_BOLDcxx . . $ `sys/Graphics.h:262:9`!
2110 : character -> stylecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#style. == Graphics_BOLD_ITALICcxx . . $ `sys/Graphics.h:264:9`! ?
2111 Graphics_BOLD_ITALICcxx . . $ `sys/Graphics.h:264:9`!
2112 :
2113 0
2114 );
2115 const double size = character -> sizecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#size. * 0.01;
2116 double charWidth = 600; // Courier
2117 if (font == (int) kGraphics_fontcxx . . $ kGraphics_font#::COURIERcxx . . $ kGraphics_font#COURIER.) {
2118 charWidth = 600;
2119 } else if (style == 0) {
2120 if (font == (int) kGraphics_fontcxx . . $ kGraphics_font#::TIMEScxx . . $ kGraphics_font#TIMES.)
2121 charWidth = info -> pscxx . . $ structLongchar_Info#ps..timescxx . . $ structLongchar_Info#$anonymous_type_0#times.;
2122 else if (font == (int) kGraphics_fontcxx . . $ kGraphics_font#::HELVETICAcxx . . $ kGraphics_font#HELVETICA.)
2123 charWidth = info -> pscxx . . $ structLongchar_Info#ps..helveticacxx . . $ structLongchar_Info#$anonymous_type_0#helvetica.;
2124 else if (font == (int) kGraphics_fontcxx . . $ kGraphics_font#::PALATINOcxx . . $ kGraphics_font#PALATINO.)
2125 charWidth = info -> pscxx . . $ structLongchar_Info#ps..palatinocxx . . $ structLongchar_Info#$anonymous_type_0#palatino.;
2126 else if (font == kGraphics_font_IPATIMEScxx . . $ `sys/GraphicsP.h:38:9`! && useSilipaPS)
2127 charWidth = info -> pscxx . . $ structLongchar_Info#ps..timesItaliccxx . . $ structLongchar_Info#$anonymous_type_0#timesItalic.;
2128 else
2129 charWidth = info -> pscxx . . $ structLongchar_Info#ps..timescxx . . $ structLongchar_Info#$anonymous_type_0#times.; // Symbol, IPA
2130 } else if (style == Graphics_BOLDcxx . . $ `sys/Graphics.h:262:9`!) {
2131 if (font == (int) kGraphics_fontcxx . . $ kGraphics_font#::TIMEScxx . . $ kGraphics_font#TIMES.)
2132 charWidth = info -> pscxx . . $ structLongchar_Info#ps..timesBoldcxx . . $ structLongchar_Info#$anonymous_type_0#timesBold.;
2133 else if (font == (int) kGraphics_fontcxx . . $ kGraphics_font#::HELVETICAcxx . . $ kGraphics_font#HELVETICA.)
2134 charWidth = info -> pscxx . . $ structLongchar_Info#ps..helveticaBoldcxx . . $ structLongchar_Info#$anonymous_type_0#helveticaBold.;
2135 else if (font == (int) kGraphics_fontcxx . . $ kGraphics_font#::PALATINOcxx . . $ kGraphics_font#PALATINO.)
2136 charWidth = info -> pscxx . . $ structLongchar_Info#ps..palatinoBoldcxx . . $ structLongchar_Info#$anonymous_type_0#palatinoBold.;
2137 else if (font == kGraphics_font_IPATIMEScxx . . $ `sys/GraphicsP.h:38:9`! && useSilipaPS)
2138 charWidth = info -> pscxx . . $ structLongchar_Info#ps..timesBoldItaliccxx . . $ structLongchar_Info#$anonymous_type_0#timesBoldItalic.;
2139 else
2140 charWidth = info -> pscxx . . $ structLongchar_Info#ps..timescxx . . $ structLongchar_Info#$anonymous_type_0#times.;
2141 } else if (style == Graphics_ITALICcxx . . $ `sys/Graphics.h:263:9`!) {
2142 if (font == (int) kGraphics_fontcxx . . $ kGraphics_font#::TIMEScxx . . $ kGraphics_font#TIMES.)
2143 charWidth = info -> pscxx . . $ structLongchar_Info#ps..timesItaliccxx . . $ structLongchar_Info#$anonymous_type_0#timesItalic.;
2144 else if (font == (int) kGraphics_fontcxx . . $ kGraphics_font#::HELVETICAcxx . . $ kGraphics_font#HELVETICA.)
2145 charWidth = info -> pscxx . . $ structLongchar_Info#ps..helveticacxx . . $ structLongchar_Info#$anonymous_type_0#helvetica.;
2146 else if (font == (int) kGraphics_fontcxx . . $ kGraphics_font#::PALATINOcxx . . $ kGraphics_font#PALATINO.)
2147 charWidth = info -> pscxx . . $ structLongchar_Info#ps..palatinoItaliccxx . . $ structLongchar_Info#$anonymous_type_0#palatinoItalic.;
2148 else if (font == kGraphics_font_IPATIMEScxx . . $ `sys/GraphicsP.h:38:9`! && useSilipaPS)
2149 charWidth = info -> pscxx . . $ structLongchar_Info#ps..timesItaliccxx . . $ structLongchar_Info#$anonymous_type_0#timesItalic.;
2150 else
2151 charWidth = info -> pscxx . . $ structLongchar_Info#ps..timescxx . . $ structLongchar_Info#$anonymous_type_0#times.;
2152 } else if (style == Graphics_BOLD_ITALICcxx . . $ `sys/Graphics.h:264:9`!) {
2153 if (font == (int) kGraphics_fontcxx . . $ kGraphics_font#::TIMEScxx . . $ kGraphics_font#TIMES.)
2154 charWidth = info -> pscxx . . $ structLongchar_Info#ps..timesBoldItaliccxx . . $ structLongchar_Info#$anonymous_type_0#timesBoldItalic.;
2155 else if (font == (int) kGraphics_fontcxx . . $ kGraphics_font#::HELVETICAcxx . . $ kGraphics_font#HELVETICA.)
2156 charWidth = info -> pscxx . . $ structLongchar_Info#ps..helveticaBoldcxx . . $ structLongchar_Info#$anonymous_type_0#helveticaBold.;
2157 else if (font == (int) kGraphics_fontcxx . . $ kGraphics_font#::PALATINOcxx . . $ kGraphics_font#PALATINO.)
2158 charWidth = info -> pscxx . . $ structLongchar_Info#ps..palatinoBoldItaliccxx . . $ structLongchar_Info#$anonymous_type_0#palatinoBoldItalic.;
2159 else if (font == kGraphics_font_IPATIMEScxx . . $ `sys/GraphicsP.h:38:9`! && useSilipaPS)
2160 charWidth = info -> pscxx . . $ structLongchar_Info#ps..timesBoldItaliccxx . . $ structLongchar_Info#$anonymous_type_0#timesBoldItalic.;
2161 else
2162 charWidth = info -> pscxx . . $ structLongchar_Info#ps..timescxx . . $ structLongchar_Info#$anonymous_type_0#times.;
2163 }
2164 charWidth *= size / 1000.0;
2165 textWidth += charWidth;
2166 }
2167 /*
2168 * The following has to be kept IN SYNC with charSizes ().
2169 */
2170 for (_Graphics_widecharcxx . . $ _Graphics_widechar# *character = & string [0]; character -> karcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#kar. > U'\t'; character ++) {
2171 if ((character -> stylecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#style. & Graphics_ITALICcxx . . $ `sys/Graphics.h:263:9`!) != 0) {
2172 _Graphics_widecharcxx . . $ _Graphics_widechar# *nextCharacter = character + 1;
2173 if (nextCharacter -> karcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#kar. <= U'\t') {
2174 textWidth += POSTSCRIPT_SLANT_CORRECTIONcxx . . $ `sys/Graphics_text.cpp:32:9`!;
2175 } else if (((nextCharacter -> stylecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#style. & Graphics_ITALICcxx . . $ `sys/Graphics.h:263:9`!) == 0 && nextCharacter -> baselinecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#baseline. >= character -> baselinecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#baseline.)
2176 || (character -> baselinecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#baseline. == 0 && nextCharacter -> baselinecxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#baseline. > 0))
2177 {
2178 if (nextCharacter -> karcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#kar. == U'.' || nextCharacter -> karcxx . . $ $anonymous_type_5b6ec70e96eeadfb_1#kar. == U',')
2179 textWidth += 0.5 * POSTSCRIPT_SLANT_CORRECTIONcxx . . $ `sys/Graphics_text.cpp:32:9`!;
2180 else
2181 textWidth += POSTSCRIPT_SLANT_CORRECTIONcxx . . $ `sys/Graphics_text.cpp:32:9`!;
2182 }
2183 }
2184 }
2185 return textWidth;
2186 }
2187
2188 double Graphics_textWidth_ps_mmcxx . . $ Graphics_textWidth_ps_mm(e28a56f5afea616d). (Graphicscxx . . $ Graphics# me, conststring32cxx . . $ conststring32# txt, bool useSilipaPS) {
2189 if (! initBuffercxx . . $ initBuffer(e049ab16a3067c7). (txt))
2190 return 0.0;
2191 parseTextIntoCellsLinesRunscxx . . $ parseTextIntoCellsLinesRuns(3ddce6bcef9a19ab). (me, txt, theWidecharcxx . . $ theWidechar.);
2192 return psTextWidthcxx . . $ psTextWidth(8ab99eaa20bf6e15). (theWidecharcxx . . $ theWidechar., useSilipaPS) * (double) mycxx . . $ `melder/melder.h:44:9`! fontSizecxx . . $ structGraphics#fontSize. * (25.4 / 72.0);
2193 }
2194
2195 double Graphics_textWidth_pscxx . . $ Graphics_textWidth_ps(e28a56f5afea616d). (Graphicscxx . . $ Graphics# me, conststring32cxx . . $ conststring32# txt, bool useSilipaPS) {
2196 return Graphics_dxMMtoWCcxx . . $ Graphics_dxMMtoWC(f042c24bcd87f07e). (me, Graphics_textWidth_ps_mmcxx . . $ Graphics_textWidth_ps_mm(e28a56f5afea616d). (me, txt, useSilipaPS));
2197 }
2198
2199 #if quartzcxx . . $ `sys/GraphicsP.h:57:10`!
2200 bool _GraphicsMac_tryToInitializeFonts () {
2201 static bool inited = false;
2202 if (inited)
2203 return true;
2204 NSArray *fontNames = [[NSFontManager sharedFontManager] availableFontFamilies];
2205 hasTimes = [fontNames containsObject: @"Times"];
2206 if (! hasTimes)
2207 hasTimes = [fontNames containsObject: @"Times New Roman"];
2208 hasHelvetica = [fontNames containsObject: @"Helvetica"];
2209 if (! hasHelvetica)
2210 hasHelvetica = [fontNames containsObject: @"Arial"];
2211 hasCourier = [fontNames containsObject: @"Courier"];
2212 if (! hasCourier)
2213 hasCourier = [fontNames containsObject: @"Courier New"];
2214 hasPalatino = [fontNames containsObject: @"Palatino"];
2215 if (! hasPalatino)
2216 hasPalatino = [fontNames containsObject: @"Book Antiqua"];
2217 hasDoulos = [fontNames containsObject: @"Doulos SIL"];
2218 hasCharis = [fontNames containsObject: @"Charis"]; // try Charis 7
2219 if (hasCharis)
2220 hasCharis7 = true;
2221 else
2222 hasCharis = [fontNames containsObject: @"Charis SIL"]; // try Charis 6
2223 hasIpaSerif = hasDoulos || hasCharis;
2224 inited = true;
2225 return true;
2226 }
2227 #endif
2228
2229 #if cairocxx . . $ `sys/GraphicsP.h:54:10`!
2230 static const char *testFontcxx . . $ testFont(fb58d2e09a2a1ce6). (const char *fontName) {
2231 PangoFontDescription *pangoFontDescription = pango_font_description_from_string (fontName);
2232 PangoFont *pangoFont = pango_font_map_load_font (thePangoFontMapcxx . . $ thePangoFontMap., thePangoContextcxx . . $ thePangoContext., pangoFontDescription);
2233 PangoFontDescription *pangoFontDescription2 = pango_font_describe (pangoFont);
2234 return pango_font_description_get_family (pangoFontDescription2);
2235 }
2236 bool _GraphicsLin_tryToInitializeFontscxx . . $ _GraphicsLin_tryToInitializeFonts(c9857a73d68e59ba). () {
2237 static bool inited = false;
2238 if (inited)
2239 return true;
2240 thePangoFontMapcxx . . $ thePangoFontMap. = pango_cairo_font_map_get_default ();
2241 thePangoContextcxx . . $ thePangoContext. = pango_font_map_create_context (thePangoFontMapcxx . . $ thePangoFontMap.);
2242 #if 0 /* For debugging: list all fonts. */
2243 PangoFontFamily **families;
2244 int numberOfFamilies;
2245 pango_font_map_list_families (thePangoFontMap, & families, & numberOfFamilies);
2246 for (int i = 0; i < numberOfFamilies; i ++)
2247 fprintf (Melder_stderr, "%d %s\n", i, pango_font_family_get_name (families [i]));
2248 g_free (families);
2249 #endif
2250 const char *trueName;
2251
2252 trueName = testFontcxx . . $ testFont(fb58d2e09a2a1ce6). ("Times");
2253 if (Melder_debugcxx . . $ Melder_debug. == 58)
2254 Melder_casualcxx . . $ Melder_casual(6298c93241566110). (U"True name of Times font: ", Melder_peek8to32_u (trueName));
2255 hasTimescxx . . $ hasTimes. = !! strstr (trueName, "Times") || !! strstr (trueName, "Roman") || !! strstr (trueName, "Serif");
2256
2257 trueName = testFontcxx . . $ testFont(fb58d2e09a2a1ce6). ("Helvetica");
2258 if (Melder_debugcxx . . $ Melder_debug. == 58)
2259 Melder_casualcxx . . $ Melder_casual(6298c93241566110). (U"True name of Helvetica font: ", Melder_peek8to32_u (trueName));
2260 hasHelveticacxx . . $ hasHelvetica. = !! strstr (trueName, "Helvetica") || !! strstr (trueName, "Arial") || !! strstr (trueName, "Sans");
2261
2262 trueName = testFontcxx . . $ testFont(fb58d2e09a2a1ce6). ("Courier");
2263 if (Melder_debugcxx . . $ Melder_debug. == 58)
2264 Melder_casualcxx . . $ Melder_casual(6298c93241566110). (U"True name of Courier font: ", Melder_peek8to32_u (trueName));
2265 hasCouriercxx . . $ hasCourier. = !! strstr (trueName, "Courier") || !! strstr (trueName, "Mono");
2266
2267 trueName = testFontcxx . . $ testFont(fb58d2e09a2a1ce6). ("Palatino");
2268 if (Melder_debugcxx . . $ Melder_debug. == 58)
2269 Melder_casualcxx . . $ Melder_casual(6298c93241566110). (U"True name of Palatino font: ", Melder_peek8to32_u (trueName));
2270 hasPalatinocxx . . $ hasPalatino. = !! strstr (trueName, "Palatino") || !! strstr (trueName, "Palladio") || !! strstr (trueName, "P052");
2271
2272 trueName = testFontcxx . . $ testFont(fb58d2e09a2a1ce6). ("Doulos SIL");
2273 if (Melder_debugcxx . . $ Melder_debug. == 58)
2274 Melder_casualcxx . . $ Melder_casual(6298c93241566110). (U"True name of Doulos SIL font: ", Melder_peek8to32_u (trueName));
2275 hasDouloscxx . . $ hasDoulos. = !! strstr (trueName, "Doulos");
2276
2277 trueName = testFontcxx . . $ testFont(fb58d2e09a2a1ce6). ("Charis");
2278 if (Melder_debugcxx . . $ Melder_debug. == 58)
2279 Melder_casualcxx . . $ Melder_casual(6298c93241566110). (U"True name of Charis font: ", Melder_peek8to32_u (trueName));
2280 hasChariscxx . . $ hasCharis. = !! strstr (trueName, "Charis");
2281
2282 if (hasChariscxx . . $ hasCharis.) {
2283 hasCharis7cxx . . $ hasCharis7. = true;
2284 } else {
2285 trueName = testFontcxx . . $ testFont(fb58d2e09a2a1ce6). ("Charis SIL");
2286 if (Melder_debugcxx . . $ Melder_debug. == 58)
2287 Melder_casualcxx . . $ Melder_casual(6298c93241566110). (U"True name of Charis SIL font: ", Melder_peek8to32_u (trueName));
2288 hasChariscxx . . $ hasCharis. = !! strstr (trueName, "Charis");
2289 }
2290
2291 hasIpaSerifcxx . . $ hasIpaSerif. = hasDouloscxx . . $ hasDoulos. || hasChariscxx . . $ hasCharis.;
2292 testFontcxx . . $ testFont(fb58d2e09a2a1ce6). ("Symbol");
2293 testFontcxx . . $ testFont(fb58d2e09a2a1ce6). ("Dingbats");
2294 if (Melder_debugcxx . . $ Melder_debug. == 58)
2295 Melder_casualcxx . . $ Melder_casual(6298c93241566110). (U"times ", hasTimescxx . . $ hasTimes., U" helvetica ", hasHelveticacxx . . $ hasHelvetica., U" courier ", hasCouriercxx . . $ hasCourier., U" palatino ", hasPalatinocxx . . $ hasPalatino.,
2296 U" doulos ", hasDouloscxx . . $ hasDoulos., U" charis ", hasChariscxx . . $ hasCharis., U" charis7 ", hasCharis7cxx . . $ hasCharis7.);
2297 inited = true;
2298 return true;
2299 }
2300 #endif
2301
2302 void _GraphicsScreen_text_initcxx . . $ _GraphicsScreen_text_init(2eab33b16e3c36be). (GraphicsScreencxx . . $ GraphicsScreen# me) { // BUG: should be done as late as possible
2303 #if cairocxx . . $ `sys/GraphicsP.h:54:10`!
2304 (void) me;
2305 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (_GraphicsLin_tryToInitializeFonts ());
2306 #elif gdi
2307 int font, size, style;
2308 if (my printer || my metafile)
2309 for (font = (int) kGraphics_font::MIN; font <= kGraphics_font_DINGBATS; font ++)
2310 for (size = 0; size <= 4; size ++)
2311 for (style = 0; style <= Graphics_BOLD_ITALIC; style ++)
2312 if (fonts [(int) my resolutionNumber] [font] [size] [style]) {
2313 //DeleteObject (fonts [my resolutionNumber] [font] [size] [style]);
2314 //fonts [my resolutionNumber] [font] [size] [style] = 0;
2315 }
2316 #elif quartz
2317 (void) me;
2318 Melder_assert (_GraphicsMac_tryToInitializeFonts ()); // should have been handled when setting my useQuartz to true
2319 #endif
2320 }
2321
2322 /* Output attributes. */
2323
2324 void Graphics_setTextAlignmentcxx . . $ Graphics_setTextAlignment(a697afee548943ae). (Graphicscxx . . $ Graphics# me, kGraphics_horizontalAlignmentcxx . . $ kGraphics_horizontalAlignment# hor, int vert) {
2325 if ((int) hor != Graphics_NOCHANGEcxx . . $ `sys/Graphics.h:248:9`!)
2326 mycxx . . $ `melder/melder.h:44:9`! horizontalTextAlignmentcxx . . $ structGraphics#horizontalTextAlignment. = (int) hor;
2327 if (vert != Graphics_NOCHANGEcxx . . $ `sys/Graphics.h:248:9`!)
2328 mycxx . . $ `melder/melder.h:44:9`! verticalTextAlignmentcxx . . $ structGraphics#verticalTextAlignment. = vert;
2329 if (mycxx . . $ `melder/melder.h:44:9`! recordingcxx . . $ structGraphics#recording.) { opcxx . . $ `sys/GraphicsP.h:179:9`! (SET_TEXT_ALIGNMENT, 2); putcxx . . $ `sys/GraphicsP.h:178:9`! (hor); putcxx . . $ `sys/GraphicsP.h:178:9`! (vert); }
2330 }
2331
2332 void Graphics_setFontcxx . . $ Graphics_setFont(f6e617e53e6c04dc). (Graphicscxx . . $ Graphics# me, kGraphics_fontcxx . . $ kGraphics_font# font) {
2333 mycxx . . $ `melder/melder.h:44:9`! fontcxx . . $ structGraphics#font. = font;
2334 if (mycxx . . $ `melder/melder.h:44:9`! recordingcxx . . $ structGraphics#recording.) { opcxx . . $ `sys/GraphicsP.h:179:9`! (SET_FONT, 1); putcxx . . $ `sys/GraphicsP.h:178:9`! (font); }
2335 }
2336
2337 void Graphics_setFontSizecxx . . $ Graphics_setFontSize(2514a1c07b6be5e2). (Graphicscxx . . $ Graphics# me, double size) {
2338 mycxx . . $ `melder/melder.h:44:9`! fontSizecxx . . $ structGraphics#fontSize. = size;
2339 if (mycxx . . $ `melder/melder.h:44:9`! recordingcxx . . $ structGraphics#recording.) { opcxx . . $ `sys/GraphicsP.h:179:9`! (SET_FONT_SIZE, 1); putcxx . . $ `sys/GraphicsP.h:178:9`! (size); }
2340 }
2341
2342 void Graphics_setFontStylecxx . . $ Graphics_setFontStyle(9abe41586e87648d). (Graphicscxx . . $ Graphics# me, int style) {
2343 mycxx . . $ `melder/melder.h:44:9`! fontStylecxx . . $ structGraphics#fontStyle. = style;
2344 if (mycxx . . $ `melder/melder.h:44:9`! recordingcxx . . $ structGraphics#recording.) { opcxx . . $ `sys/GraphicsP.h:179:9`! (SET_FONT_STYLE, 1); putcxx . . $ `sys/GraphicsP.h:178:9`! (style); }
2345 }
2346
2347 void Graphics_setItaliccxx . . $ Graphics_setItalic(b5ae742079ad918c). (Graphicscxx . . $ Graphics# me, bool onoff) {
2348 Graphics_setFontStylecxx . . $ Graphics_setFontStyle(9abe41586e87648d). (me, ( onoff ? mycxx . . $ `melder/melder.h:44:9`! fontStylecxx . . $ structGraphics#fontStyle. | Graphics_ITALICcxx . . $ `sys/Graphics.h:263:9`! : mycxx . . $ `melder/melder.h:44:9`! fontStylecxx . . $ structGraphics#fontStyle. & ~ Graphics_ITALICcxx . . $ `sys/Graphics.h:263:9`! ));
2349 }
2350
2351 void Graphics_setBoldcxx . . $ Graphics_setBold(b5ae742079ad918c). (Graphicscxx . . $ Graphics# me, bool onoff) {
2352 Graphics_setFontStylecxx . . $ Graphics_setFontStyle(9abe41586e87648d). (me, ( onoff ? mycxx . . $ `melder/melder.h:44:9`! fontStylecxx . . $ structGraphics#fontStyle. | Graphics_BOLDcxx . . $ `sys/Graphics.h:262:9`! : mycxx . . $ `melder/melder.h:44:9`! fontStylecxx . . $ structGraphics#fontStyle. & ~ Graphics_BOLDcxx . . $ `sys/Graphics.h:262:9`! ));
2353 }
2354
2355 void Graphics_setCodecxx . . $ Graphics_setCode(b5ae742079ad918c). (Graphicscxx . . $ Graphics# me, bool onoff) {
2356 Graphics_setFontStylecxx . . $ Graphics_setFontStyle(9abe41586e87648d). (me, ( onoff ? mycxx . . $ `melder/melder.h:44:9`! fontStylecxx . . $ structGraphics#fontStyle. | Graphics_CODEcxx . . $ `sys/Graphics.h:265:9`! : mycxx . . $ `melder/melder.h:44:9`! fontStylecxx . . $ structGraphics#fontStyle. & ~ Graphics_CODEcxx . . $ `sys/Graphics.h:265:9`! ));
2357 }
2358
2359 void Graphics_setTextRotationcxx . . $ Graphics_setTextRotation(2514a1c07b6be5e2). (Graphicscxx . . $ Graphics# me, double angle) {
2360 mycxx . . $ `melder/melder.h:44:9`! textRotationcxx . . $ structGraphics#textRotation. = angle;
2361 if (mycxx . . $ `melder/melder.h:44:9`! recordingcxx . . $ structGraphics#recording.) { opcxx . . $ `sys/GraphicsP.h:179:9`! (SET_TEXT_ROTATION, 1); putcxx . . $ `sys/GraphicsP.h:178:9`! (angle); }
2362 }
2363
2364 void Graphics_setWrapWidthcxx . . $ Graphics_setWrapWidth(2514a1c07b6be5e2). (Graphicscxx . . $ Graphics# me, double wrapWidth) {
2365 mycxx . . $ `melder/melder.h:44:9`! wrapWidthcxx . . $ structGraphics#wrapWidth. = wrapWidth;
2366 if (mycxx . . $ `melder/melder.h:44:9`! recordingcxx . . $ structGraphics#recording.) { opcxx . . $ `sys/GraphicsP.h:179:9`! (SET_WRAP_WIDTH, 1); putcxx . . $ `sys/GraphicsP.h:178:9`! (wrapWidth); }
2367 }
2368
2369 void Graphics_setSecondIndentcxx . . $ Graphics_setSecondIndent(2514a1c07b6be5e2). (Graphicscxx . . $ Graphics# me, double indent) {
2370 mycxx . . $ `melder/melder.h:44:9`! secondIndentcxx . . $ structGraphics#secondIndent. = indent;
2371 if (mycxx . . $ `melder/melder.h:44:9`! recordingcxx . . $ structGraphics#recording.) { opcxx . . $ `sys/GraphicsP.h:179:9`! (SET_SECOND_INDENT, 1); putcxx . . $ `sys/GraphicsP.h:178:9`! (indent); }
2372 }
2373
2374 void Graphics_setPercentSignIsItaliccxx . . $ Graphics_setPercentSignIsItalic(b5ae742079ad918c). (Graphicscxx . . $ Graphics# me, bool isItalic) {
2375 mycxx . . $ `melder/melder.h:44:9`! percentSignIsItaliccxx . . $ structGraphics#percentSignIsItalic. = isItalic;
2376 if (mycxx . . $ `melder/melder.h:44:9`! recordingcxx . . $ structGraphics#recording.) { opcxx . . $ `sys/GraphicsP.h:179:9`! (SET_PERCENT_SIGN_IS_ITALIC, 1); putcxx . . $ `sys/GraphicsP.h:178:9`! (isItalic); }
2377 }
2378
2379 void Graphics_setNumberSignIsBoldcxx . . $ Graphics_setNumberSignIsBold(b5ae742079ad918c). (Graphicscxx . . $ Graphics# me, bool isBold) {
2380 mycxx . . $ `melder/melder.h:44:9`! numberSignIsBoldcxx . . $ structGraphics#numberSignIsBold. = isBold;
2381 if (mycxx . . $ `melder/melder.h:44:9`! recordingcxx . . $ structGraphics#recording.) { opcxx . . $ `sys/GraphicsP.h:179:9`! (SET_NUMBER_SIGN_IS_BOLD, 1); putcxx . . $ `sys/GraphicsP.h:178:9`! (isBold); }
2382 }
2383
2384 void Graphics_setCircumflexIsSuperscriptcxx . . $ Graphics_setCircumflexIsSuperscript(b5ae742079ad918c). (Graphicscxx . . $ Graphics# me, bool isSuperscript) {
2385 mycxx . . $ `melder/melder.h:44:9`! circumflexIsSuperscriptcxx . . $ structGraphics#circumflexIsSuperscript. = isSuperscript;
2386 if (mycxx . . $ `melder/melder.h:44:9`! recordingcxx . . $ structGraphics#recording.) { opcxx . . $ `sys/GraphicsP.h:179:9`! (SET_CIRCUMFLEX_IS_SUPERSCRIPT, 1); putcxx . . $ `sys/GraphicsP.h:178:9`! (isSuperscript); }
2387 }
2388
2389 void Graphics_setUnderscoreIsSubscriptcxx . . $ Graphics_setUnderscoreIsSubscript(b5ae742079ad918c). (Graphicscxx . . $ Graphics# me, bool isSubscript) {
2390 mycxx . . $ `melder/melder.h:44:9`! underscoreIsSubscriptcxx . . $ structGraphics#underscoreIsSubscript. = isSubscript;
2391 if (mycxx . . $ `melder/melder.h:44:9`! recordingcxx . . $ structGraphics#recording.) { opcxx . . $ `sys/GraphicsP.h:179:9`! (SET_UNDERSCORE_IS_SUBSCRIPT, 1); putcxx . . $ `sys/GraphicsP.h:178:9`! (isSubscript); }
2392 }
2393
2394 void Graphics_setDollarSignIsCodecxx . . $ Graphics_setDollarSignIsCode(b5ae742079ad918c). (Graphicscxx . . $ Graphics# me, bool isCode) {
2395 mycxx . . $ `melder/melder.h:44:9`! dollarSignIsCodecxx . . $ structGraphics#dollarSignIsCode. = isCode;
2396 if (mycxx . . $ `melder/melder.h:44:9`! recordingcxx . . $ structGraphics#recording.) { opcxx . . $ `sys/GraphicsP.h:179:9`! (SET_DOLLAR_SIGN_IS_CODE, 1); putcxx . . $ `sys/GraphicsP.h:178:9`! (isCode); }
2397 }
2398
2399 void Graphics_setBackquoteIsVerbatimcxx . . $ Graphics_setBackquoteIsVerbatim(b5ae742079ad918c). (Graphicscxx . . $ Graphics# me, bool isVerbatim) {
2400 mycxx . . $ `melder/melder.h:44:9`! backquoteIsVerbatimcxx . . $ structGraphics#backquoteIsVerbatim. = isVerbatim;
2401 if (mycxx . . $ `melder/melder.h:44:9`! recordingcxx . . $ structGraphics#recording.) { opcxx . . $ `sys/GraphicsP.h:179:9`! (SET_BACKQUOTE_IS_VERBATIM, 1); putcxx . . $ `sys/GraphicsP.h:178:9`! (isVerbatim); }
2402 }
2403
2404 void Graphics_setAtSignIsLinkcxx . . $ Graphics_setAtSignIsLink(b5ae742079ad918c). (Graphicscxx . . $ Graphics# me, bool isLink) {
2405 mycxx . . $ `melder/melder.h:44:9`! atSignIsLinkcxx . . $ structGraphics#atSignIsLink. = isLink;
2406 if (mycxx . . $ `melder/melder.h:44:9`! recordingcxx . . $ structGraphics#recording.) { opcxx . . $ `sys/GraphicsP.h:179:9`! (SET_AT_SIGN_IS_LINK, 1); putcxx . . $ `sys/GraphicsP.h:178:9`! (isLink); }
2407 }
2408
2409 /* Inquiries. */
2410
2411 enum kGraphics_fontcxx . . $ kGraphics_font# Graphics_inqFontcxx . . $ Graphics_inqFont(c011b18e9bbd50c8). (Graphicscxx . . $ Graphics# me) { return mycxx . . $ `melder/melder.h:44:9`! fontcxx . . $ structGraphics#font.; }
2412 double Graphics_inqFontSizecxx . . $ Graphics_inqFontSize(f906975acce41a59). (Graphicscxx . . $ Graphics# me) { return mycxx . . $ `melder/melder.h:44:9`! fontSizecxx . . $ structGraphics#fontSize.; }
2413 int Graphics_inqFontStylecxx . . $ Graphics_inqFontStyle(d4bbe1b9daaaf11b). (Graphicscxx . . $ Graphics# me) { return mycxx . . $ `melder/melder.h:44:9`! fontStylecxx . . $ structGraphics#fontStyle.; }
2414
2415 /* End of file Graphics_text.cpp */