[Libreoffice-commits] .: 4 commits - i18npool/source svtools/source vcl/aqua vcl/inc vcl/source vcl/unx vcl/win

Caolán McNamara caolan at kemper.freedesktop.org
Wed Feb 9 07:04:25 PST 2011


 i18npool/source/localedata/saxparser.cxx |    5 
 svtools/source/control/ctrlbox.cxx       |  295 ++++++++++++++++++++++++++++++-
 vcl/aqua/inc/salgdi.h                    |    4 
 vcl/aqua/source/gdi/salgdi.cxx           |   42 ++++
 vcl/inc/sft.hxx                          |    4 
 vcl/inc/vcl/glyphcache.hxx               |    3 
 vcl/inc/vcl/outdev.hxx                   |    3 
 vcl/inc/vcl/salgdi.hxx                   |    2 
 vcl/source/fontsubset/gsub.cxx           |   22 ++
 vcl/source/gdi/outdev3.cxx               |   18 +
 vcl/source/glyphs/gcach_ftyp.cxx         |   29 ++-
 vcl/source/glyphs/gcach_ftyp.hxx         |    1 
 vcl/unx/headless/svpgdi.hxx              |    1 
 vcl/unx/headless/svppspgraphics.cxx      |    7 
 vcl/unx/headless/svppspgraphics.hxx      |    1 
 vcl/unx/headless/svptext.cxx             |    8 
 vcl/unx/inc/pspgraphics.h                |    1 
 vcl/unx/inc/salgdi.h                     |    1 
 vcl/unx/source/gdi/pspgraphics.cxx       |    7 
 vcl/unx/source/gdi/salgdi3.cxx           |    7 
 vcl/win/inc/salgdi.h                     |    3 
 vcl/win/source/gdi/salgdi3.cxx           |   31 +++
 22 files changed, 481 insertions(+), 14 deletions(-)

New commits:
commit d2962abe43766bc94deb808b808b7c1ff1d25617
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Feb 7 11:37:08 2011 +0000

    revert this as its orthogonal to the font capabilities

diff --git a/vcl/source/gdi/outdev3.cxx b/vcl/source/gdi/outdev3.cxx
index 9ba5e96..5cd252e 100644
--- a/vcl/source/gdi/outdev3.cxx
+++ b/vcl/source/gdi/outdev3.cxx
@@ -1499,21 +1499,40 @@ ImplDevFontListData* ImplDevFontList::GetGlyphFallbackFont( ImplFontSelectData&
 
 void ImplDevFontList::Add( ImplFontData* pNewData )
 {
-    String aSearchName = pNewData->maName;
-    GetEnglishSearchFontName( aSearchName );
+    int nAliasQuality = pNewData->mnQuality - 100;
+    String aMapNames = pNewData->maMapNames;
+    pNewData->maMapNames = String();
 
-    DevFontList::const_iterator it = maDevFontList.find( aSearchName );
-    ImplDevFontListData* pFoundData = NULL;
-    if( it != maDevFontList.end() )
-        pFoundData = (*it).second;
-
-    if( !pFoundData )
+    bool bKeepNewData = false;
+    xub_StrLen nMapNameIndex = 0;
+    while( true )
     {
-        pFoundData = new ImplDevFontListData( aSearchName );
-        maDevFontList[ aSearchName ] = pFoundData;
-    }
+        String aSearchName = pNewData->maName;
+        GetEnglishSearchFontName( aSearchName );
+
+        DevFontList::const_iterator it = maDevFontList.find( aSearchName );
+        ImplDevFontListData* pFoundData = NULL;
+        if( it != maDevFontList.end() )
+            pFoundData = (*it).second;
 
-    bool bKeepNewData = pFoundData->AddFontFace( pNewData );
+        if( !pFoundData )
+        {
+            pFoundData = new ImplDevFontListData( aSearchName );
+            maDevFontList[ aSearchName ] = pFoundData;
+        }
+
+        bKeepNewData = pFoundData->AddFontFace( pNewData );
+
+        // add (another) font alias if available
+        // a font alias should never win against an original font with similar quality
+        if( aMapNames.Len() <= nMapNameIndex )
+            break;
+        if( bKeepNewData ) // try to recycle obsoleted object
+            pNewData = pNewData->CreateAlias();
+        bKeepNewData = false;
+        pNewData->mnQuality = nAliasQuality;
+        pNewData->maName = GetNextFontToken( aMapNames, nMapNameIndex );
+    }
 
     if( !bKeepNewData )
         delete pNewData;
commit e98d7c6284344e7411ea40443de03f7c941ea6a8
Author: Francois Tigeot <ftigeot at wolfpond.org>
Date:   Sun Feb 6 14:25:31 2011 +0000

    Show exception message

diff --git a/i18npool/source/localedata/saxparser.cxx b/i18npool/source/localedata/saxparser.cxx
index 98d2e5a..79e22e4 100644
--- a/i18npool/source/localedata/saxparser.cxx
+++ b/i18npool/source/localedata/saxparser.cxx
@@ -323,9 +323,10 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
             ::rtl::OUString::createFromAscii(argv[4]),
             ::rtl::OUString::createFromAscii(argv[5]) );
     }
-    catch ( Exception& )
+    catch ( Exception &e )
     {
-        printf( "Exception on createRegistryServiceFactory\n" );
+        printf( "Exception on createRegistryServiceFactory %s\n",
+            OUStringToOString( e.Message , RTL_TEXTENCODING_ASCII_US ).getStr() );
         exit(1);
     }
 
commit d3a45a1f667b0c11146ded5abe2af52c21e26d76
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sun Feb 6 13:47:35 2011 +0000

    Resolves: fdo#33510 A way to query about likely font layout capabilities

diff --git a/vcl/aqua/inc/salgdi.h b/vcl/aqua/inc/salgdi.h
index 2c5f37c..4165ece 100644
--- a/vcl/aqua/inc/salgdi.h
+++ b/vcl/aqua/inc/salgdi.h
@@ -61,6 +61,7 @@ public:
     virtual sal_IntPtr      GetFontId() const;
     
     ImplFontCharMap*		GetImplFontCharMap() const;
+    bool                    GetImplFontLayoutCapabilities(FontLayoutCapabilities &rGetImplFontLayoutCapabilities) const;
     bool					HasChar( sal_uInt32 cChar ) const;
 
     void					ReadOs2Table() const;
@@ -70,10 +71,12 @@ public:
 private:
     const ATSUFontID			mnFontId;
     mutable ImplFontCharMap*	mpCharMap;
