mirror of
https://github.com/curioustorvald/Terrarum-sans-bitmap.git
synced 2026-03-07 11:51:50 +09:00
improved shadowing perf at the cost of reduced quality
black text on white background should work now
This commit is contained in:
1
.idea/libraries/GdxLib.xml
generated
1
.idea/libraries/GdxLib.xml
generated
@@ -9,6 +9,7 @@
|
||||
</NATIVE>
|
||||
<SOURCES>
|
||||
<root url="file://$PROJECT_DIR$/lib" />
|
||||
<root url="jar://$PROJECT_DIR$/lib/gdx.jar!/" />
|
||||
</SOURCES>
|
||||
<jarDirectory url="file://$PROJECT_DIR$/lib" recursive="false" />
|
||||
<jarDirectory url="file://$PROJECT_DIR$/lib" recursive="false" type="SOURCES" />
|
||||
|
||||
115
.idea/workspace.xml
generated
115
.idea/workspace.xml
generated
@@ -7,9 +7,11 @@
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="22c5bc80-996c-4846-b173-7dc8c2096fe3" name="Default" comment="">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/libraries/GdxLib.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/libraries/GdxLib.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/CONTRIBUTING.md" beforeDir="false" afterPath="$PROJECT_DIR$/CONTRIBUTING.md" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/FontTestGDX/lib/TerrarumSansBitmap.jar" beforeDir="false" afterPath="$PROJECT_DIR$/FontTestGDX/lib/TerrarumSansBitmap.jar" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/TerrarumSansBitmap.jar" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/demo.PNG" beforeDir="false" afterPath="$PROJECT_DIR$/demo.PNG" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/gdx/GameFontBase.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/gdx/GameFontBase.kt" afterDir="false" />
|
||||
</list>
|
||||
<ignored path="$PROJECT_DIR$/out/" />
|
||||
@@ -30,8 +32,8 @@
|
||||
<file leaf-file-name="GameFontBase.kt" pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/gdx/GameFontBase.kt">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="313">
|
||||
<caret line="726" lean-forward="true" selection-start-line="726" selection-end-line="726" />
|
||||
<state relative-caret-position="468">
|
||||
<caret line="673" column="29" selection-start-line="673" selection-start-column="29" selection-end-line="673" selection-end-column="29" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
@@ -79,16 +81,16 @@
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="demo.PNG" pinned="false" current-in-tab="true">
|
||||
<file leaf-file-name="demo.PNG" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/demo.PNG">
|
||||
<provider selected="true" editor-type-id="images" />
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="GameFontBase.kt" pinned="false" current-in-tab="false">
|
||||
<file leaf-file-name="GameFontBase.kt" pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/gdx/GameFontBase.kt">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="-190">
|
||||
<caret line="624" column="40" selection-start-line="624" selection-start-column="28" selection-end-line="624" selection-end-column="40" />
|
||||
<state relative-caret-position="435">
|
||||
<caret line="481" column="13" lean-forward="true" selection-start-line="481" selection-start-column="13" selection-end-line="481" selection-end-column="13" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
@@ -115,8 +117,8 @@
|
||||
<entry file="file://$PROJECT_DIR$/CONTRIBUTING.md">
|
||||
<provider selected="true" editor-type-id="split-provider[text-editor;MarkdownPreviewEditor]">
|
||||
<state split_layout="FIRST">
|
||||
<first_editor relative-caret-position="1222">
|
||||
<caret line="94" column="176" selection-start-line="94" selection-start-column="176" selection-end-line="94" selection-end-column="176" />
|
||||
<first_editor relative-caret-position="611">
|
||||
<caret line="95" column="30" selection-start-line="95" selection-start-column="30" selection-end-line="95" selection-end-column="30" />
|
||||
</first_editor>
|
||||
<second_editor>
|
||||
<js_state />
|
||||
@@ -161,7 +163,6 @@
|
||||
</component>
|
||||
<component name="FindInProjectRecents">
|
||||
<findStrings>
|
||||
<find>buildWidthTable</find>
|
||||
<find>lastNonDiacriticChar</find>
|
||||
<find>c.toInt()</find>
|
||||
<find>har.toInt()</find>
|
||||
@@ -191,6 +192,7 @@
|
||||
<find>xySw</find>
|
||||
<find>getWidth</find>
|
||||
<find>getWidthOfCharSeq</find>
|
||||
<find>makeShadow</find>
|
||||
</findStrings>
|
||||
<replaceStrings>
|
||||
<replace>.141</replace>
|
||||
@@ -216,19 +218,19 @@
|
||||
<option value="$PROJECT_DIR$/CONTRIBUTORS.txt" />
|
||||
<option value="$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/GlyphProps.kt" />
|
||||
<option value="$PROJECT_DIR$/README.md" />
|
||||
<option value="$PROJECT_DIR$/CONTRIBUTING.md" />
|
||||
<option value="$PROJECT_DIR$/testtext.txt" />
|
||||
<option value="$PROJECT_DIR$/demotext.txt" />
|
||||
<option value="$PROJECT_DIR$/FontTestGDX/src/FontTestGDX.kt" />
|
||||
<option value="$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/gdx/TextureRegionPack.kt" />
|
||||
<option value="$PROJECT_DIR$/CONTRIBUTING.md" />
|
||||
<option value="$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/gdx/GameFontBase.kt" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectFrameBounds" extendedState="7">
|
||||
<option name="x" value="1974" />
|
||||
<component name="ProjectFrameBounds" extendedState="6">
|
||||
<option name="x" value="-8" />
|
||||
<option name="y" value="-8" />
|
||||
<option name="width" value="1874" />
|
||||
<option name="width" value="1936" />
|
||||
<option name="height" value="1216" />
|
||||
</component>
|
||||
<component name="ProjectView">
|
||||
@@ -282,7 +284,7 @@
|
||||
</component>
|
||||
<component name="PropertiesComponent">
|
||||
<property name="SearchEverywhereHistoryKey" value="soft wr	ACTION	EditorToggleUseSoftWraps" />
|
||||
<property name="last_opened_file_path" value="$PROJECT_DIR$/FontTestGDX" />
|
||||
<property name="last_opened_file_path" value="$PROJECT_DIR$/lib/gdx.jar!/" />
|
||||
<property name="project.structure.last.edited" value="Artifacts" />
|
||||
<property name="project.structure.proportion" value="0.15" />
|
||||
<property name="project.structure.side.proportion" value="0.32068965" />
|
||||
@@ -501,11 +503,11 @@
|
||||
</todo-panel>
|
||||
</component>
|
||||
<component name="ToolWindowManager">
|
||||
<frame x="1974" y="-8" width="1874" height="1216" extended-state="7" />
|
||||
<frame x="-8" y="-8" width="1936" height="1216" extended-state="6" />
|
||||
<layout>
|
||||
<window_info anchor="right" id="Palette" order="3" />
|
||||
<window_info anchor="bottom" id="TODO" order="6" />
|
||||
<window_info active="true" anchor="bottom" id="Messages" order="7" visible="true" weight="0.32745826" />
|
||||
<window_info anchor="bottom" id="Messages" order="7" weight="0.32745826" />
|
||||
<window_info anchor="right" id="Palette	" order="3" />
|
||||
<window_info anchor="bottom" id="Event Log" order="7" side_tool="true" />
|
||||
<window_info anchor="right" id="Maven Projects" order="3" />
|
||||
@@ -513,11 +515,11 @@
|
||||
<window_info anchor="bottom" id="Version Control" order="7" />
|
||||
<window_info anchor="bottom" id="Terminal" order="7" />
|
||||
<window_info id="Designer" order="2" />
|
||||
<window_info content_ui="combo" id="Project" order="0" weight="0.090959206" />
|
||||
<window_info content_ui="combo" id="Project" order="0" weight="0.090618335" />
|
||||
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
|
||||
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
|
||||
<window_info id="UI Designer" order="2" />
|
||||
<window_info anchor="bottom" id="Debug" order="3" weight="0.2773655" />
|
||||
<window_info active="true" anchor="bottom" id="Debug" order="3" visible="true" weight="0.2773655" />
|
||||
<window_info id="Favorites" order="2" side_tool="true" />
|
||||
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
|
||||
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
|
||||
@@ -564,25 +566,6 @@
|
||||
<option name="FILTER_TARGETS" value="false" />
|
||||
</component>
|
||||
<component name="editorHistoryManager">
|
||||
<entry file="file://$PROJECT_DIR$/README.md">
|
||||
<provider selected="true" editor-type-id="split-provider[text-editor;MarkdownPreviewEditor]">
|
||||
<state split_layout="SPLIT">
|
||||
<first_editor relative-caret-position="1404">
|
||||
<caret line="108" lean-forward="true" selection-start-line="108" selection-end-line="108" />
|
||||
</first_editor>
|
||||
<second_editor>
|
||||
<js_state />
|
||||
</second_editor>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/slick2d/GameFontBase.kt">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="6071">
|
||||
<caret line="531" column="21" selection-start-line="531" selection-start-column="21" selection-end-line="531" selection-end-column="21" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/FontTestGDX/src/FontTestGDX.kt">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="1638">
|
||||
@@ -876,18 +859,6 @@
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/CONTRIBUTING.md">
|
||||
<provider selected="true" editor-type-id="split-provider[text-editor;MarkdownPreviewEditor]">
|
||||
<state split_layout="FIRST">
|
||||
<first_editor relative-caret-position="1222">
|
||||
<caret line="94" column="176" selection-start-line="94" selection-start-column="176" selection-end-line="94" selection-end-column="176" />
|
||||
</first_editor>
|
||||
<second_editor>
|
||||
<js_state />
|
||||
</second_editor>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/testtext.txt">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="117">
|
||||
@@ -912,6 +883,43 @@
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/CONTRIBUTING.md">
|
||||
<provider selected="true" editor-type-id="split-provider[text-editor;MarkdownPreviewEditor]">
|
||||
<state split_layout="FIRST">
|
||||
<first_editor relative-caret-position="611">
|
||||
<caret line="95" column="30" selection-start-line="95" selection-start-column="30" selection-end-line="95" selection-end-column="30" />
|
||||
</first_editor>
|
||||
<second_editor>
|
||||
<js_state />
|
||||
</second_editor>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="jar://$PROJECT_DIR$/lib/gdx.jar!/com/badlogic/gdx/graphics/g2d/Gdx2DPixmap.class">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="356">
|
||||
<caret line="152" column="16" selection-start-line="152" selection-start-column="16" selection-end-line="152" selection-end-column="16" />
|
||||
<folding>
|
||||
<element signature="e#4947#4948#0" expanded="true" />
|
||||
<element signature="e#4998#4999#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="jar://$PROJECT_DIR$/lib/gdx.jar!/com/badlogic/gdx/graphics/Pixmap.class">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="356">
|
||||
<caret line="118" column="15" selection-start-line="118" selection-start-column="15" selection-end-line="118" selection-end-column="15" />
|
||||
<folding>
|
||||
<element signature="e#3882#3883#0" expanded="true" />
|
||||
<element signature="e#3931#3932#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/demo.PNG">
|
||||
<provider selected="true" editor-type-id="images" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/FontTestGDX/src/FontTestGDX.kt">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="429">
|
||||
@@ -922,13 +930,10 @@
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/demo.PNG">
|
||||
<provider selected="true" editor-type-id="images" />
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarumsansbitmap/gdx/GameFontBase.kt">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="313">
|
||||
<caret line="726" lean-forward="true" selection-start-line="726" selection-end-line="726" />
|
||||
<state relative-caret-position="435">
|
||||
<caret line="481" column="13" lean-forward="true" selection-start-line="481" selection-start-column="13" selection-end-line="481" selection-end-column="13" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
|
||||
@@ -93,6 +93,7 @@ Also note that the font compiler will not "stack" these diacritics.
|
||||
|
||||
- Each spritesheet is 4096x4096 maximum, which is a size of 4K Texture. However it is recommended to be smaller or equal to 1024x1024.
|
||||
- Glyphs exceeding 15px of width needs to be broken down with 2 or more characters. Wider sheets WILL NOT BE IMPLEMENTED, can't waste much pixels just for few superwide glyphs.
|
||||
- Due to how the compiler is coded, actual glyph must have alpha value of 255, the tags must have alpha values LESS THAN 255 (and obviously greater than zero). RGB plane of the TGA image doesn't do anything, keep it as #FFFFFF white.
|
||||
|
||||
### Implementing the Korean writing system
|
||||
|
||||
|
||||
Binary file not shown.
BIN
demo.PNG
BIN
demo.PNG
Binary file not shown.
|
Before Width: | Height: | Size: 138 KiB After Width: | Height: | Size: 145 KiB |
@@ -460,11 +460,15 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (isVariable) buildWidthTable(pixmap, codeRange[index], 16)
|
||||
buildWidthTableFixed()
|
||||
|
||||
|
||||
if (!noShadow) {
|
||||
makeShadow(pixmap)
|
||||
}
|
||||
|
||||
|
||||
val texture = Texture(pixmap)
|
||||
val texRegPack = if (isVariable) {
|
||||
TextureRegionPack(texture, W_VAR_INIT, H, HGAP_VAR, 0, xySwapped = isXYSwapped)
|
||||
@@ -576,7 +580,6 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
|
||||
|
||||
originalColour = batch.color.cpy()
|
||||
var mainCol = originalColour
|
||||
var shadowCol = mainCol.cpy().mul(0.5f, 0.5f, 0.5f, 1f)
|
||||
|
||||
|
||||
//textTexture.begin()
|
||||
@@ -586,136 +589,81 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
|
||||
//println()
|
||||
|
||||
|
||||
val runs = if (noShadow) 0..0 else 3 downTo 0
|
||||
for (run in runs) { // 0: Main, 1..3: Shadows
|
||||
resetHash()
|
||||
var index = 0
|
||||
while (index <= textBuffer.lastIndex) {
|
||||
val c = textBuffer[index]
|
||||
val sheetID = getSheetType(c)
|
||||
val (sheetX, sheetY) =
|
||||
if (index == 0) getSheetwisePosition(0, c)
|
||||
else getSheetwisePosition(textBuffer[index - 1], c)
|
||||
val hash = getHash(c)
|
||||
|
||||
if (run == 0) {
|
||||
//println("[TerrarumSansBitmap] sprite: $sheetID:${sheetX}x${sheetY}")
|
||||
}
|
||||
|
||||
|
||||
if (isColourCode(c)) {
|
||||
if (c == 0x100000) {
|
||||
mainCol = originalColour
|
||||
shadowCol = mainCol.cpy().mul(0.5f, 0.5f, 0.5f, 1f)
|
||||
}
|
||||
else {
|
||||
mainCol = getColour(c)
|
||||
shadowCol = mainCol.cpy().mul(0.5f, 0.5f, 0.5f, 1f)
|
||||
}
|
||||
}
|
||||
else if (isCharsetOverride(c)) {
|
||||
charsetOverride = c - CHARSET_OVERRIDE_DEFAULT
|
||||
}
|
||||
else if (sheetID == SHEET_HANGUL) {
|
||||
// Flookahead for {I, P, F}
|
||||
|
||||
val cNext = if (index + 1 < textBuffer.size) textBuffer[index + 1] else 0
|
||||
val cNextNext = if (index + 2 < textBuffer.size) textBuffer[index + 2] else 0
|
||||
|
||||
val hangulLength = if (isHangulJongseong(cNextNext) && isHangulJungseong(cNext))
|
||||
3
|
||||
else if (isHangulJungseong(cNext))
|
||||
2
|
||||
else
|
||||
1
|
||||
|
||||
val (indices, rows) = toHangulIndexAndRow(c, cNext, cNextNext)
|
||||
|
||||
val (indexCho, indexJung, indexJong) = indices
|
||||
val (choRow, jungRow, jongRow) = rows
|
||||
val hangulSheet = sheets[SHEET_HANGUL]
|
||||
|
||||
|
||||
//println("${c.toHex()} ${cNext.toHex()} ${cNextNext.toHex()}")
|
||||
//println("I: $indexCho,\t$choRow")
|
||||
//println("P: $indexJung,\t$jungRow")
|
||||
//println("F: $indexJong,\t$jongRow")
|
||||
//println("skip: $hangulLength")
|
||||
//println("====")
|
||||
|
||||
|
||||
when (run) {
|
||||
0 -> {
|
||||
batch.color = mainCol
|
||||
batch.draw(hangulSheet.get(indexCho, choRow), x + posXbuffer[index].toFloat(), y)
|
||||
batch.draw(hangulSheet.get(indexJung, jungRow), x + posXbuffer[index].toFloat(), y)
|
||||
batch.draw(hangulSheet.get(indexJong, jongRow), x + posXbuffer[index].toFloat(), y)
|
||||
}
|
||||
1 -> {
|
||||
batch.color = shadowCol
|
||||
batch.draw(hangulSheet.get(indexCho, choRow), x + posXbuffer[index] + 1, y)
|
||||
batch.draw(hangulSheet.get(indexJung, jungRow), x + posXbuffer[index] + 1, y)
|
||||
batch.draw(hangulSheet.get(indexJong, jongRow), x + posXbuffer[index] + 1, y)
|
||||
}
|
||||
2 -> {
|
||||
batch.color = shadowCol
|
||||
batch.draw(hangulSheet.get(indexCho, choRow), x + posXbuffer[index], y + 1.flipY())
|
||||
batch.draw(hangulSheet.get(indexJung, jungRow), x + posXbuffer[index], y + 1.flipY())
|
||||
batch.draw(hangulSheet.get(indexJong, jongRow), x + posXbuffer[index], y + 1.flipY())
|
||||
}
|
||||
3 -> {
|
||||
batch.color = shadowCol
|
||||
batch.draw(hangulSheet.get(indexCho, choRow), x + posXbuffer[index] + 1, y + 1.flipY())
|
||||
batch.draw(hangulSheet.get(indexJung, jungRow), x + posXbuffer[index] + 1, y + 1.flipY())
|
||||
batch.draw(hangulSheet.get(indexJong, jongRow), x + posXbuffer[index] + 1, y + 1.flipY())
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
index += hangulLength - 1
|
||||
resetHash()
|
||||
var index = 0
|
||||
while (index <= textBuffer.lastIndex) {
|
||||
val c = textBuffer[index]
|
||||
val sheetID = getSheetType(c)
|
||||
val (sheetX, sheetY) =
|
||||
if (index == 0) getSheetwisePosition(0, c)
|
||||
else getSheetwisePosition(textBuffer[index - 1], c)
|
||||
val hash = getHash(c)
|
||||
|
||||
if (isColourCode(c)) {
|
||||
if (c == 0x100000) {
|
||||
mainCol = originalColour
|
||||
}
|
||||
else {
|
||||
try {
|
||||
|
||||
val posY = y + posYbuffer[index].flipY() +
|
||||
if (sheetID == SHEET_UNIHAN) // evil exceptions
|
||||
offsetUnihan
|
||||
else if (sheetID == SHEET_CUSTOM_SYM)
|
||||
offsetCustomSym
|
||||
else 0
|
||||
|
||||
val posX = x + posXbuffer[index]
|
||||
val texture = sheets[sheetID].get(sheetX, sheetY)
|
||||
|
||||
when (run) {
|
||||
0 -> {
|
||||
batch.color = mainCol
|
||||
batch.draw(texture, posX, posY)
|
||||
}
|
||||
1 -> {
|
||||
batch.color = shadowCol
|
||||
batch.draw(texture, posX + 1, posY)
|
||||
}
|
||||
2 -> {
|
||||
batch.color = shadowCol
|
||||
batch.draw(texture, posX, posY + 1.flipY())
|
||||
}
|
||||
3 -> {
|
||||
batch.color = shadowCol
|
||||
batch.draw(texture, posX + 1, posY + 1.flipY())
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (noSuchGlyph: ArrayIndexOutOfBoundsException) {
|
||||
batch.color = mainCol
|
||||
}
|
||||
mainCol = getColour(c)
|
||||
}
|
||||
|
||||
|
||||
index++
|
||||
}
|
||||
else if (isCharsetOverride(c)) {
|
||||
charsetOverride = c - CHARSET_OVERRIDE_DEFAULT
|
||||
}
|
||||
else if (sheetID == SHEET_HANGUL) {
|
||||
// Flookahead for {I, P, F}
|
||||
|
||||
val cNext = if (index + 1 < textBuffer.size) textBuffer[index + 1] else 0
|
||||
val cNextNext = if (index + 2 < textBuffer.size) textBuffer[index + 2] else 0
|
||||
|
||||
val hangulLength = if (isHangulJongseong(cNextNext) && isHangulJungseong(cNext))
|
||||
3
|
||||
else if (isHangulJungseong(cNext))
|
||||
2
|
||||
else
|
||||
1
|
||||
|
||||
val (indices, rows) = toHangulIndexAndRow(c, cNext, cNextNext)
|
||||
|
||||
val (indexCho, indexJung, indexJong) = indices
|
||||
val (choRow, jungRow, jongRow) = rows
|
||||
val hangulSheet = sheets[SHEET_HANGUL]
|
||||
|
||||
|
||||
|
||||
batch.color = mainCol
|
||||
batch.draw(hangulSheet.get(indexCho, choRow), x + posXbuffer[index].toFloat(), y)
|
||||
batch.draw(hangulSheet.get(indexJung, jungRow), x + posXbuffer[index].toFloat(), y)
|
||||
batch.draw(hangulSheet.get(indexJong, jongRow), x + posXbuffer[index].toFloat(), y)
|
||||
|
||||
|
||||
index += hangulLength - 1
|
||||
|
||||
}
|
||||
else {
|
||||
try {
|
||||
|
||||
val posY = y + posYbuffer[index].flipY() +
|
||||
if (sheetID == SHEET_UNIHAN) // evil exceptions
|
||||
offsetUnihan
|
||||
else if (sheetID == SHEET_CUSTOM_SYM)
|
||||
offsetCustomSym
|
||||
else 0
|
||||
|
||||
val posX = x + posXbuffer[index]
|
||||
val texture = sheets[sheetID].get(sheetX, sheetY)
|
||||
|
||||
batch.color = mainCol
|
||||
batch.draw(texture, posX, posY)
|
||||
|
||||
}
|
||||
catch (noSuchGlyph: ArrayIndexOutOfBoundsException) {
|
||||
batch.color = mainCol
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
index++
|
||||
}
|
||||
|
||||
/*textTexture.end()
|
||||
@@ -1321,6 +1269,46 @@ class GameFontBase(fontDir: String, val noShadow: Boolean = false, val flipY: Bo
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Edits the given pixmap so that it would have a shadow on it.
|
||||
*
|
||||
* This function must be called `AFTER buildWidthTable()`
|
||||
*
|
||||
* The pixmap must be mutable (beware of concurrentmodificationexception).
|
||||
*/
|
||||
private fun makeShadow(pixmap: Pixmap) {
|
||||
|
||||
|
||||
for (y in 0..pixmap.height - 2) {
|
||||
for (x in 0..pixmap.width - 2) {
|
||||
val pxNow = pixmap.getPixel(x, y) // RGBA8888
|
||||
|
||||
// if you have read CONTRIBUTING.md, it says the actual glyph part MUST HAVE alpha of 255.
|
||||
// but some of the older spritesheets still have width tag drawn as alpha of 255.
|
||||
// therefore we still skip every x+15th pixels
|
||||
|
||||
if (x % 16 != 15) {
|
||||
if (pxNow and 0xFF == 255) {
|
||||
val pxRight = (x + 1) to y
|
||||
val pxBottom = x to (y + 1)
|
||||
val pxBottomRight = (x + 1) to (y + 1)
|
||||
val opCue = listOf(pxRight, pxBottom, pxBottomRight)
|
||||
|
||||
opCue.forEach {
|
||||
if (pixmap.getPixel(it.first, it.second) and 0xFF == 0) {
|
||||
pixmap.drawPixel(it.first, it.second,
|
||||
// the shadow has the same colour, but alpha halved
|
||||
pxNow.and(0xFFFFFF00.toInt()).or(0x7F)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** High surrogate comes before the low. */
|
||||
private fun Char.isHighSurrogate() = (this.toInt() in 0xD800..0xDBFF)
|
||||
/** CodePoint = 0x10000 + (H - 0xD800) * 0x400 + (L - 0xDC00) */
|
||||
|
||||
Reference in New Issue
Block a user