LCOV - code coverage report
Current view: top level - libreoffice/svtools/source/misc - sampletext.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 552 0.0 %
Date: 2012-12-27 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             :  * Version: MPL 1.1 / GPLv3+ / LGPLv3+
       4             :  *
       5             :  * The contents of this file are subject to the Mozilla Public License Version
       6             :  * 1.1 (the "License"); you may not use this file except in compliance with
       7             :  * the License. You may obtain a copy of the License at
       8             :  * http://www.mozilla.org/MPL/
       9             :  *
      10             :  * Software distributed under the License is distributed on an "AS IS" basis,
      11             :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12             :  * for the specific language governing rights and limitations under the
      13             :  * License.
      14             :  *
      15             :  * The Initial Developer of the Original Code is
      16             :  *       [ Caolan McNamara <caolanm@redhat.com> ]
      17             :  * Portions created by the Initial Developer are Copyright (C) 2010 the
      18             :  * Initial Developer. All Rights Reserved.
      19             :  *
      20             :  * Contributor(s): Caolan McNamara <caolanm@redhat.com>
      21             :  *
      22             :  * Alternatively, the contents of this file may be used under the terms of
      23             :  * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
      24             :  * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
      25             :  * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
      26             :  * instead of those above.
      27             :  */
      28             : #include <svtools/sampletext.hxx>
      29             : #include <vcl/font.hxx>
      30             : #include <vcl/outdev.hxx>
      31             : #include <vcl/virdev.hxx>
      32             : #include <vcl/metric.hxx>
      33             : #include <i18nutil/unicode.hxx>
      34             : 
      35           0 : bool isOpenSymbolFont(const Font &rFont)
      36             : {
      37           0 :     return rFont.GetName().EqualsIgnoreCaseAscii("starsymbol") ||
      38           0 :            rFont.GetName().EqualsIgnoreCaseAscii("opensymbol");
      39             : }
      40             : 
      41           0 : bool isSymbolFont(const Font &rFont)
      42             : {
      43           0 :     return (rFont.GetCharSet() == RTL_TEXTENCODING_SYMBOL) ||
      44           0 :             rFont.GetName().EqualsIgnoreCaseAscii("cmsy10") ||
      45           0 :             rFont.GetName().EqualsIgnoreCaseAscii("cmex10") ||
      46           0 :             rFont.GetName().EqualsIgnoreCaseAscii("feta26") ||
      47           0 :             rFont.GetName().EqualsIgnoreCaseAscii("jsMath-cmsy10") ||
      48           0 :             rFont.GetName().EqualsIgnoreCaseAscii("jsMath-cmex10") ||
      49           0 :             rFont.GetName().EqualsIgnoreCaseAscii("msam10") ||
      50           0 :             rFont.GetName().EqualsIgnoreCaseAscii("msbm10") ||
      51           0 :             rFont.GetName().EqualsIgnoreCaseAscii("wasy10") ||
      52           0 :             rFont.GetName().EqualsIgnoreCaseAscii("Denemo") ||
      53           0 :             rFont.GetName().EqualsIgnoreCaseAscii("GlyphBasic1") ||
      54           0 :             rFont.GetName().EqualsIgnoreCaseAscii("GlyphBasic2") ||
      55           0 :             rFont.GetName().EqualsIgnoreCaseAscii("GlyphBasic3") ||
      56           0 :             rFont.GetName().EqualsIgnoreCaseAscii("GlyphBasic4") ||
      57           0 :             rFont.GetName().EqualsIgnoreCaseAscii("Letters Laughing") ||
      58           0 :             rFont.GetName().EqualsIgnoreCaseAscii("MusiQwik") ||
      59           0 :             rFont.GetName().EqualsIgnoreCaseAscii("MusiSync") ||
      60           0 :             isOpenSymbolFont(rFont);
      61             : }
      62             : 
      63           0 : bool canRenderNameOfSelectedFont(OutputDevice &rDevice)
      64             : {
      65           0 :     const Font &rFont = rDevice.GetFont();
      66           0 :     return !isSymbolFont(rFont) && (STRING_LEN == rDevice.HasGlyphs(rFont, rFont.GetName()));
      67             : }
      68             : 
      69           0 : rtl::OUString makeShortRepresentativeSymbolTextForSelectedFont(OutputDevice &rDevice)
      70             : {
      71           0 :     const bool bOpenSymbol = isOpenSymbolFont(rDevice.GetFont());
      72             : 
      73           0 :     if (!bOpenSymbol)
      74             :     {
      75           0 :         FontCharMap aFontCharMap;
      76           0 :         bool bHasCharMap = rDevice.GetFontCharMap(aFontCharMap);
      77           0 :         if( bHasCharMap )
      78             :         {
      79             :             // use some sample characters available in the font
      80             :             sal_Unicode aText[8];
      81             : 
      82             :             // start just above the PUA used by most symbol fonts
      83           0 :             sal_uInt32 cNewChar = 0xFF00;
      84             : #ifdef QUARTZ
      85             :             // on MacOSX there are too many non-presentable symbols above the codepoint 0x0192
      86             :             if( !bOpenSymbol )
      87             :                 cNewChar = 0x0192;
      88             : #endif
      89             : 
      90           0 :             const int nMaxCount = sizeof(aText)/sizeof(*aText) - 1;
      91           0 :             int nSkip = aFontCharMap.GetCharCount() / nMaxCount;
      92           0 :             if( nSkip > 10 )
      93           0 :                 nSkip = 10;
      94           0 :             else if( nSkip <= 0 )
      95           0 :                 nSkip = 1;
      96           0 :             for( int i = 0; i < nMaxCount; ++i )
      97             :             {
      98           0 :                 sal_uInt32 cOldChar = cNewChar;
      99           0 :                 for( int j = nSkip; --j >= 0; )
     100           0 :                     cNewChar = aFontCharMap.GetPrevChar( cNewChar );
     101           0 :                 if( cOldChar == cNewChar )
     102           0 :                     break;
     103           0 :                 aText[ i ] = static_cast<sal_Unicode>(cNewChar); // TODO: support UCS4 samples
     104           0 :                 aText[ i+1 ] = 0;
     105             :             }
     106             : 
     107           0 :             return rtl::OUString(aText);
     108           0 :         }
     109             :     }
     110             : 
     111             :     static sal_Unicode aImplSymbolFontText[] = {
     112             :         0xF021,0xF032,0xF043,0xF054,0xF065,0xF076,0xF0B7,0xF0C8,0};
     113             :     static sal_Unicode aImplStarSymbolText[] = {
     114             :         0x2706,0x2704,0x270D,0xE033,0x2211,0x2288,0};
     115           0 :     const sal_Unicode* pText = bOpenSymbol ? aImplStarSymbolText : aImplSymbolFontText;
     116           0 :     rtl::OUString sSampleText(pText);
     117           0 :     bool bHasSampleTextGlyphs = (STRING_LEN == rDevice.HasGlyphs(rDevice.GetFont(), sSampleText));
     118           0 :     return bHasSampleTextGlyphs ? sSampleText : rtl::OUString();
     119             : }
     120             : 
     121             : //These ones are typically for use in the font dropdown box beside the
     122             : //fontname, so say things roughly like "Script/Alphabet/Name-Of-Major-Language"
     123             : //
     124             : //Here we don't always know the language of course, only the script that can be
     125             : //written with the font. Often that's one single language written in that
     126             : //script, or a handful of related languages where the name of the script is the
     127             : //same between languages, or the name in the major language is known by most
     128             : //readers of the minor languages, e.g. Yiddish is written with the HEBREW
     129             : //script as well, the vast majority of Yiddish readers will be able to read
     130             : //Hebrew as well.
     131           0 : rtl::OUString makeShortRepresentativeTextForScript(UScriptCode eScript)
     132             : {
     133           0 :     rtl::OUString sSampleText;
     134           0 :     switch (eScript)
     135             :     {
     136             :         case USCRIPT_GREEK:
     137             :         {
     138             :             const sal_Unicode aGrek[] = {
     139             :                 0x0391, 0x03BB, 0x03C6, 0x03AC, 0x03B2, 0x03B7, 0x03C4, 0x03BF
     140           0 :             };
     141           0 :             sSampleText = rtl::OUString(aGrek, SAL_N_ELEMENTS(aGrek));
     142             :             break;
     143             :         }
     144             :         case USCRIPT_HEBREW:
     145             :         {
     146             :             const sal_Unicode aHebr[] = {
     147             :                 0x05D0, 0x05B8, 0x05DC, 0x05B6, 0x05E3, 0x05BE, 0x05D1, 0x05B5,
     148             :                 0x05BC, 0x05D9, 0x05EA, 0x0020, 0x05E2, 0x05B4, 0x05D1, 0x05B0,
     149             :                 0x05E8, 0x05B4, 0x05D9
     150           0 :             };
     151           0 :             sSampleText = rtl::OUString(aHebr, SAL_N_ELEMENTS(aHebr));
     152             :             break;
     153             :         }
     154             :         case USCRIPT_ARABIC:
     155             :         {
     156             :             const sal_Unicode aArab[] = {
     157             :                 0x0623, 0x0628, 0x062C, 0x062F, 0x064A, 0x0629, 0x0020, 0x0639,
     158             :                 0x0631, 0x0628, 0x064A, 0x0629
     159           0 :             };
     160           0 :             sSampleText = rtl::OUString(aArab, SAL_N_ELEMENTS(aArab));
     161             :             break;
     162             :         }
     163             :         case USCRIPT_DEVANAGARI:
     164             :         {
     165             :             const sal_Unicode aDeva[] = {
     166             :                 0x0926, 0x0947, 0x0935, 0x0928, 0x093E, 0x0917, 0x0930, 0x0940
     167           0 :             };
     168           0 :             sSampleText = rtl::OUString(aDeva, SAL_N_ELEMENTS(aDeva));
     169             :             break;
     170             :         }
     171             :         case USCRIPT_BENGALI:
     172             :         {
     173             :             const sal_Unicode aBeng[] = {
     174             :                 0x09AC, 0x09BE, 0x0982, 0x09B2, 0x09BE, 0x0020, 0x09B2, 0x09BF,
     175             :                 0x09AA, 0x09BF
     176           0 :             };
     177           0 :             sSampleText = rtl::OUString(aBeng, SAL_N_ELEMENTS(aBeng));
     178             :             break;
     179             :         }
     180             :         case USCRIPT_GURMUKHI:
     181             :         {
     182             :             const sal_Unicode aGuru[] = {
     183             :                 0x0A17, 0x0A41, 0x0A30, 0x0A2E, 0x0A41, 0x0A16, 0x0A40
     184           0 :             };
     185           0 :             sSampleText = rtl::OUString(aGuru, SAL_N_ELEMENTS(aGuru));
     186             :             break;
     187             :         }
     188             :         case USCRIPT_GUJARATI:
     189             :         {
     190             :             const sal_Unicode aGujr[] = {
     191             :                 0x0A97, 0x0AC1, 0x0A9C, 0x0AB0, 0x0ABE, 0x0AA4, 0x0aC0, 0x0020,
     192             :                 0x0AB2, 0x0ABF, 0x0AAA, 0x0ABF
     193           0 :             };
     194           0 :             sSampleText = rtl::OUString(aGujr, SAL_N_ELEMENTS(aGujr));
     195             :             break;
     196             :         }
     197             :         case USCRIPT_ORIYA:
     198             :         {
     199             :             const sal_Unicode aOrya[] = {
     200             :                 0x0B09, 0x0B24, 0x0B4D, 0x0B15, 0x0B33, 0x0020, 0x0B32, 0x0B3F,
     201             :                 0x0B2A, 0x0B3F
     202           0 :             };
     203           0 :             sSampleText = rtl::OUString(aOrya, SAL_N_ELEMENTS(aOrya));
     204             :             break;
     205             :         }
     206             :         case USCRIPT_TAMIL:
     207             :         {
     208             :             const sal_Unicode aTaml[] = {
     209             :                 0x0B85, 0x0BB0, 0x0BBF, 0x0B9A, 0x0BCD, 0x0B9A, 0x0BC1, 0x0BB5,
     210             :                 0x0B9F, 0x0BBF
     211           0 :             };
     212           0 :             sSampleText = rtl::OUString(aTaml, SAL_N_ELEMENTS(aTaml));
     213             :             break;
     214             :         }
     215             :         case USCRIPT_TELUGU:
     216             :         {
     217             :             const sal_Unicode aTelu[] = {
     218             :                 0x0C24, 0x0C46, 0x0C32, 0x0C41, 0x0C17, 0x0C41
     219           0 :             };
     220           0 :             sSampleText = rtl::OUString(aTelu, SAL_N_ELEMENTS(aTelu));
     221             :             break;
     222             :         }
     223             :         case USCRIPT_KANNADA:
     224             :         {
     225             :             const sal_Unicode aKnda[] = {
     226             :                 0x0C95, 0x0CA8, 0x0CCD, 0x0CA8, 0x0CA1, 0x0020, 0x0CB2, 0x0CBF,
     227             :                 0x0CAA, 0x0CBF
     228           0 :             };
     229           0 :             sSampleText = rtl::OUString(aKnda, SAL_N_ELEMENTS(aKnda));
     230             :             break;
     231             :         }
     232             :         case USCRIPT_MALAYALAM:
     233             :         {
     234             :             const sal_Unicode aMlym[] = {
     235             :                 0x0D2E, 0x0D32, 0x0D2F, 0x0D3E, 0x0D33, 0x0D32, 0x0D3F, 0x0D2A,
     236             :                 0x0D3F
     237           0 :             };
     238           0 :             sSampleText = rtl::OUString(aMlym, SAL_N_ELEMENTS(aMlym));
     239             :             break;
     240             :         }
     241             :         case USCRIPT_THAI:
     242             :         {
     243             :             const sal_Unicode aThai[] = {
     244             :                 0x0E2D, 0x0E31, 0x0E01, 0x0E29, 0x0E23, 0x0E44, 0x0E17, 0x0E22
     245           0 :             };
     246           0 :             sSampleText = rtl::OUString(aThai, SAL_N_ELEMENTS(aThai));
     247             :             break;
     248             :         }
     249             :         case USCRIPT_LAO:
     250             :         {
     251             :             const sal_Unicode aLao[] = {
     252             :                 0x0EAD, 0x0EB1, 0x0E81, 0x0EAA, 0x0EAD, 0x0E99, 0x0EA5, 0x0EB2,
     253             :                 0x0EA7
     254           0 :             };
     255           0 :             sSampleText = rtl::OUString(aLao, SAL_N_ELEMENTS(aLao));
     256             :             break;
     257             :         }
     258             :         case USCRIPT_GEORGIAN:
     259             :         {
     260             :             const sal_Unicode aGeorgian[] = {
     261             :                 0x10D3, 0x10D0, 0x10DB, 0x10EC, 0x10D4, 0x10E0, 0x10DA, 0x10DD,
     262             :                 0x10D1, 0x10D0
     263           0 :             };
     264           0 :             sSampleText = rtl::OUString(aGeorgian, SAL_N_ELEMENTS(aGeorgian));
     265             :             break;
     266             :         }
     267             :         case USCRIPT_HANGUL:
     268             :         case USCRIPT_KOREAN:
     269             :         {
     270             :             const sal_Unicode aHang[] = {
     271             :                 0xD55C, 0xAE00
     272           0 :             };
     273           0 :             sSampleText = rtl::OUString(aHang, SAL_N_ELEMENTS(aHang));
     274             :             break;
     275             :         }
     276             :         case USCRIPT_TIBETAN:
     277             :         {
     278             :             const sal_Unicode aTibt[] = {
     279             :                 0x0F51, 0x0F56, 0x0F74, 0x0F0B, 0x0F45, 0x0F53, 0x0F0B
     280           0 :             };
     281           0 :             sSampleText = rtl::OUString(aTibt, SAL_N_ELEMENTS(aTibt));
     282             :             break;
     283             :         }
     284             :         case USCRIPT_SYRIAC:
     285             :         {
     286             :             const sal_Unicode aSyri[] = {
     287             :                 0x0723, 0x071B, 0x072A, 0x0722, 0x0713, 0x0720, 0x0710
     288           0 :             };
     289           0 :             sSampleText = rtl::OUString(aSyri, SAL_N_ELEMENTS(aSyri));
     290             :             break;
     291             :         }
     292             :         case USCRIPT_THAANA:
     293             :         {
     294             :             const sal_Unicode aThaa[] = {
     295             :                 0x078C, 0x07A7, 0x0782, 0x07A6
     296           0 :             };
     297           0 :             sSampleText = rtl::OUString(aThaa, SAL_N_ELEMENTS(aThaa));
     298             :             break;
     299             :         }
     300             :         case USCRIPT_SINHALA:
     301             :         {
     302             :             const sal_Unicode aSinh[] = {
     303             :                 0x0DC1, 0x0DD4, 0x0DAF, 0x0DCA, 0x0DB0, 0x0020, 0x0DC3, 0x0DD2,
     304             :                 0x0D82, 0x0DC4, 0x0DBD
     305           0 :             };
     306           0 :             sSampleText = rtl::OUString(aSinh, SAL_N_ELEMENTS(aSinh));
     307             :             break;
     308             :         }
     309             :         case USCRIPT_MYANMAR:
     310             :         {
     311             :             const sal_Unicode aMymr[] = {
     312             :                 0x1019, 0x103C, 0x1014, 0x103A, 0x1019, 0x102C, 0x1021, 0x1000,
     313             :                 0x1039, 0x1001, 0x101B, 0x102C
     314           0 :             };
     315           0 :             sSampleText = rtl::OUString(aMymr, SAL_N_ELEMENTS(aMymr));
     316             :             break;
     317             :         }
     318             :         case USCRIPT_ETHIOPIC:
     319             :         {
     320             :             const sal_Unicode aEthi[] = {
     321             :                 0x130D, 0x12D5, 0x12DD
     322           0 :             };
     323           0 :             sSampleText = rtl::OUString(aEthi, SAL_N_ELEMENTS(aEthi));
     324             :             break;
     325             :         }
     326             :         case USCRIPT_CHEROKEE:
     327             :         {
     328             :             const sal_Unicode aCher[] = {
     329             :                 0x13D7, 0x13AA, 0x13EA, 0x13B6, 0x13D9, 0x13D7
     330           0 :             };
     331           0 :             sSampleText = rtl::OUString(aCher, SAL_N_ELEMENTS(aCher));
     332             :             break;
     333             :         }
     334             :         case USCRIPT_KHMER:
     335             :         {
     336             :             const sal_Unicode aKhmr[] = {
     337             :                 0x17A2, 0x1780, 0x17D2, 0x1781, 0x179A, 0x1780, 0x17D2, 0x179A,
     338             :                 0x1798, 0x1781, 0x17C1, 0x1798, 0x179A, 0x1797, 0x17B6, 0x179F,
     339             :                 0x17B6
     340           0 :             };
     341           0 :             sSampleText = rtl::OUString(aKhmr, SAL_N_ELEMENTS(aKhmr));
     342             :             break;
     343             :         }
     344             :         case USCRIPT_MONGOLIAN:
     345             :         {
     346             :             const sal_Unicode aMongolian[] = {
     347             :                 0x182A, 0x1822, 0x1834, 0x1822, 0x182D, 0x180C
     348           0 :             };
     349           0 :             sSampleText = rtl::OUString(aMongolian, SAL_N_ELEMENTS(aMongolian));
     350             :             break;
     351             :         }
     352             :         case USCRIPT_TAGALOG:
     353             :         {
     354             :             const sal_Unicode aTagalog[] = {
     355             :                 0x170A, 0x170A, 0x170C, 0x1712
     356           0 :             };
     357           0 :             sSampleText = rtl::OUString(aTagalog, SAL_N_ELEMENTS(aTagalog));
     358             :             break;
     359             :         }
     360             :         case USCRIPT_NEW_TAI_LUE:
     361             :         {
     362             :             const sal_Unicode aTalu[] = {
     363             :                 0x1991, 0x19BA, 0x199F, 0x19B9, 0x19C9
     364           0 :             };
     365           0 :             sSampleText = rtl::OUString(aTalu, SAL_N_ELEMENTS(aTalu));
     366             :             break;
     367             :         }
     368             :         case USCRIPT_TRADITIONAL_HAN:
     369             :         {
     370             :             const sal_Unicode aHant[] = {
     371             :                 0x7E41
     372           0 :             };
     373           0 :             sSampleText = rtl::OUString(aHant, SAL_N_ELEMENTS(aHant));
     374             :             break;
     375             :         }
     376             :         case USCRIPT_SIMPLIFIED_HAN:
     377             :         {
     378             :             const sal_Unicode aHans[] = {
     379             :                 0x7B80
     380           0 :             };
     381           0 :             sSampleText = rtl::OUString(aHans, SAL_N_ELEMENTS(aHans));
     382             :             break;
     383             :         }
     384             :         case USCRIPT_HAN:
     385             :         {
     386             :             const sal_Unicode aSimplifiedAndTraditionalChinese[] = {
     387             :                 0x7B80, 0x7E41
     388           0 :             };
     389             :             sSampleText = rtl::OUString(aSimplifiedAndTraditionalChinese,
     390           0 :                 SAL_N_ELEMENTS(aSimplifiedAndTraditionalChinese));
     391             :             break;
     392             :         }
     393             :         case USCRIPT_JAPANESE:
     394             :         {
     395             :             const sal_Unicode aJpan[] = {
     396             :                 0x65E5, 0x672C, 0x8A9E
     397           0 :             };
     398           0 :             sSampleText = rtl::OUString(aJpan, SAL_N_ELEMENTS(aJpan));
     399             :             break;
     400             :         }
     401             :         case USCRIPT_YI:
     402             :         {
     403             :             const sal_Unicode aYiii[] = {
     404             :                 0xA188,  0xA320, 0xA071, 0xA0B7
     405           0 :             };
     406           0 :             sSampleText = rtl::OUString(aYiii, SAL_N_ELEMENTS(aYiii));
     407             :             break;
     408             :         }
     409             :         case USCRIPT_PHAGS_PA:
     410             :         {
     411             :             const sal_Unicode aPhag[] = {
     412             :                 0xA84F, 0xA861, 0xA843, 0x0020, 0xA863, 0xA861, 0xA859, 0x0020,
     413             :                 0xA850, 0xA85C, 0xA85E
     414           0 :             };
     415           0 :             sSampleText = rtl::OUString(aPhag, SAL_N_ELEMENTS(aPhag));
     416             :             break;
     417             :         }
     418             :         case USCRIPT_TAI_LE:
     419             :         {
     420             :             const sal_Unicode aTale[] = {
     421             :                 0x1956, 0x196D, 0x1970, 0x1956, 0x196C, 0x1973, 0x1951, 0x1968,
     422             :                 0x1952, 0x1970
     423           0 :             };
     424           0 :             sSampleText = rtl::OUString(aTale, SAL_N_ELEMENTS(aTale));
     425             :             break;
     426             :         }
     427             :         case USCRIPT_LATIN:
     428           0 :             sSampleText = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Lorem ipsum"));
     429           0 :             break;
     430             :         default:
     431           0 :             break;
     432             :     }
     433           0 :     return sSampleText;
     434             : }
     435             : 
     436           0 : rtl::OUString makeRepresentativeTextForScript(UScriptCode eScript)
     437             : {
     438           0 :     rtl::OUString sSampleText;
     439           0 :     switch (eScript)
     440             :     {
     441             :         case USCRIPT_TRADITIONAL_HAN:
     442             :         case USCRIPT_SIMPLIFIED_HAN:
     443             :         case USCRIPT_HAN:
     444             :         {
     445             :             //Three Character Classic
     446             :             const sal_Unicode aZh[] = {
     447             :                 0x4EBA, 0x4E4B, 0x521D, 0x0020, 0x6027, 0x672C, 0x5584
     448           0 :             };
     449           0 :             sSampleText = rtl::OUString(aZh, SAL_N_ELEMENTS(aZh));
     450             :             break;
     451             :         }
     452             :         case USCRIPT_JAPANESE:
     453             :         {
     454             :             //'Beautiful Japanese'
     455             :             const sal_Unicode aJa[] = {
     456             :                 0x7F8E, 0x3057, 0x3044, 0x65E5, 0x672C, 0x8A9E
     457           0 :             };
     458           0 :             sSampleText = rtl::OUString(aJa, SAL_N_ELEMENTS(aJa));
     459             :             break;
     460             :         }
     461             :         case USCRIPT_KOREAN:
     462             :         case USCRIPT_HANGUL:
     463             :         {
     464             :             //The essential condition for...
     465             :             const sal_Unicode aKo[] = {
     466             :                 0xD0A4, 0xC2A4, 0xC758, 0x0020, 0xACE0, 0xC720, 0xC870,
     467             :                 0xAC74, 0xC740
     468           0 :             };
     469           0 :             sSampleText = rtl::OUString(aKo, SAL_N_ELEMENTS(aKo));
     470             :             break;
     471             :         }
     472             :         default:
     473           0 :             break;
     474             :     }
     475             : 
     476           0 :     if (sSampleText.isEmpty())
     477           0 :         sSampleText = makeShortRepresentativeTextForScript(eScript);
     478           0 :     return sSampleText;
     479             : }
     480             : 
     481           0 : rtl::OUString makeShortMinimalTextForScript(UScriptCode eScript)
     482             : {
     483           0 :     rtl::OUString sSampleText;
     484           0 :     switch (eScript)
     485             :     {
     486             :         case USCRIPT_GREEK:
     487             :         {
     488             :             const sal_Unicode aGrek[] = {
     489             :                 0x0391, 0x0392
     490           0 :             };
     491           0 :             sSampleText = rtl::OUString(aGrek, SAL_N_ELEMENTS(aGrek));
     492             :             break;
     493             :         }
     494             :         case USCRIPT_HEBREW:
     495             :         {
     496             :             const sal_Unicode aHebr[] = {
     497             :                 0x05D0, 0x05D1
     498           0 :             };
     499           0 :             sSampleText = rtl::OUString(aHebr, SAL_N_ELEMENTS(aHebr));
     500             :             break;
     501             :         }
     502             :         default:
     503           0 :             break;
     504             :     }
     505           0 :     return sSampleText;
     506             : }
     507             : 
     508           0 : rtl::OUString makeMinimalTextForScript(UScriptCode eScript)
     509             : {
     510           0 :     return makeShortMinimalTextForScript(eScript);
     511             : }
     512             : 
     513             : //These ones are typically for use in the font preview window in format
     514             : //character
     515             : //
     516             : //There we generally know the language. Though its possible for the language to
     517             : //be "none".
     518             : //
     519             : //Currently we fall back to makeShortRepresentativeTextForScript when we don't
     520             : //have suitable strings
     521           0 : rtl::OUString makeRepresentativeTextForLanguage(LanguageType eLang)
     522             : {
     523           0 :     rtl::OUString sRet;
     524           0 :     switch( eLang & LANGUAGE_MASK_PRIMARY )
     525             :     {
     526             :         case LANGUAGE_CHINESE & LANGUAGE_MASK_PRIMARY:
     527           0 :             sRet = makeRepresentativeTextForScript(USCRIPT_HAN);
     528           0 :             break;
     529             :         case LANGUAGE_GREEK & LANGUAGE_MASK_PRIMARY:
     530           0 :             sRet = makeRepresentativeTextForScript(USCRIPT_GREEK);
     531           0 :             break;
     532             :         case LANGUAGE_HEBREW & LANGUAGE_MASK_PRIMARY:
     533             :         case LANGUAGE_YIDDISH & LANGUAGE_MASK_PRIMARY:
     534           0 :             sRet = makeRepresentativeTextForScript(USCRIPT_HEBREW);
     535           0 :             break;
     536             :         case LANGUAGE_ARABIC_SAUDI_ARABIA & LANGUAGE_MASK_PRIMARY:
     537           0 :             sRet = makeRepresentativeTextForScript(USCRIPT_ARABIC);
     538           0 :             break;
     539             :         case LANGUAGE_HINDI & LANGUAGE_MASK_PRIMARY:
     540           0 :             sRet = makeRepresentativeTextForScript(USCRIPT_DEVANAGARI);
     541           0 :             break;
     542             :         case LANGUAGE_ASSAMESE & LANGUAGE_MASK_PRIMARY:
     543             :         {
     544             :             const sal_Unicode aAs[] = {
     545             :                 0x0985, 0x09B8, 0x09AE, 0x09C0, 0x09AF, 0x09BC, 0x09BE,
     546             :                 0x0020, 0x0986, 0x0996, 0x09F0
     547           0 :             };
     548           0 :             sRet = rtl::OUString(aAs, SAL_N_ELEMENTS(aAs));
     549             :             break;
     550             :         }
     551             :         case LANGUAGE_BENGALI & LANGUAGE_MASK_PRIMARY:
     552           0 :             sRet = makeRepresentativeTextForScript(USCRIPT_BENGALI);
     553           0 :             break;
     554             :         case LANGUAGE_PUNJABI & LANGUAGE_MASK_PRIMARY:
     555           0 :             sRet = makeRepresentativeTextForScript(USCRIPT_GURMUKHI);
     556           0 :             break;
     557             :         case LANGUAGE_GUJARATI & LANGUAGE_MASK_PRIMARY:
     558           0 :             sRet = makeRepresentativeTextForScript(USCRIPT_GUJARATI);
     559           0 :             break;
     560             :         case LANGUAGE_ORIYA & LANGUAGE_MASK_PRIMARY:
     561           0 :             sRet = makeRepresentativeTextForScript(USCRIPT_ORIYA);
     562           0 :             break;
     563             :         case LANGUAGE_TAMIL & LANGUAGE_MASK_PRIMARY:
     564           0 :             sRet = makeRepresentativeTextForScript(USCRIPT_TAMIL);
     565           0 :             break;
     566             :         case LANGUAGE_TELUGU & LANGUAGE_MASK_PRIMARY:
     567           0 :             sRet = makeRepresentativeTextForScript(USCRIPT_TELUGU);
     568           0 :             break;
     569             :         case LANGUAGE_KANNADA & LANGUAGE_MASK_PRIMARY:
     570           0 :             sRet = makeRepresentativeTextForScript(USCRIPT_KANNADA);
     571           0 :             break;
     572             :         case LANGUAGE_MALAYALAM & LANGUAGE_MASK_PRIMARY:
     573           0 :             sRet = makeRepresentativeTextForScript(USCRIPT_MALAYALAM);
     574           0 :             break;
     575             :         case LANGUAGE_THAI & LANGUAGE_MASK_PRIMARY:
     576           0 :             sRet = makeRepresentativeTextForScript(USCRIPT_THAI);
     577           0 :             break;
     578             :         case LANGUAGE_LAO & LANGUAGE_MASK_PRIMARY:
     579           0 :             sRet = makeRepresentativeTextForScript(USCRIPT_LAO);
     580           0 :             break;
     581             :         case LANGUAGE_GEORGIAN & LANGUAGE_MASK_PRIMARY:
     582           0 :             sRet = makeRepresentativeTextForScript(USCRIPT_GEORGIAN);
     583           0 :             break;
     584             :         case LANGUAGE_KOREAN & LANGUAGE_MASK_PRIMARY:
     585           0 :             sRet = makeRepresentativeTextForScript(USCRIPT_KOREAN);
     586           0 :             break;
     587             :         case LANGUAGE_TIBETAN & LANGUAGE_MASK_PRIMARY:
     588           0 :             sRet = makeRepresentativeTextForScript(USCRIPT_TIBETAN);
     589           0 :             break;
     590             :         case LANGUAGE_SYRIAC & LANGUAGE_MASK_PRIMARY:
     591           0 :             sRet = makeRepresentativeTextForScript(USCRIPT_SYRIAC);
     592           0 :             break;
     593             :         case LANGUAGE_SINHALESE_SRI_LANKA & LANGUAGE_MASK_PRIMARY:
     594           0 :             sRet = makeRepresentativeTextForScript(USCRIPT_SINHALA);
     595           0 :             break;
     596             :         case LANGUAGE_BURMESE & LANGUAGE_MASK_PRIMARY:
     597           0 :             sRet = makeRepresentativeTextForScript(USCRIPT_MYANMAR);
     598           0 :             break;
     599             :         case LANGUAGE_AMHARIC_ETHIOPIA & LANGUAGE_MASK_PRIMARY:
     600           0 :             sRet = makeRepresentativeTextForScript(USCRIPT_ETHIOPIC);
     601           0 :             break;
     602             :         case LANGUAGE_CHEROKEE_UNITED_STATES & LANGUAGE_MASK_PRIMARY:
     603           0 :             sRet = makeRepresentativeTextForScript(USCRIPT_CHEROKEE);
     604           0 :             break;
     605             :         case LANGUAGE_KHMER & LANGUAGE_MASK_PRIMARY:
     606           0 :             sRet = makeRepresentativeTextForScript(USCRIPT_KHMER);
     607           0 :             break;
     608             :         case LANGUAGE_MONGOLIAN & LANGUAGE_MASK_PRIMARY:
     609           0 :             sRet = makeRepresentativeTextForScript(USCRIPT_MONGOLIAN);
     610           0 :             break;
     611             :         case LANGUAGE_JAPANESE & LANGUAGE_MASK_PRIMARY:
     612           0 :             sRet = makeRepresentativeTextForScript(USCRIPT_JAPANESE);
     613           0 :             break;
     614             :         case LANGUAGE_YI & LANGUAGE_MASK_PRIMARY:
     615           0 :             sRet = makeRepresentativeTextForScript(USCRIPT_YI);
     616           0 :             break;
     617             :         case LANGUAGE_GAELIC_IRELAND & LANGUAGE_MASK_PRIMARY:
     618             :         {
     619             :             const sal_Unicode aGa[] = {
     620             :                 'T', 0x00E9, 'a', 'c', 's', ' ', 'S', 'a', 'm', 'p', 'l', 'a', 'c', 'h'
     621           0 :             };
     622           0 :             sRet = rtl::OUString(aGa, SAL_N_ELEMENTS(aGa));
     623             :             break;
     624             :         }
     625             :         default:
     626           0 :             break;
     627             :     }
     628             : 
     629           0 :     return sRet;
     630             : }
     631             : 
     632             : namespace
     633             : {
     634             : #if OSL_DEBUG_LEVEL > 2
     635             :     void lcl_dump_unicode_coverage(const boost::dynamic_bitset<sal_uInt32> &rIn)
     636             :     {
     637             :         if (rIn[vcl::UnicodeCoverage::BASIC_LATIN])
     638             :             fprintf(stderr, "BASIC_LATIN\n");
     639             :         if (rIn[vcl::UnicodeCoverage::LATIN_1_SUPPLEMENT])
     640             :             fprintf(stderr, "LATIN_1_SUPPLEMENT\n");
     641             :         if (rIn[vcl::UnicodeCoverage::LATIN_EXTENDED_A])
     642             :             fprintf(stderr, "LATIN_EXTENDED_A\n");
     643             :         if (rIn[vcl::UnicodeCoverage::LATIN_EXTENDED_B])
     644             :             fprintf(stderr, "LATIN_EXTENDED_B\n");
     645             :         if (rIn[vcl::UnicodeCoverage::IPA_EXTENSIONS])
     646             :             fprintf(stderr, "IPA_EXTENSIONS\n");
     647             :         if (rIn[vcl::UnicodeCoverage::SPACING_MODIFIER_LETTERS])
     648             :             fprintf(stderr, "SPACING_MODIFIER_LETTERS\n");
     649             :         if (rIn[vcl::UnicodeCoverage::COMBINING_DIACRITICAL_MARKS])
     650             :             fprintf(stderr, "COMBINING_DIACRITICAL_MARKS\n");
     651             :         if (rIn[vcl::UnicodeCoverage::GREEK_AND_COPTIC])
     652             :             fprintf(stderr, "GREEK_AND_COPTIC\n");
     653             :         if (rIn[vcl::UnicodeCoverage::COPTIC])
     654             :             fprintf(stderr, "COPTIC\n");
     655             :         if (rIn[vcl::UnicodeCoverage::CYRILLIC])
     656             :             fprintf(stderr, "CYRILLIC\n");
     657             :         if (rIn[vcl::UnicodeCoverage::ARMENIAN])
     658             :             fprintf(stderr, "ARMENIAN\n");
     659             :         if (rIn[vcl::UnicodeCoverage::HEBREW])
     660             :             fprintf(stderr, "HEBREW\n");
     661             :         if (rIn[vcl::UnicodeCoverage::VAI])
     662             :             fprintf(stderr, "VAI\n");
     663             :         if (rIn[vcl::UnicodeCoverage::ARABIC])
     664             :             fprintf(stderr, "ARABIC\n");
     665             :         if (rIn[vcl::UnicodeCoverage::NKO])
     666             :             fprintf(stderr, "NKO\n");
     667             :         if (rIn[vcl::UnicodeCoverage::DEVANAGARI])
     668             :             fprintf(stderr, "DEVANAGARI\n");
     669             :         if (rIn[vcl::UnicodeCoverage::BENGALI])
     670             :             fprintf(stderr, "BENGALI\n");
     671             :         if (rIn[vcl::UnicodeCoverage::GURMUKHI])
     672             :             fprintf(stderr, "GURMUKHI\n");
     673             :         if (rIn[vcl::UnicodeCoverage::GUJARATI])
     674             :             fprintf(stderr, "GUJARATI\n");
     675             :         if (rIn[vcl::UnicodeCoverage::ORIYA])
     676             :             fprintf(stderr, "ORIYA\n");
     677             :         if (rIn[vcl::UnicodeCoverage::TAMIL])
     678             :             fprintf(stderr, "TAMIL\n");
     679             :         if (rIn[vcl::UnicodeCoverage::TELUGU])
     680             :             fprintf(stderr, "TELUGU\n");
     681             :         if (rIn[vcl::UnicodeCoverage::KANNADA])
     682             :             fprintf(stderr, "KANNADA\n");
     683             :         if (rIn[vcl::UnicodeCoverage::MALAYALAM])
     684             :             fprintf(stderr, "MALAYALAM\n");
     685             :         if (rIn[vcl::UnicodeCoverage::THAI])
     686             :             fprintf(stderr, "THAI\n");
     687             :         if (rIn[vcl::UnicodeCoverage::LAO])
     688             :             fprintf(stderr, "LAO\n");
     689             :         if (rIn[vcl::UnicodeCoverage::GEORGIAN])
     690             :             fprintf(stderr, "GEORGIAN\n");
     691             :         if (rIn[vcl::UnicodeCoverage::BALINESE])
     692             :             fprintf(stderr, "BALINESE\n");
     693             :         if (rIn[vcl::UnicodeCoverage::HANGUL_JAMO])
     694             :             fprintf(stderr, "HANGUL_JAMO\n");
     695             :         if (rIn[vcl::UnicodeCoverage::LATIN_EXTENDED_ADDITIONAL])
     696             :             fprintf(stderr, "LATIN_EXTENDED_ADDITIONAL\n");
     697             :         if (rIn[vcl::UnicodeCoverage::GREEK_EXTENDED])
     698             :             fprintf(stderr, "GREEK_EXTENDED\n");
     699             :         if (rIn[vcl::UnicodeCoverage::GENERAL_PUNCTUATION])
     700             :             fprintf(stderr, "GENERAL_PUNCTUATION\n");
     701             :         if (rIn[vcl::UnicodeCoverage::SUPERSCRIPTS_AND_SUBSCRIPTS])
     702             :             fprintf(stderr, "SUPERSCRIPTS_AND_SUBSCRIPTS\n");
     703             :         if (rIn[vcl::UnicodeCoverage::CURRENCY_SYMBOLS])
     704             :             fprintf(stderr, "CURRENCY_SYMBOLS\n");
     705             :         if (rIn[vcl::UnicodeCoverage::COMBINING_DIACRITICAL_MARKS_FOR_SYMBOLS])
     706             :             fprintf(stderr, "COMBINING_DIACRITICAL_MARKS_FOR_SYMBOLS\n");
     707             :         if (rIn[vcl::UnicodeCoverage::LETTERLIKE_SYMBOLS])
     708             :             fprintf(stderr, "LETTERLIKE_SYMBOLS\n");
     709             :         if (rIn[vcl::UnicodeCoverage::NUMBER_FORMS])
     710             :             fprintf(stderr, "NUMBER_FORMS\n");
     711             :         if (rIn[vcl::UnicodeCoverage::ARROWS])
     712             :             fprintf(stderr, "ARROWS\n");
     713             :         if (rIn[vcl::UnicodeCoverage::MATHEMATICAL_OPERATORS])
     714             :             fprintf(stderr, "MATHEMATICAL_OPERATORS\n");
     715             :         if (rIn[vcl::UnicodeCoverage::MISCELLANEOUS_TECHNICAL])
     716             :             fprintf(stderr, "MISCELLANEOUS_TECHNICAL\n");
     717             :         if (rIn[vcl::UnicodeCoverage::CONTROL_PICTURES])
     718             :             fprintf(stderr, "CONTROL_PICTURES\n");
     719             :         if (rIn[vcl::UnicodeCoverage::OPTICAL_CHARACTER_RECOGNITION])
     720             :             fprintf(stderr, "OPTICAL_CHARACTER_RECOGNITION\n");
     721             :         if (rIn[vcl::UnicodeCoverage::ENCLOSED_ALPHANUMERICS])
     722             :             fprintf(stderr, "ENCLOSED_ALPHANUMERICS\n");
     723             :         if (rIn[vcl::UnicodeCoverage::BOX_DRAWING])
     724             :             fprintf(stderr, "BOX_DRAWING\n");
     725             :         if (rIn[vcl::UnicodeCoverage::BLOCK_ELEMENTS])
     726             :             fprintf(stderr, "BLOCK_ELEMENTS\n");
     727             :         if (rIn[vcl::UnicodeCoverage::GEOMETRIC_SHAPES])
     728             :             fprintf(stderr, "GEOMETRIC_SHAPES\n");
     729             :         if (rIn[vcl::UnicodeCoverage::MISCELLANEOUS_SYMBOLS])
     730             :             fprintf(stderr, "MISCELLANEOUS_SYMBOLS\n");
     731             :         if (rIn[vcl::UnicodeCoverage::DINGBATS])
     732             :             fprintf(stderr, "DINGBATS\n");
     733             :         if (rIn[vcl::UnicodeCoverage::CJK_SYMBOLS_AND_PUNCTUATION])
     734             :             fprintf(stderr, "CJK_SYMBOLS_AND_PUNCTUATION\n");
     735             :         if (rIn[vcl::UnicodeCoverage::HIRAGANA])
     736             :             fprintf(stderr, "HIRAGANA\n");
     737             :         if (rIn[vcl::UnicodeCoverage::KATAKANA])
     738             :             fprintf(stderr, "KATAKANA\n");
     739             :         if (rIn[vcl::UnicodeCoverage::BOPOMOFO])
     740             :             fprintf(stderr, "BOPOMOFO\n");
     741             :         if (rIn[vcl::UnicodeCoverage::HANGUL_COMPATIBILITY_JAMO])
     742             :             fprintf(stderr, "HANGUL_COMPATIBILITY_JAMO\n");
     743             :         if (rIn[vcl::UnicodeCoverage::PHAGS_PA])
     744             :             fprintf(stderr, "PHAGS_PA\n");
     745             :         if (rIn[vcl::UnicodeCoverage::ENCLOSED_CJK_LETTERS_AND_MONTHS])
     746             :             fprintf(stderr, "ENCLOSED_CJK_LETTERS_AND_MONTHS\n");
     747             :         if (rIn[vcl::UnicodeCoverage::CJK_COMPATIBILITY])
     748             :             fprintf(stderr, "CJK_COMPATIBILITY\n");
     749             :         if (rIn[vcl::UnicodeCoverage::HANGUL_SYLLABLES])
     750             :             fprintf(stderr, "HANGUL_SYLLABLES\n");
     751             :         if (rIn[vcl::UnicodeCoverage::NONPLANE_0])
     752             :             fprintf(stderr, "NONPLANE_0\n");
     753             :         if (rIn[vcl::UnicodeCoverage::PHOENICIAN])
     754             :             fprintf(stderr, "PHOENICIAN\n");
     755             :         if (rIn[vcl::UnicodeCoverage::CJK_UNIFIED_IDEOGRAPHS])
     756             :             fprintf(stderr, "CJK_UNIFIED_IDEOGRAPHS\n");
     757             :         if (rIn[vcl::UnicodeCoverage::PRIVATE_USE_AREA_PLANE_0])
     758             :             fprintf(stderr, "PRIVATE_USE_AREA_PLANE_0\n");
     759             :         if (rIn[vcl::UnicodeCoverage::CJK_STROKES])
     760             :             fprintf(stderr, "CJK_STROKES\n");
     761             :         if (rIn[vcl::UnicodeCoverage::ALPHABETIC_PRESENTATION_FORMS])
     762             :             fprintf(stderr, "ALPHABETIC_PRESENTATION_FORMS\n");
     763             :         if (rIn[vcl::UnicodeCoverage::ARABIC_PRESENTATION_FORMS_A])
     764             :             fprintf(stderr, "ARABIC_PRESENTATION_FORMS_A\n");
     765             :         if (rIn[vcl::UnicodeCoverage::COMBINING_HALF_MARKS])
     766             :             fprintf(stderr, "COMBINING_HALF_MARKS\n");
     767             :         if (rIn[vcl::UnicodeCoverage::VERTICAL_FORMS])
     768             :             fprintf(stderr, "VERTICAL_FORMS\n");
     769             :         if (rIn[vcl::UnicodeCoverage::SMALL_FORM_VARIANTS])
     770             :             fprintf(stderr, "SMALL_FORM_VARIANTS\n");
     771             :         if (rIn[vcl::UnicodeCoverage::ARABIC_PRESENTATION_FORMS_B])
     772             :             fprintf(stderr, "ARABIC_PRESENTATION_FORMS_B\n");
     773             :         if (rIn[vcl::UnicodeCoverage::HALFWIDTH_AND_FULLWIDTH_FORMS])
     774             :             fprintf(stderr, "HALFWIDTH_AND_FULLWIDTH_FORMS\n");
     775             :         if (rIn[vcl::UnicodeCoverage::SPECIALS])
     776             :             fprintf(stderr, "SPECIALS\n");
     777             :         if (rIn[vcl::UnicodeCoverage::TIBETAN])
     778             :             fprintf(stderr, "TIBETAN\n");
     779             :         if (rIn[vcl::UnicodeCoverage::SYRIAC])
     780             :             fprintf(stderr, "SYRIAC\n");
     781             :         if (rIn[vcl::UnicodeCoverage::THAANA])
     782             :             fprintf(stderr, "THAANA\n");
     783             :         if (rIn[vcl::UnicodeCoverage::SINHALA])
     784             :             fprintf(stderr, "SINHALA\n");
     785             :         if (rIn[vcl::UnicodeCoverage::MYANMAR])
     786             :             fprintf(stderr, "MYANMAR\n");
     787             :         if (rIn[vcl::UnicodeCoverage::ETHIOPIC])
     788             :             fprintf(stderr, "ETHIOPIC\n");
     789             :         if (rIn[vcl::UnicodeCoverage::CHEROKEE])
     790             :             fprintf(stderr, "CHEROKEE\n");
     791             :         if (rIn[vcl::UnicodeCoverage::UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS])
     792             :             fprintf(stderr, "UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS\n");
     793             :         if (rIn[vcl::UnicodeCoverage::OGHAM])
     794             :             fprintf(stderr, "OGHAM\n");
     795             :         if (rIn[vcl::UnicodeCoverage::RUNIC])
     796             :             fprintf(stderr, "RUNIC\n");
     797             :         if (rIn[vcl::UnicodeCoverage::KHMER])
     798             :             fprintf(stderr, "KHMER\n");
     799             :         if (rIn[vcl::UnicodeCoverage::MONGOLIAN])
     800             :             fprintf(stderr, "MONGOLIAN\n");
     801             :         if (rIn[vcl::UnicodeCoverage::BRAILLE_PATTERNS])
     802             :             fprintf(stderr, "BRAILLE_PATTERNS\n");
     803             :         if (rIn[vcl::UnicodeCoverage::YI_SYLLABLES])
     804             :             fprintf(stderr, "YI_SYLLABLES\n");
     805             :         if (rIn[vcl::UnicodeCoverage::TAGALOG])
     806             :             fprintf(stderr, "TAGALOG\n");
     807             :         if (rIn[vcl::UnicodeCoverage::OLD_ITALIC])
     808             :             fprintf(stderr, "OLD_ITALIC\n");
     809             :         if (rIn[vcl::UnicodeCoverage::GOTHIC])
     810             :             fprintf(stderr, "GOTHIC\n");
     811             :         if (rIn[vcl::UnicodeCoverage::DESERET])
     812             :             fprintf(stderr, "DESERET\n");
     813             :         if (rIn[vcl::UnicodeCoverage::BYZANTINE_MUSICAL_SYMBOLS])
     814             :             fprintf(stderr, "BYZANTINE_MUSICAL_SYMBOLS\n");
     815             :         if (rIn[vcl::UnicodeCoverage::MATHEMATICAL_ALPHANUMERIC_SYMBOLS])
     816             :             fprintf(stderr, "MATHEMATICAL_ALPHANUMERIC_SYMBOLS\n");
     817             :         if (rIn[vcl::UnicodeCoverage::PRIVATE_USE_PLANE_15])
     818             :             fprintf(stderr, "PRIVATE_USE_PLANE_15\n");
     819             :         if (rIn[vcl::UnicodeCoverage::VARIATION_SELECTORS])
     820             :             fprintf(stderr, "VARIATION_SELECTORS\n");
     821             :         if (rIn[vcl::UnicodeCoverage::TAGS])
     822             :             fprintf(stderr, "TAGS\n");
     823             :         if (rIn[vcl::UnicodeCoverage::LIMBU])
     824             :             fprintf(stderr, "LIMBU\n");
     825             :         if (rIn[vcl::UnicodeCoverage::TAI_LE])
     826             :             fprintf(stderr, "TAI_LE\n");
     827             :         if (rIn[vcl::UnicodeCoverage::NEW_TAI_LUE])
     828             :             fprintf(stderr, "NEW_TAI_LUE\n");
     829             :         if (rIn[vcl::UnicodeCoverage::BUGINESE])
     830             :             fprintf(stderr, "BUGINESE\n");
     831             :         if (rIn[vcl::UnicodeCoverage::GLAGOLITIC])
     832             :             fprintf(stderr, "GLAGOLITIC\n");
     833             :         if (rIn[vcl::UnicodeCoverage::TIFINAGH])
     834             :             fprintf(stderr, "TIFINAGH\n");
     835             :         if (rIn[vcl::UnicodeCoverage::YIJING_HEXAGRAM_SYMBOLS])
     836             :             fprintf(stderr, "YIJING_HEXAGRAM_SYMBOLS\n");
     837             :         if (rIn[vcl::UnicodeCoverage::SYLOTI_NAGRI])
     838             :             fprintf(stderr, "SYLOTI_NAGRI\n");
     839             :         if (rIn[vcl::UnicodeCoverage::LINEAR_B_SYLLABARY])
     840             :             fprintf(stderr, "LINEAR_B_SYLLABARY\n");
     841             :         if (rIn[vcl::UnicodeCoverage::ANCIENT_GREEK_NUMBERS])
     842             :             fprintf(stderr, "ANCIENT_GREEK_NUMBERS\n");
     843             :         if (rIn[vcl::UnicodeCoverage::UGARITIC])
     844             :             fprintf(stderr, "UGARITIC\n");
     845             :         if (rIn[vcl::UnicodeCoverage::OLD_PERSIAN])
     846             :             fprintf(stderr, "OLD_PERSIAN\n");
     847             :         if (rIn[vcl::UnicodeCoverage::SHAVIAN])
     848             :             fprintf(stderr, "SHAVIAN\n");
     849             :         if (rIn[vcl::UnicodeCoverage::OSMANYA])
     850             :             fprintf(stderr, "OSMANYA\n");
     851             :         if (rIn[vcl::UnicodeCoverage::CYPRIOT_SYLLABARY])
     852             :             fprintf(stderr, "CYPRIOT_SYLLABARY\n");
     853             :         if (rIn[vcl::UnicodeCoverage::KHAROSHTHI])
     854             :             fprintf(stderr, "KHAROSHTHI\n");
     855             :         if (rIn[vcl::UnicodeCoverage::TAI_XUAN_JING_SYMBOLS])
     856             :             fprintf(stderr, "TAI_XUAN_JING_SYMBOLS\n");
     857             :         if (rIn[vcl::UnicodeCoverage::CUNEIFORM])
     858             :             fprintf(stderr, "CUNEIFORM\n");
     859             :         if (rIn[vcl::UnicodeCoverage::COUNTING_ROD_NUMERALS])
     860             :             fprintf(stderr, "COUNTING_ROD_NUMERALS\n");
     861             :         if (rIn[vcl::UnicodeCoverage::SUNDANESE])
     862             :             fprintf(stderr, "SUNDANESE\n");
     863             :         if (rIn[vcl::UnicodeCoverage::LEPCHA])
     864             :             fprintf(stderr, "LEPCHA\n");
     865             :         if (rIn[vcl::UnicodeCoverage::OL_CHIKI])
     866             :             fprintf(stderr, "OL_CHIKI\n");
     867             :         if (rIn[vcl::UnicodeCoverage::SAURASHTRA])
     868             :             fprintf(stderr, "SAURASHTRA\n");
     869             :         if (rIn[vcl::UnicodeCoverage::KAYAH_LI])
     870             :             fprintf(stderr, "KAYAH_LI\n");
     871             :         if (rIn[vcl::UnicodeCoverage::REJANG])
     872             :             fprintf(stderr, "REJANG\n");
     873             :         if (rIn[vcl::UnicodeCoverage::CHAM])
     874             :             fprintf(stderr, "CHAM\n");
     875             :         if (rIn[vcl::UnicodeCoverage::ANCIENT_SYMBOLS])
     876             :             fprintf(stderr, "ANCIENT_SYMBOLS\n");
     877             :         if (rIn[vcl::UnicodeCoverage::PHAISTOS_DISC])
     878             :             fprintf(stderr, "PHAISTOS_DISC\n");
     879             :         if (rIn[vcl::UnicodeCoverage::CARIAN])
     880             :             fprintf(stderr, "CARIAN\n");
     881             :         if (rIn[vcl::UnicodeCoverage::DOMINO_TILES])
     882             :             fprintf(stderr, "DOMINO_TILES\n");
     883             :         if (rIn[vcl::UnicodeCoverage::RESERVED1])
     884             :             fprintf(stderr, "RESERVED1\n");
     885             :         if (rIn[vcl::UnicodeCoverage::RESERVED2])
     886             :             fprintf(stderr, "RESERVED2\n");
     887             :         if (rIn[vcl::UnicodeCoverage::RESERVED3])
     888             :             fprintf(stderr, "RESERVED3\n");
     889             :         if (rIn[vcl::UnicodeCoverage::RESERVED4])
     890             :             fprintf(stderr, "RESERVED4\n");
     891             :         if (rIn[vcl::UnicodeCoverage::RESERVED5])
     892             :             fprintf(stderr, "RESERVED5\n");
     893             :     }
     894             : 
     895             :     void lcl_dump_codepage_coverage(const boost::dynamic_bitset<sal_uInt32> &rIn)
     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())
    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 :             rtl::OUString sKorean(aKorean, SAL_N_ELEMENTS(aKorean));
    1118           0 :             if (STRING_LEN == rDevice.HasGlyphs(rFont, sKorean))
    1119           0 :                 bKore = true;
    1120             : 
    1121           0 :             const sal_Unicode aJapanese[] = { 0x3007, 0x9F9D };
    1122           0 :             rtl::OUString sJapanese(aJapanese, SAL_N_ELEMENTS(aJapanese));
    1123           0 :             if (STRING_LEN == rDevice.HasGlyphs(rFont, sJapanese))
    1124           0 :                 bJpan = true;
    1125             : 
    1126           0 :             const sal_Unicode aTraditionalChinese[] = { 0x570B };
    1127           0 :             rtl::OUString sTraditionalChinese(aTraditionalChinese, SAL_N_ELEMENTS(aTraditionalChinese));
    1128           0 :             if (STRING_LEN == rDevice.HasGlyphs(rFont, sTraditionalChinese))
    1129           0 :                 bHant = true;
    1130             : 
    1131           0 :             const sal_Unicode aSimplifiedChinese[] = { 0x56FD };
    1132           0 :             rtl::OUString sSimplifiedChinese(aSimplifiedChinese, SAL_N_ELEMENTS(aSimplifiedChinese));
    1133           0 :             if (STRING_LEN == 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 : rtl::OUString makeShortRepresentativeTextForSelectedFont(OutputDevice &rDevice)
    1151             : {
    1152           0 :     vcl::FontCapabilities aFontCapabilities;
    1153           0 :     if (!rDevice.GetFontCapabilities(aFontCapabilities))
    1154           0 :         return rtl::OUString();
    1155             : 
    1156             : #if OSL_DEBUG_LEVEL > 2
    1157             :     fprintf(stderr, "font is %s\n",
    1158             :         rtl::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 rtl::OUString();
    1171             : 
    1172           0 :     eScript = attemptToDisambiguateHan(eScript, rDevice);
    1173             : 
    1174           0 :     rtl::OUString sSampleText = makeShortRepresentativeTextForScript(eScript);
    1175           0 :     bool bHasSampleTextGlyphs = (STRING_LEN == rDevice.HasGlyphs(rDevice.GetFont(), sSampleText));
    1176           0 :     return bHasSampleTextGlyphs ? sSampleText : rtl::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::ORIYA:
    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 : rtl::OUString makeRepresentativeTextForFont(sal_Int16 nScriptType, const Font &rFont)
    1501             : {
    1502           0 :     rtl::OUString sRet(makeRepresentativeTextForLanguage(rFont.GetLanguage()));
    1503             : 
    1504           0 :     VirtualDevice aDevice;
    1505           0 :     if (sRet.isEmpty() || (STRING_LEN != 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             :                 aFontCapabilities.maCodePageRange =
    1521           0 :                     boost::dynamic_bitset<sal_uInt32>(aFontCapabilities.maCodePageRange.size());
    1522             :             }
    1523           0 :             if (nScriptType != com::sun::star::i18n::ScriptType::LATIN)
    1524           0 :                 aFontCapabilities.maUnicodeRange &= getLatinMask();
    1525           0 :             if (nScriptType != com::sun::star::i18n::ScriptType::COMPLEX)
    1526           0 :                 aFontCapabilities.maUnicodeRange &= getCTLMask();
    1527             : 
    1528             : #if OSL_DEBUG_LEVEL > 2
    1529             :             fprintf(stderr, "minimal\n");
    1530             :             lcl_dump_unicode_coverage(aFontCapabilities.maUnicodeRange);
    1531             :             lcl_dump_codepage_coverage(aFontCapabilities.maCodePageRange);
    1532             : #endif
    1533             : 
    1534           0 :             UScriptCode eScript = getScript(aFontCapabilities);
    1535             : 
    1536           0 :             if (nScriptType == com::sun::star::i18n::ScriptType::ASIAN)
    1537           0 :                 eScript = attemptToDisambiguateHan(eScript, aDevice);
    1538             : 
    1539           0 :             sRet = makeRepresentativeTextForScript(eScript);
    1540             :         }
    1541             : 
    1542           0 :         if (sRet.isEmpty())
    1543             :         {
    1544           0 :             if (nScriptType == com::sun::star::i18n::ScriptType::COMPLEX)
    1545             :             {
    1546           0 :                 sRet = makeRepresentativeTextForScript(USCRIPT_HEBREW);
    1547           0 :                 if (STRING_LEN != aDevice.HasGlyphs(rFont, sRet))
    1548             :                 {
    1549           0 :                     sRet = makeMinimalTextForScript(USCRIPT_HEBREW);
    1550           0 :                     if (STRING_LEN != aDevice.HasGlyphs(rFont, sRet))
    1551           0 :                         sRet = makeRepresentativeTextForScript(USCRIPT_ARABIC);
    1552             :                 }
    1553             :             }
    1554           0 :             else if (nScriptType == com::sun::star::i18n::ScriptType::LATIN)
    1555           0 :                 sRet = makeRepresentativeTextForScript(USCRIPT_LATIN);
    1556           0 :         }
    1557             :     }
    1558             : 
    1559           0 :     return sRet;
    1560             : }
    1561             : 
    1562             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10