summaryrefslogtreecommitdiff
path: root/vcl/quartz
diff options
context:
space:
mode:
authorAkash Jain <akash96j@gmail.com>2016-07-20 23:51:56 +0530
committerKhaled Hosny <khaledhosny@eglug.org>2016-10-18 20:41:30 +0200
commitf099f3d3bd1203045ef5f3d0b448f72c00f2fe1e (patch)
treefb31b99928edb0495c77d330790259c3eddd1b19 /vcl/quartz
parentf6db8af1eb2e6d8e511e6158ddabf8fae7a1c3ca (diff)
GSoC: Integrate new CommonSalLayout in quartz/ code
Change-Id: I07a9c956f09be5d43ee58ff0784ba0f81f52cd9a
Diffstat (limited to 'vcl/quartz')
-rw-r--r--vcl/quartz/ctfonts.cxx2
-rw-r--r--vcl/quartz/ctfonts.hxx34
-rw-r--r--vcl/quartz/ctlayout.cxx8
-rw-r--r--vcl/quartz/salgdi.cxx37
4 files changed, 41 insertions, 40 deletions
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/ctfonts.hxx b/vcl/quartz/ctfonts.hxx
deleted file mode 100644
index 983437cfaeff..000000000000
--- a/vcl/quartz/ctfonts.hxx
+++ /dev/null
@@ -1,34 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef INCLUDED_VCL_QUARTZ_CTFONTS_HXX
-#define INCLUDED_VCL_QUARTZ_CTFONTS_HXX
-
-#include "quartz/salgdi.h"
-#ifdef IOS
-#include "headless/svpgdi.hxx"
-#endif
-#include "sallayout.hxx"
-
-SystemFontList* GetCoretextFontList();
-FontAttributes DevFontFromCTFontDescriptor( CTFontDescriptorRef, bool* );
-
-#endif // INCLUDED_VCL_QUARTZ_CTFONTS_HXX
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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*/ )