[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#976172: xfonts-utils: fonttosfnt gives error "Couldn't select character map"



Package: xfonts-utils
Version: 1:7.7+6
Severity: normal

It seems that the call to FT_Select_Charmap at read.c:231 does not work for
some fonts, at least. I tried it with a Latin-1 encoded BDF font.

By default, fonttosfnt wants to reencode as Unicode, which is fine. Freetype
finds the Latin-1 encoding of the BDF font, and thus decides it needs to be
reencoded, although for some reason it records the charmap as Unicode (which
is fine, being a superset of Latin-1).

The logic at read.c:228 then tries to select the ft_encoding_none charmap,
which is only valid for bitmap fonts with no encoding (reading the freetype
source, ftobjs.c:3512). But this bitmap font has an encoding, so it is not
allowed.

I think the test at line 228 is bogus: for a symbol font (i.e. one that
declares no encoding) it’s OK to use ft_encoding_none. Otherwise, if we’re
recoding (i.e. we have a mapping) then we should use ft_encoding_unicode. If
we’re in neither case, then we should just use the existing charmap, i.e.
not call FT_Select_Charmap. Hence, this stanza should look something like:

    rc = 0; // In case we do nothing
    if(symbol)
        rc = FT_Select_Charmap(face, ft_encoding_none);
    else if(mapping)
        rc = FT_Select_Charmap(face, ft_encoding_unicode);

Of course in my case, the selection of a Charmap is a no-op, since it merely
reselects the only charmap in the font.

-- System Information:
Debian Release: bullseye/sid
  APT prefers focal-updates
  APT policy: (500, 'focal-updates'), (500, 'focal-security'), (500, 'focal'), (100, 'focal-backports')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 5.4.0-54-generic (SMP w/16 CPU cores)
Kernel taint flags: TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8), LANGUAGE=en_GB (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages xfonts-utils depends on:
ii  libc6             2.31-0ubuntu9.1
ii  libfontenc1       1:1.1.4-0ubuntu1
ii  libfreetype6      2.10.1-2ubuntu0.1
ii  x11-common        1:7.7+19ubuntu14
ii  xfonts-encodings  1:1.0.5-0ubuntu1
ii  zlib1g            1:1.2.11.dfsg-2ubuntu1.2

xfonts-utils recommends no packages.

xfonts-utils suggests no packages.

-- no debconf information

Reply to: