Commit 0aaa1ccd authored by Jérome Perrin's avatar Jérome Perrin

software/cloudooo: fix font selection

Because we were generating a fontconfig file without the default
configuration, non optimal fonts where selected during substitutions,
for example instead of the very common Arial, we were substituting a
serif font which looks completely different.
parent 237db681
Pipeline #9325 failed with stage
in 0 seconds
......@@ -61,15 +61,10 @@ fonts =
${ipaex-fonts:location}
${liberation-fonts:location}
${ocrb-fonts:location}
# XXX These fonts have always been missing in cloudooo, but we want
# keep compatibility a little bit more.
# ${dejavu-fonts:location}
# ${libreoffice-bin:location}/share/fonts/
# XXX fonts-include also have always been missing, which causes wrong
# font selections in cloudooo, such as using a serif fonts for Arial
${dejavu-fonts:location}
${libreoffice-bin:location}/share/fonts/
fontconfig-includes =
# ${fontconfig:location}/etc/fonts/conf.d
${fontconfig:location}/etc/fonts/conf.d
freetype = ${freetype:location}
glib = ${glib:location}
......
......@@ -103,8 +103,7 @@ class HTMLtoPDFConversionFontTestMixin:
def test(self):
actual_font_mapping_mapping = {}
for font, expected_substitution in sorted(
self.expected_font_mapping.items()):
for font in self.expected_font_mapping:
src_html = '''
<style>
p {{ font-family: "{font}"; font-size: 20pt; }}
......@@ -133,44 +132,44 @@ class TestWkhtmlToPDF(HTMLtoPDFConversionFontTestMixin, CloudOooTestCase):
__partition_reference__ = 'wk'
pdf_producer = 'Qt 4.8.7'
expected_font_mapping = {
'Arial Black': 'Roboto-Medium',
'Arial': 'Roboto-Medium',
'Avant Garde': 'Roboto-Medium',
'Bookman': 'Roboto-Medium',
'Carlito': 'Roboto-Medium',
'Comic Sans MS': 'Roboto-Medium',
'Courier New': 'Roboto-Medium',
'DejaVu Sans Condensed': 'Roboto-Medium',
'DejaVu Sans ExtraLight': 'Roboto-Medium',
'DejaVu Sans Mono': 'Roboto-Medium',
'DejaVu Sans': 'Roboto-Medium',
'DejaVu Serif Condensed': 'Roboto-Medium',
'DejaVu Serif': 'Roboto-Medium',
'Garamond': 'Roboto-Medium',
'Gentium Basic': 'Roboto-Medium',
'Gentium Book Basic': 'Roboto-Medium',
'Georgia': 'Roboto-Medium',
'Helvetica': 'Roboto-Medium',
'Impact': 'Roboto-Medium',
'IPAex Gothic': 'Roboto-Medium',
'IPAex Mincho': 'Roboto-Medium',
'Arial': 'LiberationSans',
'Arial Black': 'LiberationSans',
'Avant Garde': 'LiberationSans',
'Bookman': 'LiberationSans',
'Carlito': 'Carlito',
'Comic Sans MS': 'LiberationSans',
'Courier New': 'LiberationSans',
'DejaVu Sans': 'DejaVuSans',
'DejaVu Sans Condensed': 'LiberationSans',
'DejaVu Sans ExtraLight': 'LiberationSans',
'DejaVu Sans Mono': 'DejaVuSansMono',
'DejaVu Serif': 'DejaVuSerif',
'DejaVu Serif Condensed': 'LiberationSans',
'Garamond': 'LiberationSans',
'Gentium Basic': 'GentiumBasic',
'Gentium Book Basic': 'GentiumBookBasic',
'Georgia': 'LiberationSans',
'Helvetica': 'LiberationSans',
'IPAex Gothic': 'LiberationSans',
'IPAex Mincho': 'LiberationSans',
'Impact': 'LiberationSans',
'Liberation Mono': 'LiberationMono',
'Liberation Sans Narrow': 'Roboto-Medium',
'Liberation Sans': 'LiberationSans',
'Liberation Sans Narrow': 'LiberationSansNarrow',
'Liberation Serif': 'LiberationSerif',
'Linux LibertineG': 'Roboto-Medium',
'OpenSymbol': 'Roboto-Medium',
'Palatino': 'Roboto-Medium',
'Roboto Black': 'Roboto-Medium',
'Roboto Condensed Light': 'Roboto-Medium',
'Roboto Condensed Regular': 'Roboto-Medium',
'Roboto Light': 'Roboto-Medium',
'Roboto Medium': 'Roboto-Medium',
'Roboto Thin': 'Roboto-Medium',
'Times New Roman': 'Roboto-Medium',
'Trebuchet MS': 'Roboto-Medium',
'Verdana': 'Roboto-Medium',
'ZZZdefault fonts when no match': 'Roboto-Medium',
'Linux LibertineG': 'LiberationSans',
'OpenSymbol': set(['DejaVuSans', 'OpenSymbol']),
'Palatino': 'LiberationSans',
'Roboto Black': 'LiberationSans',
'Roboto Condensed Light': 'LiberationSans',
'Roboto Condensed Regular': 'LiberationSans',
'Roboto Light': 'LiberationSans',
'Roboto Medium': 'LiberationSans',
'Roboto Thin': 'LiberationSans',
'Times New Roman': 'LiberationSans',
'Trebuchet MS': 'LiberationSans',
'Verdana': 'LiberationSans',
'ZZZdefault fonts when no match': 'LiberationSans'
}
def _convert_html_to_pdf(self, src_html):
......@@ -191,44 +190,44 @@ class TestLibreoffice(HTMLtoPDFConversionFontTestMixin, CloudOooTestCase):
__partition_reference__ = 'lo'
pdf_producer = 'LibreOffice 5.2'
expected_font_mapping = {
'Arial Black': 'LinuxLibertineG',
'Arial': 'LinuxLibertineG',
'Avant Garde': 'LinuxLibertineG',
'Bookman': 'LinuxLibertineG',
'Arial': 'LiberationSans',
'Arial Black': 'DejaVuSans',
'Avant Garde': 'DejaVuSans',
'Bookman': 'DejaVuSans',
'Carlito': 'Carlito',
'Comic Sans MS': 'LinuxLibertineG',
'Courier New': 'LinuxLibertineG',
'Comic Sans MS': 'DejaVuSans',
'Courier New': 'LiberationMono',
'DejaVu Sans': 'DejaVuSans',
'DejaVu Sans Condensed': 'DejaVuSansCondensed',
'DejaVu Sans ExtraLight': 'LinuxLibertineG',
'DejaVu Sans ExtraLight': 'DejaVuSans',
'DejaVu Sans Mono': 'DejaVuSansMono',
'DejaVu Sans': 'DejaVuSans',
'DejaVu Serif Condensed': 'DejaVuSerifCondensed',
'DejaVu Serif': 'DejaVuSerif',
'Garamond': 'LinuxLibertineG',
'DejaVu Serif Condensed': 'DejaVuSerifCondensed',
'Garamond': 'DejaVuSerif',
'Gentium Basic': 'GentiumBasic',
'Gentium Book Basic': 'GentiumBookBasic',
'Georgia': 'LinuxLibertineG',
'Helvetica': 'LinuxLibertineG',
'Impact': 'LinuxLibertineG',
'Georgia': 'DejaVuSerif',
'Helvetica': 'LiberationSans',
'IPAex Gothic': 'IPAexGothic',
'IPAex Mincho': 'IPAexMincho',
'Impact': 'DejaVuSans',
'Liberation Mono': 'LiberationMono',
'Liberation Sans Narrow': 'LiberationSansNarrow',
'Liberation Sans': 'LiberationSans',
'Liberation Sans Narrow': 'LiberationSansNarrow',
'Liberation Serif': 'LiberationSerif',
'Linux LibertineG': 'LinuxLibertineG',
'OpenSymbol': 'OpenSymbol',
'Palatino': 'LinuxLibertineG',
'Palatino': 'DejaVuSerif',
'Roboto Black': 'Roboto-Black',
'Roboto Condensed Light': 'RobotoCondensed-Light',
'Roboto Condensed Regular': 'LinuxLibertineG',
'Roboto Condensed Regular': 'DejaVuSans',
'Roboto Light': 'Roboto-Light',
'Roboto Medium': 'Roboto-Medium',
'Roboto Thin': 'Roboto-Thin',
'Times New Roman': 'LinuxLibertineG',
'Trebuchet MS': 'LinuxLibertineG',
'Verdana': 'LinuxLibertineG',
'ZZZdefault fonts when no match': 'LinuxLibertineG',
'Times New Roman': 'LiberationSerif',
'Trebuchet MS': 'DejaVuSans',
'Verdana': 'DejaVuSans',
'ZZZdefault fonts when no match': 'DejaVuSans'
}
def _convert_html_to_pdf(self, src_html):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment