ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Pablo Rodriguez <oinos@gmx.es>
To: ntg-context@ntg.nl
Subject: Re: How do I add cyrillic to my typescript/document?
Date: Tue, 5 May 2020 00:49:09 +0200	[thread overview]
Message-ID: <8a433e32-756e-add7-2e09-763e5ae4c5d5@gmx.es> (raw)
In-Reply-To: <53C018F0-069A-4265-9AD4-80A73AB6D258@rna.nl>

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	other threads:[~2020-05-04 22:49 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-03 11:34 Gerben Wierda
2020-05-03 12:56 ` Gerben Wierda
2020-05-03 13:55   ` Pablo Rodriguez
2020-05-03 22:36     ` Gerben Wierda
2020-05-04  2:37       ` Vladimir Lomov
2020-05-04  6:14       ` Henning Hraban Ramm
2020-05-04 10:13       ` Pablo Rodriguez
2020-05-04 16:38         ` Gerben Wierda
2020-05-04 22:49           ` Pablo Rodriguez [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8a433e32-756e-add7-2e09-763e5ae4c5d5@gmx.es \
    --to=oinos@gmx.es \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).