summaryrefslogtreecommitdiff
path: root/vcl/source/fontsubset
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2022-09-18 17:30:22 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2022-09-18 18:04:49 +0200
commit1f985cb4779b581a77d419605ceb084707d408b8 (patch)
tree2949c362989a19b201d118978d7f4410ebef7db3 /vcl/source/fontsubset
parente66606a3334a575a183e57360c7a4696b73393c8 (diff)
tdf#151039: use the same defaults also for FontSubsetInfo::m_aFontBBox
The defaults for "maFontBBox is not valid" case were already introduced in commit 2d1f08d63942666c0094904f50ba8c512ab69b9d Author Release Engineers <releng@openoffice.org> Date Thu Aug 27 12:02:29 2009 +0000 CWS-TOOLING: integrate CWS otf01 but it used the four elements of maFontBBox unconditionally in later calculations. Possibly that code path is untested, because unless the wrong size is greater than 4, it would always crash. Unfortunately, use of { 0, 0, 0, 0 } here (as Khaled proposed in the bug, for "garbage in, garbage out" principle) is impossible: the PDF with such data shows an error in Acrobat Reader: "The font contains a bad /BBox". As Khaled mentioned, a better fix would be to use the equivalent font extents from head table. Change-Id: I949db23d8af7c1fd4c2362655bf602eea0e70062 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140121 Tested-by: Mike Kaganski <mike.kaganski@collabora.com> Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'vcl/source/fontsubset')
-rw-r--r--vcl/source/fontsubset/cff.cxx16
1 files changed, 8 insertions, 8 deletions
diff --git a/vcl/source/fontsubset/cff.cxx b/vcl/source/fontsubset/cff.cxx
index 198fc49b40cc..f22ab23f6e12 100644
--- a/vcl/source/fontsubset/cff.cxx
+++ b/vcl/source/fontsubset/cff.cxx
@@ -1830,10 +1830,10 @@ void CffSubsetterContext::emitAsType1( Type1Emitter& rEmitter,
else // emit default FontMatrix if needed
pOut += sprintf( pOut, "/FontMatrix [0.001 0 0 0.001 0 0]readonly def\n");
// emit FontBBox
- if( maFontBBox.size() == 4)
- rEmitter.emitValVector( "/FontBBox {", "}readonly def\n", maFontBBox);
- else // emit default FontBBox if needed
- pOut += sprintf( pOut, "/FontBBox {0 0 999 999}readonly def\n");
+ auto aFontBBox = maFontBBox;
+ if (aFontBBox.size() != 4)
+ aFontBBox = { 0, 0, 999, 999 }; // emit default FontBBox if needed
+ rEmitter.emitValVector( "/FontBBox {", "}readonly def\n", aFontBBox);
// emit FONTINFO into TOPDICT
pOut += sprintf( pOut,
"/FontInfo 2 dict dup begin\n" // TODO: check fontinfo entry count
@@ -2049,10 +2049,10 @@ void CffSubsetterContext::emitAsType1( Type1Emitter& rEmitter,
fXFactor = 1000.0F * maFontMatrix[0];
fYFactor = 1000.0F * maFontMatrix[3];
}
- rFSInfo.m_aFontBBox = tools::Rectangle( Point( static_cast<sal_Int32>(maFontBBox[0] * fXFactor),
- static_cast<sal_Int32>(maFontBBox[1] * fYFactor) ),
- Point( static_cast<sal_Int32>(maFontBBox[2] * fXFactor),
- static_cast<sal_Int32>(maFontBBox[3] * fYFactor) ) );
+ rFSInfo.m_aFontBBox = { Point(static_cast<sal_Int32>(aFontBBox[0] * fXFactor),
+ static_cast<sal_Int32>(aFontBBox[1] * fYFactor)),
+ Point(static_cast<sal_Int32>(aFontBBox[2] * fXFactor),
+ static_cast<sal_Int32>(aFontBBox[3] * fYFactor)) };
// PDF-Spec says the values below mean the ink bounds!
// TODO: use better approximations for these ink bounds
rFSInfo.m_nAscent = +rFSInfo.m_aFontBBox.Bottom(); // for capital letters