diff options
author | Caolán McNamara <caolanm@redhat.com> | 2016-11-23 16:01:37 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2016-11-23 20:36:30 +0000 |
commit | 4129da25f71f9082c54a3e53dd96927c2bbbe45e (patch) | |
tree | 2b9bed51d9f3eb0dce8bb2a7e37e4ab4ccc2c502 /vcl/unx | |
parent | This code is only ever compiled on Unix (diff) | |
download | core-4129da25f71f9082c54a3e53dd96927c2bbbe45e.tar.gz core-4129da25f71f9082c54a3e53dd96927c2bbbe45e.zip |
reorg a bit and ensure FontConfigFontOptions is always available
Change-Id: Ie671be765ea1d188480a399ae201081a774cb0c0
Diffstat (limited to 'vcl/unx')
-rw-r--r-- | vcl/unx/generic/fontmanager/fontconfig.cxx | 8 | ||||
-rw-r--r-- | vcl/unx/generic/gdi/cairotextrender.cxx | 6 | ||||
-rw-r--r-- | vcl/unx/generic/glyphs/freetype_glyphcache.cxx | 8 |
3 files changed, 17 insertions, 5 deletions
diff --git a/vcl/unx/generic/fontmanager/fontconfig.cxx b/vcl/unx/generic/fontmanager/fontconfig.cxx index 6b4c8e6ed9d6..81285ebcb518 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 cce03121916b..9bbfaa72c9ac 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 0bacb9455958..f8dc3daadc3f 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; } |