Alan Coopersmith
2010-May-10 23:13 UTC
[Fontconfig] fontconfig not recognizing Luxi Mono as monospace
One of the fonts X.Org distributes is "Luxi Mono", aka luximr.ttf from either: cgit.freedesktop.org/xorg/font/bh-ttf/tree or: xorg.freedesktop.org/releases/individual/font/font-bh-ttf-1.0.1.tar.bz2 One of our users complained that he couldn''t get xterm to accept this font with: xterm -fa "LuxiMono-10" - it always chose the bold version instead of the regular, since xterm specifies that it needs a monospaced font, but fontconfig thinks only the bold font is monospaced and the roman version is not.
Behdad Esfahbod
2010-Jun-02 21:45 UTC
[Fontconfig] fontconfig not recognizing Luxi Mono as monospace
On 05/10/2010 07:13 PM, Alan Coopersmith wrote:>>From digging around, it seems like there''s a glyph with an advance width > of 0 in luximr.ttf that fontconfig doesn''t expect in this font which is > confusing it, and making it classify it as not monospaced. > > Is this a bug in fontconfig''s monospace recognition or a bug in the font?I''d say both. Patch welcome. behdad
Alan Coopersmith
2010-Jun-03 00:02 UTC
[Fontconfig] fontconfig not recognizing Luxi Mono as monospace
Behdad Esfahbod wrote:> On 05/10/2010 07:13 PM, Alan Coopersmith wrote: >> >From digging around, it seems like there''s a glyph with an advance width >> of 0 in luximr.ttf that fontconfig doesn''t expect in this font which is >> confusing it, and making it classify it as not monospaced. >> >> Is this a bug in fontconfig''s monospace recognition or a bug in the font? > > I''d say both. Patch welcome.Strangely, when trying to reproduce with a freshly updated git clone, it''s now the non-bold variants with spacing=100, and the bold ones failed to match. By inserting a printf into FcFreeTypeCharSetAndSpacingForSize and running fc-cache from git master, it''s only finding characters with an advance of 1229 in luximr.ttf & luximri.ttf, but in luximb.ttf & luximbi.ttf it finds 4 each with an advance of 1338, and one with advance of 682: Glyph: 0x 175 Advance: 682 Glyph: 0x c4 Advance: 1338 Glyph: 0x c5 Advance: 1338 Glyph: 0x c2 Advance: 1338 Glyph: 0x c6 Advance: 1338 I''m not sure why these glyphs are different width, or what criteria fontconfig should be using to decide they''re not to be counted towards the spacing calculation, so I can''t suggest a fontconfig patch right now. I can easily add a fonts.conf file to the X.Org fonts/bh-ttf package to override it there though. -- -Alan Coopersmith- alan.coopersmith at oracle.com Oracle Solaris Platform Engineering: X Window System
Alan Coopersmith
2010-Jun-03 00:20 UTC
[Fontconfig] [PATCH:font/bh-ttf] Install a fontconfig snippet to force treating Luxi Mono fonts as monospaced
fontconfig detects multiple character advances in some of the Luxi Mono fonts, so doesn''t think they''re monospaced. This causes problems when running xterm -fa "Luxi Mono", since it adds :spacing=100 to the pattern when requesting a font from fontconfig to prefer monospaced fonts. Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com> --- For the background here, see the thread "fontconfig not recognizing Luxi Mono as monospace" on the fontconfig mailing list recently. 42-luxi-mono.conf | 12 ++++++++++++ Makefile.am | 8 ++++++++ 2 files changed, 20 insertions(+), 0 deletions(-) create mode 100644 42-luxi-mono.conf diff --git a/42-luxi-mono.conf b/42-luxi-mono.conf new file mode 100644 index 0000000..7babe82 --- /dev/null +++ b/42-luxi-mono.conf @@ -0,0 +1,12 @@ +<?xml version="1.0"?> +<!DOCTYPE fontconfig SYSTEM "fonts.dtd"> +<!-- force fontconfig to treat the Luxi Mono fonts as monospaced, even + though it detects multiple character widths --> +<fontconfig> + <match target="scan"> + <test name="family"> + <string>Luxi Mono</string> + </test> + <edit name="spacing"><int>100</int></edit> + </match> +</fontconfig> diff --git a/Makefile.am b/Makefile.am index c709ad9..2417e91 100644 --- a/Makefile.am +++ b/Makefile.am @@ -36,6 +36,11 @@ FONT_FILES = \ fontdir = @FONTDIR@ font_DATA = $(FONT_FILES) +fontconfigdir = $(sysconfdir)/fonts/conf +actualconfigdir = $(fontconfigdir)/conf.d +availconfigdir = $(fontconfigdir)/conf.avail +availconfig_DATA = 42-luxi-mono.conf + EXTRA_DIST = $(FONT_FILES) COPYRIGHT.BH MAINTAINERCLEANFILES = ChangeLog INSTALL @@ -45,6 +50,9 @@ install-data-hook: $(MKFONTSCALE) $(DESTDIR)$(fontdir) @rm -f $(DESTDIR)$(fontdir)/font.dir $(MKFONTDIR) $(DESTDIR)$(fontdir) + mkdir -p $(DESTDIR)$(actualconfigdir) + @rm -f $(DESTDIR)$(actualconfigdir)/$(availconfig_DATA) + ln -s ../conf.avail/$(availconfig_DATA) $(DESTDIR)$(actualconfigdir) @RUN_FCCACHE@ distuninstallcheck: -- 1.5.6.5