Kaydet (Commit) c1758893 authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl Kaydeden (comit) Andras Timar

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: 's avatarTomaž Vajngerl <quikee@gmail.com>
(cherry picked from commit eb560651)
Reviewed-on: https://gerrit.libreoffice.org/71061Reviewed-by: 's avatarAndras Timar <andras.timar@collabora.com>
üst e20c5797
...@@ -90,9 +90,11 @@ public: ...@@ -90,9 +90,11 @@ public:
CFMutableDictionaryRef GetStyleDict( void ) const { return mpStyleDict; } CFMutableDictionaryRef GetStyleDict( void ) const { return mpStyleDict; }
/// <1.0: font is squeezed, >1.0 font is stretched, else 1.0 /// <1.0: font is squeezed, >1.0 font is stretched, else 1.0
float mfFontStretch; float mfFontStretch;
/// text rotation in radian /// text rotation in radian
float mfFontRotation; float mfFontRotation;
/// faux bold - true, if font doesn't have proper bold variants
float mbFauxBold;
private: private:
explicit CoreTextStyle(const PhysicalFontFace&, const FontSelectPattern&); explicit CoreTextStyle(const PhysicalFontFace&, const FontSelectPattern&);
......
...@@ -50,6 +50,7 @@ CoreTextStyle::CoreTextStyle(const PhysicalFontFace& rPFF, const FontSelectPatte ...@@ -50,6 +50,7 @@ CoreTextStyle::CoreTextStyle(const PhysicalFontFace& rPFF, const FontSelectPatte
: LogicalFontInstance(rPFF, rFSP) : LogicalFontInstance(rPFF, rFSP)
, mfFontStretch( 1.0 ) , mfFontStretch( 1.0 )
, mfFontRotation( 0.0 ) , mfFontRotation( 0.0 )
, mbFauxBold(false)
, mpStyleDict( nullptr ) , mpStyleDict( nullptr )
{ {
double fScaledFontHeight = rFSP.mfExactHeight; double fScaledFontHeight = rFSP.mfExactHeight;
...@@ -81,9 +82,7 @@ CoreTextStyle::CoreTextStyle(const PhysicalFontFace& rPFF, const FontSelectPatte ...@@ -81,9 +82,7 @@ CoreTextStyle::CoreTextStyle(const PhysicalFontFace& rPFF, const FontSelectPatte
((rPFF.GetWeight() < WEIGHT_SEMIBOLD) && ((rPFF.GetWeight() < WEIGHT_SEMIBOLD) &&
(rPFF.GetWeight() != WEIGHT_DONTKNOW)) ) (rPFF.GetWeight() != WEIGHT_DONTKNOW)) )
{ {
int nStroke = -lrint((3.5F * rFSP.GetWeight()) / rPFF.GetWeight()); mbFauxBold = true;
CFNumberRef rStroke = CFNumberCreate(nullptr, kCFNumberSInt32Type, &nStroke);
CFDictionarySetValue(mpStyleDict, kCTStrokeWidthAttributeName, rStroke);
} }
// fake italic // fake italic
......
...@@ -460,6 +460,15 @@ void AquaSalGraphics::DrawTextLayout(const GenericSalLayout& rLayout) ...@@ -460,6 +460,15 @@ void AquaSalGraphics::DrawTextLayout(const GenericSalLayout& rLayout)
SAL_INFO("vcl.cg", "CGContextSetFillColor(" << mrContext << "," << maTextColor << ")"); SAL_INFO("vcl.cg", "CGContextSetFillColor(" << mrContext << "," << maTextColor << ")");
CGContextSetFillColor(mrContext, maTextColor.AsArray()); 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(); auto aIt = aGlyphOrientation.cbegin();
while (aIt != aGlyphOrientation.cend()) while (aIt != aGlyphOrientation.cend())
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment