diff options
author | Tor Lillqvist <tml@collabora.com> | 2018-02-22 13:52:13 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2018-02-23 19:34:57 +0100 |
commit | e092effee32cfbade59fb68adddc9db96d3c3c88 (patch) | |
tree | da581e5a94dab727af58deaeb9fbb113ce34c693 | |
parent | 6651a8e85824b11395f1c3110afe8dd91bb83375 (diff) |
A hack, but oh well. Let's hope there won't be a lot of these special
cases. Maybe some generic heuristic would be better. Like if a font's
GetStyleName() is "Medium", "Medium Oblique", or "Medium Italic" then
always force its weight to be WEIGHT_NORMAL?
Reviewed-on: https://gerrit.libreoffice.org/50172
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tor Lillqvist <tml@collabora.com>
(cherry picked from commit 1d7f96a324a4c2ab82a04513c6a38dc31fd061fa)
Change-Id: I13580d27acfb0cc200bdb0cc1911518675d3e32e
Reviewed-on: https://gerrit.libreoffice.org/50198
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Michael Stahl <mstahl@redhat.com>
-rw-r--r-- | vcl/quartz/ctfonts.cxx | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/vcl/quartz/ctfonts.cxx b/vcl/quartz/ctfonts.cxx index ebb7066be9d8..ee556a1fd2ae 100644 --- a/vcl/quartz/ctfonts.cxx +++ b/vcl/quartz/ctfonts.cxx @@ -1,4 +1,4 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ /* * This file is part of the LibreOffice project. * @@ -387,6 +387,29 @@ FontAttributes DevFontFromCTFontDescriptor( CTFontDescriptorRef pFD, bool* bFont CFNumberRef pWeightNum = static_cast<CFNumberRef>(CFDictionaryGetValue( pAttrDict, kCTFontWeightTrait )); CFNumberGetValue( pWeightNum, kCFNumberDoubleType, &fWeight ); int nInt = WEIGHT_NORMAL; + + // Special case fixes + + // tdf#67744: Courier Std Medium is always bold. We get a kCTFontWeightTrait of 0.23 which + // surely must be wrong. + if (rDFA.GetFamilyName() == "Courier Std" && + (rDFA.GetStyleName() == "Medium" || rDFA.GetStyleName() == "Medium Oblique") && + fWeight > 0.2) + { + fWeight = 0; + } + + // tdf#68889: Ditto for Gill Sans MT Pro. Here I can kinda understand it, maybe the + // kCTFontWeightTrait is intended to give a subjective "optical" impression of how the font + // looks, and Gill Sans MT Pro Medium is kinda heavy. But with the way LibreOffice uses fonts, + // we still should think of it as being "medium" weight. + if (rDFA.GetFamilyName() == "Gill Sans MT Pro" && + (rDFA.GetStyleName() == "Medium" || rDFA.GetStyleName() == "Medium Italic") && + fWeight > 0.2) + { + fWeight = 0; + } + if( fWeight > 0 ) { nInt = rint(WEIGHT_NORMAL + fWeight * ((WEIGHT_BLACK - WEIGHT_NORMAL)/0.68)); |