diff options
-rw-r--r-- | vcl/inc/osx/saldata.hxx | 3 | ||||
-rw-r--r-- | vcl/inc/quartz/ctfonts.hxx | 2 | ||||
-rw-r--r-- | vcl/inc/quartz/salgdi.h | 8 | ||||
-rw-r--r-- | vcl/osx/saldata.cxx | 2 | ||||
-rw-r--r-- | vcl/quartz/ctfonts.cxx | 12 | ||||
-rw-r--r-- | vcl/quartz/salgdi.cxx | 11 | ||||
-rw-r--r-- | vcl/skia/osx/gdiimpl.cxx | 2 |
7 files changed, 21 insertions, 19 deletions
diff --git a/vcl/inc/osx/saldata.hxx b/vcl/inc/osx/saldata.hxx index e201f45715c2..ba4d6e8c856b 100644 --- a/vcl/inc/osx/saldata.hxx +++ b/vcl/inc/osx/saldata.hxx @@ -36,6 +36,7 @@ #include <functional> #include <list> #include <map> +#include <memory> #include <unordered_set> #include <vector> #include <o3tl/enumarray.hxx> @@ -68,7 +69,7 @@ public: SalObject *mpFirstObject; // pointer of first object window SalVirtualDevice *mpFirstVD; // first VirDev SalPrinter *mpFirstPrinter; // first printing printer - SystemFontList *mpFontList; + std::unique_ptr<SystemFontList> mpFontList; NSStatusItem* mpStatusItem; // one status item that draws all our statuses // at the moment this is only one add menu button CGColorSpaceRef mxRGBSpace; diff --git a/vcl/inc/quartz/ctfonts.hxx b/vcl/inc/quartz/ctfonts.hxx index 431385aeeda6..be68dea71c9a 100644 --- a/vcl/inc/quartz/ctfonts.hxx +++ b/vcl/inc/quartz/ctfonts.hxx @@ -23,7 +23,7 @@ #include <quartz/salgdi.h> #include <sallayout.hxx> -SystemFontList* GetCoretextFontList(); +std::unique_ptr<SystemFontList> GetCoretextFontList(); FontAttributes DevFontFromCTFontDescriptor(CTFontDescriptorRef, bool*); #endif // INCLUDED_VCL_INC_QUARTZ_CTFONTS_HXX diff --git a/vcl/inc/quartz/salgdi.h b/vcl/inc/quartz/salgdi.h index 0bf004033c52..5d2611f5b06e 100644 --- a/vcl/inc/quartz/salgdi.h +++ b/vcl/inc/quartz/salgdi.h @@ -61,11 +61,13 @@ class XorEmulation; class CoreTextFontFace : public vcl::font::PhysicalFontFace { public: - CoreTextFontFace( const FontAttributes&, sal_IntPtr nFontID ); + CoreTextFontFace( const FontAttributes&, CTFontDescriptorRef xRef ); virtual ~CoreTextFontFace() override; sal_IntPtr GetFontId() const override; + CTFontDescriptorRef GetFontDescriptorRef() const { return mxFontDescriptor; } + int GetFontTable( uint32_t nTagCode, unsigned char* ) const; rtl::Reference<LogicalFontInstance> CreateFontInstance(const vcl::font::FontSelectPattern&) const override; @@ -73,7 +75,7 @@ public: virtual hb_blob_t* GetHbTable(hb_tag_t nTag) const override; private: - const sal_IntPtr mnFontId; + CTFontDescriptorRef mxFontDescriptor; }; class CoreTextStyle final : public LogicalFontInstance @@ -96,7 +98,7 @@ public: bool mbFauxBold; private: - explicit CoreTextStyle(const vcl::font::PhysicalFontFace&, const vcl::font::FontSelectPattern&); + explicit CoreTextStyle(const CoreTextFontFace&, const vcl::font::FontSelectPattern&); virtual void ImplInitHbFont(hb_font_t*) override; bool ImplGetGlyphBoundRect(sal_GlyphId, tools::Rectangle&, bool) const override; diff --git a/vcl/osx/saldata.cxx b/vcl/osx/saldata.cxx index d49df78d2ccf..e3b6703d0878 100644 --- a/vcl/osx/saldata.cxx +++ b/vcl/osx/saldata.cxx @@ -31,6 +31,7 @@ #include <sal/log.hxx> #include <bitmaps.hlst> #include <cursor_hotspots.hxx> +#include <quartz/salgdi.h> #import "apple_remote/RemoteMainController.h" @@ -49,7 +50,6 @@ SalData::SalData() mpFirstObject( nullptr ), mpFirstVD( nullptr ), mpFirstPrinter( nullptr ), - mpFontList( nullptr ), mpStatusItem( nil ), mxRGBSpace( CGColorSpaceCreateWithName(kCGColorSpaceSRGB) ), mxGraySpace( CGColorSpaceCreateWithName(kCGColorSpaceGenericGrayGamma2_2) ), diff --git a/vcl/quartz/ctfonts.cxx b/vcl/quartz/ctfonts.cxx index 887abe4f2f35..298a5274aa1f 100644 --- a/vcl/quartz/ctfonts.cxx +++ b/vcl/quartz/ctfonts.cxx @@ -41,7 +41,7 @@ #include <sallayout.hxx> #include <hb-coretext.h> -CoreTextStyle::CoreTextStyle(const vcl::font::PhysicalFontFace& rPFF, const vcl::font::FontSelectPattern& rFSP) +CoreTextStyle::CoreTextStyle(const CoreTextFontFace& rPFF, const vcl::font::FontSelectPattern& rFSP) : LogicalFontInstance(rPFF, rFSP) , mfFontStretch( 1.0 ) , mfFontRotation( 0.0 ) @@ -88,7 +88,7 @@ CoreTextStyle::CoreTextStyle(const vcl::font::PhysicalFontFace& rPFF, const vcl: aMatrix = CGAffineTransformConcat(aMatrix, CGAffineTransformMake(1, 0, basegfx::deg2rad(12), 1, 0, 0)); } - CTFontDescriptorRef pFontDesc = reinterpret_cast<CTFontDescriptorRef>(rPFF.GetFontId()); + CTFontDescriptorRef pFontDesc = rPFF.GetFontDescriptorRef(); CTFontRef pNewCTFont = CTFontCreateWithFontDescriptor( pFontDesc, fScaledFontHeight, &aMatrix ); CFDictionarySetValue( mpStyleDict, kCTFontAttributeName, pNewCTFont ); CFRelease( pNewCTFont); @@ -536,8 +536,7 @@ static void fontEnumCallBack( const void* pValue, void* pContext ) if( bFontEnabled) { - const sal_IntPtr nFontId = reinterpret_cast<sal_IntPtr>(pValue); - rtl::Reference<CoreTextFontFace> pFontData = new CoreTextFontFace( rDFA, nFontId ); + rtl::Reference<CoreTextFontFace> pFontData = new CoreTextFontFace( rDFA, pFD ); SystemFontList* pFontList = static_cast<SystemFontList*>(pContext); pFontList->AddFont( pFontData.get() ); } @@ -607,12 +606,11 @@ bool SystemFontList::Init() return true; } -SystemFontList* GetCoretextFontList() +std::unique_ptr<SystemFontList> GetCoretextFontList() { - SystemFontList* pList = new SystemFontList(); + std::unique_ptr<SystemFontList> pList(new SystemFontList()); if( !pList->Init() ) { - delete pList; return nullptr; } diff --git a/vcl/quartz/salgdi.cxx b/vcl/quartz/salgdi.cxx index aa5c5ca598ef..ac32415edc87 100644 --- a/vcl/quartz/salgdi.cxx +++ b/vcl/quartz/salgdi.cxx @@ -126,19 +126,21 @@ bool CoreTextGlyphFallbackSubstititution::FindFontSubstitute(vcl::font::FontSele return bFound; } -CoreTextFontFace::CoreTextFontFace( const FontAttributes& rDFA, sal_IntPtr nFontId ) +CoreTextFontFace::CoreTextFontFace( const FontAttributes& rDFA, CTFontDescriptorRef xFontDescriptor ) : vcl::font::PhysicalFontFace( rDFA ) - , mnFontId( nFontId ) + , mxFontDescriptor( xFontDescriptor ) { + CFRetain(mxFontDescriptor); } CoreTextFontFace::~CoreTextFontFace() { + CFRelease(mxFontDescriptor); } sal_IntPtr CoreTextFontFace::GetFontId() const { - return mnFontId; + return reinterpret_cast<sal_IntPtr>(mxFontDescriptor); } AquaSalGraphics::AquaSalGraphics() @@ -291,8 +293,7 @@ void AquaSalGraphics::GetDevFontList(vcl::font::PhysicalFontCollection* pFontCol void AquaSalGraphics::ClearDevFontCache() { SalData* pSalData = GetSalData(); - delete pSalData->mpFontList; - pSalData->mpFontList = nullptr; + pSalData->mpFontList.reset(); } bool AquaSalGraphics::AddTempDevFont(vcl::font::PhysicalFontCollection*, diff --git a/vcl/skia/osx/gdiimpl.cxx b/vcl/skia/osx/gdiimpl.cxx index ffc84ae89006..fef8b54e3db4 100644 --- a/vcl/skia/osx/gdiimpl.cxx +++ b/vcl/skia/osx/gdiimpl.cxx @@ -289,7 +289,7 @@ void AquaSkiaSalGraphicsImpl::drawTextLayout(const GenericSalLayout& rLayout, if (!fontManager) { - SystemFontList* fontList = GetCoretextFontList(); + std::unique_ptr<SystemFontList> fontList = GetCoretextFontList(); if (fontList == nullptr) { SAL_WARN("vcl.skia", "DrawTextLayout(): No coretext font list"); |