[texhax] pdftex and Unicode

David Carlisle d.p.carlisle at gmail.com
Sun Aug 26 17:11:08 CEST 2018

On Sun, 26 Aug 2018 at 01:37, D. R. Evans <doc.evans at gmail.com> wrote:
> I have a document that uses just one font, \tt, and contains the string "1/2".
> The document renders perfectly under pdftex.
> I would like to change the document so that instead of "1/2", it uses the
> single Unicode character ½ (VULGAR FRACTION ONE HALF, Unicode character 555,
> 0x22b).
> https://texfaq.org/FAQ-unicode says:
> > “Modern” TeX-alike applications, XeTeX and LuaTeX read their input using
> > UTF-8 representations of Unicode as standard. They also use TrueType or
> > OpenType fonts for output; each such font has tables that tell the
> > application which part(s) of the Unicode space it covers; the tables enable
> > the engines to decide which font to use for which character (assuming there
> > is any choice at all).

We should probably adjust that wording a bit. The OpenType tables do say which
scripts or Unicode ranges a font covers but (unlike say CSS) the tex
engines will
not automatically load any font until it finds a font with the
required character, as in classic tex
it is up to the document author to say which font to use at any point.

However if you have a monospace font that has ½ it is easy to use it
in xetex or luatex, for example
I have Lucida Console (from somewhere) and this works for me

\font\tt="Lucida Console" at 10pt

\tt  half [½]



producing the attached output

> No errors are raised by pdftex, but the "½" character is absent in the output.
> What is the correct way to have pdftex produce the "½" glyph?

the quote from the texfaq was about xetex or luatex so not really
relevant to pdftex

If you were using latex then it has built in support for decoding
UTF-8 and you could define ½ to be anything that pdftex can output,
for example $\frac{1}{2}$ but in plain tex It's probably not worth the
effort, and using a Unicode tex engine such as xetex or luatex will be
a lot easier.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: half.png
Type: image/png
Size: 1135 bytes
Desc: not available
URL: <https://tug.org/pipermail/texhax/attachments/20180826/dc2d056d/attachment.png>

More information about the texhax mailing list