[Libreoffice-commits] .: 2 commits - vcl/inc vcl/source vcl/win

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Dec 21 17:05:14 PST 2012


 vcl/inc/outdev.h                 |    4 ----
 vcl/source/gdi/outdev3.cxx       |   26 --------------------------
 vcl/win/source/gdi/winlayout.cxx |    9 +++++++++
 3 files changed, 9 insertions(+), 30 deletions(-)

New commits:
commit bb51791ae49ecded0f618b4534893adb8fcf917e
Author: Michael Stahl <mstahl at redhat.com>
Date:   Wed Dec 19 21:03:53 2012 +0100

    fdo#38090: vcl: remove ImplFontCache::maFontNameList:
    
    The font cache in VCL returns different fonts for identical parameters,
    which causes layout differences in Writer.
    
    first we search the font with language 1054:
     debug: XXX 0x2103950   add to maFontNameList: TH SarabunPSK->waree
     p maFontNameList
     $9 = boost::unordered_map with 1 elements = {
       ["TH SarabunPSK"] = "waree"
     debug: XXX 0x2103950 found in maFontNameList: TH SarabunPSK->waree
    in this very same invocation the "waree" is then rerouted to Deja Vu
    (which can only be because it was called with language 1033):
     debug: XXX 0x2103950   add to maFontNameList: TH SarabunPSK->dejavusans
     p maFontNameList
     $11 = boost::unordered_map with 1 elements = {
       ["TH SarabunPSK"] = "dejavusans"
     }
     debug: XXX 0x2103950 found in maFontNameList: TH SarabunPSK->dejavusans
    
    - the selection of different fonts happens in
      FcPreMatchSubstititution::FindFontSubstitute.
    - we never get a direct cache hit from maFontInstanceList because there
      are some differences like WIDTH_DONTKNOW, and the maSearchName
    - the first time a font is searched, it ends up in maFontInstanceList
    - the second time a font is searched, it may end up in maFontNameList,
      which maps _only_ based on the name (appears to be an invalid optimization)
    - once we have TH SarabunPSK->dejavusans in maFontNameList we can never
      select the other one because apparently dejavusans covers all languages
    
    Change-Id: Ibd73de88d8fc3b6e1319eb34c261e55ea217a988

diff --git a/vcl/inc/outdev.h b/vcl/inc/outdev.h
index a37f2a9..20c1d36 100644
--- a/vcl/inc/outdev.h
+++ b/vcl/inc/outdev.h
@@ -210,10 +210,6 @@ private:
     typedef ::boost::unordered_map<FontSelectPattern,ImplFontEntry*,IFSD_Hash,IFSD_Equal > FontInstanceList;
     FontInstanceList    maFontInstanceList;
 
-    // cache of recently requested font names vs. selected font names
-    typedef ::boost::unordered_map<String,String,FontNameHash> FontNameList;
-    FontNameList        maFontNameList;
-
 public:
                         ImplFontCache( bool bPrinter );
                         ~ImplFontCache();
diff --git a/vcl/source/gdi/outdev3.cxx b/vcl/source/gdi/outdev3.cxx
index c769458..db9cb8d 100644
--- a/vcl/source/gdi/outdev3.cxx
+++ b/vcl/source/gdi/outdev3.cxx
@@ -2344,22 +2344,6 @@ ImplFontEntry* ImplFontCache::GetFontEntry( ImplDevFontList* pFontList,
 {
     String aSearchName = rFont.GetName();
 
-    // TODO: also add device specific name caching
-    if( !pDevSpecific )
-    {
-        // check if the requested font name is already known
-        // if it is already known get its normalized search name
-        FontNameList::const_iterator it_name = maFontNameList.find( aSearchName );
-        if( it_name != maFontNameList.end() )
-            if( !(*it_name).second.EqualsAscii( "hg", 0, 2)
-#ifdef ENABLE_GRAPHITE
-                && (aSearchName.Search(grutils::GrFeatureParser::FEAT_PREFIX)
-                    == STRING_NOTFOUND)
-#endif
-            )
-                aSearchName = (*it_name).second;
-    }
-
     // initialize internal font request object
     FontSelectPattern aFontSelData( rFont, aSearchName, rSize, fExactHeight );
     return GetFontEntry( pFontList, aFontSelData, pDevSpecific );
@@ -2398,16 +2382,6 @@ ImplFontEntry* ImplFontCache::GetFontEntry( ImplDevFontList* pFontList,
         {
             // we have an indirect cache hit
             pEntry = (*it).second;
-            // cache the requested and the selected font names
-            // => next time there is a good chance for a direct cache hit
-            // don't allow the cache to grow too big
-            // TODO: implement some fancy LRU caching?
-            if( maFontNameList.size() >= 4000 )
-                maFontNameList.clear();
-            // TODO: also add device specific name caching
-            if( !pDevSpecific )
-                if( aFontSelData.maName != aFontSelData.maSearchName )
-                    maFontNameList[ aFontSelData.maName ] = aFontSelData.maSearchName;
         }
     }
 
commit cec68bceba9aa1e984d74897fcd7bf4db702d14b
Author: Michael Stahl <mstahl at redhat.com>
Date:   Sat Dec 22 01:53:09 2012 +0100

    fdo#47553: UniscribeLayout: adjust mnSubStringMin
    
    ... to actual minimum so that the fix for fdo#33090 in
    UniscribeLayout::GetNextGlyphs subtracts exactly the right number.
    
    The original value of mnSubStringMin is guessed and may be up to 8
    smaller than the actual start of the first VisualItem.
    
    For the bugdoc it happens that sometimes it's too small by 8 and then
    the wrong entries in mpGlyphs2Chars are initialized and then apparently
    there are single glyphs that represent multiple characters and so
    GetNextGlyphs returns a -1 character which is invalid.
    
     ->GetNextGlyphs dir 1 36 mnSubStringMin 28
     ->GetNextGlyphs g2c #1 [8] = 36
     ->GetNextGlyphs g2c #1 [9] = 37
     ->GetNextGlyphs g2c #1 [10] = 38
     ->GetNextGlyphs g2c #1 [11] = 39
     ->GetNextGlyphs g2c #1 [12] = 40
     ->GetNextGlyphs g2c #2 [4] = 40
     ->GetNextGlyphs g2c #2 [3] = 39
     ->GetNextGlyphs g2c #2 [1] = 38
     ->GetNextGlyphs g2c #2 [1] = 37
     ->GetNextGlyphs g2c #2 [0] = 36
    ...
     ->GetNextGlyphs init nCharPos -1
     ->GetNextGlyphs g2c [2]  nCharPos -1
     ->GetNextGlyphs set pCharPosAry -1
    layout[0]->GetNextGlyphs 768,1024 a1800 c-1 0
    
    Change-Id: Ie33ec797a412aa898bec3f4e8f97b88dcfed4d11

diff --git a/vcl/win/source/gdi/winlayout.cxx b/vcl/win/source/gdi/winlayout.cxx
index fcc5fdc..abd5144 100644
--- a/vcl/win/source/gdi/winlayout.cxx
+++ b/vcl/win/source/gdi/winlayout.cxx
@@ -1331,6 +1331,12 @@ bool UniscribeLayout::LayoutText( ImplLayoutArgs& rArgs )
         {
             for( int j = rVisualItem.mnMinCharPos; j < rVisualItem.mnEndCharPos; ++j )
                 mpLogClusters[j] = sal::static_int_cast<WORD>(~0U);
+            if (rArgs.mnMinCharPos >= rVisualItem.mnEndCharPos)
+            {   // fdo#47553 adjust "guessed" min (maybe up to -8 off) to
+                // actual min so it can be used properly in GetNextGlyphs
+                assert(mnSubStringMin <= rVisualItem.mnEndCharPos);
+                mnSubStringMin = rVisualItem.mnEndCharPos;
+            }
             continue;
         }
 
@@ -1785,7 +1791,10 @@ int UniscribeLayout::GetNextGlyphs( int nLen, sal_GlyphId* pGlyphs, Point& rPos,
         int nGlyphWidth = pGlyphWidths[ nStart ];
         int nCharPos = -1;    // no need to determine charpos
         if( mpGlyphs2Chars )  // unless explicitly requested+provided
+        {
             nCharPos = mpGlyphs2Chars[ nStart ];
+            assert(-1 != nCharPos);
+        }
 
         // inject kashida glyphs if needed
         if( !mbDisableGlyphInjection


More information about the Libreoffice-commits mailing list