wenquanyi: fixed bad code point allocation

This commit is contained in:
Song Minjae
2017-04-20 21:18:47 +09:00
parent b764aedb0c
commit db4cd9bbbe
8 changed files with 204 additions and 251 deletions

View File

@@ -65,8 +65,6 @@ open class GameFontBase : Font {
private fun isCyrilic(c: Char) = c.toInt() in 0x400..0x45F
private fun isFullwidthUni(c: Char) = c.toInt() in 0xFF00..0xFF1F
private fun isUniPunct(c: Char) = c.toInt() in 0x2000..0x206F
private fun isWenQuanYi1(c: Char) = c.toInt() in 0x33F3..0x69FC
private fun isWenQuanYi2(c: Char) = c.toInt() in 0x69FD..0x9FDC
private fun isGreek(c: Char) = c.toInt() in 0x370..0x3CE
@@ -86,8 +84,8 @@ open class GameFontBase : Font {
private fun cjkPunctIndexX(c: Char) = (c.toInt() - 0x3000) % 16
private fun cjkPunctIndexY(c: Char) = (c.toInt() - 0x3000) / 16
private fun uniHanIndexX(c: Char) = (c.toInt() - 0x3400) % 256
private fun uniHanIndexY(c: Char) = (c.toInt() - 0x3400) / 256
private fun unihanIndexX(c: Char) = (c.toInt() - 0x3400) % 256
private fun unihanIndexY(c: Char) = (c.toInt() - 0x3400) / 256
private fun cyrilicIndexX(c: Char) = (c.toInt() - 0x400) % 16
private fun cyrilicIndexY(c: Char) = (c.toInt() - 0x400) / 16
@@ -98,19 +96,13 @@ open class GameFontBase : Font {
private fun uniPunctIndexX(c: Char) = (c.toInt() - 0x2000) % 16
private fun uniPunctIndexY(c: Char) = (c.toInt() - 0x2000) / 16
private fun wenQuanYiIndexX(c: Char) =
(c.toInt() - if (c.toInt() <= 0x4DB5) 0x33F3 else 0x33F3 + 0x4A) % 32
private fun wenQuanYi1IndexY(c: Char) = (c.toInt() - (0x33F3 + 0x4A)) / 32
private fun wenQuanYi2IndexY(c: Char) = (c.toInt() - 0x69FD) / 32
private fun greekIndexX(c: Char) = (c.toInt() - 0x370) % 16
private fun greekIndexY(c: Char) = (c.toInt() - 0x370) / 16
private val unihanWidthSheets = arrayOf(
SHEET_UNIHAN,
SHEET_FW_UNI,
SHEET_WENQUANYI_1,
SHEET_WENQUANYI_2
SHEET_UNIHAN
)
private val zeroWidthSheets = arrayOf(
SHEET_COLOURCODE
@@ -216,40 +208,20 @@ open class GameFontBase : Font {
}
//hangulSheet.endUse()
// unihan fonts
/*uniHan.startUse();
for (int i = 0; i < s.length(); i++) {
char ch = s.charAt(i);
// WenQuanYi
//uniHan.startUse()
for (i in 0..s.length - 1) {
val ch = s[i]
if (ch.isColourCode()) {
thisCol = colourKey[ch]!!
continue
}
if (isUniHan(ch)) {
int glyphW = getWidth("" + ch);
uniHan.renderInUse(
Math.round(x
+ getWidthSubstr(s, i + 1) - glyphW
)
, Math.round((H - H_UNIHAN) / 2 + y)
, uniHanIndexX(ch)
, uniHanIndexY(ch)
);
}
}
uniHan.endUse();*/
// WenQuanYi 1
//wenQuanYi_1.startUse()
for (i in 0..s.length - 1) {
val ch = s[i]
if (ch.isColourCode()) {
thisCol = colourKey[ch]!!
continue
}
if (isWenQuanYi1(ch)) {
val glyphW = getWidth("" + ch)
wenQuanYi_1.getSubImage(wenQuanYiIndexX(ch), wenQuanYi1IndexY(ch)).drawWithShadow(
uniHan.getSubImage(unihanIndexX(ch), unihanIndexY(ch)).drawWithShadow(
Math.round(x + getWidthSubstr(s, i + 1) - glyphW).toFloat(),
Math.round((H - H_UNIHAN) / 2 + y).toFloat(),
scale.toFloat(), thisCol
@@ -257,29 +229,7 @@ open class GameFontBase : Font {
}
}
//wenQuanYi_1.endUse()
// WenQuanYi 2
//wenQuanYi_2.startUse()
for (i in 0..s.length - 1) {
val ch = s[i]
if (ch.isColourCode()) {
thisCol = colourKey[ch]!!
continue
}
if (isWenQuanYi2(ch)) {
val glyphW = getWidth("" + ch)
wenQuanYi_2.getSubImage(wenQuanYiIndexX(ch), wenQuanYi2IndexY(ch)).drawWithShadow(
Math.round(x + getWidthSubstr(s, i + 1) - glyphW).toFloat(),
Math.round((H - H_UNIHAN) / 2 + y).toFloat(),
scale.toFloat(), thisCol
)
}
}
//wenQuanYi_2.endUse()
//uniHan.endUse()
// regular fonts
var prevInstance = -1
@@ -489,12 +439,10 @@ open class GameFontBase : Font {
lateinit internal var extBSheet: SpriteSheet
lateinit internal var kanaSheet: SpriteSheet
lateinit internal var cjkPunct: SpriteSheet
// static SpriteSheet uniHan;
lateinit internal var uniHan: SpriteSheet
lateinit internal var cyrilic: SpriteSheet
lateinit internal var fullwidthForms: SpriteSheet
lateinit internal var uniPunct: SpriteSheet
lateinit internal var wenQuanYi_1: SpriteSheet
lateinit internal var wenQuanYi_2: SpriteSheet
lateinit internal var greekSheet: SpriteSheet
internal val JUNG_COUNT = 21
@@ -519,9 +467,7 @@ open class GameFontBase : Font {
internal val SHEET_CYRILIC_VARW = 8
internal val SHEET_FW_UNI = 9
internal val SHEET_UNI_PUNCT = 10
internal val SHEET_WENQUANYI_1 = 11
internal val SHEET_WENQUANYI_2 = 12
internal val SHEET_GREEK_VARW = 13
internal val SHEET_GREEK_VARW = 11
internal val SHEET_UNKNOWN = 254

View File

@@ -22,13 +22,6 @@ class GameFontImpl : GameFontBase() {
"./assets/graphics/fonts/kana.tga", GameFontBase.W_KANA, GameFontBase.H)
GameFontBase.cjkPunct = SpriteSheet(
"./assets/graphics/fonts/cjkpunct.tga", GameFontBase.W_ASIAN_PUNCT, GameFontBase.H)
/*uniHan = new SpriteSheet(
"./assets/graphics/fonts/unifont_unihan"
+ ((!terrarum.gameLocale.contains("zh"))
? "_ja" : "")
+".tga"
, W_UNIHAN, H_UNIHAN
);*/
GameFontBase.cyrilic = SpriteSheet(
when (GameFontDemo.gameLocale.substring(0..1)) {
"bg" -> "./assets/graphics/fonts/cyrilic_bulgarian_variable.tga"
@@ -39,10 +32,8 @@ class GameFontImpl : GameFontBase() {
"./assets/graphics/fonts/fullwidth_forms.tga", GameFontBase.W_UNIHAN, GameFontBase.H_UNIHAN)
GameFontBase.uniPunct = SpriteSheet(
"./assets/graphics/fonts/unipunct.tga", GameFontBase.W_LATIN_WIDE, GameFontBase.H)
GameFontBase.wenQuanYi_1 = SpriteSheet(
"./assets/graphics/fonts/wenquanyi_11pt_part1.tga", 16, 18, 2)
GameFontBase.wenQuanYi_2 = SpriteSheet(
"./assets/graphics/fonts/wenquanyi_11pt_part2.tga", 16, 18, 2)
GameFontBase.uniHan = SpriteSheet(
"./assets/graphics/fonts/wenquanyi.tga", 16, 16)
GameFontBase.greekSheet = SpriteSheet(
"./assets/graphics/fonts/greek_variable.tga", 15, 19, 1)
@@ -54,12 +45,10 @@ class GameFontImpl : GameFontBase() {
GameFontBase.extBSheet,
GameFontBase.kanaSheet,
GameFontBase.cjkPunct,
null, // Full unihan, filler because we're using WenQuanYi
GameFontBase.uniHan,
GameFontBase.cyrilic,
GameFontBase.fullwidthForms,
GameFontBase.uniPunct,
GameFontBase.wenQuanYi_1,
GameFontBase.wenQuanYi_2,
GameFontBase.greekSheet
)
GameFontBase.sheetKey = shk

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 MiB

245
demo/.idea/workspace.xml generated
View File

@@ -23,54 +23,62 @@
</component>
<component name="ExecutionTargetManager" SELECTED_TARGET="default_target" />
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file leaf-file-name="GameFontDemo.kt" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarum/imagefont/GameFontDemo.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="924">
<caret line="72" column="55" lean-forward="false" selection-start-line="72" selection-start-column="55" selection-end-line="72" selection-end-column="55" />
<folding>
<element signature="e#40#238#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="GameFontBase.kt" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarum/imagefont/GameFontBase.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="409">
<caret line="204" column="48" lean-forward="false" selection-start-line="204" selection-start-column="48" selection-end-line="204" selection-end-column="48" />
<folding>
<element signature="e#31#171#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="GameFontImpl.kt" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarum/imagefont/GameFontImpl.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="518">
<caret line="37" column="41" lean-forward="false" selection-start-line="37" selection-start-column="41" selection-end-line="37" selection-end-column="41" />
<folding>
<element signature="e#31#108#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="text.txt" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/text.txt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="252">
<caret line="18" column="0" lean-forward="true" selection-start-line="18" selection-start-column="0" selection-end-line="18" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
</file>
</leaf>
<splitter split-orientation="horizontal" split-proportion="0.5">
<split-first>
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file leaf-file-name="GameFontDemo.kt" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarum/imagefont/GameFontDemo.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1008">
<caret line="72" column="55" lean-forward="false" selection-start-line="72" selection-start-column="55" selection-end-line="72" selection-end-column="55" />
<folding>
<element signature="e#40#238#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="GameFontImpl.kt" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarum/imagefont/GameFontImpl.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="375">
<caret line="36" column="22" lean-forward="false" selection-start-line="36" selection-start-column="22" selection-end-line="36" selection-end-column="22" />
<folding>
<element signature="e#31#108#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="text.txt" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/text.txt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="252">
<caret line="18" column="0" lean-forward="false" selection-start-line="18" selection-start-column="0" selection-end-line="18" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
</file>
</leaf>
</split-first>
<split-second>
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file leaf-file-name="GameFontBase.kt" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarum/imagefont/GameFontBase.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="14">
<caret line="36" column="19" lean-forward="false" selection-start-line="36" selection-start-column="19" selection-end-line="36" selection-end-column="19" />
<folding>
<element signature="e#31#171#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
</leaf>
</split-second>
</splitter>
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
@@ -106,9 +114,9 @@
<option value="$PROJECT_DIR$/config.properties" />
<option value="$PROJECT_DIR$/META-INF/MANIFEST.MF" />
<option value="$PROJECT_DIR$/src/net/torvald/terrarum/imagefont/GameFontDemo.kt" />
<option value="$PROJECT_DIR$/src/net/torvald/terrarum/imagefont/GameFontImpl.kt" />
<option value="$PROJECT_DIR$/src/net/torvald/terrarum/imagefont/GameFontBase.kt" />
<option value="$PROJECT_DIR$/text.txt" />
<option value="$PROJECT_DIR$/src/net/torvald/terrarum/imagefont/GameFontBase.kt" />
<option value="$PROJECT_DIR$/src/net/torvald/terrarum/imagefont/GameFontImpl.kt" />
</list>
</option>
</component>
@@ -133,9 +141,6 @@
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="Scope" />
<pane id="Scratches" />
<pane id="PackagesPane" />
<pane id="ProjectPane">
<subPane>
<PATH>
@@ -182,12 +187,15 @@
</PATH>
</subPane>
</pane>
<pane id="PackagesPane" />
<pane id="Scratches" />
<pane id="Scope" />
</panes>
</component>
<component name="PropertiesComponent">
<property name="settings.editor.selected.configurable" value="project.kotlinCompiler" />
<property name="settings.editor.splitter.proportion" value="0.2" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/lib" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
<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" />
@@ -415,17 +423,17 @@
<window_info id="Palette&#9;" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
<window_info id="Maven Projects" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32960597" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="false" weight="0.33" sideWeight="0.5" order="8" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3292683" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="false" weight="0.33" sideWeight="0.5" order="8" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="9" side_tool="false" content_ui="tabs" />
<window_info id="Designer" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.21100427" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.21634616" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
<window_info id="LuaJ" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32960597" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3054371" sideWeight="0.5" order="11" side_tool="false" content_ui="tabs" />
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="UI Designer" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="4" side_tool="true" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.2581574" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="4" side_tool="true" content_ui="tabs" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
@@ -451,6 +459,82 @@
<option name="FILTER_TARGETS" value="false" />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarum/imagefont/GameFontDemo.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1008">
<caret line="72" column="55" lean-forward="false" selection-start-line="72" selection-start-column="55" selection-end-line="72" selection-end-column="55" />
<folding>
<element signature="e#40#238#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/text.txt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="252">
<caret line="18" column="0" lean-forward="false" selection-start-line="18" selection-start-column="0" selection-end-line="18" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarum/imagefont/GameFontImpl.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="588">
<caret line="42" column="46" lean-forward="true" selection-start-line="42" selection-start-column="46" selection-end-line="42" selection-end-column="46" />
<folding>
<element signature="e#31#108#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarum/imagefont/GameFontBase.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding>
<element signature="e#31#171#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarum/imagefont/GameFontDemo.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="924">
<caret line="72" column="55" lean-forward="false" selection-start-line="72" selection-start-column="55" selection-end-line="72" selection-end-column="55" />
<folding>
<element signature="e#40#238#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarum/imagefont/GameFontImpl.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="504">
<caret line="37" column="41" lean-forward="false" selection-start-line="37" selection-start-column="41" selection-end-line="37" selection-end-column="41" />
<folding>
<element signature="e#31#108#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/text.txt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="252">
<caret line="18" column="0" lean-forward="true" selection-start-line="18" selection-start-column="0" selection-end-line="18" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarum/imagefont/GameFontBase.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="2800">
<caret line="204" column="48" lean-forward="false" selection-start-line="204" selection-start-column="48" selection-end-line="204" selection-end-column="48" />
<folding>
<element signature="e#31#171#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarum/imagefont/GameFontDemo.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="924">
@@ -540,16 +624,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarum/imagefont/GameFontDemo.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="924">
<caret line="72" column="55" lean-forward="false" selection-start-line="72" selection-start-column="55" selection-end-line="72" selection-end-column="55" />
<folding>
<element signature="e#40#238#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/config.properties">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
@@ -561,38 +635,47 @@
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="338">
<caret line="491" column="24" lean-forward="false" selection-start-line="491" selection-start-column="24" selection-end-line="491" selection-end-column="24" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/text.txt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="252">
<caret line="18" column="0" lean-forward="true" selection-start-line="18" selection-start-column="0" selection-end-line="18" selection-end-column="0" />
<caret line="18" column="0" lean-forward="false" selection-start-line="18" selection-start-column="0" selection-end-line="18" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarum/imagefont/GameFontImpl.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="518">
<caret line="37" column="41" lean-forward="false" selection-start-line="37" selection-start-column="41" selection-end-line="37" selection-end-column="41" />
<folding>
<element signature="e#31#108#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarum/imagefont/GameFontBase.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="409">
<caret line="204" column="48" lean-forward="false" selection-start-line="204" selection-start-column="48" selection-end-line="204" selection-end-column="48" />
<state relative-caret-position="14">
<caret line="36" column="19" lean-forward="false" selection-start-line="36" selection-start-column="19" selection-end-line="36" selection-end-column="19" />
<folding>
<element signature="e#31#171#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarum/imagefont/GameFontDemo.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1008">
<caret line="72" column="55" lean-forward="false" selection-start-line="72" selection-start-column="55" selection-end-line="72" selection-end-column="55" />
<folding>
<element signature="e#40#238#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/net/torvald/terrarum/imagefont/GameFontImpl.kt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="375">
<caret line="36" column="22" lean-forward="false" selection-start-line="36" selection-start-column="22" selection-end-line="36" selection-end-column="22" />
<folding>
<element signature="e#31#108#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</component>
<component name="masterDetails">
<states>

View File

@@ -65,8 +65,6 @@ open class GameFontBase : Font {
private fun isCyrilic(c: Char) = c.toInt() in 0x400..0x45F
private fun isFullwidthUni(c: Char) = c.toInt() in 0xFF00..0xFF1F
private fun isUniPunct(c: Char) = c.toInt() in 0x2000..0x206F
private fun isWenQuanYi1(c: Char) = c.toInt() in 0x33F3..0x69FC
private fun isWenQuanYi2(c: Char) = c.toInt() in 0x69FD..0x9FDC
private fun isGreek(c: Char) = c.toInt() in 0x370..0x3CE
@@ -86,8 +84,8 @@ open class GameFontBase : Font {
private fun cjkPunctIndexX(c: Char) = (c.toInt() - 0x3000) % 16
private fun cjkPunctIndexY(c: Char) = (c.toInt() - 0x3000) / 16
private fun uniHanIndexX(c: Char) = (c.toInt() - 0x3400) % 256
private fun uniHanIndexY(c: Char) = (c.toInt() - 0x3400) / 256
private fun unihanIndexX(c: Char) = (c.toInt() - 0x3400) % 256
private fun unihanIndexY(c: Char) = (c.toInt() - 0x3400) / 256
private fun cyrilicIndexX(c: Char) = (c.toInt() - 0x400) % 16
private fun cyrilicIndexY(c: Char) = (c.toInt() - 0x400) / 16
@@ -98,19 +96,13 @@ open class GameFontBase : Font {
private fun uniPunctIndexX(c: Char) = (c.toInt() - 0x2000) % 16
private fun uniPunctIndexY(c: Char) = (c.toInt() - 0x2000) / 16
private fun wenQuanYiIndexX(c: Char) =
(c.toInt() - if (c.toInt() <= 0x4DB5) 0x33F3 else 0x33F3 + 0x4A) % 32
private fun wenQuanYi1IndexY(c: Char) = (c.toInt() - (0x33F3 + 0x4A)) / 32
private fun wenQuanYi2IndexY(c: Char) = (c.toInt() - 0x69FD) / 32
private fun greekIndexX(c: Char) = (c.toInt() - 0x370) % 16
private fun greekIndexY(c: Char) = (c.toInt() - 0x370) / 16
private val unihanWidthSheets = arrayOf(
SHEET_UNIHAN,
SHEET_FW_UNI,
SHEET_WENQUANYI_1,
SHEET_WENQUANYI_2
SHEET_UNIHAN
)
private val zeroWidthSheets = arrayOf(
SHEET_COLOURCODE
@@ -216,40 +208,20 @@ open class GameFontBase : Font {
}
//hangulSheet.endUse()
// unihan fonts
/*uniHan.startUse();
for (int i = 0; i < s.length(); i++) {
char ch = s.charAt(i);
// WenQuanYi
//uniHan.startUse()
for (i in 0..s.length - 1) {
val ch = s[i]
if (ch.isColourCode()) {
thisCol = colourKey[ch]!!
continue
}
if (isUniHan(ch)) {
int glyphW = getWidth("" + ch);
uniHan.renderInUse(
Math.round(x
+ getWidthSubstr(s, i + 1) - glyphW
)
, Math.round((H - H_UNIHAN) / 2 + y)
, uniHanIndexX(ch)
, uniHanIndexY(ch)
);
}
}
uniHan.endUse();*/
// WenQuanYi 1
//wenQuanYi_1.startUse()
for (i in 0..s.length - 1) {
val ch = s[i]
if (ch.isColourCode()) {
thisCol = colourKey[ch]!!
continue
}
if (isWenQuanYi1(ch)) {
val glyphW = getWidth("" + ch)
wenQuanYi_1.getSubImage(wenQuanYiIndexX(ch), wenQuanYi1IndexY(ch)).drawWithShadow(
uniHan.getSubImage(unihanIndexX(ch), unihanIndexY(ch)).drawWithShadow(
Math.round(x + getWidthSubstr(s, i + 1) - glyphW).toFloat(),
Math.round((H - H_UNIHAN) / 2 + y).toFloat(),
scale.toFloat(), thisCol
@@ -257,29 +229,7 @@ open class GameFontBase : Font {
}
}
//wenQuanYi_1.endUse()
// WenQuanYi 2
//wenQuanYi_2.startUse()
for (i in 0..s.length - 1) {
val ch = s[i]
if (ch.isColourCode()) {
thisCol = colourKey[ch]!!
continue
}
if (isWenQuanYi2(ch)) {
val glyphW = getWidth("" + ch)
wenQuanYi_2.getSubImage(wenQuanYiIndexX(ch), wenQuanYi2IndexY(ch)).drawWithShadow(
Math.round(x + getWidthSubstr(s, i + 1) - glyphW).toFloat(),
Math.round((H - H_UNIHAN) / 2 + y).toFloat(),
scale.toFloat(), thisCol
)
}
}
//wenQuanYi_2.endUse()
//uniHan.endUse()
// regular fonts
var prevInstance = -1
@@ -489,12 +439,10 @@ open class GameFontBase : Font {
lateinit internal var extBSheet: SpriteSheet
lateinit internal var kanaSheet: SpriteSheet
lateinit internal var cjkPunct: SpriteSheet
// static SpriteSheet uniHan;
lateinit internal var uniHan: SpriteSheet
lateinit internal var cyrilic: SpriteSheet
lateinit internal var fullwidthForms: SpriteSheet
lateinit internal var uniPunct: SpriteSheet
lateinit internal var wenQuanYi_1: SpriteSheet
lateinit internal var wenQuanYi_2: SpriteSheet
lateinit internal var greekSheet: SpriteSheet
internal val JUNG_COUNT = 21
@@ -519,9 +467,7 @@ open class GameFontBase : Font {
internal val SHEET_CYRILIC_VARW = 8
internal val SHEET_FW_UNI = 9
internal val SHEET_UNI_PUNCT = 10
internal val SHEET_WENQUANYI_1 = 11
internal val SHEET_WENQUANYI_2 = 12
internal val SHEET_GREEK_VARW = 13
internal val SHEET_GREEK_VARW = 11
internal val SHEET_UNKNOWN = 254

View File

@@ -22,13 +22,6 @@ class GameFontImpl : GameFontBase() {
"./assets/graphics/fonts/kana.tga", GameFontBase.W_KANA, GameFontBase.H)
GameFontBase.cjkPunct = SpriteSheet(
"./assets/graphics/fonts/cjkpunct.tga", GameFontBase.W_ASIAN_PUNCT, GameFontBase.H)
/*uniHan = new SpriteSheet(
"./assets/graphics/fonts/unifont_unihan"
+ ((!terrarum.gameLocale.contains("zh"))
? "_ja" : "")
+".tga"
, W_UNIHAN, H_UNIHAN
);*/
GameFontBase.cyrilic = SpriteSheet(
when (GameFontDemo.gameLocale.substring(0..1)) {
"bg" -> "./assets/graphics/fonts/cyrilic_bulgarian_variable.tga"
@@ -39,10 +32,8 @@ class GameFontImpl : GameFontBase() {
"./assets/graphics/fonts/fullwidth_forms.tga", GameFontBase.W_UNIHAN, GameFontBase.H_UNIHAN)
GameFontBase.uniPunct = SpriteSheet(
"./assets/graphics/fonts/unipunct.tga", GameFontBase.W_LATIN_WIDE, GameFontBase.H)
GameFontBase.wenQuanYi_1 = SpriteSheet(
"./assets/graphics/fonts/wenquanyi_11pt_part1.tga", 16, 18, 2)
GameFontBase.wenQuanYi_2 = SpriteSheet(
"./assets/graphics/fonts/wenquanyi_11pt_part2.tga", 16, 18, 2)
GameFontBase.uniHan = SpriteSheet(
"./assets/graphics/fonts/wenquanyi.tga", 16, 16)
GameFontBase.greekSheet = SpriteSheet(
"./assets/graphics/fonts/greek_variable.tga", 15, 19, 1)
@@ -54,12 +45,10 @@ class GameFontImpl : GameFontBase() {
GameFontBase.extBSheet,
GameFontBase.kanaSheet,
GameFontBase.cjkPunct,
null, // Full unihan, filler because we're using WenQuanYi
GameFontBase.uniHan,
GameFontBase.cyrilic,
GameFontBase.fullwidthForms,
GameFontBase.uniPunct,
GameFontBase.wenQuanYi_1,
GameFontBase.wenQuanYi_2,
GameFontBase.greekSheet
)
GameFontBase.sheetKey = shk