diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2017-12-26 15:58:21 +0100 |
---|---|---|
committer | Khaled Hosny <khaledhosny@eglug.org> | 2018-05-07 23:03:37 +0200 |
commit | 083b7ca26bbf4b9bad2922520caaf5c0227dac5e (patch) | |
tree | b33576cd90c64cb2ede5ab1a930b11828f110105 /vcl/unx/generic/glyphs/freetype_glyphcache.cxx | |
parent | 1ca1886d46f38a0759ab466e6a4a8c3c0866c523 (diff) |
Move PhysicalFontFace member of FontSelectPattern
A FontSelectPattern describes a general font request. It can be
used to find the best matching LogicalFontInstance. The instance
will be created based on a PhysicalFontFace, which is really a
factory since commit 8b700794b2746070814e9ff416ecd7bbb1c902e7.
Following this workflow, this moves the PhysicalFontFace pointer
to the instance and makes it constant.
Which leaves some special symbol font handling code in the hash
and instance lookup code path. It used to query the font face
directly from the instance.
I'm not sure of the correct handling. The related commits where
made to fix #i89002#, which has an attached test document.
1. commit 849f618270da313f9339dda29a9f35938434c91d
2. commit 8c9823d311fdf8092cc75873e4565325d204a658
The document is as broken as it was before the patch. The symbol
substitution still works, but the 'Q's are missing when displaying
a symbol font.
I also don't understand all the reinterpret_casts for fake font
ids. I guess this was used to prevent the crashes I see, where a
PhysicalFontFace referenced in a valid LogicalFontInstance is
freed and a later FontId check in the GlyphCache crashes. So this
now checks for a valid cache instead.
Change-Id: If8ee5a6288e66cfa4c419289fbdd5b5da128c6ea
Reviewed-on: https://gerrit.libreoffice.org/47279
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Khaled Hosny <khaledhosny@eglug.org>
Diffstat (limited to 'vcl/unx/generic/glyphs/freetype_glyphcache.cxx')
-rw-r--r-- | vcl/unx/generic/glyphs/freetype_glyphcache.cxx | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx index 65a9e4f14a0b..795284493f12 100644 --- a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx +++ b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx @@ -63,6 +63,7 @@ #include <sys/mman.h> #include <unx/fontmanager.hxx> #include <impfontcharmap.hxx> +#include <impfontcache.hxx> static FT_Library aLibFT = nullptr; @@ -335,8 +336,11 @@ FreetypeFont* FreetypeManager::CreateFont( const FontSelectPattern& rFSD ) FreetypeFontInfo* pFontInfo = nullptr; // find a FontInfo matching to the font id - sal_IntPtr nFontId = reinterpret_cast<sal_IntPtr>( rFSD.mpFontData ); - FontList::iterator it = maFontList.find( nFontId ); + sal_IntPtr nFontId = 0; + if (rFSD.mpFontInstance && rFSD.mpFontInstance->GetFontFace()) + nFontId = rFSD.mpFontInstance->GetFontFace()->GetFontId(); + + FontList::iterator it = maFontList.find(nFontId); if( it != maFontList.end() ) pFontInfo = it->second; @@ -356,7 +360,7 @@ FreetypeFontFace::FreetypeFontFace( FreetypeFontInfo* pFI, const FontAttributes& LogicalFontInstance* FreetypeFontFace::CreateFontInstance(const FontSelectPattern& rFSD) const { - return new FreetypeFontInstance(rFSD); + return new FreetypeFontInstance(*this, rFSD); } // FreetypeFont @@ -384,6 +388,7 @@ FreetypeFont::FreetypeFont( const FontSelectPattern& rFSD, FreetypeFontInfo* pFI // TODO: move update of mpFontInstance into FontEntry class when // it becomes responsible for the FreetypeFont instantiation static_cast<FreetypeFontInstance*>(rFSD.mpFontInstance)->SetFreetypeFont( this ); + maFontSelData.mpFontInstance->Acquire(); maFaceFT = pFI->GetFaceFT(); @@ -485,15 +490,16 @@ FreetypeFont::~FreetypeFont() if( mpHbFont ) hb_font_destroy( mpHbFont ); + maFontSelData.mpFontInstance->Release(); + ReleaseFromGarbageCollect(); } - void FreetypeFont::GetFontMetric(ImplFontMetricDataRef const & rxTo) const { rxTo->FontAttributes::operator =(mpFontInfo->GetFontAttributes()); - rxTo->SetOrientation( GetFontSelData().mnOrientation ); + rxTo->SetOrientation( maFontSelData.mnOrientation ); //Always consider [star]symbol as symbol fonts if ( IsStarSymbol( rxTo->GetFamilyName() ) ) @@ -563,7 +569,7 @@ void FreetypeFont::GetFontMetric(ImplFontMetricDataRef const & rxTo) const void FreetypeFont::ApplyGlyphTransform(bool bVertical, FT_Glyph pGlyphFT ) const { // shortcut most common case - if (!GetFontSelData().mnOrientation && !bVertical) + if (!maFontSelData.mnOrientation && !bVertical) return; const FT_Size_Metrics& rMetrics = maFaceFT->size->metrics; @@ -644,7 +650,7 @@ void FreetypeFont::InitGlyphData(const GlyphItem& rGlyph, GlyphData& rGD ) const bool FreetypeFont::GetAntialiasAdvice() const { // TODO: also use GASP info - return !GetFontSelData().mbNonAntialiased && (mnPrioAntiAlias > 0); + return !maFontSelData.mbNonAntialiased && (mnPrioAntiAlias > 0); } // determine unicode ranges in font |