diff --git a/assets/mods/basegame/books/btex.xml b/assets/mods/basegame/books/btex.xml
index 15f9af456..9dd5ebf28 100644
--- a/assets/mods/basegame/books/btex.xml
+++ b/assets/mods/basegame/books/btex.xml
@@ -109,7 +109,7 @@
part — inserts part separation page to your book
chapter, section — inserts a new chapter/section. If an alternative name is required on the Table of Contents, the alt attribute can be used. If the chapter/section needs to be hidden on the Table of Contents, add the hide="1" attribute. If the chapter must start on a new page, simply add newpage in front of the chapter tag
p — inserts a new paragraph. The body texts must be written inside this tag. All paragraphs will have a 16-pixel indentation, with the following exceptions: first p of the part/chapter/section; first p after br, newpage, callout, ul, ol or anonbreak
- span — allows changing the colour or the style of the texts. The colour must be specified in the colour attribute. Six-digit hex code, three-digit hex code and CSS Colors Level 4 named colours are supported. Note that all the colours will be rounded to the nearest three-digit hex code
+ span — allows changing the colour or the style of the texts. The colour must be specified in the colour attribute. Six-digit hex code, three-digit hex code and CSS Colours Level 4 named colours are supported. Note that all the colours will be rounded to the nearest three-digit hex code
emph — is a special case of the span tag. The resulting text will be red
itemname — is a special case of the span tag used to highlight the name of the ingame item. The resulting text will be blue
targetname — is a special case of the span tag used to highlight the name of an arbitrary target or goals. The resulting text will be green
@@ -211,14 +211,22 @@
thepart — Part heading. Default: Part %1$s
+ parttype — Default style of the part tag. Default: I
thechapter — Chapter heading. Default: %1$s
+ parttype — Default style of the chapter tag. Default: 1
The argument key %1$s will be replaced into a number, Roman numerals, etc.
depending on the value of type attribute.
These macros can be used to localise the chapter headings for your language. For example,
- in Korean text, you might want to change thechapter into %1$s장.
+ in Korean text, the following idiomatic definition will be useful:
+
+ <macrodef>
<pair key="thepart" value="제%1$s부"/>
<pair key="parttype" value="1"/>
<pair key="thechapter" value="%1$s장"/>
</macrodef>
Printing External Variables
diff --git a/assets/mods/basegame/books/btex_ko.xml b/assets/mods/basegame/books/btex_ko.xml
index 90bcdeb33..f499a7cf7 100644
--- a/assets/mods/basegame/books/btex_ko.xml
+++ b/assets/mods/basegame/books/btex_ko.xml
@@ -3,6 +3,7 @@
+
@@ -15,7 +16,7 @@
- 책
+ 책
책이란 무엇인가
@@ -40,7 +41,7 @@
을 통하며 책 전체의 생김새를 간단히 기술할 수 있다. 사용할 수 있는 스타일은 조판 시스템이 지원하는 범위 안에서 제약이 없다. 타자기로 찍어낸 듯한 글도 원한다면 얼마든지 인쇄되도록 할 수 있다.
-
+
소개
@@ -104,7 +105,7 @@
part — 원고에 새 부(part)를 추가함
chapter, section — 원고에 새 장(chapter)·절(section)을 추가함. 목차 페이지에는 다른 이름을 표시하고 싶다면 alt 속성을 사용할 수 있음. 목차 페이지에서 숨기고 싶다면 hide="1" 속성을 추가할 것. 장이 새 페이지에서 시작되게 하려면 chapter 태그 앞에 newpage를 추가할 것
p — 새 문단을 삽입함. 본문의 글은 반드시 이 태그 내부에 작성되어야 함. 모든 문단는 16픽셀의 들여쓰기로 조판되나, 다음의 경우 들여쓰기가 적용되지 않음: 부·장·절의 첫 문단, br, newpage, callout, ul, ol, anonbreak 태그 직후의 문단
- span — 문구의 색상이나 스타일을 변경함. 색상은 colour 속성에 작성되어야 함. 6자리 헥스코드, 3자리 헥스코드, CSS Colour Level 4에 정의된 색상명을 사용할 수 있음. 모든 색상은 내부적으로 가장 가까운 3자리 헥스코드로 변경됨에 유의할 것
+ span — 문구의 색상이나 스타일을 변경함. 색상은 colour 속성에 작성되어야 함. 6자리 헥스코드, 3자리 헥스코드, CSS Colours Level 4에 정의된 색상명을 사용할 수 있음. 모든 색상은 내부적으로 가장 가까운 3자리 헥스코드로 변경됨에 유의할 것
emph — span의 특수한 경우로, 문구를 빨간색으로 인자함
itemname — span의 특수한 경우로, 게임 내 아이템의 이름을 강조 표시할 때 사용함. 문구는 파란색으로 인자됨
targetname — span의 특수한 경우로, 임의의 목표를 강조 표시할 때 사용함. 문구는 초록색으로 인자됨
@@ -178,7 +179,7 @@
- 고급 매크로
+ 고급 매크로
매크로 정의문
@@ -198,13 +199,20 @@
thepart — 부 제목 번호. 기본값: Part %1$s
+ parttype — part 태그의 기본 스타일. 기본값: I
thechapter — 장 제목 번호. 기본값: %1$s
+ parttype — chapter 태그의 기본 스타일. 기본값: 1
매개변수인 %1$s는 각 제목의 type 속성에 따라 적절한 숫자로 치환된다.
- 이 매크로는 장제목을 원하는 언어의 스타일로 변경하는 데에 사용될 수 있다. 예를 들면 한국어 환경에서는 thechapter를 %1$s장으로 정의하는 것이 되겠다.
+ 이 매크로는 장제목을 원하는 언어의 스타일로 변경하는 데에 사용될 수 있다. 예를 들면 한국어 환경에서는 다음과 같은 정의가 바람직할 것이다.
+ <macrodef>
<pair key="thepart" value="제%1$s부"/>
<pair key="parttype" value="1"/>
<pair key="thechapter" value="%1$s장"/>
</macrodef>
외부 변수 인자하기
diff --git a/src/net/torvald/btex/BTeXDocument.kt b/src/net/torvald/btex/BTeXDocument.kt
index f35e5ae2b..e7379128c 100644
--- a/src/net/torvald/btex/BTeXDocument.kt
+++ b/src/net/torvald/btex/BTeXDocument.kt
@@ -150,6 +150,8 @@ class BTeXDocument : Disposable {
if (fromArchive) throw IllegalStateException("Document is loaded from the archive and thus cannot be finalised")
if (isFinalised) throw IllegalStateException("Page is already been finalised")
+ // TODO serialise and finalise via CPU (store every page as Pixmap)
+
pageTextures = ArrayList()
pageFrameBuffers = ArrayList()
diff --git a/src/net/torvald/btex/BTeXParser.kt b/src/net/torvald/btex/BTeXParser.kt
index 03028aa1b..2cf65467e 100644
--- a/src/net/torvald/btex/BTeXParser.kt
+++ b/src/net/torvald/btex/BTeXParser.kt
@@ -122,6 +122,7 @@ object BTeXParser {
private var coverCol: Color? = null
private lateinit var testFont: TerrarumSansBitmap
+ private lateinit var partTitleFont: TerrarumSansBitmap
private lateinit var titleFont: TerrarumSansBitmap
private lateinit var subtitleFont: TerrarumSansBitmap
@@ -129,7 +130,9 @@ object BTeXParser {
private val macrodefs = hashMapOf(
"thepart" to "Part %1\$s",
- "thechapter" to "%1\$s"
+ "parttype" to "I",
+ "thechapter" to "%1\$s",
+ "chaptertype" to "1"
)
private fun invokeMacro(name: String, vararg args: String): String {
@@ -211,6 +214,7 @@ object BTeXParser {
fun dispose() {
if (::testFont.isInitialized) testFont.tryDispose()
if (::titleFont.isInitialized) titleFont.tryDispose()
+ if (::partTitleFont.isInitialized) partTitleFont.tryDispose()
if (::subtitleFont.isInitialized) subtitleFont.tryDispose()
}
@@ -359,6 +363,13 @@ object BTeXParser {
}
}
+ private fun getPartTitleFont(): TerrarumSansBitmap {
+ if (!::partTitleFont.isInitialized) partTitleFont = TerrarumSansBitmap(App.FONT_DIR, shadowAlpha = bodyTextShadowAlpha).also {
+ it.interchar = 1
+ }
+ return partTitleFont
+ }
+
private fun getTitleFont(): TerrarumSansBitmap {
if (!::titleFont.isInitialized) titleFont = TerrarumSansBitmap(App.FONT_DIR).also {
it.interchar = 1
@@ -1119,18 +1130,18 @@ object BTeXParser {
clearParBuffer()
if (attribs["hide"] == null)
- cptSectStack.add(CptSect("part", attribs["alt"], attribs["type"] ?: "I", attribs["start"]?.toInt()))
+ cptSectStack.add(CptSect("part", attribs["alt"], attribs["type"] ?: macrodefs["parttype"]!!, attribs["start"]?.toInt()))
else
- cptSectStack.add(CptSect("part-hidden", attribs["alt"], attribs["type"] ?: "I", attribs["start"]?.toInt()))
+ cptSectStack.add(CptSect("part-hidden", attribs["alt"], attribs["type"] ?: macrodefs["parttype"]!!, attribs["start"]?.toInt()))
}
@OpenTag // reflective access is impossible with 'private'
fun processElemCHAPTER(handler: BTeXHandler, doc: BTeXDocument, uri: String, attribs: HashMap) {
clearParBuffer()
if (attribs["hide"] == null)
- cptSectStack.add(CptSect("chapter", attribs["alt"], attribs["type"] ?: "1", attribs["start"]?.toInt()))
+ cptSectStack.add(CptSect("chapter", attribs["alt"], attribs["type"] ?: macrodefs["chaptertype"]!!, attribs["start"]?.toInt()))
else
- cptSectStack.add(CptSect("chapter-hidden", attribs["alt"], attribs["type"] ?: "1", attribs["start"]?.toInt()))
+ cptSectStack.add(CptSect("chapter-hidden", attribs["alt"], attribs["type"] ?: macrodefs["chaptertype"]!!, attribs["start"]?.toInt()))
}
@OpenTag // reflective access is impossible with 'private'
fun processElemSECTION(handler: BTeXHandler, doc: BTeXDocument, uri: String, attribs: HashMap) {
@@ -1304,7 +1315,7 @@ object BTeXParser {
private fun typesetPartHeading(num: String, thePar: String, handler: BTeXHandler, indent: Int = PAR_INDENTATION, width: Int = doc.textWidth) {
typesetParagraphs("${ccDefault}⁃ $num ⁃", handler, align = "left")
typesetParagraphs(" ", handler, align = "left")
- typesetParagraphs(getSubtitleFont(), "$ccDefault$thePar", handler, align = "left")
+ typesetParagraphs(getPartTitleFont(), "$ccDefault$thePar", handler, align = "left")
// get global yDelta
doc.currentPageObj.let { page ->
diff --git a/src/net/torvald/terrarum/tests/BTeXTest.kt b/src/net/torvald/terrarum/tests/BTeXTest.kt
index f70f2021d..d6529c68f 100644
--- a/src/net/torvald/terrarum/tests/BTeXTest.kt
+++ b/src/net/torvald/terrarum/tests/BTeXTest.kt
@@ -24,7 +24,7 @@ import kotlin.system.measureTimeMillis
*/
class BTeXTest : ApplicationAdapter() {
- val filePath = "btex.xml"
+ val filePath = "btex_ko.xml"
// val filePath = "test.xml"
// val filePath = "literature/en/daniel_defoe_robinson_crusoe.btxbook"
// val filePath = "literature/ruRU/anton_chekhov_palata_no_6.xml"