summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-09-05 15:24:26 +0100
committerAdolfo Jayme Barrientos <fitojb@ubuntu.com>2017-09-06 01:29:25 +0200
commite0ea7df25faeaae9f98ebde32f49eec92603d629 (patch)
treeb7705351fcc907abd41a172efd286ec5cb13a5e6
parent4ce1f36e6f4fd7ea923cf2ae81895f6e45919ba6 (diff)
Resolves: tdf#107249 round ascent/descent/extleading on conversion to int
Reviewed-on: https://gerrit.libreoffice.org/41944 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com> (cherry picked from commit 0c8b749e602b6743857a9bc4efb24b6183690311) Change-Id: Ia3ab5960d5288f5831aaa4ade800ca7513dad766 Reviewed-on: https://gerrit.libreoffice.org/41956 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
-rw-r--r--vcl/source/font/fontmetric.cxx25
1 files changed, 15 insertions, 10 deletions
diff --git a/vcl/source/font/fontmetric.cxx b/vcl/source/font/fontmetric.cxx
index 3d7bf9a0b375..b48b0aaca348 100644
--- a/vcl/source/font/fontmetric.cxx
+++ b/vcl/source/font/fontmetric.cxx
@@ -448,6 +448,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));
@@ -456,30 +457,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;