| 1 |
\documentclass[12pt]{article} |
| 2 |
|
| 3 |
% Ruby markup renewal |
| 4 |
\usepackage[overlap, CJK]{ruby} |
| 5 |
\renewcommand{\rubysep}{-0.3ex} |
| 6 |
\renewcommand{\rubysize}{0.6} |
| 7 |
|
| 8 |
% automatically wraps characters from specific unicode blocks with the relevant font tag |
| 9 |
\usepackage{fontwrap} |
| 10 |
|
| 11 |
% in this example, fontwrap is only allowed to process content for 'ruby' tags. |
| 12 |
\setfontwrapallowedmacros{ruby} |
| 13 |
|
| 14 |
% The main font is a somewhat bland font. |
| 15 |
\setmainfont{Times New Roman} |
| 16 |
|
| 17 |
% always good to have, in case a sentence is unmanageable and needs to be rewritten. |
| 18 |
\overfullrule=5pt |
| 19 |
|
| 20 |
% document start |
| 21 |
\begin{document} |
| 22 |
|
| 23 |
|
| 24 |
% --------------------------------------------------------- |
| 25 |
% |
| 26 |
% In the first part of what is effectively a unit test, |
| 27 |
% we set the font handling for characters from the Latin |
| 28 |
% unicode blocks to the 'Palatino Linotype' font. For |
| 29 |
% characters from the CJK unicode blocks, we use the |
| 30 |
% 'kiloji' font, which is a playful font for Japanese. |
| 31 |
% |
| 32 |
% --------------------------------------------------------- |
| 33 |
|
| 34 |
\section{Before we start:} |
| 35 |
|
| 36 |
\setunicodegroupfont{Latin}{Palatino Linotype} |
| 37 |
\setunicodegroupfont{CJK}{kiloji} |
| 38 |
|
| 39 |
Before the test text is generated, \textbackslash unicodegroupLatinFont is set to '\unicodegroupLatinFont', |
| 40 |
and \textbackslash unicodegroupCJKFont is set to '\unicodegroupCJKFont'. |
| 41 |
|
| 42 |
|
| 43 |
% --------------------------------------------------------- |
| 44 |
% |
| 45 |
% In our unit test, the first section must look identical |
| 46 |
% to the second section. |
| 47 |
% |
| 48 |
% --------------------------------------------------------- |
| 49 |
|
| 50 |
\section{This:} |
| 51 |
|
| 52 |
\fontwrap{ |
| 53 |
test 1: \emph{- 仕 -}, test2: \ruby{ruby base text}{- 仕 -}\ どうぞ. |
| 54 |
} |
| 55 |
|
| 56 |
\section{Should look like this:} |
| 57 |
|
| 58 |
\fontspec{\unicodegroupLatinFont}test 1: \emph{- 仕 -}, test2: \ruby{ruby |
| 59 |
base text}{- \fontspec{\unicodegroupCJKFont}仕\fontspec{\unicodegroupLatinFont} |
| 60 |
-}\ \fontspec{\unicodegroupCJKFont}どうぞ\fontspec{\unicodegroupLatinFont}. |
| 61 |
|
| 62 |
|
| 63 |
% --------------------------------------------------------- |
| 64 |
% |
| 65 |
% In the second part of our test, we issue font changes. |
| 66 |
% We set the font handling for characters from the Latin |
| 67 |
% unicode blocks to the 'Arial' font, which is distinctly |
| 68 |
% different from the Palatino Linotype font, and we set |
| 69 |
% the CJK font to 'Ume Mincho', a "clinical" Japanese font. |
| 70 |
% |
| 71 |
% --------------------------------------------------------- |
| 72 |
|
| 73 |
\section{Before we continue:} |
| 74 |
|
| 75 |
\setunicodegroupfont{Latin}{Arial} |
| 76 |
\setunicodegroupfont{CJK}{Ume Mincho} |
| 77 |
|
| 78 |
Then, before we continue our test, \textbackslash unicodegroupLatinFont is set to '\unicodegroupLatinFont', |
| 79 |
and \textbackslash unicodegroupCJKFont is set to '\unicodegroupCJKFont'. |
| 80 |
|
| 81 |
|
| 82 |
% --------------------------------------------------------- |
| 83 |
% |
| 84 |
% Again, the first section must look identical to the |
| 85 |
% second section. |
| 86 |
% |
| 87 |
% --------------------------------------------------------- |
| 88 |
|
| 89 |
\section{And more elaborately, this:} |
| 90 |
|
| 91 |
\fontwrap{ |
| 92 |
This is a paragraph on the Japanese language, written \ruby{日本語}{nihongo}. The pronunciation above |
| 93 |
the Japanese is a romanisation of the Japanese syllabic word にほんご, which is a combination of 'ni', |
| 94 |
'ho', 'n' and 'go'. The last syllable is a voicing of the syllable こ, 'ko', denoted with two tickmarks |
| 95 |
in the upper right. |
| 96 |
|
| 97 |
Adding a pronunciation key to written Japanese is a common practice. A simple example of this would |
| 98 |
be the aforementioned \ruby{日本語}{にほんご}, this time with Japanese in the pronunciation key. |
| 99 |
The type of writing that is used to mark pronunciation is called \ruby{振り仮名}{ふりがな}\ in Japanese, |
| 100 |
which translates to something like 'sprinkled (syllabic) writing'. |
| 101 |
} |
| 102 |
|
| 103 |
\section{Should look like:} |
| 104 |
|
| 105 |
\fontspec{\unicodegroupLatinFont}This is a paragraph on the Japanese language, written \ruby{\fontspec{\unicodegroupCJKFont}日本語\fontspec{\unicodegroupLatinFont}}{nihongo}. The pronunciation above |
| 106 |
the Japanese is a romanisation of the Japanese syllabic word \fontspec{\unicodegroupCJKFont}にほんご\fontspec{\unicodegroupLatinFont}, which is a combination of 'ni', |
| 107 |
'ho', 'n' and 'go'. The last syllable is a voicing of the syllable \fontspec{\unicodegroupCJKFont}こ\fontspec{\unicodegroupLatinFont}, 'ko', denoted with two tickmarks |
| 108 |
in the upper right. |
| 109 |
|
| 110 |
Adding a pronunciation key to written Japanese is a common practice. A simple example of this would |
| 111 |
be the aforementioned \ruby{\fontspec{\unicodegroupCJKFont}日本語\fontspec{\unicodegroupLatinFont}}{\fontspec{\unicodegroupCJKFont}にほんご\fontspec{\unicodegroupLatinFont}}, this time with Japanese in the pronunciation key. |
| 112 |
The type of writing that is used to mark pronunciation is called \ruby{\fontspec{\unicodegroupCJKFont}振り仮名\fontspec{\unicodegroupLatinFont}}{\fontspec{\unicodegroupCJKFont}ふりがな\fontspec{\unicodegroupLatinFont}}\ in Japanese, |
| 113 |
which translates to something like 'sprinkled (syllabic) writing'. |
| 114 |
|
| 115 |
% --------------------------------------------------------- |
| 116 |
% |
| 117 |
% In the third part of our test, we check whether fontwrap |
| 118 |
% respects our environment declarations. Because we'll use |
| 119 |
% a verbatim group, we make sure to call verbatimfontwrap |
| 120 |
% as well, to preserve the whitespace precisely. |
| 121 |
% |
| 122 |
% --------------------------------------------------------- |
| 123 |
|
| 124 |
\section{Again, before we continue:} |
| 125 |
|
| 126 |
\setunicodegroupfont{Latin}{Arial} |
| 127 |
\setunicodegroupfont{CJK}{kiloji} |
| 128 |
|
| 129 |
For the final test, \textbackslash unicodegroupLatinFont is set to \unicodegroupLatinFont\ |
| 130 |
and \textbackslash unicodegroupCJKFont is kept at '\unicodegroupLatinFont', for contrast. |
| 131 |
The verbatim block will not support Japanese, so we'll see gaps in it. |
| 132 |
|
| 133 |
\section{This:} |
| 134 |
|
| 135 |
\begin{verbatimfontwrap} |
| 136 |
\fontwrap{ |
| 137 |
This is some text with English and 日本語 in it (\ruby{正解}{せいかい}), with a |
| 138 |
\begin{verbatim} |
| 139 |
Verbatim Block Inside It. |
| 140 |
Also With English And 日本語 Text. |
| 141 |
(Don't mind the capitals. The point was there |
| 142 |
should not be any fontspec tags) |
| 143 |
\end{verbatim} |
| 144 |
After which some more 日本語 and English. |
| 145 |
} |
| 146 |
\end{verbatimfontwrap} |
| 147 |
|
| 148 |
\section{Should look like this:} |
| 149 |
|
| 150 |
\fontspec{\unicodegroupLatinFont}This is some text with English and |
| 151 |
\fontspec{\unicodegroupCJKFont}日本語\fontspec{\unicodegroupLatinFont}\ in it (\ruby{\fontspec{\unicodegroupCJKFont}正解\fontspec{\unicodegroupLatinFont}}{\fontspec{\unicodegroupCJKFont}せいかい\fontspec{\unicodegroupLatinFont}}), with a |
| 152 |
\begin{verbatim} |
| 153 |
Verbatim Block Inside It. |
| 154 |
Also With English And 日本語 Text. |
| 155 |
(Don't mind the capitals. The point was there |
| 156 |
should not be any fontspec tags) |
| 157 |
\end{verbatim} |
| 158 |
After which some more \fontspec{\unicodegroupCJKFont}日本語\fontspec{\unicodegroupLatinFont}\ and English. |
| 159 |
|
| 160 |
|
| 161 |
% --------------------------------------------------------- |
| 162 |
% |
| 163 |
% And that concludes the unit test. |
| 164 |
% |
| 165 |
% --------------------------------------------------------- |
| 166 |
|
| 167 |
\end{document} |