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] \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] \definefontfamily [mainface] [serif] [TeX Gyre Pagella] \setupbodyfont[mainface] \starttext \input knuth Традиционная систематика лишайников оказывается во многом условна и \stoptext Wolfgang
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@gmail.com> wrote:
It seems the keyword here is "features"? Only the plural version works here in my newest beta.
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. 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.
-- Best Regards Chen
Am 12.10.2013 um 15:04 schrieb Zhichu Chen
Yes, the name of the key is “features”, the missing “s” was a typo.
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
On 10/13/2013 01:39 AM, Wolfgang Schuster wrote:
I get it now. I can put range and features of the fallback fonts in the preset.
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}% ,regularfont=name:adobesongstdlight% ,italicfont=name:adobefangsongstdregular% ,boldfont=name:adobeheitistdregular% ,bolditalicfont=name:adobekaitistdregular% ,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.
Am 13.10.2013 um 11:56 schrieb Zhichu Chen
I can fit this, it’s a side effect for font families with a single font, e.g. Adobe Song Std which has only the Light font but no files for regular, bold etc.
That’s not possible but you can the slant and extend options from \definefontfeature. http://wiki.contextgarden.net/Simplefonts#Faking_italics_and_bold_fonts Wolfgang
Am 12.10.2013 um 19:39 schrieb Wolfgang Schuster
I changed the way to set fonts and features for certain alternatives (the existing keys mentioned above will remain for a while) in the last beta and you can now set both values in a single setup. Below is a example where I changed the font and features for italic: \definefontfamily [mainface] [serif] [TeX Gyre Pagella] [it={style:bolditalic,features:smallcaps}] \setupbodyfont[mainface] \starttext Upright \it Italic \bf Bold \bi BoldItalic \stoptext The name for the keys are “tf”, “it”, “sl”, “bf”, “bi”, “bs” and “sc”. The values for the keys can be a font change with the methods mentioned above where the method and argument are separated by a colon. When you want to apply a feature use the “features” method. Wolfgang
Hi Wolfgang, I'm doing an overhaul of font handling in our large project, and wondering whether I should switch to simplefonts at this point. Can you tell me, how mature is simplefonts? Is it ready for heavy-duty, complex production use? Also, is it superceding the standard ConTeXt font handling? That is, should I expect to find better help available from this list for issues with simplefonts? Will new development be focused more on simplefonts? Thanks, Lars On 10/10/2013 2:02 PM, Wolfgang Schuster wrote:
On 10/14/2013 5:17 PM, Lars Huttar wrote:
Hi Wolfgang,
let me try to answer ...
I'm doing an overhaul of font handling in our large project, and wondering whether I should switch to simplefonts at this point.
Tor a a real long term robust font usage it all depends on where you store your fonts: if you rely on the operating systems setup you could burn yourself in the long run with any setup, unless you use typescripts + filenames but when you keep fonts in your project tree you can use selectfont (aka simplefonts) when it does the right job for you.
Can you tell me, how mature is simplefonts? Is it ready for heavy-duty, complex production use?
The font system is sort of layered: -- low level \font commands: most robust -- \definefont: wrapper around this -- typescripts: combines fonts in groups, create abstraction -- fallbacks: combine fonts into one -- typefaces: sets up a collection of fonts In identifying fonts there are methods like file, name, spec and file is the most robust. Selectfonts runs on top of all this, and given that its way of doing it has been around for a while (apart from the current implementation being done from scratch), it's pretty mature. If things change in the low level api (unlikely) I'm sure selectfont will adapt which is also easier now that it's in the core.
It is not a font mechanism, but a wrapper that generates unseen the standard commands. So, it runs on top of the font mechanism and not alongside; it's not a matter of replacing but of convenience. If you have a crappy font setup or use fuzzy names of use fonts that have confusing properties, nothing will help and you can't blame selectfont, but it will do its best to help you as much as possible. Improvements might be possible in the heuristics, but I'm pretty sure that Wolfgang already covered most of it. If there are issues, then the challenge is to see if they are general enough to become part of the heuristics. In that process improvements might migrate into other places. As it's now in the core, you can probably expect more of the (mw) examples to use it which is educational too. (Btw, this new modules is a nice examples of hybrid coding.) Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
Hi Wolfgang, Thanks for the update. I have a question, and I came across a bug. Question: I need some keywords in a distinctively different font, which I accomplished by defining \kword as "\definesimplefont[kword][DejaVu Mono][size=13pt]". I looked through font-sel.mkvi, but I did not see any way of implementing equivalents. (I still haven't learnt macros properly, though.) Can you please give me a hint on how I can do this with the latest fonts interface? Bug: I prefer Euler font for math. This does not seem to work with the latest fonts interface. Best regards, Prash On 10/10/13 20:02, Wolfgang Schuster wrote:
Am 14.10.2013 um 18:38 schrieb Prashanth
I’m not bringing it back but you can achieve the same by defining a new typeface/family and refer to a certain alternative of this typeface with the \classfont command. \definefontfamily[keywords][ss][DejaVu Sans Mono] \definefont[kword][\classfont{keywords}{Sans} at 13pt] \definehighlight[keyword][style=kword] \starttext Text font \keyword{keyword font} \stoptext
Bug: I prefer Euler font for math. This does not seem to work with the latest fonts interface.
The name of the font is “Neo Euler”: \definefontfamily[mainface][rm][TeX Gyre Pagella] \definefontfamily[mainface][mm][Neo Euler] \setupbodyfont[mainface] \starttext Text font $math font$ \stoptext You can also use the predefined typescript which has the name “eulernova”: \definefontfamily[mainface][rm][TeX Gyre Pagella] \definefontfamily[mainface][mm][eulernova] \setupbodyfont[mainface] \starttext Text font $math font$ \stoptext Wolfgang
On 14 oct. 2013, at 19:38, Wolfgang Schuster
Hi Wolfgang, Thanks for this wonderful module and functionalities, and the very good tutorials you give us! Out of curiosity I tested the examples you sent, which all work perfetcly, but the above code with eulernova typescript seems not to give the expected result (using ConTeXt ver: 2013.10.13 23:58 MKIV) on my installation: please see the attached PDF result of the following example: %%% begin Wolfgang's example \definefontfamily[mainface][rm][TeX Gyre Pagella] \definefontfamily[mainface][mm][eulernova] \setupbodyfont[mainface] \starttext Text font $math font$ and $\sin(t) = \int_{0}^t \cos(\theta)d\theta$ \stoptext %%% end Wolfgang's example Best regards: OK
On 10/15/2013 10:02 AM, Otared Kavian wrote:
The 'h' in mathfont is a probably a bug in the font (planck constant issue as unicode math has no italic h - sic) The large () puzzle me a bit as one would expect small ones to start with. But ... keep in mind that eulernova is unfinished. Although it is an official (dante funded) project, we have to wait till Khaled has found time for it which is probably less an issue with a few smal patched to the font, but making it complete is large effort. One complication is that euler is normally a mixed-in font, so there is an upright/italic cq. distinction issue there that will always make euler a font that should be used when the domain permits it. Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
On Tue, Oct 15, 2013 at 10:26 AM, Hans Hagen
The first example by Wolfgang works as it should \definefontfamily[mainface][rm][TeX Gyre Pagella] \definefontfamily[mainface][mm][Neo Euler] \setupbodyfont[mainface] \starttext Text font $math font$ and $\sin(t) = \int_{0}^t \cos(\theta)d\theta$ \stoptext Maybe I misunderstood something (that Neo Euler and eulernova isn't the same thing)? /Mikael
On 10/15/2013 10:41 AM, Mikael P. Sundqvist wrote:
ok, so don't use eulernova then (i checked and it's the viortual one that picks from all places ...) but anyway beware of the fatc that eulers are not complete (they were meant to be combined with concrete for instance) Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
Dnia 2013-10-15, o godz. 11:12:16
Hans Hagen
but anyway beware of the fatc that eulers are not complete (they were meant to be combined with concrete for instance)
BTW: what is the status of Concrete fonts? I'd *love* to be able to use them in ConTeXt (I can in LaTeX), what do I do to achieve this? Best, -- Marcin Borkowski http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski Adam Mickiewicz University
Am 15.10.2013 um 21:12 schrieb Marcin Borkowski
Download the CMU fonts http://canopus.iacp.dvo.ru/~panov/cm-unicode/ and use them with \definefontfamily [mainface] [rm] [CMU Concrete] \setupbodyfont[mainface] \starttext \input knuth \stoptext Wolfgang
Dnia 2013-10-15, o godz. 21:17:03
Wolfgang Schuster
Thanks, I'll try it as soon as I have some time. Best, -- Marcin Borkowski http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski Adam Mickiewicz University
On 10/15/2013 9:12 PM, Marcin Borkowski wrote:
that's luigi's pet project .. making (pouring) perfect concrete fonts (he showed some a few years ago at meetings) Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
On 10/15/2013 10:41 AM, Mikael P. Sundqvist wrote:
You need to change this in type-imp-euler.mkiv \starttypescript [\s!math] [eulernova] [\s!name] \loadfontgoodies[euler-math] \definefontsynonym [MathRoman] [\s!file:euler.otf] [\s!features=\s!math\mathsizesuffix] \stoptypescript For Neo Euler a similar set up is generated at runtime by the selectfont mechanism and that code has some hard coded settings for fonts like these. Contrary to typescripts that can be changed and are loaded at runtime, the selectfont heuristics are more frozen into the core. Anyhow, eulernova used to be a virtual variant using the Neo Euler (we used the name Nova before that but it's too close to other nova's so to confusing). However, we now overlay fonts at a different place too so that's where the weird () come from. The patch above is fixing this (okay, as nobody is going to complete the virtual vectors anyway). so, to summarize: \definefontfamily[mainface][mm][Neo Euler] uses the selectont heuristics \definefontfamily[mainface][mm][eulernova] uses the predefined euler setup, buit both boil down to the same end result. Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
On 10/15/2013 11:26 AM, Hans Hagen wrote:
I fixed the h for the combined variants, so we have: % \definefontfamily[mainface][rm][pagella] % \definefontfamily[mainface][mm][Neo Euler] % \setupbodyfont[mainface] % \definefontfamily[mainface][rm][pagella] % \definefontfamily[mainface][mm][eulernova] % \setupbodyfont[mainface] % \usetypescriptfile[euler] % \setupbodyfont [pagella-with-euler] % \usetypescriptfile[euler] % \setupbodyfont [euler-with-pagella] % \setupbodyfont [eulernova] \starttext Text font $math font$ and $\sin(t) = \int_{0}^t \cos(\theta)d\theta$ and [[$hij$]] \stoptext ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
Am 15.10.2013 um 10:26 schrieb Hans Hagen
\starttext Text font $math font( m^{(34+23)} )$ and $\sin(t) = \int_{0}^t \cos(\theta)d\theta$ \stoptext and the result came out correct! I would assume that simplefonts is not understanding the TYPESCRIPT eulernova correctly! I just look at the log and seems that MKIV load latin modern math as a fall back. From the log Using the above simplefonts method I see: Using the above simplefonts method with \definefontfamily[mainface][mm][Neo Euler] I see: This suggests to me that that simplefonts is some how trying to fall back and fails or allows a lower level method do the fall back!
participants (10)
-
Hans Hagen
-
Keith J. Schultz
-
Lars Huttar
-
Marcin Borkowski
-
Mikael P. Sundqvist
-
Otared Kavian
-
Prashanth
-
Wolfgang Schuster
-
Wolfgang Schuster
-
Zhichu Chen