bd6c345b19267f28add74a32b013d1b01fb55d09
[m17n/m17n-docs.git] / data-usr / dbformat.txt
1 /*** @addtogroup m17nDatabase */
2 ////
3 /*** @{ */
4 ////
5 /***@defgroup m17nDatabaseFormat DatabaseFormat
6
7 This section describes the formats of predefined @e plist @e type data
8 in the m17n database.
9
10 @section dbformat General format
11
12 The m17n library expects that the function mdatabase_load () returns a
13 plist of a specific format on loading data identified by a specific
14 set of tags.  As the plist format used for the database data is
15 strongly limited, we can use the equivalent text of simple syntax
16 (S-expression) to represent the plist as below.
17
18 The text consists of one or more @e elements .  Each element
19 represents a property, i.e. a single element of a plist, and the
20 sequence of the elements constitute a plist.
21
22 Elements are separated by one or more @e whitespaces, i.e. a space
23 (code 32), a tab (code 9), or a newline (code 10).  Comments begin
24 with a semicolon (<tt>;</tt>) and extend to the end of the line.
25
26 The key and the value of each property are determined based on the
27 form of element as below:
28
29 <ul>
30
31 <li> INTEGER
32
33 An element that matches the regular expression @c -?[0-9]+ or @c
34 0[xX][0-9A-Fa-f]+ represents a property whose key is @c Minteger .  An
35 element matching the former expression is interpreted as an integer in
36 decimal notation, and one matching the latter expression is
37 interpreted as an integer in hexadecimal notation.  The resulting
38 integer is the value of the property.
39
40 For instance, the element 0xA0 represents a property whose value is
41 the integer 160.
42
43 <li> SYMBOL
44
45 An element that matchs the regular expression @c
46 [^-0-9(]([^\\()]|\\.)+ represents a property whose key is @c Msymbol .
47 In the sequence, @c \\t , @c \\n , @c \\r , and @c \\e are replaced
48 with tab (code 9), newline (code 10), carriage return (code 13), and
49 escape (code 27) respectively.  Other characters following a backslash
50 is interpreted as it is.  The symbol having the name of the resulting
51 sequence is the value of the property.
52
53 For instance, the element <tt>abc\ def</tt> represents a property
54 whose value is the symbol of name "abc def".
55
56 <li> M-TEXT
57
58 An element that matches the regular expression @c "([^"]|\\")*"
59 represents a property whose key is @c Mtext .  The backslash escape
60 explained above also applies here.  Moreover, each part in the
61 sequence matching the regular expression @c
62 \\[xX][0-9A-Fa-f][0-9A-Fa-f] is replaced with its hexadecimal
63 interpretation.
64
65 After having resolved the backslash escapes, the byte sequence between
66 the double quotes is interpreted as a UTF-8 sequence and decoded into
67 an M-text.  This M-text is the value of the property.
68
69 <li> PLIST
70
71 An element that is preceded by a left parenthesis, followed zero or
72 more elements, and terminated by a right parenthesis represents a
73 property whose key is @c Mplist .  Parentheses also serve as a
74 separator, which means whitespaces before and after a parenthesis can
75 be omitted.  The value of the property is a plist, which is the result
76 of recursive interpretation of the elements between the parentheses.
77
78 </ul>
79
80 EXAMPLE
81
82 Suppose (K1:V1, K2:V2, ... ,Kn:Vn) represents a plist whose first
83 property key and value are K1 and V1, second key and value are K2 and
84 V2, and so on.  Then the line:
85 @verbatim
86 abc 123 (pqr 0xff) "m\"text" (_\\_ ("string" xyz) -456)
87 @endverbatim
88 is interpreted as follows.
89 @verbatim
90 (Msymbol:abc,
91  Minteger:123,
92  Mplist:(Msymbol:pqr,
93          Minteger:255),
94  Mtext:m"text,
95  Mplist:(Msymbol:_\_,
96          Mplist:(Mtext:string,
97                  Msymbol:xyz),
98          Minteger:-456))
99 @endverbatim
100
101 The default database loader of the m17n library actually read a text
102 of this syntax from the database file.
103
104 Here after we describes the plist format of each data by this syntax.
105
106 @section fontset Fontset
107
108 @section fontenc Font Encoding
109
110 The m17n library loads information about the encoding of each font
111 form the m17n database by the tags \<font, encoding\>.  The plist
112 format of the data is as follows:
113
114 @verbatim
115 FONT-ENCODING ::=
116     '(' PER-FONT-INFO * ')'
117
118 PER-FONT-INFO ::=
119     '(' FONT-SPEC ENCODING ')'
120
121 FONT-SPEC ::=
122     '(' 
123     [ FOUNDRY FAMILY [ WEIGHT [ STYLE [ STRETCH [ ADSTYLE ] ] ] ] ] REGISTRY
124     ')'
125 @endverbatim
126
127 @c FOUNDRY to @c REGISTRY are symbols specifying the corresponding
128 XLFD font name fields.  Omitted symbols are regarded as @c nil, and
129 @c nil means a wild card.  For instance, this @c FONT-SPEC:
130
131 @verbatim
132     (nil alice0\ lao iso8859-1)
133 @endverbatim
134
135 should be applied to all fonts whose family is "alice0 lao", and
136 registry is "iso8859-1".
137
138 @c ENCODING is a charset symbol.  A font matching @c FONT-SPEC
139 supports all characters of the charset, and a character code is mapped
140 to the corresponding glyph code of the font by this charset.
141
142 @section fontsize Font Resizing
143
144 In some case, a font contains incorrect information about its size
145 (typically in the case of a hacked TrueType font), and results in a
146 bad text layout when such a font is used in combination with the other
147 fonts.  To overcome this problem, the m17n library loads information
148 about font-size correction from the m17n database by the tags \<font,
149 resize\>.  The plist format of the data is as follows:
150
151 @verbatim
152 FONT-RESIZE ::=
153     '(' PER-FONT-INFO * ')'
154
155 PER-FONT-INFO ::=
156     '(' FONT-SPEC RESIZE-RATIO ')'
157
158 FONT-SPEC ::=
159     '(' 
160     [ FOUNDRY FAMILY [ WEIGHT [ STYLE [ STRETCH [ ADSTYLE ] ] ] ] ] REGISTRY
161     ')'
162 @endverbatim
163
164 The meanings of @c FOUNDRY to @c REGISTRY are the same as @e Font @e
165 Encoding.  @c RESIZE-RATIO is an integer number specifying by
166 percentage how much the font-size must be adjusted.  For instance,
167 this @c PER-FONT-INFO:
168
169 @verbatim
170     ((devanagari-cdac) 150)
171 @endverbatim
172
173 means that, to use a font of registry "devanagari-cdac" with a
174 specific size, we have to open an 1.5 times bigger one.
175
176 @section flt Font Layout Table
177
178 @verbinclude flt.txt
179
180 @section im Input Method
181
182 @verbinclude im.txt */
183
184 ////
185 /*** @} */
186 ////