Am 12.10.2013 um 15:04 schrieb Zhichu Chen <zhichu.c...@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.schus...@gmail.com> wrote:
> Hi all,
>
> I’m happy to announce a new version of the simplefonts code. Thew new version
> of the code
> is a complete rewrite and brings many changes.
>
> 1. The module is now part of the core and no external module is needed
> anymore.
>
> 2. The commands to select a font have changed to commands which fit better to
> context normal syntax.
>
> 3. I removed the keys to enable font expansion and protrusion, when you need
> them use \definefontfeature.
>
>
> To use a font with the simplefonts code two ways are available. The first
> method is to create
> one or more typefaces and load it with \setupbodyfont. A complete example for
> this is:
>
> \definefontfamily [mainface] [serif] [DejaVu Serif]
> \definefontfamily [mainface] [sans] [DejaVu Sans]
> \definefontfamily [mainface] [mono] [DejaVu Sans Mono] [feature=none]
> It seems the keyword here is "features"? Only the plural version works here
> in my newest beta.
Yes, the name of the key is “features”, the missing “s” was a typo.
> \definefontfamily [mainface] [math] [TeX Gyre Pagella Math]
>
> \setupbodyfont[mainface]
>
> \starttext
> \startlines
> \rm DejaVu Serif
> \ss DejaVu Sans
> \tt DejaVu Sans Mono
> \m{c^2 = a^2 + b^2}
> \stoplines
> \stoptext
>
>
> The second method is similar to the old commands of the simplefonts module
> (e.g. \setmainfont)
> where the font is enabled after it was set and no \setupbodyfont is
> necessary. Below is a example
> for this method but I recommend to avoid this method because it’s slow when
> you set font a font
> for each style in your document.
>
> \setupfontfamily [serif] [DejaVu Serif]
> \setupfontfamily [sans] [DejaVu Sans]
> \setupfontfamily [mono] [DejaVu Sans Mono] [feature=none]
> \setupfontfamily [math] [TeX Gyre Pagella Math]
>
> \starttext
> \startlines
> \rm DejaVu Serif
> \ss DejaVu Sans
> \tt DejaVu Sans Mono
> \m{c^2 = a^2 + b^2}
> \stoplines
> \stoptext
>
>
> Another feature of simplefonts is the ability to set a fallback font when you
> need certain glyphs
> from a different font (e.g. for cyrillic ) which aren’t available in the
> mainfont of the document.
> To set such a fallback font the code provides the \definefallbackfamily
> command where you
> can set in the fourth argument the range for the replacement characters.
>
> \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.
> 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.
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
___________________________________________________________________________________
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://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________