summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2019-04-20 21:50:37 +0900
committerTomaž Vajngerl <quikee@gmail.com>2019-04-21 01:00:48 +0200
commiteb5606511fac2a8ee1af7cc03c12d6c5b16f7c96 (patch)
treeda0a52ebdafdf5f988cc32e83b09bc49f5a232ba /vcl
parent2b307927f028eeefcec41a8bc8daae392521f9df (diff)
tdf#101854 Move to CommonSalLayout removed faux bold in macos
Previously faux bold was drawn with setting a dictionary key kCTStrokeWidthAttributeName and a value of the stroke width. This stopped working because we don't use attributedString for drawing anymore but we always use CTFontDrawGlyphs and draw the glyphs, which doesn't have a way to set this attributes. It took me a while to find a workaround (thanks to Apple's great documentation), where we switch text drawing to fill and stroke, and after that we can modify the stroke by changing the line width. Change-Id: I594fcb9c796a9c04ea8234a9938ca2f719706199 Reviewed-on: https://gerrit.libreoffice.org/71012 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/quartz/salgdi.h6
-rw-r--r--vcl/quartz/ctfonts.cxx5
-rw-r--r--vcl/quartz/salgdi.cxx9
3 files changed, 15 insertions, 5 deletions
diff --git a/vcl/inc/quartz/salgdi.h b/vcl/inc/quartz/salgdi.h
index adb5d30429ff..d04b290a8560 100644
--- a/vcl/inc/quartz/salgdi.h
+++ b/vcl/inc/quartz/salgdi.h
@@ -90,9 +90,11 @@ public:
CFMutableDictionaryRef GetStyleDict( void ) const { return mpStyleDict; }
/// <1.0: font is squeezed, >1.0 font is stretched, else 1.0
- float mfFontStretch;
+ float mfFontStretch;
/// text rotation in radian
- float mfFontRotation;
+ float mfFontRotation;
+ /// faux bold - true, if font doesn't have proper bold variants
+ float mbFauxBold;
private:
explicit CoreTextStyle(const PhysicalFontFace&, const FontSelectPattern&);
diff --git a/vcl/quartz/ctfonts.cxx b/vcl/quartz/ctfonts.cxx
index 5a0b5b62916d..06a25965653f 100644
--- a/vcl/quartz/ctfonts.cxx
+++ b/vcl/quartz/ctfonts.cxx
@@ -50,6 +50,7 @@ CoreTextStyle::CoreTextStyle(const PhysicalFontFace& rPFF, const FontSelectPatte
: LogicalFontInstance(rPFF, rFSP)
, mfFontStretch( 1.0 )
, mfFontRotation( 0.0 )
+ , mbFauxBold(false)
, mpStyleDict( nullptr )
{
double fScaledFontHeight = rFSP.mfExactHeight;
@@ -81,9 +82,7 @@ CoreTextStyle::CoreTextStyle(const PhysicalFontFace& rPFF, const FontSelectPatte
((rPFF.GetWeight() < WEIGHT_SEMIBOLD) &&
(rPFF.GetWeight() != WEIGHT_DONTKNOW)) )
{
- int nStroke = -lrint((3.5F * rFSP.GetWeight()) / rPFF.GetWeight());
- CFNumberRef rStroke = CFNumberCreate(nullptr, kCFNumberSInt32Type, &nStroke);
- CFDictionarySetValue(mpStyleDict, kCTStrokeWidthAttributeName, rStroke);
+ mbFauxBold = true;
}
// fake italic
diff --git a/vcl/quartz/salgdi.cxx b/vcl/quartz/salgdi.cxx
index 18eda87c2de7..59e2522e58e1 100644
--- a/vcl/quartz/salgdi.cxx
+++ b/vcl/quartz/salgdi.cxx
@@ -460,6 +460,15 @@ void AquaSalGraphics::DrawTextLayout(const GenericSalLayout& rLayout)
SAL_INFO("vcl.cg", "CGContextSetFillColor(" << mrContext << "," << maTextColor << ")");
CGContextSetFillColor(mrContext, maTextColor.AsArray());
+ if (rStyle.mbFauxBold)
+ {
+
+ float fSize = rFontSelect.mnHeight / 23.0f;
+ CGContextSetStrokeColor(mrContext, maTextColor.AsArray());
+ CGContextSetLineWidth(mrContext, fSize);
+ CGContextSetTextDrawingMode(mrContext, kCGTextFillStroke);
+ }
+
auto aIt = aGlyphOrientation.cbegin();
while (aIt != aGlyphOrientation.cend())
{