75 Commits
v1.6 ... v1.9

Author SHA1 Message Date
minjaesong
3841611780 1.9 release 2021-03-15 19:56:53 +09:00
minjaesong
06bc8c9e2d forgot to update demo.png 2020-10-16 15:20:07 +09:00
minjaesong
21415c6f8d add: kerning sets for b and d 2020-10-06 16:31:24 +09:00
minjaesong
22c2a7aa52 fix: issue #12 2020-10-06 15:14:57 +09:00
minjaesong
0eb181f315 time to get off so i'll just commit this 2020-09-29 18:04:58 +09:00
minjaesong
45b431f953 fix: partial fix for issue #12 2020-09-29 14:07:35 +09:00
minjaesong
bbee554fec add: error msg for illegal linotype dimension 2020-09-29 11:36:59 +09:00
minjaesong
c4c67f489e fixing idiotic priority cache impl where they won't get younger 2020-05-04 00:09:05 +09:00
minjaesong
4d867d6523 replacing personalised test text 2020-05-03 23:42:06 +09:00
minjaesong
6620c11178 hangul: minor texture changes 2020-05-03 23:28:59 +09:00
minjaesong
db06cab07c cleaning up unnecessary functions 2020-05-03 22:26:45 +09:00
minjaesong
90b11cdd97 hangul: more microkerning shit 2020-05-03 20:34:12 +09:00
minjaesong
7bb92d1b4e hangul: some of the microkerning implemented in dirty way 2020-05-03 18:13:17 +09:00
minjaesong
b5dd744bd5 hangul: WEO to use wider initials just like WI and YI 2020-05-02 00:03:50 +09:00
minjaesong
34903b10d4 more hangul improvements 2020-05-01 17:12:13 +09:00
minjaesong
0c5b7c8b70 more letters for kerning charsets 2020-04-23 02:50:03 +09:00
minjaesong
cdffca98ef even more kerning pairs i can think of WIP 2020-04-23 01:16:18 +09:00
minjaesong
ce30d1d5fd major modification on hangul font 2020-04-23 01:02:57 +09:00
minjaesong
ab067044f8 more kerning pairs i can think of WIP 2020-04-21 05:17:19 +09:00
minjaesong
3e04b8bbe6 more kerning pairs WIP 2020-04-19 15:03:37 +09:00
minjaesong
4556a9e244 very crude kerning impl for Ys and Ts and AV-VA pairs 2020-04-14 23:56:08 +09:00
minjaesong
e5d04de250 character sets to use ints rather than chars 2020-04-14 23:45:35 +09:00
minjaesong
b7df181729 minor improvement on rotund r 2020-04-14 07:25:11 +09:00
minjaesong
2fd3fcfd46 support for LatinExt-D 2020-04-14 06:41:11 +09:00
minjaesong
73251d70fa completely dropping Slick2d stuffs 2020-01-14 16:26:10 +09:00
minjaesong
971f98beb3 shadow inversion to make recessed texts 2020-01-06 15:19:07 +09:00
minjaesong
abe1da35a0 kana minor edits, fixing wrong case 2019-10-03 01:24:39 +09:00
Minjae Song
29885f3ac9 updating demo.png 2019-05-31 04:14:32 +09:00
Minjae Song
56d2a98a5b hangul update 2019-05-30 14:10:27 +09:00
Minjae Song
43342fff00 demo: updating unicode references 2019-05-14 13:33:14 +09:00
Minjae Song
51d4dec6d3 new redesigned hangul 2019-05-14 13:17:20 +09:00
Minjae Song
81dc38d242 support for Compatibility Hangul 0x3130..0x318F 2019-05-13 02:27:56 +09:00
Minjae Song
863f9d91c8 hangul redraw wip -- less "laundry line" 2019-05-12 23:51:50 +09:00
Minjae Song
4c99cca7ff internal test mode 2019-05-12 17:20:22 +09:00
Minjae Song
b807b96b5f hangul redraw and punct adjustments 2019-05-12 17:10:05 +09:00
Minjae Song
91c9a7a99c TextureRegionPack is now Gdx.disposable 2019-03-10 16:43:32 +09:00
Minjae Song
778e2b0afb tweaks on left/right bumper labels 2019-02-23 23:48:18 +09:00
Minjae Song
c9055ef7b8 PUA: LR buttons are now xbox shaped, added xbox one's View and Menu buttons 2019-02-13 17:52:45 +09:00
Minjae Song
e60b95efb8 bgBG: one dark pixel fixed on 'zhe' 2019-02-08 09:54:54 +09:00
Minjae Song
9ca70a601b fixing memory leak caused by my sloppy-ass coding 2019-02-07 17:30:15 +09:00
Minjae Song
6cacc56ea8 Update README.md 2019-02-07 03:25:59 +09:00
Minjae Song
6d142f082c readme: gitlab link -> github link 2019-01-29 23:42:20 +09:00
Minjae Song
db3b13800b Merge branch 'cpu-render-pixmap-cache' 2019-01-22 22:39:15 +09:00
Minjae Song
7fe0cc9527 copyright update 2019-01-13 04:42:14 +09:00
Minjae Song
b62fee89cb fixed getWidth() not returning correct width
getWidth() is heavier than ever now, at least it's cached
2019-01-10 20:11:36 +09:00
Minjae Song
d88443814f sheet name comment on coderange, default cache size is 64 2019-01-10 18:25:24 +09:00
Minjae Song
dfeab56bb5 Update CONTRIBUTING.md 2018-12-02 02:35:58 +09:00
Minjae Song
b623727b1a potential memory leak fixed (unbound cache size) 2018-11-03 16:35:26 +09:00
minjaesong
048b683cb2 sorta works but poor performance on wall of text 2018-09-19 02:54:07 +09:00
minjaesong
35b384af53 proper render, except there can be NO transparency in color & spritesheet 2018-09-19 00:07:32 +09:00
minjaesong
cebfa27d59 this is cursed; new shadowing method pls code 2018-09-18 01:08:28 +09:00
minjaesong
c57de3a21f we have a render (but not colour) 2018-09-17 23:10:29 +09:00
minjaesong
4ad5e47758 little diagnose print 2018-09-17 21:29:55 +09:00
Minjae Song
f06ed4529c how the fuck this does not work 2018-09-17 17:51:36 +09:00
Minjae Song
8da321bdc2 fixed bad offset but still bad render 2018-09-17 17:02:09 +09:00
Minjae Song
920b11e3e9 WIP, at least it draws something 2018-09-17 16:26:25 +09:00
minjaesong
d8dd88c6a7 aggressive cacheing (ShittyGlyphLayout) 2018-09-16 18:51:11 +09:00
minjaesong
ba28b6d10c improved shadowing perf at the cost of reduced quality
black text on white background should work now
2018-09-16 16:08:34 +09:00
minjaesong
50ae1789bf this should fix issue #11
If performance is not a concern (which is WIP)
2018-09-16 14:48:02 +09:00
minjaesong
bd9784a516 release candidate 1.7 2018-09-15 16:29:27 +09:00
minjaesong
0bafde9914 latin extended-c 2018-09-10 21:31:00 +09:00
minjaesong
b3bfe6035f support for polytonic greek 2018-09-10 01:26:58 +09:00
minjaesong
c3cf795e9a I still suck at Armenian; polytone greek WIP 2018-09-10 01:02:27 +09:00
minjaesong
cefc7860b3 new armenian (#10)
- Redesigned glyphs
- Update to Unicode 11 (2 chrs added)
2018-09-09 19:51:43 +09:00
minjaesong
b8963cd3a9 full support of old hangul 2018-08-29 00:35:46 +09:00
minjaesong
32290dd504 selectively skipping spritesheets 2018-08-24 02:36:29 +09:00
minjaesong
2702f850c2 elaboration of before-and-after tag; spec change
- RTL tag removed
- we're calling the program part "the font compiler"
2018-08-24 00:37:48 +09:00
minjaesong
2e10249f27 unicode super/subscripts (fractions) 2018-08-23 03:37:22 +09:00
minjaesong
04a375328c fixing up diacritics; complete unipunct 2018-08-22 18:17:48 +09:00
minjaesong
97ef1ddc27 more fucking bengali 2018-08-21 19:54:36 +09:00
minjaesong
4057d86176 more works on IPA
diacritics Overlay and Joiner has implemented
2018-08-14 23:37:29 +09:00
minjaesong
654f7b9ac4 I overwrote the fucking demo text 2018-08-14 19:36:00 +09:00
minjaesong
91afc4af31 tʰɛstɪŋgə tʰɛstɪŋ wʌn tʉ θɹɪ
isOverlay not actually implemented
2018-08-14 19:21:12 +09:00
minjaesong
1440908820 tags definition update to accomodate more weirdness 2018-08-11 04:39:44 +09:00
minjaesong
4ce58cf5d1 made demo program actually run 2018-08-11 00:33:52 +09:00
75 changed files with 1809 additions and 2384 deletions

5
.gitignore vendored Normal file → Executable file
View File

@@ -3,4 +3,7 @@ demo/lib/*
demo/assets/*
out/*
lib/*
Terrarum-sans-bitmap*.zip
Terrarum-sans-bitmap*.zip
TerrarumSansBitmap*.jar
Font*.jar
tmp_*

0
.idea/.name generated Normal file → Executable file
View File

0
.idea/artifacts/FontDemoGDX.xml generated Normal file → Executable file
View File

2
.idea/artifacts/TerrarumSansBitmap.xml generated Normal file → Executable file
View File

@@ -1,6 +1,6 @@
<component name="ArtifactManager">
<artifact type="jar" name="TerrarumSansBitmap">
<output-path>$PROJECT_DIR$/FontTestGDX/lib</output-path>
<output-path>$PROJECT_DIR$/lib</output-path>
<root id="archive" name="TerrarumSansBitmap.jar">
<element id="module-output" name="BuildJAR_TerrarumSansBitmap" />
<element id="directory" name="META-INF">

0
.idea/codeStyles/Project.xml generated Normal file → Executable file
View File

0
.idea/codeStyles/codeStyleConfig.xml generated Normal file → Executable file
View File

0
.idea/kotlinc.xml generated Normal file → Executable file
View File

1
.idea/libraries/GdxLib.xml generated Normal file → Executable file
View File

@@ -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" />

9
.idea/libraries/KotlinJavaRuntime.xml generated Normal file → Executable file
View File

@@ -3,10 +3,19 @@
<CLASSES>
<root url="jar://$KOTLIN_BUNDLED$/lib/kotlin-runtime.jar!/" />
<root url="jar://$KOTLIN_BUNDLED$/lib/kotlin-reflect.jar!/" />
<root url="jar://$KOTLIN_BUNDLED$/lib/kotlin-stdlib.jar!/" />
<root url="jar://$KOTLIN_BUNDLED$/lib/kotlin-test.jar!/" />
<root url="jar://$KOTLIN_BUNDLED$/lib/kotlin-stdlib-jdk7.jar!/" />
<root url="jar://$KOTLIN_BUNDLED$/lib/kotlin-stdlib-jdk8.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$KOTLIN_BUNDLED$/lib/kotlin-runtime-sources.jar!/" />
<root url="jar://$KOTLIN_BUNDLED$/lib/kotlin-stdlib-sources.jar!/" />
<root url="jar://$KOTLIN_BUNDLED$/lib/kotlin-reflect-sources.jar!/" />
<root url="jar://$KOTLIN_BUNDLED$/lib/kotlin-test-sources.jar!/" />
<root url="jar://$KOTLIN_BUNDLED$/lib/kotlin-stdlib-jdk7-sources.jar!/" />
<root url="jar://$KOTLIN_BUNDLED$/lib/kotlin-stdlib-jdk8-sources.jar!/" />
</SOURCES>
</library>
</component>

0
.idea/libraries/TesterLib.xml generated Normal file → Executable file
View File

0
.idea/markdown-navigator.xml generated Normal file → Executable file
View File

0
.idea/markdown-navigator/profiles_settings.xml generated Normal file → Executable file
View File

2
.idea/misc.xml generated Normal file → Executable file
View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8.0_242" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

0
.idea/modules.xml generated Normal file → Executable file
View File

0
.idea/vcs.xml generated Normal file → Executable file
View File

1061
.idea/workspace.xml generated Normal file → Executable file

File diff suppressed because it is too large Load Diff

0
BuildJAR_TerrarumSansBitmap.iml Normal file → Executable file
View File

79
CONTRIBUTING.md Normal file → Executable file
View File

@@ -1,3 +1,5 @@
#### Pixel Artists Wanted: for Arabic (all four forms) and other Indian scripts (all the ligatures). Must willing to follow the styles and have a knowledge in Unicode. Your name will be inscribed in the list of contributors.
You can contribute to the font by fixing wrong glyphs, suggesting better ones, extending character set (letters for other writing systems or filling in the blanks on the existing ones), or code for other game frameworks (not limited to Java). Please leave pull request for that.
Font Spritesheets are stored in ```assets/graphics/fonts``` directory. Image format must be TGA with Alpha — no PNG. If someone needs PNG, they can batch-convert the font using utils like ImageMagick.
@@ -5,7 +7,7 @@ Font Spritesheets are stored in ```assets/graphics/fonts``` directory. Image for
#### Before getting started, you did read our design goals, right? Good. Now you may continue your awesome work.
### Ascenders, descenders, width informations
### Ascenders, descenders, width informations (aka Glyph Tags)
![Alas, use more modern browser or get better internet connexion!](glyph_height_pos_annotation.png)
@@ -34,46 +36,81 @@ Although the font is basically a Spritesheet, some of the sheet expects variable
Width is encoded in binary bits, on pixels. On the font spritesheet, every glyph has vertical dots on their top-right side (to be exact, every (16k - 1)th pixel on x axis). Above image is a sample of the font, with width information coloured in magenta. From top to bottom, each dot represents 1, 2, 4 and 8. For example, in the above image, ! (exclamation mark) has width of 5, " (double quote) has width of 6, # (octothorp) has width of 8, $ (dollar sign) has width of 9.
### Glyph Tagging System
### Glyph Tags
Green-tinted area (should be 10 px tall) contains the tags. Tags are defined as following:
```
(LSB) 0 == RTL
1 -+ 1 | Align to this X pos of prev char,
1 | 2 | only valid if write-on-top is 1
1 | 4 | and is centre-aligned and non-zero
1 -+ 8 | (if this is zero, floorOf(width/2) will be used instead)
0 -+ 0 Align 1 Align 0 Align 1 Align before
1 -+ 0 left 0 right 1 centre 1 the glyph
0 == Write on top of prev chars (e.g. diacritics)
1 == Diacritics stack 0:upward/1:downward
(MSB) X == undefined, should be 0
NOTE: If glyphs are right or centre aligned, they must be aligned in the
same way inside of the bitmap; the program assumes every variable-
width glyphs to have a width of 15, regardless of the tagged width.
If the diacritic is aligned before the glyph, the diacritic itself
is always assumed as left-aligned, as this font will swap position
of said diacritic and the glyph right before it.
(LSB) 0 == Use Compiler Directive (Undefined right now, keep it as 0)
1 -, 1 = Align to this X pos of prev char,
1 | 2 = only valid if write-on-top is 1
1 | 4 = and is centre-aligned and non-zero
1 -' 8 = (if this is zero, floorOf(width/2) will be used instead)
0 -, 0 Align 1 Align 0 Align 1 Align before
1 -' 0 left 0 right 1 centre 1 the glyph
1 == write-on-top, usually it's diatritics but not always (e.g. devanagari vowel sign O)
1 -, 0 Stack 1 Stack 0 Before 1 Up &
(MSB) 0 -' 0 up 0 down 1 &After 1 Down (e.g. U+0C48)
```
#### Stack Up/Down
When the tag is stack-up, it'll be drawn 4 px lower if the underlying
character is lowercase.
#### Align-To-This-X-Pos
Since this tag does not make sense for diacritics, they will use the value for compeletely different purpose:
0 : Nothing special
1 : Covers previous character; it's neither stack-up nor down.
Will be drawn 2 px lower if the underlying character is lowercase
2 : Joiner.
3..15: undefined
#### Diacritics That Comes Before and After
When this tag is set, the font compiler will replace this glyph with two extra code points given in the bitmap.
To implement those, this two extra code points are needed, which are provided in the Unicode's Reference Chart (www.unicode.org/charts/PDF/Uxxxx.pdf) The code points must be "drawn" in the bitmap, in the same manor as a tagging system. The zeroth column (x = 0) has the "before" character, the first column (x = 1) has the "after". All nineteen pixels (bits) are read by the font, which encompasses U+0000..U+EFFFF
For working examples, take a note at the bengali sprite sheet.
This tag can be used as a general "replace this with these" directive, as long as you're replacing it into two letters. This directive is exploited to construct dutch ligature "IJ" (U+0132 and U+0133), in the sheet LatinExtA.
Also note that the font compiler will not "stack" these diacritics.
#### NOTES
- If glyphs are right or centre aligned, they must be aligned in the same way inside of the bitmap; the font compiler assumes every variable-width glyphs to have a width of 15, regardless of the tagged width.
- If the diacritic is aligned before the glyph, the diacritic itself is always assumed as left-aligned, as the font compiler will exchange position of said diacritic and the glyph right before it.
![Visual representation of left/right/centre align](alignment_illustration.jpg)
(fun fact: it was drawn on Rhodia memopad with Lamy 2000, then photographed and edited on my iPhone. Letter used is a Cherokee WE Ꮺ)
### Technical Limitations
- 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
On this font, Hangul letters are printed by assemblying two or three letter pieces. There are 10 sets of Hangul letter pieces on the font. Top 6 are initials, middle 2 are medials, and bottom 2 are finals. On the rightmost side, there's eight assembled glyphs to help you with (assuming you have basic knowledge on the writing system). Top 6 tells you how to use 6 initials, and bottom 2 tells you how to use 2 finals.
This is a Kotlin-like pseudocode for assembling the glyph:
// NOTE: this code implements modern Hangul only, in the unicode range of 0xAC00..0xD7A3.
// the spritesheet is made to accomodate Johab encoding scheme, but can still be used with the following code.
// for the code for full Johab encoding (U+1100.. that includes Old Korean), please refer to the actual code in the repo.
function getHanChosung(hanIndex: Int) = hanIndex / (21 * 28)
function getHanJungseong(hanIndex: Int) = hanIndex / 28 % 21
function getHanJongseong(hanIndex: Int) = hanIndex % 28
jungseongWide = arrayOf(8, 12, 13, 17, 18, 21)
jungseongComplex = arrayOf(9, 10, 11, 14, 15, 16, 22)
jungseongWide = arrayOf(9,13,14,18,19)
jungseongComplex = arrayOf(10,11,12,15,16,17,20,23)
function getHanInitialRow(hanIndex: Int): Int {
val ret: Int

9
CONTRIBUTORS.txt Executable file
View File

@@ -0,0 +1,9 @@
Project Maintainer and Programmer
- minjaesong (Torvald)
This font was not possible without following artists:
- minjaesong (Torvald)
<< Append your name here. If you're getting consistent merge conflicts, push without this and leave a Issue on the GitHub page >>

Binary file not shown.

1
FontTestGDX/FontTestGDX.iml Normal file → Executable file
View File

@@ -10,5 +10,6 @@
<orderEntry type="library" name="KotlinJavaRuntime" level="project" />
<orderEntry type="library" name="GdxLib" level="project" />
<orderEntry type="library" name="TesterLib" level="project" />
<orderEntry type="module" module-name="BuildJAR_TerrarumSansBitmap" />
</component>
</module>

2
FontTestGDX/META-INF/MANIFEST.MF Normal file → Executable file
View File

@@ -1,6 +1,6 @@
Manifest-Version: 1.0
Class-Path: lib/gdx.jar lib/gdx-backend-lwjgl.jar lib/gdx-backend-lwjg
l-natives.jar lib/gdx-natives.jar lib/kotlin-stdlib.jar TerrarumSansB
l-natives.jar lib/gdx-natives.jar lib/kotlin-stdlib.jar lib/TerrarumSansB
itmap.jar
Main-Class: FontTestGDXKt

120
FontTestGDX/src/FontTestGDX.kt Normal file → Executable file
View File

@@ -22,11 +22,16 @@ class FontTestGDX : Game() {
lateinit var camera: OrthographicCamera
override fun create() {
font = GameFontBase("./assets", flipY = false, errorOnUnknownChar = true) // must test for two flipY cases
private val testing = false
val inTextFile = Gdx.files.internal("./FontTestGDX/demotext.txt")
val reader = inTextFile.reader()
private val demotextName = if (testing) "testtext.txt" else "demotext.txt"
private val outimageName = if (testing) "testing.PNG" else "demo.PNG"
override fun create() {
font = GameFontBase("./assets", flipY = false, errorOnUnknownChar = false) // must test for two flipY cases
val inTextFile = Gdx.files.internal("./$demotextName")
val reader = inTextFile.reader("UTF-8")
inputText = reader.readLines()
reader.close()
@@ -35,106 +40,9 @@ class FontTestGDX : Game() {
println("START")
val l = intArrayOf(0xFF00,
0xFF10,
0xFF20,
0xFF30,
0xFF40,
0xFF50,
0xFF60,
0xFF70,
0xFF80,
0xFF90,
0xFFA0,
0xFFB0,
0xFFC0,
0xFFD0,
0xFFE0,
0xFFF0,
0xFEF0,
0xFDF0,
0xFCF0,
0xFBF0,
0xFAF0,
0xF9F0,
0xF8F0,
0xF7F0,
0xF6F0,
0xF5F0,
0xF4F0,
0xF3F0,
0xF2F0,
0xF1F0,
0xF0F0,
0xF0F1,
0xF0F2,
0xF0F3,
0xF0F4,
0xF0F5,
0xF0F6,
0xF0F7,
0xF0F8,
0xF0F9,
0xF0FA,
0xF0FB,
0xF0FC,
0xF0FD,
0xF0FE,
0xF0FF,
0xF0EF,
0xF0DF,
0xF0CF,
0xF0BF,
0xF0AF,
0xF09F,
0xF08F,
0xF07F,
0xF06F,
0xF05F,
0xF04F,
0xF03F,
0xF02F,
0xF01F,
0xF00F,
0xF10F,
0xF20F,
0xF30F,
0xF40F,
0xF50F,
0xF60F,
0xF70F,
0xF80F,
0xF90F,
0xFA0F,
0xFB0F,
0xFC0F,
0xFD0F,
0xFE0F,
0xFF0F)
val s = "ᚱᛂᚴᛋᛂᛋᛏᛋᚮᚾᛔᚢᛏᛚᚮᛋ᛬ᚱᛂᚴᛋᛋᚢᚼᚾᚢᛘᚢᛚᚾᛏᚮ᛬ᛏᚮᛋᛁᚮᚵᛂᚢᛏᚮᚱᛘᛔᚱᛂᚴᛋᛏ᛭ᛋᚢᚼᚾᚢᛋᛘᚮᛁᚵᚾᛁᛂᛏᚮᛑ᛭ᚵᛂᚢᛏᚮᚱ"
var lc = 0
var sc = 0
while (lc < l.size) {
print(font.toColorCode(l[lc]))
print(s[sc])
lc++
sc++
if (sc == s.length) break
if (s[sc] == ' ') {
print(" ")
sc++
}
}
println("${font.noColorCode}\nEND")
println(font.toColorCode(0xF_EEC))
println(font.charsetOverrideDefault)
println(font.charsetOverrideBulgarian)
println(font.charsetOverrideSerbian)
frameBuffer = FrameBuffer(Pixmap.Format.RGBA8888, TEXW, TEXH, true)
@@ -185,7 +93,7 @@ class FontTestGDX : Game() {
if (!screenshotExported) {
val pixmap = ScreenUtils.getFrameBufferPixmap(0, 0, frameBuffer.width, frameBuffer.height)
PixmapIO.writePNG(Gdx.files.local("demo.PNG"), pixmap)
PixmapIO.writePNG(Gdx.files.local(outimageName), pixmap)
pixmap.dispose()
screenshotExported = true
@@ -251,7 +159,7 @@ class FontTestGDX : Game() {
lateinit var appConfig: LwjglApplicationConfiguration
const val TEXW = 874
const val TEXH = 2060
const val TEXH = 2400
fun main(args: Array<String>) {
appConfig = LwjglApplicationConfiguration()

4
LICENSE.md Normal file → Executable file
View File

@@ -1,6 +1,4 @@
Terrarum Sans Bitmap
Copyright (c) 2017-2018 Minjae Song (Torvald) and the contributors
Copyright (c) 2017-2020 see CONTRIBUTORS.txt
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

0
META-INF/MANIFEST.MF Normal file → Executable file
View File

BIN
PUA_allocation_chart.xlsx Normal file → Executable file

Binary file not shown.

20
README.md Normal file → Executable file
View File

@@ -1,17 +1,18 @@
# Terrarum Sans Bitmap
![Font sample](demo.PNG)
![Font sample — necessary information in this image is also provided below.](demo.PNG)
This font is a bitmap font used in [my game project called Terrarum](https://gitlab.com/minjaesong/terrarum) (hence the name). The font supports more than 90 % of european languages, as well as Chinese, Japanese and Korean. More technical side, it supports Latin-1 Supplement, Latin Ext-A, Latin Ext-B, IPA Extension (required by some languages), Greek, Cyrillic (+ Bulgarian, Serbian variants) and the supplement, Armenian, Thai (beta version), Georgian, Unicode Punctuations, CJK Punctuations, Kana, Chinese (limited to Unihan and Ext-A), Hangul (all 11 172 possible syllables) and Fullwidth forms.
This font is a bitmap font used in [my game project called Terrarum](https://github.com/minjaesong/Terrarum) (hence the name). The font supports more than 90 % of european languages, as well as Chinese, Japanese and Korean. More technical side, it supports Latin-1 Supplement, Latin Ext-A/B/C, IPA Extension, Greek, Cyrillic (+ Bulgarian, Serbian variants) and the supplement, Armenian, Devanagari, Bengali, Thai, Georgian (Mkhedruli and Mtavruli), General Punctuations, Super/Subscrips, CJK Punctuations, All of the Kana (minus the Hentaigana), Chinese (limited to Unihan and Ext-A), Hangul (every possible syllables) and Fullwidth forms.
The JAR package is meant to be used with Slick2d (extends ```Font``` class) and LibGDX (extends ```BitmapFont``` class). If you are not using the framework, please refer to the __Font metrics__ section to implement the font metrics correctly on your system.
The JAR package is meant to be used with LibGDX (extends ```BitmapFont``` class). If you are not using the framework, please refer to the __Font metrics__ section to implement the font metrics correctly on your system.
The issue page is open. If you have some issues to submit, or have a question, please leave it on the page.
#### Little notes
- To display Bulgarian/Serbian variants, you need special Control Characters. (GameFontBase.charsetOverrideBulgarian -- U+FFFF9; GameFontBase.charsetOverrideSerbian -- U+FFFFA)
- All Han characters are in Chinese variant, no other variants are to be supported as most Chinese, Japanese and Korean can understand other's variant and to be honest, we don't bother anyway.
- Indian script in general is not perfect: this font will never do the proper ligatures (I can't draw all the 1 224 possible combinations). Hopefully it's still be able to understand without them.
- To display Bulgarian/Serbian variants, you need special Control Characters. (GameFontBase.charsetOverrideBulgarian -- U+FFFC1; GameFontBase.charsetOverrideSerbian -- U+FFFC2)
- All Han characters are in Chinese variant, no other variants are to be supported as most Chinese, Japanese and Korean people can understand other's variant and as long as I can, we don't bother anyway.
- Indian script in general is not perfect: right now this font will never do the proper ligatures (I can't draw all the 1 224 possible combinations). Hopefully it's still be able to understand without them.
- Slick2d versions are now unsupported. I couldn't extend myself to work on both versions, but I'm still welcome to merge your pull requests.
### Design Goals
@@ -20,6 +21,9 @@ The issue page is open. If you have some issues to submit, or have a question, p
- Combininig with the sans-serif, this stands for **no over-simplification**
- Condensed capitals for efficient space usage
## Download
- Go ahead to the [release tab](https://github.com/minjaesong/Terrarum-sans-bitmap/releases), and download the most recent version. It is **not** advised to use the .jar found within the repository, they're experimental builds I use during the development, and may contain bugs like leaking memory.
## Using on your game
@@ -68,7 +72,7 @@ On your code (Java):
}
### Using on Slick2d
### Using on Slick2d (legacy version only)
On your code (Kotlin):
@@ -126,4 +130,4 @@ Please refer to [CONTRIBUTING.md](https://github.com/minjaesong/Terrarum-sans-bi
Thanks to kind people of [/r/Typography](https://www.reddit.com/r/typography/) for amazing feedbacks.
CJK Ideographs are powered by [WenQuanYi Font](http://wenq.org/wqy2/index.cgi?BitmapSong). The font is distributed under the GNU GPL version 2. Although, in some countries including where I'm based on, the shapes of typefaces are not copyrightable (the program codes—e.g. TTF—do), we would like to give a credit for the font and the people behind it.
CJK Ideographs are powered by [WenQuanYi Font](http://wenq.org/wqy2/index.cgi?BitmapSong). The font is distributed under the GNU GPL version 2. Although the shapes of typefaces are not copyrightable (the program codes—e.g. TTF—do), we would like to give a credit for the font and the people behind it.

Binary file not shown.

0
alignment_illustration.jpg Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 59 KiB

After

Width:  |  Height:  |  Size: 59 KiB

BIN
assets/ascii_variable.tga Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 320 KiB

After

Width:  |  Height:  |  Size: 320 KiB

0
assets/cjkpunct.tga Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 50 KiB

BIN
assets/cyrilic_bulgarian_variable.tga Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 120 KiB

After

Width:  |  Height:  |  Size: 120 KiB

BIN
assets/cyrilic_serbian_variable.tga Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 120 KiB

After

Width:  |  Height:  |  Size: 120 KiB

BIN
assets/cyrilic_variable.tga Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 380 KiB

After

Width:  |  Height:  |  Size: 380 KiB

BIN
assets/devanagari_bengali_variable.tga Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 320 KiB

After

Width:  |  Height:  |  Size: 320 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 140 KiB

BIN
assets/fullwidth_forms.tga Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 40 KiB

0
assets/futhark.tga Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 68 KiB

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 320 KiB

BIN
assets/greek_variable.tga Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 120 KiB

After

Width:  |  Height:  |  Size: 120 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 262 KiB

After

Width:  |  Height:  |  Size: 2.6 MiB

BIN
assets/hayeren_variable.tga Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 120 KiB

After

Width:  |  Height:  |  Size: 120 KiB

BIN
assets/insular_variable.tga Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

BIN
assets/ipa_ext_variable.tga Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 120 KiB

After

Width:  |  Height:  |  Size: 220 KiB

BIN
assets/kana.tga Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 210 KiB

After

Width:  |  Height:  |  Size: 210 KiB

0
assets/kartuli_allcaps_variable.tga Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 60 KiB

After

Width:  |  Height:  |  Size: 60 KiB

0
assets/kartuli_variable.tga Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 60 KiB

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 160 KiB

After

Width:  |  Height:  |  Size: 160 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 260 KiB

After

Width:  |  Height:  |  Size: 260 KiB

BIN
assets/latinExtC_variable.tga Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

BIN
assets/latinExt_additional_variable.tga Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 320 KiB

After

Width:  |  Height:  |  Size: 320 KiB

BIN
assets/puae000-e0ff.tga Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 324 KiB

After

Width:  |  Height:  |  Size: 324 KiB

BIN
assets/richtext_furigana.tga Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

0
assets/thai_variable.tga Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 120 KiB

After

Width:  |  Height:  |  Size: 120 KiB

0
assets/tsalagi_variable.tga Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 120 KiB

After

Width:  |  Height:  |  Size: 120 KiB

BIN
assets/unipunct_variable.tga Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 120 KiB

After

Width:  |  Height:  |  Size: 200 KiB

0
assets/wenquanyi.tga.gz Normal file → Executable file
View File

BIN
demo.PNG Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 120 KiB

After

Width:  |  Height:  |  Size: 146 KiB

53
FontTestGDX/demotext.txt → demotext.txt Normal file → Executable file
View File

@@ -3,16 +3,16 @@
There are many bitmap fonts on the internet. You care for the multilingual support, but alas!
most of them do not support your language, vector fonts take too much time to load, and even
then their legibility suffers because fuck built-in antialias.
then their legibility suffers because screw built-in antialias.
You somehow found a multilingual one, and it makes your game look like an old computer, and you say:
“Well, better than nothing… no, its ugly.”
You speak japanese and you wish to support it, but then このクソなfont only goot for displaying
Japanese, it's not even multilingual, and their English look uncanny and inconsistent as hell.
You speak japanese and you wish to support it, but then このクソなfont only good for displaying
Japanese, its not even truly multilingual, and their English look uncanny and inconsistent.
Eventually you just mix different fonts together, and the results were always infuriating.
Eventually you just mix different fonts together, and the results were always mildly infuriating.
No more suffering. This font has everything you need.
@@ -26,25 +26,26 @@ How multilingual? Real multilingual!
􏻬գրիչս վայր դրի, վեր կացա և պատրաստվում էի, որ քնեմ, երբ հանկարծ դռանս զանգակը հնչեց􀀀
􏻬ՄՇԱԿԻՉ ԿԱՄ ԿԵՆՏՐՈՆԱԿԱՆ ՄՇԱԿԻՉ ՀԱՆԳՈՒՅՑԸ ՀԱՆԴԻՍԱՆՈՒՄ Է ՀԱՄԱԿԱՐԳՉԻ ՍԱՐՔԱՎՈՐՈՒՄՆԵՐԻՑ􀀀
􏻬Zəfər, jaketini də papağını da götür, bu axşam hava çox soyuq olacaq􀀀
􏻬󿿹Под южно дърво, цъфтящо в синьо, бягаше малко пухкаво зайче󿿸􀀀
􏻬আমি কাঁচ খেতে পারি, তাতে আমার কোনো ক্ষতি হয় না। 􀀀
􏻬󿿁Под южно дърво, цъфтящо в синьо, бягаше малко пухкаво зайче󿿀􀀀
􏻬ᎠᏍᎦᏯᎡᎦᎢᎾᎨᎢᎣᏍᏓᎤᎩᏍᏗᎥᎴᏓᎯᎲᎢᏔᎵᏕᎦᏟᏗᏖᎸᎳᏗᏗᎧᎵᎢᏘᎴᎩ ᏙᏱᏗᏜᏫᏗᏣᏚᎦᏫᏛᏄᏓᎦᏝᏃᎠᎾᏗᎭᏞᎦᎯᎦᏘᏓᏠᎨᏏᏕᏡᎬᏢᏓᏥᏩᏝᎡᎢᎪᎢ􀀀
􏻬ᎠᎦᏂᏗᎮᎢᎫᎩᎬᏩᎴᎢᎠᏆᏅᏛᎫᏊᎾᎥᎠᏁᏙᎲᏐᏈᎵᎤᎩᎸᏓᏭᎷᏤᎢᏏᏉᏯᏌᏊ ᎤᏂᏋᎢᏡᎬᎢᎰᏩᎬᏤᎵᏍᏗᏱᎩᎱᎱᎤᎩᎴᎢᏦᎢᎠᏂᏧᏣᏨᎦᏥᎪᎥᏌᏊᎤᎶᏒᎢᎢᏡᎬᎢ􀀀
􏻬ᎹᎦᎺᎵᏥᎻᎼᏏᎽᏗᏩᏂᎦᏘᎾᎿᎠᏁᎬᎢᏅᎩᎾᏂᎡᎢᏌᎶᎵᏎᎷᎠᏑᏍᏗᏪᎩ ᎠᎴ ᏬᏗᏲᏭᎾᏓᏍᏓᏴᏁᎢᎤᎦᏅᏮᏰᎵᏳᏂᎨᎢ􀀀
􏻬Příliš žluťoučký kůň úpěl ďábelské ódy􀀀
􏻬Quizdeltagerne spiste jordbær med fløde, mens cirkusklovnen Walther spillede på xylofon􀀀
􏻬PACK MY BOX WITH FIVE DOZEN LIQUOR JUGS􀀀
􏻬hƿæt ƿe ᵹardena inᵹear ꝺaᵹum þeoꝺ cynninᵹa þꞃym ᵹeꝼꞃumon􀀀
􏻬Victor jagt zwölf Boxkämpfer quer über den großen Sylter Deich GROẞEN GROẞE􀀀
􏻬ζαφείρι δέξου πάγκαλο, βαθων ψυχης το σημα􀀀
􏻬ζαφείρι δέξου πάγκαλο, βαθν ψυχς τ σμα􀀀
􏻬ΔΙΑΦΥΛΆΞΤΕ ΓΕΝΙΚΆ ΤΗ ΖΩΉ ΣΑΣ ΑΠΌ ΒΑΘΕΙΆ ΨΥΧΙΚΆ ΤΡΑΎΜΑΤΑ􀀀
􏻬სწრაფი ყავისფერი მელა გადაახტა ზარმაც ძაღლს ᲘᲜᲢᲔᲚ ᲞᲔᲜᲢᲘᲣᲛᲘ ᲛᲘᲙᲠᲝᲞᲠᲝᲪᲔᲡᲝᲠᲘ􀀀
􏻬ऋषियों को सताने वाले दुष्ट राक्षसों के राजा रावण का सर्वनाश करने वाले विष्णुवतार भगवान श्रीराम अयोध्या के महाराज दशरथ के􀀀
􏻬Kæmi ný öxi hér, ykist þjófum nú bæði víl og ádrepa􀀀
􏻬Ꝺꝼuaꞅcail Íoꞅa Úꞃṁac na hÓiᵹe Beannaiꞇe póꞃ Éaḃa aᵹus Áꝺaiṁ􀀀
􏻬Ċuaiġ bé ṁórṡáċ le dlúṫspád fíorḟinn trí hata mo ḋea-ṗorcáin ḃig􀀀
􏻬Ċuaiġ bé ṁórṡáċ le dlúṫspád fíoꝛḟinn trí hata mo ḋea-ṗoꝛcáin ḃig􀀀
􏻬あめつちほしそら やまかはみねたに くもきりむろこけ ひといぬうへすゑ ゆわさるおふせよ えの𛀁をなれゐて􀀀
􏻬トリナクコヱス ユメサマセ ミヨアケワタル ヒンカシヲ ソライロハエテ オキツヘニ ホフネムレヰヌ モヤノウチ􀀀
􏻬田居に出で 菜摘むわれをぞ 君召すと 求食り追ひゆく 山城の 打酔へる子ら 藻葉干せよ え舟繋けぬ􀀀
􏻬정 참판 양반댁 규수 큰 교자 타고 혼례 치른 날 하얬다 도럄직한 퀡봹퉪헰􀀀
􏻬정 참판 양반댁 규수 큰 교자 타고 혼례 치른 날 하얬다 도럄직한 퀡봹퉪헰ꥸᅦퟗꥸᅦퟗᄋힳᆫㅗㅜㅑㄷ􀀀
􏻬Četri psihi faķīri vēlu vakarā zāģēja guļbūvei durvis, fonā šņācot mežam􀀀
􏻬Įlinkdama fechtuotojo špaga sublykčiojusi pragręžė apvalų arbūzą􀀀
􏻬Ѕидарски пејзаж: шугав билмез со чудење џвака ќофте и кељ на туѓ цех􀀀
@@ -53,13 +54,14 @@ How multilingual? Real multilingual!
􏻬कः खगौघाङचिच्छौजा झाञ्ज्ञोऽटौठीडडण्ढणः। तथोदधीन् पफर्बाभीर्मयोऽरिल्वाशिषां सहः॥􀀀
􏻬Înjurând pițigăiat, zoofobul comandă vexat whisky și tequila􀀀
􏻬Широкая электрификация южных губерний даст мощный толчок подъёму сельского хозяйства􀀀
􏻬󿿺Ајшо, лепото и чежњо, за љубав срца мога дођи у Хаџиће на кафу󿿸􀀀
􏻬󿿂Ајшо, лепото и чежњо, за љубав срца мога дођи у Хаџиће на кафу󿿀􀀀
􏻬Jovencillo emponzoñado de whisky: ¡qué figurota exhibe!􀀀
􏻬นายสังฆภัณฑ์ เฮงพิทักษ์ฝั่ง ผู้เฒ่าซึ่งมีอาชีพเป็นฅนขายฃวด ถูกตำรวจปฏิบัติการจับฟ้องศาล ฐานลักนาฬิกาคุณหญิงฉัตรชฎา ฌานสมาธิ􀀀
􏻬Pijamalı hasta yağız şoföre çabucak güvendi􀀀
􏻬Жебракують філософи при ґанку церкви в Гадячі, ще й шатро їхнє п’яне знаємо􀀀
􏻬Do bạch kim rất quý nên sẽ dùng để lắp vô xương􀀀
􏻬日堀油告観観藤村抄海評業庁経賃室弁市。太撮収改売週法所何都慣次現。価紙一無三洋日話転手治稿載末替付致治。􀀀
􏻬[pʰnɣɬɥi.m͡ŋχɫʍɨnaɸ.cθʊɫɯ.ɹɨɫʏ͡ɛx.ɯ͡ɣaxɲaɣɫ.ɸtʰɑɣɴ]􀀀
􏃯Features:􀀀
@@ -74,10 +76,10 @@ How multilingual? Real multilingual!
􏼀ᚱ􏼐ᛂ􏼠ᚴ􏼰ᛋ􏽀ᛂ􏽐ᛋ􏽠ᛏ􏽰ᛋ􏾀ᚮ􏾐ᚾ􏾠ᛔ􏾰ᚢ􏿀ᛏ􏿐ᛚ􏿠ᚮ􏿰ᛋ􏻰᛬􏷰ᚱ􏳰ᛂ􏯰ᚴ􏫰ᛋ􏧰ᛋ􏣰ᚢ􏟰ᚼ􏛰ᚾ􏗰ᚢ􏓰ᛘ􏏰ᚢ􏋰ᛚ􏇰ᚾ􏃰ᛏ􏃱ᚮ􏃲᛬􏃳ᛏ􏃴ᚮ􏃵ᛋ􏃶ᛁ􏃷ᚮ􏃸ᚵ􏃹ᛂ􏃺ᚢ􏃻ᛏ􏃼ᚮ􏃽ᚱ􏃾ᛘ􏃿ᛔ􏃯ᚱ􏃟ᛂ􏃏ᚴ􏂿ᛋ􏂯ᛏ􏂟᛭􏂏ᛋ􏁿ᚢ􏁯ᚼ􏁟ᚾ􏁏ᚢ􏀿ᛋ􏀯ᛘ􏀟ᚮ􏀏ᛁ􏄏ᚵ􏈏ᚾ􏌏ᛁ􏐏ᛂ􏔏ᛏ􏘏ᚮ􏜏ᛑ􏠏᛭􏤏ᚵ􏨏ᛂ􏬏ᚢ􏰏ᛏ􏴏ᚮ􏸏ᚱ􀀀
􎳌Colour-code that supports 65535 opaque or semi-transparent colours via 4 bit ARGB􀀀
􎳌Colour-code that supports 4096 colours via 4 bit RGB􀀀
􏿿󿿹Гномът Доцьо приключи спящ в шейна за жаби󿿸 (Bulgarian)􀀀
􏿿󿿺Љубазни фењерџија чађавог лица хоће да ми покаже штос󿿸 (Serbian)􀀀
􏿿󿿁Щиглецът се яде само пържен в юфка без чушки и хвойна󿿀 (Bulgarian)􀀀
􏿿󿿂Љубазни фењерџија чађавог лица хоће да ми покаже штос󿿀 (Serbian)􀀀
􏿿Разъяренный чтец эгоистично бьёт пятью жердями шустрого фехтовальщика (Russian)􀀀
􎳌Control characters to support Bulgarian and Serbian letter shapes on the fly􀀀
@@ -90,13 +92,28 @@ How multilingual? Real multilingual!
􎳌For all those dash-pedants, we have en-dash, em-dash, and even horizontal bars!􀀀
􏿿5¹⁹₃₂ inch is 142.1 mm · (C₂F₄)ₙ is godly · Error = MoreCode²􀀀
􏿿NOTE: we dont do fractions. 142¹₁₀ mm is illegal!􀀀
􎳌Did you know Unicode supports arbitrary fractions? Actually I didnt… as they abused super/subscripts!􀀀
􏿿ᄋᆡ급 일 ᄭᅡᄃᆞᆰ에 영국 ᄒᆞ고 불난셔 ᄒᆞ고 ᄃᆡ단이 시비가 잇슬 모양 인ᄃᆡ􀀀
􏿿일본 농샹공부에셔 젼긔학 학ᄉᆞ 셋ᄉᆞᆯ 미국과 구라파로 보내셔 젼화 쓰ᄂᆞᆫ 법을 더ᄇᆡ호게 ᄒᆞ더라􀀀
􏿿일쳔 구ᄇᆡᆨ년에 불난셔 셔울 파리스에 만국 박남회를 버릴터 인ᄃᆡ 각국이 다 물화와 졔조품을 거긔 보낼터이더라􀀀
􎳌Rejoice, now we can render Old Korean in a correct way!􀀀
􏃯Unicode References:􀀀
Basic Latin Latin-1 Latin Extension A Latin Extionsion B IPA Extension Greek Cyrillic
Cyrillic Supplement Armenian Devanagari Thai Georgian Runic Cherokee Georgian Extended
General Punctuations CJK Symbols Kana Kana Phonetic Extension CJK Unihan Extension A CJK Unihan
Hangul Syllables Fullwidth Forms Kana Supplement
Basic Latin Latin-1 Supplement Latin Extended-A Latin Extended-B IPA Extension Greek Cyrillic
Cyrillic Supplement Armenian Devanagari Bengali Thai Georgian Hangul Jamo Cherokee Runic
Georgian Extended Greek Extended General Punctuations Superscripts and Subscripts CJK Symbols
Latin Extended-C Kana Hangul Compatibility Jamo Kana Phonetic Extensions CJK Unihan Extension A
CJK Unihan Latin Extended-D Hangul Jamo Extended-A Hangul Syllables Hangul Jamo Extended-B
Fullwidth Forms Kana Supplement
GitHubs issue page is open! You can report any 􏽕errors􀀀, or leave 􏽕suggestions􀀀.
You can help this font to be more versatile. (for more languages, more frameworks) 􏽕Clone􀀀 this repo, make
changes, and make a 􏽕pull request􀀀! I appreciate any and all supports.
changes, and make a 􏽕pull request􀀀! I appreciate any and all supports.
<EFBFBD> 􎳌文字化け!􀀀 <20>

0
font_drawing_template.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

0
glyph_height_pos_annotation.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

0
samples/README.md Normal file → Executable file
View File

0
samples/wikipedia_x86.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 75 KiB

After

Width:  |  Height:  |  Size: 75 KiB

50
src/net/torvald/terrarumsansbitmap/GlyphProps.kt Normal file → Executable file
View File

@@ -9,13 +9,24 @@ data class GlyphProps(
val alignWhere: Int,
val alignXPos: Int,
val rtl: Boolean = false,
val diacriticsStackDown: Boolean = false,
val diacriticsBeforeGlyph: Boolean = false
val stackWhere: Int = 0,
var extInfo: IntArray? = null
) {
companion object {
const val LEFT = 0
const val RIGHT = 1
const val CENTRE = 2
const val ALIGN_LEFT = 0
const val ALIGN_RIGHT = 1
const val ALIGN_CENTRE = 2
const val ALIGN_BEFORE = 3
const val STACK_UP = 0
const val STACK_DOWN = 1
const val STACK_BEFORE_N_AFTER = 2
const val STACK_UP_N_DOWN = 3
const val DIA_OVERLAY = 1
const val DIA_JOINER = 2
private fun Boolean.toInt() = if (this) 1 else 0
}
constructor(width: Int, tags: Int) : this(
@@ -24,7 +35,32 @@ data class GlyphProps(
tags.ushr(5).and(3),
tags.ushr(1).and(15),
tags.and(1) == 1,
tags.ushr(8).and(1) == 1,
tags.ushr(5).and(3) == 3
tags.ushr(8).and(3)
)
fun isOverlay() = writeOnTop && alignXPos == 1
override fun hashCode(): Int {
val tags = rtl.toInt() or alignXPos.shl(1) or alignWhere.shl(5) or
writeOnTop.toInt().shl(7) or stackWhere.shl(8)
var hash = -2128831034
extInfo?.forEach {
hash = hash xor it
hash = hash * 16777619
}
hash = hash xor tags
hash = hash * 167677619
return hash
}
override fun equals(other: Any?): Boolean {
// comparing hash because I'm lazy
return other is GlyphProps && this.hashCode() == other.hashCode()
}
fun requiredExtInfoCount() = if (stackWhere == STACK_BEFORE_N_AFTER) 2 else 0
}

1751
src/net/torvald/terrarumsansbitmap/gdx/GameFontBase.kt Normal file → Executable file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,168 @@
/*
* Terrarum Sans Bitmap
*
* Copyright (c) 2018 Minjae Song (Torvald)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package net.torvald.terrarumsansbitmap.gdx
import com.badlogic.gdx.files.FileHandle
import com.badlogic.gdx.graphics.Pixmap
/**
* Breaks one pixmap atlas into many child pixmaps
*
* Created by minjaesong on 2018-09-17.
*/
class PixmapRegionPack(
pixmapAtlas: Pixmap,
val tileW: Int,
val tileH: Int,
val hGap: Int = 0,
val vGap: Int = 0,
val hFrame: Int = 0,
val vFrame: Int = 0,
val xySwapped: Boolean = false // because Unicode chart does, duh
) {
//constructor(ref: String, tileW: Int, tileH: Int, hGap: Int = 0, vGap: Int = 0, hFrame: Int = 0, vFrame: Int = 0, xySwapped: Boolean = false) :
// this(Pixmap(ref), tileW, tileH, hGap, vGap, hFrame, vFrame, xySwapped)
constructor(fileHandle: FileHandle, tileW: Int, tileH: Int, hGap: Int = 0, vGap: Int = 0, hFrame: Int = 0, vFrame: Int = 0, xySwapped: Boolean = false) :
this(Pixmap(fileHandle), tileW, tileH, hGap, vGap, hFrame, vFrame, xySwapped)
val horizontalCount = (pixmapAtlas.width - 2 * hFrame + hGap) / (tileW + hGap)
val verticalCount = (pixmapAtlas.height - 2 * vFrame + vGap) / (tileH + vGap)
val regions: Array<Pixmap>
init {
// test print the whole sheet
/*pixmap.pixels.rewind()
for (y in 0 until pixmap.height) {
for (x in 0 until pixmap.width) {
pixmap.pixels.get() // discard r
pixmap.pixels.get() // discard g
pixmap.pixels.get() // discard b
val a = pixmap.pixels.get()
if (a == 255.toByte()) print("█") else print("·")
}
println()
}
println()*/
pixmapAtlas.pixels.rewind()
if (!xySwapped) {
regions = Array<Pixmap>(horizontalCount * verticalCount) {
val rx = (it % horizontalCount * (tileW + hGap)) + hFrame // pixel, not index
val ry = (it / horizontalCount * (tileH + vGap)) + vFrame // pixel, not index
val region = Pixmap(tileW, tileH, Pixmap.Format.RGBA8888)
region.pixels.rewind()
// for every "scanline"
for (y in 0 until tileH) {
val offsetY = (ry + y) * (pixmapAtlas.width * 4) + (vFrame * pixmapAtlas.width * 4)
val offsetX = rx * 4 + hFrame * 4
//println("offset: ${offsetX + offsetY}")
val bytesBuffer = ByteArray(4 * tileW)
pixmapAtlas.pixels.position(offsetY + offsetX)
pixmapAtlas.pixels.get(bytesBuffer, 0, bytesBuffer.size)
// test print bytesbuffer
/*bytesBuffer.forEachIndexed { index, it ->
if (index % 4 == 3) {
if (it == 255.toByte()) print("█") else print("·")
}
}
println()*/
region.pixels.put(bytesBuffer)
}
//println()
// todo globalFlipY ?
/*return*/region
}
}
else {
regions = Array<Pixmap>(horizontalCount * verticalCount) {
val rx = (it / verticalCount * (tileW + hGap)) + hFrame
val ry = (it % verticalCount * (tileH + vGap)) + vFrame
val region = Pixmap(tileW, tileH, Pixmap.Format.RGBA8888)
region.pixels.rewind()
// for every "scanline"
for (y in 0 until tileH) {
val offsetY = (ry + y) * (pixmapAtlas.width * 4) + (vFrame * pixmapAtlas.width * 4)
val offsetX = rx * 4 + hFrame * 4
//println("offset: ${offsetX + offsetY}")
val bytesBuffer = ByteArray(4 * tileW)
pixmapAtlas.pixels.position(offsetY + offsetX)
pixmapAtlas.pixels.get(bytesBuffer, 0, bytesBuffer.size)
// test print bytesbuffer
/*bytesBuffer.forEachIndexed { index, it ->
if (index % 4 == 3) {
if (it == 255.toByte()) print("█") else print("·")
}
}
println()*/
region.pixels.put(bytesBuffer)
}
//println()
// todo globalFlipY ?
/*return*/region
}
}
}
fun get(x: Int, y: Int) = regions[y * horizontalCount + x]
fun dispose() {
regions.forEach { it.dispose() }
}
}

View File

@@ -27,6 +27,7 @@ package net.torvald.terrarumsansbitmap.gdx
import com.badlogic.gdx.files.FileHandle
import com.badlogic.gdx.graphics.Texture
import com.badlogic.gdx.graphics.g2d.TextureRegion
import com.badlogic.gdx.utils.Disposable
/**
* Created by minjaesong on 2017-06-15.
@@ -38,13 +39,14 @@ class TextureRegionPack(
val hGap: Int = 0,
val vGap: Int = 0,
val hFrame: Int = 0,
val vFrame: Int = 0
) {
val vFrame: Int = 0,
val xySwapped: Boolean = false // because Unicode chart does, duh
): Disposable {
constructor(ref: String, tileW: Int, tileH: Int, hGap: Int = 0, vGap: Int = 0, hFrame: Int = 0, vFrame: Int = 0) :
this(Texture(ref), tileW, tileH, hGap, vGap, hFrame, vFrame)
constructor(fileHandle: FileHandle, tileW: Int, tileH: Int, hGap: Int = 0, vGap: Int = 0, hFrame: Int = 0, vFrame: Int = 0) :
this(Texture(fileHandle), tileW, tileH, hGap, vGap, hFrame, vFrame)
constructor(ref: String, tileW: Int, tileH: Int, hGap: Int = 0, vGap: Int = 0, hFrame: Int = 0, vFrame: Int = 0, xySwapped: Boolean = false) :
this(Texture(ref), tileW, tileH, hGap, vGap, hFrame, vFrame, xySwapped)
constructor(fileHandle: FileHandle, tileW: Int, tileH: Int, hGap: Int = 0, vGap: Int = 0, hFrame: Int = 0, vFrame: Int = 0, xySwapped: Boolean = false) :
this(Texture(fileHandle), tileW, tileH, hGap, vGap, hFrame, vFrame, xySwapped)
companion object {
/** Intented for Y-down coord system, typically fon Non-GDX codebase */
@@ -59,23 +61,39 @@ class TextureRegionPack(
init {
//println("texture: $texture, dim: ${texture.width} x ${texture.height}, grid: $horizontalCount x $verticalCount, cellDim: $tileW x $tileH")
regions = Array<TextureRegion>(horizontalCount * verticalCount, {
val region = TextureRegion()
val rx = (it % horizontalCount * (tileW + hGap)) + hFrame
val ry = (it / horizontalCount * (tileH + vGap)) + vFrame
if (!xySwapped) {
regions = Array<TextureRegion>(horizontalCount * verticalCount) {
val region = TextureRegion()
val rx = (it % horizontalCount * (tileW + hGap)) + hFrame
val ry = (it / horizontalCount * (tileH + vGap)) + vFrame
region.setRegion(texture)
region.setRegion(rx, ry, tileW, tileH)
region.setRegion(texture)
region.setRegion(rx, ry, tileW, tileH)
region.flip(false, globalFlipY)
region.flip(false, globalFlipY)
/*return*/region
})
/*return*/region
}
}
else {
regions = Array<TextureRegion>(horizontalCount * verticalCount) {
val region = TextureRegion()
val rx = (it / verticalCount * (tileW + hGap)) + hFrame
val ry = (it % verticalCount * (tileH + vGap)) + vFrame
region.setRegion(texture)
region.setRegion(rx, ry, tileW, tileH)
region.flip(false, globalFlipY)
/*return*/region
}
}
}
fun get(x: Int, y: Int) = regions[y * horizontalCount + x]
fun dispose() {
override fun dispose() {
texture.dispose()
}

0
src/net/torvald/terrarumsansbitmap/readme.md Normal file → Executable file
View File

View File

@@ -1,790 +0,0 @@
/*
* Terrarum Sans Bitmap
*
* Copyright (c) 2017 Minjae Song (Torvald)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package net.torvald.terrarumsansbitmap.slick2d
/*import net.torvald.terrarumsansbitmap.gdx.GameFontBase
import net.torvald.terrarumsansbitmap.gdx.GameFontBase.Companion.JUNG_COUNT
import net.torvald.terrarumsansbitmap.gdx.GameFontBase.Companion.JONG_COUNT
import net.torvald.terrarumsansbitmap.gdx.GameFontBase.Companion.W_ASIAN_PUNCT
import net.torvald.terrarumsansbitmap.gdx.GameFontBase.Companion.W_HANGUL
import net.torvald.terrarumsansbitmap.gdx.GameFontBase.Companion.W_KANA
import net.torvald.terrarumsansbitmap.gdx.GameFontBase.Companion.W_UNIHAN
import net.torvald.terrarumsansbitmap.gdx.GameFontBase.Companion.W_LATIN_WIDE
import net.torvald.terrarumsansbitmap.gdx.GameFontBase.Companion.W_VAR_INIT
import net.torvald.terrarumsansbitmap.gdx.GameFontBase.Companion.HGAP_VAR
import net.torvald.terrarumsansbitmap.gdx.GameFontBase.Companion.H
import net.torvald.terrarumsansbitmap.gdx.GameFontBase.Companion.H_UNIHAN
import net.torvald.terrarumsansbitmap.gdx.GameFontBase.Companion.SIZE_CUSTOM_SYM
import net.torvald.terrarumsansbitmap.gdx.GameFontBase.Companion.SHEET_ASCII_VARW
import net.torvald.terrarumsansbitmap.gdx.GameFontBase.Companion.SHEET_HANGUL
import net.torvald.terrarumsansbitmap.gdx.GameFontBase.Companion.SHEET_EXTA_VARW
import net.torvald.terrarumsansbitmap.gdx.GameFontBase.Companion.SHEET_EXTB_VARW
import net.torvald.terrarumsansbitmap.gdx.GameFontBase.Companion.SHEET_KANA
import net.torvald.terrarumsansbitmap.gdx.GameFontBase.Companion.SHEET_CJK_PUNCT
import net.torvald.terrarumsansbitmap.gdx.GameFontBase.Companion.SHEET_UNIHAN
import net.torvald.terrarumsansbitmap.gdx.GameFontBase.Companion.SHEET_CYRILIC_VARW
import net.torvald.terrarumsansbitmap.gdx.GameFontBase.Companion.SHEET_FW_UNI
import net.torvald.terrarumsansbitmap.gdx.GameFontBase.Companion.SHEET_UNI_PUNCT_VARW
import net.torvald.terrarumsansbitmap.gdx.GameFontBase.Companion.SHEET_GREEK_VARW
import net.torvald.terrarumsansbitmap.gdx.GameFontBase.Companion.SHEET_THAI_VARW
import net.torvald.terrarumsansbitmap.gdx.GameFontBase.Companion.SHEET_HAYEREN_VARW
import net.torvald.terrarumsansbitmap.gdx.GameFontBase.Companion.SHEET_KARTULI_VARW
import net.torvald.terrarumsansbitmap.gdx.GameFontBase.Companion.SHEET_IPA_VARW
import net.torvald.terrarumsansbitmap.gdx.GameFontBase.Companion.SHEET_CUSTOM_SYM
import net.torvald.terrarumsansbitmap.gdx.GameFontBase.Companion.SHEET_UNKNOWN
import net.torvald.terrarumsansbitmap.gdx.GameFontBase.Companion.SHEET_RUNIC
import net.torvald.terrarumsansbitmap.gdx.GameFontBase.Companion.SHEET_LATIN_EXT_ADD_VARW
import org.newdawn.slick.Color
import org.newdawn.slick.Font
import org.newdawn.slick.Image
import org.newdawn.slick.SpriteSheet
import org.newdawn.slick.opengl.Texture
import java.io.BufferedOutputStream
import java.io.File
import java.io.FileInputStream
import java.io.FileOutputStream
import java.util.*
import java.util.zip.GZIPInputStream
/**
* LibGDX->Slick2D back-port of Terrarum Sans Bitmap implementation
*
* Filename and Extension for the spritesheet is hard-coded, which are:
*
* - ascii_variable.tga
* - hangul_johab.tga
* - LatinExtA_variable.tga
* - LatinExtB_variable.tga
* - kana.tga
* - cjkpunct.tga
* - wenquanyi.tga.gz
* - cyrillic_variable.tga
* - fullwidth_forms.tga
* - unipunct_variable.tga
* - greek_variable.tga
* - thai_variable.tga
* - puae000-e0ff.tga
*
*
* Glyphs are drawn lazily (calculated on-the-fly, rather than load up all), which is inevitable as we just can't load
* up 40k+ characters on the machine, which will certainly make loading time painfully long.
*
* Color Codes have following Unicode mapping: U+10RGBA, A must be non-zero to be visible. U+100000 reverts any colour code effects.
*
* @param noShadow Self-explanatory
* @param flipY If you have Y-down coord system implemented on your GDX (e.g. legacy codebase), set this to ```true``` so that the shadow won't be upside-down. For glyph getting upside-down, set ```TextureRegionPack.globalFlipY = true```.
*
* Created by minjaesong on 2017-06-15.
*/
class GameFontBase(fontDir: String, val noShadow: Boolean = false) : Font {
private fun getHanChosung(hanIndex: Int) = hanIndex / (JUNG_COUNT * JONG_COUNT)
private fun getHanJungseong(hanIndex: Int) = hanIndex / JONG_COUNT % JUNG_COUNT
private fun getHanJongseong(hanIndex: Int) = hanIndex % JONG_COUNT
private val jungseongWide = arrayOf(8, 12, 13, 17, 18, 21)
private val jungseongComplex = arrayOf(9, 10, 11, 14, 15, 16, 22)
private fun isJungseongWide(hanIndex: Int) = jungseongWide.contains(getHanJungseong(hanIndex))
private fun isJungseongComplex(hanIndex: Int) = jungseongComplex.contains(getHanJungseong(hanIndex))
private fun getHanInitialRow(hanIndex: Int): Int {
val ret: Int
if (isJungseongWide(hanIndex))
ret = 2
else if (isJungseongComplex(hanIndex))
ret = 4
else
ret = 0
return if (getHanJongseong(hanIndex) == 0) ret else ret + 1
}
private fun getHanMedialRow(hanIndex: Int) = if (getHanJongseong(hanIndex) == 0) 6 else 7
private fun getHanFinalRow(hanIndex: Int): Int {
val jungseongIndex = getHanJungseong(hanIndex)
return if (jungseongWide.contains(jungseongIndex))
8
else
9
}
private fun isHangul(c: Char) = c.toInt() in codeRange[SHEET_HANGUL]
private fun isAscii(c: Char) = c.toInt() in codeRange[SHEET_ASCII_VARW]
private fun isRunic(c: Char) = c.toInt() in codeRange[SHEET_RUNIC]
private fun isExtA(c: Char) = c.toInt() in codeRange[SHEET_EXTA_VARW]
private fun isExtB(c: Char) = c.toInt() in codeRange[SHEET_EXTB_VARW]
private fun isKana(c: Char) = c.toInt() in codeRange[SHEET_KANA]
private fun isCJKPunct(c: Char) = c.toInt() in codeRange[SHEET_CJK_PUNCT]
private fun isUniHan(c: Char) = c.toInt() in codeRange[SHEET_UNIHAN]
private fun isCyrilic(c: Char) = c.toInt() in codeRange[SHEET_CYRILIC_VARW]
private fun isFullwidthUni(c: Char) = c.toInt() in codeRange[SHEET_FW_UNI]
private fun isUniPunct(c: Char) = c.toInt() in codeRange[SHEET_UNI_PUNCT_VARW]
private fun isGreek(c: Char) = c.toInt() in codeRange[SHEET_GREEK_VARW]
private fun isThai(c: Char) = c.toInt() in codeRange[SHEET_THAI_VARW]
private fun isDiacritics(c: Char) = c.toInt() in 0xE34..0xE3A
|| c.toInt() in 0xE47..0xE4E
|| c.toInt() == 0xE31
private fun isCustomSym(c: Char) = c.toInt() in codeRange[SHEET_CUSTOM_SYM]
private fun isArmenian(c: Char) = c.toInt() in codeRange[SHEET_HAYEREN_VARW]
private fun isKartvelian(c: Char) = c.toInt() in codeRange[SHEET_KARTULI_VARW]
private fun isIPA(c: Char) = c.toInt() in codeRange[SHEET_IPA_VARW]
private fun isColourCodeHigh(c: Char) = c.toInt() in 0b110110_1111000000..0b110110_1111111111 // only works with JVM (which uses UTF-16 internally)
private fun isColourCodeLow(c: Char) = c.toInt() in 0b110111_0000000000..0b110111_1111111111 // only works with JVM (which uses UTF-16 internally)
private fun isLatinExtAdd(c: Char) = c.toInt() in 0x1E00..0x1EFF
private fun extAindexX(c: Char) = (c.toInt() - 0x100) % 16
private fun extAindexY(c: Char) = (c.toInt() - 0x100) / 16
private fun extBindexX(c: Char) = (c.toInt() - 0x180) % 16
private fun extBindexY(c: Char) = (c.toInt() - 0x180) / 16
private fun runicIndexX(c: Char) = (c.toInt() - 0x16A0) % 16
private fun runicIndexY(c: Char) = (c.toInt() - 0x16A0) / 16
private fun kanaIndexX(c: Char) = (c.toInt() - 0x3040) % 16
private fun kanaIndexY(c: Char) = (c.toInt() - 0x3040) / 16
private fun cjkPunctIndexX(c: Char) = (c.toInt() - 0x3000) % 16
private fun cjkPunctIndexY(c: Char) = (c.toInt() - 0x3000) / 16
private fun cyrilicIndexX(c: Char) = (c.toInt() - 0x400) % 16
private fun cyrilicIndexY(c: Char) = (c.toInt() - 0x400) / 16
private fun fullwidthUniIndexX(c: Char) = (c.toInt() - 0xFF00) % 16
private fun fullwidthUniIndexY(c: Char) = (c.toInt() - 0xFF00) / 16
private fun uniPunctIndexX(c: Char) = (c.toInt() - 0x2000) % 16
private fun uniPunctIndexY(c: Char) = (c.toInt() - 0x2000) / 16
private fun unihanIndexX(c: Char) = (c.toInt() - 0x3400) % 256
private fun unihanIndexY(c: Char) = (c.toInt() - 0x3400) / 256
private fun greekIndexX(c: Char) = (c.toInt() - 0x370) % 16
private fun greekIndexY(c: Char) = (c.toInt() - 0x370) / 16
private fun thaiIndexX(c: Char) = (c.toInt() - 0xE00) % 16
private fun thaiIndexY(c: Char) = (c.toInt() - 0xE00) / 16
private fun symbolIndexX(c: Char) = (c.toInt() - 0xE000) % 16
private fun symbolIndexY(c: Char) = (c.toInt() - 0xE000) / 16
private fun armenianIndexX(c: Char) = (c.toInt() - 0x530) % 16
private fun armenianIndexY(c: Char) = (c.toInt() - 0x530) / 16
private fun kartvelianIndexX(c: Char) = (c.toInt() - 0x10D0) % 16
private fun kartvelianIndexY(c: Char) = (c.toInt() - 0x10D0) / 16
private fun ipaIndexX(c: Char) = (c.toInt() - 0x250) % 16
private fun ipaIndexY(c: Char) = (c.toInt() - 0x250) / 16
private fun latinExtAddX(c: Char) = (c.toInt() - 0x1E00) % 16
private fun latinExtAddY(c: Char) = (c.toInt() - 0x1E00) / 16
private fun getColour(charHigh: Char, charLow: Char): Color { // input: 0x10ARGB, out: RGBA8888
val codePoint = Character.toCodePoint(charHigh, charLow)
if (colourBuffer.containsKey(codePoint))
return colourBuffer[codePoint]!!
val r = codePoint.and(0xF000).ushr(12)
val g = codePoint.and(0x0F00).ushr(8)
val b = codePoint.and(0x00F0).ushr(4)
val a = codePoint.and(0x000F)
val col = Color(a.shl(28) or a.shl(24) or r.shl(20) or r.shl(16) or g.shl(12) or g.shl(8) or b.shl(4) or b)
colourBuffer[codePoint] = col
return col
}
private val colourBuffer = HashMap<Int, Color>()
private val unihanWidthSheets = arrayOf(
SHEET_UNIHAN,
SHEET_FW_UNI
)
private val variableWidthSheets = arrayOf(
SHEET_ASCII_VARW,
SHEET_EXTA_VARW,
SHEET_EXTB_VARW,
SHEET_CYRILIC_VARW,
SHEET_UNI_PUNCT_VARW,
SHEET_GREEK_VARW,
SHEET_THAI_VARW,
SHEET_HAYEREN_VARW,
SHEET_KARTULI_VARW,
SHEET_IPA_VARW,
SHEET_LATIN_EXT_ADD_VARW
)
private val fontParentDir = if (fontDir.endsWith('/') || fontDir.endsWith('\\')) fontDir else "$fontDir/"
private val fileList = arrayOf( // MUST BE MATCHING WITH SHEET INDICES!!
"ascii_variable.tga",
"hangul_johab.tga",
"latinExtA_variable.tga",
"latinExtB_variable.tga",
"kana.tga",
"cjkpunct.tga",
"wenquanyi.tga.gz",
"cyrilic_variable.tga",
"fullwidth_forms.tga",
"unipunct_variable.tga",
"greek_variable.tga",
"thai_variable.tga",
"hayeren_variable.tga",
"kartuli_variable.tga",
"ipa_ext_variable.tga",
"futhark.tga",
"latinExt_additional_variable.tga",
"puae000-e0ff.tga"
)
private val cyrilic_bg = "cyrilic_bulgarian_variable.tga"
private val cyrilic_sr = "cyrilic_serbian_variable.tga"
private val codeRange = arrayOf( // MUST BE MATCHING WITH SHEET INDICES!!
0..0xFF,
0xAC00..0xD7A3,
0x100..0x17F,
0x180..0x24F,
0x3040..0x30FF,
0x3000..0x303F,
0x3400..0x9FFF,
0x400..0x52F,
0xFF00..0xFF1F,
0x2000..0x205F,
0x370..0x3CE,
0xE00..0xE5F,
0x530..0x58F,
0x10D0..0x10FF,
0x250..0x2AF,
0x16A0..0x16FF,
0x1E00..0x1EFF,
0xE000..0xE0FF
)
private val glyphWidths: HashMap<Int, Int> = HashMap() // if the value is negative, it's diacritics
private val sheets: Array<SpriteSheet>
init {
val sheetsPack = ArrayList<SpriteSheet>()
// first we create pixmap to read pixels, then make texture using pixmap
fileList.forEachIndexed { index, it ->
val isVariable1 = it.endsWith("_variable.tga")
val isVariable2 = variableWidthSheets.contains(index)
val isVariable = isVariable1 && isVariable2
// idiocity check
if (isVariable1 && !isVariable2)
throw Error("[TerrarumSansBitmap] font is named as variable on the name but not enlisted as")
else if (!isVariable1 && isVariable2)
throw Error("[TerrarumSansBitmap] font is enlisted as variable on the name but not named as")
val image: Image
// unpack gz if applicable
if (it.endsWith(".gz")) {
val gzi = GZIPInputStream(FileInputStream(fontParentDir + it))
val wholeFile = gzi.readBytes()
gzi.close()
val fos = BufferedOutputStream(FileOutputStream("tmp_wenquanyi.tga"))
fos.write(wholeFile)
fos.flush()
fos.close()
image = Image("tmp_wenquanyi.tga")
File("tmp_wenquanyi.tga").delete()
}
else {
image = Image(fontParentDir + it)
}
val texture = image.texture
if (isVariable) {
println("[TerrarumSansBitmap] loading texture $it [VARIABLE]")
buildWidthTable(texture, codeRange[index], 16)
}
else {
println("[TerrarumSansBitmap] loading texture $it")
}
val texRegPack = if (isVariable) {
SpriteSheet(image, W_VAR_INIT, H - 1, HGAP_VAR)
}
else if (index == SHEET_UNIHAN) {
SpriteSheet(image, W_UNIHAN, H_UNIHAN) // the only exception that is height is 16
}
// below they all have height of 20 'H'
else if (index == SHEET_FW_UNI) {
SpriteSheet(image, W_UNIHAN, H)
}
else if (index == SHEET_CJK_PUNCT) {
SpriteSheet(image, W_ASIAN_PUNCT, H)
}
else if (index == SHEET_KANA) {
SpriteSheet(image, W_KANA, H)
}
else if (index == SHEET_HANGUL) {
SpriteSheet(image, W_HANGUL, H)
}
else if (index == SHEET_CUSTOM_SYM) {
SpriteSheet(image, SIZE_CUSTOM_SYM, SIZE_CUSTOM_SYM) // TODO variable
}
else if (index == SHEET_RUNIC) {
SpriteSheet(image, W_LATIN_WIDE, H)
}
else throw IllegalArgumentException("[TerrarumSansBitmap] Unknown sheet index: $index")
sheetsPack.add(texRegPack)
}
sheets = sheetsPack.toTypedArray()
}
private var localeBuffer = ""
fun reload(locale: String) {
if (!localeBuffer.startsWith("ru") && locale.startsWith("ru")) {
val image = Image(fontParentDir + fileList[SHEET_CYRILIC_VARW])
sheets[SHEET_CYRILIC_VARW].destroy()
sheets[SHEET_CYRILIC_VARW] = SpriteSheet(image, W_VAR_INIT, H, HGAP_VAR, 0)
}
else if (!localeBuffer.startsWith("bg") && locale.startsWith("bg")) {
val image = Image(fontParentDir + cyrilic_bg)
sheets[SHEET_CYRILIC_VARW].destroy()
sheets[SHEET_CYRILIC_VARW] = SpriteSheet(image, W_VAR_INIT, H, HGAP_VAR, 0)
}
else if (!localeBuffer.startsWith("sr") && locale.startsWith("sr")) {
val image = Image(fontParentDir + cyrilic_sr)
sheets[SHEET_CYRILIC_VARW].destroy()
sheets[SHEET_CYRILIC_VARW] = SpriteSheet(image, W_VAR_INIT, H, HGAP_VAR, 0)
}
localeBuffer = locale
}
override fun getLineHeight(): Int = H
override fun getHeight(p0: String) = lineHeight
private val offsetUnihan = (H - H_UNIHAN) / 2
private val offsetCustomSym = (H - SIZE_CUSTOM_SYM) / 2
private var textBuffer: CharSequence = ""
private var textBWidth = intArrayOf() // absolute posX of glyphs from print-origin
private var textBGSize = intArrayOf() // width of each glyph
override fun drawString(x: Float, y: Float, str: String) {
drawString(x, y, str, Color.white)
}
override fun drawString(p0: Float, p1: Float, p2: String?, p3: Color?, p4: Int, p5: Int) {
throw UnsupportedOperationException()
}
override fun drawString(x: Float, y: Float, str: String, color: Color) {
// always draw at integer position; this is bitmap font after all
val x = Math.round(x).toFloat()
val y = Math.round(y).toFloat()
if (textBuffer != str) {
textBuffer = str
val widths = getWidthOfCharSeq(str)
textBGSize = widths
textBWidth = IntArray(str.length, { charIndex ->
if (charIndex == 0)
0
else {
var acc = 0
(0..charIndex - 1).forEach { acc += maxOf(0, widths[it]) } // don't accumulate diacrtics (which has negative value)
/*return*/acc
}
})
}
//print("[TerrarumSansBitmap] widthTable for $textBuffer: ")
//textBWidth.forEach { print("$it ") }; println()
var mainCol = color
var shadowCol = color.darker(0.5f)
var index = 0
while (index <= textBuffer.lastIndex) {
val c = textBuffer[index]
val sheetID = getSheetType(c)
val sheetXY = getSheetwisePosition(c)
//println("[TerrarumSansBitmap] sprite: $sheetID:${sheetXY[0]}x${sheetXY[1]}")
if (isColourCodeHigh(c)) {
val cchigh = c
val cclow = textBuffer[index + 1]
if (Character.toCodePoint(cchigh, cclow) == 0x100000) {
mainCol = color
shadowCol = color.darker(0.5f)
}
else {
mainCol = getColour(cchigh, cclow)
shadowCol = mainCol.darker(0.5f)
}
index += 1
}
else if (isColourCodeLow(c)) {
throw Error("Unexpected encounter of ColourCodeLow at index $index of String '$textBuffer'")
}
else if (sheetID == SHEET_HANGUL) {
val hangulSheet = sheets[SHEET_HANGUL]
val hIndex = c.toInt() - 0xAC00
val indexCho = getHanChosung(hIndex)
val indexJung = getHanJungseong(hIndex)
val indexJong = getHanJongseong(hIndex)
val choRow = getHanInitialRow(hIndex)
val jungRow = getHanMedialRow(hIndex)
val jongRow = getHanFinalRow(hIndex)
if (!noShadow) {
hangulSheet.getSubImage(indexCho, choRow ).draw(x + textBWidth[index] + 1, y, shadowCol)
hangulSheet.getSubImage(indexCho, choRow ).draw(x + textBWidth[index] , y, shadowCol)
hangulSheet.getSubImage(indexCho, choRow ).draw(x + textBWidth[index] + 1, y, shadowCol)
hangulSheet.getSubImage(indexJung, jungRow).draw(x + textBWidth[index] + 1, y, shadowCol)
hangulSheet.getSubImage(indexJung, jungRow).draw(x + textBWidth[index] , y, shadowCol)
hangulSheet.getSubImage(indexJung, jungRow).draw(x + textBWidth[index] + 1, y, shadowCol)
hangulSheet.getSubImage(indexJong, jongRow).draw(x + textBWidth[index] + 1, y, shadowCol)
hangulSheet.getSubImage(indexJong, jongRow).draw(x + textBWidth[index] , y, shadowCol)
hangulSheet.getSubImage(indexJong, jongRow).draw(x + textBWidth[index] + 1, y, shadowCol)
}
hangulSheet.getSubImage(indexCho, choRow ).draw(x + textBWidth[index], y, mainCol)
hangulSheet.getSubImage(indexJung, jungRow).draw(x + textBWidth[index], y, mainCol)
hangulSheet.getSubImage(indexJong, jongRow).draw(x + textBWidth[index], y, mainCol)
}
else {
try {
val offset = if (!isDiacritics(c)) 0 else {
if (index > 0) // LIMITATION: does not support double (or more) diacritics properly
(textBGSize[index] - textBGSize[index - 1]) / 2
else
textBGSize[index]
}
if (!noShadow) {
sheets[sheetID].getSubImage(sheetXY[0], sheetXY[1]).draw(
x + textBWidth[index] + 1 + offset,
y + (if (sheetID == SHEET_UNIHAN) // evil exceptions
offsetUnihan
else if (sheetID == SHEET_CUSTOM_SYM)
offsetCustomSym
else
0),
shadowCol
)
sheets[sheetID].getSubImage(sheetXY[0], sheetXY[1]).draw(
x + textBWidth[index] + offset,
y + (if (sheetID == SHEET_UNIHAN) // evil exceptions
offsetUnihan + 1
else if (sheetID == SHEET_CUSTOM_SYM)
offsetCustomSym + 1
else
1),
shadowCol
)
sheets[sheetID].getSubImage(sheetXY[0], sheetXY[1]).draw(
x + textBWidth[index] + 1 + offset,
y + (if (sheetID == SHEET_UNIHAN) // evil exceptions
offsetUnihan + 1
else if (sheetID == SHEET_CUSTOM_SYM)
offsetCustomSym + 1
else
1),
shadowCol
)
}
sheets[sheetID].getSubImage(sheetXY[0], sheetXY[1]).draw(
x + textBWidth[index] + offset,
y + if (sheetID == SHEET_UNIHAN) // evil exceptions
offsetUnihan
else if (sheetID == SHEET_CUSTOM_SYM)
offsetCustomSym
else 0,
mainCol
)
}
catch (noSuchGlyph: ArrayIndexOutOfBoundsException) {
}
}
index += 1
}
}
fun dispose() {
sheets.forEach { it.destroy() }
}
private fun getWidthOfCharSeq(s: CharSequence): IntArray {
val len = IntArray(s.length)
for (i in 0..s.lastIndex) {
val chr = s[i]
val ctype = getSheetType(s[i])
if (variableWidthSheets.contains(ctype)) {
if (!glyphWidths.containsKey(chr.toInt())) {
println("[TerrarumSansBitmap] no width data for glyph number ${Integer.toHexString(chr.toInt()).toUpperCase()}")
len[i] = W_LATIN_WIDE
}
len[i] = glyphWidths[chr.toInt()]!!
}
else if (isColourCodeHigh(chr) || isColourCodeLow(chr))
len[i] = 0
else if (ctype == SHEET_CJK_PUNCT)
len[i] = W_ASIAN_PUNCT
else if (ctype == SHEET_HANGUL)
len[i] = W_HANGUL
else if (ctype == SHEET_KANA)
len[i] = W_KANA
else if (unihanWidthSheets.contains(ctype))
len[i] = W_UNIHAN
else if (ctype == SHEET_CUSTOM_SYM)
len[i] = SIZE_CUSTOM_SYM
else
len[i] = W_LATIN_WIDE
if (scale > 1) len[i] *= scale
if (i < s.lastIndex) len[i] += interchar
}
return len
}
private fun getSheetType(c: Char): Int {
if (isHangul(c))
return SHEET_HANGUL
else if (isKana(c))
return SHEET_KANA
else if (isUniHan(c))
return SHEET_UNIHAN
else if (isAscii(c))
return SHEET_ASCII_VARW
else if (isExtA(c))
return SHEET_EXTA_VARW
else if (isExtB(c))
return SHEET_EXTB_VARW
else if (isCyrilic(c))
return SHEET_CYRILIC_VARW
else if (isUniPunct(c))
return SHEET_UNI_PUNCT_VARW
else if (isCJKPunct(c))
return SHEET_CJK_PUNCT
else if (isFullwidthUni(c))
return SHEET_FW_UNI
else if (isGreek(c))
return SHEET_GREEK_VARW
else if (isThai(c))
return SHEET_THAI_VARW
else if (isCustomSym(c))
return SHEET_CUSTOM_SYM
else if (isArmenian(c))
return SHEET_HAYEREN_VARW
else if (isKartvelian(c))
return SHEET_KARTULI_VARW
else if (isIPA(c))
return SHEET_IPA_VARW
else if (isRunic(c))
return SHEET_RUNIC
else if (isLatinExtAdd(c))
return SHEET_LATIN_EXT_ADD_VARW
else
return SHEET_UNKNOWN
// fixed width
// fallback
}
private fun getSheetwisePosition(ch: Char): IntArray {
val sheetX: Int; val sheetY: Int
when (getSheetType(ch)) {
SHEET_UNIHAN -> {
sheetX = unihanIndexX(ch)
sheetY = unihanIndexY(ch)
}
SHEET_EXTA_VARW -> {
sheetX = extAindexX(ch)
sheetY = extAindexY(ch)
}
SHEET_EXTB_VARW -> {
sheetX = extBindexX(ch)
sheetY = extBindexY(ch)
}
SHEET_KANA -> {
sheetX = kanaIndexX(ch)
sheetY = kanaIndexY(ch)
}
SHEET_CJK_PUNCT -> {
sheetX = cjkPunctIndexX(ch)
sheetY = cjkPunctIndexY(ch)
}
SHEET_CYRILIC_VARW -> {
sheetX = cyrilicIndexX(ch)
sheetY = cyrilicIndexY(ch)
}
SHEET_FW_UNI -> {
sheetX = fullwidthUniIndexX(ch)
sheetY = fullwidthUniIndexY(ch)
}
SHEET_UNI_PUNCT_VARW -> {
sheetX = uniPunctIndexX(ch)
sheetY = uniPunctIndexY(ch)
}
SHEET_GREEK_VARW -> {
sheetX = greekIndexX(ch)
sheetY = greekIndexY(ch)
}
SHEET_THAI_VARW -> {
sheetX = thaiIndexX(ch)
sheetY = thaiIndexY(ch)
}
SHEET_CUSTOM_SYM -> {
sheetX = symbolIndexX(ch)
sheetY = symbolIndexY(ch)
}
SHEET_HAYEREN_VARW -> {
sheetX = armenianIndexX(ch)
sheetY = armenianIndexY(ch)
}
SHEET_KARTULI_VARW -> {
sheetX = kartvelianIndexX(ch)
sheetY = kartvelianIndexY(ch)
}
SHEET_IPA_VARW -> {
sheetX = ipaIndexX(ch)
sheetY = ipaIndexY(ch)
}
SHEET_RUNIC -> {
sheetX = runicIndexX(ch)
sheetY = runicIndexY(ch)
}
SHEET_LATIN_EXT_ADD_VARW -> {
sheetX = latinExtAddX(ch)
sheetY = latinExtAddY(ch)
}
else -> {
sheetX = ch.toInt() % 16
sheetY = ch.toInt() / 16
}
}
return intArrayOf(sheetX, sheetY)
}
fun buildWidthTable(texture: Texture, codeRange: IntRange, cols: Int = 16) {
val binaryCodeOffset = W_VAR_INIT
val cellW = W_VAR_INIT + 1
val cellH = H
for (code in codeRange) {
val cellX = ((code - codeRange.start) % cols) * cellW
val cellY = ((code - codeRange.start) / cols) * cellH
val codeStartX = cellX + binaryCodeOffset
val codeStartY = cellY
var glyphWidth = 0
for (downCtr in 0..3) {
// if ALPHA is not zero, assume it's 1
if (texture.textureData[4 * (codeStartX + (codeStartY + downCtr) * texture.textureWidth) + 3] != 0.toByte()) {
glyphWidth = glyphWidth or (1 shl downCtr)
}
}
val isDiacritics = texture.textureData[4 * (codeStartX + (codeStartY + H - 1) * texture.textureWidth) + 3] != 0.toByte()
if (isDiacritics)
glyphWidth = -glyphWidth
glyphWidths[code] = glyphWidth
}
}
override fun getWidth(text: String): Int {
return getWidthOfCharSeq(text).sum()
}
var interchar = 0
var scale = 1
set(value) {
if (value > 0) field = value
else throw IllegalArgumentException("Font scale cannot be zero or negative (input: $value)")
}
fun toColorCode(rgba4444: Int): String = GameFontBase.toColorCode(rgba4444)
fun toColorCode(r: Int, g: Int, b: Int, a: Int = 0x0F): String = toColorCode(r.shl(12) or g.shl(8) or b.shl(4) or a)
val noColorCode = toColorCode(0x0000)
companion object {
fun toColorCode(rgba4444: Int): String = Character.toChars(0x100000 + rgba4444).toColCode()
fun toColorCode(r: Int, g: Int, b: Int, a: Int = 0x0F): String = toColorCode(r.shl(12) or g.shl(8) or b.shl(4) or a)
private fun CharArray.toColCode(): String = "${this[0]}${this[1]}"
val noColorCode = toColorCode(0x0000)
}
}*/

0
terrarum_sans_cyrillic_2.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

BIN
testing.PNG Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

16
testtext.txt Executable file
View File

@@ -0,0 +1,16 @@
To
uu
Td
mm
Ye
Yd
/œ̃/
/ɛ̃/
/ẽ
when the line ends with a diacritics, whole letter wont render
if the line starts with a letter-with-diacritic, it will error out

0
width_bit_encoding_annotated.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB