mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-12 03:24:06 +09:00
fix: btex toc overflow
This commit is contained in:
@@ -160,6 +160,24 @@
|
|||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
<section>Figures</section>
|
||||||
|
|
||||||
|
<p>Figures, or external images can be inserted using the self-closing <code>img</code> tag.
|
||||||
|
This tag inserts the image starting from the current line; if the size is taller than the
|
||||||
|
remaining lines, the image will be printed onto the next page. Its syntax is as follows:</p>
|
||||||
|
|
||||||
|
<callout align="left" class="code"><!--
|
||||||
|
--><img src="web URL" height="8"/><br/><!--
|
||||||
|
--><img fromgame="basegame:gui/small.png" height="4"/><br/><!--
|
||||||
|
--><img gameitem="basegame:33" height="1"/>
|
||||||
|
</callout>
|
||||||
|
|
||||||
|
<p>The <code>height</code> attribute specifies the height of the image <emph>in the number of lines</emph>,
|
||||||
|
rather than pixels.</p>
|
||||||
|
|
||||||
|
<p>Supported image formats: JPEG, PNG, BMP or TGA</p>
|
||||||
|
|
||||||
|
|
||||||
<chapter>The Index Page</chapter>
|
<chapter>The Index Page</chapter>
|
||||||
|
|
||||||
<p><index id="index page"/>The contents of the Index Page is filled in automatically by reading through your manuscript.
|
<p><index id="index page"/>The contents of the Index Page is filled in automatically by reading through your manuscript.
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import com.badlogic.gdx.graphics.*
|
|||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||||
import com.badlogic.gdx.utils.Disposable
|
import com.badlogic.gdx.utils.Disposable
|
||||||
import net.torvald.terrarum.FlippingSpriteBatch
|
|
||||||
import net.torvald.terrarum.ceilToInt
|
import net.torvald.terrarum.ceilToInt
|
||||||
import net.torvald.terrarum.concurrent.ThreadExecutor
|
import net.torvald.terrarum.concurrent.ThreadExecutor
|
||||||
import net.torvald.terrarum.imagefont.TinyAlphNum
|
import net.torvald.terrarum.imagefont.TinyAlphNum
|
||||||
|
|||||||
@@ -792,10 +792,11 @@ object BTeXParser {
|
|||||||
if (tocPage != null) {
|
if (tocPage != null) {
|
||||||
// estimate the number of TOC pages
|
// estimate the number of TOC pages
|
||||||
// TOC page always takes up a full paper, therefore tocSizeInPages is always multiple of 2
|
// TOC page always takes up a full paper, therefore tocSizeInPages is always multiple of 2
|
||||||
var tocSizeInPages = (cptSectMap.size + 2) / doc.pageLines
|
var tocSizeInPages = ((cptSectMap.size + 2f) / doc.pageLines).ceilToInt()
|
||||||
if (tocSizeInPages == 0) tocSizeInPages = 2
|
if (tocSizeInPages == 0) tocSizeInPages = 2
|
||||||
if (tocSizeInPages % 2 == 1) tocSizeInPages += 1
|
if (tocSizeInPages % 2 == 1) tocSizeInPages += 1
|
||||||
|
|
||||||
|
println("TOC number of entries: ${cptSectMap.size}, estimated page count: $tocSizeInPages")
|
||||||
|
|
||||||
// renumber things
|
// renumber things
|
||||||
if (tocSizeInPages > 1) {
|
if (tocSizeInPages > 1) {
|
||||||
@@ -812,6 +813,7 @@ object BTeXParser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var currentTOCpage = tocPage!!
|
||||||
cptSectMap.forEach { (type, name, pg, part, cpt, sect) ->
|
cptSectMap.forEach { (type, name, pg, part, cpt, sect) ->
|
||||||
val indent = if (type == "subsection") 2*PAR_INDENTATION else if (type == "section") PAR_INDENTATION else 0
|
val indent = if (type == "subsection") 2*PAR_INDENTATION else if (type == "section") PAR_INDENTATION else 0
|
||||||
val heading = if (part == null && cpt == null && sect == null)
|
val heading = if (part == null && cpt == null && sect == null)
|
||||||
@@ -823,7 +825,11 @@ object BTeXParser {
|
|||||||
else
|
else
|
||||||
"$cpt.$sect${spacingBlockToString(HEADING_NUM_TITLE_GAP)}"
|
"$cpt.$sect${spacingBlockToString(HEADING_NUM_TITLE_GAP)}"
|
||||||
|
|
||||||
typesetTOCline("$heading", name, pg, handler, indent, tocPage)
|
typesetTOCline("$heading", name, pg, handler, indent, currentTOCpage)
|
||||||
|
|
||||||
|
if (doc.linesPrintedOnPage[currentTOCpage] >= doc.pageLines) {
|
||||||
|
currentTOCpage += 1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1728,7 +1734,7 @@ object BTeXParser {
|
|||||||
|
|
||||||
val ccDefault = TerrarumSansBitmap.toColorCode(0,0,0)
|
val ccDefault = TerrarumSansBitmap.toColorCode(0,0,0)
|
||||||
val ccBucks = TerrarumSansBitmap.toColorCode(5,0,0)
|
val ccBucks = TerrarumSansBitmap.toColorCode(5,0,0)
|
||||||
val ccCode = TerrarumSansBitmap.toColorCode(8,0,0)
|
val ccCode = TerrarumSansBitmap.toColorCode(7,0,0)
|
||||||
val ccHref = TerrarumSansBitmap.toColorCode(0,3,11)
|
val ccHref = TerrarumSansBitmap.toColorCode(0,3,11)
|
||||||
val ccEmph = TerrarumSansBitmap.toColorCode(0xfc11)
|
val ccEmph = TerrarumSansBitmap.toColorCode(0xfc11)
|
||||||
val ccItemName = TerrarumSansBitmap.toColorCode(0xf03b)
|
val ccItemName = TerrarumSansBitmap.toColorCode(0xf03b)
|
||||||
|
|||||||
@@ -26,9 +26,10 @@ import kotlin.system.measureTimeMillis
|
|||||||
*/
|
*/
|
||||||
class BTeXTest : ApplicationAdapter() {
|
class BTeXTest : ApplicationAdapter() {
|
||||||
|
|
||||||
|
val filePath = "btex.xml"
|
||||||
// val filePath = "btex_ko.xml"
|
// val filePath = "btex_ko.xml"
|
||||||
// val filePath = "test.xml"
|
// val filePath = "test.xml"
|
||||||
val filePath = "literature/en/daniel_defoe_robinson_crusoe.xml"
|
// val filePath = "literature/en/daniel_defoe_robinson_crusoe.xml"
|
||||||
// val filePath = "literature/ruRU/anton_chekhov_palata_no_6.xml"
|
// val filePath = "literature/ruRU/anton_chekhov_palata_no_6.xml"
|
||||||
// val filePath = "literature/koKR/yisang_nalgae.btxbook"
|
// val filePath = "literature/koKR/yisang_nalgae.btxbook"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user