Difference between revisions of "Command/definefontfallback"

From Wiki
Jump to navigation Jump to search
(renewed with command template)
 
(another example)
 
Line 23: Line 23:
 
     <cd:assignmentsdoc>options</cd:assignmentsdoc>
 
     <cd:assignmentsdoc>options</cd:assignmentsdoc>
 
     <cd:parameter name="rscale">
 
     <cd:parameter name="rscale">
       <cd:paramdoc></cd:paramdoc>
+
       <cd:paramdoc>relative scaling</cd:paramdoc>
 
       <cd:constant type="cd:number"></cd:constant>
 
       <cd:constant type="cd:number"></cd:constant>
 
     </cd:parameter>
 
     </cd:parameter>
 
     <cd:parameter name="force">
 
     <cd:parameter name="force">
       <cd:paramdoc></cd:paramdoc>
+
       <cd:paramdoc>use the replacement font, even if the main font contains the glyphs</cd:paramdoc>
 
       <cd:constant type="yes"></cd:constant>
 
       <cd:constant type="yes"></cd:constant>
 
       <cd:constant default="yes" type="no"></cd:constant>
 
       <cd:constant default="yes" type="no"></cd:constant>
 
     </cd:parameter>
 
     </cd:parameter>
 
     <cd:parameter name="check">
 
     <cd:parameter name="check">
       <cd:paramdoc></cd:paramdoc>
+
       <cd:paramdoc>check if the main font contains the glyphs (adds some lag)</cd:paramdoc>
 
       <cd:constant type="yes"></cd:constant>
 
       <cd:constant type="yes"></cd:constant>
 
       <cd:constant default="yes" type="no"></cd:constant>
 
       <cd:constant default="yes" type="no"></cd:constant>
Line 47: Line 47:
 
     </cd:parameter>
 
     </cd:parameter>
 
     <cd:parameter name="features">
 
     <cd:parameter name="features">
       <cd:paramdoc></cd:paramdoc>
+
       <cd:paramdoc>activate font features</cd:paramdoc>
 
       <cd:constant type="cd:name"></cd:constant>
 
       <cd:constant type="cd:name"></cd:constant>
 
     </cd:parameter>
 
     </cd:parameter>
Line 66: Line 66:
  
 
See [[Unicode blocks in ConTeXt]] and [[List of Unicode blocks]].</cd:description>
 
See [[Unicode blocks in ConTeXt]] and [[List of Unicode blocks]].</cd:description>
<cd:examples><cd:example title="Moustache brackets">We load the moustache brackets from XITS Math because they are not available in Latin Modern Math, which is the default math font.  Of course, the technique also works for text fonts.
+
<cd:examples><cd:example title="Moustache brackets">We load the moustache brackets from XITS Math because they are not available in Latin Modern Math, which is the default math font.  Of course, the technique also works for text fonts (but not in this page).
  
 
<context source="yes">
 
<context source="yes">
Line 87: Line 87:
 
\stopformula
 
\stopformula
 
</context>
 
</context>
</cd:example></cd:examples>
+
</cd:example><cd:example title="Emojis">Our main fonts doesn’t contain emojis, so we want to take them from a specialized font.
 +
And since emojis are spread over several Unicode blocks, we just say “take every unknown glyph from that emoji font” (which doesn’t work for all symbols, of course).
 +
 
 +
<texcode>
 +
\definefontfallback[emojifallback]
 +
[name:EmojiOneColor][0x00000-0xFFFFF][check=yes,force=no]
 +
 
 +
\definefontsynonym [Serif] [Pagella]  [features=default,fallbacks=emojifallback]
 +
</texcode></cd:example></cd:examples>
 
<cd:notes></cd:notes>
 
<cd:notes></cd:notes>
 
<cd:seealso>
 
<cd:seealso>
 
<cd:source file="font-col.mkvi" originator="system"></cd:source>
 
<cd:source file="font-col.mkvi" originator="system"></cd:source>
 +
<cd:source file="font-col.lua"></cd:source>
 
<cd:wikipage originator="system" page="Category:Fonts"></cd:wikipage>
 
<cd:wikipage originator="system" page="Category:Fonts"></cd:wikipage>
 
<cd:commandref name="definefontfamily"></cd:commandref>
 
<cd:commandref name="definefontfamily"></cd:commandref>
 
<cd:commandref name="definefallbackfamily"></cd:commandref>
 
<cd:commandref name="definefallbackfamily"></cd:commandref>
<cd:wikipage page="Unicode blocks in ConTeXt"></cd:wikipage></cd:seealso>
+
<cd:wikipage page="Unicode blocks in ConTeXt"></cd:wikipage>
 +
<cd:wikipage page="List of Unicode blocks"></cd:wikipage></cd:seealso>
 
</cd:commandgroup>
 
</cd:commandgroup>

Latest revision as of 11:46, 22 April 2023


\definefontfallback

Summary

The command \definefontfallback is used to setup fonts for missing characters in the main font.

Settings

\definefontfallback[...][...][...,...][...=...,...]
[...]name
[...]font name
[...,...]name number
rscalenumber
forceyes no
checkyes no
offsetnumber name
targetnumber name
featuresname
factornumber
methodlowercase uppercase

OptionExplanation
a typescript identifier to use with \definefontsynonym
the font to be used for the fallbacks
unicode character ranges or unicode block name(s)
options
rscale
relative scaling
force
use the replacement font, even if the main font contains the glyphs
check
check if the main font contains the glyphs (adds some lag)
features
activate font features

Description

This command allows to define fallback fonts for certain glyphs which are not found in the main font. The command takes four arguments where the last one is optional. The third argument (Unicode ranges) may be either a comma separated list of slots, or a a range with the syntax code|1=slot-slot or one of the mnemonic names from the following table.

See Unicode blocks in ConTeXt and List of Unicode blocks.

Examples

Moustache brackets

We load the moustache brackets from XITS Math because they are not available in Latin Modern Math, which is the default math font. Of course, the technique also works for text fonts (but not in this page).

\definefontfallback [xits-fallback] [file:xits-math.otf] [023B0,023B1]

\definefontsynonym  [MathRoman]     [modern]             [fallbacks=xits-fallback]

Consider this increasing sequence of moustached primes:

\startformula
  \lmoustache 11 \rmoustache <

  \lmoustache 29 \rmoustache <

  \lmoustache 31 \rmoustache <

  \lmoustache 37 \rmoustache <

  \lmoustache 41 \rmoustache
\stopformula

Emojis

Our main fonts doesn’t contain emojis, so we want to take them from a specialized font. And since emojis are spread over several Unicode blocks, we just say “take every unknown glyph from that emoji font” (which doesn’t work for all symbols, of course).

\definefontfallback[emojifallback]
[name:EmojiOneColor][0x00000-0xFFFFF][check=yes,force=no]

\definefontsynonym [Serif] [Pagella]  [features=default,fallbacks=emojifallback]

Notes

See also

Help from ConTeXt-Mailinglist/Forum

All issues with: