fontconfig should prefer DejaVu over Bitstream Vera

Bug #2043829 reported by Skia
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
fontconfig (Debian)
New
Undecided
fontconfig (Ubuntu)
New
Undecided
Unassigned

Bug Description

Imported from Debian bug http://bugs.debian.org/981577:

Message part #1
Package: ttf-bitstream-vera
Version: 1.10-8.1
Control: affects -1 chromium fontconfig python-matplotlib-data src:fonts-dejavu

Textual tables drawn with standard UTF-8 box drawing characters
(U+2500…U+25FF) are being mis-rendered by Chromium in a common default
configuration.

    https://dkg.fifthhorseman.net/table.txt

ships a text/plain; charset=UTF-8 file contains a simple textual table
for testing:

     ╒══════════════════╤═══════════════════════════╤═════════════════════╕
     │ This is a Table │ It contains text │ Implemented with │
     ╞══════════════════╪═══════════════════════════╪═════════════════════╡
     │ Unicode │ Box drawing │ Characters │
     └──────────────────┴───────────────────────────┴─────────────────────┘

It is mis-rendered by default on chromium on systems that have Bitstream
Vera Mono installed, like so:

Message part #2
[inline image 'bitstream-vera-chromium.png']

Message part #3

If I remove ttf-bitstream-vera from the system, then Chromium renders
the text with DejaVu Sans Mono instead, yielding a correct view:

Message part #4
[inline image 'dejavu-chromium.png']

Message part #5

I think what's happening is that Chromium selects Vera Sans through
fontconfig, and then when it discovers missing glyphs, it falls back to
rendering those glyphs in some other font, which does not have the same
width as Vera Sans. This results in mis-rendered tables that use
unicode box drawing.

Possible Solutions
------------------

I see a few different possible fixes, in different places:

 - Bitstream Vera Mono could implement monospaced glyphs for the unicode
   box drawing characters

 - fontconfig could prefer more complete fonts when searching for a
   match, which would prioritize dejavu sans (or some other more
   complete font) over bitstream vera

 - fontconfig could manually prefer DejaVu Sans Mono over Bitstream Vera
   Mono when given the search string "monospace"

 - chromium, when substituting missing glyphs in a monospace font, could
   ensure that the substitute glyphs are appropriately sized for the
   font they are filling in for.

 - chromium could hardcode (and depend on?) a preferred monospace font
   by default that is more complete than Bistream Vera as its default
   monospace font

 - We could drop ttf-bitstream-vera from the archive, which would affect
   packages like python-matplotlib-data, gravit-data, and the ~20 other
   packages that Depend on ttf-bitstream-vera directly. I can't afford
   to just purge the package from my system because i need matplotlib :(

 - fonts-dejavu-core (or fonts-dejavu-extra?) could Provide:
   ttf-bitstream-vera, since it appears to provide aliases for Bitstream
   Vera in e.g. /etc/fonts/conf.avail/57-dejavu-sans-mono.conf -- i
   don't know whether this is sufficient for all the explicit
   Dependencies of ttf-bitstream-vera, though.

Diagnosis
---------

Chromium's default monospace font appears to rely on fontconfig for
selection.

In particular, i think it sends font-config the "monospace" search term,
which when Bitstream Vera is installed results in:

    0 dkg@alice:~$ fc-match monospace
    VeraMono.ttf: "Bitstream Vera Sans Mono" "Roman"
    0 dkg@alice:~$

Without bitstream-vera installed, it looks like fontconfig will prefer
dejavu sans mono, which contains these glyphs and doesn't break the
rendering:

    0 dkg@alice:~$ fc-match --sort monospace | head
    VeraMono.ttf: "Bitstream Vera Sans Mono" "Roman"
    DejaVuSansMono.ttf: "DejaVu Sans Mono" "Book"
    DejaVuSansMono-Bold.ttf: "DejaVu Sans Mono" "Bold"
    DejaVuSansMono-Oblique.ttf: "DejaVu Sans Mono" "Oblique"
    Inconsolata.otf: "Inconsolata" "Medium"
    Andale_Mono.ttf: "Andale Mono" "Regular"
    Courier_New.ttf: "Courier New" "Regular"
    Courier_New_Italic.ttf: "Courier New" "Italic"
    n022003l.pfb: "Nimbus Mono L" "Regular"
    NimbusMonoPS-Regular.otf: "Nimbus Mono PS" "Regular"
    0 dkg@alice:~$

To verify my suspicion about font replacement characters, i used
"fontimage" from the fontforge package to render the files in question
explicitly:

I tried rendering the table using fontimage with the two fonts:

    fontimage -o veramono.png --pixelsize 10 \
      --text '╒══════════════════╤═══════════════════════════╤═════════════════════╕' \
      --text '│ This is a Table │ It contains text │ Implemented with │' \
      --text '╞══════════════════╪═══════════════════════════╪═════════════════════╡' \
      --text '│ Unicode │ Box drawing │ Characters │' \
      --text '└──────────────────┴───────────────────────────┴─────────────────────┘' \
    /usr/share/fonts/truetype/ttf-bitstream-vera/VeraMono.ttf

Message part #6
[inline image 'veramono.png']

Message part #7

    fontimage -o dejavusansmono.png --pixelsize 10 \
      --text '╒══════════════════╤═══════════════════════════╤═════════════════════╕' \
      --text '│ This is a Table │ It contains text │ Implemented with │' \
      --text '╞══════════════════╪═══════════════════════════╪═════════════════════╡' \
      --text '│ Unicode │ Box drawing │ Characters │' \
      --text '└──────────────────┴───────────────────────────┴─────────────────────┘' \
    /usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf

Message part #8
[inline image 'dejavusansmono.png']

Message part #9

My takeaway from these two images is that Vera Mono doesn't have the
box drawing glyphs at all, but DejaVu Sans Mono does have them.

----

I recognize that this report is likely to be difficult for debian to
handle as there are so many different packages that are involved. I've
initially assigned it to ttf-bitstream-vera, but if the maintainers of
that package think that the best solution lies outside of that package,
i hope they'll re-assign it appropriately.

Regards,

  --dkg

Revision history for this message
Skia (hyask) wrote :

Imported from Debian bug http://bugs.debian.org/981577

Revision history for this message
Skia (hyask) wrote :

Imported from Debian bug http://bugs.debian.org/981577

Revision history for this message
Skia (hyask) wrote :

Imported from Debian bug http://bugs.debian.org/981577

Revision history for this message
Skia (hyask) wrote :

Imported from Debian bug http://bugs.debian.org/981577

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.