LCOV - code coverage report
Current view: top level - svtools/source/misc - sampletext.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 597 0.0 %
Date: 2014-04-14 Functions: 0 20 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10