diff options
author | Akash Jain <akash96j@gmail.com> | 2016-07-20 23:51:56 +0530 |
---|---|---|
committer | Khaled Hosny <khaledhosny@eglug.org> | 2016-10-18 20:41:30 +0200 |
commit | f099f3d3bd1203045ef5f3d0b448f72c00f2fe1e (patch) | |
tree | fb31b99928edb0495c77d330790259c3eddd1b19 /vcl | |
parent | f6db8af1eb2e6d8e511e6158ddabf8fae7a1c3ca (diff) |
GSoC: Integrate new CommonSalLayout in quartz/ code
Change-Id: I07a9c956f09be5d43ee58ff0784ba0f81f52cd9a
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/CommonSalLayout.hxx | 1 | ||||
-rw-r--r-- | vcl/inc/quartz/ctfonts.hxx (renamed from vcl/quartz/ctfonts.hxx) | 6 | ||||
-rw-r--r-- | vcl/inc/quartz/salgdi.h | 2 | ||||
-rw-r--r-- | vcl/quartz/ctfonts.cxx | 2 | ||||
-rw-r--r-- | vcl/quartz/ctlayout.cxx | 8 | ||||
-rw-r--r-- | vcl/quartz/salgdi.cxx | 37 | ||||
-rw-r--r-- | vcl/source/gdi/CommonSalLayout.cxx | 10 |
7 files changed, 55 insertions, 11 deletions
diff --git a/vcl/inc/CommonSalLayout.hxx b/vcl/inc/CommonSalLayout.hxx index 11455673e233..1fe3a6ebf1c6 100644 --- a/vcl/inc/CommonSalLayout.hxx +++ b/vcl/inc/CommonSalLayout.hxx @@ -26,6 +26,7 @@ #elif defined(MACOSX) || defined(IOS) #include <com/sun/star/i18n/XBreakIterator.hpp> #include "quartz/ctfonts.hxx" +#include <hb-coretext.h> #else #include "unx/freetype_glyphcache.hxx" diff --git a/vcl/quartz/ctfonts.hxx b/vcl/inc/quartz/ctfonts.hxx index 983437cfaeff..1a3dd7a1eaa8 100644 --- a/vcl/quartz/ctfonts.hxx +++ b/vcl/inc/quartz/ctfonts.hxx @@ -17,8 +17,8 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_VCL_QUARTZ_CTFONTS_HXX -#define INCLUDED_VCL_QUARTZ_CTFONTS_HXX +#ifndef INCLUDED_VCL_INC_QUARTZ_CTFONTS_HXX +#define INCLUDED_VCL_INC_QUARTZ_CTFONTS_HXX #include "quartz/salgdi.h" #ifdef IOS @@ -29,6 +29,6 @@ SystemFontList* GetCoretextFontList(); FontAttributes DevFontFromCTFontDescriptor( CTFontDescriptorRef, bool* ); -#endif // INCLUDED_VCL_QUARTZ_CTFONTS_HXX +#endif // INCLUDED_VCL_INC_QUARTZ_CTFONTS_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/quartz/salgdi.h b/vcl/inc/quartz/salgdi.h index ba0200b36180..104699bc1d89 100644 --- a/vcl/inc/quartz/salgdi.h +++ b/vcl/inc/quartz/salgdi.h @@ -111,6 +111,8 @@ private: CFMutableDictionaryRef mpStyleDict; friend class CTLayout; + friend class AquaSalGraphics; + friend class CommonSalLayout; CFMutableDictionaryRef GetStyleDict( void ) const { return mpStyleDict; } }; diff --git a/vcl/quartz/ctfonts.cxx b/vcl/quartz/ctfonts.cxx index 36b155d5241e..28be80b0b08b 100644 --- a/vcl/quartz/ctfonts.cxx +++ b/vcl/quartz/ctfonts.cxx @@ -25,7 +25,7 @@ #include <vcl/settings.hxx> -#include "ctfonts.hxx" +#include "quartz/ctfonts.hxx" #include "impfont.hxx" #ifdef MACOSX #include "osx/saldata.hxx" diff --git a/vcl/quartz/ctlayout.cxx b/vcl/quartz/ctlayout.cxx index 35f7143028d5..4c841d43d545 100644 --- a/vcl/quartz/ctlayout.cxx +++ b/vcl/quartz/ctlayout.cxx @@ -25,9 +25,10 @@ #include <sal/types.h> #include <tools/debug.hxx> -#include "ctfonts.hxx" +#include "quartz/ctfonts.hxx" #include "CTRunData.hxx" #include "quartz/utils.h" +#include "CommonSalLayout.hxx" class CTLayout : public SalLayout @@ -781,7 +782,10 @@ void CTLayout::Simplify( bool /*bIsBase*/ ) {} SalLayout* CoreTextStyle::GetTextLayout() const { - return new CTLayout( this); + if (getenv("SAL_USE_COMMON_LAYOUT")) + return new CommonSalLayout(*this); + else + return new CTLayout( this); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/quartz/salgdi.cxx b/vcl/quartz/salgdi.cxx index 5645a610e016..f9e3e0c27c12 100644 --- a/vcl/quartz/salgdi.cxx +++ b/vcl/quartz/salgdi.cxx @@ -36,7 +36,7 @@ #include <vcl/svapp.hxx> #include <vcl/sysdata.hxx> -#include "ctfonts.hxx" +#include "quartz/ctfonts.hxx" #include "fontsubset.hxx" #include "impfont.hxx" #include "impfontcharmap.hxx" @@ -414,8 +414,39 @@ bool AquaSalGraphics::GetGlyphBoundRect( sal_GlyphId aGlyphId, Rectangle& rRect return bRC; } -void AquaSalGraphics::DrawSalLayout( const CommonSalLayout& ) -{ +void AquaSalGraphics::DrawSalLayout(const CommonSalLayout& rLayout) +{ + CGContextRef context = mrContext; + SAL_INFO("vcl.ct", "CGContextSaveGState(" << context << ")"); + CGContextSaveGState(context); + SAL_INFO("vcl.ct", "CGContextScaleCTM(" << context << ",1.0,-1.0)"); + const CoreTextStyle& rCTStyle = rLayout.getFontData(); + + CTFontRef pFont = static_cast<CTFontRef>(CFDictionaryGetValue(rCTStyle.GetStyleDict(), kCTFontAttributeName)); + CGContextScaleCTM(context, 1.0, -1.0); + CGContextSetShouldAntialias(context, !mbNonAntialiasedText); + // rotate the matrix + const CGFloat fRadians = rCTStyle.mfFontRotation; + CGContextRotateCTM(context, +fRadians); + const CGAffineTransform aInvMatrix = CGAffineTransformMakeRotation(-fRadians); + CGContextSetFillColor(context, maTextColor.AsArray()); + + // draw the text + Point aPos; + sal_GlyphId aGlyphId; + std::vector<CGGlyph> aGlyphIds; + std::vector<CGPoint> aGlyphPos; + int nStart = 0; + for (; rLayout.GetNextGlyphs(1, &aGlyphId, aPos, nStart); ) + { + aGlyphIds.push_back(aGlyphId & GF_IDXMASK); + aGlyphPos.push_back(CGPointApplyAffineTransform(CGPointMake(aPos.X(), -1*aPos.Y()), aInvMatrix)); + } + CTFontDrawGlyphs(pFont, aGlyphIds.data(), aGlyphPos.data(), nStart, context); + + // restore the original graphic context transformations + SAL_INFO("vcl.ct", "CGContextRestoreGState(" << context << ")"); + CGContextRestoreGState(context); } void AquaSalGraphics::SetFont( FontSelectPattern* pReqFont, int /*nFallbackLevel*/ ) diff --git a/vcl/source/gdi/CommonSalLayout.cxx b/vcl/source/gdi/CommonSalLayout.cxx index 485dcef33af4..89acdb74b506 100644 --- a/vcl/source/gdi/CommonSalLayout.cxx +++ b/vcl/source/gdi/CommonSalLayout.cxx @@ -57,7 +57,7 @@ static hb_blob_t* getFontTable(hb_face_t* /*face*/, hb_tag_t nTableTag, void* pU hb_blob_t* pBlob = nullptr; if (pBuffer != nullptr) -#if defined(_WIN32) +#if defined(_WIN32) || defined(MACOSX) || defined(IOS) pBlob = hb_blob_create(reinterpret_cast<const char*>(pBuffer), nLength, HB_MEMORY_MODE_READONLY, const_cast<unsigned char*>(pBuffer), [](void* data){ delete[] reinterpret_cast<unsigned char*>(data); }); #else @@ -97,7 +97,13 @@ CommonSalLayout::CommonSalLayout(const CoreTextStyle& rCoreTextStyle) maFontSelData(rCoreTextStyle.maFontSelData), mrCoreTextStyle(rCoreTextStyle) { - mpHbFace = hb_face_create_for_tables(getFontTable, const_cast<CoreTextFontFace*>(rCoreTextStyle.mpFontData), nullptr); + CTFontRef pCTFont = static_cast<CTFontRef>(CFDictionaryGetValue(rCoreTextStyle.GetStyleDict(), kCTFontAttributeName)); + CGFontRef pCGFont = CTFontCopyGraphicsFont(pCTFont, NULL); + if (pCGFont) + mpHbFace = hb_coretext_face_create(pCGFont); + else + mpHbFace = hb_face_create_for_tables(getFontTable, const_cast<CoreTextFontFace*>(rCoreTextStyle.mpFontData), nullptr); + CGFontRelease(pCGFont); } #else |