summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2020-07-20 11:36:13 +0200
committerMiklos Vajna <vmiklos@collabora.com>2020-07-21 08:45:03 +0200
commitc91a8faaf6b03bde165894d6d35ce5f71a39c7c4 (patch)
tree225409fc6f41a18b356a2b48489217e5f22c619d /vcl
parent9a937193f80ea914d25d939747e27bfc98ee6927 (diff)
tdf#50879 PDF export: ensure only built-in fonts are used for forms
Alternative would be to embed the whole font, which is unusual: PDF typically just embeds the used subset. (cherry picked from commit 6294ecd7b4da38de98b24ddfb9f201cef98c1f41) [ Backport is missing the testcase, pdfium on this branch is too old. ] Change-Id: Ic0b7e121b3ae38804c1a396ea36104ebcc0b9588 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99070 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/gdi/pdfwriter_impl.cxx13
1 files changed, 10 insertions, 3 deletions
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index 60be24294217..e44edd1fe8a9 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -4066,6 +4066,13 @@ Font PDFWriterImpl::replaceFont( const vcl::Font& rControlFont, const vcl::Font&
sal_Int32 PDFWriterImpl::getBestBuildinFont( const vcl::Font& rFont )
{
sal_Int32 nBest = 4; // default to Helvetica
+
+ if (rFont.GetFamilyType() == FAMILY_ROMAN)
+ {
+ // Serif: default to Times-Roman.
+ nBest = 8;
+ }
+
OUString aFontName( rFont.GetFamilyName() );
aFontName = aFontName.toAsciiLowerCase();
@@ -4212,14 +4219,14 @@ void PDFWriterImpl::createDefaultEditAppearance( PDFWidget& rEdit, const PDFWrit
// prepare font to use, draw field border
Font aFont = drawFieldBorder( rEdit, rWidget, rSettings );
- sal_Int32 nBest = getSystemFont( aFont );
+ // Get the built-in font which is closest to aFont.
+ sal_Int32 nBest = getBestBuildinFont(aFont);
// prepare DA string
OStringBuffer aDA( 32 );
appendNonStrokingColor( replaceColor( rWidget.TextColor, rSettings.GetFieldTextColor() ), aDA );
aDA.append( ' ' );
- aDA.append( "/F" );
- aDA.append( nBest );
+ aDA.append(pdf::BuildinFontFace::Get(nBest).getNameObject());
OStringBuffer aDR( 32 );
aDR.append( "/Font " );