diff options
Diffstat (limited to 'vcl/unx')
-rw-r--r-- | vcl/unx/generic/gdi/cairotextrender.cxx | 15 | ||||
-rw-r--r-- | vcl/unx/generic/glyphs/freetype_glyphcache.cxx | 22 | ||||
-rw-r--r-- | vcl/unx/generic/glyphs/glyphcache.cxx | 26 | ||||
-rw-r--r-- | vcl/unx/generic/print/genpspgraphics.cxx | 2 |
4 files changed, 44 insertions, 21 deletions
diff --git a/vcl/unx/generic/gdi/cairotextrender.cxx b/vcl/unx/generic/gdi/cairotextrender.cxx index bde9ff6827ac..d856821de72c 100644 --- a/vcl/unx/generic/gdi/cairotextrender.cxx +++ b/vcl/unx/generic/gdi/cairotextrender.cxx @@ -31,6 +31,7 @@ #include <unx/geninst.h> #include <unx/glyphcache.hxx> #include <unx/fc_fontoptions.hxx> +#include <unx/freetype_glyphcache.hxx> #include <PhysicalFontFace.hxx> #include <impfont.hxx> #include <impfontmetricdata.hxx> @@ -169,7 +170,8 @@ namespace void CairoTextRender::DrawTextLayout(const CommonSalLayout& rLayout) { - const FreetypeFont& rFont = *rLayout.getFreetypeFont(); + const FreetypeFontInstance& rInstance = static_cast<FreetypeFontInstance&>(rLayout.getFont()); + const FreetypeFont& rFont = *rInstance.GetFreetypeFont(); std::vector<cairo_glyph_t> cairo_glyphs; std::vector<int> glyph_extrarotation; @@ -195,7 +197,7 @@ void CairoTextRender::DrawTextLayout(const CommonSalLayout& rLayout) if (cairo_glyphs.empty()) return; - const FontSelectPattern& rFSD = rFont.GetFontSelData(); + const FontSelectPattern& rFSD = rInstance.GetFontSelectPattern(); int nHeight = rFSD.mnHeight; int nWidth = rFSD.mnWidth ? rFSD.mnWidth : nHeight; if (nWidth == 0 || nHeight == 0) @@ -460,7 +462,7 @@ bool CairoTextRender::GetGlyphOutline(const GlyphItem& rGlyph, if( nLevel >= MAX_FALLBACK ) return false; - FreetypeFont* pSF = mpFreetypeFont[ nLevel ]; + const FreetypeFont* pSF = mpFreetypeFont[ nLevel ]; if( !pSF ) return false; @@ -470,7 +472,7 @@ bool CairoTextRender::GetGlyphOutline(const GlyphItem& rGlyph, std::unique_ptr<SalLayout> CairoTextRender::GetTextLayout(ImplLayoutArgs& /*rArgs*/, int nFallbackLevel) { if (mpFreetypeFont[nFallbackLevel]) - return std::unique_ptr<SalLayout>(new CommonSalLayout(*mpFreetypeFont[nFallbackLevel])); + return std::unique_ptr<SalLayout>(new CommonSalLayout(*mpFreetypeFont[nFallbackLevel]->GetFontInstance())); return nullptr; } @@ -485,13 +487,13 @@ SystemFontData CairoTextRender::GetSysFontData( int nFallbackLevel ) const if (mpFreetypeFont[nFallbackLevel] != nullptr) { - FreetypeFont* rFont = mpFreetypeFont[nFallbackLevel]; + const FreetypeFont* rFont = mpFreetypeFont[nFallbackLevel]; aSysFontData.nFontId = rFont->GetFtFace(); aSysFontData.nFontFlags = rFont->GetLoadFlags(); aSysFontData.bFakeBold = rFont->NeedsArtificialBold(); aSysFontData.bFakeItalic = rFont->NeedsArtificialItalic(); aSysFontData.bAntialias = rFont->GetAntialiasAdvice(); - aSysFontData.bVerticalCharacterType = rFont->GetFontSelData().mbVertical; + aSysFontData.bVerticalCharacterType = rFont->GetFontInstance()->GetFontSelectPattern().mbVertical; } return aSysFontData; @@ -555,4 +557,5 @@ void CairoTextRender::GetGlyphWidths( const PhysicalFontFace* pFont, psp::fontID aFont = pFont->GetFontId(); GenPspGraphics::DoGetGlyphWidths( aFont, bVertical, rWidths, rUnicodeEnc ); } + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx index 795284493f12..b2b1c59f67cf 100644 --- a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx +++ b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx @@ -367,7 +367,7 @@ LogicalFontInstance* FreetypeFontFace::CreateFontInstance(const FontSelectPatter FreetypeFont::FreetypeFont( const FontSelectPattern& rFSD, FreetypeFontInfo* pFI ) : maGlyphList( 0), - maFontSelData(rFSD), + mpFontInstance(rFSD.mpFontInstance), mnRefCount(1), mnBytesUsed( sizeof(FreetypeFont) ), mpPrevGCFont( nullptr ), @@ -382,13 +382,12 @@ FreetypeFont::FreetypeFont( const FontSelectPattern& rFSD, FreetypeFontInfo* pFI maSizeFT( nullptr ), mbFaceOk( false ), mbArtItalic( false ), - mbArtBold( false ), - mpHbFont( nullptr ) + mbArtBold(false) { // 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(); + static_cast<FreetypeFontInstance*>(mpFontInstance)->SetFreetypeFont( this ); + mpFontInstance->Acquire(); maFaceFT = pFI->GetFaceFT(); @@ -459,7 +458,7 @@ const FontConfigFontOptions* FreetypeFont::GetFontOptions() const { if (!mxFontOptions) { - mxFontOptions.reset(GetFCFontOptions(mpFontInfo->GetFontAttributes(), maFontSelData.mnHeight)); + mxFontOptions.reset(GetFCFontOptions(mpFontInfo->GetFontAttributes(), mpFontInstance->GetFontSelectPattern().mnHeight)); mxFontOptions->SyncPattern(GetFontFileName(), GetFontFaceIndex(), NeedsArtificialBold()); } return mxFontOptions.get(); @@ -487,10 +486,7 @@ FreetypeFont::~FreetypeFont() mpFontInfo->ReleaseFaceFT(); - if( mpHbFont ) - hb_font_destroy( mpHbFont ); - - maFontSelData.mpFontInstance->Release(); + mpFontInstance->Release(); ReleaseFromGarbageCollect(); } @@ -499,7 +495,7 @@ void FreetypeFont::GetFontMetric(ImplFontMetricDataRef const & rxTo) const { rxTo->FontAttributes::operator =(mpFontInfo->GetFontAttributes()); - rxTo->SetOrientation( maFontSelData.mnOrientation ); + rxTo->SetOrientation( mpFontInstance->GetFontSelectPattern().mnOrientation ); //Always consider [star]symbol as symbol fonts if ( IsStarSymbol( rxTo->GetFamilyName() ) ) @@ -569,7 +565,7 @@ void FreetypeFont::GetFontMetric(ImplFontMetricDataRef const & rxTo) const void FreetypeFont::ApplyGlyphTransform(bool bVertical, FT_Glyph pGlyphFT ) const { // shortcut most common case - if (!maFontSelData.mnOrientation && !bVertical) + if (!mpFontInstance->GetFontSelectPattern().mnOrientation && !bVertical) return; const FT_Size_Metrics& rMetrics = maFaceFT->size->metrics; @@ -650,7 +646,7 @@ void FreetypeFont::InitGlyphData(const GlyphItem& rGlyph, GlyphData& rGD ) const bool FreetypeFont::GetAntialiasAdvice() const { // TODO: also use GASP info - return !maFontSelData.mbNonAntialiased && (mnPrioAntiAlias > 0); + return !mpFontInstance->GetFontSelectPattern().mbNonAntialiased && (mnPrioAntiAlias > 0); } // determine unicode ranges in font diff --git a/vcl/unx/generic/glyphs/glyphcache.cxx b/vcl/unx/generic/glyphs/glyphcache.cxx index ac2f8cf83218..218161c65be2 100644 --- a/vcl/unx/generic/glyphs/glyphcache.cxx +++ b/vcl/unx/generic/glyphs/glyphcache.cxx @@ -259,7 +259,7 @@ void GlyphCache::GarbageCollect() pFreetypeFont->GarbageCollect( mnLruIndex+0x10000000 ); if( pFreetypeFont == mpCurrentGCFont ) mpCurrentGCFont = nullptr; - const FontSelectPattern& rIFSD = pFreetypeFont->GetFontSelData(); + const FontSelectPattern& rIFSD = pFreetypeFont->GetFontInstance()->GetFontSelectPattern(); maFontList.erase( rIFSD ); mnBytesUsed -= pFreetypeFont->GetByteCount(); @@ -370,4 +370,28 @@ FreetypeFontInstance::~FreetypeFontInstance() if (mpFreetypeFont) mpFreetypeFont->Release(); } + +static hb_blob_t* getFontTable(hb_face_t* /*face*/, hb_tag_t nTableTag, void* pUserData) +{ + char pTagName[5]; + LogicalFontInstance::DecodeOpenTypeTag( nTableTag, pTagName ); + + sal_uLong nLength = 0; + FreetypeFontInstance* pFontInstance = static_cast<FreetypeFontInstance*>( pUserData ); + FreetypeFont* pFont = pFontInstance->GetFreetypeFont(); + const char* pBuffer = reinterpret_cast<const char*>( + pFont->GetTable(pTagName, &nLength) ); + + hb_blob_t* pBlob = nullptr; + if (pBuffer != nullptr) + pBlob = hb_blob_create(pBuffer, nLength, HB_MEMORY_MODE_READONLY, nullptr, nullptr); + + return pBlob; +} + +hb_font_t* FreetypeFontInstance::ImplInitHbFont() +{ + return InitHbFont(hb_face_create_for_tables(getFontTable, this, nullptr)); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/generic/print/genpspgraphics.cxx b/vcl/unx/generic/print/genpspgraphics.cxx index d651da2812c6..c1f1caf014a0 100644 --- a/vcl/unx/generic/print/genpspgraphics.cxx +++ b/vcl/unx/generic/print/genpspgraphics.cxx @@ -547,7 +547,7 @@ private: }; PspCommonSalLayout::PspCommonSalLayout(::psp::PrinterGfx& rGfx, FreetypeFont& rFont) -: CommonSalLayout(rFont) +: CommonSalLayout(*rFont.GetFontInstance()) , mrPrinterGfx(rGfx) { mnFontID = mrPrinterGfx.GetFontID(); |