bidi-fonts.tex /size: 3570 b    last modification: 2021-10-28 13:50
1% language=us runpath=texruns:manuals/bidi
2
3\startcomponent bidi-fonts
4
5\environment bidi-style
6
7\startchapter[title={Setting up fonts}]
8
9So let's see how Arabic and Hebrew come out:
10
11\startbuffer
12The sentence \quotation {I have no clue what this means.} is translated (by
13Google Translate) into \quotation {\ar \righttoleft ليس لدي أي فكرة عما يعنيه هذا.}
14which is then translated back to \quotation {I have no idea what this means.} so
15maybe arabic has no clue what a clue is. The suggested Arabic pronunciation is
16\quotation {lays laday 'ayu fikrat eamaa yaenih hadha}. Hebrew also likes ideas
17more: \quotation {\he \righttoleft אין לי מושג מה זה אומר}.
18\stopbuffer
19
20\typebuffer
21
22\getbuffer
23
24According to Idris Hamid the Arabic should actually be this: \quotation {\ar
25لَيْسَ لَدَيَّ أَيُّ فِكْرَةٍ عَمَّا يَعْنِيهِ هٰذَا} and the transliteration \quotation {Laysa
26ladayya ayyu fikratin ʿammā yaʿnihi hādhā}.
27
28The \CONTEXT\ (or any \TEX) ecosystem deals with languages and fonts. Languages
29(that relate to scripts) have specific characteristics, like running from right
30to left, and fonts provide a repertoire of glyphs and features. There is no real
31(standard) relationship between these. In for instance browsers, there are
32automatic fallback systems for missing characters in a font: another font is
33taken. These fallbacks are often not easy to tweak.
34
35In this document we use Dejavu and although that font has Arabic shapes in its
36monospace variant, the serifs come without them (at least when I write this
37down). Before we actually define the bodyfont we hook in some fallbacks. The
38typescript for Dejavu has lines like this:
39
40\starttyping
41\definefontsynonym
42  [SerifBoldItalic]
43  [name:dejavuserifbolditalic]
44  [features=default,
45   fallbacks=SerifBoldItalic]
46\stoptyping
47
48This permits us to do this:
49
50\typebuffer[preamble-fonts]
51
52In addition we set up the languages:
53
54\typebuffer[preamble-languages]
55
56The following example demonstrates what the effects of these commands are:
57
58\startbuffer
59{لَيْسَ لَدَيَّ أَيُّ فِكْرَةٍ عَمَّا يَعْنِيهِ هٰذَا.}
60{אין לי מושג מה זה אומר.}
61{\righttoleft لَيْسَ لَدَيَّ أَيُّ فِكْرَةٍ عَمَّا يَعْنِيهِ هٰذَا.}
62{\righttoleft אין לי מושג מה זה אומר.}
63{\ar \righttoleft لَيْسَ لَدَيَّ أَيُّ فِكْرَةٍ عَمَّا يَعْنِيهِ هٰذَا.}
64{\he \righttoleft אין לי מושג מה זה אומר.}
65{\ar لَيْسَ لَدَيَّ أَيُّ فِكْرَةٍ عَمَّا يَعْنِيهِ هٰذَا.}
66{\he אין לי מושג מה זה אומר.}
67\stopbuffer
68
69\typebuffer
70
71\startlines
72\getbuffer
73\stoplines
74
75In principle you can also rely on automatic direction changes, for instance
76by using the following command:
77
78\starttyping
79\setupdirections
80  [bidi=global,
81   method=three]
82\stoptyping
83
84But that doesn't do a font switch for you, nor does it do any of the other
85language related settings. It really helps if you properly tag your
86document content, as in:
87
88\starttyping
89{\ar لَيْسَ لَدَيَّ أَيُّ فِكْرَةٍ عَمَّا يَعْنِيهِ هٰذَا.}
90{\he אין לי מושג מה זה אומר.}
91\stoptyping
92
93One reason to set the \type {font} parameter for a language is that it will
94activate the right features in a font. Instead of falling back on some default,
95we can be very specific in what we want to enable.
96
97\stopchapter
98
99\stopcomponent
100