Re: [XeTeX] Detect, whether a font contains a certain character
Hi, thanks to your answers. Am 28.11.2011 09:19, schrieb Jonathan Kew: [snip] Assuming the OP is interested in native truetype/opentype fonts, not .tfm-based fonts, \XeTeXcharglyph is the simple answer. JK As I normally use (Linux Libertine O or TeX Gyre Pagella), Linux Biolinum O and Asana Math, I'm interested i native opentype fonts. \XeTeXcharglyph (and Heiko's code) work in text mode. But I also print SI values in math mode, where it doesn't work. See the minimal example: \documentclass{minimal} \usepackage{fontspec} \usepackage{unicode-math} \setmainfont{DejaVu Serif} \setmathfont{XITS Math} \usepackage{siunitx} \sisetup{% detect-all, } \usepackage{pgffor} \begin{document} \sisetup{% text-celsius=9 } \foreach \phont in {TeX Gyre Pagella, Linux Libertine O, DejaVu Serif} { \setmainfont{\phont} \ifnum\XeTeXfonttype\font0 7 \ifnum\XeTeXcharglyph21030 8 \sisetup{text-celsius=℃}\SI{123}{\celsius} \fi \fi \SI{456}{\celsius}\\ } \sisetup{% math-celsius=9 } \foreach \phont in {Asana Math, XITS Math, STIXGeneral, Neo Euler} { \setmathfont{\phont} \(\ifnum\XeTeXfonttype\font0 7 \ifnum\XeTeXcharglyph21030 8 \sisetup{math-celsius=℃}\SI{123}{\celsius} \fi \fi\) \(\SI{456}{\celsius}\)\\ } \end{document} Although u2103 (why did Heiko use u018e=latin capital reversed E?) is only available in Asana Math (which on the other hand doesn't have °) the innermost \if yields true (can be seen by printing the 8 and setting math-celsius to a not-defined glyph). Another problem (but that might be due to siunitx): the following \SI{456}{\celsius} doesn't know about the \sisetup in the math before. I assume this has something to do with grouping and local/global changes. But how can I check for glyph availability in math fonts whithout going into math mode via \(\)? Thanks Toscho -- Subscriptions, Archive, and List information, etc.: http://tug.org/mailman/listinfo/xetex
Re: [XeTeX] Detect, whether a font contains a certain character
Am Mon, 28 Nov 2011 11:44:08 +0200 schrieb Tobias Schoel: \XeTeXcharglyph (and Heiko's code) work in text mode. But I also print SI values in math mode, where it doesn't work. See the minimal example: \foreach \phont in {Asana Math, XITS Math, STIXGeneral, Neo Euler} { \setmathfont{\phont} \(\ifnum\XeTeXfonttype\font0 7 \ifnum\XeTeXcharglyph21030 8 \sisetup{math-celsius=℃}\SI{123}{\celsius} \fi \fi\) \(\SI{456}{\celsius}\)\\ } Although u2103 (why did Heiko use u018e=latin capital reversed E?) is only available in Asana Math (which on the other hand doesn't have °) the innermost \if yields true (can be seen by printing the 8 and setting math-celsius to a not-defined glyph). You are testing the current text font. It works if you use e.g. \foreach \phont in {Asana Math, XITS Math, STIXGeneral} { \setmathfont{\phont} \setmainfont{\phont} or \foreach \phont in {Asana Math, XITS Math, STIXGeneral} { \setmathfont{\phont} \font\test=\phont \test Then you also don't need math mode. But as you switch fonts, you should do the test in a group and then set some global value which you can use outside the group to setup siunitx. -- Ulrike Fischer -- Subscriptions, Archive, and List information, etc.: http://tug.org/mailman/listinfo/xetex
Re: [XeTeX] Detect, whether a font contains a certain character
So this seems to work: \documentclass{minimal} \usepackage{fontspec} \usepackage{unicode-math} \setmathfont{XITS Math} \usepackage{siunitx} \sisetup{% detect-all, } \newcounter{works} \setcounter{works}{0} \usepackage{pgffor} \begin{document} \newcommand{\ifavailablethenelse}[4]{%#1=font,#2=charcode,#3=then-clause,#4=else-clause \setcounter{works}{0} \bgroup \font\test=#1 \test \ifnum\XeTeXfonttype\font0 \ifnum\XeTeXcharglyph#20 \setcounter{works}{1} \fi \fi \egroup \ifnum\theworks=1 #3 \else #4 \fi } \sisetup{math-celsius=foo} \foreach \phont in {Asana Math,XITS Math, STIXGeneral, Neo Euler} { \ifavailablethenelse{\phont}{2103}{\sisetup{math-celsius=℃}}{% \ifavailablethenelse{\phont}{00B0}{\sisetup{math-celsius=°C}}{ \sisetup{math-celsius=nix} } } \setmathfont{\phont} \(\SI{123}{\celsius}\) } \sisetup{text-celsius=bar} \foreach \phont in {DejaVu Serif, Linux Libertine O, TeX Gyre Pagella, Arial} { \ifavailablethenelse{\phont}{2103}{\sisetup{text-celsius=℃}}{% \ifavailablethenelse{\phont}{00B0}{\sisetup{text-celsius=°C}}{ \sisetup{text-celsius=niente} } } \setmainfont{\phont} \SI{123}{\celsius} } \end{document} Albeit, it seems to be slow. -- Subscriptions, Archive, and List information, etc.: http://tug.org/mailman/listinfo/xetex
Re: [XeTeX] XeTeX and ignore sub substitution rules
It appears to me that XeTeX doesn't handle, at all, OpenType context substitutions that match without doing a substitution - i.e. the ones that appear in Adobe feature files as ignore sub rules. When one of these Well I don't really agree.I have included the following feature in a font that I am working and it works just fine with XeTeX: @calt1 = [ Omicron.calt Epsilon.calt Alpha.calt alpha.calt epsilon.calt omicron.calt ]; @calt2 = [ Alphatonos Epsilontonos Omicrontonos alphatonos epsilontonos omicrontonos uni1F04 uni1F0C uni1F14 uni1F1C uni1F44 uni1F4C ]; @calt3 = [Alphatonos Epsilontonos Etatonos Iotatonos Omicrontonos Upsilontonos Omegatonos uni1FF3 uni1FF4 uni1FF6 uni1FF7 uni1FF8 uni1FF9 uni1FFA uni1FFB uni1FFC ]; feature calt { # Contextual Alternates .. script grek; # Greek ignore sub @calt3 etatonos'; ignore sub etatonos' @calt3; sub etatonos' by etatonos.calt; ignore sub @calt3 uni1F22'; ignore sub uni1F22' @calt3; sub uni1F22' by uni1F22.calt; sub @calt2' [iota upsilon] by [Alpha.calt Epsilon.calt Omicron.calt alpha.calt epsilon.calt omicron.calt alpha.calt Alpha.calt epsilon.calt Epsilon.calt omicron.calt Omicron.calt]; sub @calt1 [iota upsilon]' by [iotadieresis.calt upsilondieresis.calt]; } calt; A.S. -- Apostolos Syropoulos Xanthi, Greece -- Subscriptions, Archive, and List information, etc.: http://tug.org/mailman/listinfo/xetex
Re: [XeTeX] Detect, whether a font contains a certain character
On 28/11/2011 12:34, Tobias Schoel wrote: So this seems to work: \documentclass{minimal} \usepackage{fontspec} \usepackage{unicode-math} \setmathfont{XITS Math} \usepackage{siunitx} \sisetup{% detect-all, } \newcounter{works} \setcounter{works}{0} \usepackage{pgffor} \begin{document} \newcommand{\ifavailablethenelse}[4]{%#1=font,#2=charcode,#3=then-clause,#4=else-clause \setcounter{works}{0} \bgroup \font\test=#1 \test \ifnum\XeTeXfonttype\font0 \ifnum\XeTeXcharglyph#20 \setcounter{works}{1} \fi \fi \egroup \ifnum\theworks=1 #3 \else #4 \fi } \sisetup{math-celsius=foo} \foreach \phont in {Asana Math,XITS Math, STIXGeneral, Neo Euler} { \ifavailablethenelse{\phont}{2103}{\sisetup{math-celsius=℃}}{% \ifavailablethenelse{\phont}{00B0}{\sisetup{math-celsius=°C}}{ \sisetup{math-celsius=nix} } } \setmathfont{\phont} \(\SI{123}{\celsius}\) } \sisetup{text-celsius=bar} \foreach \phont in {DejaVu Serif, Linux Libertine O, TeX Gyre Pagella, Arial} { \ifavailablethenelse{\phont}{2103}{\sisetup{text-celsius=℃}}{% \ifavailablethenelse{\phont}{00B0}{\sisetup{text-celsius=°C}}{ \sisetup{text-celsius=niente} } } \setmainfont{\phont} \SI{123}{\celsius} } \end{document} Albeit, it seems to be slow. I hope you can see why siunitx does not attempt to auto-detect every available case! (I may slightly alter the XeTeX/LuaTeX defaults, but am currently testing that this is indeed okay.) -- Joseph Wright -- Subscriptions, Archive, and List information, etc.: http://tug.org/mailman/listinfo/xetex
[XeTeX] Diacritics in color (was Re: XETEX cannot access OpenType features in PUA?)
Jonathan Kew writes: Making this work in xetex would require a different approach to implementing color. I have been able to get it to work (the base glyph in black and the diacritic in red) in LuaTeX using the luacolor package. Here's a minimal example: \documentclass{minimal} \usepackage{fontspec} \usepackage{xcolor} \usepackage{luacolor} \newfontface\moo{MezenetsUnicode} \begin{document} \moo \textcolor{red}{} \end{document} I'm not much of an expert in the inner workings of TeX and I know absolutely nothing about Lua (is that a derivative of LISP?) so I can't comment on whether the luacolor package could be ported to XeTeX. Any insights? Aleks -- Subscriptions, Archive, and List information, etc.: http://tug.org/mailman/listinfo/xetex
Re: [XeTeX] XeTeX and ignore sub substitution rules
Here's a stripped-down example of the problem. The attached OTF font contains rules in the clig feature saying that a b should be replaced by a B (i.e. the b is changed to upper case) except when it is followed by c. For greater clarity, the feature file is also attached. Testing in FontForge's metrics window requires me to manually turn on clig (which should be on by default) but with the feature turned on, the substitution and non-subsitution happen as expected. When I run the attached .tex file through XeLaTeX with the attached font, aba becomes aBa as it should, but abc becomes aBc, whereas FontForge leaves it as abc (which I think is correct). The ignore rule doesn't seem to be processed by XeTeX. Confirmed on a couple of different installations, but I'd be interested to hear whether it happens for anyone else. Apostolos Syropoulos sent me a font using ignore rules and reported to work correctly, but I haven't finished testing myself whether that one works for me. -- Matthew Skala msk...@ansuz.sooke.bc.ca People before principles. http://ansuz.sooke.bc.ca/ testfont.otf Description: Binary data languagesystem DFLT dflt; languagesystem latn dflt; feature clig { ignore sub a b' c; sub a b' by B; } clig; \documentclass{article} \usepackage{fontspec} \begin{document} \setmainfont[Path=./]{testfont.otf} aba abc \end{document} -- Subscriptions, Archive, and List information, etc.: http://tug.org/mailman/listinfo/xetex
Re: [XeTeX] Diacritics in color (was Re: XETEX cannot access OpenType features in PUA?)
Hi Aleks, On 29/11/2011, at 6:18 AM, Aleksandr Andreev wrote: Jonathan Kew writes: Making this work in xetex would require a different approach to implementing color. I have been able to get it to work (the base glyph in black and the diacritic in red) in LuaTeX using the luacolor package. Here's a minimal example: \documentclass{minimal} \usepackage{fontspec} \usepackage{xcolor} \usepackage{luacolor} \newfontface\moo{MezenetsUnicode} \begin{document} \moo \textcolor{red}{} \end{document} Would you be so kind as to post the PDF from this? And where does one obtain the font MezenetsUnicode ? --- Google gives nothing with this name. Furthermore my LuaTeX gives a Segmentation Fault, so I cannot just try with a different font! I'm not much of an expert in the inner workings of TeX and I know absolutely nothing about Lua (is that a derivative of LISP?) so I can't comment on whether the luacolor package could be ported to XeTeX. I'd doubt that this could work currently. My guess is that you would need to do some post-processing of the PDF code snippet returned from the OS positioning the glyphs. Once positioned, you would need to wrap the colour commands around the part which places the diacritic. Any insights? But XeTeX currently does not give you access to that PDF string, and it is well past the place of macro-expansion in LaTeX, so there wouldn't be a mechanism for such late adjustments. It can be done with LuaTeX, since it does have the appropriate mechanism for such post-processing. Others more familiar with how LuaTeX works can confirm this explanation -- or shoot it down, as appropriate. Aleks Hope this helps, Ross Ross Moore ross.mo...@mq.edu.au Mathematics Department office: E7A-419 Macquarie University tel: +61 (0)2 9850 8955 Sydney, Australia 2109 fax: +61 (0)2 9850 8114 -- Subscriptions, Archive, and List information, etc.: http://tug.org/mailman/listinfo/xetex
Re: [XeTeX] Detect, whether a font contains a certain character
On Mon, Nov 28, 2011 at 07:19:48AM +, Jonathan Kew wrote: On 28 Nov 2011, at 06:59, Heiko Oberdiek wrote: On Mon, Nov 28, 2011 at 03:07:07PM +1030, Andrew Moschou wrote: 2011/11/28 Zdenek Wagner zdenek.wag...@gmail.com Put it into an \hbox and measure its width (\wd). If the width is zero, the glyph does not exist. If the required glyph doesn't exist, wouldn't this measure the .notdef glyph? No, Yes, it would (and .notdef may of course have non-zero width). \catcode`\{=1 \catcode`\}=2 \catcode`\^=7 \showboxdepth=1 \showboxbreadth=1 \tracingonline=1 \font\rm=cmr10\relax \rm \setbox0=\hbox{\kern1pt018e} \showbox0 \csname @@end\endcsname\end And where is the inserted .notdef glyph? the problem is rather that a existing glyph can have width zero (not likely in your case) and that there is a warning in the .log file. See my examples. Assuming the OP is interested in native truetype/opentype fonts, not .tfm-based fonts, \XeTeXcharglyph is the simple answer. In case of \ifnum\XeTeXfonttype0 there is a better test. Or what do you suggest for a general test of glyph existence? Yours sincerely Heiko Oberdiek -- Subscriptions, Archive, and List information, etc.: http://tug.org/mailman/listinfo/xetex
Re: [XeTeX] Diacritics in color (was Re: XETEX cannot access OpenType features in PUA?)
On Mon, Nov 28, 2011 at 02:18:56PM -0500, Aleksandr Andreev wrote: Jonathan Kew writes: Making this work in xetex would require a different approach to implementing color. I have been able to get it to work (the base glyph in black and the diacritic in red) in LuaTeX using the luacolor package. Here's a minimal example: \documentclass{minimal} \usepackage{fontspec} \usepackage{xcolor} \usepackage{luacolor} \newfontface\moo{MezenetsUnicode} \begin{document} \moo \textcolor{red}{} \end{document} I'm not much of an expert in the inner workings of TeX and I know absolutely nothing about Lua (is that a derivative of LISP?) so I can't comment on whether the luacolor package could be ported to XeTeX. No. Package luacolor uses LuaTeX's attributes and LuaTeX's ability to process node lists. Yours sincerely Heiko Oberdiek -- Subscriptions, Archive, and List information, etc.: http://tug.org/mailman/listinfo/xetex