summaryrefslogtreecommitdiff
path: root/doc/context/sources/general/manuals/bidi/bidi-fonts.tex
blob: bfedd8f4745d0e1d8db694e9d892f4e4cbe49f66 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
% language=us

\startcomponent bidi-fonts

\environment bidi-style

\startchapter[title={Setting up fonts}]

So let's see how Arabic and Hebrew come out:

\startbuffer
The sentence \quotation {I have no clue what this means.} is translated (by
Google Translate) into \quotation {\ar \righttoleft ليس لدي أي فكرة عما يعنيه هذا.}
which is then translated back to \quotation {I have no idea what this means.} so
maybe arabic has no clue what a clue is. The suggested Arabic pronunciation is
\quotation {lays laday 'ayu fikrat eamaa yaenih hadha}. Hebrew also likes ideas
more: \quotation {\he \righttoleft אין לי מושג מה זה אומר}.
\stopbuffer

\typebuffer

\getbuffer

According to Idris Hamid the Arabic should actually be this: \quotation {\ar
لَيْسَ لَدَيَّ أَيُّ فِكْرَةٍ عَمَّا يَعْنِيهِ هٰذَا} and the transliteration \quotation {Laysa
ladayya ayyu fikratin ʿammā yaʿnihi hādhā}.

The \CONTEXT\ (or any \TEX) ecosystem deals with languages and fonts. Languages
(that relate to scripts) have specific characteristics, like running from right
to left, and fonts provide a repertoire of glyphs and features. There is no real
(standard) relationship between these. In for instance browsers, there are
automatic fallback systems for missing characters in a font: another font is
taken. These fallbacks are often not easy to tweak.

In this document we use Dejavu and although that font has Arabic shapes in its
monospace variant, the serifs come without them (at least when I write this
down). Before we actually define the bodyfont we hook in some fallbacks. The
typescript for Dejavu has lines like this:

\starttyping
\definefontsynonym
  [SerifBoldItalic]
  [name:dejavuserifbolditalic]
  [features=default,
   fallbacks=SerifBoldItalic]
\stoptyping

This permits us to do this:

\typebuffer[preamble-fonts]

In addition we set up the languages:

\typebuffer[preamble-languages]

The following example demonstrates what the effects of these commands are:

\startbuffer
{لَيْسَ لَدَيَّ أَيُّ فِكْرَةٍ عَمَّا يَعْنِيهِ هٰذَا.}
{אין לי מושג מה זה אומר.}
{\righttoleft لَيْسَ لَدَيَّ أَيُّ فِكْرَةٍ عَمَّا يَعْنِيهِ هٰذَا.}
{\righttoleft אין לי מושג מה זה אומר.}
{\ar \righttoleft لَيْسَ لَدَيَّ أَيُّ فِكْرَةٍ عَمَّا يَعْنِيهِ هٰذَا.}
{\he \righttoleft אין לי מושג מה זה אומר.}
{\ar لَيْسَ لَدَيَّ أَيُّ فِكْرَةٍ عَمَّا يَعْنِيهِ هٰذَا.}
{\he אין לי מושג מה זה אומר.}
\stopbuffer

\typebuffer

\startlines
\getbuffer
\stoplines

In principle you can also rely on automatic direction changes, for instance
by using the following command:

\starttyping
\setupdirections
  [bidi=global,
   method=three]
\stoptyping

But that doesn't do a font switch for you, nor does it do any of the other
language related settings. It really helps if you properly tag your
document content, as in:

\starttyping
{\ar لَيْسَ لَدَيَّ أَيُّ فِكْرَةٍ عَمَّا يَعْنِيهِ هٰذَا.}
{\he אין לי מושג מה זה אומר.}
\stoptyping

One reason to set the \type {font} parameter for a language is that it will
activate the right features in a font. Instead of falling back on some default,
we can be very specific in what we want to enable.

\stopchapter

\stopcomponent