Dear list, in my math, I would like one font (the text font) to be used for letters and digits and another font (the math font) to be used for mathematical symbols. I have tried it like that: % Example 1 \usemodule[simplefonts][size=40pt] \setmathfont[termes] \setmainfont[latinmodernroman] \starttext 123\\$ 123 \coprod \leftrightarrow $ \stoptext % Example 2 \definetypeface [fonttest] [rm] [serif] [modern] \definetypeface [fonttest] [mm] [math] [termes] \setupbodyfont[fonttest, 40pt] \starttext 123\\$ 123 \coprod \leftrightarrow $ \stoptext In both examples, the math font is used for the whole formula. How can I mix the fonts? Kind regards and best wishes for 2014, Joshua Krämer
Am 04.01.2014 um 16:04 schrieb Joshua Krämer
Dear list,
in my math, I would like one font (the text font) to be used for letters and digits and another font (the math font) to be used for mathematical symbols. I have tried it like that:
% Example 1 \usemodule[simplefonts][size=40pt] \setmathfont[termes] \setmainfont[latinmodernroman] \starttext 123\\$ 123 \coprod \leftrightarrow $ \stoptext
% Example 2 \definetypeface [fonttest] [rm] [serif] [modern] \definetypeface [fonttest] [mm] [math] [termes] \setupbodyfont[fonttest, 40pt] \starttext 123\\$ 123 \coprod \leftrightarrow $ \stoptext
In both examples, the math font is used for the whole formula. How can I mix the fonts?
This is possible but you have to use the context suite [1] and not texlive or miktex because the context version they provide doesn’t include the necessary mechanism. [1] http://wiki.contextgarden.net/ConTeXt_Standalone Wolfgang
Am Sat, 04 Jan 2014 17:44:22 +0100 schrieb Wolfgang Schuster:
This is possible but you have to use the context suite [1] and not texlive or miktex because the context version they provide doesn’t include the necessary mechanism.
[1] http://wiki.contextgarden.net/ConTeXt_Standalone
Wolfgang
Thanks for your answer. I already use context standalone, but even after an update (first-setup.sh), the fonts are not mixed. What are the additional steps to do? Kind regards, Joshua Krämer
Am 04.01.2014 um 18:22 schrieb Joshua Krämer
Am Sat, 04 Jan 2014 17:44:22 +0100 schrieb Wolfgang Schuster:
This is possible but you have to use the context suite [1] and not texlive or miktex because the context version they provide doesn’t include the necessary mechanism.
[1] http://wiki.contextgarden.net/ConTeXt_Standalone
Wolfgang
Thanks for your answer. I already use context standalone, but even after an update (first-setup.sh), the fonts are not mixed. What are the additional steps to do?
You have to switch from the simplefonts module to the new fontfamily command (a new built-in system which replaces simplefonts) to set the fonts for your document. The fourth argument specifies which part of the font you want to replace (you could also have written [preset=math:lowercaseitalic] instead of [math:lowercaseitalic]). \definefontfamily [mainface] [rm] [Latin Modern Roman] \definefallbackfamily [mainface] [mm] [Latin Modern Roman] [math:lowercaseitalic] \definefontfamily [mainface] [mm] [TeX Gyre Termes Math] \setupbodyfont[mainface] \starttext TeX uses different fonts for text and math, e.g. \math{f(x)=x^2+2x+4} but it possible to replace certain characters in the math font with glyphs from a text font. \stoptext Wolfgang
Am Sat, 04 Jan 2014 19:50:24 +0100 schrieb Wolfgang Schuster:
You have to switch from the simplefonts module to the new fontfamily command (a new built-in system which replaces simplefonts) to set the fonts for your document. [...]
Thank you, it functions as intended. I suppose this mechanism works with Opentype math fonts only? However, I'm glad to know ConTeXt's font handling is evolving! Kind regards, Joshua
Am 08.01.2014 um 11:52 schrieb Joshua Krämer
Am Sat, 04 Jan 2014 19:50:24 +0100 schrieb Wolfgang Schuster:
You have to switch from the simplefonts module to the new fontfamily command (a new built-in system which replaces simplefonts) to set the fonts for your document. [...]
Thank you, it functions as intended. I suppose this mechanism works with Opentype math fonts only?
Yes, you need an opentype math font but when it would be possible to use the fallback mechanism with a virtual math font the \definefallbackfamily can’t be used for them.
However, I'm glad to know ConTeXt's font handling is evolving!
The support of the fallback mechanism for math fonts was a recent addition from Hans. The new \definefontfamily commands are part of the new version of the simplefonts module which tries to stay closer to context normal typeface mechanism. Wolfgang
Thanks for your hard work! I have a few additional questions regarding the new system and font fallbacks. (1) How can I replace the hyphen automatically inserted at linebreaks? If I use the following, only manually inserted hyphens are replaced: \definefallbackfamily[mainface][serif][TeX Gyre Termes][range={0x0002d}] (2) What effect does force=yes have? It doesn't seem to make a difference for me. (3) I have a typeface that uses unusual style names: "roman1", "roman2", "italic1", "italic2"; 1 is regular, 2 is bold weight. The following works: \definefontfamily[xxxface][serif][xxx][regularfont=xxxroman1, italicfont=xxxitalic1, boldfont=xxxroman2] \setupbodyfont[xxxface] \starttext abc {\it abc} {\bf abc} \stoptext This works for roman1 only: \definefontfamily[xxxface][serif][xxx][regularfont=spec:roman1, italicfont=spec:italic1, boldfont=spec:roman2] Even this works for roman1 only: \definefontfamily[xxxface][serif][xxx][regularfont=spec:roman1, italicfont=xxxitalic1, boldfont=xxxroman2] (4) Now I want to use this typeface for math fallback. In the following example, the upright glyphs are replaced, but not the italic glyphs: \definefontfamily[xxxface][serif][xxx][regularfont=xxxroman1, italicfont=xxxitalic1, boldfont=xxxroman2] \definefallbackfamily[xxxface][math][xxx][regularfont=xxxroman1, preset=math:lowercasenormal] \definefallbackfamily[xxxface][math][xxx][regularfont=xxxroman1, preset=math:uppercasenormal] \definefallbackfamily[xxxface][math][xxx][italicfont=xxxitalic1, preset=math:lowercaseitalic] \definefallbackfamily[xxxface][math][xxx][italicfont=xxxitalic1, preset=math:uppercaseitalic] \definefallbackfamily[xxxface][math][xxx][regularfont=xxxroman1, preset=math:digitsnormal] \definefontfamily[xxxface][math][TeX Gyre Termes Math] \setupbodyfont[xxxface] \starttext $ \coprod \leftrightarrow ABC abc {\mathupright ABC abc} 123 $ \stoptext Kind regards, Joshua
Am 09.01.2014 um 12:01 schrieb Joshua Krämer
Thanks for your hard work! I have a few additional questions regarding the new system and font fallbacks.
(1) How can I replace the hyphen automatically inserted at linebreaks? If I use the following, only manually inserted hyphens are replaced:
\definefallbackfamily[mainface][serif][TeX Gyre Termes][range={0x0002d}]
Dunno, can you make this a separate question?
(2) What effect does force=yes have? It doesn't seem to make a difference for me.
When you set “force=yes” (default value) context uses the fallback font even when the character exists the main font.
(3) I have a typeface that uses unusual style names: "roman1", "roman2", "italic1", "italic2"; 1 is regular, 2 is bold weight. The following works:
\definefontfamily[xxxface][serif][xxx][regularfont=xxxroman1, italicfont=xxxitalic1, boldfont=xxxroman2] \setupbodyfont[xxxface] \starttext abc {\it abc} {\bf abc} \stoptext
This works for roman1 only:
\definefontfamily[xxxface][serif][xxx][regularfont=spec:roman1, italicfont=spec:italic1, boldfont=spec:roman2]
Even this works for roman1 only:
\definefontfamily[xxxface][serif][xxx][regularfont=spec:roman1, italicfont=xxxitalic1, boldfont=xxxroman2]
The name of the font files has nothing to do with way how \definefontfamily collects the individual files for each style, to do this it uses internal names and values from the font. In a case where \definefontfamily can’t find all styles you can select them with the name of the files: \definefontfamily[<typeface>][<style>][<family name>][tf=file:uprightfont,it=file:italicfont,…]
(4) Now I want to use this typeface for math fallback. In the following example, the upright glyphs are replaced, but not the italic glyphs:
\definefontfamily[xxxface][serif][xxx][regularfont=xxxroman1, italicfont=xxxitalic1, boldfont=xxxroman2] \definefallbackfamily[xxxface][math][xxx][regularfont=xxxroman1, preset=math:lowercasenormal] \definefallbackfamily[xxxface][math][xxx][regularfont=xxxroman1, preset=math:uppercasenormal] \definefallbackfamily[xxxface][math][xxx][italicfont=xxxitalic1, preset=math:lowercaseitalic] \definefallbackfamily[xxxface][math][xxx][italicfont=xxxitalic1, preset=math:uppercaseitalic] \definefallbackfamily[xxxface][math][xxx][regularfont=xxxroman1, preset=math:digitsnormal] \definefontfamily[xxxface][math][TeX Gyre Termes Math] \setupbodyfont[xxxface] \starttext $ \coprod \leftrightarrow ABC abc {\mathupright ABC abc} 123 $ \stoptext
When you use a opentype math font the upright, italic, bold etc. characters are all in the same file which uses only the regular style (a few math fonts provide also a bold style which can be useful in headings). Because there is only a upright math font you have to set a fallbacks also for the upright style even when the font you’re using is italic, e.g. \definefallbackfamily[xxxface][math][xxx][tf=file:xxxitalic1,preset=math:lowercaseitalic] Wolfgang
Am Thu, 9 Jan 2014 20:41:15 +0100
schrieb Wolfgang Schuster
(3) I have a typeface that uses unusual style names: "roman1", "roman2", "italic1", "italic2"; 1 is regular, 2 is bold weight. The following works:
\definefontfamily[xxxface][serif][xxx][regularfont=xxxroman1, italicfont=xxxitalic1, boldfont=xxxroman2] \setupbodyfont[xxxface] \starttext abc {\it abc} {\bf abc} \stoptext
This works for roman1 only:
\definefontfamily[xxxface][serif][xxx][regularfont=spec:roman1, italicfont=spec:italic1, boldfont=spec:roman2]
Even this works for roman1 only:
\definefontfamily[xxxface][serif][xxx][regularfont=spec:roman1, italicfont=xxxitalic1, boldfont=xxxroman2]
The name of the font files has nothing to do with way how \definefontfamily collects the individual files for each style, to do this it uses internal names and values from the font.
I've got the values from the output of "mtxrun --script fonts --list --all --pattern=xxx" (and compared with the name/style values in Fontforge), so I don't understand why "spec:roman1" works, but "spec:italic1" doesn't. Additionally, what I think must be a bug is that "italicfont=file:xxxitalic1, boldfont=file:xxxroman2" works but stops working if I add "regularfont=spec:roman1": \definefontfamily[xxxface][serif][xxx][regularfont=spec:roman1, italicfont=file:xxxitalic1, boldfont=file:xxxroman2] Maybe if one of the values uses the "spec:" selector, all the values are treated as spec values despite the "file:" selector given?
When you use a opentype math font the upright, italic, bold etc. characters are all in the same file which uses only the regular style (a few math fonts provide also a bold style which can be useful in headings).
Because there is only a upright math font you have to set a fallbacks also for the upright style even when the font you’re using is italic, e.g.
\definefallbackfamily[xxxface][math][xxx][tf=file:xxxitalic1,preset=math:lowercaseitalic]
Thanks, this works. For some reason, "tf=" works, but "regularfont=" doesn't. And by the way, this works: \definefontfamily[leitura][serif][Leitura News][regularfont=spec:roman2] and this doesn't work: \definefontfamily[leitura][serif][Leitura News][tf=spec:roman2] So in some cases only "regularfont" seems to work, and in some cases only "tf". Kind regards, Joshua
Am 09.01.2014 um 22:30 schrieb Joshua Krämer
Am Thu, 9 Jan 2014 20:41:15 +0100 schrieb Wolfgang Schuster
: (3) I have a typeface that uses unusual style names: "roman1", "roman2", "italic1", "italic2"; 1 is regular, 2 is bold weight. The following works:
\definefontfamily[xxxface][serif][xxx][regularfont=xxxroman1, italicfont=xxxitalic1, boldfont=xxxroman2] \setupbodyfont[xxxface] \starttext abc {\it abc} {\bf abc} \stoptext
This works for roman1 only:
\definefontfamily[xxxface][serif][xxx][regularfont=spec:roman1, italicfont=spec:italic1, boldfont=spec:roman2]
Even this works for roman1 only:
\definefontfamily[xxxface][serif][xxx][regularfont=spec:roman1, italicfont=xxxitalic1, boldfont=xxxroman2]
The name of the font files has nothing to do with way how \definefontfamily collects the individual files for each style, to do this it uses internal names and values from the font.
I've got the values from the output of "mtxrun --script fonts --list --all --pattern=xxx" (and compared with the name/style values in Fontforge), so I don't understand why "spec:roman1" works, but "spec:italic1" doesn't.
Additionally, what I think must be a bug is that "italicfont=file:xxxitalic1, boldfont=file:xxxroman2" works but stops working if I add "regularfont=spec:roman1":
\definefontfamily[xxxface][serif][xxx][regularfont=spec:roman1, italicfont=file:xxxitalic1, boldfont=file:xxxroman2]
Maybe if one of the values uses the "spec:" selector, all the values are treated as spec values despite the "file:" selector given?
What you try can’t work because spec is one of context three methods to load a font, the first two are “file:…” and “name:…”. With the spec method you give context a list of features for the font you want to load, the spec specifier has 5 argument: 1. The family name of the font 2. The weight of the font (light, normal, medium, bold, …) 3. The style of the font (normal, italic, slanted, …) 4. The width of the font (condensed, normal, expanded, …) 5. The variant of the font (normal, old style or smallcaps) When you load a font you separate all arguments by a hyphen, when you leave arguments out they get normal as default values. Below is a example how to load TeX Gyre Pagella Regular and Bold with the spec method: \starttext {\definedfont[spec:texgyrepagella-normal]TeX Gyre Pagella Regular} {\definedfont[spec:texgyrepagella-bold]TeX Gyre Pagella Bold} \stoptext When you want now the bolditalic form of the font you have to set the third argument for the style: \starttext {\definedfont[spec:texgyrepagella-bold-normal]TeX Gyre Pagella Bold} {\definedfont[spec:texgyrepagella-bold-italic]TeX Gyre Pagella Bolditalic} \stoptext When you now use the spec method with \definefontfamily nearly the same thing happens but you set only the argument 2–5 because the name of the font was already set.
When you use a opentype math font the upright, italic, bold etc. characters are all in the same file which uses only the regular style (a few math fonts provide also a bold style which can be useful in headings).
Because there is only a upright math font you have to set a fallbacks also for the upright style even when the font you’re using is italic, e.g.
\definefallbackfamily[xxxface][math][xxx][tf=file:xxxitalic1,preset=math:lowercaseitalic]
Thanks, this works. For some reason, "tf=" works, but "regularfont=" doesn't.
And by the way, this works: \definefontfamily[leitura][serif][Leitura News][regularfont=spec:roman2]
and this doesn't work: \definefontfamily[leitura][serif][Leitura News][tf=spec:roman2]
So in some cases only "regularfont" seems to work, and in some cases only "tf“.
Just avoid the spec method, it depends a lot on the information in the font and is not always reliable, because of this I don’t use it as default method to search for all files in a font family. Wolfgang
Dear Wolfgang, thanks for your clarifications. I will avoid the spec method. The remaining question is, if "regularfont=" should be avoided, too, in favour of "tf=", or will this be made to work in the future?
\definefallbackfamily[xxxface][math][xxx][regularfont=file:xxxitalic1,preset=math:lowercaseitalic]
Kind regards, Joshua
Am 09.01.2014 um 23:12 schrieb Joshua Krämer
Dear Wolfgang,
thanks for your clarifications. I will avoid the spec method. The remaining question is, if "regularfont=" should be avoided, too, in favour of "tf=", or will this be made to work in the future?
The “regularfont”, “regularfeatures” etc. keys are going to disappear at some point because both settings can be done with with “tf”, “it” etc. keys. Wolfgang
On Sat, 4 Jan 2014, Joshua Krämer wrote:
Dear list,
in my math, I would like one font (the text font) to be used for letters and digits and another font (the math font) to be used for mathematical symbols. I have tried it like that:
% Example 1 \usemodule[simplefonts][size=40pt] \setmathfont[termes] \setmainfont[latinmodernroman] \starttext 123\\$ 123 \coprod \leftrightarrow $ \stoptext
% Example 2 \definetypeface [fonttest] [rm] [serif] [modern] \definetypeface [fonttest] [mm] [math] [termes] \setupbodyfont[fonttest, 40pt] \starttext 123\\$ 123 \coprod \leftrightarrow $ \stoptext
In both examples, the math font is used for the whole formula. How can I mix the fonts?
You ask for modern as the text font and termes as the math font, and that is what you get. Can you elaborate what do you mean by 'mix the fonts'? What output do you want to get. Aditya
Am Sat, 04 Jan 2014 12:47:24 -0500 schrieb Aditya Mahajan:
You ask for modern as the text font and termes as the math font, and that is what you get. Can you elaborate what do you mean by 'mix the fonts'? What output do you want to get.
For the text font I use (it's a commercial typeface), a matching math font doesn't exist. Now if I use for example Termes as the math font, the formulae don't match the regular text, because the letters and digits differ. That's why I want in the formulae math symbols like special arrows and operators to be taken from Termes, but regular alphanumeric characters from my text font. So in my minimal examples, "123" should look the same in the text and the formula. Kind regards, Joshua Krämer
participants (3)
-
Aditya Mahajan
-
Joshua Krämer
-
Wolfgang Schuster