[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ft-devel] How to map a char to glyph with pcf
From: |
Werner LEMBERG |
Subject: |
Re: [ft-devel] How to map a char to glyph with pcf |
Date: |
Wed, 21 Mar 2018 07:13:09 +0100 (CET) |
> I find it, I cannot use FT_Load_Char() to load the glyph from a pcf file.
> (face->charmaps[0]->encoding is zero)
Yes.
> and I make a dirty hack to do this mapping before using FT_Load_Glyph()
> Like:
> https://paste.ubuntu.com/p/T3M2mHVYg4/
> it works.
Mhmm, this is indeed an ad-hoc solution that may work for your
particular font but not in general
> My question is, is there any better way to map the "char" to "glyph"
> using The freetype2 libiray.
Yes, of course – IIRC I've mentioned already in a previous
e-mail that you need `iconv'...
You have to use function `FT_Get_BDF_Property' to extract the
`CHARSET_REGISTRY' and `CHARSET_ENCODING' fields from your PCF font.
Using this information you can set up, say, function `iconv' to map
from Unicode to the font's cmap.
Using
FT2_DEBUG=any:7 ftdump gothic14.pcf.Z
I see
CHARSET_REGISTRY: `KSC5601.1987'
CHARSET_ENCODING: `0'
in the debug messages. The characters in the font are indeed encoded
as plain KSC5601. A standard `iconv' call doesn't support this out of
the box, I think; you have to convert this to the EUC-KR form by
adding 0x8080 to each code point (e.g. 0x2121 -> 0xA1A1).[1]
This reminds me of good, old ISO-2022, with Emacs as the only editor
that really supports it :-)
Werner
[1] https://en.wikipedia.org/wiki/Extended_Unix_Code
Message not available