diff options
author | Caolán McNamara <caolanm@redhat.com> | 2011-02-06 13:47:35 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-02-09 14:33:20 +0000 |
commit | cea018b386018d32dd9a762dfddd5bf316f218aa (patch) | |
tree | 7555e13536d44e10d72babd69074b95bc2b2207b /vcl/aqua | |
parent | 052a4a89ed6293298b930b52de9e53837dd908e3 (diff) |
Resolves: fdo#33510 A way to query about likely font layout capabilities
Diffstat (limited to 'vcl/aqua')
-rw-r--r-- | vcl/aqua/inc/salgdi.h | 4 | ||||
-rw-r--r-- | vcl/aqua/source/gdi/salgdi.cxx | 42 |
2 files changed, 46 insertions, 0 deletions
diff --git a/vcl/aqua/inc/salgdi.h b/vcl/aqua/inc/salgdi.h index 9d432a2b0ff3..8b2a9564bea3 100644 --- a/vcl/aqua/inc/salgdi.h +++ b/vcl/aqua/inc/salgdi.h @@ -61,6 +61,7 @@ public: virtual sal_IntPtr GetFontId() const; ImplFontCharMap* GetImplFontCharMap() const; + bool GetImplFontLayoutCapabilities(FontLayoutCapabilities &rGetImplFontLayoutCapabilities) const; bool HasChar( sal_uInt32 cChar ) const; void ReadOs2Table() const; @@ -70,10 +71,12 @@ public: private: const ATSUFontID mnFontId; mutable ImplFontCharMap* mpCharMap; + mutable FontLayoutCapabilities maFontLayoutCapabilities; mutable bool mbOs2Read; // true if OS2-table related info is valid mutable bool mbHasOs2Table; mutable bool mbCmapEncodingRead; // true if cmap encoding of Mac font is read mutable bool mbHasCJKSupport; // #i78970# CJK fonts need extra leading + mutable bool mbFontLayoutCapabilitiesRead; }; // abstracting quartz color instead of having to use an CGFloat[] array @@ -283,6 +286,7 @@ public: virtual ULONG GetKernPairs( ULONG nPairs, ImplKernPairData* pKernPairs ); // get the repertoire of the current font virtual ImplFontCharMap* GetImplFontCharMap() const; + virtual bool GetImplFontLayoutCapabilities(FontLayoutCapabilities &rGetImplFontLayoutCapabilities) const; // graphics must fill supplied font list virtual void GetDevFontList( ImplDevFontList* ); // graphics should call ImplAddDevFontSubstitute on supplied diff --git a/vcl/aqua/source/gdi/salgdi.cxx b/vcl/aqua/source/gdi/salgdi.cxx index e15f1cd3a2c1..07b3cbb6e1dd 100644 --- a/vcl/aqua/source/gdi/salgdi.cxx +++ b/vcl/aqua/source/gdi/salgdi.cxx @@ -73,6 +73,7 @@ ImplMacFontData::ImplMacFontData( const ImplDevFontAttributes& rDFA, ATSUFontID , mbHasOs2Table( false ) , mbCmapEncodingRead( false ) , mbHasCJKSupport( false ) +, mbFontLayoutCapabilitiesRead( false ) {} // ----------------------------------------------------------------------- @@ -157,6 +158,39 @@ ImplFontCharMap* ImplMacFontData::GetImplFontCharMap() const return mpCharMap; } +bool ImplMacFontData::GetImplFontLayoutCapabilities(FontLayoutCapabilities &rFontLayoutCapabilities) +{ + // read this only once per font + if( mbFontLayoutCapabilitiesRead ) + { + rFontLayoutCapabilities = maFontLayoutCapabilities; + return !rFontLayoutCapabilities.empty(); + } + mbFontLayoutCapabilitiesRead = true; + + // prepare to get the GSUB table raw data + ATSFontRef rFont = FMGetATSFontRefFromFont( mnFontId ); + ByteCount nBufSize = 0; + OSStatus eStatus = ATSFontGetTable( rFont, GetTag("GSUB"), 0, 0, NULL, &nBufSize ); + if( eStatus != noErr ) + return false; + + // allocate a buffer for the GSUB raw data + ByteVector aBuffer( nBufSize ); + + // get the GSUB raw data + ByteCount nRawLength = 0; + eStatus = ATSFontGetTable( rFont, GetTag("GSUB"), 0, nBufSize, (void*)&aBuffer[0], &nRawLength ); + if( eStatus != noErr ) + return false; + + const unsigned char* pGSUBTable = &aBuffer[0]; + vcl::getTTFontLayoutCapabilities(maFontLayoutCapabilities, pGSUBTable); + rFontLayoutCapabilities = maFontLayoutCapabilities; + + return !rFontLayoutCapabilities.empty() +} + // ----------------------------------------------------------------------- void ImplMacFontData::ReadOs2Table( void ) const @@ -1984,6 +2018,14 @@ ImplFontCharMap* AquaSalGraphics::GetImplFontCharMap() const return mpMacFontData->GetImplFontCharMap(); } +bool AquaSalGraphics::GetImplFontLayoutCapabilities(FontLayoutCapabilities &rFontLayoutCapabilities) +{ + if( !mpMacFontData ) + return false; + + return mpMacFontData->GetImplFontLayoutCapabilities(rFontLayoutCapabilities); +} + // ----------------------------------------------------------------------- // fake a SFNT font directory entry for a font table |