[XeTeX] Unicode math, was fontspec 1.5 (& Lucida Math)
Bruno Voisin
bvoisin at mac.com
Sat Dec 4 08:31:34 CET 2004
Le 4 déc. 04, à 02:25, Will Robertson a écrit :
> I've spent a small amount of time investigating the use of
> symbols/greek letters within unicode fonts for maths seeing what is
> possible with LaTeX's
> \DeclareMathSymbol{<symbol>}{<type>}{<font>}{<"slot">}
> command, but it's hard-coded (understandably) to only accept 256
> positions within a font.
>
> Something along the lines of Ross Moore's extension to
> \DeclareTextCommand to allow for unicode characters (in
> utf8accents.sty) is required, along with some sort of extended
> mathchar support of which I'm not too sure of the details.
I had the same kind of problem using Apple Symbols with XeLaTeX: text
fonts accepting (through \char) 16-bit characters codes, but math fonts
(through \mathchar) only 8-bit characters codes. Jonathan confirmed
this is a built-in limitation of XeTeX, due to the way TeX and eTeX
themselves work (the way \mathchar decomposes, for math fonts,
specifications such as "0000 into one digit for the type ot math entity
-- ordinary letter, binary operator, relation, delimiter, etc. --, one
digit for the font number -- math italic, math symbol, math extension,
etc. -- and two digits for the character code, I don't remember in
which order). Thus you'd have to modify TeX arithmetics, in such a way
that it accepts math character codes of the form "000000 -- certainly
no trivial work. I don't know whether the Omega/Aleph people have been
faced with this limitation, and, if so, how they solved it.
I ended up using text font commands, plus the \text command of the
amsmath package for use of text in maths. More of a dirty hack than a
real fix! Here's what it came up to:
> \DeclareFontFamily{U}{applsym}{}
> \DeclareFontShape{U}{applsym}{m}{n}{<-> "Apple\space Symbols"}{}
>
> %\DeclareSymbolFont{applesymbols}{U}{applsym}{m}{n}
>
> %\DeclareMathSymbol{\applehighplus} {\mathord}{applesymbols}{"253C}
> %\DeclareMathSymbol{\appleblacksquare} {\mathord}{applesymbols}{"25A0}
> %\DeclareMathSymbol{\applewhitesquare} {\mathord}{applesymbols}{"0040}
> %\DeclareMathSymbol{\appleblackdiamond}{\mathord}{applesymbols}{"25C6}
> %\DeclareMathSymbol{\applewhitediamond}{\mathord}{applesymbols}{"25C7}
> %\DeclareMathSymbol{\applewhitecircle} {\mathord}{applesymbols}{"25CB}
> %\DeclareMathSymbol{\appleblackcircle} {\mathord}{applesymbols}{"25CF}
>
> \DeclareTextFontCommand{\applesymbol}
> {\normalfont\fontencoding{U}\fontfamily{applsym}\selectfont}
>
> \DeclareRobustCommand{\applehighplus}
> {\text{\applesymbol{\char"253C}}}
> \DeclareRobustCommand{\appleblacksquare}
> {\text{\applesymbol{\char"25A0}}}
> \DeclareRobustCommand{\applewhitesquare}
> {\text{\applesymbol{\char"25A1}}}
> \DeclareRobustCommand{\appleblackdiamond}{\text{\applesymbol{\char"25C6
> }}}
> \DeclareRobustCommand{\applewhitediamond}{\text{\applesymbol{\char"25C7
> }}}
> \DeclareRobustCommand{\applewhitecircle}
> {\text{\applesymbol{\char"25CB}}}
> \DeclareRobustCommand{\appleblackcircle}
> {\text{\applesymbol{\char"25CF}}}
>
> \newcommand {\medcirc} {\applewhitecircle}
> \newcommand {\medbullet} {\appleblackcircle}
> \renewcommand{\Box} {\applewhitesquare}
> \renewcommand{\Diamond} {\applewhitediamond}
> \renewcommand{\square} {\applewhitesquare}
> \renewcommand{\blacksquare} {\appleblacksquare}
> \renewcommand{\lozenge} {\applewhitediamond}
> \renewcommand{\blacklozenge}{\appleblackdiamond}
First is (commented out) the failed attempt using math font commands,
then the hack using text font commands, then the redefinition of
symbols from the packages latexsym.sty (\Box and \Diamond) and
amssymb.sty (\square, \blacksquare, \lozenge and \blacklozenge), and
the definition of symbols similar to those in the package txfonts.sty
(\medcirc and \medbullet).
All this was for labelling the caption of a figure with lookalikes of
the symbols used in the figure. With pdfLaTeX, I got similar symbols
using the AMS and TX fonts:
> \usepackage{amssymb}
>
> \DeclareSymbolFont{symbolsC} {U}{txsyc}{m} {n}
> \SetSymbolFont {symbolsC}{bold}{U}{txsyc}{bx}{n}
>
> \DeclareMathSymbol{\medcirc} {\mathbin}{symbolsC}{7}
> \DeclareMathSymbol{\medbullet}{\mathbin}{symbolsC}{8}
Bruno Voisin
More information about the XeTeX
mailing list