type-imp-braille.mkxl /size: 5102 b    last modification: 2024-01-16 10:22
1%D \module
2%D   [       file=type-imp-vraille,
3%D        version=2021.11.17,
4%D          title=\CONTEXT\ Typescript Macros,
5%D       subtitle=Braille (using Dejavu fonts),
6%D         author=Hans Hagen,
7%D           date=\currentdate,
8%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9%C
10%C This module is part of the \CONTEXT\ macro||package and is
11%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12%C details.
13
14\continuewhenlmtxmode
15
16%D There is no need to waste money on a commercial braille font if we have dejavu. After
17%D all it's just dots. We also don't need features.
18
19\registerctxluafile{font-imp-braille}{autosuffix}
20
21% todo : not fallback, just replace directly .. special case anyway .. now inefficient and slow
22
23\starttypescriptcollection[braille]
24
25    \doifunknownfontfeature {dejavu-math-bold} {\definefontfeature[dejavu-math-bold][boldened]}
26
27    \definefontfeature[brailletext]  [braille=text]    % no ligatures, no kerning etc
28    \definefontfeature[braillemath]  [braille=math]    % no ligatures, no kerning etc
29    \definefontfeature[serifbraille] [features=none]   % no ligatures, no kerning etc
30    \definefontfeature[sansbraille]  [features=none]   % no ligatures, no kerning etc
31    \definefontfeature[monobraille]  [features=none]   % no ligatures, no kerning etc
32    \definefontfeature[mathbraille]  [features=none]   % [compactmath=yes] % no ssty so compact anyway
33
34    % Maybe some day sans and mono will also have braille but it doesn't really matter because we
35    % don't really need sans and for mono we only need the fixed spacing.
36
37    \definefontfallback[BrailleMono] [\s!name:dejavuserif*brailletext][0x0000-0x1FFFF][force=yes]
38    \definefontfallback[BrailleSerif][\s!name:dejavuserif*brailletext][0x0000-0x1FFFF][force=yes]
39    \definefontfallback[BrailleSans] [\s!name:dejavuserif*brailletext][0x0000-0x1FFFF][force=yes]
40   %\definefontfallback[BrailleMath] [\s!name:dejavuserif*braillemath][0x0000-0x1FFFF][force=yes]
41
42    \definefontfallback[BrailleMonoBold] [\s!name:dejavuserifbold*brailletext][0x0000-0x1FFFF][force=yes]
43    \definefontfallback[BrailleSerifBold][\s!name:dejavuserifbold*brailletext][0x0000-0x1FFFF][force=yes]
44    \definefontfallback[BrailleSansBold] [\s!name:dejavuserifbold*brailletext][0x0000-0x1FFFF][force=yes]
45
46    \starttypescript [\s!serif] [braille] [\s!name]
47        \definefontsynonym [\s!Serif]           [\s!name:dejavuserif]    [\s!features=serifbraille,\s!fallbacks=BrailleSerif]
48        \definefontsynonym [\s!SerifBold]       [\s!name:dejavuserifbold][\s!features=serifbraille,\s!fallbacks=BrailleSerifBold]
49        \definefontsynonym [\s!SerifItalic]     [\s!Serif]
50        \definefontsynonym [\s!SerifBoldItalic] [\s!SerifBold]
51        \definefontsynonym [\s!SerifSlanted]    [\s!Serif]
52        \definefontsynonym [\s!SerifBoldSlanted][\s!SerifBold]
53    \stoptypescript
54
55    \starttypescript [\s!sans] [braille] [\s!name]
56        \definefontsynonym [\s!Sans]           [\s!name:dejavusans]    [\s!features=sansbraille,\s!fallbacks=BrailleSans]
57        \definefontsynonym [\s!SansBold]       [\s!name:dejavusansbold][\s!features=sansbraille,\s!fallbacks=BrailleSansBold]
58        \definefontsynonym [\s!SansItalic]     [\s!Sans]
59        \definefontsynonym [\s!SansBoldItalic] [\s!SansBold]
60        \definefontsynonym [\s!SansSlanted]    [\s!Sans]
61        \definefontsynonym [\s!SansBoldSlanted][\s!SansBold]
62    \stoptypescript
63
64    \starttypescript [\s!mono] [braille] [\s!name]
65        \definefontsynonym [\s!Mono]           [\s!name:dejavusansmono]    [\s!features=monobraille,\s!fallbacks=BrailleMono]
66        \definefontsynonym [\s!MonoBold]       [\s!name:dejavusansmonobold][\s!features=monobraille,\s!fallbacks=BrailleMonoBold]
67        \definefontsynonym [\s!MonoItalic]     [\s!Mono]
68        \definefontsynonym [\s!MonoBoldItalic] [\s!MonoBold]
69        \definefontsynonym [\s!MonoSlanted]    [\s!Mono]
70        \definefontsynonym [\s!MonoBoldSlanted][\s!MonoBold]
71    \stoptypescript
72
73    \starttypescript [\s!math][braille] [\s!name]
74        \loadfontgoodies[dejavu-math]
75       %\definefontsynonym[\s!MathRoman]    [\s!file:texgyredejavu-math][\s!features={mathbraille,\s!math\mathsizesuffix},\s!fallbacks=BrailleMath]
76       %\definefontsynonym[\s!MathRomanBold][\s!file:texgyredejavu-math][\s!features={mathbraille,\s!math\mathsizesuffix,dejavu-math-bold},\s!fallbacks=BrailleMath]
77        \definefontsynonym[\s!MathRoman]    [\s!file:texgyredejavu-math][\s!features={braillemath,\s!math\mathsizesuffix},\s!goodies=dejavu-math]
78        \definefontsynonym[\s!MathRomanBold][\s!file:texgyredejavu-math][\s!features={braillemath,\s!math\mathsizesuffix,dejavu-math-bold},\s!goodies=dejavu-math]
79    \stoptypescript
80
81    \starttypescript[braille]
82        \definetypeface [braille] [\s!rm] [\s!serif] [braille] [\s!default]
83        \definetypeface [braille] [\s!ss] [\s!sans]  [braille] [\s!default]
84        \definetypeface [braille] [\s!tt] [\s!mono]  [braille] [\s!default]
85        \definetypeface [braille] [\s!mm] [\s!math]  [braille] [\s!default]
86    \stoptypescript
87
88\stoptypescriptcollection
89