Difference between revisions of "Fontfeaturefiles"
m (featurefiles moved to fontfeaturefiles: this title fits best) |
(a bit of indentation) |
||
Line 35: | Line 35: | ||
The feature file that is used "times_fl.fea" looks like this: | The feature file that is used "times_fl.fea" looks like this: | ||
− | + | <pre> | |
− | lookup fligatures { lookupflag 0; | + | lookup fligatures { |
+ | lookupflag 0; | ||
sub \f \i by \fi; | sub \f \i by \fi; | ||
− | sub \f \l by \fl | + | sub \f \l by \fl; |
− | + | } fligatures; | |
− | |||
− | |||
− | |||
+ | feature liga { | ||
+ | script DFLT; | ||
+ | language dflt; | ||
+ | lookup fligatures; | ||
+ | script latn; | ||
+ | language dflt; | ||
+ | lookup fligatures; | ||
+ | } liga; | ||
+ | </pre> | ||
This is another example showing how improved kerning can be added to the font via feature files: | This is another example showing how improved kerning can be added to the font via feature files: |
Revision as of 19:41, 1 September 2010
(This page was written and tested under ConTeXt ver: 2010.08.20 00:00 MKIV)
Recently there was the question how to modify a font at runtime. For OpenType fonts Khaled recalled an article he wrote in fontspec manual (section 11) about font feature files: you just load the feature file with featurefile=foo in your font features definition.
This is an example on how missing ligatures can be used:
\definefontfeature[thetimes][default][mode=node,featurefile=times_fl.fea] \starttypescript [serif] [TimesNR] [name] \setups[font:fallback:serif] \definefontsynonym [Serif] [file:Times New Roman.ttf] [features=thetimes] \definefontsynonym [SerifBold] [file:Times New Roman Bold.ttf] [features=thetimes] \definefontsynonym [SerifItalic] [file:Times New Roman Italic.ttf] [features=thetimes] \definefontsynonym [SerifBoldItalic][file:Times New Roman Bold Italic.ttf][features=thetimes] \stoptypescript \starttypescript[TimesNR] \definetypeface [TimesNR] [rm] [serif] [TimesNR] [default] \stoptypescript \starttypescript[TheTimes] \definetypeface [TheTimes] [rm] [serif] [TimesNR] [default] \stoptypescript \mainlanguage[de] \usetypescript[TheTimes] \setupbodyfont[TheTimes, 10pt] \starttext Hoffnung finden: fliegen \stoptext
The feature file that is used "times_fl.fea" looks like this:
lookup fligatures { lookupflag 0; sub \f \i by \fi; sub \f \l by \fl; } fligatures; feature liga { script DFLT; language dflt; lookup fligatures; script latn; language dflt; lookup fligatures; } liga;
This is another example showing how improved kerning can be added to the font via feature files:
\definefontfeature[thetimes][default][mode=node,featurefile=times_kern.fea] \starttypescript [serif] [TimesNR] [name] \setups[font:fallback:serif] \definefontsynonym [Serif] [file:Times New Roman.ttf] [features=thetimes] \definefontsynonym [SerifBold] [file:Times New Roman Bold.ttf] [features=thetimes] \definefontsynonym [SerifItalic] [file:Times New Roman Italic.ttf] [features=thetimes] \definefontsynonym [SerifBoldItalic][file:Times New Roman Bold Italic.ttf][features=thetimes] \stoptypescript \starttypescript[TimesNR] \definetypeface [TimesNR] [rm] [serif] [TimesNR] [default] \stoptypescript \starttypescript[TheTimes] \definetypeface [TheTimes] [rm] [serif] [TimesNR] [default] \stoptypescript \mainlanguage[de] \usetypescript[TheTimes] \setupbodyfont[TheTimes, 10pt] \starttext „W \stoptext
The feature file that is used here "times_kern.fea" looks like this:
lookup MyKerns { lookupflag 0; pos \quotedblbase \W -150; } MyKerns; feature kern { script DFLT; language dflt ; lookup MyKerns; script latn; language dflt ; lookup MyKerns; } kern;
These font features are loaded in the font cache.
Thus, for experimenting and eg. changing the value "-150" one must clear the cache between two runs: mtxrun --script cache --erase
For example when running context minimal in Mac you just enter in Terminal:
source /Users/YourName/context/tex/setuptex /Users/YourName/context/tex mtxrun --script cache --erase
Update
Today (1. Sept 2010.) Hans announced that with the next release this clearing isn't needed anymore:
"when you change the file or the name (or remove it) the font will be recached".