[Libreoffice-commits] core.git: vcl/inc vcl/unx

Caolán McNamara caolanm at redhat.com
Wed Nov 23 20:37:09 UTC 2016


 vcl/inc/unx/fc_fontoptions.hxx                 |    3 ++-
 vcl/inc/unx/glyphcache.hxx                     |    2 +-
 vcl/unx/generic/fontmanager/fontconfig.cxx     |    8 ++++++--
 vcl/unx/generic/gdi/cairotextrender.cxx        |    6 +++---
 vcl/unx/generic/glyphs/freetype_glyphcache.cxx |    8 ++++++++
 5 files changed, 20 insertions(+), 7 deletions(-)

New commits:
commit 4129da25f71f9082c54a3e53dd96927c2bbbe45e
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Nov 23 16:01:37 2016 +0000

    reorg a bit and ensure FontConfigFontOptions is always available
    
    Change-Id: Ie671be765ea1d188480a399ae201081a774cb0c0

diff --git a/vcl/inc/unx/fc_fontoptions.hxx b/vcl/inc/unx/fc_fontoptions.hxx
index 340df27..48661de 100644
--- a/vcl/inc/unx/fc_fontoptions.hxx
+++ b/vcl/inc/unx/fc_fontoptions.hxx
@@ -51,7 +51,8 @@ public:
     bool                DontUseEmbeddedBitmaps() const { return meEmbeddedBitmap == EMBEDDEDBITMAP_FALSE; }
     bool                DontUseAntiAlias() const { return meAntiAlias == ANTIALIAS_FALSE; }
     bool                DontUseHinting() const { return (meHinting == FontHinting::No) || (GetHintStyle() == FontHintStyle::NONE); }
-    FcPattern*          GetPattern(const OString& rFileName, int nFontFace, bool bEmbolden) const;
+    void                SyncPattern(const OString& rFileName, int nFontFace, bool bEmbolden);
+    FcPattern*          GetPattern() const;
 private:
     FcPattern* mpPattern;
 };
diff --git a/vcl/inc/unx/glyphcache.hxx b/vcl/inc/unx/glyphcache.hxx
index 15afbcd..9d3f011 100644
--- a/vcl/inc/unx/glyphcache.hxx
+++ b/vcl/inc/unx/glyphcache.hxx
@@ -230,7 +230,7 @@ private:
     FT_FaceRec_*            maFaceFT;
     FT_SizeRec_*            maSizeFT;
 
-    std::shared_ptr<FontConfigFontOptions> mxFontOptions;
+    mutable std::shared_ptr<FontConfigFontOptions> mxFontOptions;
 
     bool                    mbFaceOk;
     bool                    mbArtItalic;
diff --git a/vcl/unx/generic/fontmanager/fontconfig.cxx b/vcl/unx/generic/fontmanager/fontconfig.cxx
index 6b4c8e6..81285eb 100644
--- a/vcl/unx/generic/fontmanager/fontconfig.cxx
+++ b/vcl/unx/generic/fontmanager/fontconfig.cxx
@@ -1154,7 +1154,12 @@ FontConfigFontOptions::~FontConfigFontOptions()
     FcPatternDestroy(mpPattern);
 }
 
-FcPattern *FontConfigFontOptions::GetPattern(const OString& rFileName, int nIndex, bool bEmbolden) const
+FcPattern *FontConfigFontOptions::GetPattern() const
+{
+    return mpPattern;
+}
+
+void FontConfigFontOptions::SyncPattern(const OString& rFileName, int nIndex, bool bEmbolden)
 {
     FcPatternDel(mpPattern, FC_FILE);
     FcPatternAddString(mpPattern, FC_FILE, reinterpret_cast<FcChar8 const *>(rFileName.getStr()));
@@ -1162,7 +1167,6 @@ FcPattern *FontConfigFontOptions::GetPattern(const OString& rFileName, int nInde
     FcPatternAddInteger(mpPattern, FC_INDEX, nIndex);
     FcPatternDel(mpPattern, FC_EMBOLDEN);
     FcPatternAddBool(mpPattern, FC_EMBOLDEN, bEmbolden ? FcTrue : FcFalse);
-    return mpPattern;
 }
 
 FontConfigFontOptions* PrintFontManager::getFontOptions(
diff --git a/vcl/unx/generic/gdi/cairotextrender.cxx b/vcl/unx/generic/gdi/cairotextrender.cxx
index cce0312..9bbfaa7 100644
--- a/vcl/unx/generic/gdi/cairotextrender.cxx
+++ b/vcl/unx/generic/gdi/cairotextrender.cxx
@@ -64,7 +64,7 @@ public:
     struct CacheId
     {
         FT_Face maFace;
-        const void *mpOptions;
+        const FontConfigFontOptions *mpOptions;
         bool mbEmbolden;
         bool mbVerticalMetrics;
         bool operator ==(const CacheId& rOther) const
@@ -288,8 +288,8 @@ void CairoTextRender::DrawServerFontLayout( const GenericSalLayout& rLayout, con
         cairo_font_face_t* font_face = static_cast<cairo_font_face_t*>(CairoFontsCache::FindCachedFont(aId));
         if (!font_face)
         {
-            const FontConfigFontOptions *pOptions = rFont.GetFontOptions().get();
-            FcPattern *pPattern = pOptions->GetPattern(rFont.GetFontFileName(), rFont.GetFontFaceIndex(), aId.mbEmbolden);
+            const FontConfigFontOptions *pOptions = aId.mpOptions;
+            FcPattern *pPattern = pOptions->GetPattern();
             font_face = cairo_ft_font_face_create_for_pattern(pPattern);
             CairoFontsCache::CacheFont(font_face, aId);
         }
diff --git a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx
index 0bacb94..f8dc3da 100644
--- a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx
+++ b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx
@@ -588,8 +588,16 @@ void FreetypeFont::SetFontOptions(const std::shared_ptr<FontConfigFontOptions>&
         mnLoadFlags |= FT_LOAD_NO_BITMAP;
 }
 
+extern FontConfigFontOptions* GetFCFontOptions( const FontAttributes& rFontAttributes, int nSize);
+
 const std::shared_ptr<FontConfigFontOptions>& FreetypeFont::GetFontOptions() const
 {
+    if (!mxFontOptions)
+    {
+        SAL_WARN("vcl", "this doesn't happen in practice I believe");
+        mxFontOptions.reset(GetFCFontOptions(mpFontInfo->GetFontAttributes(), maFontSelData.mnHeight));
+    }
+    mxFontOptions->SyncPattern(GetFontFileName(), GetFontFaceIndex(), NeedsArtificialBold());
     return mxFontOptions;
 }
 


More information about the Libreoffice-commits mailing list