Changes

Jump to navigation Jump to search
Added: Meeting the JIS X 4051 Requirements for Japanese Text Layout
\ruby{早}{はや}く。
いきましょう。
\stoptext
</texcode>
 
==Meeting the JIS X 4051 Requirements for Japanese Text Layout==
The requirements are described here: 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)
<texcode>
%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
</texcode>
12

edits

Navigation menu