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
___________________________________________________________________________________
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
___________________________________________________________________________________

Reply via email to