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 = ...@@ -61,15 +61,10 @@ fonts =
${ipaex-fonts:location} ${ipaex-fonts:location}
${liberation-fonts:location} ${liberation-fonts:location}
${ocrb-fonts:location} ${ocrb-fonts:location}
# XXX These fonts have always been missing in cloudooo, but we want ${dejavu-fonts:location}
# keep compatibility a little bit more. ${libreoffice-bin:location}/share/fonts/
# ${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
fontconfig-includes = fontconfig-includes =
# ${fontconfig:location}/etc/fonts/conf.d ${fontconfig:location}/etc/fonts/conf.d
freetype = ${freetype:location} freetype = ${freetype:location}
glib = ${glib:location} glib = ${glib:location}
......
...@@ -103,8 +103,7 @@ class HTMLtoPDFConversionFontTestMixin: ...@@ -103,8 +103,7 @@ class HTMLtoPDFConversionFontTestMixin:
def test(self): def test(self):
actual_font_mapping_mapping = {} actual_font_mapping_mapping = {}
for font, expected_substitution in sorted( for font in self.expected_font_mapping:
self.expected_font_mapping.items()):
src_html = ''' src_html = '''
<style> <style>
p {{ font-family: "{font}"; font-size: 20pt; }} p {{ font-family: "{font}"; font-size: 20pt; }}
...@@ -133,44 +132,44 @@ class TestWkhtmlToPDF(HTMLtoPDFConversionFontTestMixin, CloudOooTestCase): ...@@ -133,44 +132,44 @@ class TestWkhtmlToPDF(HTMLtoPDFConversionFontTestMixin, CloudOooTestCase):
__partition_reference__ = 'wk' __partition_reference__ = 'wk'
pdf_producer = 'Qt 4.8.7' pdf_producer = 'Qt 4.8.7'
expected_font_mapping = { expected_font_mapping = {
'Arial Black': 'Roboto-Medium', 'Arial': 'LiberationSans',
'Arial': 'Roboto-Medium', 'Arial Black': 'LiberationSans',
'Avant Garde': 'Roboto-Medium', 'Avant Garde': 'LiberationSans',
'Bookman': 'Roboto-Medium', 'Bookman': 'LiberationSans',
'Carlito': 'Roboto-Medium', 'Carlito': 'Carlito',
'Comic Sans MS': 'Roboto-Medium', 'Comic Sans MS': 'LiberationSans',
'Courier New': 'Roboto-Medium', 'Courier New': 'LiberationSans',
'DejaVu Sans Condensed': 'Roboto-Medium', 'DejaVu Sans': 'DejaVuSans',
'DejaVu Sans ExtraLight': 'Roboto-Medium', 'DejaVu Sans Condensed': 'LiberationSans',
'DejaVu Sans Mono': 'Roboto-Medium', 'DejaVu Sans ExtraLight': 'LiberationSans',
'DejaVu Sans': 'Roboto-Medium', 'DejaVu Sans Mono': 'DejaVuSansMono',
'DejaVu Serif Condensed': 'Roboto-Medium', 'DejaVu Serif': 'DejaVuSerif',
'DejaVu Serif': 'Roboto-Medium', 'DejaVu Serif Condensed': 'LiberationSans',
'Garamond': 'Roboto-Medium', 'Garamond': 'LiberationSans',
'Gentium Basic': 'Roboto-Medium', 'Gentium Basic': 'GentiumBasic',
'Gentium Book Basic': 'Roboto-Medium', 'Gentium Book Basic': 'GentiumBookBasic',
'Georgia': 'Roboto-Medium', 'Georgia': 'LiberationSans',
'Helvetica': 'Roboto-Medium', 'Helvetica': 'LiberationSans',
'Impact': 'Roboto-Medium', 'IPAex Gothic': 'LiberationSans',
'IPAex Gothic': 'Roboto-Medium', 'IPAex Mincho': 'LiberationSans',
'IPAex Mincho': 'Roboto-Medium', 'Impact': 'LiberationSans',
'Liberation Mono': 'LiberationMono', 'Liberation Mono': 'LiberationMono',
'Liberation Sans Narrow': 'Roboto-Medium',
'Liberation Sans': 'LiberationSans', 'Liberation Sans': 'LiberationSans',
'Liberation Sans Narrow': 'LiberationSansNarrow',
'Liberation Serif': 'LiberationSerif', 'Liberation Serif': 'LiberationSerif',
'Linux LibertineG': 'Roboto-Medium', 'Linux LibertineG': 'LiberationSans',
'OpenSymbol': 'Roboto-Medium', 'OpenSymbol': set(['DejaVuSans', 'OpenSymbol']),
'Palatino': 'Roboto-Medium', 'Palatino': 'LiberationSans',
'Roboto Black': 'Roboto-Medium', 'Roboto Black': 'LiberationSans',
'Roboto Condensed Light': 'Roboto-Medium', 'Roboto Condensed Light': 'LiberationSans',
'Roboto Condensed Regular': 'Roboto-Medium', 'Roboto Condensed Regular': 'LiberationSans',
'Roboto Light': 'Roboto-Medium', 'Roboto Light': 'LiberationSans',
'Roboto Medium': 'Roboto-Medium', 'Roboto Medium': 'LiberationSans',
'Roboto Thin': 'Roboto-Medium', 'Roboto Thin': 'LiberationSans',
'Times New Roman': 'Roboto-Medium', 'Times New Roman': 'LiberationSans',
'Trebuchet MS': 'Roboto-Medium', 'Trebuchet MS': 'LiberationSans',
'Verdana': 'Roboto-Medium', 'Verdana': 'LiberationSans',
'ZZZdefault fonts when no match': 'Roboto-Medium', 'ZZZdefault fonts when no match': 'LiberationSans'
} }
def _convert_html_to_pdf(self, src_html): def _convert_html_to_pdf(self, src_html):
...@@ -191,44 +190,44 @@ class TestLibreoffice(HTMLtoPDFConversionFontTestMixin, CloudOooTestCase): ...@@ -191,44 +190,44 @@ class TestLibreoffice(HTMLtoPDFConversionFontTestMixin, CloudOooTestCase):
__partition_reference__ = 'lo' __partition_reference__ = 'lo'
pdf_producer = 'LibreOffice 5.2' pdf_producer = 'LibreOffice 5.2'
expected_font_mapping = { expected_font_mapping = {
'Arial Black': 'LinuxLibertineG', 'Arial': 'LiberationSans',
'Arial': 'LinuxLibertineG', 'Arial Black': 'DejaVuSans',
'Avant Garde': 'LinuxLibertineG', 'Avant Garde': 'DejaVuSans',
'Bookman': 'LinuxLibertineG', 'Bookman': 'DejaVuSans',
'Carlito': 'Carlito', 'Carlito': 'Carlito',
'Comic Sans MS': 'LinuxLibertineG', 'Comic Sans MS': 'DejaVuSans',
'Courier New': 'LinuxLibertineG', 'Courier New': 'LiberationMono',
'DejaVu Sans': 'DejaVuSans',
'DejaVu Sans Condensed': 'DejaVuSansCondensed', 'DejaVu Sans Condensed': 'DejaVuSansCondensed',
'DejaVu Sans ExtraLight': 'LinuxLibertineG', 'DejaVu Sans ExtraLight': 'DejaVuSans',
'DejaVu Sans Mono': 'DejaVuSansMono', 'DejaVu Sans Mono': 'DejaVuSansMono',
'DejaVu Sans': 'DejaVuSans',
'DejaVu Serif Condensed': 'DejaVuSerifCondensed',
'DejaVu Serif': 'DejaVuSerif', 'DejaVu Serif': 'DejaVuSerif',
'Garamond': 'LinuxLibertineG', 'DejaVu Serif Condensed': 'DejaVuSerifCondensed',
'Garamond': 'DejaVuSerif',
'Gentium Basic': 'GentiumBasic', 'Gentium Basic': 'GentiumBasic',
'Gentium Book Basic': 'GentiumBookBasic', 'Gentium Book Basic': 'GentiumBookBasic',
'Georgia': 'LinuxLibertineG', 'Georgia': 'DejaVuSerif',
'Helvetica': 'LinuxLibertineG', 'Helvetica': 'LiberationSans',
'Impact': 'LinuxLibertineG',
'IPAex Gothic': 'IPAexGothic', 'IPAex Gothic': 'IPAexGothic',
'IPAex Mincho': 'IPAexMincho', 'IPAex Mincho': 'IPAexMincho',
'Impact': 'DejaVuSans',
'Liberation Mono': 'LiberationMono', 'Liberation Mono': 'LiberationMono',
'Liberation Sans Narrow': 'LiberationSansNarrow',
'Liberation Sans': 'LiberationSans', 'Liberation Sans': 'LiberationSans',
'Liberation Sans Narrow': 'LiberationSansNarrow',
'Liberation Serif': 'LiberationSerif', 'Liberation Serif': 'LiberationSerif',
'Linux LibertineG': 'LinuxLibertineG', 'Linux LibertineG': 'LinuxLibertineG',
'OpenSymbol': 'OpenSymbol', 'OpenSymbol': 'OpenSymbol',
'Palatino': 'LinuxLibertineG', 'Palatino': 'DejaVuSerif',
'Roboto Black': 'Roboto-Black', 'Roboto Black': 'Roboto-Black',
'Roboto Condensed Light': 'RobotoCondensed-Light', 'Roboto Condensed Light': 'RobotoCondensed-Light',
'Roboto Condensed Regular': 'LinuxLibertineG', 'Roboto Condensed Regular': 'DejaVuSans',
'Roboto Light': 'Roboto-Light', 'Roboto Light': 'Roboto-Light',
'Roboto Medium': 'Roboto-Medium', 'Roboto Medium': 'Roboto-Medium',
'Roboto Thin': 'Roboto-Thin', 'Roboto Thin': 'Roboto-Thin',
'Times New Roman': 'LinuxLibertineG', 'Times New Roman': 'LiberationSerif',
'Trebuchet MS': 'LinuxLibertineG', 'Trebuchet MS': 'DejaVuSans',
'Verdana': 'LinuxLibertineG', 'Verdana': 'DejaVuSans',
'ZZZdefault fonts when no match': 'LinuxLibertineG', 'ZZZdefault fonts when no match': 'DejaVuSans'
} }
def _convert_html_to_pdf(self, src_html): 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