Difference between revisions of "Fontfeaturefiles"
m (fontfeatures moved to featurefiles: der alte Name ist falsch/irreführend) |
m |
||
(7 intermediate revisions by 4 users not shown) | |||
Line 7: | Line 7: | ||
This is an example on how missing ligatures can be used: | This is an example on how missing ligatures can be used: | ||
− | + | <texcode> | |
− | + | \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 | |
− | + | </texcode> | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
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; | ||
+ | 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; | |
+ | </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: | ||
− | + | <texcode> | |
− | + | \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 | |
+ | </texcode> | ||
The feature file that is used here "times_kern.fea" looks like this: | The feature file that is used here "times_kern.fea" looks like this: | ||
Line 81: | Line 92: | ||
feature kern { | feature kern { | ||
− | + | script DFLT; | |
language dflt ; | language dflt ; | ||
− | + | lookup MyKerns; | |
− | + | script latn; | |
language dflt ; | language dflt ; | ||
− | + | lookup MyKerns; | |
} kern; | } kern; | ||
Line 98: | Line 109: | ||
source /Users/YourName/context/tex/setuptex /Users/YourName/context/tex | source /Users/YourName/context/tex/setuptex /Users/YourName/context/tex | ||
mtxrun --script cache --erase | 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". | ||
+ | |||
+ | |||
+ | [[Category:Old_Content]] |
Latest revision as of 14:19, 8 June 2020
(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".