[XeTeX] anti-xunicode ;-)
Ross Moore
ross at ics.mq.edu.au
Sun Jul 23 06:32:50 CEST 2006
Hi Jonathan, François, and others,
On 22/07/2006, at 12:12 AM, Jonathan Kew wrote:
> On 21 Jul 2006, at 2:58 pm, François Charette wrote:
> I'd be pretty wary of fallbacks that involve getting glyphs from
> another font;
Agreed, about getting from another font, automatically.
The author of a document needs to have explicit input
into handling awkward characters that way.
> what I think is much more useful, in general, is the
> ability to fall back to the use of \accent, etc., when the font
> doesn't include all the precomposed glyphs (or full positioning
> support so that decomposed Unicode sequences of base + diacritic(s)
> render well).
xunicode.sty currently implements fall-backs to combining characters
when the precomposed glyph isn't declared to be available.
You can use the following LaTeX coding to test this feature.
\documentclass{article}
\usepackage{fontspec}
\usepackage{xunicode}
\setromanfont[Mapping=tex-text]{Lucida Grande}
\begin{document}
\"u
\UndeclareUTFcomposite[U]{x00FC}{\"}{u}
\"u
\end{document}
Here the first \"u gets set as Ux00A8
while the 2nd gives the combination u Ux0308 .
xunicode.sty could (and perhaps should) be modified to also include
a check for the precomposed glyph, then use the fall-back if not found.
But this thread is about having yet another kind of fall-back,
whereby TeX positions the accent-glyph over a letter, as it
used to do, and still does with OT1 encoding.
Here is a way to achieve this.
\documentclass[11pt,a4paper]{article}
\usepackage{fontspec}
\usepackage{xunicode}
\setromanfont[Mapping=tex-text]{Lucida Grande}
\makeatletter
\def\changefencoding#1{\def\cf at encoding{#1}}
\makeatother
\let\realaccent\" %% this is important ...
\DeclareTextAccent{\"}{UX}{"00A8}
\let\"\realaccent %% ... to avoid an infinite loop
\begin{document}
{%\tracingall
\"u
\UndeclareUTFcomposite[U]{x00FC}{\"}{u}
\"u
\changefencoding{UX}%
\"u
}
\end{document}
Now the 3rd instance of \"u is set by placing Ux00A8
appropriately above the letter u .
One way to check these claims is to uncomment before
\tracingall , and check the .log file or Console window.
There you can find that the 3 instances result in,
respectively:
1st instance:
\\U\"-u ->\char "00FC\relax
2nd instance:
\@secondoftwo #1#2->#2
#1<-\\U\"-u
#2<-\add at encoded@accent {0308}{u}{00A8}
\add at encoded@accent #1#2#3->\ifx \relax #2\relax \char "#3\else \ifx
\ #2\relax
\char "#3\else \expandafter \ifx \UTF at space #2\relax \char "#3\else
\ifx ~#2\c
har "#3\else #2\char "#1\fi \fi \fi \fi \relax
#1<-0308
#2<-u
#3<-00A8
(... ultimately gets to the final branch: #2\char "#1 )
3rd instance:
\UX\" ->\add at accent {"00A8}
\add at accent #1#2->\hmode at bgroup \let \hmode at start@before at group
\@firstofone \se
tbox \@tempboxa \hbox {#2\global \mathchardef \accent at spacefactor
\spacefactor
}\accent #1 #2\egroup \spacefactor \accent at spacefactor
#1<-"00A8
#2<-u
Note that this latter method *is* the OT1 method of placing
accents.
For accents that "go under", as with \d (dot-under accent),
there is a slight variation, since the OT1 method doesn't
use \add at accent for these.
However, this works:
\let\realaccent\d
\DeclareTextAccent{\d}{UX}{"002E}
\expandafter\let\csname UX\string\d\expandafter\endcsname\csname OT1
\string\d\endcsname
\let\d\realaccent
>
> This could be a little like a generalized extension of MLTeX's
> \charsubdef, which in theory exists in xetex, but is not fully
> Unicode-enabled. This is something I'd like to enhance at some point,
> as suggested by Mojca, but I can't offer a timescale of when it might
> happen.
The above examples show that XeLaTeX already has the ability to do
what the OP requested; namely to have a sequence of fall-backs
available for accented characters, according to what is available
in the font, or font-encoding.
It just takes a little bit of careful exploring to find the best
way to hook into LaTeX's font-handling mechanism.
If you want the same ability in (Plain) XeTeX or XeConTeXt
well, that's a different story.
>
> JK
Hope this helps,
Ross
------------------------------------------------------------------------
Ross Moore ross at maths.mq.edu.au
Mathematics Department office: E7A-419
Macquarie University tel: +61 +2 9850 8955
Sydney, Australia 2109 fax: +61 +2 9850 8114
------------------------------------------------------------------------
More information about the XeTeX
mailing list