+    mutable FontLayoutCapabilities maFontLayoutCapabilities;
     mutable bool				mbOs2Read;		 // true if OS2-table related info is valid
     mutable bool				mbHasOs2Table;
     mutable bool				mbCmapEncodingRead; // true if cmap encoding of Mac font is read
     mutable bool				mbHasCJKSupport; // #i78970# CJK fonts need extra leading
+    mutable bool				mbFontLayoutCapabilitiesRead;
 };
 
 // abstracting quartz color instead of having to use an CGFloat[] array
@@ -283,6 +286,7 @@ public:
     virtual ULONG			GetKernPairs( ULONG nPairs, ImplKernPairData* pKernPairs );
     // get the repertoire of the current font
     virtual ImplFontCharMap* GetImplFontCharMap() const;
+    virtual bool GetImplFontLayoutCapabilities(FontLayoutCapabilities &rGetImplFontLayoutCapabilities) const;
     // graphics must fill supplied font list
     virtual void			GetDevFontList( ImplDevFontList* );
     // graphics should call ImplAddDevFontSubstitute on supplied
diff --git a/vcl/aqua/source/gdi/salgdi.cxx b/vcl/aqua/source/gdi/salgdi.cxx
index a892aaa..4747872 100644
--- a/vcl/aqua/source/gdi/salgdi.cxx
+++ b/vcl/aqua/source/gdi/salgdi.cxx
@@ -73,6 +73,7 @@ ImplMacFontData::ImplMacFontData( const ImplDevFontAttributes& rDFA, ATSUFontID
 ,	mbHasOs2Table( false )
 ,	mbCmapEncodingRead( false )
 ,	mbHasCJKSupport( false )
+,	mbFontLayoutCapabilitiesRead( false )
 {}
 
 // -----------------------------------------------------------------------
@@ -157,6 +158,39 @@ ImplFontCharMap* ImplMacFontData::GetImplFontCharMap() const
     return mpCharMap;
 }
 
+bool ImplMacFontData::GetImplFontLayoutCapabilities(FontLayoutCapabilities &rFontLayoutCapabilities)
+{
+    // read this only once per font
+    if( mbFontLayoutCapabilitiesRead )
+    {
+        rFontLayoutCapabilities = maFontLayoutCapabilities;
+        return !rFontLayoutCapabilities.empty();
+    }
+    mbFontLayoutCapabilitiesRead = true;
+
+    // prepare to get the GSUB table raw data
+    ATSFontRef rFont = FMGetATSFontRefFromFont( mnFontId );
+    ByteCount nBufSize = 0;
+    OSStatus eStatus = ATSFontGetTable( rFont, GetTag("GSUB"), 0, 0, NULL, &nBufSize );
+    if( eStatus != noErr )
+        return false;
+
+    // allocate a buffer for the GSUB raw data
+    ByteVector aBuffer( nBufSize );
+
+    // get the GSUB raw data
+    ByteCount nRawLength = 0;
+    eStatus = ATSFontGetTable( rFont, GetTag("GSUB"), 0, nBufSize, (void*)&aBuffer[0], &nRawLength );
+    if( eStatus != noErr )
+        return false;
+
+    const unsigned char* pGSUBTable = &aBuffer[0];
+    vcl::getTTFontLayoutCapabilities(maFontLayoutCapabilities, pGSUBTable);
+    rFontLayoutCapabilities = maFontLayoutCapabilities;
+
+    return !rFontLayoutCapabilities.empty()
+}
+
 // -----------------------------------------------------------------------
 
 void ImplMacFontData::ReadOs2Table( void ) const
@@ -1984,6 +2018,14 @@ ImplFontCharMap* AquaSalGraphics::GetImplFontCharMap() const
     return mpMacFontData->GetImplFontCharMap();
 }
 
+bool AquaSalGraphics::GetImplFontLayoutCapabilities(FontLayoutCapabilities &rFontLayoutCapabilities)
+{
+    if( !mpMacFontData )
+        return false;
+
+    return mpMacFontData->GetImplFontLayoutCapabilities(rFontLayoutCapabilities);
+}
+
 // -----------------------------------------------------------------------
 
 // fake a SFNT font directory entry for a font table
diff --git a/vcl/inc/sft.hxx b/vcl/inc/sft.hxx
index 85e6faf..64757ca 100644
--- a/vcl/inc/sft.hxx
+++ b/vcl/inc/sft.hxx
@@ -71,6 +71,8 @@
 
 #include <vector>
 
