fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / svtools / source / misc / sampletext.cxx
blob9b017a8d653752b1fb78e122b15c66b59863746b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
9 #include <svtools/sampletext.hxx>
10 #include <vcl/font.hxx>
11 #include <vcl/outdev.hxx>
12 #include <vcl/virdev.hxx>
13 #include <vcl/metric.hxx>
14 #include <i18nutil/unicode.hxx>
16 bool isOpenSymbolFont(const Font &rFont)
18 return rFont.GetName().EqualsIgnoreCaseAscii("starsymbol") ||
19 rFont.GetName().EqualsIgnoreCaseAscii("opensymbol");
22 bool isSymbolFont(const Font &rFont)
24 return (rFont.GetCharSet() == RTL_TEXTENCODING_SYMBOL) ||
25 rFont.GetName().EqualsIgnoreCaseAscii("cmsy10") ||
26 rFont.GetName().EqualsIgnoreCaseAscii("cmex10") ||
27 rFont.GetName().EqualsIgnoreCaseAscii("feta26") ||
28 rFont.GetName().EqualsIgnoreCaseAscii("jsMath-cmsy10") ||
29 rFont.GetName().EqualsIgnoreCaseAscii("jsMath-cmex10") ||
30 rFont.GetName().EqualsIgnoreCaseAscii("msam10") ||
31 rFont.GetName().EqualsIgnoreCaseAscii("msbm10") ||
32 rFont.GetName().EqualsIgnoreCaseAscii("wasy10") ||
33 rFont.GetName().EqualsIgnoreCaseAscii("Denemo") ||
34 rFont.GetName().EqualsIgnoreCaseAscii("GlyphBasic1") ||
35 rFont.GetName().EqualsIgnoreCaseAscii("GlyphBasic2") ||
36 rFont.GetName().EqualsIgnoreCaseAscii("GlyphBasic3") ||
37 rFont.GetName().EqualsIgnoreCaseAscii("GlyphBasic4") ||
38 rFont.GetName().EqualsIgnoreCaseAscii("Letters Laughing") ||
39 rFont.GetName().EqualsIgnoreCaseAscii("MusiQwik") ||
40 rFont.GetName().EqualsIgnoreCaseAscii("MusiSync") ||
41 isOpenSymbolFont(rFont);
44 bool canRenderNameOfSelectedFont(OutputDevice &rDevice)
46 const Font &rFont = rDevice.GetFont();
47 return !isSymbolFont(rFont) && (STRING_LEN == rDevice.HasGlyphs(rFont, rFont.GetName()));
50 OUString makeShortRepresentativeSymbolTextForSelectedFont(OutputDevice &rDevice)
52 const bool bOpenSymbol = isOpenSymbolFont(rDevice.GetFont());
54 if (!bOpenSymbol)
56 FontCharMap aFontCharMap;
57 bool bHasCharMap = rDevice.GetFontCharMap(aFontCharMap);
58 if( bHasCharMap )
60 // use some sample characters available in the font
61 sal_Unicode aText[8];
63 // start just above the PUA used by most symbol fonts
64 sal_uInt32 cNewChar = 0xFF00;
65 #ifdef MACOSX
66 // on MacOSX there are too many non-presentable symbols above the codepoint 0x0192
67 if( !bOpenSymbol )
68 cNewChar = 0x0192;
69 #endif
71 const int nMaxCount = sizeof(aText)/sizeof(*aText) - 1;
72 int nSkip = aFontCharMap.GetCharCount() / nMaxCount;
73 if( nSkip > 10 )
74 nSkip = 10;
75 else if( nSkip <= 0 )
76 nSkip = 1;
77 for( int i = 0; i < nMaxCount; ++i )
79 sal_uInt32 cOldChar = cNewChar;
80 for( int j = nSkip; --j >= 0; )
81 cNewChar = aFontCharMap.GetPrevChar( cNewChar );
82 if( cOldChar == cNewChar )
83 break;
84 aText[ i ] = static_cast<sal_Unicode>(cNewChar); // TODO: support UCS4 samples
85 aText[ i+1 ] = 0;
88 return OUString(aText);
92 static sal_Unicode aImplSymbolFontText[] = {
93 0xF021,0xF032,0xF043,0xF054,0xF065,0xF076,0xF0B7,0xF0C8,0};
94 static sal_Unicode aImplStarSymbolText[] = {
95 0x2706,0x2704,0x270D,0xE033,0x2211,0x2288,0};
96 const sal_Unicode* pText = bOpenSymbol ? aImplStarSymbolText : aImplSymbolFontText;
97 OUString sSampleText(pText);
98 bool bHasSampleTextGlyphs = (STRING_LEN == rDevice.HasGlyphs(rDevice.GetFont(), sSampleText));
99 return bHasSampleTextGlyphs ? sSampleText : OUString();
102 //These ones are typically for use in the font dropdown box beside the
103 //fontname, so say things roughly like "Script/Alphabet/Name-Of-Major-Language"
105 //Here we don't always know the language of course, only the script that can be
106 //written with the font. Often that's one single language written in that
107 //script, or a handful of related languages where the name of the script is the
108 //same between languages, or the name in the major language is known by most
109 //readers of the minor languages, e.g. Yiddish is written with the HEBREW
110 //script as well, the vast majority of Yiddish readers will be able to read
111 //Hebrew as well.
112 OUString makeShortRepresentativeTextForScript(UScriptCode eScript)
114 OUString sSampleText;
115 switch (eScript)
117 case USCRIPT_GREEK:
119 const sal_Unicode aGrek[] = {
120 0x0391, 0x03BB, 0x03C6, 0x03AC, 0x03B2, 0x03B7, 0x03C4, 0x03BF
122 sSampleText = OUString(aGrek, SAL_N_ELEMENTS(aGrek));
123 break;
125 case USCRIPT_HEBREW:
127 const sal_Unicode aHebr[] = {
128 0x05D0, 0x05B8, 0x05DC, 0x05B6, 0x05E3, 0x05BE, 0x05D1, 0x05B5,
129 0x05BC, 0x05D9, 0x05EA, 0x0020, 0x05E2, 0x05B4, 0x05D1, 0x05B0,
130 0x05E8, 0x05B4, 0x05D9
132 sSampleText = OUString(aHebr, SAL_N_ELEMENTS(aHebr));
133 break;
135 case USCRIPT_ARABIC:
137 const sal_Unicode aArab[] = {
138 0x0623, 0x0628, 0x062C, 0x062F, 0x064A, 0x0629, 0x0020, 0x0639,
139 0x0631, 0x0628, 0x064A, 0x0629
141 sSampleText = OUString(aArab, SAL_N_ELEMENTS(aArab));
142 break;
144 case USCRIPT_DEVANAGARI:
146 const sal_Unicode aDeva[] = {
147 0x0926, 0x0947, 0x0935, 0x0928, 0x093E, 0x0917, 0x0930, 0x0940
149 sSampleText = OUString(aDeva, SAL_N_ELEMENTS(aDeva));
150 break;
152 case USCRIPT_BENGALI:
154 const sal_Unicode aBeng[] = {
155 0x09AC, 0x09BE, 0x0982, 0x09B2, 0x09BE, 0x0020, 0x09B2, 0x09BF,
156 0x09AA, 0x09BF
158 sSampleText = OUString(aBeng, SAL_N_ELEMENTS(aBeng));
159 break;
161 case USCRIPT_GURMUKHI:
163 const sal_Unicode aGuru[] = {
164 0x0A17, 0x0A41, 0x0A30, 0x0A2E, 0x0A41, 0x0A16, 0x0A40
166 sSampleText = OUString(aGuru, SAL_N_ELEMENTS(aGuru));
167 break;
169 case USCRIPT_GUJARATI:
171 const sal_Unicode aGujr[] = {
172 0x0A97, 0x0AC1, 0x0A9C, 0x0AB0, 0x0ABE, 0x0AA4, 0x0aC0, 0x0020,
173 0x0AB2, 0x0ABF, 0x0AAA, 0x0ABF
175 sSampleText = OUString(aGujr, SAL_N_ELEMENTS(aGujr));
176 break;
178 case USCRIPT_ORIYA:
180 const sal_Unicode aOrya[] = {
181 0x0B09, 0x0B24, 0x0B4D, 0x0B15, 0x0B33, 0x0020, 0x0B32, 0x0B3F,
182 0x0B2A, 0x0B3F
184 sSampleText = OUString(aOrya, SAL_N_ELEMENTS(aOrya));
185 break;
187 case USCRIPT_TAMIL:
189 const sal_Unicode aTaml[] = {
190 0x0B85, 0x0BB0, 0x0BBF, 0x0B9A, 0x0BCD, 0x0B9A, 0x0BC1, 0x0BB5,
191 0x0B9F, 0x0BBF
193 sSampleText = OUString(aTaml, SAL_N_ELEMENTS(aTaml));
194 break;
196 case USCRIPT_TELUGU:
198 const sal_Unicode aTelu[] = {
199 0x0C24, 0x0C46, 0x0C32, 0x0C41, 0x0C17, 0x0C41
201 sSampleText = OUString(aTelu, SAL_N_ELEMENTS(aTelu));
202 break;
204 case USCRIPT_KANNADA:
206 const sal_Unicode aKnda[] = {
207 0x0C95, 0x0CA8, 0x0CCD, 0x0CA8, 0x0CA1, 0x0020, 0x0CB2, 0x0CBF,
208 0x0CAA, 0x0CBF
210 sSampleText = OUString(aKnda, SAL_N_ELEMENTS(aKnda));
211 break;
213 case USCRIPT_MALAYALAM:
215 const sal_Unicode aMlym[] = {
216 0x0D2E, 0x0D32, 0x0D2F, 0x0D3E, 0x0D33, 0x0D32, 0x0D3F, 0x0D2A,
217 0x0D3F
219 sSampleText = OUString(aMlym, SAL_N_ELEMENTS(aMlym));
220 break;
222 case USCRIPT_THAI:
224 const sal_Unicode aThai[] = {
225 0x0E2D, 0x0E31, 0x0E01, 0x0E29, 0x0E23, 0x0E44, 0x0E17, 0x0E22
227 sSampleText = OUString(aThai, SAL_N_ELEMENTS(aThai));
228 break;
230 case USCRIPT_LAO:
232 const sal_Unicode aLao[] = {
233 0x0EAD, 0x0EB1, 0x0E81, 0x0EAA, 0x0EAD, 0x0E99, 0x0EA5, 0x0EB2,
234 0x0EA7
236 sSampleText = OUString(aLao, SAL_N_ELEMENTS(aLao));
237 break;
239 case USCRIPT_GEORGIAN:
241 const sal_Unicode aGeorgian[] = {
242 0x10D3, 0x10D0, 0x10DB, 0x10EC, 0x10D4, 0x10E0, 0x10DA, 0x10DD,
243 0x10D1, 0x10D0
245 sSampleText = OUString(aGeorgian, SAL_N_ELEMENTS(aGeorgian));
246 break;
248 case USCRIPT_HANGUL:
249 case USCRIPT_KOREAN:
251 const sal_Unicode aHang[] = {
252 0xD55C, 0xAE00
254 sSampleText = OUString(aHang, SAL_N_ELEMENTS(aHang));
255 break;
257 case USCRIPT_TIBETAN:
259 const sal_Unicode aTibt[] = {
260 0x0F51, 0x0F56, 0x0F74, 0x0F0B, 0x0F45, 0x0F53, 0x0F0B
262 sSampleText = OUString(aTibt, SAL_N_ELEMENTS(aTibt));
263 break;
265 case USCRIPT_SYRIAC:
267 const sal_Unicode aSyri[] = {
268 0x0723, 0x071B, 0x072A, 0x0722, 0x0713, 0x0720, 0x0710
270 sSampleText = OUString(aSyri, SAL_N_ELEMENTS(aSyri));
271 break;
273 case USCRIPT_THAANA:
275 const sal_Unicode aThaa[] = {
276 0x078C, 0x07A7, 0x0782, 0x07A6
278 sSampleText = OUString(aThaa, SAL_N_ELEMENTS(aThaa));
279 break;
281 case USCRIPT_SINHALA:
283 const sal_Unicode aSinh[] = {
284 0x0DC1, 0x0DD4, 0x0DAF, 0x0DCA, 0x0DB0, 0x0020, 0x0DC3, 0x0DD2,
285 0x0D82, 0x0DC4, 0x0DBD
287 sSampleText = OUString(aSinh, SAL_N_ELEMENTS(aSinh));
288 break;
290 case USCRIPT_MYANMAR:
292 const sal_Unicode aMymr[] = {
293 0x1019, 0x103C, 0x1014, 0x103A, 0x1019, 0x102C, 0x1021, 0x1000,
294 0x1039, 0x1001, 0x101B, 0x102C
296 sSampleText = OUString(aMymr, SAL_N_ELEMENTS(aMymr));
297 break;
299 case USCRIPT_ETHIOPIC:
301 const sal_Unicode aEthi[] = {
302 0x130D, 0x12D5, 0x12DD
304 sSampleText = OUString(aEthi, SAL_N_ELEMENTS(aEthi));
305 break;
307 case USCRIPT_CHEROKEE:
309 const sal_Unicode aCher[] = {
310 0x13D7, 0x13AA, 0x13EA, 0x13B6, 0x13D9, 0x13D7
312 sSampleText = OUString(aCher, SAL_N_ELEMENTS(aCher));
313 break;
315 case USCRIPT_KHMER:
317 const sal_Unicode aKhmr[] = {
318 0x17A2, 0x1780, 0x17D2, 0x1781, 0x179A, 0x1780, 0x17D2, 0x179A,
319 0x1798, 0x1781, 0x17C1, 0x1798, 0x179A, 0x1797, 0x17B6, 0x179F,
320 0x17B6
322 sSampleText = OUString(aKhmr, SAL_N_ELEMENTS(aKhmr));
323 break;
325 case USCRIPT_MONGOLIAN:
327 const sal_Unicode aMongolian[] = {
328 0x182A, 0x1822, 0x1834, 0x1822, 0x182D, 0x180C
330 sSampleText = OUString(aMongolian, SAL_N_ELEMENTS(aMongolian));
331 break;
333 case USCRIPT_TAGALOG:
335 const sal_Unicode aTagalog[] = {
336 0x170A, 0x170A, 0x170C, 0x1712
338 sSampleText = OUString(aTagalog, SAL_N_ELEMENTS(aTagalog));
339 break;
341 case USCRIPT_NEW_TAI_LUE:
343 const sal_Unicode aTalu[] = {
344 0x1991, 0x19BA, 0x199F, 0x19B9, 0x19C9
346 sSampleText = OUString(aTalu, SAL_N_ELEMENTS(aTalu));
347 break;
349 case USCRIPT_TRADITIONAL_HAN:
351 const sal_Unicode aHant[] = {
352 0x7E41
354 sSampleText = OUString(aHant, SAL_N_ELEMENTS(aHant));
355 break;
357 case USCRIPT_SIMPLIFIED_HAN:
359 const sal_Unicode aHans[] = {
360 0x7B80
362 sSampleText = OUString(aHans, SAL_N_ELEMENTS(aHans));
363 break;
365 case USCRIPT_HAN:
367 const sal_Unicode aSimplifiedAndTraditionalChinese[] = {
368 0x7B80, 0x7E41
370 sSampleText = OUString(aSimplifiedAndTraditionalChinese,
371 SAL_N_ELEMENTS(aSimplifiedAndTraditionalChinese));
372 break;
374 case USCRIPT_JAPANESE:
376 const sal_Unicode aJpan[] = {
377 0x65E5, 0x672C, 0x8A9E
379 sSampleText = OUString(aJpan, SAL_N_ELEMENTS(aJpan));
380 break;
382 case USCRIPT_YI:
384 const sal_Unicode aYiii[] = {
385 0xA188, 0xA320, 0xA071, 0xA0B7
387 sSampleText = OUString(aYiii, SAL_N_ELEMENTS(aYiii));
388 break;
390 case USCRIPT_PHAGS_PA:
392 const sal_Unicode aPhag[] = {
393 0xA84F, 0xA861, 0xA843, 0x0020, 0xA863, 0xA861, 0xA859, 0x0020,
394 0xA850, 0xA85C, 0xA85E
396 sSampleText = OUString(aPhag, SAL_N_ELEMENTS(aPhag));
397 break;
399 case USCRIPT_TAI_LE:
401 const sal_Unicode aTale[] = {
402 0x1956, 0x196D, 0x1970, 0x1956, 0x196C, 0x1973, 0x1951, 0x1968,
403 0x1952, 0x1970
405 sSampleText = OUString(aTale, SAL_N_ELEMENTS(aTale));
406 break;
408 case USCRIPT_LATIN:
409 sSampleText = OUString("Lorem ipsum");
410 break;
411 default:
412 break;
414 return sSampleText;
417 OUString makeRepresentativeTextForScript(UScriptCode eScript)
419 OUString sSampleText;
420 switch (eScript)
422 case USCRIPT_TRADITIONAL_HAN:
423 case USCRIPT_SIMPLIFIED_HAN:
424 case USCRIPT_HAN:
426 //Three Character Classic
427 const sal_Unicode aZh[] = {
428 0x4EBA, 0x4E4B, 0x521D, 0x0020, 0x6027, 0x672C, 0x5584
430 sSampleText = OUString(aZh, SAL_N_ELEMENTS(aZh));
431 break;
433 case USCRIPT_JAPANESE:
435 //'Beautiful Japanese'
436 const sal_Unicode aJa[] = {
437 0x7F8E, 0x3057, 0x3044, 0x65E5, 0x672C, 0x8A9E
439 sSampleText = OUString(aJa, SAL_N_ELEMENTS(aJa));
440 break;
442 case USCRIPT_KOREAN:
443 case USCRIPT_HANGUL:
445 //The essential condition for...
446 const sal_Unicode aKo[] = {
447 0xD0A4, 0xC2A4, 0xC758, 0x0020, 0xACE0, 0xC720, 0xC870,
448 0xAC74, 0xC740
450 sSampleText = OUString(aKo, SAL_N_ELEMENTS(aKo));
451 break;
453 default:
454 break;
457 if (sSampleText.isEmpty())
458 sSampleText = makeShortRepresentativeTextForScript(eScript);
459 return sSampleText;
462 OUString makeShortMinimalTextForScript(UScriptCode eScript)
464 OUString sSampleText;
465 switch (eScript)
467 case USCRIPT_GREEK:
469 const sal_Unicode aGrek[] = {
470 0x0391, 0x0392
472 sSampleText = OUString(aGrek, SAL_N_ELEMENTS(aGrek));
473 break;
475 case USCRIPT_HEBREW:
477 const sal_Unicode aHebr[] = {
478 0x05D0, 0x05D1
480 sSampleText = OUString(aHebr, SAL_N_ELEMENTS(aHebr));
481 break;
483 default:
484 break;
486 return sSampleText;
489 OUString makeMinimalTextForScript(UScriptCode eScript)
491 return makeShortMinimalTextForScript(eScript);
494 //These ones are typically for use in the font preview window in format
495 //character
497 //There we generally know the language. Though its possible for the language to
498 //be "none".
500 //Currently we fall back to makeShortRepresentativeTextForScript when we don't
501 //have suitable strings
502 OUString makeRepresentativeTextForLanguage(LanguageType eLang)
504 OUString sRet;
505 switch( eLang & LANGUAGE_MASK_PRIMARY )
507 case LANGUAGE_CHINESE & LANGUAGE_MASK_PRIMARY:
508 sRet = makeRepresentativeTextForScript(USCRIPT_HAN);
509 break;
510 case LANGUAGE_GREEK & LANGUAGE_MASK_PRIMARY:
511 sRet = makeRepresentativeTextForScript(USCRIPT_GREEK);
512 break;
513 case LANGUAGE_HEBREW & LANGUAGE_MASK_PRIMARY:
514 case LANGUAGE_YIDDISH & LANGUAGE_MASK_PRIMARY:
515 sRet = makeRepresentativeTextForScript(USCRIPT_HEBREW);
516 break;
517 case LANGUAGE_ARABIC_SAUDI_ARABIA & LANGUAGE_MASK_PRIMARY:
518 sRet = makeRepresentativeTextForScript(USCRIPT_ARABIC);
519 break;
520 case LANGUAGE_HINDI & LANGUAGE_MASK_PRIMARY:
521 sRet = makeRepresentativeTextForScript(USCRIPT_DEVANAGARI);
522 break;
523 case LANGUAGE_ASSAMESE & LANGUAGE_MASK_PRIMARY:
525 const sal_Unicode aAs[] = {
526 0x0985, 0x09B8, 0x09AE, 0x09C0, 0x09AF, 0x09BC, 0x09BE,
527 0x0020, 0x0986, 0x0996, 0x09F0
529 sRet = OUString(aAs, SAL_N_ELEMENTS(aAs));
530 break;
532 case LANGUAGE_BENGALI & LANGUAGE_MASK_PRIMARY:
533 sRet = makeRepresentativeTextForScript(USCRIPT_BENGALI);
534 break;
535 case LANGUAGE_PUNJABI & LANGUAGE_MASK_PRIMARY:
536 sRet = makeRepresentativeTextForScript(USCRIPT_GURMUKHI);
537 break;
538 case LANGUAGE_GUJARATI & LANGUAGE_MASK_PRIMARY:
539 sRet = makeRepresentativeTextForScript(USCRIPT_GUJARATI);
540 break;
541 case LANGUAGE_ORIYA & LANGUAGE_MASK_PRIMARY:
542 sRet = makeRepresentativeTextForScript(USCRIPT_ORIYA);
543 break;
544 case LANGUAGE_TAMIL & LANGUAGE_MASK_PRIMARY:
545 sRet = makeRepresentativeTextForScript(USCRIPT_TAMIL);
546 break;
547 case LANGUAGE_TELUGU & LANGUAGE_MASK_PRIMARY:
548 sRet = makeRepresentativeTextForScript(USCRIPT_TELUGU);
549 break;
550 case LANGUAGE_KANNADA & LANGUAGE_MASK_PRIMARY:
551 sRet = makeRepresentativeTextForScript(USCRIPT_KANNADA);
552 break;
553 case LANGUAGE_MALAYALAM & LANGUAGE_MASK_PRIMARY:
554 sRet = makeRepresentativeTextForScript(USCRIPT_MALAYALAM);
555 break;
556 case LANGUAGE_THAI & LANGUAGE_MASK_PRIMARY:
557 sRet = makeRepresentativeTextForScript(USCRIPT_THAI);
558 break;
559 case LANGUAGE_LAO & LANGUAGE_MASK_PRIMARY:
560 sRet = makeRepresentativeTextForScript(USCRIPT_LAO);
561 break;
562 case LANGUAGE_GEORGIAN & LANGUAGE_MASK_PRIMARY:
563 sRet = makeRepresentativeTextForScript(USCRIPT_GEORGIAN);
564 break;
565 case LANGUAGE_KOREAN & LANGUAGE_MASK_PRIMARY:
566 sRet = makeRepresentativeTextForScript(USCRIPT_KOREAN);
567 break;
568 case LANGUAGE_TIBETAN & LANGUAGE_MASK_PRIMARY:
569 sRet = makeRepresentativeTextForScript(USCRIPT_TIBETAN);
570 break;
571 case LANGUAGE_SYRIAC & LANGUAGE_MASK_PRIMARY:
572 sRet = makeRepresentativeTextForScript(USCRIPT_SYRIAC);
573 break;
574 case LANGUAGE_SINHALESE_SRI_LANKA & LANGUAGE_MASK_PRIMARY:
575 sRet = makeRepresentativeTextForScript(USCRIPT_SINHALA);
576 break;
577 case LANGUAGE_BURMESE & LANGUAGE_MASK_PRIMARY:
578 sRet = makeRepresentativeTextForScript(USCRIPT_MYANMAR);
579 break;
580 case LANGUAGE_AMHARIC_ETHIOPIA & LANGUAGE_MASK_PRIMARY:
581 sRet = makeRepresentativeTextForScript(USCRIPT_ETHIOPIC);
582 break;
583 case LANGUAGE_CHEROKEE_UNITED_STATES & LANGUAGE_MASK_PRIMARY:
584 sRet = makeRepresentativeTextForScript(USCRIPT_CHEROKEE);
585 break;
586 case LANGUAGE_KHMER & LANGUAGE_MASK_PRIMARY:
587 sRet = makeRepresentativeTextForScript(USCRIPT_KHMER);
588 break;
589 case LANGUAGE_MONGOLIAN & LANGUAGE_MASK_PRIMARY:
590 sRet = makeRepresentativeTextForScript(USCRIPT_MONGOLIAN);
591 break;
592 case LANGUAGE_JAPANESE & LANGUAGE_MASK_PRIMARY:
593 sRet = makeRepresentativeTextForScript(USCRIPT_JAPANESE);
594 break;
595 case LANGUAGE_YI & LANGUAGE_MASK_PRIMARY:
596 sRet = makeRepresentativeTextForScript(USCRIPT_YI);
597 break;
598 case LANGUAGE_GAELIC_IRELAND & LANGUAGE_MASK_PRIMARY:
600 const sal_Unicode aGa[] = {
601 'T', 0x00E9, 'a', 'c', 's', ' ', 'S', 'a', 'm', 'p', 'l', 'a', 'c', 'h'
603 sRet = OUString(aGa, SAL_N_ELEMENTS(aGa));
604 break;
606 default:
607 break;
610 return sRet;
613 namespace
615 #if OSL_DEBUG_LEVEL > 2
616 void lcl_dump_unicode_coverage(const boost::dynamic_bitset<sal_uInt32> &rIn)
618 if (rIn.none())
620 fprintf(stderr, "<NONE>\n");
621 return;
623 if (rIn[vcl::UnicodeCoverage::BASIC_LATIN])
624 fprintf(stderr, "BASIC_LATIN\n");
625 if (rIn[vcl::UnicodeCoverage::LATIN_1_SUPPLEMENT])
626 fprintf(stderr, "LATIN_1_SUPPLEMENT\n");
627 if (rIn[vcl::UnicodeCoverage::LATIN_EXTENDED_A])
628 fprintf(stderr, "LATIN_EXTENDED_A\n");
629 if (rIn[vcl::UnicodeCoverage::LATIN_EXTENDED_B])
630 fprintf(stderr, "LATIN_EXTENDED_B\n");
631 if (rIn[vcl::UnicodeCoverage::IPA_EXTENSIONS])
632 fprintf(stderr, "IPA_EXTENSIONS\n");
633 if (rIn[vcl::UnicodeCoverage::SPACING_MODIFIER_LETTERS])
634 fprintf(stderr, "SPACING_MODIFIER_LETTERS\n");
635 if (rIn[vcl::UnicodeCoverage::COMBINING_DIACRITICAL_MARKS])
636 fprintf(stderr, "COMBINING_DIACRITICAL_MARKS\n");
637 if (rIn[vcl::UnicodeCoverage::GREEK_AND_COPTIC])
638 fprintf(stderr, "GREEK_AND_COPTIC\n");
639 if (rIn[vcl::UnicodeCoverage::COPTIC])
640 fprintf(stderr, "COPTIC\n");
641 if (rIn[vcl::UnicodeCoverage::CYRILLIC])
642 fprintf(stderr, "CYRILLIC\n");
643 if (rIn[vcl::UnicodeCoverage::ARMENIAN])
644 fprintf(stderr, "ARMENIAN\n");
645 if (rIn[vcl::UnicodeCoverage::HEBREW])
646 fprintf(stderr, "HEBREW\n");
647 if (rIn[vcl::UnicodeCoverage::VAI])
648 fprintf(stderr, "VAI\n");
649 if (rIn[vcl::UnicodeCoverage::ARABIC])
650 fprintf(stderr, "ARABIC\n");
651 if (rIn[vcl::UnicodeCoverage::NKO])
652 fprintf(stderr, "NKO\n");
653 if (rIn[vcl::UnicodeCoverage::DEVANAGARI])
654 fprintf(stderr, "DEVANAGARI\n");
655 if (rIn[vcl::UnicodeCoverage::BENGALI])
656 fprintf(stderr, "BENGALI\n");
657 if (rIn[vcl::UnicodeCoverage::GURMUKHI])
658 fprintf(stderr, "GURMUKHI\n");
659 if (rIn[vcl::UnicodeCoverage::GUJARATI])
660 fprintf(stderr, "GUJARATI\n");
661 if (rIn[vcl::UnicodeCoverage::ORIYA])
662 fprintf(stderr, "ORIYA\n");
663 if (rIn[vcl::UnicodeCoverage::TAMIL])
664 fprintf(stderr, "TAMIL\n");
665 if (rIn[vcl::UnicodeCoverage::TELUGU])
666 fprintf(stderr, "TELUGU\n");
667 if (rIn[vcl::UnicodeCoverage::KANNADA])
668 fprintf(stderr, "KANNADA\n");
669 if (rIn[vcl::UnicodeCoverage::MALAYALAM])
670 fprintf(stderr, "MALAYALAM\n");
671 if (rIn[vcl::UnicodeCoverage::THAI])
672 fprintf(stderr, "THAI\n");
673 if (rIn[vcl::UnicodeCoverage::LAO])
674 fprintf(stderr, "LAO\n");
675 if (rIn[vcl::UnicodeCoverage::GEORGIAN])
676 fprintf(stderr, "GEORGIAN\n");
677 if (rIn[vcl::UnicodeCoverage::BALINESE])
678 fprintf(stderr, "BALINESE\n");
679 if (rIn[vcl::UnicodeCoverage::HANGUL_JAMO])
680 fprintf(stderr, "HANGUL_JAMO\n");
681 if (rIn[vcl::UnicodeCoverage::LATIN_EXTENDED_ADDITIONAL])
682 fprintf(stderr, "LATIN_EXTENDED_ADDITIONAL\n");
683 if (rIn[vcl::UnicodeCoverage::GREEK_EXTENDED])
684 fprintf(stderr, "GREEK_EXTENDED\n");
685 if (rIn[vcl::UnicodeCoverage::GENERAL_PUNCTUATION])
686 fprintf(stderr, "GENERAL_PUNCTUATION\n");
687 if (rIn[vcl::UnicodeCoverage::SUPERSCRIPTS_AND_SUBSCRIPTS])
688 fprintf(stderr, "SUPERSCRIPTS_AND_SUBSCRIPTS\n");
689 if (rIn[vcl::UnicodeCoverage::CURRENCY_SYMBOLS])
690 fprintf(stderr, "CURRENCY_SYMBOLS\n");
691 if (rIn[vcl::UnicodeCoverage::COMBINING_DIACRITICAL_MARKS_FOR_SYMBOLS])
692 fprintf(stderr, "COMBINING_DIACRITICAL_MARKS_FOR_SYMBOLS\n");
693 if (rIn[vcl::UnicodeCoverage::LETTERLIKE_SYMBOLS])
694 fprintf(stderr, "LETTERLIKE_SYMBOLS\n");
695 if (rIn[vcl::UnicodeCoverage::NUMBER_FORMS])
696 fprintf(stderr, "NUMBER_FORMS\n");
697 if (rIn[vcl::UnicodeCoverage::ARROWS])
698 fprintf(stderr, "ARROWS\n");
699 if (rIn[vcl::UnicodeCoverage::MATHEMATICAL_OPERATORS])
700 fprintf(stderr, "MATHEMATICAL_OPERATORS\n");
701 if (rIn[vcl::UnicodeCoverage::MISCELLANEOUS_TECHNICAL])
702 fprintf(stderr, "MISCELLANEOUS_TECHNICAL\n");
703 if (rIn[vcl::UnicodeCoverage::CONTROL_PICTURES])
704 fprintf(stderr, "CONTROL_PICTURES\n");
705 if (rIn[vcl::UnicodeCoverage::OPTICAL_CHARACTER_RECOGNITION])
706 fprintf(stderr, "OPTICAL_CHARACTER_RECOGNITION\n");
707 if (rIn[vcl::UnicodeCoverage::ENCLOSED_ALPHANUMERICS])
708 fprintf(stderr, "ENCLOSED_ALPHANUMERICS\n");
709 if (rIn[vcl::UnicodeCoverage::BOX_DRAWING])
710 fprintf(stderr, "BOX_DRAWING\n");
711 if (rIn[vcl::UnicodeCoverage::BLOCK_ELEMENTS])
712 fprintf(stderr, "BLOCK_ELEMENTS\n");
713 if (rIn[vcl::UnicodeCoverage::GEOMETRIC_SHAPES])
714 fprintf(stderr, "GEOMETRIC_SHAPES\n");
715 if (rIn[vcl::UnicodeCoverage::MISCELLANEOUS_SYMBOLS])
716 fprintf(stderr, "MISCELLANEOUS_SYMBOLS\n");
717 if (rIn[vcl::UnicodeCoverage::DINGBATS])
718 fprintf(stderr, "DINGBATS\n");
719 if (rIn[vcl::UnicodeCoverage::CJK_SYMBOLS_AND_PUNCTUATION])
720 fprintf(stderr, "CJK_SYMBOLS_AND_PUNCTUATION\n");
721 if (rIn[vcl::UnicodeCoverage::HIRAGANA])
722 fprintf(stderr, "HIRAGANA\n");
723 if (rIn[vcl::UnicodeCoverage::KATAKANA])
724 fprintf(stderr, "KATAKANA\n");
725 if (rIn[vcl::UnicodeCoverage::BOPOMOFO])
726 fprintf(stderr, "BOPOMOFO\n");
727 if (rIn[vcl::UnicodeCoverage::HANGUL_COMPATIBILITY_JAMO])
728 fprintf(stderr, "HANGUL_COMPATIBILITY_JAMO\n");
729 if (rIn[vcl::UnicodeCoverage::PHAGS_PA])
730 fprintf(stderr, "PHAGS_PA\n");
731 if (rIn[vcl::UnicodeCoverage::ENCLOSED_CJK_LETTERS_AND_MONTHS])
732 fprintf(stderr, "ENCLOSED_CJK_LETTERS_AND_MONTHS\n");
733 if (rIn[vcl::UnicodeCoverage::CJK_COMPATIBILITY])
734 fprintf(stderr, "CJK_COMPATIBILITY\n");
735 if (rIn[vcl::UnicodeCoverage::HANGUL_SYLLABLES])
736 fprintf(stderr, "HANGUL_SYLLABLES\n");
737 if (rIn[vcl::UnicodeCoverage::NONPLANE_0])
738 fprintf(stderr, "NONPLANE_0\n");
739 if (rIn[vcl::UnicodeCoverage::PHOENICIAN])
740 fprintf(stderr, "PHOENICIAN\n");
741 if (rIn[vcl::UnicodeCoverage::CJK_UNIFIED_IDEOGRAPHS])
742 fprintf(stderr, "CJK_UNIFIED_IDEOGRAPHS\n");
743 if (rIn[vcl::UnicodeCoverage::PRIVATE_USE_AREA_PLANE_0])
744 fprintf(stderr, "PRIVATE_USE_AREA_PLANE_0\n");
745 if (rIn[vcl::UnicodeCoverage::CJK_STROKES])
746 fprintf(stderr, "CJK_STROKES\n");
747 if (rIn[vcl::UnicodeCoverage::ALPHABETIC_PRESENTATION_FORMS])
748 fprintf(stderr, "ALPHABETIC_PRESENTATION_FORMS\n");
749 if (rIn[vcl::UnicodeCoverage::ARABIC_PRESENTATION_FORMS_A])
750 fprintf(stderr, "ARABIC_PRESENTATION_FORMS_A\n");
751 if (rIn[vcl::UnicodeCoverage::COMBINING_HALF_MARKS])
752 fprintf(stderr, "COMBINING_HALF_MARKS\n");
753 if (rIn[vcl::UnicodeCoverage::VERTICAL_FORMS])
754 fprintf(stderr, "VERTICAL_FORMS\n");
755 if (rIn[vcl::UnicodeCoverage::SMALL_FORM_VARIANTS])
756 fprintf(stderr, "SMALL_FORM_VARIANTS\n");
757 if (rIn[vcl::UnicodeCoverage::ARABIC_PRESENTATION_FORMS_B])
758 fprintf(stderr, "ARABIC_PRESENTATION_FORMS_B\n");
759 if (rIn[vcl::UnicodeCoverage::HALFWIDTH_AND_FULLWIDTH_FORMS])
760 fprintf(stderr, "HALFWIDTH_AND_FULLWIDTH_FORMS\n");
761 if (rIn[vcl::UnicodeCoverage::SPECIALS])
762 fprintf(stderr, "SPECIALS\n");
763 if (rIn[vcl::UnicodeCoverage::TIBETAN])
764 fprintf(stderr, "TIBETAN\n");
765 if (rIn[vcl::UnicodeCoverage::SYRIAC])
766 fprintf(stderr, "SYRIAC\n");
767 if (rIn[vcl::UnicodeCoverage::THAANA])
768 fprintf(stderr, "THAANA\n");
769 if (rIn[vcl::UnicodeCoverage::SINHALA])
770 fprintf(stderr, "SINHALA\n");
771 if (rIn[vcl::UnicodeCoverage::MYANMAR])
772 fprintf(stderr, "MYANMAR\n");
773 if (rIn[vcl::UnicodeCoverage::ETHIOPIC])
774 fprintf(stderr, "ETHIOPIC\n");
775 if (rIn[vcl::UnicodeCoverage::CHEROKEE])
776 fprintf(stderr, "CHEROKEE\n");
777 if (rIn[vcl::UnicodeCoverage::UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS])
778 fprintf(stderr, "UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS\n");
779 if (rIn[vcl::UnicodeCoverage::OGHAM])
780 fprintf(stderr, "OGHAM\n");
781 if (rIn[vcl::UnicodeCoverage::RUNIC])
782 fprintf(stderr, "RUNIC\n");
783 if (rIn[vcl::UnicodeCoverage::KHMER])
784 fprintf(stderr, "KHMER\n");
785 if (rIn[vcl::UnicodeCoverage::MONGOLIAN])
786 fprintf(stderr, "MONGOLIAN\n");
787 if (rIn[vcl::UnicodeCoverage::BRAILLE_PATTERNS])
788 fprintf(stderr, "BRAILLE_PATTERNS\n");
789 if (rIn[vcl::UnicodeCoverage::YI_SYLLABLES])
790 fprintf(stderr, "YI_SYLLABLES\n");
791 if (rIn[vcl::UnicodeCoverage::TAGALOG])
792 fprintf(stderr, "TAGALOG\n");
793 if (rIn[vcl::UnicodeCoverage::OLD_ITALIC])
794 fprintf(stderr, "OLD_ITALIC\n");
795 if (rIn[vcl::UnicodeCoverage::GOTHIC])
796 fprintf(stderr, "GOTHIC\n");
797 if (rIn[vcl::UnicodeCoverage::DESERET])
798 fprintf(stderr, "DESERET\n");
799 if (rIn[vcl::UnicodeCoverage::BYZANTINE_MUSICAL_SYMBOLS])
800 fprintf(stderr, "BYZANTINE_MUSICAL_SYMBOLS\n");
801 if (rIn[vcl::UnicodeCoverage::MATHEMATICAL_ALPHANUMERIC_SYMBOLS])
802 fprintf(stderr, "MATHEMATICAL_ALPHANUMERIC_SYMBOLS\n");
803 if (rIn[vcl::UnicodeCoverage::PRIVATE_USE_PLANE_15])
804 fprintf(stderr, "PRIVATE_USE_PLANE_15\n");
805 if (rIn[vcl::UnicodeCoverage::VARIATION_SELECTORS])
806 fprintf(stderr, "VARIATION_SELECTORS\n");
807 if (rIn[vcl::UnicodeCoverage::TAGS])
808 fprintf(stderr, "TAGS\n");
809 if (rIn[vcl::UnicodeCoverage::LIMBU])
810 fprintf(stderr, "LIMBU\n");
811 if (rIn[vcl::UnicodeCoverage::TAI_LE])
812 fprintf(stderr, "TAI_LE\n");
813 if (rIn[vcl::UnicodeCoverage::NEW_TAI_LUE])
814 fprintf(stderr, "NEW_TAI_LUE\n");
815 if (rIn[vcl::UnicodeCoverage::BUGINESE])
816 fprintf(stderr, "BUGINESE\n");
817 if (rIn[vcl::UnicodeCoverage::GLAGOLITIC])
818 fprintf(stderr, "GLAGOLITIC\n");
819 if (rIn[vcl::UnicodeCoverage::TIFINAGH])
820 fprintf(stderr, "TIFINAGH\n");
821 if (rIn[vcl::UnicodeCoverage::YIJING_HEXAGRAM_SYMBOLS])
822 fprintf(stderr, "YIJING_HEXAGRAM_SYMBOLS\n");
823 if (rIn[vcl::UnicodeCoverage::SYLOTI_NAGRI])
824 fprintf(stderr, "SYLOTI_NAGRI\n");
825 if (rIn[vcl::UnicodeCoverage::LINEAR_B_SYLLABARY])
826 fprintf(stderr, "LINEAR_B_SYLLABARY\n");
827 if (rIn[vcl::UnicodeCoverage::ANCIENT_GREEK_NUMBERS])
828 fprintf(stderr, "ANCIENT_GREEK_NUMBERS\n");
829 if (rIn[vcl::UnicodeCoverage::UGARITIC])
830 fprintf(stderr, "UGARITIC\n");
831 if (rIn[vcl::UnicodeCoverage::OLD_PERSIAN])
832 fprintf(stderr, "OLD_PERSIAN\n");
833 if (rIn[vcl::UnicodeCoverage::SHAVIAN])
834 fprintf(stderr, "SHAVIAN\n");
835 if (rIn[vcl::UnicodeCoverage::OSMANYA])
836 fprintf(stderr, "OSMANYA\n");
837 if (rIn[vcl::UnicodeCoverage::CYPRIOT_SYLLABARY])
838 fprintf(stderr, "CYPRIOT_SYLLABARY\n");
839 if (rIn[vcl::UnicodeCoverage::KHAROSHTHI])
840 fprintf(stderr, "KHAROSHTHI\n");
841 if (rIn[vcl::UnicodeCoverage::TAI_XUAN_JING_SYMBOLS])
842 fprintf(stderr, "TAI_XUAN_JING_SYMBOLS\n");
843 if (rIn[vcl::UnicodeCoverage::CUNEIFORM])
844 fprintf(stderr, "CUNEIFORM\n");
845 if (rIn[vcl::UnicodeCoverage::COUNTING_ROD_NUMERALS])
846 fprintf(stderr, "COUNTING_ROD_NUMERALS\n");
847 if (rIn[vcl::UnicodeCoverage::SUNDANESE])
848 fprintf(stderr, "SUNDANESE\n");
849 if (rIn[vcl::UnicodeCoverage::LEPCHA])
850 fprintf(stderr, "LEPCHA\n");
851 if (rIn[vcl::UnicodeCoverage::OL_CHIKI])
852 fprintf(stderr, "OL_CHIKI\n");
853 if (rIn[vcl::UnicodeCoverage::SAURASHTRA])
854 fprintf(stderr, "SAURASHTRA\n");
855 if (rIn[vcl::UnicodeCoverage::KAYAH_LI])
856 fprintf(stderr, "KAYAH_LI\n");
857 if (rIn[vcl::UnicodeCoverage::REJANG])
858 fprintf(stderr, "REJANG\n");
859 if (rIn[vcl::UnicodeCoverage::CHAM])
860 fprintf(stderr, "CHAM\n");
861 if (rIn[vcl::UnicodeCoverage::ANCIENT_SYMBOLS])
862 fprintf(stderr, "ANCIENT_SYMBOLS\n");
863 if (rIn[vcl::UnicodeCoverage::PHAISTOS_DISC])
864 fprintf(stderr, "PHAISTOS_DISC\n");
865 if (rIn[vcl::UnicodeCoverage::CARIAN])
866 fprintf(stderr, "CARIAN\n");
867 if (rIn[vcl::UnicodeCoverage::DOMINO_TILES])
868 fprintf(stderr, "DOMINO_TILES\n");
869 if (rIn[vcl::UnicodeCoverage::RESERVED1])
870 fprintf(stderr, "RESERVED1\n");
871 if (rIn[vcl::UnicodeCoverage::RESERVED2])
872 fprintf(stderr, "RESERVED2\n");
873 if (rIn[vcl::UnicodeCoverage::RESERVED3])
874 fprintf(stderr, "RESERVED3\n");
875 if (rIn[vcl::UnicodeCoverage::RESERVED4])
876 fprintf(stderr, "RESERVED4\n");
877 if (rIn[vcl::UnicodeCoverage::RESERVED5])
878 fprintf(stderr, "RESERVED5\n");
881 void lcl_dump_codepage_coverage(const boost::dynamic_bitset<sal_uInt32> &rIn)
883 if (rIn.none())
885 fprintf(stderr, "<NONE>\n");
886 return;
888 if (rIn[vcl::CodePageCoverage::CP1252])
889 fprintf(stderr, "CP1252\n");
890 if (rIn[vcl::CodePageCoverage::CP1250])
891 fprintf(stderr, "CP1250\n");
892 if (rIn[vcl::CodePageCoverage::CP1251])
893 fprintf(stderr, "CP1251\n");
894 if (rIn[vcl::CodePageCoverage::CP1253])
895 fprintf(stderr, "CP1253\n");
896 if (rIn[vcl::CodePageCoverage::CP1254])
897 fprintf(stderr, "CP1254\n");
898 if (rIn[vcl::CodePageCoverage::CP1255])
899 fprintf(stderr, "CP1255\n");
900 if (rIn[vcl::CodePageCoverage::CP1256])
901 fprintf(stderr, "CP1256\n");
902 if (rIn[vcl::CodePageCoverage::CP1257])
903 fprintf(stderr, "CP1257\n");
904 if (rIn[vcl::CodePageCoverage::CP1258])
905 fprintf(stderr, "CP1258\n");
906 if (rIn[vcl::CodePageCoverage::CP874])
907 fprintf(stderr, "CP874\n");
908 if (rIn[vcl::CodePageCoverage::CP932])
909 fprintf(stderr, "CP932\n");
910 if (rIn[vcl::CodePageCoverage::CP936])
911 fprintf(stderr, "CP936\n");
912 if (rIn[vcl::CodePageCoverage::CP949])
913 fprintf(stderr, "CP949\n");
914 if (rIn[vcl::CodePageCoverage::CP950])
915 fprintf(stderr, "CP950\n");
916 if (rIn[vcl::CodePageCoverage::CP1361])
917 fprintf(stderr, "CP1361\n");
918 if (rIn[vcl::CodePageCoverage::CP869])
919 fprintf(stderr, "CP869\n");
920 if (rIn[vcl::CodePageCoverage::CP866])
921 fprintf(stderr, "CP866\n");
922 if (rIn[vcl::CodePageCoverage::CP865])
923 fprintf(stderr, "CP865\n");
924 if (rIn[vcl::CodePageCoverage::CP864])
925 fprintf(stderr, "CP864\n");
926 if (rIn[vcl::CodePageCoverage::CP863])
927 fprintf(stderr, "CP863\n");
928 if (rIn[vcl::CodePageCoverage::CP862])
929 fprintf(stderr, "CP862\n");
930 if (rIn[vcl::CodePageCoverage::CP861])
931 fprintf(stderr, "CP861\n");
932 if (rIn[vcl::CodePageCoverage::CP860])
933 fprintf(stderr, "CP860\n");
934 if (rIn[vcl::CodePageCoverage::CP857])
935 fprintf(stderr, "CP857\n");
936 if (rIn[vcl::CodePageCoverage::CP855])
937 fprintf(stderr, "CP855\n");
938 if (rIn[vcl::CodePageCoverage::CP852])
939 fprintf(stderr, "CP852\n");
940 if (rIn[vcl::CodePageCoverage::CP775])
941 fprintf(stderr, "CP775\n");
942 if (rIn[vcl::CodePageCoverage::CP737])
943 fprintf(stderr, "CP737\n");
944 if (rIn[vcl::CodePageCoverage::CP780])
945 fprintf(stderr, "CP780\n");
946 if (rIn[vcl::CodePageCoverage::CP850])
947 fprintf(stderr, "CP850\n");
948 if (rIn[vcl::CodePageCoverage::CP437])
949 fprintf(stderr, "CP437\n");
951 #endif
953 boost::dynamic_bitset<sal_uInt32> getMaskByScriptType(sal_Int16 nScriptType)
955 boost::dynamic_bitset<sal_uInt32> aMask(vcl::UnicodeCoverage::MAX_UC_ENUM);
956 aMask.set();
958 for (size_t i = 0; i < vcl::UnicodeCoverage::MAX_UC_ENUM; ++i)
960 using vcl::UnicodeCoverage::UnicodeCoverageEnum;
961 UScriptCode eScriptCode = otCoverageToScript(static_cast<UnicodeCoverageEnum>(i));
962 if (unicode::getScriptClassFromUScriptCode(eScriptCode) == nScriptType)
963 aMask.set(i, false);
966 return aMask;
969 //false for all bits considered "Latin" by LibreOffice
970 boost::dynamic_bitset<sal_uInt32> getLatinMask()
972 static boost::dynamic_bitset<sal_uInt32> aMask(getMaskByScriptType(com::sun::star::i18n::ScriptType::LATIN));
973 return aMask;
976 //false for all bits considered "Asian" by LibreOffice
977 boost::dynamic_bitset<sal_uInt32> getCJKMask()
979 static boost::dynamic_bitset<sal_uInt32> aMask(getMaskByScriptType(com::sun::star::i18n::ScriptType::ASIAN));
980 return aMask;
983 //false for all bits considered "Complex" by LibreOffice
984 boost::dynamic_bitset<sal_uInt32> getCTLMask()
986 static boost::dynamic_bitset<sal_uInt32> aMask(getMaskByScriptType(com::sun::star::i18n::ScriptType::COMPLEX));
987 return aMask;
990 //false for all bits considered "WEAK" by LibreOffice
991 boost::dynamic_bitset<sal_uInt32> getWeakMask()
993 static boost::dynamic_bitset<sal_uInt32> aMask(getMaskByScriptType(com::sun::star::i18n::ScriptType::WEAK));
994 return aMask;
997 //Nearly every font supports some basic Latin
998 boost::dynamic_bitset<sal_uInt32> getCommonLatnSubsetMask()
1000 boost::dynamic_bitset<sal_uInt32> aMask(vcl::UnicodeCoverage::MAX_UC_ENUM);
1001 aMask.set();
1002 aMask.set(vcl::UnicodeCoverage::BASIC_LATIN, false);
1003 aMask.set(vcl::UnicodeCoverage::LATIN_1_SUPPLEMENT, false);
1004 aMask.set(vcl::UnicodeCoverage::LATIN_EXTENDED_A, false);
1005 aMask.set(vcl::UnicodeCoverage::LATIN_EXTENDED_B, false);
1006 aMask.set(vcl::UnicodeCoverage::LATIN_EXTENDED_ADDITIONAL, false);
1007 return aMask;
1010 UScriptCode getScript(const vcl::FontCapabilities &rFontCapabilities)
1012 using vcl::UnicodeCoverage::UnicodeCoverageEnum;
1014 boost::dynamic_bitset<sal_uInt32> aMasked = rFontCapabilities.maUnicodeRange & getWeakMask();
1016 if (aMasked.count() == 1)
1017 return otCoverageToScript(static_cast<UnicodeCoverageEnum>(aMasked.find_first()));
1019 if (aMasked[vcl::UnicodeCoverage::ARABIC])
1021 aMasked.set(vcl::UnicodeCoverage::ARABIC_PRESENTATION_FORMS_A, false);
1022 aMasked.set(vcl::UnicodeCoverage::ARABIC_PRESENTATION_FORMS_B, false);
1023 aMasked.set(vcl::UnicodeCoverage::NKO, false);
1024 //Probably strongly tuned for Arabic
1025 if (aMasked.count() == 1)
1026 return USCRIPT_ARABIC;
1027 if (aMasked.count() == 2 && aMasked[vcl::UnicodeCoverage::SYRIAC])
1028 return USCRIPT_SYRIAC;
1031 if (aMasked[vcl::UnicodeCoverage::DEVANAGARI])
1033 aMasked.set(vcl::UnicodeCoverage::DEVANAGARI, false);
1034 //Probably strongly tuned for a single Indic script
1035 if (aMasked.count() == 1)
1036 return otCoverageToScript(static_cast<UnicodeCoverageEnum>(aMasked.find_first()));
1039 aMasked.set(vcl::UnicodeCoverage::GREEK_EXTENDED, false);
1040 aMasked.set(vcl::UnicodeCoverage::GREEK_AND_COPTIC, false);
1041 if (aMasked.count() == 1)
1042 return otCoverageToScript(static_cast<UnicodeCoverageEnum>(aMasked.find_first()));
1044 if (aMasked[vcl::UnicodeCoverage::CYRILLIC])
1046 //Probably strongly tuned for Georgian
1047 if (aMasked.count() == 2 && aMasked[vcl::UnicodeCoverage::GEORGIAN])
1048 return USCRIPT_GEORGIAN;
1051 aMasked &= getCJKMask();
1053 aMasked.set(vcl::UnicodeCoverage::CYRILLIC, false);
1054 aMasked.set(vcl::UnicodeCoverage::THAI, false);
1055 aMasked.set(vcl::UnicodeCoverage::DESERET, false);
1056 aMasked.set(vcl::UnicodeCoverage::PHAGS_PA, false);
1058 //So, possibly a CJK font
1059 if (!aMasked.count() && !rFontCapabilities.maCodePageRange.empty())
1061 boost::dynamic_bitset<sal_uInt32> aCJKCodePageMask(vcl::CodePageCoverage::MAX_CP_ENUM);
1062 aCJKCodePageMask.set(vcl::CodePageCoverage::CP932);
1063 aCJKCodePageMask.set(vcl::CodePageCoverage::CP936);
1064 aCJKCodePageMask.set(vcl::CodePageCoverage::CP949);
1065 aCJKCodePageMask.set(vcl::CodePageCoverage::CP950);
1066 aCJKCodePageMask.set(vcl::CodePageCoverage::CP1361);
1067 boost::dynamic_bitset<sal_uInt32> aMaskedCodePage =
1068 rFontCapabilities.maCodePageRange & aCJKCodePageMask;
1069 //fold Korean
1070 if (aMaskedCodePage[vcl::CodePageCoverage::CP1361])
1072 aMaskedCodePage.set(vcl::CodePageCoverage::CP949);
1073 aMaskedCodePage.set(vcl::CodePageCoverage::CP1361, false);
1076 if (aMaskedCodePage.count() == 1)
1078 if (aMaskedCodePage[vcl::CodePageCoverage::CP932])
1079 return USCRIPT_JAPANESE;
1080 if (aMaskedCodePage[vcl::CodePageCoverage::CP949])
1081 return USCRIPT_KOREAN;
1082 if (aMaskedCodePage[vcl::CodePageCoverage::CP936])
1083 return USCRIPT_SIMPLIFIED_HAN;
1084 if (aMaskedCodePage[vcl::CodePageCoverage::CP950])
1085 return USCRIPT_TRADITIONAL_HAN;
1088 if (aMaskedCodePage.count())
1089 return USCRIPT_HAN;
1092 return USCRIPT_COMMON;
1096 namespace
1098 UScriptCode attemptToDisambiguateHan(UScriptCode eScript, OutputDevice &rDevice)
1100 //If we're a CJK font, see if we seem to be tuned for C, J or K
1101 if (eScript == USCRIPT_HAN)
1103 const Font &rFont = rDevice.GetFont();
1105 bool bKore = false, bJpan = false, bHant = false, bHans = false;
1107 const sal_Unicode aKorean[] = { 0x3131 };
1108 OUString sKorean(aKorean, SAL_N_ELEMENTS(aKorean));
1109 if (STRING_LEN == rDevice.HasGlyphs(rFont, sKorean))
1110 bKore = true;
1112 const sal_Unicode aJapanese[] = { 0x3007, 0x9F9D };
1113 OUString sJapanese(aJapanese, SAL_N_ELEMENTS(aJapanese));
1114 if (STRING_LEN == rDevice.HasGlyphs(rFont, sJapanese))
1115 bJpan = true;
1117 const sal_Unicode aTraditionalChinese[] = { 0x570B };
1118 OUString sTraditionalChinese(aTraditionalChinese, SAL_N_ELEMENTS(aTraditionalChinese));
1119 if (STRING_LEN == rDevice.HasGlyphs(rFont, sTraditionalChinese))
1120 bHant = true;
1122 const sal_Unicode aSimplifiedChinese[] = { 0x56FD };
1123 OUString sSimplifiedChinese(aSimplifiedChinese, SAL_N_ELEMENTS(aSimplifiedChinese));
1124 if (STRING_LEN == rDevice.HasGlyphs(rFont, sSimplifiedChinese))
1125 bHans = true;
1127 if (bKore && !bJpan && !bHans)
1128 eScript = USCRIPT_KOREAN;
1129 else if (bJpan && !bKore && !bHant)
1130 eScript = USCRIPT_JAPANESE;
1131 else if (bHant && !bHans && !bKore && !bJpan)
1132 eScript = USCRIPT_TRADITIONAL_HAN;
1133 else if (bHans && !bHant && !bKore && !bJpan)
1134 eScript = USCRIPT_SIMPLIFIED_HAN;
1135 //otherwise fall-through as USCRIPT_HAN and expect a combind Hant/Hans preview
1137 return eScript;
1141 OUString makeShortRepresentativeTextForSelectedFont(OutputDevice &rDevice)
1143 vcl::FontCapabilities aFontCapabilities;
1144 if (!rDevice.GetFontCapabilities(aFontCapabilities))
1145 return OUString();
1147 #if OSL_DEBUG_LEVEL > 2
1148 fprintf(stderr, "font is %s\n",
1149 OUStringToOString(rDevice.GetFont().GetName(), RTL_TEXTENCODING_UTF8).getStr());
1150 lcl_dump_unicode_coverage(aFontCapabilities.maUnicodeRange);
1151 lcl_dump_codepage_coverage(aFontCapabilities.maCodePageRange);
1152 #endif
1154 aFontCapabilities.maUnicodeRange &= getCommonLatnSubsetMask();
1156 //If this font is probably tuned to display a single non-Latin
1157 //script and the font name is itself in Latin, then show a small
1158 //chunk of representative text for that script
1159 UScriptCode eScript = getScript(aFontCapabilities);
1160 if (!eScript != USCRIPT_COMMON)
1161 return OUString();
1163 eScript = attemptToDisambiguateHan(eScript, rDevice);
1165 OUString sSampleText = makeShortRepresentativeTextForScript(eScript);
1166 bool bHasSampleTextGlyphs = (STRING_LEN == rDevice.HasGlyphs(rDevice.GetFont(), sSampleText));
1167 return bHasSampleTextGlyphs ? sSampleText : OUString();
1170 UScriptCode otCoverageToScript(vcl::UnicodeCoverage::UnicodeCoverageEnum eOTCoverage)
1172 UScriptCode eRet = USCRIPT_COMMON;
1173 switch (eOTCoverage)
1175 case vcl::UnicodeCoverage::BASIC_LATIN:
1176 case vcl::UnicodeCoverage::LATIN_1_SUPPLEMENT:
1177 case vcl::UnicodeCoverage::LATIN_EXTENDED_A:
1178 case vcl::UnicodeCoverage::LATIN_EXTENDED_B:
1179 eRet = USCRIPT_LATIN;
1180 break;
1181 case vcl::UnicodeCoverage::COMBINING_DIACRITICAL_MARKS:
1182 eRet = USCRIPT_INHERITED;
1183 break;
1184 case vcl::UnicodeCoverage::GREEK_AND_COPTIC:
1185 eRet = USCRIPT_GREEK;
1186 break;
1187 case vcl::UnicodeCoverage::COPTIC:
1188 eRet = USCRIPT_COPTIC;
1189 break;
1190 case vcl::UnicodeCoverage::CYRILLIC:
1191 eRet = USCRIPT_CYRILLIC;
1192 break;
1193 case vcl::UnicodeCoverage::ARMENIAN:
1194 eRet = USCRIPT_ARMENIAN;
1195 break;
1196 case vcl::UnicodeCoverage::HEBREW:
1197 eRet = USCRIPT_HEBREW;
1198 break;
1199 case vcl::UnicodeCoverage::VAI:
1200 eRet = USCRIPT_VAI;
1201 break;
1202 case vcl::UnicodeCoverage::ARABIC:
1203 eRet = USCRIPT_ARABIC;
1204 break;
1205 case vcl::UnicodeCoverage::NKO:
1206 eRet = USCRIPT_NKO;
1207 break;
1208 case vcl::UnicodeCoverage::DEVANAGARI:
1209 eRet = USCRIPT_DEVANAGARI;
1210 break;
1211 case vcl::UnicodeCoverage::BENGALI:
1212 eRet = USCRIPT_BENGALI;
1213 break;
1214 case vcl::UnicodeCoverage::GURMUKHI:
1215 eRet = USCRIPT_GURMUKHI;
1216 break;
1217 case vcl::UnicodeCoverage::GUJARATI:
1218 eRet = USCRIPT_GUJARATI;
1219 break;
1220 case vcl::UnicodeCoverage::ORIYA:
1221 eRet = USCRIPT_ORIYA;
1222 break;
1223 case vcl::UnicodeCoverage::TAMIL:
1224 eRet = USCRIPT_TAMIL;
1225 break;
1226 case vcl::UnicodeCoverage::TELUGU:
1227 eRet = USCRIPT_TELUGU;
1228 break;
1229 case vcl::UnicodeCoverage::KANNADA:
1230 eRet = USCRIPT_KANNADA;
1231 break;
1232 case vcl::UnicodeCoverage::MALAYALAM:
1233 eRet = USCRIPT_MALAYALAM;
1234 break;
1235 case vcl::UnicodeCoverage::THAI:
1236 eRet = USCRIPT_THAI;
1237 break;
1238 case vcl::UnicodeCoverage::LAO:
1239 eRet = USCRIPT_LAO;
1240 break;
1241 case vcl::UnicodeCoverage::GEORGIAN:
1242 eRet = USCRIPT_GEORGIAN;
1243 break;
1244 case vcl::UnicodeCoverage::BALINESE:
1245 eRet = USCRIPT_BALINESE;
1246 break;
1247 case vcl::UnicodeCoverage::HANGUL_JAMO:
1248 eRet = USCRIPT_HANGUL;
1249 break;
1250 case vcl::UnicodeCoverage::LATIN_EXTENDED_ADDITIONAL:
1251 eRet = USCRIPT_LATIN;
1252 break;
1253 case vcl::UnicodeCoverage::GREEK_EXTENDED:
1254 eRet = USCRIPT_GREEK;
1255 break;
1256 case vcl::UnicodeCoverage::CURRENCY_SYMBOLS:
1257 eRet = USCRIPT_SYMBOLS;
1258 break;
1259 case vcl::UnicodeCoverage::COMBINING_DIACRITICAL_MARKS_FOR_SYMBOLS:
1260 eRet = USCRIPT_INHERITED;
1261 break;
1262 case vcl::UnicodeCoverage::LETTERLIKE_SYMBOLS:
1263 case vcl::UnicodeCoverage::NUMBER_FORMS:
1264 case vcl::UnicodeCoverage::ARROWS:
1265 eRet = USCRIPT_SYMBOLS;
1266 break;
1267 case vcl::UnicodeCoverage::MATHEMATICAL_OPERATORS:
1268 eRet = USCRIPT_MATHEMATICAL_NOTATION;
1269 break;
1270 case vcl::UnicodeCoverage::MISCELLANEOUS_TECHNICAL:
1271 case vcl::UnicodeCoverage::OPTICAL_CHARACTER_RECOGNITION:
1272 case vcl::UnicodeCoverage::BOX_DRAWING:
1273 case vcl::UnicodeCoverage::BLOCK_ELEMENTS:
1274 case vcl::UnicodeCoverage::GEOMETRIC_SHAPES:
1275 case vcl::UnicodeCoverage::MISCELLANEOUS_SYMBOLS:
1276 case vcl::UnicodeCoverage::DINGBATS:
1277 case vcl::UnicodeCoverage::CJK_SYMBOLS_AND_PUNCTUATION:
1278 eRet = USCRIPT_SYMBOLS;
1279 break;
1280 case vcl::UnicodeCoverage::HIRAGANA:
1281 eRet = USCRIPT_HIRAGANA;
1282 break;
1283 case vcl::UnicodeCoverage::KATAKANA:
1284 eRet = USCRIPT_KATAKANA;
1285 break;
1286 case vcl::UnicodeCoverage::BOPOMOFO:
1287 eRet = USCRIPT_BOPOMOFO;
1288 break;
1289 case vcl::UnicodeCoverage::HANGUL_COMPATIBILITY_JAMO:
1290 eRet = USCRIPT_HANGUL;
1291 break;
1292 case vcl::UnicodeCoverage::PHAGS_PA:
1293 eRet = USCRIPT_PHAGS_PA;
1294 break;
1295 case vcl::UnicodeCoverage::ENCLOSED_CJK_LETTERS_AND_MONTHS:
1296 eRet = USCRIPT_HANGUL;
1297 break;
1298 case vcl::UnicodeCoverage::CJK_COMPATIBILITY:
1299 eRet = USCRIPT_HAN;
1300 break;
1301 case vcl::UnicodeCoverage::HANGUL_SYLLABLES:
1302 eRet = USCRIPT_HANGUL;
1303 break;
1304 case vcl::UnicodeCoverage::PHOENICIAN:
1305 eRet = USCRIPT_PHOENICIAN;
1306 break;
1307 case vcl::UnicodeCoverage::CJK_UNIFIED_IDEOGRAPHS:
1308 case vcl::UnicodeCoverage::CJK_STROKES:
1309 eRet = USCRIPT_HAN;
1310 break;
1311 case vcl::UnicodeCoverage::ARABIC_PRESENTATION_FORMS_A:
1312 eRet = USCRIPT_ARABIC;
1313 break;
1314 case vcl::UnicodeCoverage::COMBINING_HALF_MARKS:
1315 eRet = USCRIPT_INHERITED;
1316 break;
1317 case vcl::UnicodeCoverage::ARABIC_PRESENTATION_FORMS_B:
1318 eRet = USCRIPT_ARABIC;
1319 break;
1320 case vcl::UnicodeCoverage::TIBETAN:
1321 eRet = USCRIPT_TIBETAN;
1322 break;
1323 case vcl::UnicodeCoverage::SYRIAC:
1324 eRet = USCRIPT_SYRIAC;
1325 break;
1326 case vcl::UnicodeCoverage::THAANA:
1327 eRet = USCRIPT_THAANA;
1328 break;
1329 case vcl::UnicodeCoverage::SINHALA:
1330 eRet = USCRIPT_SINHALA;
1331 break;
1332 case vcl::UnicodeCoverage::MYANMAR:
1333 eRet = USCRIPT_MYANMAR;
1334 break;
1335 case vcl::UnicodeCoverage::ETHIOPIC:
1336 eRet = USCRIPT_ETHIOPIC;
1337 break;
1338 case vcl::UnicodeCoverage::CHEROKEE:
1339 eRet = USCRIPT_CHEROKEE;
1340 break;
1341 case vcl::UnicodeCoverage::UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS:
1342 eRet = USCRIPT_CANADIAN_ABORIGINAL;
1343 break;
1344 case vcl::UnicodeCoverage::OGHAM:
1345 eRet = USCRIPT_OGHAM;
1346 break;
1347 case vcl::UnicodeCoverage::RUNIC:
1348 eRet = USCRIPT_RUNIC;
1349 break;
1350 case vcl::UnicodeCoverage::KHMER:
1351 eRet = USCRIPT_KHMER;
1352 break;
1353 case vcl::UnicodeCoverage::MONGOLIAN:
1354 eRet = USCRIPT_MONGOLIAN;
1355 break;
1356 case vcl::UnicodeCoverage::BRAILLE_PATTERNS:
1357 eRet = USCRIPT_BRAILLE;
1358 break;
1359 case vcl::UnicodeCoverage::YI_SYLLABLES:
1360 eRet = USCRIPT_YI;
1361 break;
1362 case vcl::UnicodeCoverage::TAGALOG:
1363 eRet = USCRIPT_TAGALOG;
1364 break;
1365 case vcl::UnicodeCoverage::OLD_ITALIC:
1366 eRet = USCRIPT_OLD_ITALIC;
1367 break;
1368 case vcl::UnicodeCoverage::GOTHIC:
1369 eRet = USCRIPT_GOTHIC;
1370 break;
1371 case vcl::UnicodeCoverage::DESERET:
1372 eRet = USCRIPT_DESERET;
1373 break;
1374 case vcl::UnicodeCoverage::BYZANTINE_MUSICAL_SYMBOLS:
1375 case vcl::UnicodeCoverage::MATHEMATICAL_ALPHANUMERIC_SYMBOLS:
1376 case vcl::UnicodeCoverage::PRIVATE_USE_PLANE_15:
1377 eRet = USCRIPT_SYMBOLS;
1378 break;
1379 case vcl::UnicodeCoverage::VARIATION_SELECTORS:
1380 eRet = USCRIPT_INHERITED;
1381 break;
1382 case vcl::UnicodeCoverage::TAGS:
1383 eRet = USCRIPT_SYMBOLS;
1384 break;
1385 case vcl::UnicodeCoverage::LIMBU:
1386 eRet = USCRIPT_LIMBU;
1387 break;
1388 case vcl::UnicodeCoverage::TAI_LE:
1389 eRet = USCRIPT_TAI_LE;
1390 break;
1391 case vcl::UnicodeCoverage::NEW_TAI_LUE:
1392 eRet = USCRIPT_NEW_TAI_LUE;
1393 break;
1394 case vcl::UnicodeCoverage::BUGINESE:
1395 eRet = USCRIPT_BUGINESE;
1396 break;
1397 case vcl::UnicodeCoverage::GLAGOLITIC:
1398 eRet = USCRIPT_GLAGOLITIC;
1399 break;
1400 case vcl::UnicodeCoverage::TIFINAGH:
1401 eRet = USCRIPT_TIFINAGH;
1402 break;
1403 case vcl::UnicodeCoverage::YIJING_HEXAGRAM_SYMBOLS:
1404 eRet = USCRIPT_SYMBOLS;
1405 break;
1406 case vcl::UnicodeCoverage::SYLOTI_NAGRI:
1407 eRet = USCRIPT_SYLOTI_NAGRI;
1408 break;
1409 case vcl::UnicodeCoverage::LINEAR_B_SYLLABARY:
1410 eRet = USCRIPT_LINEAR_B;
1411 break;
1412 case vcl::UnicodeCoverage::ANCIENT_GREEK_NUMBERS:
1413 eRet = USCRIPT_GREEK;
1414 break;
1415 case vcl::UnicodeCoverage::UGARITIC:
1416 eRet = USCRIPT_UGARITIC;
1417 break;
1418 case vcl::UnicodeCoverage::OLD_PERSIAN:
1419 eRet = USCRIPT_OLD_PERSIAN;
1420 break;
1421 case vcl::UnicodeCoverage::SHAVIAN:
1422 eRet = USCRIPT_SHAVIAN;
1423 break;
1424 case vcl::UnicodeCoverage::OSMANYA:
1425 eRet = USCRIPT_OSMANYA;
1426 break;
1427 case vcl::UnicodeCoverage::CYPRIOT_SYLLABARY:
1428 eRet = USCRIPT_CYPRIOT;
1429 break;
1430 case vcl::UnicodeCoverage::KHAROSHTHI:
1431 eRet = USCRIPT_KHAROSHTHI;
1432 break;
1433 case vcl::UnicodeCoverage::CUNEIFORM:
1434 eRet = USCRIPT_CUNEIFORM;
1435 break;
1436 case vcl::UnicodeCoverage::SUNDANESE:
1437 eRet = USCRIPT_SUNDANESE;
1438 break;
1439 case vcl::UnicodeCoverage::LEPCHA:
1440 eRet = USCRIPT_LEPCHA;
1441 break;
1442 case vcl::UnicodeCoverage::OL_CHIKI:
1443 eRet = USCRIPT_OL_CHIKI;
1444 break;
1445 case vcl::UnicodeCoverage::SAURASHTRA:
1446 eRet = USCRIPT_SAURASHTRA;
1447 break;
1448 case vcl::UnicodeCoverage::KAYAH_LI:
1449 eRet = USCRIPT_KAYAH_LI;
1450 break;
1451 case vcl::UnicodeCoverage::REJANG:
1452 eRet = USCRIPT_REJANG;
1453 break;
1454 case vcl::UnicodeCoverage::CHAM:
1455 eRet = USCRIPT_CHAM;
1456 break;
1457 case vcl::UnicodeCoverage::CARIAN:
1458 eRet = USCRIPT_CARIAN;
1459 break;
1460 case vcl::UnicodeCoverage::DOMINO_TILES:
1461 case vcl::UnicodeCoverage::TAI_XUAN_JING_SYMBOLS:
1462 case vcl::UnicodeCoverage::COUNTING_ROD_NUMERALS:
1463 case vcl::UnicodeCoverage::ANCIENT_SYMBOLS:
1464 case vcl::UnicodeCoverage::PHAISTOS_DISC:
1465 eRet = USCRIPT_SYMBOLS;
1466 break;
1467 case vcl::UnicodeCoverage::IPA_EXTENSIONS:
1468 case vcl::UnicodeCoverage::SPECIALS:
1469 case vcl::UnicodeCoverage::HALFWIDTH_AND_FULLWIDTH_FORMS:
1470 case vcl::UnicodeCoverage::VERTICAL_FORMS:
1471 case vcl::UnicodeCoverage::SMALL_FORM_VARIANTS:
1472 case vcl::UnicodeCoverage::ALPHABETIC_PRESENTATION_FORMS:
1473 case vcl::UnicodeCoverage::PRIVATE_USE_AREA_PLANE_0:
1474 case vcl::UnicodeCoverage::NONPLANE_0:
1475 case vcl::UnicodeCoverage::ENCLOSED_ALPHANUMERICS:
1476 case vcl::UnicodeCoverage::CONTROL_PICTURES:
1477 case vcl::UnicodeCoverage::SUPERSCRIPTS_AND_SUBSCRIPTS:
1478 case vcl::UnicodeCoverage::GENERAL_PUNCTUATION:
1479 case vcl::UnicodeCoverage::SPACING_MODIFIER_LETTERS:
1480 case vcl::UnicodeCoverage::RESERVED1:
1481 case vcl::UnicodeCoverage::RESERVED2:
1482 case vcl::UnicodeCoverage::RESERVED3:
1483 case vcl::UnicodeCoverage::RESERVED4:
1484 case vcl::UnicodeCoverage::RESERVED5:
1485 case vcl::UnicodeCoverage::MAX_UC_ENUM:
1486 break;
1488 return eRet;
1491 OUString makeRepresentativeTextForFont(sal_Int16 nScriptType, const Font &rFont)
1493 OUString sRet(makeRepresentativeTextForLanguage(rFont.GetLanguage()));
1495 VirtualDevice aDevice;
1496 if (sRet.isEmpty() || (STRING_LEN != aDevice.HasGlyphs(rFont, sRet)))
1498 aDevice.SetFont(rFont);
1499 vcl::FontCapabilities aFontCapabilities;
1500 if (aDevice.GetFontCapabilities(aFontCapabilities))
1502 #if OSL_DEBUG_LEVEL > 2
1503 lcl_dump_unicode_coverage(aFontCapabilities.maUnicodeRange);
1504 #endif
1506 aFontCapabilities.maUnicodeRange &= getWeakMask();
1508 if (nScriptType != com::sun::star::i18n::ScriptType::ASIAN)
1510 aFontCapabilities.maUnicodeRange &= getCJKMask();
1511 aFontCapabilities.maCodePageRange.clear();
1513 if (nScriptType != com::sun::star::i18n::ScriptType::LATIN)
1514 aFontCapabilities.maUnicodeRange &= getLatinMask();
1515 if (nScriptType != com::sun::star::i18n::ScriptType::COMPLEX)
1516 aFontCapabilities.maUnicodeRange &= getCTLMask();
1518 #if OSL_DEBUG_LEVEL > 2
1519 fprintf(stderr, "minimal\n");
1520 lcl_dump_unicode_coverage(aFontCapabilities.maUnicodeRange);
1521 lcl_dump_codepage_coverage(aFontCapabilities.maCodePageRange);
1522 #endif
1524 UScriptCode eScript = getScript(aFontCapabilities);
1526 if (nScriptType == com::sun::star::i18n::ScriptType::ASIAN)
1527 eScript = attemptToDisambiguateHan(eScript, aDevice);
1529 sRet = makeRepresentativeTextForScript(eScript);
1532 if (sRet.isEmpty())
1534 if (nScriptType == com::sun::star::i18n::ScriptType::COMPLEX)
1536 sRet = makeRepresentativeTextForScript(USCRIPT_HEBREW);
1537 if (STRING_LEN != aDevice.HasGlyphs(rFont, sRet))
1539 sRet = makeMinimalTextForScript(USCRIPT_HEBREW);
1540 if (STRING_LEN != aDevice.HasGlyphs(rFont, sRet))
1541 sRet = makeRepresentativeTextForScript(USCRIPT_ARABIC);
1544 else if (nScriptType == com::sun::star::i18n::ScriptType::LATIN)
1545 sRet = makeRepresentativeTextForScript(USCRIPT_LATIN);
1549 return sRet;
1552 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */