How do I add cyrillic to my typescript/document?
I am looking for a way to amend a typescript for the additional use of cyrillic characters. I currently use: \starttypescript [sans] [optima] \setups[font:fallback:sans] \definefontsynonym [Sans] [file:Optima.ttc(Optima Regular)] [features=default] \definefontsynonym [SansBold] [file:Optima.ttc(Optima Bold)] [features=default] \definefontsynonym [SansItalic] [file:Optima.ttc(Optima Italic)] [features=default] \definefontsynonym [SansBoldItalic] [file:Optima.ttc(Optima Bold Italic)] [features=default] \stoptypescript \definetypeface [optima] [ss] [sans] [optima] [default] \definetypeface [optima] [rm] [serif] [optima] [default] \definetypeface [optima] [tt] [mono] [modern] [default] \definetypeface [optima] [mm] [math] [pagella] [default] \setupbodyfont [optima] But Optima doesn’t have cyrillic characters. So, either I have te use another typescript. I tried creating a Helvetica (as Helvetica.ttc on macOS seems to have cyrillic characters) but did not succeed. I also tried \language[ru] without any \setupbodyfont hoping it would also fix the font issue but keep getting fonts > checking > char –® (U+00428) in font 'LMRoman10-Regular' with id 8: missing I read the languages-mkiv document but it did not say what I had to do about fonts. What do I have to do to get both English and Russian in my document in terms of fonts? G
ConTeXtgarden had theanswer when I searched again: \setupbodyfont[dejavu] \mainlanguage[russian] G
On 3 May 2020, at 13:34, Gerben Wierda
wrote: I am looking for a way to amend a typescript for the additional use of cyrillic characters.
I currently use:
\starttypescript [sans] [optima] \setups[font:fallback:sans] \definefontsynonym [Sans] [file:Optima.ttc(Optima Regular)] [features=default] \definefontsynonym [SansBold] [file:Optima.ttc(Optima Bold)] [features=default] \definefontsynonym [SansItalic] [file:Optima.ttc(Optima Italic)] [features=default] \definefontsynonym [SansBoldItalic] [file:Optima.ttc(Optima Bold Italic)] [features=default] \stoptypescript
\definetypeface [optima] [ss] [sans] [optima] [default] \definetypeface [optima] [rm] [serif] [optima] [default] \definetypeface [optima] [tt] [mono] [modern] [default] \definetypeface [optima] [mm] [math] [pagella] [default]
\setupbodyfont [optima]
But Optima doesn’t have cyrillic characters. So, either I have te use another typescript. I tried creating a Helvetica (as Helvetica.ttc on macOS seems to have cyrillic characters) but did not succeed.
I also tried
\language[ru]
without any \setupbodyfont hoping it would also fix the font issue but keep getting
fonts > checking > char –® (U+00428) in font 'LMRoman10-Regular' with id 8: missing
I read the languages-mkiv document but it did not say what I had to do about fonts.
What do I have to do to get both English and Russian in my document in terms of fonts?
G ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________
On 5/3/20 2:56 PM, Gerben Wierda wrote:
ConTeXtgarden had theanswer when I searched again:
\setupbodyfont[dejavu] \mainlanguage[russian]
Hi Gerben, I’m afraid they may be different issues: setting a language and getting the glyphs required for that language. See the following sample: \setupbodyfont[dejavu] \mainlanguage[russian] \starttext \hyphenatedword{% Николаевич typography \en typography} \stoptext Since you set the main language to Russian in the document, you would have to mark all English texts properly. I doubt this may be what you intend. The way to get a fallback font would be (depending on which approach you use) \definefontfallback or \definefallbackfamily. A sample of the second option would read: \definefallbackfamily [mainface] [ss] [FreeSans] [preset=range:cyrillic, force=yes] In any case, http://www.pragma-ade.com/general/qrcs/setup-en.pdf#search=%22definefontfall... explains the syntax of the first option (sorry, but I only use the \definefontfamily approach). Just in case it helps, Pablo -- http://www.ousia.tk
On 3 May 2020, at 15:55, Pablo Rodriguez
On 5/3/20 2:56 PM, Gerben Wierda wrote:
ConTeXtgarden had theanswer when I searched again:
\setupbodyfont[dejavu] \mainlanguage[russian]
Hi Gerben,
I’m afraid they may be different issues: setting a language and getting the glyphs required for that language.
See the following sample:
\setupbodyfont[dejavu] \mainlanguage[russian] \starttext \hyphenatedword{% Николаевич typography \en typography} \stoptext
Since you set the main language to Russian in the document, you would have to mark all English texts properly. I doubt this may be what you intend.
The way to get a fallback font would be (depending on which approach you use) \definefontfallback or \definefallbackfamily.
A sample of the second option would read:
\definefallbackfamily [mainface] [ss] [FreeSans] [preset=range:cyrillic, force=yes]
In any case, http://www.pragma-ade.com/general/qrcs/setup-en.pdf#search=%22definefontfall... explains the syntax of the first option (sorry, but I only use the \definefontfamily approach).
Just in case it helps,
Thank you. It could help if I would understand ConTeXt better. The link gives me a grammar for a command, but doesn’t tell me what to put in. I tried many, many different permutations, I tried everything I could find on ConTeXtgarden (but then, that also finds me stuff from 15 years ago that isn’t valid anymore), but no luck so far. The last I tried was \starttypescript [sans] [optima] \setups[font:fallback:sans] \definefontsynonym [Sans] [file:Optima.ttc(Optima Regular)] [features=default] \definefontsynonym [SansBold] [file:Optima.ttc(Optima Bold)] [features=default] \definefontsynonym [SansItalic] [file:Optima.ttc(Optima Italic)] [features=default] \definefontsynonym [SansBoldItalic] [file:Optima.ttc(Optima Bold Italic)] [features=default] \stoptypescript \definetypeface [optima] [ss] [sans] [optima] [default] \definetypeface [optima] [rm] [serif] [optima] [default] \definetypeface [optima] [tt] [mono] [modern] [default] \definetypeface [optima] [mm] [math] [pagella] [default] \definefallbackfamily [optima] [ss] [file:Helvetica.ttc] [preset=range:cyrillic, force=yes] \setupbodyfont [optima] The error is: fonts > typescripts > unknown library 'optima' open source > level 3, order 6, name '/usr/local/context-osx-64/tex/texmf-context/tex/context/fonts/mkiv/type-imp-texgyre.mkiv' close source > level 3, order 6, name '/usr/local/context-osx-64/tex/texmf-context/tex/context/fonts/mkiv/type-imp-texgyre.mkiv' selectfont > the requested fallback font 'file:Helvetica.ttc' for typeface 'optima' style 'ss' was ignored because no files where found. Which is weird because Optima.ttc is in the same directory and it is found. I have a lot o difficulty understanding any of the documentation (as far as it is available for the subjects and commands I am lookng for). For instance: what is the difference between the “Syntax (autogenerated)” and “Syntax entries on ConTeXtgarden? If they differ which one should I take? If you tell me “preset=range:cyrillic and what I find says "range=cyrillic", which one do I use ( in this case, changing did not help). There are just too many things that can be different for tial and error to be effective. But anyway, even if I could understand it, I can’t find anything useful (that is: something that works or makes me try something that works) about font fallbacks. Spending hours of looking (losing a lot of sleep) and then having to bother the list again is very frustrating. Why isn’t this straightforward? I am sorry, everybody is very helpful, but the frustration mounts again. G
Hello,
** Gerben Wierda
On 3 May 2020, at 15:55, Pablo Rodriguez
wrote: On 5/3/20 2:56 PM, Gerben Wierda wrote:
ConTeXtgarden had theanswer when I searched again:
\setupbodyfont[dejavu] \mainlanguage[russian]
Hi Gerben,
I’m afraid they may be different issues: setting a language and getting the glyphs required for that language.
See the following sample:
\setupbodyfont[dejavu] \mainlanguage[russian] \starttext \hyphenatedword{% Николаевич typography \en typography} \stoptext
Since you set the main language to Russian in the document, you would have to mark all English texts properly. I doubt this may be what you intend.
The way to get a fallback font would be (depending on which approach you use) \definefontfallback or \definefallbackfamily.
A sample of the second option would read:
\definefallbackfamily [mainface] [ss] [FreeSans] [preset=range:cyrillic, force=yes]
In any case, http://www.pragma-ade.com/general/qrcs/setup-en.pdf#search=%22definefontfall... explains the syntax of the first option (sorry, but I only use the \definefontfamily approach).
Just in case it helps,
Thank you.
It could help if I would understand ConTeXt better. The link gives me a grammar for a command, but doesn’t tell me what to put in.
Prepare a (small) example, for example.
I tried many, many different permutations, I tried everything I could find on ConTeXtgarden (but then, that also finds me stuff from 15 years ago that isn’t valid anymore), but no luck so far.
The last I tried was
\starttypescript [sans] [optima] \setups[font:fallback:sans] \definefontsynonym [Sans] [file:Optima.ttc(Optima Regular)] [features=default] \definefontsynonym [SansBold] [file:Optima.ttc(Optima Bold)] [features=default] \definefontsynonym [SansItalic] [file:Optima.ttc(Optima Italic)] [features=default] \definefontsynonym [SansBoldItalic] [file:Optima.ttc(Optima Bold Italic)] [features=default] \stoptypescript
\definetypeface [optima] [ss] [sans] [optima] [default] \definetypeface [optima] [rm] [serif] [optima] [default] \definetypeface [optima] [tt] [mono] [modern] [default] \definetypeface [optima] [mm] [math] [pagella] [default]
\definefallbackfamily [optima] [ss] [file:Helvetica.ttc] [preset=range:cyrillic, force=yes]
\setupbodyfont [optima]
The error is:
fonts > typescripts > unknown library 'optima' open source > level 3, order 6, name '/usr/local/context-osx-64/tex/texmf-context/tex/context/fonts/mkiv/type-imp-texgyre.mkiv' close source > level 3, order 6, name '/usr/local/context-osx-64/tex/texmf-context/tex/context/fonts/mkiv/type-imp-texgyre.mkiv' selectfont > the requested fallback font 'file:Helvetica.ttc' for typeface 'optima' style 'ss' was ignored because no files where found.
Which is weird because Optima.ttc is in the same directory and it is found.
Note that log says about "Helvetica.ttc" not "Optima.ttc". Why you mention it is it a typo and you mean "Helvetica.ttc"? I'm not sure how context searches for fonts, but when I plainly use "standard" locations for fonts, for example OSFONTDIR variable, it could find and use requested font.
I have a lot o difficulty understanding any of the documentation (as far as it is available for the subjects and commands I am lookng for).
For instance: what is the difference between the “Syntax (autogenerated)” and “Syntax entries on ConTeXtgarden? If they differ which one should I take? If you tell me “preset=range:cyrillic and what I find says "range=cyrillic", which one do I use ( in this case, changing did not help). There are just too many things that can be different for tial and error to be effective.
But anyway, even if I could understand it, I can’t find anything useful (that is: something that works or makes me try something that works) about font fallbacks. Spending hours of looking (losing a lot of sleep) and then having to bother the list again is very frustrating. Why isn’t this straightforward? I am sorry, everybody is very helpful, but the frustration mounts again.
I couldn't help here because I understand better the LaTeX font mechanism than ConTeXt one but I don't use ConTeXt as often as LaTeX. If I understand correctly, fallback mechanism allows to use some "main" font for most of letters in a document, for example, for Latin letters and use another font, if some letters are missing from "main" one. The "missing" is based on letters codes, see "range" above. Your original question is a bit unclear to me. Do you want typeset document with Cyrillic letters, for example Russian text or just want to include some words using Cyrillic (Russian) letters? The former assumes that you will use \mainlanguage[ru] and appropriate font with Cyrillic glyphs, while for the latter you need only the font. I'm not a Mac OS user neither I have Optima nor Helvetica fonts, but Computer Modern Unicode (OTF) and OldStandard (OTF) have both Cyrillic and Latin letters (OldStandard doesn't have support "out of box" in context while Computer Modern Unicode has) so I made two small examples (well, the first example not so small, sometimes I prepare example not only for others but for myself too) which show both uses. Both fonts can be found on ctan: https://ctan.org/pkg/cm-unicode and https://ctan.org/pkg/oldstandard.
G
--- WBR, Vladimir Lomov -- Girls marry for love. Boys marry because of a chronic irritation that causes them to gravitate in the direction of objects with certain curvilinear properties. -- Ashley Montagu
Am 04.05.2020 um 00:36 schrieb Gerben Wierda
: \starttypescript [sans] [optima] \setups[font:fallback:sans] \definefontsynonym [Sans] [file:Optima.ttc(Optima Regular)] [features=default] \definefontsynonym [SansBold] [file:Optima.ttc(Optima Bold)] [features=default] \definefontsynonym [SansItalic] [file:Optima.ttc(Optima Italic)] [features=default] \definefontsynonym [SansBoldItalic] [file:Optima.ttc(Optima Bold Italic)] [features=default] \stoptypescript
\definetypeface [optima] [ss] [sans] [optima] [default] \definetypeface [optima] [rm] [serif] [optima] [default] \definetypeface [optima] [tt] [mono] [modern] [default] \definetypeface [optima] [mm] [math] [pagella] [default]
\definefallbackfamily [optima] [ss] [file:Helvetica.ttc] [preset=range:cyrillic, force=yes]
\setupbodyfont [optima]
The error is:
fonts > typescripts > unknown library 'optima'
This is about \definetypeface [optima] [rm] [serif] [optima] [default], because you only defined [sans][optima].
open source > level 3, order 6, name '/usr/local/context-osx-64/tex/texmf-context/tex/context/fonts/mkiv/type-imp-texgyre.mkiv' close source > level 3, order 6, name '/usr/local/context-osx-64/tex/texmf-context/tex/context/fonts/mkiv/type-imp-texgyre.mkiv' selectfont > the requested fallback font 'file:Helvetica.ttc' for typeface 'optima' style 'ss' was ignored because no files where found.
The fallback font for cyrillic, Helvetica.ttc, is not found. No problem with Optima reported. Best, Hraban
On 5/4/20 12:36 AM, Gerben Wierda wrote:
[...] It could help if I would understand ConTeXt better. The link gives me a grammar for a command, but doesn’t tell me what to put in.
I tried many, many different permutations, I tried everything I could find on ConTeXtgarden (but then, that also finds me stuff from 15 years ago that isn’t valid anymore), but no luck so far.
Sorry for not explaining it better, Gerben. Let me know if the following sample works for you: \setuplanguage[en][patterns={en, ru}] \definefallbackfamily [abc] [ss] [Helvetica] [preset=range:cyrillic, %~ tf=style:light, %~ it=style:lightoblique, %~ bf=style:regular, %~ bi=style:oblique, force=yes, rscale=0.9] \definefontfamily [abc] [ss] [Optima] \setupbodyfont[abc] \starttext \startTEXpage[offset=1em] \doloopoverlist{\tf, \it, \bf, \bi}{ \recursestring\hyphenatedword{Николаевич typography}\par} \stopTEXpage \stoptext It should hyphenate both English and Russian in all four fonts (regular, italic, bold and bold italic).
Which is weird because Optima.ttc is in the same directory and it is found.
Aren’t Optima.ttc and Helvetica.ttc installed as typefaces on your macOS? This is relevant, since ConTeXt may have problems finding them when not installed on the system (especially with the system I use). If the sample above doesn’t work, please provide the output of "locate Helvetica.ttc".
But anyway, even if I could understand it, I can’t find anything useful (that is: something that works or makes me try something that works) about font fallbacks. Spending hours of looking (losing a lot of sleep) and then having to bother the list again is very frustrating. Why isn’t this straightforward? I am sorry, everybody is very helpful, but the frustration mounts again.
If the sample above works, I think font management for your documents may be easier to handle (or at least, the font code will be simpler). Don’t loose sleep when code is not working, ask here instead. I must admit that not having access to a macOS computer (I needed the help of a friend to test) makes everything a bit harder. But it isn’t impossible. BTW, I use "preset=range:cyrillic" instead of "range=cyrillic", since it includes cyrillic, cyrillicextendeda, cyrillicextendedb and cyrillicsupplement. I hope the sample above helps now, Pablo -- http://www.ousia.tk
On 4 May 2020, at 12:13, Pablo Rodriguez
On 5/4/20 12:36 AM, Gerben Wierda wrote:
[...] It could help if I would understand ConTeXt better. The link gives me a grammar for a command, but doesn’t tell me what to put in.
I tried many, many different permutations, I tried everything I could find on ConTeXtgarden (but then, that also finds me stuff from 15 years ago that isn’t valid anymore), but no luck so far.
Sorry for not explaining it better, Gerben.
Let me know if the following sample works for you:
\setuplanguage[en][patterns={en, ru}]
\definefallbackfamily [abc] [ss] [Helvetica] [preset=range:cyrillic, %~ tf=style:light, %~ it=style:lightoblique, %~ bf=style:regular, %~ bi=style:oblique, force=yes, rscale=0.9]
\definefontfamily [abc] [ss] [Optima]
\setupbodyfont[abc]
\starttext \startTEXpage[offset=1em] \doloopoverlist{\tf, \it, \bf, \bi}{ \recursestring\hyphenatedword{Николаевич typography}\par} \stopTEXpage \stoptext
It should hyphenate both English and Russian in all four fonts (regular, italic, bold and bold italic).
The above works (including using macOS Helvetica as the font for cyrillic). Thank you. I have no idea why (earlier I got the typescript suggestion for my fonts management, but this uses another approach). Is it the case that the ‘family’ and ’typescript’ approaches don’t really mix? The above is a lot simpler than that what I had and it works fine. Any reason to leave these commented? And does uncommenting is plan TeX-uncommenting, so only the % goes away? Makes me wonder what ‘~’ means.
%~ tf=style:light, %~ it=style:lightoblique, %~ bf=style:regular, %~ bi=style:oblique,
What I try to do is to have english as the default (and fallback) language and Optima as the default font, but there may be snippets in other languages which should be typeset in a font that can handle cyrillic. Helvetica is an option. So is dejavu. I still am totally in the dark how this works and what made the earlier setup find Optima but not find Helvetica. And I’m curious why this adaptation doesn’t work: \definefallbackfamily [abc] [ss] [dejavu] [preset=range:cyrillic, %~ tf=style:light, %~ it=style:lightoblique, %~ bf=style:regular, %~ bi=style:oblique, force=yes, rscale=0.9] Anyway, I can go on, not wiser but helped further. Thanks again. G
Which is weird because Optima.ttc is in the same directory and it is found.
Aren’t Optima.ttc and Helvetica.ttc installed as typefaces on your macOS?
This is relevant, since ConTeXt may have problems finding them when not installed on the system (especially with the system I use).
If the sample above doesn’t work, please provide the output of "locate Helvetica.ttc".
But anyway, even if I could understand it, I can’t find anything useful (that is: something that works or makes me try something that works) about font fallbacks. Spending hours of looking (losing a lot of sleep) and then having to bother the list again is very frustrating. Why isn’t this straightforward? I am sorry, everybody is very helpful, but the frustration mounts again.
If the sample above works, I think font management for your documents may be easier to handle (or at least, the font code will be simpler).
Don’t loose sleep when code is not working, ask here instead. I must admit that not having access to a macOS computer (I needed the help of a friend to test) makes everything a bit harder. But it isn’t impossible.
BTW, I use "preset=range:cyrillic" instead of "range=cyrillic", since it includes cyrillic, cyrillicextendeda, cyrillicextendedb and cyrillicsupplement.
I hope the sample above helps now,
Pablo -- http://www.ousia.tk ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________
On 5/4/20 6:38 PM, Gerben Wierda wrote:
[...] The above works (including using macOS Helvetica as the font for cyrillic). Thank you.
Hi Gerben, glad to read it worked.
I have no idea why (earlier I got the typescript suggestion for my fonts management, but this uses another approach). Is it the case that the ‘family’ and ’typescript’ approaches don’t really mix? The above is a lot simpler than that what I had and it works fine.
I don’t know how to use typescripts and the approach I suggested is the only one I know to deal with fonts in ConTeXt. \definefontfamily (and \definefallbackfamily) were created to avoid using typescripts in the vast majority of cases.
Any reason to leave these commented? And does uncommenting is plan TeX-uncommenting, so only the % goes away? Makes me wonder what ‘~’ means.
%~ tf=style:light,
They are just an option. The tilde (~) is added after the percent sign (%), because “Geany” (the text editor I use) adds it after the comment sign in different programming languages. It has no special meaning.
What I try to do is to have english as the default (and fallback) language and Optima as the default font, but there may be snippets in other languages which should be typeset in a font that can handle cyrillic. Helvetica is an option. So is dejavu.
Now I get it: a fallback typeface for Russian and the main typeface as Optima. This might read the following way: \setuplanguage[en][patterns={en, ru}] \definefallbackfamily [mainface] [rm] [Helvetica] [preset=range:cyrillic, force=yes, rscale=0.9] \definefontfamily [mainface] [rm] [Optima] \setupbodyfont[mainface] The first command loads both English and Russian hyphenation patterns in English, so that you don’t have to bother to mark the texts that use the Cyrillic alphabet (although all hyphenation of Cyrillic will be according the Russian rules). The second command defines the fallback family. It has four option groups. 1. The first group sets up the name to be used in ConTeXt (mainly in \setupbodyfont and \switchtobodyfont). 2. The second group specifies which kind of typeface is: serif, sans-serif, typewriter, math and others. Of course, this isn’t a declaration of what kind of font the selected one is, but how ConTeXt will handle it. So, if your document is sans-serif only, it is safe to use "[rm]" with sans-serif fonts as above. 3. The third group specifies the font name as specified in your OS. This selects it. 4. The fourth group specifies different options. Here for the fallback font, I specify: a. Range: for which Unicode blocks (alphabets) will the font be used. You can use "range=cyrillic", but it is safer to use "preset=range:cyrillic" (this avoids specifying "range={cyrillicextendeda, cyrillicextendedb, cyrillicsupplement}"). b. Force: it is important to set it up to "yes", since otherwise if the main font (Optima in this case) has any glyph for the Cyrillic block, it would use that glyph in Optima, mixing it with the other ones from the fallback font. In my personal experience, this looks crappy. c. Relative scale to the main font: increase or decrease the fallback font to match similar x-height with the main font. In this case, Helvetica has a higher x-height that Optima, so I decreased it. All the previous options where related to \definefallbackfamily. \definefontfamily has also three option groups, which are the same that the ones explained for \definefallbackfamily. The values for the first and second groups should be the same, values for the third group should differ. Otherwise, glyph substition won’t take place (either the font family or typeface won’t match, or the fallback font won’t be actually a different one).
I still am totally in the dark how this works and what made the earlier setup find Optima but not find Helvetica.
I hope it is clear now: the fallback mechanism for your setup should read different than the one I provided. I think it could be better for you to use \definefallbackfamily and \definefontfamily. It is way simpler.
And I’m curious why this adaptation doesn’t work:
\definefallbackfamily [abc] [ss] [dejavu]
As explained above, the third option group should contain the font name (as your OS would display it, not as ConTeXt names it [probably, in a typescript]). So, the value should read "[DejaVu Sans]".
Anyway, I can go on, not wiser but helped further. Thanks again.
Please, ask what you don’t understand. And if you need help with your font code, post it on the list and we may help you. Sorry if the message contains errors (it’s too late for me to write on these topics). Pablo -- http://www.ousia.tk
participants (4)
-
Gerben Wierda
-
Henning Hraban Ramm
-
Pablo Rodriguez
-
Vladimir Lomov