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 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!--
Copyright (C) 2001 Information-technology Promotion Agency (IPA)
Copyright (C) 2001-2004
National Institute of Advanced Industrial Science and Technology (AIST)
This file is part of the m17n library documentation.
See the end for copying conditions.
-->
<html><head><meta http-equiv="Content-Type" content="text/html;charset="UTF-8">
<title>The m17n Library</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#ffffff">
<a name="top-of-page"></a>
<hr><center>
<a class="qindex" href="index.html">Main Page</a>
<a class="qindex" href="modules.html">Modules</a>
<!-- <a class="qindex" href="classes.html">Alphabetical List</a> -->
<a class="qindex" href="annotated.html">Data Structures</a>
<!-- <a class="qindex" href="files.html">File List</a> -->
<!-- <a class="qindex" href="functions.html">Data Fields</a> -->
<a class="qindex" href="globals.html">Globals</a>
<a class="qindex" href="pages.html">Appendix</a>
</center>
<hr>
<!-- Generated by Doxygen 1.3.9.1 -->
<h1><a class="anchor" name="m17nDBFormat">Data format of the m17n database</a></h1>This section describes formats of these data supplied by the m17n database.<p>
<ul>
<li>
<a class="el" href="m17nDBFormat.html#mdbGeneral">General</a> -- General Format </li>
<li>
<a class="el" href="m17nDBFormat.html#mdbCharsetList">CharsetList</a> -- List of character set definitions </li>
<li>
<a class="el" href="m17nDBFormat.html#mdbCodingList">CodingList</a> -- List of coding system definitions </li>
<li>
<a class="el" href="m17nDBFormat.html#mdbDir">Dir</a> -- List of data in a database directory. </li>
<li>
<a class="el" href="m17nDBFormat.html#mdbFLT">FLT</a> -- Font Layout Table </li>
<li>
<a class="el" href="m17nDBFormat.html#mdbFontEncoding">FontEncoding</a> -- Font Encoding </li>
<li>
<a class="el" href="m17nDBFormat.html#mdbFontSize">FontSize</a> -- Font Size </li>
<li>
<a class="el" href="m17nDBFormat.html#mdbFontset">Fontset</a> -- Fontset </li>
<li>
<a class="el" href="m17nDBFormat.html#mdbIM">IM</a> -- Input Method </li>
</ul>
<h2><a class="anchor" name="mdbGeneral">
General Format</a></h2>
<h3><a class="anchor" name="general-description">
DESCRIPTION</a></h3>
The <a class="el" href="group__m17nDatabase.html#ga5">mdatabase_load()</a> function returns the data specified by tags in the form of plist if the first tag is not <code>Mchartable</code> nor <code>Mcharset</code>. The keys of the returned plist are limited to <code>Minteger</code>, <code>Msymbol</code>, <code>Mtext</code>, and <code>Mplist</code>. The type of the value is unambiguously determined by the corresponding key. If the key is <code>Minteger</code>, the value is an integer. If the key is <code>Msymbol</code>, the value is a symbol. And so on.<p>
A number of expressions are possible to represent a plist. For instance, we can use the form <code>(K1:V1, K2:V2, ..., Kn:Vn)</code> to represent a plist whose first property key and value are K1 and V1, second key and value are K2 and V2, and so on. However, we can use a simpler expression here because the types of plists used in the m17n database are fairly restricted.<p>
Hereafter, we use an expression, which is similar to S-expression, to represent a plist. (Actually, the default database loader of the m17n library is designed to read data files written in this expression.)<p>
The expression consists of one or more <em>elements</em>. Each element represents a property, i.e. a single element of a plist.<p>
Elements are separated by one or more <em>whitespaces</em>, i.e. a space (code 32), a tab (code 9), or a newline (code 10). Comments begin with a semicolon (<code>;</code>) and extend to the end of the line.<p>
The key and the value of each property are determined based on the type of the element as explained below.<p>
<ul>
<li>
INTEGER<p>
An element that matches the regular expression <code>-?[0-9]+</code> or <code>0[xX][0-9A-Fa-f]+</code> represents a property whose key is <code>Minteger</code>. An element matching the former expression is interpreted as an integer in decimal notation, and one matching the latter is interpreted as an integer in hexadecimal notation. The value of the property is the result of interpretation.<p>
For instance, the element <code>0xA0</code> represents a property whose value is 160 in decimal.<p>
</li>
<li>
SYMBOL<p>
An element that matches the regular expression <code>[^-0-9(]([^\()]|\.)+</code> represents a property whose key is <code> Msymbol</code>. In the element, <code>\t</code>, <code>\n</code>, <code>\r</code>, and <code>\e</code> are replaced with tab (code 9), newline (code 10), carriage return (code 13), and escape (code 27) respectively. Other characters following a backslash is interpreted as it is. The value of the property is the symbol having the resulting string as its name.<p>
For instance, the element <code>abc\ def</code> represents a property whose value is the symbol having the name "abc def".<p>
</li>
<li>
MTEXT<p>
An element that matches the regular expression <code>"([^"]|\")*"</code> represents a property whose key is <code>Mtext</code>. The backslash escape explained above also applies here. Moreover, each part in the element matching the regular expression <code> \[xX][0-9A-Fa-f][0-9A-Fa-f]</code> is replaced with its hexadecimal interpretation.<p>
After having resolved the backslash escapes, the byte sequence between the double quotes is interpreted as a UTF-8 sequence and decoded into an M-text. This M-text is the value of the property.<p>
</li>
<li>
PLIST<p>
Zero or more elements surrounded by a pair of parentheses represent a property whose key is <code>Mplist</code>. Whitespaces before and after a parenthesis can be omitted. The value of the property is a plist, which is the result of recursive interpretation of the elements between the parentheses.<p>
</li>
</ul>
<h3><a class="anchor" name="general-syntax">
SYNTAX NOTATION</a></h3>
In an explanation of a plist format of data, a BNF-like notation is used. In the notation, non-terminals are represented by a string of uppercase letters (including '-' in the middle), terminals are represented by a string surrounded by '"'. Special non-terminals INTEGER, SYMBOL, MTEXT and PLIST represents property integer, symbol, M-text, or plist respectively.<h3><a class="anchor" name="general-example">
EXAMPLE</a></h3>
Here is an example of database data that is read into a plist of this simple format:<p>
<div class="fragment"><pre class="fragment">
DATA-FORMAT ::=
[ INTEGER | SYMBOL | MTEXT | FUNC ] *
FUNC ::=
'(' FUNC-NAME FUNC-ARG * ')'
FUNC-NAME ::=
SYMBOL
FUNC-ARG ::=
INTEGER | SYMBOL | MTEXT | '(' FUNC-ARG ')'
</pre></div><p>
For instance, a data file that contains this text matches the above syntax:<p>
<div class="fragment"><pre class="fragment">
abc 123 (pqr 0xff) "m\"text" (_\\_ ("string" xyz) -456)
</pre></div><p>
and is read into this plist:<p>
<div class="fragment"><pre class="fragment">
1st element: key: Msymbol, value: abc
2nd element: key: Minteger, value: 123
3rd element: key: Mplist, value: a plist of these elements:
1st element: key Msymbol, value: pgr
2nd element: key Minteger, value: 255
4th element: key: Mtext, value: m"text
5th element: key: Mplist, value: a plist of these elements:
1st element: key: Msymbol, value: _\_
2nd element: key: Mplist, value: a plist of these elements:
1st element: key: Mtext, value: string
2nd element: key: Msymbol, value: xyz
3rd element: key: Minteger, value: -456
</pre></div><h2><a class="anchor" name="mdbCharsetList">
List of character set definitions</a></h2>
<h3><a class="anchor" name="cslist-description">
DESCRIPTION</a></h3>
The m17n library loads a list of charset definitions from the data of tag <charset-list>. The data is loaded as a plist of this format.<p>
<div class="fragment"><pre class="fragment">
CHARSET-LIST ::= DEFINITION *
DEFINITION ::= '(' NAME ( KEY VALUE ) * ')'
NAME ::= SYMBOL
KEY ::= SYMBOL
VALUE ::= SYMBOL | INTEGER | MTEXT | PLIST
</pre></div><p>
<code>NAME</code> is a name of a charset to define.<p>
<code>KEY</code> and <code>VALUE</code> pair is a property given to the function <a class="el" href="group__m17nCharset.html#ga26">mchar_define_charset()</a> as an element of the second argument <b>plist</b>.<h3><a class="anchor" name="cslist-seealso">
SEE ALSO</a></h3>
<a class="el" href="m17nDBFormat.html#mdbGeneral">mdbGeneral(5)</a>, <a class="el" href="group__m17nCharset.html#ga26">mchar_define_charset()</a><h2><a class="anchor" name="mdbCodingList">
List of coding system definitions</a></h2>
<h3><a class="anchor" name="coding-list-description">
DESCRIPTION</a></h3>
The m17n library loads a list of coding system definitions from the m17n database by the tags <coding-list> at initialization time. The data is loaded as a plist of this format.<p>
<div class="fragment"><pre class="fragment">
CODING-LIST ::= DEFINITION *
DEFINITION ::= '(' NAME ( KEY VALUE ) * ')'
NAME ::= SYMBOL
KEY ::= SYMBOL
VALUE ::= SYMBOL | INTEGER | MTEXT | PLIST
</pre></div><p>
<code>NAME</code> is a name of a coding system to define.<p>
<code>KEY</code> and <code>VALUE</code> pair is a property given to the function <a class="el" href="group__m17nConv.html#ga38">mconv_define_coding()</a> as the second argument.<h3><a class="anchor" name="coding-list-seealso">
SEE ALSO</a></h3>
<a class="el" href="m17nDBFormat.html#mdbGeneral">mdbGeneral(5)</a>, <a class="el" href="group__m17nConv.html#ga38">mconv_define_coding()</a><h2><a class="anchor" name="mdbDir">
List of data in a database directory.</a></h2>
<h3><a class="anchor" name="dir-description">
DESCRIPTION</a></h3>
The m17n library loads a list of definitions of data of the m17n database from files of name "mdb.dir" in each database directory at initialization time. The plist format of this file is as follows:<p>
<div class="fragment"><pre class="fragment">
MDB-DIR ::= DEFINITION *
DEFINITION ::= '(' TAG [ TAG [ TAG [ TAG ] ] ] FILE ')'
TAG ::= SYMBOL
FILE ::= MTEXT
</pre></div><h2><a class="anchor" name="mdbFLT">
Font Layout Table</a></h2>
<h3><a class="anchor" name="flt-description">
DESCRIPTION</a></h3>
For simple scripts, the rendering engine converts character codes into glyph codes one by one by consulting the encoding of each selected font. But, to render text that requires complicated layout (e.g. Thai and Indic scripts), one to one conversion is not sufficient. A sequence of characters may have to be drawn as a single ligature. Some glyphs may have to be drawn at 2-dimensionally shifted positions.<p>
To handle those complicated scripts, the m17n library uses Font Layout Tables (FLTs for short). The FLT driver interprets an FLT and converts a character sequence into a glyph sequence that is ready to be passed to the rendering engine.<p>
An FLT can contain information to extract a grapheme cluster from a character sequence and to reorder the characters in the cluster, in addition to information found in OpenType Layout Tables (CMAP, GSUB, and GPOS).<p>
An FLT is a cascade of one or more conversion stages. In each stage, a sequence is converted into another sequence to be read in the next stage. The length of sequences may differ from stage to stage. Each element in a sequence has the following integer attributes.<p>
<ul>
<li>
code<p>
In the first conversion stage, this is the character code in the original character sequence. In the last stage, it is the glyph code passed to the rendering engine. In other cases, it is an intermediate glyph code.<p>
</li>
<li>
category<p>
This is the category code defined in the <code>CATEGORY-TABLE</code> of the current stage.<p>
</li>
<li>
combining-spec<p>
If nonzero, it specifies how to combine this (intermediate) glyph with the previous one.<p>
</li>
<li>
left-padding-flag<p>
If nonzero, it instructs the rendering function to insert a padding space before this (intermediate) glyph so that the glyph does not overlap with the previous one.<p>
</li>
<li>
right-padding-flag<p>
If nonzero, it instructs the rendering function to insert a padding space after this (intermediate) glyph so that the glyph does not overlap with the next one.<p>
</li>
</ul>
<p>
When the layout engine draws text, it at first determines a font and an FLT for each character in the text. For each subsequence of characters that use use the same font and FLT, the layout engine generates an intermediate glyph sequence from the character subsequence. Each element in the intermediate glyph sequence has the corresponding character code as the code attribute and zeroes for other attributes. This sequence is processed in the first stage of FLT as the current <em>run</em> (substring).<p>
Each stage works as follows.<p>
At first, if the stage has a <code>CATEGORY-TABLE</code>, the category of each glyph in the current run is updated. If there is a glyph that has no category, the current run ends before that glyph.<p>
Then, the default values of code-offset, combining-spec, and left-padding-flag of this stage are initialized to zero.<p>
Next, the initial conversion rule of the stage is applied to the current run.<p>
Lastly, the current run is replaced with the newly produced (intermediate) glyph sequence.<h3><a class="anchor" name="flt-syntax">
SYNTAX and SEMANTICS</a></h3>
The m17n library loads an FLT from the m17n database using the tag <font, layouter, FLT-NAME>. The date format of an FLT is as follows:<p>
<div class="fragment"><pre class="fragment">
FONT-LAYOUT-TABLE ::= STAGE0 STAGE *
STAGE0 ::= CATEGORY-TABLE GENERATOR
STAGE ::= CATEGORY-TABLE ? GENERATOR
CATEGORY-TABLE ::= '(' 'category' CATEGORY-SPEC + ')'
CATEGORY-SPEC ::= '(' CODE CATEGORY ')'
| '(' CODE CODE CATEGORY ')'
CODE ::= INTEGER
CATEGORY ::= INTEGER
</pre></div><p>
In the definition of <code>CATEGORY-SPEC</code>, <code>CODE</code> is a glyph code, and <code>CATEGORY</code> is ASCII code of an upper or lower letter, i.e. one of 'A', ... 'Z', 'a', .. 'z'.<p>
The first form of <code>CATEGORY-SPEC</code> assigns <code>CATEGORY</code> to a glyph whose code <code>CODE</code>. The second form assigns <code>CATEGORY</code> to glyphs whose code falls between the two <code>CODEs</code>.<p>
<div class="fragment"><pre class="fragment">
GENERATOR ::= '(' 'generator' RULE MACRO-DEF * ')'
RULE ::= REGEXP-BLOCK | MATCH-BLOCK | SUBST-BLOCK | COND-BLOCK
| DIRECT-CODE | COMBINING-SPEC | OTF-SPEC
| PREDEFINED-RULE | MACRO-NAME
MACOR-DEF ::= '(' MACRO-NAME RULE + ')'
</pre></div><p>
Each <code>RULE</code> specifies glyphs to be consumed and glyphs to be produced. When some glyphs are consumed, they are taken away from the current run. A rule may fail in some condition. If not described explicitly to fail, it should be regarded that the rule succeeds.<p>
<div class="fragment"><pre class="fragment">
DIRECT-CODE ::= INTEGER
</pre></div><p>
This rule consumes no glyph and produces a glyph which has the following attributes:<p>
<ul>
<li>
code : <code>INTEGER</code> plus the default code-offset </li>
<li>
combining-spec : default value </li>
<li>
left-padding-flag : default value </li>
<li>
right-padding-flag : zero </li>
</ul>
<p>
After having produced the glyph, the default code-offset, combining-spec, and left-padding-flag are all reset to zero.<p>
<div class="fragment"><pre class="fragment">
PREDEFINED-RULE ::= '=' | '*' | '<' | '>' | '|' | '[' | ']'
</pre></div><p>
They perform actions as follows.<p>
<ul>
<li>
<code>=</code> <p>
This rule consumes the first glyph in the current run and produces the same glyph. It fails if the current run is empty.<p>
</li>
<li>
<code>*</code> <p>
This rule repeatedly executes the previous rule. If the previous rule fails, this rule does nothing and fails.<p>
</li>
<li>
<code><</code> <p>
This rule specifies the start of a grapheme cluster.<p>
</li>
<li>
<code>></code> <p>
This rule specifies the end of a grapheme cluster.<p>
</li>
<li>
<code>@</code>[<p>
This rule sets the default left-padding-flag to 1. No glyph is consumed. No glyph is produced.<p>
</li>
<li>
<code>@</code>]<p>
This rule changes the right-padding-flag of the lastly generated glyph to 1. No glyph is consumed. No glyph is produced.<p>
</li>
<li>
<code></code>|<p>
This rule consumes no glyph and produces a special glyph whose category is ' ' and other attributes are zero. This is the only rule that produces that special glyph.<p>
</li>
</ul>
<p>
<div class="fragment"><pre class="fragment">
REGEXP-BLOCK ::= '(' REGEXP RULE * ')'
REGEXP ::= MTEXT
</pre></div><p>
<code>MTEXT</code> is a regular expression that should match the sequence of categories of the current run. If a match is found, this rule executes <code>RULEs</code> temporarily limiting the current run to the matched part. The matched part is consumed by this rule.<p>
Parenthesized subexpressions, if any, are recorded to be used in <code>MATCH-BLOCK</code> that may appear in one of <code>RULEs</code>.<p>
If no match is found, this rule fails.<p>
<div class="fragment"><pre class="fragment">
MATCH-BLOCK ::= '(' MATCH-INDEX RULE * ')'
MATCH-INDEX ::= INTEGER
</pre></div><p>
<code>MATCH-INDEX</code> is an integer specifying a parenthesized subexpression recorded by the previous <code>REGEXP-BLOCK</code>. If such a subexpression was found by the previous regular expression matching, this rule executes <code>RULEs</code> temporarily limiting the current run to the matched part of the subexpression. The matched part is consumed by this rule.<p>
If no match was found, this rule fails.<p>
If this is the first rule of the stage, <code>MATCH-INDEX</code> must be 0, and it matches the whole current run.<p>
<div class="fragment"><pre class="fragment">
SUBST-BLOCK ::= '(' SOURCE-PATTERN RULE * ')'
SOURCE-PATTERN ::= '(' CODE + ')'
| (' 'range' CODE CODE ')'
</pre></div><p>
If the sequence of codes of the current run matches <code>SOURCE-PATTERN</code>, this rule executes <code>RULEs</code> temporarily limiting the current run to the matched part. The matched part is consumed.<p>
The first form of <code>SOURCE-PATTERN</code> specifies a sequence of glyph codes to be matched. In this case, this rule resets the default code-offset to zero.<p>
The second form specifies a range of codes that should match the first glyph code of the code sequence. In this case, this rule sets the default code-offset to the first glyph code minus the first <code>CODE</code> specifying the range.<p>
If no match is found, this rule fails.<p>
<div class="fragment"><pre class="fragment">
COND-BLOCK ::= '(' 'cond' RULE + ')'
</pre></div><p>
This rule sequentially executes <code>RULEs</code> until one succeeds. If no rule succeeds, this rule fails. Otherwise, it succeeds.<p>
<div class="fragment"><pre class="fragment">
OTF-SPEC ::= SYMBOL
</pre></div><p>
<code>OTF-SPEC</code> is a symbol whose name specifies an instruction to the OTF driver. The name has the following syntax.<p>
<div class="fragment"><pre class="fragment">
OTF-SPEC-NAME ::= 'otf:' SCRIPT LANGSYS ? GSUB-FEATURES ? GPOS-FEATURES ?
SCRIPT ::= SYMBOL
LANGSYS ::= '/' SYMBOL
GSUB-FEATURES ::= '=' FEATURE-LIST ?
GPOS-FEATURES ::= '+' FEATURE-LIST ?
FEATURE-LIST ::= ( SYMBOL ',' ) * [ SYMBOL | '*' ]
</pre></div><p>
Each <code>SYMBOL</code> specifies a tag name defined in the OpenType specification.<p>
For <code>SCRIPT</code>, <code>SYMBOL</code> specifies a Script tag name (e.g. deva for Devanagari).<p>
For <code>LANGSYS</code>, <code>SYMBOL</code> specifies a Language System tag name. If <code>LANGSYS</code> is omitted, the Default Language System table is used.<p>
For <code>GSUB-FEATURES</code>, each <code>SYMBOL</code> in <code>FEATURE</code> LIST specifies a GSUB Feature tag name to apply. '*' is allowed as the last item to specify all remaining features. If <code>SYMBOL</code> is preceded by '~' and the last item is '*', <code>SYMBOL</code> is excluded from the features to apply. If no <code>SYMBOL</code> is specified, no GSUB feature is applied. If <code>GSUB-FEATURES</code> itself is omitted, all GSUB features are applied.<p>
The specification of <code>GPOS-FEATURES</code> is analogous to that of <code>GSUB-FEATURES</code>.<p>
See the following page for the OpenType specification.<br>
<<a href="http://www.microsoft.com/typography/otspec/default.htm">http://www.microsoft.com/typography/otspec/default.htm</a>><p>
<div class="fragment"><pre class="fragment">
COMBINING ::= SYMBOL
</pre></div><p>
<code>COMBINING</code> is a symbol whose name specifies how to combine the next glyph with the previous one. This rule sets the default combining-spec to an integer code that is unique to the symbol name. The name has the following syntax.<p>
<div class="fragment"><pre class="fragment">
COMBINING-NAME ::= VPOS HPOS OFFSET VPOS HPOS
VPOS ::= 't' | 'c' | 'b' | 'B'
HPOS ::= 'l' | 'c' | 'r'
OFFSET :: = '.' | XOFF | YOFF XOFF ?
XOFF ::= ('<' | '>') INTEGER ?
YOFF ::= ('+' | '-') INTEGER ?
</pre></div><p>
<code>VPOS</code> and <code>HPOS</code> specify the vertical and horizontal positions as described below.<p>
<div class="fragment"><pre class="fragment">
POINT VPOS HPOS
----- ---- ----
0----1----2 <---- top 0 t l
| | 1 t c
| | 2 t r
| | 3 B l
9 10 11 <---- center 4 B c
| | 5 B r
--3----4----5-- <-- baseline 6 b l
| | 7 b c
6----7----8 <---- bottom 8 b r
9 c l
| | | 10 c c
left center right 11 c r
</pre></div><p>
The left figure shows 12 reference points of a glyph by numbers 0 to 11. The rectangle 0-6-8-2 is the bounding box of the glyph, the positions 3, 4, and 5 are on the baseline, 9 and 11 are on the center of the lines 0-6 and 2-8 respectively, 1, 10, 4, and 7 are on the center of the lines 1-2, 3-5, 9-11, and 6-8 respectively.<p>
The right table shows how those reference points are specified by a pair of <code>VPOS</code> and <code>HPOS</code>.<p>
The first <code>VPOS</code> and <code>HPOS</code> in the definition of <code>COMBINING-NAME</code> specify the reference point of the previous glyph, and the second <code>VPOS</code> and <code>HPOS</code> specify that of the next glyph. The next glyph is drawn so that these two reference points align.<p>
<code>OFFSET</code> specifies the way of alignment in detail. If it is '.', the reference points are on the same position.<p>
<code>XOFF</code> specifies how much the X position of the reference point of the next glyph should be shifted to the right ('<') or left ('>') from the previous reference point.<p>
<code>YOFF</code> specifies how much the Y position of the reference point the next glyphshould be shifted upward ('+') or downward ('-') from the previous reference point.<p>
In both cases, <code>INTEGER</code> is the amount of shift expressed as a percentage of the font size, i.e., if <code>INTEGER</code> is 10, it means 10% (1/10) of the font size. If <code>INTEGER</code> is omitted, it is assumed that 5 is specified.<p>
Once the next glyph is combined with the previous one, they are treated as a single combined glyph.<p>
<div class="fragment"><pre class="fragment">
MACRO-NAME ::= SYMBOL
</pre></div><p>
<code>MACRO-NAME</code> is a symbol that appears in one of <code>MACRO-DEF</code>. It is exapanded to the sequence of the correponding <code>RULEs</code>.<h3><a class="anchor" name="flt-context-dependent">
CONTEXT DEPENDENT BEHAVIOR</a></h3>
So far, it has been assumed that each sequence, which is drawn with a specific font, is context free, i.e. not affected by the glyphs preceding or following that sequence. This is true when sequence S1 is drawn with font F1 while the preceding sequence S0 unconditionally requires font F0.<p>
<div class="fragment"><pre class="fragment">
sequence S0 S1
currently used font F0 F1
usable font(s) F0 F1
</pre></div><p>
Sometimes, however, a clear separation of sequences is not possible. Suppose that the preceding sequence S0 can be drawn not only with F0 but also with F1.<p>
<div class="fragment"><pre class="fragment">
sequence S0 S1
currently used font F0 F1
usable font(s) F0,F1 F1
</pre></div><p>
In this case, glyphs used to draw the preceding S0 may affect glyph generation of S1. Therefore it is necessary to access information about S0, which has already been processed, when processing S1. Generation rules in the first stage (only in the first stage) accept a special regular expression to access already processed parts.<p>
<div class="fragment"><pre class="fragment">
"RE0 RE1"
</pre></div><p>
<code>RE0</code> and <code>RE1</code> are regular expressions that match the preceding sequence S0 and the following sequence S1, respectively.<p>
Pay attention to the space between the two regular expressions. It represents the special category ' ' (see above). Note that the regular expression above belongs to glyph generation rules using font F1, therefore not only RE1 but also RE0 must be expressed with the categories for F1. This means when the preceding sequence S0 cannot be expressed with the categories for F1 (as in the first example above) generation rules having these patterns never match.<h3><a class="anchor" name="flt-seealso">
SEE ALSO</a></h3>
<a class="el" href="m17nDBFormat.html#mdbGeneral">mdbGeneral(5)</a>, <a class="el" href="m17nDBData.html#flt-list">FLTs provided by the m17n database</a><h2><a class="anchor" name="mdbFontEncoding">
Font Encoding</a></h2>
<h3><a class="anchor" name="font-encoding-description">
DESCRIPTION</a></h3>
The m17n library loads information about the encoding of each font form the m17n database by the tags <font, encoding>. The data is loaded as a plist of this format.<p>
<div class="fragment"><pre class="fragment">
FONT-ENCODING ::= PER-FONT *
PER-FONT ::= '(' FONT-SPEC ENCODING [ REPERTORY ] ')'
FONT-SPEC ::=
'(' [ FOUNDRY FAMILY
[ WEIGHT [ STYLE [ STRETCH [ ADSTYLE ]]]]]
REGISTRY ')'
ENCODING ::= SYMBOL
</pre></div><p>
<code>FONT-SPEC</code> is to specify properties of a font. <code>FOUNDRY</code> to <code>REGISTRY</code> are symbols corresponding to <a class="el" href="group__m17nFont.html#ga1">Mfoundry</a> to <a class="el" href="group__m17nFont.html#ga7">Mregistry</a> property of a font. See <a class="el" href="group__m17nFont.html">Font</a> for the meaning of each property.<p>
For instance, this <code>FONT-SPEC</code>:<p>
<div class="fragment"><pre class="fragment">
(nil alice0\ lao iso8859-1)
</pre></div><p>
should be applied to all fonts whose family name is "alice0 lao", and registry is "iso8859-1".<p>
<code>ENCODING</code> is a symbol representing a charset. A font matching <code>FONT-SPEC</code> supports all characters of the charset, and a character code is mapped to the corresponding glyph code of the font by this charset.<p>
<code>REPERTORY</code> is a symbol representing a charset or "nil". Omitting it is the same as specifying <code>ENCODING</code> as <code>REPERTORY</code>. If it is not "nil", the charset specifies the repertory of the font, i.e, which character it supports. Otherwise, whether a specific character is supported by the font or not is asked to each font driver.<p>
For so called Unicode fonts (registry is "iso10646-1"), it is recommended to specify "nil" as <code>REPERTORY</code> because such fonts usually supports only a subset of Unicode characters.<h2><a class="anchor" name="mdbFontSize">
Font Size</a></h2>
<h3><a class="anchor" name="font-size-description">
DESCRIPTION</a></h3>
In some case, a font contains incorrect information about its size (typically in the case of a hacked TrueType font), which results in a bad text layout when such a font is used in combination with the other fonts. To overcome this problem, the m17n library loads information about font-size adjustment from the m17n database by the tags <font, resize>. The data is loaded as a plist of this format.<p>
<div class="fragment"><pre class="fragment">
FONT-SIZE-ADJUSTMENT ::= PER-FONT *
PER-FONT ::= '(' FONT-SPEC ADJUST-RATIO ')'
FONT-SPEC ::=
'(' [ FOUNDRY FAMILY
[ WEIGHT [ STYLE [ STRETCH [ ADSTYLE ]]]]]
REGISTRY ')'
ADJUST-RATIO ::= INTEGER
</pre></div><p>
<code>FONT-SPEC</code> is to specify properties of a font. <code>FOUNDRY</code> to <code>REGISTRY</code> are symbols corresponding to <a class="el" href="group__m17nFont.html#ga1">Mfoundry</a> to <a class="el" href="group__m17nFont.html#ga7">Mregistry</a> property of a font. See <a class="el" href="group__m17nFont.html">Font</a> for the meaning of each property.<p>
<code>ADJUST-RATIO</code> is an integer number specifying by percentage how much the font-size must be adjusted. For instance, this <code>PER-FONT</code>:<p>
<div class="fragment"><pre class="fragment">
((devanagari-cdac) 150)
</pre></div><p>
instructs the font handler of the m17n library to open a font of 1.5 times bigger than a requested size on opening a font whose registry is "devanagari-cdac".<h2><a class="anchor" name="mdbFontset">
Fontset</a></h2>
<h3><a class="anchor" name="fontset-description">
DESCRIPTION</a></h3>
The m17n library loads a fontset definition from the m17n database by the tags <fontset, FONTSET-NAME>. The plist format of the data is as follows:<p>
<div class="fragment"><pre class="fragment">
FONTSET ::= PER-SCRIPT * PER-CHARSET * FALLBACK *
PER-SCRIPT ::= '(' SCRIPT PER-LANGUAGE + ')'
PER-LANGUAGE ::= '(' LANGUAGE FONT-SPEC-ELEMENT + ')'
PER-CHARSET ::= '(' CHARSET FONT-SPEC-ELEMENT + ')'
FALLBACK ::= FONT-SPEC-ELEMENT
FONT-SPEC-ELEMENT ::= '(' FONT-SPEC [ FLT-NAME ] ')'
FONT-SPEC ::=
'(' [ FOUNDRY FAMILY
[ WEIGHT [ STYLE [ STRETCH [ ADSTYLE ]]]]]
REGISTRY ')'
</pre></div><p>
<code>SCRIPT</code> is a symbol of script name (e.g. latin, han) or <code>nil</code>. <code>LANGUAGE</code> is a two-letter symbol of language name code defined by ISO 639 (e.g. ja, zh) or <code>nil</code>.<p>
<code>FONT-SPEC</code> is to specify properties of a font. <code>FOUNDRY</code> to <code>REGISTRY</code> are symbols corresponding to <a class="el" href="group__m17nFont.html#ga1">Mfoundry</a> to <a class="el" href="group__m17nFont.html#ga7">Mregistry</a> property of a font. See <a class="el" href="group__m17nFont.html">Font</a> for the meaning of each property.<p>
<code>FLT-NAME</code> is a name of Font Layout Table (<a class="el" href="m17nDBFormat.html#mdbFLT">Font Layout Table</a>).<h3><a class="anchor" name="fontset-example">
EXAMPLE</a></h3>
This is an example of <code>PER_SCRIPT</code>.<p>
<div class="fragment"><pre class="fragment">
(han
(ja
((jisx0208.1983-0)))
(zh
((gb2312.1980-0)))
(nil
((big5-0))))
</pre></div><p>
It instructs the font selector to use a font of registry "jisx0208.1983-0" for a "han" character (i.e. a character whose <a class="el" href="group__m17nCharacter.html#ga0">Mscript</a> property is 'han') if the character has <a class="el" href="group__m17nLocale.html#ga1">Mlanguage</a> text property "ja" in an M-text and the character is in the repertories of such fonts. Otherwise, try a font of registry "gb2312.1980-0" or "big5-0". If that "han" character does not have <a class="el" href="group__m17nLocale.html#ga1">Mlanguage</a> text property, try all three fonts.<p>
See the function <a class="el" href="group__m17nDraw.html#ga2">mdraw_text()</a> for the detail of how a font is selected.<h2><a class="anchor" name="mdbIM">
Input Method</a></h2>
<h3><a class="anchor" name="im-description">
DESCRIPTION</a></h3>
The m17n library provides a driver for input methods that are dynamically loadable from the m17n database (see <a class="el" href="group__m17nInputMethod.html">Input Method (basic)</a> ).<p>
This section describes the data format that defines those input methods.<h3><a class="anchor" name="im-format">
SYNTAX and SEMANTICS</a></h3>
The following data format defines an input method. The driver loads a definition from a file, a stream, etc. A definitions is converted into the form of plist in the driver.<p>
<div class="fragment"><pre class="fragment">
INPUT-METHOD ::= TITLE MAP-LIST MACRO-LIST ? MODULE-LIST ? STATE-LIST
TITLE ::= '(' 'title' MTEXT ')'
</pre></div><p>
<code>MTEXT</code> is a text displayed on the screen when this input method is active.<p>
<div class="fragment"><pre class="fragment">
MAP-LIST ::= '(' 'map' MAP * ')'
MAP ::= '(' MAP-NAME RULE * ')'
MAP-NAME ::= SYMBOL
RULE ::= '(' KEYSEQ MAP-ACTION * ')'
KEYSEQ ::= MTEXT | '(' [ SYMBOL | INTEGER ] * ')'
</pre></div><p>
<code>SYMBOL</code> in the definitions of <code>MAP-NAME</code> must not be <code>t</code> nor <code>nil</code>.<p>
<code>MTEXT</code> in the definition of <code>KEYSEQ</code> consists of characters that can be generated by a keyboard. Therefore <code>MTEXT</code> usually contains only ASCII characters. However, if the input method is intended to be used, for instance, with a West European keyboard, <code>MTEXT</code> may contain Latin-1 characters.<p>
<code>SYMBOL</code> in the definition of <code>KEYSEQ</code> must be the return value of the <a class="el" href="group__m17nInputMethodWin.html#ga3">minput_event_to_key()</a> function.<p>
<code>INTEGER</code> in the definition of <code>KEYSEQ</code> must be a valid character code.<p>
<div class="fragment"><pre class="fragment">
MAP-ACTION ::= ACTION
ACTION ::= INSERT | DELETE | SELECT | MOVE | MARK |
| SHOW | HIDE | PUSHBACK | UNDO | SHIFT | CALL
| SET | IF | '(' MACRO-NAME ')'
PREDEFINED-SYMBOL ::=
'@0' | '@1' | '@2' | '@3' | '@4' |
'@5' | '@6' | '@7' | '@8' | '@9' |
'@<' | '@=' | '@>' | '@-' | '@+' | '@[' | '@]'
</pre></div><div class="fragment"><pre class="fragment">
MACRO-LIST ::= '(' 'macro' MACRO * ')'
MACRO ::= '(' MACRO-NAME MACRO-ACTION * ')'
MACRO-NAME ::= SYMBOL
MACRO-ACTION ::= ACTION
</pre></div><div class="fragment"><pre class="fragment">
MODULE-LIST ::= '(' 'module' MODULE * ')'
MODULE ::= '(' MODULE-NAME FUNCTION * ')'
MODULE-NAME ::= SYMBOL
FUNCTION ::= SYMBOL
</pre></div><p>
Each <code>MODULE</code> declares the name of external module (i.e. dynamic library) and function names exported by the module. If a <code>FUNCTION</code> has name "init", it is called with only the default arguments (see the section about <code>CALL</code>) when an input context is created for the input method. If a <code>FUNCTION</code> has name "fini", it is called with only the default arguments when an input context is destroyed.<p>
<div class="fragment"><pre class="fragment">
STATE-LIST ::= '(' 'state' STATE * ')'
STATE ::= '(' STATE-NAME BRANCH * ')'
STATE-NAME ::= SYMBOL
BRANCH ::= '(' MAP-NAME BRANCH-ACTION * ')'
| '(' nil BRANCH-ACTION * ')'
| '(' t BRANCH-ACTION * ')'
</pre></div><p>
In the first form of <code>BRANCH</code>, <code>MAP-NAME</code> must be an item that appears in <code>MAP</code>. In this case, if a key sequence matching one of <code>KEYSEQs</code> of <code>MAP-NAME</code> is typed, <code>BRANCH-ACTIONs</code> are executed.<p>
In the second form of <code>BRANCH</code>, <code>BRANCH-ACTIONs</code> are executed if a key sequence that doesn't match any of <code>Branch's</code> of the current state is typed.<p>
In the third form of <code>BRANCH</code>, <code>BRANCH-ACTIONs</code> are executed if we shift to the current state after handling all typed keys. If the current state is the initial state, <code>BRANCH-ACTIONs</code> are executed just after an input context of the input method is created.<p>
<div class="fragment"><pre class="fragment">
BRANCH-ACTION ::= ACTION
</pre></div><p>
An input method has the following two lists of symbols.<p>
<ul>
<li>
marker list<p>
A marker is a symbol indicating a character position in the preediting text. The <code>MARK</code> action assigns a position to a marker. The position of a marker is referred by the <code>MOVE</code> and the <code>DELETE</code> actions.<p>
</li>
<li>
variable list<p>
A variable is a symbol associated with an integer value. The value of a variable is set by the <code>SET</code> action, and is referred by the <code>SET</code>, the <code>INSERT</code>, and the <code>IF</code> actions. All variables are implicitly initialized to zero.<p>
</li>
</ul>
<p>
Each <code>PREDEFINED-SYMBOL</code> has a special meaning when used as a marker.<p>
<ul>
<li>
<code>@0</code>, <code>@1</code>, <code>@2</code>, <code>@3</code>, <code>@4</code>, <code>@5</code>, <code>@6</code>, <code>@7</code>, <code>@8</code>, <code>@9</code> <p>
The 0th, 1st, 2nd, ... 9th position respectively.<p>
</li>
<li>
<code>@<</code>, <code>@=</code>, <code>@></code> <p>
The first, the current, and the last position.<p>
</li>
<li>
<code>@-</code>, <code>@+</code> <p>
The previous and the next position.<p>
</li>
<li>
<code>@</code>[, <code>@</code>]<p>
The previous and the next position where a candidate list changes. </li>
</ul>
<p>
Some of the <code>PREDEFINED-SYMBOL</code> has a special meaning when used as a candidate index in the <code>SELECT</code> action.<p>
<ul>
<li>
<code>@<</code>, <code>@=</code>, <code>@></code> <p>
The first, the current, and the last candidate of the current candidate group.<p>
</li>
<li>
<code>@-</code> <p>
The previous candidate. If the current candidate is the first one in the current candidate group, then it means the last candidate in the previous candidate group.<p>
</li>
<li>
<code>@+</code> <p>
The next candidate. If the current candidate is the last one in the current candidate group, then it means the first candidate in the next candidate group.<p>
</li>
<li>
<code>@</code>[, <code>@</code>]<p>
The candidate in the previous and the next candidate group having the same candidate index as the current one. </li>
</ul>
<p>
The arguments and the behavior of each action are listed below.<p>
<div class="fragment"><pre class="fragment">
INSERT ::= '(' 'insert' MTEXT ')'
| MTEXT
| INTEGER
| '(' 'insert' SYMBOL ')'
| '(' 'insert' '(' CANDIDATES * ')' ')'
| '(' CANDIDATES * ')'
CANDIDATES ::= MTEXT | '(' MTEXT * ')'
</pre></div><p>
The first and second forms insert <code>MTEXT</code> before the current position.<p>
The third form inserts the character <code>INTEGER</code> before the current position.<p>
The fourth form treats <code>SYMBOL</code> as a variable, and inserts its value (if it is a valid character code) before the current position.<p>
In the fifth and sixth forms, each <code>CANDIDATES</code> represents a candidate group, and each element of <code>CANDIDATES</code> represents a candidate, i.e. if <code>CANDIDATES</code> is an M-text, the candidates are the characters in the M-text; if <code>CANDIDATES</code> is a list of M-texts, the candidates are the M-texts in the list.<p>
These forms insert the first candidate before the current position. The inserted string is associated with the list of candidates and the information indicating the currently selected candidate.<p>
The marker positions affected by the insertion are automatically relocated.<p>
<div class="fragment"><pre class="fragment">
DELETE ::= '(' 'delete' SYMBOL ')'
| '(' 'delete' INTEGER ')'
</pre></div><p>
The first form treats <code>SYMBOL</code> as a marker, and deletes characters between the current position and the marker position.<p>
The second form treats <code>INTEGER</code> as a character position, and deletes characters between the current position and the character position.<p>
The marker positions affected by the deletion are automatically relocated.<p>
<div class="fragment"><pre class="fragment">
SELECT ::= '(' 'select' PREDEFINED-SYMBOL ')'
| '(' 'select' INTEGER ')'
</pre></div><p>
This action first checks if the character just before the current position belongs to a string that is associated with a candidate list. If it is, the action replaces that string with a candidate specified by the argument.<p>
The first form treats <code>PREDEFINED-SYMBOL</code> as a candidate index (as described above) that specifies a new candidate in the candidate list.<p>
The second form treats <code>INTEGER</code> as a candidate index that specifies a new candidate in the candidate list.<p>
<div class="fragment"><pre class="fragment">
SHOW ::= '(show)'
</pre></div><p>
This actions instructs the input method driver to display a candidate list associated with the string before the current position.<p>
<div class="fragment"><pre class="fragment">
HIDE ::= '(hide)'
</pre></div><p>
This action instructs the input method driver to hide the currently displayed candidate list.<p>
<div class="fragment"><pre class="fragment">
MOVE ::= '(' 'move' SYMBOL ')'
| '(' 'move' INTEGER ')'
</pre></div><p>
The first form treats <code>SYMBOL</code> as a marker, and makes the marker position be the new current position.<p>
The second form treats <code>INTEGER</code> as a character position, and makes that position be the new current position.<p>
<div class="fragment"><pre class="fragment">
MARK ::= '(' 'mark' SYMBOL ')'
</pre></div><p>
This action treats <code>SYMBOL</code> as a marker, and sets its position to the current position. <code>SYMBOL</code> must not be a <code>PREDEFINED-SYMBOL</code>.<p>
<div class="fragment"><pre class="fragment">
PUSHBACK :: = '(pushback INTEGER)'
</pre></div><p>
This action pushes back the latest <code>INTEGER</code> number of key events to the event queue.<p>
<div class="fragment"><pre class="fragment">
UNDO :: = '(undo)'
</pre></div><p>
This action cancels the last key event.<p>
<div class="fragment"><pre class="fragment">
SHIFT :: = '(' 'shift' STATE-NAME ')'
</pre></div><p>
This action shifts the current state to <code>STATE-NAME</code>. <code>STATE-NAME</code> must appear in <code>STATE-LIST</code>.<p>
<div class="fragment"><pre class="fragment">
CALL ::= '(' 'call' MODULE-NAME FUNCTION ARG * ')'
ARG ::= INTEGER | SYMBOL | MTEXT | PLIST
</pre></div><p>
This action calls the function <code>FUNCTION</code> of external module <code>MODULE-NAME</code>. <code>MODULE-NAME</code> and <code>FUNCTION</code> must appear in <code>MODULE-LIST</code>.<p>
The function is called with an argument of the type (<a class="el" href="group__m17nPlist.html#ga0">MPlist</a> *). The key of the first element is <a class="el" href="group__m17nSymbol.html#ga2">Mt</a> and its value is a pointer to an object of the type <a class="el" href="structMInputContext.html">MInputContext</a>. The key of the second element is <a class="el" href="group__m17nSymbol.html#ga4">Msymbol</a> and its value is the current state name. <code>ARGs</code> are used as the value of the third and later elements. Their keys are determined automatically; if an <code>ARG</code> is an integer, the corresponding key is <a class="el" href="group__m17nPlist.html#ga1">Minteger</a>; if an <code>ARG</code> is a symbol, the corresponding key is <a class="el" href="group__m17nSymbol.html#ga4">Msymbol</a>, etc.<p>
The function must return NULL or a value of the type (<a class="el" href="group__m17nPlist.html#ga0">MPlist</a> *) that represents a list of actions to take.<p>
<div class="fragment"><pre class="fragment">
SET ::= '(' OPERAND SYMBOL1 [ INTEGER | SYMBOL2 ] ')'
OPERAND ::= 'set' | 'add' | 'sub' | 'mul' | 'div'
</pre></div><p>
This action treats <code>SYMBOL1</code> and <code>SYMBOL2</code> as variables and sets the value of <code>SYMBOL1</code> as below.<p>
If <code>OPERAND</code> is 'set', it sets the value of <code>SYMBOL1</code> to <code>INTEGER</code> or the value of <code>SYMBOL2</code>.<p>
If <code>OPERAND</code> is 'add', it increments the value of <code>SYMBOL1</code> by <code>INTEGER</code> or the value of <code>SYMBOL2</code>.<p>
If <code>OPERAND</code> is 'sub', it decrements the value of <code>SYMBOL1</code> by <code>INTEGER</code> or the value of <code>SYMBOL2</code>.<p>
If <code>OPERAND</code> is 'mul', it multiplies the value of <code>SYMBOL1</code> by <code>INTEGER</code> or the value of <code>SYMBOL2</code>.<p>
If <code>OPERAND</code> is 'div', it divides the value of <code>SYMBOL1</code> by <code>INTEGER</code> or the value of <code>SYMBOL2</code>.<p>
<div class="fragment"><pre class="fragment">
IF ::= '(' CONDITION ACTION-LIST1 ACTION-LIST2 * ')'
CONDITION ::= OPERAND VAL1 VAL2
ACTION-LIST1 ::= '(' ACTION * ')'
ACTION-LIST2 ::= '(' ACTION * ')'
OPERAND ::= '=' '<' '>'
VAL1 ::= [ INTEGER1 | SYMBOL1 ]
VAL2 ::= [ INTEGER2 | SYMBOL2 ]
</pre></div><p>
This action performs actions in <code>ACTION-LIST1</code> if <code>CONDITION</code> is true, and performs <code>ACTION-LIST2</code> (if any) otherwise.<p>
<code>SYMBOL1</code> and <code>SYMBOL2</code> are treated as variables.<h3><a class="anchor" name="im-example1">
EXAMPLE 1</a></h3>
This is a very simple example for inputting Latin characters with diacritical marks (acute and cedilla). For instance, when you type: <div class="fragment"><pre class="fragment">
Comme'die-Franc,ais, chic,,
</pre></div>you will get this:<p>
<div class="fragment"><pre class="fragment">
Commédie-Français, chic,
</pre></div><p>
The definition of the input method is very simple as below, and it is quite straight forward to extend it to cover all Latin characters.<p>
<div class="fragment"><pre class="fragment">
(title "latin-postfix")
(map
(trans
("a'" ?á) ("e'" ?é) ("i'" ?í) ("o'" ?ó) ("u'" ?ú) ("c," ?ç)
("A'" ?Á) ("E'" ?É) ("I'" ?Í) ("O'" ?Ó) ("U'" ?Ú) ("C," ?Ç)
("a''" "a'") ("e''" "e'") ("i''" "i'") ("o''" "o'") ("u''" "u'")
("c,," "c,")
("A''" "A'") ("E''" "E'") ("I''" "I'") ("O''" "O'") ("U''" "U'")
("C,," "C,")))
(state
(init
(trans)))
</pre></div><h3><a class="anchor" name="im-example2">
EXAMPLE 2</a></h3>
This example is for inputting Unicode characters by typing C-u (Control-u) followed by four hexadecimal numbers. For instance, when you type ("^u" means Control-u): <div class="fragment"><pre class="fragment">
^u2190^u2191^u2192^u2193
</pre></div>you will get this (Unicode arrow symbols): <div class="fragment"><pre class="fragment">
←↑→↓
</pre></div><p>
The definition utilizes <code>SET</code> and <code>IF</code> commands as below: <div class="fragment"><pre class="fragment">
(title "UNICODE")
(map
(starter
((C-U) "U+"))
(hex
("0" ?0) ("1" ?1) ... ("9" ?9) ("a" ?A) ("b" ?B) ... ("f" ?F)))
(state
(init
(starter (set code 0) (set count 0) (shift unicode)))
(unicode
(hex (set this @-)
(< this ?A
((sub this 48))
((sub this 55)))
(mul code 16) (add code this)
(add count 1)
(= count 4
((delete @<) (insert code) (shift init))))))
</pre></div><h3><a class="anchor" name="im-example3">
EXAMPLE 3</a></h3>
This example is for inputting Chinese characters by typing PinYin key sequence.<p>
For instance, when you type: <div class="fragment"><pre class="fragment">
nihaobei2jing2
</pre></div>you will get: <div class="fragment"><pre class="fragment">
你好北京
</pre></div><p>
The definition utilizes <code>CANDIDATE</code> and <code>SELECT</code> commands as below. Note that this is just an example, and it ignores such important key as Backspace.<p>
<div class="fragment"><pre class="fragment">
(title "拼")
(map
;; The initial character of Pinyin.
(starter
("a") ("b") ... ("h") ("j") ... ("t") ("w") ("x") ("y") ("z"))
;; Big table of Pinyin vs the corresponding Chinese characters.
(pinyin
...
("bei" ("被北备背悲辈杯倍贝碑" ...))
("hao" ("好号毫豪浩耗皓嚎昊郝" ...))
("jing" ("经京精境警竟静惊景敬" ...))
("ni" ("你呢尼泥逆倪匿拟腻妮" ...))
...)
;; Typing 1, 2, ..., 0 selects the 0th, 1st, ..., 9th candidate.
(choose
("1" (select 0)) ("2" (select 1)) ... ("9" (select 8)) ("0" (select 9))))
(state
(init
;; When an initial character of Pinyin is typed, re-handle it in
;; "main" state. Anything else is just produced as is.
(starter (show) (pushback 1) (shift main)))
(main
;; When a complete Pinyin sequence is typed, shift to "select" state
;; to allow users to select one from the candidates.
(pinyin (shift select))
;; When anything else is typed, produce the current candidate (if
;; any), and re-handle the last input in "init" state.
(nil (hide) (shift init)))
(select
;; When a number is typed, select the corresponding canidate,
;; produce it, and shift to "init" state.
(choose (hide) (shift init))
;; When anything else is typed, produce the current candidate,
;; and re-handle the last input in "init" state.
(nil (hide) (shift init))))
</pre></div><h3><a class="anchor" name="im-seealso">
SEE ALSO</a></h3>
<a class="el" href="m17nDBData.html#mim-list">Input Methods provided by the m17n database</a>, <a class="el" href="m17nDBFormat.html#mdbGeneral">mdbGeneral(5)</a> <hr>
<center>
<a href="#top-of-page">Top of this page</a><br><br>
<a class="qindex" href="index.html">Main Page</a>
<a class="qindex" href="modules.html">Modules</a>
<!-- <a class="qindex" href="classes.html">Alphabetical List</a> -->
<a class="qindex" href="annotated.html">Data Structures</a>
<!-- <a class="qindex" href="files.html">File List</a> -->
<!-- <a class="qindex" href="functions.html">Data Fields</a> -->
<a class="qindex" href="globals.html">Globals</a>
<a class="qindex" href="pages.html">Appendix</a>
</center>
<hr>
<ADDRESS>
<a href="http://www.m17n.org/m17n-lib/index.html" target="mulewindow"><img src="parrot.png" align=bottom alt="mulemark" border=0></a>
<A HREF="mailto:mule-aist@m17n.org">mule-aist@m17n.org</a>
</ADDRESS>
</body>
</HTML>
<!-- Copyright information
Copyright (C) 2001 Information-technology Promotion Agency (IPA)
Copyright (C) 2001-2004
National Institute of Advanced Industrial Science and Technology (AIST)
This file is part of the m17n library documentation.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.2 or
any later version published by the Free Software Foundation; with no
Invariant Section, Front-Cover Texts "The m17n library documentation",
and no Back-Cover Texts. A copy of the license is included in the
appendix entitled "GNU Free Documentation License".
-->
|