+typedef std::vector< sal_uInt32 > FontLayoutCapabilities;
+
 namespace vcl
 {
     
@@ -301,6 +303,8 @@ namespace vcl
     int OpenTTFontFile(const char *fname, sal_uInt32 facenum, TrueTypeFont** ttf);
 #endif
 
+    void getTTFontLayoutCapabilities(FontLayoutCapabilities &rFontLayoutCapabilities, const unsigned char* pTable);
+
 /**
  * TrueTypeFont destructor. Deallocates the memory.
  * @ingroup sft
diff --git a/vcl/inc/vcl/glyphcache.hxx b/vcl/inc/vcl/glyphcache.hxx
index 1224632..c934c4a 100644
--- a/vcl/inc/vcl/glyphcache.hxx
+++ b/vcl/inc/vcl/glyphcache.hxx
@@ -57,6 +57,8 @@ class CmapResult;
 class ServerFontLayout;
 #include <vcl/sallayout.hxx>
 
+typedef std::vector< sal_uInt32 > FontLayoutCapabilities;
+
 // =======================================================================
 
 class VCL_DLLPUBLIC GlyphCache
@@ -192,6 +194,7 @@ public:
     virtual ULONG               GetKernPairs( ImplKernPairData** ) const      { return 0; }
     virtual int                 GetGlyphKernValue( int, int ) const           { return 0; }
     virtual bool                GetFontCodeRanges( CmapResult& ) const        { return false; }
+    virtual bool                GetFontLayoutCapabilities(FontLayoutCapabilities &) const { return false; }
     Point                       TransformPoint( const Point& ) const;
 
     GlyphData&                  GetGlyphData( int nGlyphIndex );
diff --git a/vcl/inc/vcl/outdev.hxx b/vcl/inc/vcl/outdev.hxx
index cef22b9..b7ca252 100644
--- a/vcl/inc/vcl/outdev.hxx
+++ b/vcl/inc/vcl/outdev.hxx
@@ -104,6 +104,8 @@ namespace awt {
 
 typedef std::vector< Rectangle > MetricVector;
 
+typedef std::vector< sal_uInt32 > FontLayoutCapabilities;
+
 namespace vcl
 {
     class PDFWriterImpl;
@@ -1072,6 +1074,7 @@ public:
     FontMetric          GetFontMetric() const;
     FontMetric          GetFontMetric( const Font& rFont ) const;
     BOOL                GetFontCharMap( FontCharMap& rFontCharMap ) const;
+    bool                GetFontLayoutCapabilities( FontLayoutCapabilities& rFontLayoutCapabilities ) const;
 
     xub_StrLen          HasGlyphs( const Font& rFont, const String& rStr,
                             xub_StrLen nIndex = 0, xub_StrLen nLen = STRING_LEN ) const;
diff --git a/vcl/inc/vcl/salgdi.hxx b/vcl/inc/vcl/salgdi.hxx
index 15b2c70..1d73f2f 100644
--- a/vcl/inc/vcl/salgdi.hxx
+++ b/vcl/inc/vcl/salgdi.hxx
@@ -241,6 +241,8 @@ public:
     virtual ULONG			GetKernPairs( ULONG nMaxPairCount, ImplKernPairData* ) = 0;
     // get the repertoire of the current font
     virtual ImplFontCharMap* GetImplFontCharMap() const = 0;
+    // get the layout capabilities of the current font
+    virtual bool GetImplFontLayoutCapabilities(FontLayoutCapabilities &rGetImplFontLayoutCapabilities) const = 0;
     // graphics must fill supplied font list
     virtual void			GetDevFontList( ImplDevFontList* ) = 0;
     // graphics should call ImplAddDevFontSubstitute on supplied
diff --git a/vcl/source/fontsubset/gsub.cxx b/vcl/source/fontsubset/gsub.cxx
index 450a70b..bb93823 100644
--- a/vcl/source/fontsubset/gsub.cxx
+++ b/vcl/source/fontsubset/gsub.cxx
@@ -50,9 +50,9 @@ typedef sal_uInt8 FT_Byte;
 typedef std::map<USHORT,USHORT> GlyphSubstitution;
 
 
-inline long NEXT_Long( const unsigned char* &p )
+inline sal_uInt32 NEXT_Long( const unsigned char* &p )
 {
-    long nVal = (p[0]<<24) + (p[1]<<16) + (p[2]<<8) + p[3];
+    sal_uInt32 nVal = (p[0]<<24) + (p[1]<<16) + (p[2]<<8) + p[3];
     p += 4;
     return nVal;
 }
@@ -358,6 +358,24 @@ int HasVerticalGSUB( struct _TrueTypeFont* pTTFile )
     return pGlyphSubstitution ? +1 : 0;
 }
 
+void getTTFontLayoutCapabilities(FontLayoutCapabilities &rFontLayoutCapabilities, const unsigned char* pBase)
+{
+    // parse GSUB/GPOS header
+    const FT_Byte* pGsubHeader = pBase;
+    pGsubHeader+=4;
+    const USHORT nOfsScriptList = NEXT_UShort(pGsubHeader);
+
+    // parse Script Table
+    const FT_Byte* pScriptHeader = pBase + nOfsScriptList;
+    const USHORT nCntScript = NEXT_UShort(pScriptHeader);
+    for( USHORT nScriptIndex = 0; nScriptIndex < nCntScript; ++nScriptIndex )
+    {
+        sal_uInt32 nTag = NEXT_Long(pScriptHeader);
+        pScriptHeader += 2;
+        rFontLayoutCapabilities.push_back(nTag); // e.g. hani/arab/kana/hang
+    }
+}
+
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/gdi/outdev3.cxx b/vcl/source/gdi/outdev3.cxx
index dbe5dc2..9ba5e96 100644
--- a/vcl/source/gdi/outdev3.cxx
+++ b/vcl/source/gdi/outdev3.cxx
@@ -1499,41 +1499,22 @@ ImplDevFontListData* ImplDevFontList::GetGlyphFallbackFont( ImplFontSelectData&
 
 void ImplDevFontList::Add( ImplFontData* pNewData )
 {
-    int nAliasQuality = pNewData->mnQuality - 100;
-    String aMapNames = pNewData->maMapNames;
-    pNewData->maMapNames = String();
+    String aSearchName = pNewData->maName;
+    GetEnglishSearchFontName( aSearchName );
 
-    bool bKeepNewData = false;
-    xub_StrLen nMapNameIndex = 0;
-    while( true )
-    {
-        String aSearchName = pNewData->maName;
-        GetEnglishSearchFontName( aSearchName );
-
-        DevFontList::const_iterator it = maDevFontList.find( aSearchName );
-        ImplDevFontListData* pFoundData = NULL;
-        if( it != maDevFontList.end() )
-            pFoundData = (*it).second;
-
-        if( !pFoundData )
-        {
-            pFoundData = new ImplDevFontListData( aSearchName );
-            maDevFontList[ aSearchName ] = pFoundData;
-        }
-
-        bKeepNewData = pFoundData->AddFontFace( pNewData );
+    DevFontList::const_iterator it = maDevFontList.find( aSearchName );
+    ImplDevFontListData* pFoundData = NULL;
+    if( it != maDevFontList.end() )
+        pFoundData = (*it).second;
 
-        // add (another) font alias if available
-        // a font alias should never win against an original font with similar quality
-        if( aMapNames.Len() <= nMapNameIndex )
-            break;
-        if( bKeepNewData ) // try to recycle obsoleted object
-            pNewData = pNewData->CreateAlias();
-        bKeepNewData = false;
-        pNewData->mnQuality = nAliasQuality;
-        pNewData->maName = GetNextFontToken( aMapNames, nMapNameIndex );
+    if( !pFoundData )
+    {
+        pFoundData = new ImplDevFontListData( aSearchName );
+        maDevFontList[ aSearchName ] = pFoundData;
     }
 
+    bool bKeepNewData = pFoundData->AddFontFace( pNewData );
+
     if( !bKeepNewData )
         delete pNewData;
 }
@@ -7937,6 +7918,24 @@ BOOL OutputDevice::GetTextOutline( PolyPolygon& rPolyPoly,
     return TRUE;
 }
 
+bool OutputDevice::GetFontLayoutCapabilities( FontLayoutCapabilities& rFontLayoutCapabilities ) const
+{
+    rFontLayoutCapabilities.clear();
+
+    // we need a graphics
+    if( !mpGraphics && !ImplGetGraphics() )
+        return false;
+
+    if( mbNewFont )
+        ImplNewFont();
+    if( mbInitFont )
+        ImplInitFont();
+    if( !mpFontEntry )
+        return false;
+
+    return mpGraphics->GetImplFontLayoutCapabilities(rFontLayoutCapabilities);
+}
+
 // -----------------------------------------------------------------------
 
 BOOL OutputDevice::GetFontCharMap( FontCharMap& rFontCharMap ) const
diff --git a/vcl/source/glyphs/gcach_ftyp.cxx b/vcl/source/glyphs/gcach_ftyp.cxx
index cd27227..d5e3b82 100644
--- a/vcl/source/glyphs/gcach_ftyp.cxx
+++ b/vcl/source/glyphs/gcach_ftyp.cxx
@@ -48,6 +48,8 @@
 #include "osl/file.hxx"
 #include "osl/thread.hxx"
 
+#include "sft.hxx"
+
 #include <ft2build.h>
 #include FT_FREETYPE_H
 #include FT_GLYPH_H
@@ -590,7 +592,7 @@ long FreetypeManager::AddFontDir( const String& rUrlName )
                 aDFA.maName        = String::CreateFromAscii( aFaceFT->family_name );
 
             if ( aFaceFT->style_name )
-                aDFA.maStyleName   = String::CreateFromAscii( aFaceFT->style_name );
+                aDFA.maStyleName = String::CreateFromAscii( aFaceFT->style_name );
 
             aDFA.mbSymbolFlag = false;
             for( int i = aFaceFT->num_charmaps; --i >= 0; )
@@ -1768,6 +1770,31 @@ bool FreetypeServerFont::GetFontCodeRanges( CmapResult& rResult ) const
     return true;
 }
 
+bool FreetypeServerFont::GetFontLayoutCapabilities(FontLayoutCapabilities &rFontLayoutCapabilities) const
+{
+    rFontLayoutCapabilities.clear();
+
+    ULONG nLength = 0;
+    const FT_Byte* pBase;
+    // load GSUB table
+    pBase = mpFontInfo->GetTable("GSUB", &nLength);
+    if( pBase )
+        vcl::getTTFontLayoutCapabilities(rFontLayoutCapabilities, pBase);
+#if 0
+    //If there's any need for it, we could check the GPOS as well
+    // load GPOS table
+    pBase = mpFontInfo->GetTable("GPOS", &nLength);
+    if( pBase )
+        vcl::getTTFontLayoutCapabilities(rFontLayoutCapabilities, pBase);
+#endif
+
+    std::sort(rFontLayoutCapabilities.begin(), rFontLayoutCapabilities.end());
+    rFontLayoutCapabilities.erase(std::unique(rFontLayoutCapabilities.begin(), rFontLayoutCapabilities.end()),
+        rFontLayoutCapabilities.end());
+
+    return !rFontLayoutCapabilities.empty();
+}
+
 // -----------------------------------------------------------------------
 // kerning stuff
 // -----------------------------------------------------------------------
diff --git a/vcl/source/glyphs/gcach_ftyp.hxx b/vcl/source/glyphs/gcach_ftyp.hxx
index 0198ab2..ce5c56f 100644
--- a/vcl/source/glyphs/gcach_ftyp.hxx
+++ b/vcl/source/glyphs/gcach_ftyp.hxx
@@ -205,6 +205,7 @@ protected:
     int                         ApplyGlyphTransform( int nGlyphFlags, FT_GlyphRec_*, bool ) const;
     virtual void                InitGlyphData( int nGlyphIndex, GlyphData& ) const;
     virtual bool                GetFontCodeRanges( CmapResult& ) const;
+    virtual bool                GetFontLayoutCapabilities(FontLayoutCapabilities &) const;
     bool                        ApplyGSUB( const ImplFontSelectData& );
     virtual ServerFontLayoutEngine* GetLayoutEngine();
 
diff --git a/vcl/unx/headless/svpgdi.hxx b/vcl/unx/headless/svpgdi.hxx
index ed3396e..233b915 100644
--- a/vcl/unx/headless/svpgdi.hxx
+++ b/vcl/unx/headless/svpgdi.hxx
@@ -90,6 +90,7 @@ public:
     virtual void			GetFontMetric( ImplFontMetricData*, int nFallbackLevel );
     virtual ULONG			GetKernPairs( ULONG nPairs, ImplKernPairData* pKernPairs );
     virtual ImplFontCharMap* GetImplFontCharMap() const;
+    virtual bool GetImplFontLayoutCapabilities(FontLayoutCapabilities &rGetImplFontLayoutCapabilities) const;
     virtual void			GetDevFontList( ImplDevFontList* );
     virtual void			GetDevFontSubstList( OutputDevice* );
     virtual bool			AddTempDevFont( ImplDevFontList*, const String& rFileURL, const String& rFontName );
diff --git a/vcl/unx/headless/svppspgraphics.cxx b/vcl/unx/headless/svppspgraphics.cxx
index 7facb57..39c984f 100644
--- a/vcl/unx/headless/svppspgraphics.cxx
+++ b/vcl/unx/headless/svppspgraphics.cxx
@@ -696,6 +696,13 @@ ImplFontCharMap* PspGraphics::GetImplFontCharMap() const
     return new ImplFontCharMap( aCmapResult );
 }
 
+bool PspGraphics::GetImplFontLayoutCapabilities(FontLayoutCapabilities &rGetImplFontLayoutCapabilities) const
+{
+    if (!m_pServerFont[0])
+        return NULL;
+    return !m_pServerFont[0]->GetFontLayoutCapabilities(rGetImplFontLayoutCapabilities);
+}
+
 USHORT PspGraphics::SetFont( ImplFontSelectData *pEntry, int nFallbackLevel )
 {
     // release all fonts that are to be overridden
diff --git a/vcl/unx/headless/svppspgraphics.hxx b/vcl/unx/headless/svppspgraphics.hxx
index a438ef3..095f294 100644
--- a/vcl/unx/headless/svppspgraphics.hxx
+++ b/vcl/unx/headless/svppspgraphics.hxx
@@ -109,6 +109,7 @@ public:
     virtual void			GetFontMetric( ImplFontMetricData*, int nFallbackLevel );
     virtual ULONG			GetKernPairs( ULONG nPairs, ImplKernPairData* pKernPairs );
     virtual ImplFontCharMap* GetImplFontCharMap() const;
+    virtual bool GetImplFontLayoutCapabilities(FontLayoutCapabilities &rGetImplFontLayoutCapabilities) const;
     virtual void			GetDevFontList( ImplDevFontList* );
     virtual void			GetDevFontSubstList( OutputDevice* );
     virtual bool			AddTempDevFont( ImplDevFontList*, const String& rFileURL, const String& rFontName );
diff --git a/vcl/unx/headless/svptext.cxx b/vcl/unx/headless/svptext.cxx
index 71a9f34..7f7b8e4 100644
--- a/vcl/unx/headless/svptext.cxx
+++ b/vcl/unx/headless/svptext.cxx
@@ -282,6 +282,14 @@ ImplFontCharMap* SvpSalGraphics::GetImplFontCharMap() const
     return new ImplFontCharMap( aCmapResult );
 }
 
+bool SvpSalGraphics::GetImplFontLayoutCapabilities(FontLayoutCapabilities &rGetImplFontLayoutCapabilities) const
+{
+    if (!m_pServerFont[0])
+        return NULL;
+
+    return !m_pServerFont[0]->GetFontLayoutCapabilities( rGetImplFontLayoutCapabilities);
+}
+
 // ---------------------------------------------------------------------------
 
 void SvpSalGraphics::GetDevFontList( ImplDevFontList* pDevFontList )
diff --git a/vcl/unx/inc/pspgraphics.h b/vcl/unx/inc/pspgraphics.h
index 275c3a9..16f206e 100644
--- a/vcl/unx/inc/pspgraphics.h
+++ b/vcl/unx/inc/pspgraphics.h
@@ -106,6 +106,7 @@ public:
     virtual void			GetFontMetric( ImplFontMetricData*, int nFallbackLevel );
     virtual ULONG			GetKernPairs( ULONG nMaxPairs, ImplKernPairData* );
     virtual ImplFontCharMap* GetImplFontCharMap() const;
+    virtual bool GetImplFontLayoutCapabilities(FontLayoutCapabilities &rGetImplFontLayoutCapabilities) const;
     virtual void			GetDevFontList( ImplDevFontList* );
     virtual void			GetDevFontSubstList( OutputDevice* );
     virtual bool			AddTempDevFont( ImplDevFontList*, const String& rFileURL, const String& rFontName );
diff --git a/vcl/unx/inc/salgdi.h b/vcl/unx/inc/salgdi.h
index 938e220..cf67715 100644
--- a/vcl/unx/inc/salgdi.h
+++ b/vcl/unx/inc/salgdi.h
@@ -257,6 +257,7 @@ public:
     virtual void			GetFontMetric( ImplFontMetricData*, int nFallbackLevel );
     virtual ULONG			GetKernPairs( ULONG nMaxPairs, ImplKernPairData* );
     virtual ImplFontCharMap* GetImplFontCharMap() const;
+    virtual bool GetImplFontLayoutCapabilities(FontLayoutCapabilities &rGetImplFontLayoutCapabilities) const;
     virtual void			GetDevFontList( ImplDevFontList* );
     virtual void			GetDevFontSubstList( OutputDevice* );
     virtual bool			AddTempDevFont( ImplDevFontList*, const String& rFileURL, const String& rFontName );
diff --git a/vcl/unx/source/gdi/pspgraphics.cxx b/vcl/unx/source/gdi/pspgraphics.cxx
index 615b6d2..6ac39ee 100644
--- a/vcl/unx/source/gdi/pspgraphics.cxx
+++ b/vcl/unx/source/gdi/pspgraphics.cxx
@@ -780,6 +780,13 @@ ImplFontCharMap* PspGraphics::GetImplFontCharMap() const
     return new ImplFontCharMap( aCmapResult );
 }
 
+bool PspGraphics::GetImplFontLayoutCapabilities(FontLayoutCapabilities &rGetImplFontLayoutCapabilities) const
+{
+    if (!m_pServerFont[0])
+        return NULL;
+    return !m_pServerFont[0]->GetFontLayoutCapabilities(rGetImplFontLayoutCapabilities);
+}
+
 USHORT PspGraphics::SetFont( ImplFontSelectData *pEntry, int nFallbackLevel )
 {
     // release all fonts that are to be overridden
diff --git a/vcl/unx/source/gdi/salgdi3.cxx b/vcl/unx/source/gdi/salgdi3.cxx
index a2862cc..2a6dc92 100644
--- a/vcl/unx/source/gdi/salgdi3.cxx
+++ b/vcl/unx/source/gdi/salgdi3.cxx
@@ -1497,6 +1497,13 @@ ImplFontCharMap* X11SalGraphics::GetImplFontCharMap() const
     return new ImplFontCharMap( aCmapResult );
 }
 
+bool X11SalGraphics::GetImplFontLayoutCapabilities(FontLayoutCapabilities &rGetImplFontLayoutCapabilities) const
+{
+    if (!mpServerFont[0])
+        return NULL;
+    return !mpServerFont[0]->GetFontLayoutCapabilities(rGetImplFontLayoutCapabilities);
+}
+
 // ----------------------------------------------------------------------------
 //
 // SalGraphics
diff --git a/vcl/win/inc/salgdi.h b/vcl/win/inc/salgdi.h
index a562123..46c841c 100644
--- a/vcl/win/inc/salgdi.h
+++ b/vcl/win/inc/salgdi.h
@@ -84,6 +84,7 @@ public:
 #endif
 
     ImplFontCharMap*        GetImplFontCharMap() const;
+    bool GetImplFontLayoutCapabilities(FontLayoutCapabilities &rGetImplFontLayoutCapabilities) const;
     const Ucs2SIntMap* GetEncodingVector() const { return mpEncodingVector; }
     void SetEncodingVector( const Ucs2SIntMap* pNewVec ) const
     {
@@ -102,8 +103,10 @@ private:
     mutable bool                    mbHasGraphiteSupport;
 #endif
     mutable bool                    mbHasArabicSupport;
+    mutable bool                    mbFontLayoutCapabilitiesRead;
     mutable ImplFontCharMap*        mpUnicodeMap;
     mutable const Ucs2SIntMap*      mpEncodingVector;
+    mutable FontLayoutCapabilities  maFontLayoutCapabilities;
 
     // TODO: get rid of the members below needed to work with the Win9x non-unicode API
     BYTE*                   mpFontCharSets;     // all Charsets for the current font (used on W98 for kerning)
diff --git a/vcl/win/source/gdi/salgdi3.cxx b/vcl/win/source/gdi/salgdi3.cxx
index 5b119ea..6b4af9e 100644
--- a/vcl/win/source/gdi/salgdi3.cxx
+++ b/vcl/win/source/gdi/salgdi3.cxx
@@ -1107,6 +1107,7 @@ ImplWinFontData::ImplWinFontData( const ImplDevFontAttributes& rDFS,
     mbHasGraphiteSupport( false ),
 #endif
     mbHasArabicSupport ( false ),
+    mbFontLayoutCapabilities( false ),
     mbAliasSymbolsLow( false ),
     mbAliasSymbolsHigh( false ),
     mnId( 0 ),
@@ -1208,6 +1209,12 @@ ImplFontCharMap* ImplWinFontData::GetImplFontCharMap() const
     return mpUnicodeMap;
 }
 
+bool ImplWinFontData::GetImplFontLayoutCapabilities(FontLayoutCapabilities &rFontLayoutCapabilities) const
+{
+    rFontLayoutCapabilities = maFontLayoutCapabilities;
+    return !rFontLayoutCapabilities.empty();
+}
+
 // -----------------------------------------------------------------------
 
 static unsigned GetUInt( const unsigned char* p ) { return((p[0]<<24)+(p[1]<<16)+(p[2]<<8)+p[3]);}
@@ -1312,6 +1319,23 @@ void ImplWinFontData::ReadCmapTable( HDC hDC ) const
         mpUnicodeMap = ImplFontCharMap::GetDefaultMap( bIsSymbolFont );
 }
 
+void ImplWinFontData::GetFontLayoutCapabilities( HDC hDC ) const
+{
+    mbFontLayoutCapabilitiesRead = true;
+
+    // check the existence of a GSUB table
+    const DWORD GsubTag = CalcTag( "GSUB" );
+    DWORD nLength = ::GetFontData( hDC, GsubTag, 0, NULL, 0 );
+    if( (nLength == GDI_ERROR) || !nLength )
+        return;
+
+    std::vector<unsigned char> aTable( nLength );
+    unsigned char* pTable = &Table[0];
+    ::GetFontData( hDC, GsubTag, 0, pTable, nLength );
+
+    vcl::getTTFontLayoutCapabilities(maFontLayoutCapabilities, pTable);
+}
+
 // =======================================================================
 
 void WinSalGraphics::SetTextColor( SalColor nSalColor )
@@ -1854,6 +1878,13 @@ ImplFontCharMap* WinSalGraphics::GetImplFontCharMap() const
     return mpWinFontData[0]->GetImplFontCharMap();
 }
 
+bool WinSalGraphics::GetImplFontLayoutCapabilities(FontLayoutCapabilities &rFontLayoutCapabilities) const
+{
+    if( !mpWinFontData[0] )
+        return false;
+    return mpWinFontData[0]->GetImplFontLayoutCapabilities(rFontLayoutCapabilities);
+}
+
 // -----------------------------------------------------------------------
 
 int CALLBACK SalEnumFontsProcExA( const ENUMLOGFONTEXA* pLogFont,
commit a8e88da77e8f73ee2d55249361db9115d454679e
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sun Feb 6 13:46:45 2011 +0000

    Resolves: fdo#33510 better font preview for Arabic/CTL fonts

diff --git a/svtools/source/control/ctrlbox.cxx b/svtools/source/control/ctrlbox.cxx
index 2282e91..8ccd18c 100644
--- a/svtools/source/control/ctrlbox.cxx
+++ b/svtools/source/control/ctrlbox.cxx
@@ -52,9 +52,6 @@
 #define EXTRAFONTSIZE 5
 #define MAXPREVIEWWIDTH 150
 
-static sal_Unicode aImplSymbolFontText[] = {0xF021,0xF032,0xF043,0xF054,0xF065,0xF076,0xF0B7,0xF0C8,0};
-static sal_Unicode aImplStarSymbolText[] = {0x2706,0x2704,0x270D,0xE033,0x2211,0x2288,0};
-
 using namespace ::com::sun::star;
 
 // ========================================================================
@@ -894,10 +891,224 @@ void FontNameBox::ImplCalcUserItemSize()
     SetUserItemSize( aUserItemSz );
 }
 
-#define MKTAG(s) ((((((s[0]<<8)+s[1])<<8)+s[2])<<8)+s[3])
+#define MKTAG(s) sal_uInt32((((((s[0]<<8)+s[1])<<8)+s[2])<<8)+s[3])
 
 namespace
 {
+    rtl::OUString getRepresentativeText(sal_uInt32 nScript)
+    {
+        rtl::OUString sSampleText;
+        if (nScript == MKTAG("arab"))
+        {
+            const sal_Unicode aArab[] = {
+                0x0623, 0x0628, 0x062C, 0x062F, 0x064A, 0x0629, 0x0020, 0x0639,
+                0x0631, 0x0628, 0x064A, 0x0629
+            };
+            sSampleText = rtl::OUString(aArab, SAL_N_ELEMENTS(aArab));
+        }
+        else if (nScript == MKTAG("cyrl"))
+        {
+            const sal_Unicode aCyrl[] = {
+                0x041A, 0x0438, 0x0440, 0x0438, 0x043B, 0x043B, 0x0438, 0x0446,
+                0x0430
+            };
+            sSampleText = rtl::OUString(aCyrl, SAL_N_ELEMENTS(aCyrl));
+        }
+        else if (nScript == MKTAG("beng"))
+        {
+            const sal_Unicode aBeng[] = {
+                0x09AC, 0x09BE, 0x0982, 0x09B2, 0x09BE, 0x0020, 0x09B2, 0x09BF,
+                0x09AA, 0x09BF
+            };
+            sSampleText = rtl::OUString(aBeng, SAL_N_ELEMENTS(aBeng));
+        }
+        else if (nScript == MKTAG("deva"))
+        {
+            const sal_Unicode aDeva[] = {
+                0x0926, 0x0947, 0x0935, 0x0928, 0x093E, 0x0917, 0x0930, 0x0940
+            };
+            sSampleText = rtl::OUString(aDeva, SAL_N_ELEMENTS(aDeva));
+        }
+        else if (nScript == MKTAG("ethi"))
+        {
+            const sal_Unicode aEthi[] = {
+                0x130D, 0x12D5, 0x12DD
+            };
+            sSampleText = rtl::OUString(aEthi, SAL_N_ELEMENTS(aEthi));
+        }
+        else if (nScript == MKTAG("grek"))
+        {
+            const sal_Unicode aGrek[] = {
+                0x0391, 0x03BB, 0x03C6, 0x03AC, 0x03B2, 0x03B7, 0x03C4, 0x03BF
+            };
+            sSampleText = rtl::OUString(aGrek, SAL_N_ELEMENTS(aGrek));
+        }
+        else if (nScript == MKTAG("gujr"))
+        {
+            const sal_Unicode aGujr[] = {
+                0x0A97, 0x0AC1, 0x0A9C, 0x0AB0, 0x0ABE, 0x0AA4, 0x0aC0, 0x0020,
+                0x0AB2, 0x0ABF, 0x0AAA, 0x0ABF
+            };
+            sSampleText = rtl::OUString(aGujr, SAL_N_ELEMENTS(aGujr));
+        }
+        else if (nScript == MKTAG("guru"))
+        {
+            const sal_Unicode aGuru[] = {
+                0x0A17, 0x0A41, 0x0A30, 0x0A2E, 0x0A41, 0x0A16, 0x0A40
+            };
+            sSampleText = rtl::OUString(aGuru, SAL_N_ELEMENTS(aGuru));
+        }
+        else if (nScript == MKTAG("hani"))
+        {
+            const sal_Unicode aHani[] = {
+                0x6C49, 0x5B57
+            };
+            sSampleText = rtl::OUString(aHani, SAL_N_ELEMENTS(aHani));
+        }
+        else if (nScript == MKTAG("hebr"))
+        {
+            const sal_Unicode aHebr[] = {
+                0x05D0, 0x05B8, 0x05DC, 0x05B6, 0x05E3, 0x05D1, 0x05B5, 0x05BC,
+                0x05D9, 0x05EA, 0x0020, 0x05E2, 0x05B4, 0x05D1, 0x05B0, 0x05E8,
+                0x05B4, 0x05D9
+            };
+            sSampleText = rtl::OUString(aHebr, SAL_N_ELEMENTS(aHebr));
+        }
+        else if (nScript == MKTAG("kana"))
+        {
+            const sal_Unicode aKana[] = {
+                0x7247, 0x4EEE, 0x540D
+            };
+            sSampleText = rtl::OUString(aKana, SAL_N_ELEMENTS(aKana));
+        }
+        else if (nScript == MKTAG("khmr"))
+        {
+            const sal_Unicode aKhmr[] = {
+                0x17A2, 0x1780, 0x17D2, 0x1781, 0x179A, 0x1780, 0x17D2, 0x179A,
+                0x1798, 0x1781, 0x17C1, 0x1798, 0x179A, 0x1797, 0x17B6, 0x179F,
+                0x17B6
+            };
+            sSampleText = rtl::OUString(aKhmr, SAL_N_ELEMENTS(aKhmr));
+        }
+        else if (nScript == MKTAG("knda"))
+        {
+            const sal_Unicode aKnda[] = {
+                0x0C95, 0x0CA8, 0x0CCD, 0x0CA8, 0x0CA1, 0x0020, 0x0CB2, 0x0CBF,
+                0x0CAA, 0x0CBF
+            };
+            sSampleText = rtl::OUString(aKnda, SAL_N_ELEMENTS(aKnda));
+        }
+        else if (nScript == MKTAG("latf"))
+            sSampleText = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Fraktur"));
+        else if (nScript == MKTAG("latn"))
+            sSampleText = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Latin"));
+        else if (nScript == MKTAG("latg"))
+        {
+            const sal_Unicode aLatg[] = {
+              0x0063, 0x006C, 0x00F3, 0x0020, 0x0047, 0x0061, 0x0065, 0x006C,
+              0x0061, 0x0063, 0x0068
+            };
+            sSampleText = rtl::OUString(aLatg, SAL_N_ELEMENTS(aLatg));
+        }
+        else if (nScript == MKTAG("mlym"))
+        {
+            const sal_Unicode aMlym[] = {
+                0x0D2E, 0x0D32, 0x0D2F, 0x0D3E, 0x0D33, 0x0D32, 0x0D3F, 0x0D2A,
+                0x0D3F
+            };
+            sSampleText = rtl::OUString(aMlym, SAL_N_ELEMENTS(aMlym));
+        }
+        else if (nScript == MKTAG("mymr"))
+        {
+            const sal_Unicode aMymr[] = {
+                0x1019, 0x103C, 0x1014, 0x103A, 0x1019, 0x102C, 0x1021, 0x1000,
+                0x1039, 0x1001, 0x101B, 0x102C
+            };
+            sSampleText = rtl::OUString(aMymr, SAL_N_ELEMENTS(aMymr));
+        }
+        else if (nScript == MKTAG("orya"))
+        {
+            const sal_Unicode aOrya[] = {
+                0x0B09, 0x0B24, 0x0B4D, 0x0B15, 0x0B33, 0x0020, 0x0B32, 0x0B3F,
+                0x0B2A, 0x0B3F
+            };
+            sSampleText = rtl::OUString(aOrya, SAL_N_ELEMENTS(aOrya));
+        }
+        else if (nScript == MKTAG("thai"))
+        {
+            const sal_Unicode aThai[] = {
+                0x0E2D, 0x0E31, 0x0E01, 0x0E29, 0x0E23, 0x0E44, 0x0E17, 0x0E22
+            };
+            sSampleText = rtl::OUString(aThai, SAL_N_ELEMENTS(aThai));
+        }
+        else if (nScript == MKTAG("taml"))
+        {
+            const sal_Unicode aTaml[] = {
+                0x0B85, 0x0BB0, 0x0BBF, 0x0B9A, 0x0BCD, 0x0B9A, 0x0BC1, 0x0BB5,
+                0x0B9F, 0x0BBF
+            };
+            sSampleText = rtl::OUString(aTaml, SAL_N_ELEMENTS(aTaml));
+        }
+        else if (nScript == MKTAG("telu"))
+        {
+            const sal_Unicode aTelu[] = {
+                0x0C24, 0x0C46, 0x0C32, 0x0C41, 0x0C17, 0x0C41
+            };
+            sSampleText = rtl::OUString(aTelu, SAL_N_ELEMENTS(aTelu));
+        }
+        else if (nScript == MKTAG("tibt"))
+        {
+            const sal_Unicode aTibt[] = {
+                0x0F51, 0x0F56, 0x0F74, 0x0F0B, 0x0F45, 0x0F53, 0x0F0B
+            };
+            sSampleText = rtl::OUString(aTibt, SAL_N_ELEMENTS(aTibt));
+        }
+        else if (nScript == MKTAG("sinh"))
+        {
+            const sal_Unicode aSinh[] = {
+                0x0DC1, 0x0DD4, 0x0DAF, 0x0DCA, 0x0DB0, 0x0020, 0x0DC3, 0x0DD2,
+                0x0D82, 0x0DC4, 0x0DBD
+            };
+            sSampleText = rtl::OUString(aSinh, SAL_N_ELEMENTS(aSinh));
+        }
+        else if (nScript == (MKTAG("hani") | MKTAG("kana")))
+        {
+            const sal_Unicode aKana[] = {
+                0x7247, 0x4EEE, 0x540D, ' ', 0x6C49, 0x5B57
+            };
+            sSampleText = rtl::OUString(aKana, SAL_N_ELEMENTS(aKana));
+        }
+
+        return sSampleText;
+    }
+
+    sal_uInt32 getSingleNonLatnTag(const FontLayoutCapabilities &rFontLayoutCapabilities)
+    {
+        FontLayoutCapabilities aTmp(rFontLayoutCapabilities);
+
+        aTmp.erase(std::remove(aTmp.begin(), aTmp.end(), MKTAG("DFLT")), aTmp.end());
+        aTmp.erase(std::remove(aTmp.begin(), aTmp.end(), MKTAG("dflt")), aTmp.end());
+        aTmp.erase(std::remove(aTmp.begin(), aTmp.end(), MKTAG("latn")), aTmp.end());
+
+        //Tuned for a single non-latin script
+        if (aTmp.size() == 1)
+            return aTmp[0];
+
+        aTmp.erase(std::remove(aTmp.begin(), aTmp.end(), MKTAG("deva")), aTmp.end());
+
+        //Probably strongly tuned for a single Indic script
+        if (aTmp.size() == 1)
+            return aTmp[0];
+
+        if (aTmp.size() == 2)
+        {
+            const sal_uInt32 nHaniKaniTag = MKTAG("hani") | MKTAG("kana");
+            if ((aTmp[0] | aTmp[1]) == nHaniKaniTag)
+                return nHaniKaniTag;
+        }
+        return 0;
+    }
+
     rtl::OUString makeRepresentativeSymbolText(bool bOpenSymbol, OutputDevice &rDevice)
     {
         rtl::OUString sSampleText;
@@ -911,11 +1122,11 @@ namespace
 
             // start just above the PUA used by most symbol fonts
             sal_uInt32 cNewChar = 0xFF00;
-    #ifdef QUARTZ
+#ifdef QUARTZ
             // on MacOSX there are too many non-presentable symbols above the codepoint 0x0192
             if( !bOpenSymbol )
                 cNewChar = 0x0192;
-    #endif
+#endif
 
             const int nMaxCount = sizeof(aText)/sizeof(*aText) - 1;
             int nSkip = aFontCharMap.GetCharCount() / nMaxCount;
@@ -938,9 +1149,15 @@ namespace
         }
         else
         {
+            static sal_Unicode aImplSymbolFontText[] = {
+                0xF021,0xF032,0xF043,0xF054,0xF065,0xF076,0xF0B7,0xF0C8,0};
             const sal_Unicode* pText = aImplSymbolFontText;
             if( bOpenSymbol )
+            {
+                static sal_Unicode aImplStarSymbolText[] = {
+                    0x2706,0x2704,0x270D,0xE033,0x2211,0x2288,0};
                 pText = aImplStarSymbolText;
+            }
             sSampleText = rtl::OUString(pText);
         }
 
@@ -1077,13 +1294,73 @@ void FontNameBox::UserDraw( const UserDrawEvent& rUDEvt )
         rtl::OUString sSampleText;
         bool bHasSampleTextGlyphs=false;
 
-        //TO-DO: for non-symbol fonts pull GPOS/GSUB features through vcl to
-        //and map to suitable strings for Arabic, Hebrew, etc fonts
+        if (!bSymbolFont)
+        {
+            const bool bNameBeginsWithLatinText = rInfo.GetName().GetChar(0) <= 'z';
+            if (bNameBeginsWithLatinText)
+            {
+                //If this font is probably tuned to display a single non-Latin
+                //script and the font name is itself in Latin, then show a small
+                //chunk of representative text for that script
+                FontLayoutCapabilities aFontLayoutCapabilities;
+                rUDEvt.GetDevice()->GetFontLayoutCapabilities( aFontLayoutCapabilities );
+                sal_uInt32 nLangTag = getSingleNonLatnTag(aFontLayoutCapabilities);
+                if (nLangTag)
+                {
+                    sSampleText = getRepresentativeText(nLangTag);
+                    bHasSampleTextGlyphs = (STRING_LEN == rUDEvt.GetDevice()->HasGlyphs(aFont, sSampleText));
+                    if (!bHasSampleTextGlyphs && (nLangTag == (MKTAG("hani")|MKTAG("kana"))))
+                    {
+                        sSampleText = getRepresentativeText(MKTAG("kana"));
+                        bHasSampleTextGlyphs = (STRING_LEN == rUDEvt.GetDevice()->HasGlyphs(aFont, sSampleText));
+                        if (!bHasSampleTextGlyphs)
+                        {
+                            sSampleText = getRepresentativeText(MKTAG("hani"));
+                            bHasSampleTextGlyphs = (STRING_LEN == rUDEvt.GetDevice()->HasGlyphs(aFont, sSampleText));
+                        }
+                    }
+                }
+            }
+        }
+
+        //If we're not a symbol font, but could neither render our own name and
+        //we can't determine what script it would like to render, then try a
+        //few well known scripts
+        if (!sSampleText.getLength() && !bUsingCorrectFont)
+        {
+            static const sal_Int32 tags[] =
+            {
+                MKTAG("arab"), MKTAG("hebr"),
+
+                MKTAG("beng"), MKTAG("gujr"), MKTAG("guru"), MKTAG("knda"),
+                MKTAG("mlym"), MKTAG("mymr"), MKTAG("orya"), MKTAG("taml"),
+                MKTAG("telu"), MKTAG("sinh"),
+
+                MKTAG("tibt"), MKTAG("thai"), MKTAG("khmr"), MKTAG("ethi"),
+
+                (MKTAG("hani")|MKTAG("kana")), MKTAG("hani"), MKTAG("kana"),
+
+                MKTAG("deva"),
+
+                MKTAG("grek"), MKTAG("cyrl")
+            };
+
+            for (size_t i = 0; i < SAL_N_ELEMENTS(tags); ++i)
+            {
+                sSampleText = getRepresentativeText(tags[i]);
+                if (sSampleText.getLength())
+                {
+                    bHasSampleTextGlyphs = (STRING_LEN == rUDEvt.GetDevice()->HasGlyphs(aFont, sSampleText));
+                    if (bHasSampleTextGlyphs)
+                        break;
+                }
+            }
+        }
 
         //If we're a symbol font, or for some reason the font still couldn't
         //render something representative of what it would like to render then
         //make up some semi-random text that it *can* display
-        if (bSymbolFont || !bUsingCorrectFont)
+        if (bSymbolFont || (!bUsingCorrectFont && !bHasSampleTextGlyphs))
         {
             sSampleText = makeRepresentativeSymbolText(bOpenSymbol, *rUDEvt.GetDevice());
             bHasSampleTextGlyphs = (STRING_LEN == rUDEvt.GetDevice()->HasGlyphs(aFont, sSampleText));


More information about the Libreoffice-commits mailing list