diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-09-05 12:33:48 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-09-05 15:04:54 +0200 |
commit | e2159061db8e266a3fe9f31773c676887168b254 (patch) | |
tree | d6d6aae124cbe57cb757c0968113fdc9b280178e | |
parent | f263692de96ac68e73eeb953b7e92a18d149f30e (diff) |
Resolves: tdf#107249 round ascent/descent/extleading on conversion to int
Change-Id: Iaf30b90762818c57fc0277e771b5bf172fb558be
Reviewed-on: https://gerrit.libreoffice.org/41933
Reviewed-by: Michael Meeks <michael@gnome.org>
Reviewed-by: Khaled Hosny <khaledhosny@eglug.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | vcl/source/font/fontmetric.cxx | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/vcl/source/font/fontmetric.cxx b/vcl/source/font/fontmetric.cxx index a255d0403847..7371c1dc7c74 100644 --- a/vcl/source/font/fontmetric.cxx +++ b/vcl/source/font/fontmetric.cxx @@ -412,6 +412,7 @@ void ImplFontMetricData::ImplCalcLineSpacing(const std::vector<uint8_t>& rHheaDa mnAscent = mnDescent = mnExtLeading = mnIntLeading = 0; double fScale = static_cast<double>(mnHeight) / nUPEM; + double fAscent = 0, fDescent = 0, fExtLeading = 0; vcl::TTGlobalFontInfo rInfo; memset(&rInfo, 0, sizeof(vcl::TTGlobalFontInfo)); @@ -420,30 +421,34 @@ void ImplFontMetricData::ImplCalcLineSpacing(const std::vector<uint8_t>& rHheaDa // Try hhea table first. if (rInfo.ascender || rInfo.descender) { - mnAscent = rInfo.ascender * fScale; - mnDescent = -rInfo.descender * fScale; - mnExtLeading = rInfo.linegap * fScale; + fAscent = rInfo.ascender * fScale; + fDescent = -rInfo.descender * fScale; + fExtLeading = rInfo.linegap * fScale; } // But if OS/2 is present, prefer it. if (rInfo.winAscent || rInfo.winDescent || rInfo.typoAscender || rInfo.typoDescender) { - if (mnAscent == 0 && mnDescent == 0) + if (fAscent == 0 && fDescent == 0) { - mnAscent = rInfo.winAscent * fScale; - mnDescent = rInfo.winDescent * fScale; - mnExtLeading = 0; + fAscent = rInfo.winAscent * fScale; + fDescent = rInfo.winDescent * fScale; + fExtLeading = 0; } const uint16_t kUseTypoMetricsMask = 1 << 7; if (rInfo.fsSelection & kUseTypoMetricsMask) { - mnAscent = rInfo.typoAscender * fScale; - mnDescent = -rInfo.typoDescender * fScale; - mnExtLeading = rInfo.typoLineGap * fScale; + fAscent = rInfo.typoAscender * fScale; + fDescent = -rInfo.typoDescender * fScale; + fExtLeading = rInfo.typoLineGap * fScale; } } + mnAscent = round(fAscent); + mnDescent = round(fDescent); + mnExtLeading = round(fExtLeading); + if (mnAscent || mnDescent) mnIntLeading = mnAscent + mnDescent - mnHeight; |