# [NTG-context] Simplefonts

Zhichu Chen zhichu.chen at gmail.com
Sun Oct 13 11:56:03 CEST 2013

On 10/13/2013 01:39 AM, Wolfgang Schuster wrote:
>
> Am 12.10.2013 um 15:04 schrieb Zhichu Chen <zhichu.chen at gmail.com
> <mailto:zhichu.chen at gmail.com>>:
>
>> Hi Wolfgang,
>>
>> Good to know that, but I might have some questions.
>>
>>
>> On Fri, Oct 11, 2013 at 2:02 AM, Wolfgang Schuster
>> <wolfgang.schuster at gmail.com <mailto:wolfgang.schuster at gmail.com>> wrote:
>>
>>     Hi all,
>>
>>     \definefallbackfamily [mainface] [serif] [DejaVu Serif]
>>     [range=cyrillic,force=yes]
>>
>> What if I want to use the CJK font? The code in "font-sel.mkvi" hints
>> I could use range=chinese but it didn't work. I have to use interval
>> {0x00400-0x2FA1F} explicitly.
>
> When you take a look into char-def.lua you can see names certain
> character ranges and “range=cyrillic”
> used such a name.
>
> For a chinese font you need
> “range={cjkunifiedideographs,cjkunifiedideographsextensiona,…}".
> Because the list with names is very long you do this setup only once
> with the \definefontfamilypreset
> command, e.g.
>
> \definefontfamilypreset[chinese][range={cjkunifiedideographs,cjkunifiedideographsextensiona,…}]
>
> and load this setup when you set the font with
> \definefontfamilyfallback, e.g.
>
>   \definefontfamilyfallback[<typeface>][<style>][<font>][preset=chinese]
>
> For the moment I added three presets “chinese”, “japanese” and
> “korean” but they need better
> names, e.g. “range:chinese” because there could be also
> “features:chinese” etc.
I get it now. I can put range and features of the fallback fonts in the
preset.
>
>> And how can I assign the boldfont, italicfont and bolditalicfont? I'm
>> currently using the Adobe Song Std as the regular font but it didn't
>> come with a bold version or else, hence I might need this feature.
>
> The module provides keys to apply a certain font and feature for each
> alternative (upright, italic etc.)
> of a font, a complete list with all keys is shown in the table below.
>
> -------------------------------------------------------
> | Alternative | Font            | Feature             |
> |-----------------------------------------------------|
> | tf          | regularfont     | regularfeatures     |
> | it          | italicfont      | italicfeatures      |
> | sl          | slantedfont     | slantedfeatures     |
> | bf          | boldfont        | boldfeatures        |
> | bi          | bolditalicfont  | bolditalicfeatures  |
> | bs          | boldslantedfont | boldslantedfeatures |
> | sc          | smallcapsfont   | smallcapsfeatures   |
> -------------------------------------------------------
>
> The feature-keys expect the name from the \definefontfeature command,
> when you don’t
> specify a feature to a certain alternative the value from the
> “features” key is used.
>
> When you want to set a certain font for a alternative there are
> different ways, I’m going
> to show the different ways with a few examples where I change the font
> for italic.
Thanks for the descriptions. I have made a small test and turns out the
"regularfont" has to be assigned to something or the other "xxxfont"s
won't have any effects.

Here's my code:
=================================================
\definefallbackfamily [mainface] [serif] [adobesongstd]
[range={0x00400-0x2FA1F}%
,force=yes%
,features=song%
]
=================================================
and if I remove the "regularfont=..." line, the boldface Chinese
characters will use the Adobe Song Std font as well. Same thing happened
when I used the "preset=xxx" option which I don't know if it is intended
to behave like that, by the way.

Oh, and off the topic, can I use "effect" to assign the fonts? Like if I
have defined
=================================================
\defineeffect[mybold][alternative=both,rulethickness=\dimexpr\bodyfontsize/10\relax]
=================================================
I would like to use this effect to apply to my bold fonts, maybe:
=================================================
\setupfontfamily [serif] [DejaVu Serif] [boldfont=effect:mybold]
=================================================
I know this has nothing to do with this module. I just thought this
might be interesting.
>
> 1. Use the filename of a font. With the “file:” prefix you can the
> tell the module
> to look for a file with the given name, when the file isn’t found the
> font from
> the tf-alternative is used. The file-method is also used when you omit
> the prefix.
>
> \setupfontfamily [serif] [DejaVu Serif] [italicfont=file:dejavuserifbold]
>
> \starttext
> Regular and \it Italic
> \stoptext
>
> 2. Use a certain style. When you use the “style: ”prefix the module
> looks for a certain
> style of the requested font.
>
> \setupfontfamily [serif] [DejaVu Serif] [italicfont=style:bolditalic]
>
> \starttext
> Regular and \it Italic
> \stoptext
>
> 3. Search for a font with a certain name. When you use the “name:”
> prefix the module
> looks for a font with the requested name. Names are internal values of
> a font which
> is sometimes the same as the filename.
>
> \setupfontfamily [serif] [DejaVu Serif] [italicfont=name:dejavuserifbold]
>
> \starttext
> Regular and \it Italic
> \stoptext
>
> 4. Use the spec information. When you use the “spec:” prefix you can
> request a font
> with a certain “weight” (bold or normal), “style” (italic or normal)
> and variant (smallcaps or normal).
>
> \setupfontfamily [serif] [DejaVu Serif] [italicfont=spec:bold-italic]
>
> \starttext
> Regular and \it Italic
> \stoptext
>
>
> There is a possibility that I change the way to set font and features
> for alternatives
> in the feature to a way which is more compact and easier to parse in Lua.
>
> Wolfgang

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.ntg.nl/pipermail/ntg-context/attachments/20131013/b35ece13/attachment-0001.html>