U:V U U:' U U: @ E^ Pinyin Is a Phonetic System for Transcribing the Pro- a A- a A' a Av a A' Nunciation (In Mandarin) of Chinese Characters
Total Page:16
File Type:pdf, Size:1020Kb
TUGboat, Volume 14 (1993)) No. 1 - a a- a a' 5 av a a' Philology - e e- e e' 5 ev i e' T i- i i' T iv i i' - Typesetting Chinese pinyin Using o 0- 6 0' 6 ov o o' - U u- u u' ij uv h u' Virtual Fonts - " Wai Wong U u:- u u:' U u:v u u:' u U: @ e^ Pinyin is a phonetic system for transcribing the pro- A A- A A' A Av A A' nunciation (in Mandarin) of Chinese characters. It E E- E E' i EV E E' - " is in widespread use in China 111. Pinyin is taught to I I- i I' I IV I I' millions of children in schools there. It is also used 0 0- 6 0) d ov o 0' to teach foreigners and speakers of other Chinese u u- u U' 0 uv u U' dialects to learn Mandarin. This paper describes a - package for typesetting pinyin in LAW 121. It uses u u:- u U:' 6 U:v " u: ' the features of virtual fonts and ligatures to provide u U: i E- an easy way of generating fonts for pinyin and a simple input method. This package requires a . dvi Table l: Input formats of pinyin characters driver which is capable of handling virtual fonts. a paragraph of properly tone-marked pznyzn using 1 What is pinyin those macros yourself.) The pznyzn package provides a new style op- Pinyin uses the Latin alphabet to transcribe the tion pinyin to simplify the input and typesetting of sound of Chinese characters. All Chinese charac- pznyzn. This option provides an environment, a sim- ters are single syllables. Each syllable can be divided ple input method and several fonts specially built for into two parts: the initial and the final. The initials pznyzn. To use it, put the word pinyin in the op- are consonants (or sheng mij in Chinese). Some of tional argument of the \documentst yle command. the finals (or yhn mij in Chinese) are pure vowels, the Then, within your document, the pinyin environ- others are combinations of vowels and consonants. ment can be used anywhere. Each syllable can be pronounced in one of four pos- Within the pinyin environment, tone marks sible tones (shsng diao). When writing down pinyin, are input by typing the appropriate character after the tone of the characters is indicated by placing a the main vowel. The characters to mark the tones tone mark on top of the main vowel in the finals. are: - ' v '. For example, ma- ma' mav ma' will For example the vowel a can have the following four produce ma ma m5 ma. Another example shown be- tones 5 a 5 a. low is a poem by the famous poet IT b6i in the Tang There are two styles of writing pinyin: the first dynasty. The input is to separate syllables by spaces, i.e., the pinyin for each character is separated, the second puts the \begin(quote)% pinyin of multi-character words together, like pinyin. \begin(pinyin)% When writing in the second form, syllables begin- chua'ng qia'n mi'ng yue' pa-ng\\ ning with a, e or o may follow a vowel-ending sylla- yi' shi' di' sha'ng shua-ng\\ ble. This will cause confusion. If such case arises, an juv to'u wa'ng mi'ng yueC\\ apostrophe mark (') is used to separate them. For di- to'u si- gu- xia-ng \end(pinyin)% example pya6 (meaning leather jacket). \end(quote) produces 2 How to typeset pinyin Since pinyin uses the Latin alphabet, it would not chu6ng qian ming yui guang be too difficult to typeset it in LATEX, except one has yi shi di shang shuzng to place the tone marks properly. The normal jii t6u wang ming yui accent mark macros may be used for this purpose, di tou si gii xiang but they are not very convenient since you need to put a tone mark on each syllable. (Try typing in The input formats of all possible combinations of the tone marks and vowels are listed in Table 1. TUGboat, Volume 14 (1993), No. I I I I I I I I 'I I '272 u ij 6 1 "Bx "8"9 / "A / "B / "C 1 "D 1 "E 1 "F I Table 2: pinyin character positions The pinyin environment can take an optional pyssio from cmssi0. Ligature tables were defined argument which specifies the font to use. The cur- for each of the vowels to map the combinations of rently available fonts are sf and rm. Conventionally, the vowel and tone mark character to new charac- pinyin is printed in a Sans Serif font, so sf is the ter positions. All new characters and their codes are default as you can see in the examples above. If you listed in Table 2l. The compound characters are de- say fined in terms of the base vowel characters and the \begin{pinyin)[rml ... \end{pinyin) appropriate accent characters. These mappings and character definitions were done in the property list the pinyin text will be typeset in a Roman font. files. For example, the pysslO font is created by the Very often, a small piece of pinyin is embedded following procedures: in running text. A shorthand command \py can be used instead of the pinyin environment. For exam- 1. convert cmssi0.tfm to cmssl0.pl using ple, \py{pi-n yi-n) produces pin yin. Like the en- tftopl; vironment, \py can also take an optional argument 2. copy cmssio . pl into a file named pyssl0.vpl; to specify the font. 3. edit pyssl0.vpl to add the ligature tables and There is a command to specify the size of the new character definitions: pinyin characters: \pysize. It takes a single ar- 4. generate pyssl0.tfm and pyssl0.vf using gument which is the required size. It can be any vptovf . reasonable size for text, such as IOpt, llpt and so The ligature tables for all pznyin fonts should on. The default is IOpt. be identical. Appendix A lists the complete ligature table. When editing the .vpl file, care must be 3 The implementation of the pinyin taken to merge this into the existing table in the package file. The new character definitions have a general The pinyin environment is implemented using vir- form that looks like the example below: tual fonts and ligatures. Two families of virtual (CHARACTER 0 241 fonts. namely pyrn and pyssn, were created for (COMMENT a1 a-1 typesetting pinyin. These pinyin fonts are needed (MAP (PUSH) (SETCHAR C a) (POP) because: (SETCHAR 0 26)) accented characters, e.g., 3, i, which are not (CHARWD R 0.480557) included in ordinary fonts and not even in (CHARHT R 0.608887) the extended (DCIEC) fonts, are required 1 in pinyin; The positions of the lowercase pinyin charac- a special ligature table is required to support ters are arranged in a way that their codes are equal the input method in the pinyin environment. to the least significant byte of GB codes (the Chi- These pinyin fonts are based on the Computer Mod- nese national standard). For example, 3 at position ern fonts, i.e., pyr10 is modified from cmrlO and "A1 has GB code A8A1 in hexadecimal. TUGboat, Volume 14 (1993), No. 1 for single accent in (-, ', ", ' , ", ^) if the base character basechar is in (a, e. o, u) wd is the width of basechar ht is the height of accent no movement is need for setting the character the program is: (PUSH) (SETCHAR basechar ) (POP) (SETCHAR accent) if the base character basechar is i . basechar becomes 1 (the dotless i) wd is the width of basechar ht is the height of accent the program is: (PUSH) (MOVELEFT (wdaCcent- ~dbasechar)/2) (SETCHAR accent ) (POP) (SETCHAR dotless i) for double accent wd is the width of the base character (u) ht + htddot + htaccent - htu the program is: (PUSH) (SETCHAR C u) (POP) (PUSH) (SETCHAR 0 177) (POP) (MOVEUP htddot- htu) (SETCHAR accent) Figure 1: Algorithm for pinyin character definitions. This is the definition for character 2 whose char- mechanize the generation of new font files by a pro- acter code is ,241. The MAP property specifies how gram. To achieve the perfect result, manual editing, this character is generated. It first saves the cur- i.e., moving the accents or base character around, is rent position, typesets the character a in the current necessary. base font and recovers the current position. It then overprints the accent character - whose code is '26. This is the simplest case since the accents in CM 4 A sample installation fonts were designed so that they do not need to be This package has been developed and tested in UNIX raised or lowered for most lower _case letters. For systems. It will not be difficult to port it to other more complicated characters like ii, the second ac- systems; in fact, the style file and the font files can cent mark (the one on top) has to be moved up. The be moved to other systems without any change pro- amount can be calculated using the heights of the vided that the new environment has m and . dvi base character and the accents given in the original driver supporting virtual fonts. The remainder of .pl file. The CHARWD and CHARHT properties specify this section describes an installation procedure in the width and height of the new character. They are UNIX systems as an example. calculated from the widths and heights of the base This package is distributed as a uuencoded and accent characters.