Difference between revisions of "Chinese Japanese and Korean"

From Wiki
Jump to navigation Jump to search
(fix Typo)
m (Explanation of the paperSize variable used in lua)
 
(25 intermediate revisions by 11 users not shown)
Line 1: Line 1:
< [[Fonts]] | [[Encodings and Regimes]] >
+
=Setup for Japanese=
  
* old introduction [[Uptodate]] by Pragma: [http://www.pragma-ade.com/general/uptodate/up-007-s.pdf screen] and [http://www.pragma-ade.com/general/uptodate/up-007-p.pdf paper] version
+
<texcode>
* manual by Pragma: [http://www.pragma-ade.com/general/manuals/mchinese.pdf Chinese in ConTeXt]
+
% 2024-02 Otared Kavian, Jeong Dal et al.
 +
\mainlanguage[ja]
  
=Chinese in ConTeXt (ConTeXt 2005.12.19 and newer)=
+
\definefontfamily[JapaneseFont][rm][Noto Serif JP]
 +
  [  it={style:regular,features:{*,slanted}},
 +
      sl={style:regular,features:{*,slanted}},
 +
      bi={style:bold,features:{*,slanted}},force=yes]
  
If you have [[Context 2005.12.19]], you only have to get the fonts.
+
\definefontfamily[JapaneseFont][ss][Noto Serif JP]
 +
  [  it={style:regular,features:{*,slanted}},
 +
      sl={style:regular,features:{*,slanted}},
 +
      bi={style:bold,features:{*,slanted}},force=yes]
 +
 
 +
\definefontfamily[JapaneseFont][tt][Noto Serif JP]
 +
  [  it={style:regular,features:{*,slanted}},
 +
      sl={style:regular,features:{*,slanted}},
 +
      bi={style:bold,features:{*,slanted}},force=yes]
 +
 
 +
\definefontfamily[JapaneseFont][math][Tex Gyre Termes Math]
 +
%\definefontfamily[JapaneseFont][math][Tex Gyre Pagella Math]
 +
%\definefontfamily[JapaneseFont][math][Tex Gyre Aventor]
 +
 
 +
%%%%
 +
 
 +
\setupbodyfont[JapaneseFont,12pt]
 +
\setupruby[location=top,voffset=-2ex]
 +
\setupwhitespace[big]
 +
\setscript[nihongo]
 +
 
 +
\starttext
 +
\ruby{早}{はや}く。
 +
いきましょう。
 +
\stoptext
 +
</texcode>
 +
 
 +
==Meeting the JIS X 4051 Requirements for Japanese Text Layout==
 +
The actual standard was revised in 2004 and the latest version is JIS X 4051:2004. You can read it in Japanese here: https://kikakurui.com/x4/X4051-2004-02.html
 +
 
 +
The W3C technical note "Requirements for Japanese Text Layout", published on 4 June 2009, is based on JIS X 4051. This is also available in English: https://www.w3.org/TR/jlreq/
 +
 
 +
Following code is a work in progress. Its text layout output meets already some of the requirements (see comments in the code). Among the ones to still be implemented are:
 +
* solid setting (no extra spacing between characters) https://www.w3.org/TR/jlreq/#fig1_8 if no requirement for line-adjustment https://www.w3.org/TR/jlreq/#term.line-adjustment
 +
* aligning of the lines to the Kihon-hanmen (optimizing the code below in this regard)
 +
* positioning and realm of headings https://www.w3.org/TR/jlreq/#fig3_1_9 https://www.w3.org/TR/jlreq/#fig3_1_15 et al, and https://www.w3.org/TR/jlreq/#fig3_1_4
 +
* positioning of yokugo-ruby https://www.w3.org/TR/jlreq/#fig2_3_24
 +
* inline cutting note (warichu) https://www.w3.org/TR/jlreq/#fig2_4_1
 +
* emphasis with sesame dot or bullet
 +
* itemization https://www.w3.org/TR/jlreq/#fig2_5_6
 +
* indenting of quotation paragraphs https://www.w3.org/TR/jlreq/#fig2_5_7
 +
* tab setting https://www.w3.org/TR/jlreq/#fig2_6_1
 +
* furiwake https://www.w3.org/TR/jlreq/#fig2_7_2
 +
* jidori https://www.w3.org/TR/jlreq/#fig2_7_4
 +
* math https://www.w3.org/TR/jlreq/#fig2_7_6 and https://www.w3.org/TR/jlreq/#fig2_7_62
 +
* tategaki (writing vertically)
 +
 
 +
When you read the lua code in the first <code>\directlua{}</code>, you should realize that the dimensions of almost all layout elements are depending on the value of my lua variable "paperSize".
 +
Thanks to defining the paper size first in lua, I can apply calculations of numeric values.  
 +
 
 +
The value of paperSize is later passed on to <code>\setuppapersize</code> via <code>\setuppapersize[\directlua{tex.print(paperSize)}]</code>
  
# You need some Chinese (TrueType) fonts; you may want to get [ftp://ftp.ctex.org/pub/tex/fonts/truetype/ttf/htfs.ttf FangSong], [ftp://ftp.ctex.org/pub/tex/fonts/truetype/ttf/hthei.ttf HeiTi], [ftp://ftp.ctex.org/pub/tex/fonts/truetype/ttf/htkai.ttf KaiTi] and [ftp://ftp.ctex.org/pub/tex/fonts/truetype/ttf/htsong.ttf SongTi]. Put those e.g. into $TEXMF/fonts/truetype/chinese/.
 
# Use Hans Hagen's experimental [http://www.physik.fu-berlin.de/~tburnus/ttf2uni.rb ttf2uni.rb] script to create .map, .tmf and .enc files. You can then put the files e.g. to $TEXMF/fonts/tfm/chinese/ (*.tmf files), $TEXMF/fonts/enc/chinese/ (*.enc files, they are basically the same for all fonts) and to $TEXMF/fonts/map/chinese/.
 
# You may now need to update the hash TeX uses to find the files; using teTeX this is done by running <tt>texhash</tt>.
 
# How you can run your Hello World program:
 
 
<texcode>
 
<texcode>
\enableregime[utf]
+
%Visual Debugging, to be commented out later:
\usemodule[chi-00]
+
%\showframe %shows the layout elements
 +
%\showgrid %shows the line numbering
 +
%\showmakeup[penalty] %shows characters for which specific breaking line rules apply
 +
%\showmakeup[glyph] %shows the box of each character
 +
 
 +
%Define the elements of Kihon-hanmen.
 +
%Line length should be multiples of the character size.
 +
%Following dimensions are taken from JIS X 4051, annex 3, cases Y-1 to Y-4. Just change value (A4, A5, B5, B6) for paperSize to switch between the cases.
 +
\directlua{
 +
unit = "pt"
 +
 
 +
paperSize = "B5"
 +
 
 +
characterSizeNumeric = 9
 +
if paperSize == "A4" or paperSize == "A5" or paperSize == "B5" then
 +
  characterSizeNumeric = 9
 +
elseif paperSize == "B6" then
 +
  characterSizeNumeric = 8
 +
end
 +
characterSize = tostring(characterSizeNumeric) .. unit
 +
 
 +
characterCountPerColumn = 25
 +
if paperSize == "A4" then
 +
  characterCountPerColumn = 25
 +
elseif paperSize == "B5" then
 +
  characterCountPerColumn = 22
 +
elseif paperSize == "A5" or paperSize == "B6" then
 +
  characterCountPerColumn = 34
 +
end
 +
 
 +
columnCount = 2
 +
if paperSize == "A4" or paperSize == "B5" then
 +
  columnCount = 2
 +
elseif paperSize == "A5" or paperSize == "B6" then
 +
  columnCount = 1
 +
end
 +
 
 +
lineCount = 46
 +
if paperSize == "A4" then
 +
  lineCount = 46
 +
elseif paperSize == "B5" then
 +
  lineCount = 40
 +
elseif paperSize == "A5" then
 +
  lineCount = 29
 +
elseif paperSize == "B6" then
 +
  lineCount = 27
 +
end
 +
 
 +
lineSpacingNumeric = 6
 +
if paperSize == "A4" or paperSize == "B5" then
 +
  lineSpacingNumeric = 6
 +
elseif paperSize == "A5" or paperSize == "B5" then
 +
  lineSpacingNumeric = 7
 +
end
 +
 
 +
columnGapNumeric = 18
 +
columnGap = tostring(columnGapNumeric) .. unit
 +
 
 +
headerFooterHeightNumeric = characterSizeNumeric
 +
headerFooterHeight = tostring(headerFooterHeightNumeric) .. unit
 +
 
 +
headerFooterDistanceNumeric = characterSizeNumeric
 +
headerFooterDistance = tostring(headerFooterDistanceNumeric) .. unit
 +
 
 +
lineFeedNumeric = characterSizeNumeric + lineSpacingNumeric
 +
lineFeed = tostring(lineFeedNumeric) .. unit
 +
 
 +
lineWidthNumeric = characterSizeNumeric * characterCountPerColumn
 +
 
 +
kihonHanmenWidthNumeric = columnCount * lineWidthNumeric + (columnCount - 1) * columnGapNumeric
 +
kihonHanmenWidth = tostring(kihonHanmenWidthNumeric) .. unit
 +
 
 +
backSpaceNumeric = (597.5079 - kihonHanmenWidthNumeric) / 2
 +
if paperSize == "A4" then
 +
  backSpaceNumeric = (597.5079 - kihonHanmenWidthNumeric) / 2
 +
elseif paperSize == "B5" then
 +
  backSpaceNumeric = (500.7685 - kihonHanmenWidthNumeric) / 2
 +
elseif paperSize == "A5" then
 +
  backSpaceNumeric = (421.1008 - kihonHanmenWidthNumeric) / 2
 +
elseif paperSize == "B6" then
 +
  backSpaceNumeric = (355.6594 - kihonHanmenWidthNumeric) / 2
 +
end
 +
backSpace = tostring(backSpaceNumeric) .. unit
 +
 
 +
kihonHanmenHeightNumeric = lineCount * characterSizeNumeric + (lineCount - 1) * lineSpacingNumeric
 +
kihonHanmenHeight = tostring(kihonHanmenHeightNumeric) .. unit
 +
 
 +
makeUpHeightNumeric = kihonHanmenHeightNumeric + 2 * headerFooterHeightNumeric + 2 * headerFooterDistanceNumeric
 +
makeUpHeight = tostring(makeUpHeightNumeric) .. unit
 +
 
 +
topMarginNumericMm = 29
 +
topMarginNumeric = 2.8346 * topMarginNumericMm
 +
topSpaceNumeric = topMarginNumeric - headerFooterHeightNumeric - headerFooterDistanceNumeric
 +
if paperSize == "A4" then
 +
  topMarginNumericMm = 29
 +
  topMarginNumeric = 2.8346 * topMarginNumericMm
 +
  topSpaceNumeric = topMarginNumeric - headerFooterHeightNumeric - headerFooterDistanceNumeric
 +
elseif paperSize == "B5" then
 +
  topSpaceNumeric = (711.3189 - kihonHanmenHeightNumeric - 2 * (headerFooterDistanceNumeric + headerFooterHeightNumeric))/2
 +
elseif paperSize == "A5" then
 +
  topMarginNumericMm = 25
 +
  topMarginNumeric = 2.8346 * topMarginNumericMm
 +
  topSpaceNumeric = topMarginNumeric - headerFooterHeightNumeric - headerFooterDistanceNumeric
 +
elseif paperSize == "B6" then
 +
  topSpaceNumeric = (500.7685 - kihonHanmenHeightNumeric - 2 * (headerFooterDistanceNumeric + headerFooterHeightNumeric))/2
 +
end
 +
topSpace = tostring(topSpaceNumeric) .. unit
 +
}
 +
 
 +
\setuppapersize[\directlua{tex.print(paperSize)}]
 +
 
 +
\setuppagenumbering
 +
  [alternative=doublesided,
 +
  location=none]
 +
 
 +
\setuphead
 +
  [title,subject]
 +
  [align=middle]
 +
 
 +
\startsetups [header:rightpage]
 +
 
 +
  \startframed [
 +
      frame=off,
 +
      strut=no,
 +
      height=\headerheight,
 +
      offset=none,
 +
      align=low,
 +
      roffset=1em,
 +
  ]
 +
 
 +
    \getmarking[subject]
 +
 
 +
  \stopframed
 +
 
 +
\stopsetups
 +
 
 +
\startsetups [header:leftpage]
 +
 
 +
  \startframed [
 +
      frame=off,
 +
      strut=no,
 +
      height=\headerheight,
 +
      offset=none,
 +
      align=low,
 +
      loffset=1em,
 +
  ]
 +
 
 +
    \getmarking[title]
 +
 
 +
  \stopframed
 +
 
 +
\stopsetups
 +
 
 +
\startsetups [footer:rightpage]
 +
 
 +
  \startframed [
 +
      frame=off,
 +
      strut=no,
 +
      height=\headerheight,
 +
      offset=none,
 +
      align=low,
 +
      roffset=1em,
 +
  ]
 +
 
 +
    \prefixedpagenumber
 +
 
 +
  \stopframed
 +
 
 +
\stopsetups
 +
 
 +
\startsetups [footer:leftpage]
 +
 
 +
  \startframed [
 +
      frame=off,
 +
      strut=no,
 +
      height=\headerheight,
 +
      offset=none,
 +
      align=low,
 +
      loffset=1em,
 +
  ]
 +
 
 +
    \prefixedpagenumber
 +
 
 +
  \stopframed
 +
 
 +
\stopsetups
 +
 
 +
\setupheadertexts
 +
  [] [\directsetup{header:rightpage}]
 +
  [\directsetup{header:leftpage}] []
 +
 
 +
\setupfootertexts
 +
  [] [\directsetup{footer:rightpage}]
 +
  [\directsetup{footer:leftpage}] []
 +
 
 +
\setupheader
 +
  [strut=no]
 +
 
 +
\setupfooter
 +
  [strut=no]
 +
 
 +
\setuplayout[
 +
  topspace=\directlua{tex.print(topSpace)},
 +
  header=\directlua{tex.print(headerFooterHeight)},
 +
  headerdistance=\directlua{tex.print(headerFooterDistance)},
 +
  footer=\directlua{tex.print(headerFooterHeight)},
 +
  footerdistance=\directlua{tex.print(headerFooterDistance)},
 +
  width=\directlua{tex.print(kihonHanmenWidth)},
 +
  height=\directlua{tex.print(makeUpHeight)},
 +
  backspace=\directlua{tex.print(backSpace)},
 +
]
 +
 
 +
 
 +
\definebodyfontenvironment[\directlua{tex.print(characterSize)}]
 +
 
 +
\setupinterlinespace
 +
  [line=\directlua{tex.print(lineFeed)},
 +
  height=0.56, %Necessary for aligning the lines to the Kihon-hanmen. Aligning is still not perfect yet, needs to be improved.
 +
  depth=0.44, %Necessary for aligning the lines to the Kihon-hanmen. Aligning is still not perfect yet, needs to be improved.
 +
  ]
 +
 
 +
\definepagecolumns[mycolumns]
 +
[
 +
  n=\directlua{tex.print(columnCount)},
 +
  distance=\directlua{tex.print(columnGap)},
 +
  %frame=on, %to be commented out later
 +
  framecolor=blue,
 +
  rulethickness=.1pt,
 +
]
 +
 
 +
\definefontfeature [default] [default] [protrusion=pure] %needed for protrusion of full stops and commas.
 +
 
 +
%%% Noto Fonts
 +
 
 +
\definefontfamily[JapaneseFont][rm][Noto Serif JP]
 +
  [  it={style:regular,features:{*,slanted}},
 +
      sl={style:regular,features:{*,slanted}},
 +
      bi={style:bold,features:{*,slanted}},force=yes]
 +
 
 +
\definefontfamily[JapaneseFont][ss][Noto Serif JP]
 +
  [  it={style:regular,features:{*,slanted}},
 +
      sl={style:regular,features:{*,slanted}},
 +
      bi={style:bold,features:{*,slanted}},force=yes]
 +
 
 +
\definefontfamily[JapaneseFont][tt][Noto Serif JP]
 +
  [  it={style:regular,features:{*,slanted}},
 +
      sl={style:regular,features:{*,slanted}},
 +
      bi={style:bold,features:{*,slanted}},force=yes]
 +
 
 +
\definefontfamily[JapaneseFont][math][Tex Gyre Termes Math]
 +
 
 +
 
 +
\setupbodyfont[JapaneseFont,\directlua{tex.print(characterSize)}]
 +
\setupalign [hanging] %needed for protrusion of full stops and commas
 +
\setupruby[location=top,voffset=-1.9ex]
 +
\mainlanguage[ja]
 +
\language[ja]
 +
\setscript[nihongo] %this loads the line breaking rules defined under scrp-cjk.lua
 +
 
 +
%\setupruby
 +
%  [style={\switchtobodyfont[6pt]}]
 +
 
 +
%Line head indent at the beginning of paragraphs is applied to all paragraphs. Nearly all books and magazines make use of this method.
 +
\setupindenting[yes, 1em]
 +
 
 
\starttext
 
\starttext
  你好!
+
 
 +
\startmycolumns
 +
\starttitle [title={ス位心}]
 +
 
 +
\startsubject [title={ワソ多}]
 +
 
 +
%The text has no meaning and is imitating some Japanese lorum ipsum.
 +
打構セト読役いゆお及層\ruby{僕}{ぼく}はもう大コモクカ軟毎ホアヲト極書た球87本野ぎレべ襲画売ぎ関負ら断紀チラネキ質、紋キタ資私トゃふん。江コキトサ狂毎現ンづ応通サシ続36島性84界ぼゆゃが実書ちぽふず辞躍【事シ世図二ハス盛堀\ruby{早}{はや}く人わレをう第紙きかイの浅69乳キメタ事争つょお\ruby{休}{やす}みなさい社以ヨナム法例やほにル済療にしいむ。子け記多ゅくよ正役モ母憲ト\ruby{寝}{ね}る。ぞ説帝け務賞ク付打ワナ内桁ぼでクフ因倒おふフ印気地レタケマ冬4雇各裁微ひるぼ。
 +
 
 +
事ーやずお両遇ほがお職喜じきちそ経岡ウナオケ型児てきろ置実イハ隊留社びか車斉ムマ数今せぴさし都{聞最へぼう康自コミニク月言ム検代捕ぶねやう。6本うげがぎ無多シワソ多転のづが加分がど臣次オモエヱ務教すそ必組テタレソhello, nice to meet you極渡げフ資聞ぽへトづ禁昔キイウニ食度地ヱ考性ユエ内生ヱセ音94党と経陸咲幼勤りだフ。83男融録ょもな氷社くにルべ害変でおけう変世7超キ減安リヌ株崎5転理済ほだをな黒府 $a+b=b+a$ コワスソ地賢堂衛イぶにし。
 +
 
 +
広げがぴ視立ス位心もスわ止想ツクケラ産竹聞ヌ落38判境ノア賞7写カチ華供ソミワ名認ばゆずほ始色らふひも属対73写けで止突兄呂びの。策イルリヘ行十織キヘ興必む万初ゃづは勝米い館独ム感一チヒナ希8写タムシイ室情づがい焼殺つか広質トクロ毎新ソモ患関済えめね働表め白告こリあ杯困摘屈裂れ。
 +
 
 +
名テホユ稿国む生覧ヨナケヤ文6垣めこル社2市むあし保止転済ノ問判りッ集員セワ全宣コ森領で温子う。ラちぎ夏査せすむ来資ニ面三わぼ際6之減喰杜き。堂ヲ賞了かえー単惑イめ秋投クツ意拡平ヘタヱ時83死れる互武ぽほ拉51届ニネラヘ掲団ヨ度両議ク。状親日値ル断大示ヘニコク米界を連禁イが性正ルッ問句サルユ試片サロヤ前毎到くぜ黄雑らりえ報同ょきむ督晴岡確たごげむ。
 +
 
 +
両おぎゅら写合ル書殖だインぎ孝自氷ばぞひ事権ウノレヲ少止ヲマヨミ惑磁ぞくゅ竹月おやま手51質サム付2仏い職断年にーばざ場現ムワホ襲印講行否えうご。5帰7報ク用講ルのよす媛表サシメマ札変ナヲ案積出ソトマセ決情注モハイ際県らぶドご食績どはあだ徳増フシ断県ぼね了件親億かゆ。申府ホ線全る訪親ケヒネ芸比歳よをづう供記モケ正同とき練1紀ゅくふい割市ざ著法べちめせ客答ヤヌキオ入朗ルヌカス況写天境月郎ろたづ。
 +
 
 +
想ネシモヤ人時ワ化新リぱイこ京希っじ索視ケア風月受マカ東初ぞ月公て無速だ文保か受4香刃尿憎潔だクばづ。果テカ川程イ相安べろ方4映チ米闘ヤタレ会民クをづい治果とルせ字社かイよ新軍こ持芸ワラウケ掲三58治館壌ゃ。行びまむ快野分真タネス応住えじで半記キネト正6者理ぼあ面出ヱシレワ慎首レトアハ託展オ良育圏ーを申傷説ひよもぶ索構を持試奇拝括ぱふ。
 +
 
 +
\stopsubject
 +
 
 +
\startsubject [title={覧ロヨヤ}]
 +
 
 +
写みを参念タ三辞よルさき想3込ぜトリ会図ロ法部じち之杉ぎば厳近ワオコ光傷治ワ整区童熊習本さはリん。一ナカヒハ経松隊整キメケト需湖モユエウ秘千そ含覧ふリさ挙言ねをク凍誉ょい利際ゃぼの織用ユリル育4緊ご選1面とし胃危雪異みのひき。竹品ハ著供うげル、島該ょ城豊ぎすご腹独べじり皆5座わーう化著式サマ木陸ミレノ義軍80鯨ヒキトフ読大フニノネ読覧ロヨヤイ投時ょうす都活きっみざ。
 +
 
 +
上なラ済経ロ有実マ乳装ざなぴま武1守い掲6町ぼ禁28担惑らばんフ社策送案物んまへ。人際クょゃね験伝め念変クマヌ白馳ナツエヤ著側ッごフぞ済川さ趣載ツア挙85適クウネレ稿並ドむわの論棋ナソスヒ教伎締潤革フ。球尊話者が心三いむり達尼スか町過ミタオ上止ワカヤ正着ざぱぎぼ失成行偽ワマヘ北奮く。
 +
 
 +
済開ぼスじと力紹オア手混チコ成意コテモケ定因ド情最どいとづ写今えりめ問景ルオフチ度自す作12行トヱワ録消ひイ。縦右で後賞たじつド諸場後し面詐でばト題社のれふた」。年結すたぜじ下労リえたゅ高作セレテ給5山ワ任共ご京前ミレシ本写午吉活ぽし。播るせ部3席ヒ投揮ぴしんけ安図んき同更展将ごさぽ画9用サキ購21十ツヘト京締乱僕ろ。
 +
 
 +
図ラ象45韓ど考小ヌニ野初ムユイシ河止中ヤトキヒ巻女ッ除稿イ輔余た研弔カ被悪テヘ業購ヘタ詳支ルれ身日だがん出療ずー盛趣なばぐ離女放佳怖れずへ。理じかぐ討15枠制8五袋ヒク選会ソアシカ主手付みとこ猪月メ語経マオヱミ社接フセユア幌財ー香口衆ンろ著瀬なこン身個供悪射窃どスあ。切テセ重購ニホ覧権じゆむげ影文ヒヘ相断66哉ノホテフ黒植くね氏員更あきぱゆ文記ふわひ載更上ぜいひば。
 +
 
 +
打構セト読役いゆお及層\ruby{僕}{ぼく}はもう大コモクカ軟毎ホアヲト極書た球87本野ぎレべ襲画売ぎ関負ら断紀チラネキ質、紋キタ資私トゃふん。江コキトサ狂毎現ンづ応通サシ続36島性84界ぼゆゃが実書ちぽふず辞躍事シ世図二ハス盛堀\ruby{早}{はや}く人わレをう第紙きかイの浅69乳キメタ事争つょお\ruby{休}{やす}みなさい社以ヨナム法例やほにル済療にしいむ。子け記多ゅくよ正役モ母憲ト\ruby{寝}{ね}る。ぞ説帝け務賞ク付打ワナ内桁ぼでクフ因倒おふフ印気地レタケマ冬4雇各裁微ひるぼ。
 +
 
 +
事ーやずお両遇ほがお職喜じきちそ経岡ウナオケ型児てきろ置実イハ隊留社びか車斉ムマ数今せぴさし都聞最へぼう康自コミニク月言ム検代捕ぶねやう。6本うげがぎ無多シワソ多転のづが加分がど臣次オモエヱ務教すそ必組テタレソhello, nice to meet you極渡げフ資聞ぽへトづ禁昔キイウニ食度地ヱ考性ユエ内生ヱセ音94党と経陸咲幼勤りだフ。83男融録ょもな氷社くにルべ害変でおけう変世7超キ減安リヌ株崎5転理済ほだをな黒府コワスソ地賢堂衛イぶにし。
 +
 
 +
広げがぴ視立ス位心もスわ止想ツクケラ産竹聞ヌ落38判境ノア賞7写カチ華供ソミワ名認ばゆずほ始色らふひも属対73写けで止突兄呂びの。策イルリヘ行十織キヘ興必む万初ゃづは勝米い館独ム感一チヒナ希8写タムシイ室情づがい焼殺つか広質トクロ毎新ソモ患関済えめね働表め白告こリあ杯困摘屈裂れ。
 +
 
 +
名テホユ稿国む生覧ヨナケヤ文6垣めこル社2市むあし保止転済ノ問判りッ集員セワ全宣コ森領で温子うラちぎ夏査せすむ来資ニ面三わぼ際6之減喰杜き。堂ヲ賞了かえー単惑イめ秋投クツ意拡平ヘタヱ時83死れる互武ぽほ拉51届ニネラヘ掲団ヨ度両議ク。状親日値ル断大示ヘニコク米界を連禁イが性正ルッ問句サルユ試片サロヤ前毎到くぜ黄雑らりえ報同ょきむ督晴岡確たごげむ。
 +
 
 +
両おぎゅら写合ル書殖だインぎ孝自氷ばぞひ事権ウノレヲ少止ヲマヨミ惑磁ぞくゅ竹月おやま手51質サム付2仏い職断年にーばざ場現ムワホ襲印講行否えうご。5帰7報ク用講ルのよす媛表サシメマ札変ナヲ案積出ソトマセ決情注モハイ際県らぶドご食績どはあだ徳増フシ断県ぼね了件親億かゆ。申府ホ線全る訪親ケヒネ芸比歳よをづう供記モケ正同とき練1紀ゅくふい割市ざ著法べちめせ客答ヤヌキオ入朗ルヌカス況写天境月郎ろたづ。
 +
 
 +
想ネシモヤ人時ワ化新リぱイこ京希っじ索視ケア風月受マカ東初ぞ月公て無速だ文保か受4香刃尿憎潔だクばづ。果テカ川程イ相安べろ方4映チ米闘ヤタレ会民クをづい治果とルせ字社かイよ新軍こ持芸ワラウケ掲三58治館壌ゃ。行びまむ快野分真タネス応住えじで半記キネト正6者理ぼあ面出ヱシレワ慎首レトアハ託展オ良育圏ーを申傷説ひよもぶ索構を持試奇拝括ぱふ。
 +
 
 +
写みを参念タ三辞よルさき想3込ぜトリ会図ロ法部じち之杉ぎば厳近ワオコ光傷治ワ整区童熊習本さはリん。一ナカヒハ経松隊整キメケト需湖モユエウ秘千そ含覧ふリさ挙言ねをク凍誉ょい利際ゃぼの織用ユリル育4緊ご選1面とし胃危雪異みのひき。竹品ハ著供うげル島該ょ城豊ぎすご腹独べじり皆5座わーう化著式サマ木陸ミレノ義軍80鯨ヒキトフ読大フニノネ読覧ロヨヤイ投時ょうす都活きっみざ。
 +
 
 +
\stopsubject
 +
 
 +
\startsubject [title={が心三いむ}]
 +
 
 +
上なラ済経ロ有実マ乳装ざなぴま武1守い掲6町ぼ禁28担惑らばんフ社策送案物んまへ。人際クょゃね験伝め念変クマヌ白馳ナツエヤ著側ッごフぞ済川さ趣載ツア挙85適クウネレ稿並ドむわの論棋ナソスヒ教伎締潤革フ。球尊話者が心三いむり達尼スか町過ミタオ上止ワカヤ正着ざぱぎぼ失成行偽ワマヘ北奮く。
 +
 
 +
済開ぼスじと力紹オア手混チコ成意コテモケ定因ド情最どいとづ写今えりめ問景ルオフチ度自す作12行トヱワ録消ひイ。縦右で後賞たじつド諸場後し面詐でばト題社のれふた」。年結すたぜじ下労リえたゅ高作セレテ給5山ワ任共ご京前ミレシ本写午吉活ぽし。播るせ部3席ヒ投揮ぴしんけ安図んき同更展将ごさぽ画9用サキ購21十ツヘト京締乱僕ろ。
 +
 
 +
図ラ象45韓ど考小ヌニ野初ムユイシ河止中ヤトキヒ巻女ッ除稿イ輔余た研弔カ被悪テヘ業購ヘタ詳支ルれ身日だがん出療ずー盛趣なばぐ離女放佳怖れずへ。理じかぐ討15枠制8五袋ヒク選会ソアシカ主手付みとこ猪月メ語経マオヱミ社接フセユア幌財ー香口衆ンろ著瀬なこン身個供悪射窃どスあ。切テセ重購ニホ覧権じゆむげ影文ヒヘ相断66哉ノホテフ黒植くね氏員更あきぱゆ文記ふわひ載更上ぜいひば。
 +
 
 +
\stopsubject
 +
 
 +
\stoptitle
 +
 
 +
\stopmycolumns
 +
 
 +
 
 +
%\showlayout %for Debugging, to be commented out later
 +
 
 
\stoptext
 
\stoptext
 
</texcode>
 
</texcode>
  
If you want to typset vertical text, use <tt>\startvertical ... \stopvertical</tt>, if you want to use Chinese numbers, you can use e.g. <tt>\startitemize[c]</tt>; possible options are <tt>c</tt> or <tt>cn</tt> for normal Chinese numbers (一, , 三, 四, 无, 六 etc.), <tt>cc</tt> for the capitalized (or financial) Chinese numbers (壹, , 叄 etc.), <tt>ec</tt> for an extended version which uses 廿 and 卅 (instead of 一十 and 二十), and <tt>ac</tt> for using the Chinese numbers zero (零, 〇) to nine (九) in the same way one does with the Arabic digits 0 to 9.
+
=Setup for Chinese=
 +
 
 +
Get inspirated with importing Chinese fonts with this [https://github.com/BruXy/ConTeXt-Chinese script].
 +
 
 +
# You need some Chinese (TrueType) fonts; you may want to get for example Microsoft Truetype fonts:
 +
## [http://archive1.village.virginia.edu/spw4s/fonts/STSONG.TTF STSong],
 +
## [http://archive1.village.virginia.edu/spw4s/fonts/STZHONGS.TTF STZhongsong],
 +
## [http://archive1.village.virginia.edu/spw4s/fonts/STXIHEI.TTF STXihei],
 +
## [http://archive1.village.virginia.edu/spw4s/fonts/STKAITI.TTF STKaiti],
 +
## [http://archive1.village.virginia.edu/spw4s/fonts/STFANGSO.TTF STFangsong].
 +
# Example of some basic document with enabled Chinese:
 +
 
 +
<texcode>
 +
\mainlanguage[cn]
 +
\language[cn]
 +
\setscript[hanzi] % hyphenation
 +
 
 +
% Enable fonts
 +
\usetypescriptfile[mscore]
 +
\setupbodyfont [mschinese,12pt]
 +
\usebodyfont  [mschinese-light,12pt]
 +
\definebodyfontenvironment[24pt]
 +
\definebodyfontenvironment[18pt]
 +
 
 +
\setuppagenumber [numberconversion=cn]
 +
\definestructureconversionset[chinese][numbers][cn]
 +
\setupheads [sectionconversionset=chinese]
 +
 
 +
\define[2]\ChineseChapter{第#1章 #2}
 +
\setuphead[chapter][command=\ChineseChapter,style={\bf\switchtobodyfont[24pt]}]
 +
\setuphead[section][style={\bf\switchtobodyfont[18pt]}]
 +
 
 +
\setuppagenumbering[state=start,
 +
    alternative=singlesided,
 +
    location={footer, center},
 +
    style={\bf\switchtobodyfont[11pt]}
 +
]
  
 +
\starttext
 +
\chapter{华文字体系列}
 +
 +
在微软提供的 Office 套装中附带了一定数量的中文字体,这些字体是常州华文印刷新技术有限公司制造的。
  
=Chinese in ConTeXt (before 2005.12.19)=
+
\startitemize
[[User:Xiaojf|Xiao Jianfeng]] wrote in a [http://archive.contextgarden.net/message/20050606.080842.5e1c2057.en.html mail to the mailing list on 2005-06-06]:
+
\item \type{\it}: {\it 华文仿宋}
 +
\item \type{\rm}: {\rm 华文仿宋}
 +
\item \type{\bf}: {\bf 华文中宋}
 +
\item \type{\ss}: {\ss 华文细黑}
 +
\item \type{\tfxx}: {\tfxx 华文仿宋}
 +
\item \type{\tfx}: {\tfx 华文仿宋}
 +
\item \type{\tf}: {\tf 华文仿宋}
 +
\item \type{\tfa}: {\tfa 华文仿宋}
 +
\item \type{\tfb}: {\tfb  华文仿宋}
 +
\item \type{\tfc}: {\tfc 华文仿宋}
 +
\item \type{\tfd}: {\tfd 华文仿宋}
 +
\stopitemize
 +
\stoptext
 +
</texcode>
  
Here is my way of Chinese setup in ConTeXt. I hope this can be of any help to some newbies like me who have problems in processing Chinese.
+
=Setup for Korean=
  
# Get the truetype fonts <tt>[ftp://ftp.ctex.org/pub/tex/fonts/truetype/ttf/htfs.ttf htfs.ttf], [ftp://ftp.ctex.org/pub/tex/fonts/truetype/ttf/hthei.ttf hthei.ttf], [ftp://ftp.ctex.org/pub/tex/fonts/truetype/ttf/htkai.ttf htkai.ttf]</tt> and <tt>[ftp://ftp.ctex.org/pub/tex/fonts/truetype/ttf/htsong.ttf htsong.ttf]</tt> from ftp://ftp.ctex.org/pub/tex/fonts/truetype/ttf/
+
You need fonts which contain hangul characters (don’t forget to set a math font because it is used for the symbols in enumerations) and you have to enable linebreaking for Korean with the {{cmd|setscript}} command.
# Get corresponding tfm files <tt>[ftp://ftp.ctex.org/pub/tex/fonts/truetype/for_pdftex/tfm/gbfs.zip gbfs.zip], [ftp://ftp.ctex.org/pub/tex/fonts/truetype/for_pdftex/tfm/gbhei.zip gbhei.zip], [ftp://ftp.ctex.org/pub/tex/fonts/truetype/for_pdftex/tfm/gbkai.zip gbkai.zip]</tt> and <tt>[ftp://ftp.ctex.org/pub/tex/fonts/truetype/for_pdftex/tfm/gbsong.zip gbsong.zip]</tt> from ftp://ftp.ctex.org/pub/tex/fonts/truetype/for_pdftex/tfm/
 
# Get the enc file <tt>[ftp://ftp.ctex.org/pub/tex/fonts/truetype/for_pdftex/enc_map/Gbk.zip Gbk.zip]</tt> from ftp://ftp.ctex.org/pub/tex/fonts/truetype/for_pdftex/enc_map/
 
# Get the map file <tt>[ftp://ftp.ctex.org/pub/tex/fonts/truetype/for_pdftex/enc_map/map.zip map.zip]</tt> from ftp://ftp.ctex.org/pub/tex/fonts/truetype/for_pdftex/enc_map/
 
# Put the ttf font files you got in step 1 to <tt>texmf-fonts/fonts/truetype/chinese</tt>
 
# Unzip the files you got in step 2 and you get four corresponding directories (which contain tfm files), then put them  in <tt>texmf-fonts/fonts/tfm/chinese</tt>
 
# Unzip <tt>Gbk.zip</tt>, you will get a directory named <tt>Gbk</tt> which contains many enc files. Put the directory to <tt>texmf-fonts/fonts/enc/chinese</tt>
 
# Unzip <tt>map.zip</tt>, you will get many map files, you need just the <tt>gbk.map</tt>. You need to edit <tt>gbk.map</tt>, delete entries of gbli* at the end of the file (lines 505-629). Then, put the modified <tt>gbk.map</tt> to <tt>texmf-fonts/fonts/map/chinese</tt>. Note that newer pdfetex don't read [[pdftex.cfg]] so better use <cmd>loadmapfile[gbk]</cmd> in your document.
 
# Your document should be compilable now. See sample below.
 
# I haven't tried to compile Traditional Chinese documents. Maybe just get corresponding files for Traditional Chinese and put there to the right location will work. I'm not sure.
 
  
Sample Code (save in cp936 encoding):
 
 
<texcode>
 
<texcode>
\loadmapfile[gbk]
+
% Wolfgang Schuster 2017-12-06
\usemodule[chinese]
+
\mainlanguage[kr]
\setuppagenumbering[state=stop]
+
 
\starttext
+
\definefallbackfamily [mainface] [rm] [Nanum Myeongjo] [preset=range:korean]
\tfd
+
\definefontfamily    [mainface] [rm] [DejaVu Serif]
这里什么饮料也没有真不像话!
+
 
\stoptext
+
\definefallbackfamily [mainface] [ss] [Nanum Gothic] [preset=range:korean]
 +
\definefontfamily    [mainface] [ss] [DejaVu Sans]
 +
 
 +
\definefallbackfamily [mainface] [tt] [Nanum Gothic Coding] [features=none,preset=range:korean]
 +
\definefontfamily    [mainface] [tt] [DejaVu Sans Mono] [features=none]
 +
 
 +
\definefontfamily    [mainface] [mm] [DejaVu Math]
 +
 
 +
\setupbodyfont[mainface]
 +
 
 +
\setscript[hangul]
 +
 
 +
\starttext
 +
 
 +
이 FAQ 은 자주 반복되는 질문과 그에 대한 대답을 간단명료한 양식으로
 +
모아 엮어졌습니다.
 +
 
 +
{\ss 이 FAQ 은 자주 반복되는 질문과 그에 대한 대답을 간단명료한 양식으로
 +
모아 엮어졌습니다.}
 +
 
 +
\starttyping
 +
이 FAQ 은 자주 반복되는 질문과 그에 대한 대답을 간단명료한 양식으로
 +
모아 엮어졌습니다.
 +
\stoptyping
 +
 
 +
\stoptext
 
</texcode>
 
</texcode>
  
If you want to use UTF-8, the [http://www.ntg.nl/pipermail/ntg-context/2005/013542.html script by Lutz Haseloff] might of interest to you; the needed perl module Encode::HanConvert is [http://search.cpan.org/dist/Encode-HanConvert/ available at CPAN]. Note, however, that you may only use characters representable in gbk, German umlauts for instance are converted into ??.
+
=Outdated=
 +
 
 +
* old introduction [[Uptodate]] by Pragma: [http://www.pragma-ade.nl/general/uptodate/up-007-s.pdf screen] and [http://www.pragma-ade.nl/general/uptodate/up-007-p.pdf paper] version
 +
* manual by Pragma: [[manual:mchinese.pdf|Chinese in ConTeXt]] (Old 2001)
 +
 
 +
== See also ==
 +
* [[CJK fonts]]
 +
 
 
[[Category:Fonts]]
 
[[Category:Fonts]]
[[Category:International]]
+
[[Category:Languages]]

Latest revision as of 07:19, 14 March 2024

Setup for Japanese

% 2024-02 Otared Kavian, Jeong Dal et al.
\mainlanguage[ja]

\definefontfamily[JapaneseFont][rm][Noto Serif JP]
  [   it={style:regular,features:{*,slanted}},
      sl={style:regular,features:{*,slanted}},
      bi={style:bold,features:{*,slanted}},force=yes]

\definefontfamily[JapaneseFont][ss][Noto Serif JP]
  [   it={style:regular,features:{*,slanted}},
      sl={style:regular,features:{*,slanted}},
      bi={style:bold,features:{*,slanted}},force=yes]

\definefontfamily[JapaneseFont][tt][Noto Serif JP]
  [   it={style:regular,features:{*,slanted}},
      sl={style:regular,features:{*,slanted}},
      bi={style:bold,features:{*,slanted}},force=yes]

\definefontfamily[JapaneseFont][math][Tex Gyre Termes Math]
%\definefontfamily[JapaneseFont][math][Tex Gyre Pagella Math]
%\definefontfamily[JapaneseFont][math][Tex Gyre Aventor]

%%%%

\setupbodyfont[JapaneseFont,12pt]
\setupruby[location=top,voffset=-2ex]
\setupwhitespace[big]
\setscript[nihongo]

\starttext
\ruby{}{はや}く。
いきましょう。
\stoptext

Meeting the JIS X 4051 Requirements for Japanese Text Layout

The actual standard was revised in 2004 and the latest version is JIS X 4051:2004. You can read it in Japanese here: https://kikakurui.com/x4/X4051-2004-02.html

The W3C technical note "Requirements for Japanese Text Layout", published on 4 June 2009, is based on JIS X 4051. This is also available in English: https://www.w3.org/TR/jlreq/

Following code is a work in progress. Its text layout output meets already some of the requirements (see comments in the code). Among the ones to still be implemented are:

When you read the lua code in the first \directlua{}, you should realize that the dimensions of almost all layout elements are depending on the value of my lua variable "paperSize". Thanks to defining the paper size first in lua, I can apply calculations of numeric values.

The value of paperSize is later passed on to \setuppapersize via \setuppapersize[\directlua{tex.print(paperSize)}]

%Visual Debugging, to be commented out later:
%\showframe %shows the layout elements
%\showgrid %shows the line numbering
%\showmakeup[penalty] %shows characters for which specific breaking line rules apply
%\showmakeup[glyph] %shows the box of each character

%Define the elements of Kihon-hanmen. 
%Line length should be multiples of the character size.
%Following dimensions are taken from JIS X 4051, annex 3, cases Y-1 to Y-4. Just change value (A4, A5, B5, B6) for paperSize to switch between the cases. 
\directlua{
unit = "pt"

paperSize = "B5"

characterSizeNumeric = 9 
if paperSize == "A4" or paperSize == "A5" or paperSize == "B5" then
  characterSizeNumeric = 9
elseif paperSize == "B6" then
  characterSizeNumeric = 8
end
characterSize = tostring(characterSizeNumeric) .. unit

characterCountPerColumn = 25 
if paperSize == "A4" then
  characterCountPerColumn = 25
elseif paperSize == "B5" then
  characterCountPerColumn = 22
elseif paperSize == "A5" or paperSize == "B6" then
  characterCountPerColumn = 34
end

columnCount = 2 
if paperSize == "A4" or paperSize == "B5" then
  columnCount = 2
elseif paperSize == "A5" or paperSize == "B6" then
  columnCount = 1
end

lineCount = 46 
if paperSize == "A4" then
  lineCount = 46
elseif paperSize == "B5" then
  lineCount = 40
elseif paperSize == "A5" then
  lineCount = 29
elseif paperSize == "B6" then
  lineCount = 27
end

lineSpacingNumeric = 6 
if paperSize == "A4" or paperSize == "B5" then
  lineSpacingNumeric = 6
elseif paperSize == "A5" or paperSize == "B5" then
  lineSpacingNumeric = 7
end

columnGapNumeric = 18
columnGap = tostring(columnGapNumeric) .. unit

headerFooterHeightNumeric = characterSizeNumeric
headerFooterHeight = tostring(headerFooterHeightNumeric) .. unit

headerFooterDistanceNumeric = characterSizeNumeric
headerFooterDistance = tostring(headerFooterDistanceNumeric) .. unit

lineFeedNumeric = characterSizeNumeric + lineSpacingNumeric
lineFeed = tostring(lineFeedNumeric) .. unit

lineWidthNumeric = characterSizeNumeric * characterCountPerColumn

kihonHanmenWidthNumeric = columnCount * lineWidthNumeric + (columnCount - 1) * columnGapNumeric
kihonHanmenWidth = tostring(kihonHanmenWidthNumeric) .. unit

backSpaceNumeric = (597.5079 - kihonHanmenWidthNumeric) / 2
if paperSize == "A4" then
  backSpaceNumeric = (597.5079 - kihonHanmenWidthNumeric) / 2
elseif paperSize == "B5" then
  backSpaceNumeric = (500.7685 - kihonHanmenWidthNumeric) / 2
elseif paperSize == "A5" then
  backSpaceNumeric = (421.1008 - kihonHanmenWidthNumeric) / 2
elseif paperSize == "B6" then
  backSpaceNumeric = (355.6594 - kihonHanmenWidthNumeric) / 2
end
backSpace = tostring(backSpaceNumeric) .. unit

kihonHanmenHeightNumeric = lineCount * characterSizeNumeric + (lineCount - 1) * lineSpacingNumeric
kihonHanmenHeight = tostring(kihonHanmenHeightNumeric) .. unit

makeUpHeightNumeric = kihonHanmenHeightNumeric + 2 * headerFooterHeightNumeric + 2 * headerFooterDistanceNumeric
makeUpHeight = tostring(makeUpHeightNumeric) .. unit

topMarginNumericMm = 29
topMarginNumeric = 2.8346 * topMarginNumericMm
topSpaceNumeric = topMarginNumeric - headerFooterHeightNumeric - headerFooterDistanceNumeric
if paperSize == "A4" then
  topMarginNumericMm = 29
  topMarginNumeric = 2.8346 * topMarginNumericMm
  topSpaceNumeric = topMarginNumeric - headerFooterHeightNumeric - headerFooterDistanceNumeric
elseif paperSize == "B5" then
  topSpaceNumeric = (711.3189 - kihonHanmenHeightNumeric - 2 * (headerFooterDistanceNumeric + headerFooterHeightNumeric))/2
elseif paperSize == "A5" then
  topMarginNumericMm = 25
  topMarginNumeric = 2.8346 * topMarginNumericMm
  topSpaceNumeric = topMarginNumeric - headerFooterHeightNumeric - headerFooterDistanceNumeric
elseif paperSize == "B6" then
  topSpaceNumeric = (500.7685 - kihonHanmenHeightNumeric - 2 * (headerFooterDistanceNumeric + headerFooterHeightNumeric))/2
end
topSpace = tostring(topSpaceNumeric) .. unit
}

\setuppapersize[\directlua{tex.print(paperSize)}]

\setuppagenumbering
  [alternative=doublesided,
   location=none]

\setuphead
  [title,subject]
  [align=middle]

\startsetups [header:rightpage]

  \startframed [
      frame=off,
      strut=no,
      height=\headerheight,
      offset=none,
      align=low,
      roffset=1em,
  ]

    \getmarking[subject]

  \stopframed

\stopsetups

\startsetups [header:leftpage]

  \startframed [
      frame=off,
      strut=no,
      height=\headerheight,
      offset=none,
      align=low,
      loffset=1em,
  ]

    \getmarking[title]

  \stopframed

\stopsetups

\startsetups [footer:rightpage]

  \startframed [
      frame=off,
      strut=no,
      height=\headerheight,
      offset=none,
      align=low,
      roffset=1em,
  ]

    \prefixedpagenumber

  \stopframed

\stopsetups

\startsetups [footer:leftpage]

  \startframed [
      frame=off,
      strut=no,
      height=\headerheight,
      offset=none,
      align=low,
      loffset=1em,
  ]

    \prefixedpagenumber

  \stopframed

\stopsetups

\setupheadertexts
  [] [\directsetup{header:rightpage}]
  [\directsetup{header:leftpage}] []

\setupfootertexts
  [] [\directsetup{footer:rightpage}]
  [\directsetup{footer:leftpage}] []

\setupheader
  [strut=no]

\setupfooter
  [strut=no]
  
\setuplayout[
  topspace=\directlua{tex.print(topSpace)},
  header=\directlua{tex.print(headerFooterHeight)},
  headerdistance=\directlua{tex.print(headerFooterDistance)},
  footer=\directlua{tex.print(headerFooterHeight)},
  footerdistance=\directlua{tex.print(headerFooterDistance)},
  width=\directlua{tex.print(kihonHanmenWidth)}, 
  height=\directlua{tex.print(makeUpHeight)}, 
  backspace=\directlua{tex.print(backSpace)}, 
]


\definebodyfontenvironment[\directlua{tex.print(characterSize)}]

\setupinterlinespace
  [line=\directlua{tex.print(lineFeed)},
   height=0.56, %Necessary for aligning the lines to the Kihon-hanmen. Aligning is still not perfect yet, needs to be improved.
   depth=0.44, %Necessary for aligning the lines to the Kihon-hanmen. Aligning is still not perfect yet, needs to be improved.
   ]

\definepagecolumns[mycolumns]
[
  n=\directlua{tex.print(columnCount)}, 
  distance=\directlua{tex.print(columnGap)}, 
  %frame=on, %to be commented out later
  framecolor=blue, 
  rulethickness=.1pt, 
]

\definefontfeature [default] [default] [protrusion=pure] %needed for protrusion of full stops and commas.

%%% Noto Fonts

\definefontfamily[JapaneseFont][rm][Noto Serif JP]
  [   it={style:regular,features:{*,slanted}},
      sl={style:regular,features:{*,slanted}},
      bi={style:bold,features:{*,slanted}},force=yes]

\definefontfamily[JapaneseFont][ss][Noto Serif JP]
  [   it={style:regular,features:{*,slanted}},
      sl={style:regular,features:{*,slanted}},
      bi={style:bold,features:{*,slanted}},force=yes]

\definefontfamily[JapaneseFont][tt][Noto Serif JP]
  [   it={style:regular,features:{*,slanted}},
      sl={style:regular,features:{*,slanted}},
      bi={style:bold,features:{*,slanted}},force=yes]

\definefontfamily[JapaneseFont][math][Tex Gyre Termes Math]


\setupbodyfont[JapaneseFont,\directlua{tex.print(characterSize)}]
\setupalign [hanging] %needed for protrusion of full stops and commas
\setupruby[location=top,voffset=-1.9ex]
\mainlanguage[ja]
\language[ja]
\setscript[nihongo] %this loads the line breaking rules defined under scrp-cjk.lua

%\setupruby
%  [style={\switchtobodyfont[6pt]}]
  
%Line head indent at the beginning of paragraphs is applied to all paragraphs. Nearly all books and magazines make use of this method.
\setupindenting[yes, 1em]

\starttext

\startmycolumns
\starttitle [title={ス位心}] 

\startsubject [title={ワソ多}]

%The text has no meaning and is imitating some Japanese lorum ipsum.
打構セト読役いゆお及層\ruby{}{ぼく}はもう大コモクカ軟毎ホアヲト極書た球87本野ぎレべ襲画売ぎ関負ら断紀チラネキ質、紋キタ資私トゃふん。江コキトサ狂毎現ンづ応通サシ続36島性84界ぼゆゃが実書ちぽふず辞躍【事シ世図二ハス盛堀\ruby{}{はや}く人わレをう第紙きかイの浅69乳キメタ事争つょお\ruby{}{やす}みなさい社以ヨナム法例やほにル済療にしいむ。子け記多ゅくよ正役モ母憲ト\ruby{}{}る。ぞ説帝け務賞ク付打ワナ内桁ぼでクフ因倒おふフ印気地レタケマ冬4雇各裁微ひるぼ。

事ーやずお両遇ほがお職喜じきちそ経岡ウナオケ型児てきろ置実イハ隊留社びか車斉ムマ数今せぴさし都{聞最へぼう康自コミニク月言ム検代捕ぶねやう。6本うげがぎ無多シワソ多転のづが加分がど臣次オモエヱ務教すそ必組テタレソhello, nice to meet you極渡げフ資聞ぽへトづ禁昔キイウニ食度地ヱ考性ユエ内生ヱセ音94党と経陸咲幼勤りだフ。83男融録ょもな氷社くにルべ害変でおけう変世7超キ減安リヌ株崎5転理済ほだをな黒府 $a+b=b+a$ コワスソ地賢堂衛イぶにし。

広げがぴ視立ス位心もスわ止想ツクケラ産竹聞ヌ落38判境ノア賞7写カチ華供ソミワ名認ばゆずほ始色らふひも属対73写けで止突兄呂びの。策イルリヘ行十織キヘ興必む万初ゃづは勝米い館独ム感一チヒナ希8写タムシイ室情づがい焼殺つか広質トクロ毎新ソモ患関済えめね働表め白告こリあ杯困摘屈裂れ。

名テホユ稿国む生覧ヨナケヤ文6垣めこル社2市むあし保止転済ノ問判りッ集員セワ全宣コ森領で温子う。ラちぎ夏査せすむ来資ニ面三わぼ際6之減喰杜き。堂ヲ賞了かえー単惑イめ秋投クツ意拡平ヘタヱ時83死れる互武ぽほ拉51届ニネラヘ掲団ヨ度両議ク。状親日値ル断大示ヘニコク米界を連禁イが性正ルッ問句サルユ試片サロヤ前毎到くぜ黄雑らりえ報同ょきむ督晴岡確たごげむ。

両おぎゅら写合ル書殖だインぎ孝自氷ばぞひ事権ウノレヲ少止ヲマヨミ惑磁ぞくゅ竹月おやま手51質サム付2仏い職断年にーばざ場現ムワホ襲印講行否えうご。5帰7報ク用講ルのよす媛表サシメマ札変ナヲ案積出ソトマセ決情注モハイ際県らぶドご食績どはあだ徳増フシ断県ぼね了件親億かゆ。申府ホ線全る訪親ケヒネ芸比歳よをづう供記モケ正同とき練1紀ゅくふい割市ざ著法べちめせ客答ヤヌキオ入朗ルヌカス況写天境月郎ろたづ。

想ネシモヤ人時ワ化新リぱイこ京希っじ索視ケア風月受マカ東初ぞ月公て無速だ文保か受4香刃尿憎潔だクばづ。果テカ川程イ相安べろ方4映チ米闘ヤタレ会民クをづい治果とルせ字社かイよ新軍こ持芸ワラウケ掲三58治館壌ゃ。行びまむ快野分真タネス応住えじで半記キネト正6者理ぼあ面出ヱシレワ慎首レトアハ託展オ良育圏ーを申傷説ひよもぶ索構を持試奇拝括ぱふ。

\stopsubject

\startsubject [title={覧ロヨヤ}]

写みを参念タ三辞よルさき想3込ぜトリ会図ロ法部じち之杉ぎば厳近ワオコ光傷治ワ整区童熊習本さはリん。一ナカヒハ経松隊整キメケト需湖モユエウ秘千そ含覧ふリさ挙言ねをク凍誉ょい利際ゃぼの織用ユリル育4緊ご選1面とし胃危雪異みのひき。竹品ハ著供うげル、島該ょ城豊ぎすご腹独べじり皆5座わーう化著式サマ木陸ミレノ義軍80鯨ヒキトフ読大フニノネ読覧ロヨヤイ投時ょうす都活きっみざ。

上なラ済経ロ有実マ乳装ざなぴま武1守い掲6町ぼ禁28担惑らばんフ社策送案物んまへ。人際クょゃね験伝め念変クマヌ白馳ナツエヤ著側ッごフぞ済川さ趣載ツア挙85適クウネレ稿並ドむわの論棋ナソスヒ教伎締潤革フ。球尊話者が心三いむり達尼スか町過ミタオ上止ワカヤ正着ざぱぎぼ失成行偽ワマヘ北奮く。

済開ぼスじと力紹オア手混チコ成意コテモケ定因ド情最どいとづ写今えりめ問景ルオフチ度自す作12行トヱワ録消ひイ。縦右で後賞たじつド諸場後し面詐でばト題社のれふた」。年結すたぜじ下労リえたゅ高作セレテ給5山ワ任共ご京前ミレシ本写午吉活ぽし。播るせ部3席ヒ投揮ぴしんけ安図んき同更展将ごさぽ画9用サキ購21十ツヘト京締乱僕ろ。

図ラ象45韓ど考小ヌニ野初ムユイシ河止中ヤトキヒ巻女ッ除稿イ輔余た研弔カ被悪テヘ業購ヘタ詳支ルれ身日だがん出療ずー盛趣なばぐ離女放佳怖れずへ。理じかぐ討15枠制8五袋ヒク選会ソアシカ主手付みとこ猪月メ語経マオヱミ社接フセユア幌財ー香口衆ンろ著瀬なこン身個供悪射窃どスあ。切テセ重購ニホ覧権じゆむげ影文ヒヘ相断66哉ノホテフ黒植くね氏員更あきぱゆ文記ふわひ載更上ぜいひば。

打構セト読役いゆお及層\ruby{}{ぼく}はもう大コモクカ軟毎ホアヲト極書た球87本野ぎレべ襲画売ぎ関負ら断紀チラネキ質、紋キタ資私トゃふん。江コキトサ狂毎現ンづ応通サシ続36島性84界ぼゆゃが実書ちぽふず辞躍事シ世図二ハス盛堀\ruby{}{はや}く人わレをう第紙きかイの浅69乳キメタ事争つょお\ruby{}{やす}みなさい社以ヨナム法例やほにル済療にしいむ。子け記多ゅくよ正役モ母憲ト\ruby{}{}る。ぞ説帝け務賞ク付打ワナ内桁ぼでクフ因倒おふフ印気地レタケマ冬4雇各裁微ひるぼ。

事ーやずお両遇ほがお職喜じきちそ経岡ウナオケ型児てきろ置実イハ隊留社びか車斉ムマ数今せぴさし都聞最へぼう康自コミニク月言ム検代捕ぶねやう。6本うげがぎ無多シワソ多転のづが加分がど臣次オモエヱ務教すそ必組テタレソhello, nice to meet you極渡げフ資聞ぽへトづ禁昔キイウニ食度地ヱ考性ユエ内生ヱセ音94党と経陸咲幼勤りだフ。83男融録ょもな氷社くにルべ害変でおけう変世7超キ減安リヌ株崎5転理済ほだをな黒府コワスソ地賢堂衛イぶにし。

広げがぴ視立ス位心もスわ止想ツクケラ産竹聞ヌ落38判境ノア賞7写カチ華供ソミワ名認ばゆずほ始色らふひも属対73写けで止突兄呂びの。策イルリヘ行十織キヘ興必む万初ゃづは勝米い館独ム感一チヒナ希8写タムシイ室情づがい焼殺つか広質トクロ毎新ソモ患関済えめね働表め白告こリあ杯困摘屈裂れ。

名テホユ稿国む生覧ヨナケヤ文6垣めこル社2市むあし保止転済ノ問判りッ集員セワ全宣コ森領で温子うラちぎ夏査せすむ来資ニ面三わぼ際6之減喰杜き。堂ヲ賞了かえー単惑イめ秋投クツ意拡平ヘタヱ時83死れる互武ぽほ拉51届ニネラヘ掲団ヨ度両議ク。状親日値ル断大示ヘニコク米界を連禁イが性正ルッ問句サルユ試片サロヤ前毎到くぜ黄雑らりえ報同ょきむ督晴岡確たごげむ。

両おぎゅら写合ル書殖だインぎ孝自氷ばぞひ事権ウノレヲ少止ヲマヨミ惑磁ぞくゅ竹月おやま手51質サム付2仏い職断年にーばざ場現ムワホ襲印講行否えうご。5帰7報ク用講ルのよす媛表サシメマ札変ナヲ案積出ソトマセ決情注モハイ際県らぶドご食績どはあだ徳増フシ断県ぼね了件親億かゆ。申府ホ線全る訪親ケヒネ芸比歳よをづう供記モケ正同とき練1紀ゅくふい割市ざ著法べちめせ客答ヤヌキオ入朗ルヌカス況写天境月郎ろたづ。

想ネシモヤ人時ワ化新リぱイこ京希っじ索視ケア風月受マカ東初ぞ月公て無速だ文保か受4香刃尿憎潔だクばづ。果テカ川程イ相安べろ方4映チ米闘ヤタレ会民クをづい治果とルせ字社かイよ新軍こ持芸ワラウケ掲三58治館壌ゃ。行びまむ快野分真タネス応住えじで半記キネト正6者理ぼあ面出ヱシレワ慎首レトアハ託展オ良育圏ーを申傷説ひよもぶ索構を持試奇拝括ぱふ。

写みを参念タ三辞よルさき想3込ぜトリ会図ロ法部じち之杉ぎば厳近ワオコ光傷治ワ整区童熊習本さはリん。一ナカヒハ経松隊整キメケト需湖モユエウ秘千そ含覧ふリさ挙言ねをク凍誉ょい利際ゃぼの織用ユリル育4緊ご選1面とし胃危雪異みのひき。竹品ハ著供うげル島該ょ城豊ぎすご腹独べじり皆5座わーう化著式サマ木陸ミレノ義軍80鯨ヒキトフ読大フニノネ読覧ロヨヤイ投時ょうす都活きっみざ。

\stopsubject

\startsubject [title={が心三いむ}]

上なラ済経ロ有実マ乳装ざなぴま武1守い掲6町ぼ禁28担惑らばんフ社策送案物んまへ。人際クょゃね験伝め念変クマヌ白馳ナツエヤ著側ッごフぞ済川さ趣載ツア挙85適クウネレ稿並ドむわの論棋ナソスヒ教伎締潤革フ。球尊話者が心三いむり達尼スか町過ミタオ上止ワカヤ正着ざぱぎぼ失成行偽ワマヘ北奮く。

済開ぼスじと力紹オア手混チコ成意コテモケ定因ド情最どいとづ写今えりめ問景ルオフチ度自す作12行トヱワ録消ひイ。縦右で後賞たじつド諸場後し面詐でばト題社のれふた」。年結すたぜじ下労リえたゅ高作セレテ給5山ワ任共ご京前ミレシ本写午吉活ぽし。播るせ部3席ヒ投揮ぴしんけ安図んき同更展将ごさぽ画9用サキ購21十ツヘト京締乱僕ろ。

図ラ象45韓ど考小ヌニ野初ムユイシ河止中ヤトキヒ巻女ッ除稿イ輔余た研弔カ被悪テヘ業購ヘタ詳支ルれ身日だがん出療ずー盛趣なばぐ離女放佳怖れずへ。理じかぐ討15枠制8五袋ヒク選会ソアシカ主手付みとこ猪月メ語経マオヱミ社接フセユア幌財ー香口衆ンろ著瀬なこン身個供悪射窃どスあ。切テセ重購ニホ覧権じゆむげ影文ヒヘ相断66哉ノホテフ黒植くね氏員更あきぱゆ文記ふわひ載更上ぜいひば。

\stopsubject

\stoptitle

\stopmycolumns


%\showlayout %for Debugging, to be commented out later

\stoptext

Setup for Chinese

Get inspirated with importing Chinese fonts with this script.

  1. You need some Chinese (TrueType) fonts; you may want to get for example Microsoft Truetype fonts:
    1. STSong,
    2. STZhongsong,
    3. STXihei,
    4. STKaiti,
    5. STFangsong.
  2. Example of some basic document with enabled Chinese:
\mainlanguage[cn]
\language[cn]
\setscript[hanzi] % hyphenation

% Enable fonts
\usetypescriptfile[mscore]
\setupbodyfont [mschinese,12pt]
\usebodyfont   [mschinese-light,12pt]
\definebodyfontenvironment[24pt]
\definebodyfontenvironment[18pt]

\setuppagenumber [numberconversion=cn]
\definestructureconversionset[chinese][numbers][cn]
\setupheads [sectionconversionset=chinese]

\define[2]\ChineseChapter{#1章 #2}
\setuphead[chapter][command=\ChineseChapter,style={\bf\switchtobodyfont[24pt]}]
\setuphead[section][style={\bf\switchtobodyfont[18pt]}]

\setuppagenumbering[state=start,
    alternative=singlesided,
    location={footer, center},
    style={\bf\switchtobodyfont[11pt]}
]

\starttext
\chapter{华文字体系列}
 
在微软提供的 Office 套装中附带了一定数量的中文字体,这些字体是常州华文印刷新技术有限公司制造的。

\startitemize
\item \type{\it}: {\it 华文仿宋}
\item \type{\rm}: {\rm 华文仿宋}
\item \type{\bf}: {\bf 华文中宋}
\item \type{\ss}: {\ss 华文细黑}
\item \type{\tfxx}: {\tfxx 华文仿宋}
\item \type{\tfx}: {\tfx 华文仿宋}
\item \type{\tf}: {\tf 华文仿宋}
\item \type{\tfa}: {\tfa 华文仿宋}
\item \type{\tfb}: {\tfb  华文仿宋}
\item \type{\tfc}: {\tfc 华文仿宋}
\item \type{\tfd}: {\tfd 华文仿宋}
\stopitemize
\stoptext

Setup for Korean

You need fonts which contain hangul characters (don’t forget to set a math font because it is used for the symbols in enumerations) and you have to enable linebreaking for Korean with the \setscript command.

% Wolfgang Schuster 2017-12-06
\mainlanguage[kr]

\definefallbackfamily [mainface] [rm] [Nanum Myeongjo] [preset=range:korean]
\definefontfamily     [mainface] [rm] [DejaVu Serif]

\definefallbackfamily [mainface] [ss] [Nanum Gothic] [preset=range:korean]
\definefontfamily     [mainface] [ss] [DejaVu Sans]

\definefallbackfamily [mainface] [tt] [Nanum Gothic Coding] [features=none,preset=range:korean]
\definefontfamily     [mainface] [tt] [DejaVu Sans Mono] [features=none]

\definefontfamily     [mainface] [mm] [DejaVu Math]

\setupbodyfont[mainface]

\setscript[hangul]

\starttext

이 FAQ 은 자주 반복되는 질문과 그에 대한 대답을 간단명료한 양식으로
모아 엮어졌습니다.

{\ss 이 FAQ 은 자주 반복되는 질문과 그에 대한 대답을 간단명료한 양식으로
모아 엮어졌습니다.}

\starttyping
이 FAQ 은 자주 반복되는 질문과 그에 대한 대답을 간단명료한 양식으로
모아 엮어졌습니다.
\stoptyping

\stoptext

Outdated

See also