Upgraded to code2000 font

This commit is contained in:
Willem Cazander 2022-02-11 02:46:44 +01:00
parent bb76cbbe2f
commit 76014cfe87
11 changed files with 81 additions and 106 deletions

View file

@ -18,19 +18,34 @@ console.log("<opentype>");
let num = font.numGlyphs; let num = font.numGlyphs;
for(let glyphIndex = 0; glyphIndex < num; glyphIndex++) { for(let glyphIndex = 0; glyphIndex < num; glyphIndex++) {
let glyph = font.glyphs.get(glyphIndex); let glyph = font.glyphs.get(glyphIndex);
let path = glyph.getPath(0, 0, 72);
if (path.commands.length === 0) { // JS NOTE: without calling xMin the getContours return empty set.... :''(
glyph.xMin;
var contours = glyph.getContours();
if (contours.length === 0) {
// TODO: add compound support
continue; continue;
} }
if (glyph.unicodes.length === 0) { if (glyph.unicodes.length === 0) {
continue; // with cmds, these are compound glyphs continue; // with cmds, these are compound glyphs
} }
let uni = glyph.unicodes.map(formatUnicode).join(', '); let uni = glyph.unicodes.map(formatUnicode).join(', ');
console.log("\t<glyph unicode=\""+uni+"\" name=\""+glyph.name+"\">"); /*"advanceWidth=\""+glyph.advanceWidth+"\" "+ console.log("\t<glyph unicode=\""+uni+"\" name=\""+glyph.name+"\" advanceWidth=\""+glyph.advanceWidth+"\" "+
"xMin=\""+glyph.xMin+"\" xMax=\""+glyph.xMax+"\" yMin=\""+glyph.yMin+"\" yMax=\""+glyph.yMax+"\" "+ "xMin=\""+glyph.xMin+"\" xMax=\""+glyph.xMax+"\" yMin=\""+glyph.yMin+"\" yMax=\""+glyph.yMax+"\" "+
"leftSideBearing=\""+glyph.leftSideBearing+"\" pathFill=\""+path.fill+"\" "+ "leftSideBearing=\""+glyph.leftSideBearing+"\">");
"strokeStyle=\""+path.stroke+"\" lineWidth=\""+path.strokeWidth+"\">"); */
for (let contourIndex = 0; contourIndex < contours.length; ++contourIndex) {
const contour = contours[contourIndex];
console.log("\t\t<contour>");
for (let i = 0; i < contour.length; ++i) {
let curr = contour[i];
console.log("\t\t\t<point x=\""+curr.x+"\" y=\""+curr.y+"\" onCurve=\""+curr.onCurve+"\"/>");
}
console.log("\t\t</contour>");
//console.log(JSON.stringify(curr));
}
/*
for (i = 0; i < path.commands.length; i += 1) { for (i = 0; i < path.commands.length; i += 1) {
cmd = path.commands[i]; cmd = path.commands[i];
if (cmd.type === 'M') { if (cmd.type === 'M') {
@ -45,6 +60,7 @@ for(let glyphIndex = 0; glyphIndex < num; glyphIndex++) {
console.log("\t\t<pathClose/>"); console.log("\t\t<pathClose/>");
} }
} }
*/``
console.log("\t</glyph>"); console.log("\t</glyph>");
} }
console.log("</opentype>"); console.log("</opentype>");

View file

@ -4,13 +4,10 @@
"description": "Convert font data to XML intermediate.", "description": "Convert font data to XML intermediate.",
"private": true, "private": true,
"scripts": { "scripts": {
"start": "npm run-script conv0 && npm run-script conv1 && npm run-script conv2 && npm run-script conv3 && npm run-script conv4", "start": "npm run-script conv0 && npm run-script conv1",
"conv0": "node conv-font.js ../main-gdxapp/assets/font/free-sans.ttf > bin/free-sans.xml", "conv0": "node conv-font.js ../main-gdxapp/assets/font/code2000.ttf > bin/code2000.xml",
"conv1": "node conv-font.js ../main-gdxapp/assets/font/noto-sans-cjkjp-medium.otf > bin/noto-sans-cjkjp-medium.xml", "conv1": "node conv-font.js ../main-gdxapp/assets/font/free-sans.ttf > bin/free-sans.xml",
"conv2": "node conv-font.js ../main-gdxapp/assets/font/roboto-bold.ttf > bin/roboto-bold.xml", "debug": "node conv-font.js ../main-gdxapp/assets/font/free-sans.ttf"
"conv3": "node conv-font.js ../main-gdxapp/assets/font/arslan-wessam.ttf > bin/arslan-wessam.xml",
"conv4": "node conv-font.js ../main-gdxapp/assets/font/norse-kawl.otf > bin/norse-kawl.xml",
"debug": "node conv-font.js ../main-gdxapp/assets/font/roboto-bold.ttf"
}, },
"dependencies": { "dependencies": {
"opentype.js": "1.3.4" "opentype.js": "1.3.4"

View file

@ -13,11 +13,11 @@ public enum T10PartDecimal implements BãßBȍőnPartAlt2ʸᴰ<T10PartDecimal> {
PART_1 ("˥","","zero", "˥",""), PART_1 ("˥","","zero", "˥",""),
PART_2 ("˦","","one", "˦",""), PART_2 ("˦","","one", "˦",""),
PART_3 ("˧","","two", "˧",""), PART_3 ("˧","","two", "˧",""),
PART_4 ("˨","","three","˨",""), PART_4 ("˨","","three","˨",""),
PART_5 ("˩","","four", "˩",""), PART_5 ("˩","","four", "˩",""),
PART_6 ("","","five", "",""), PART_6 ("","","five", "",""),
PART_7 ("","","six", "",""), PART_7 ("","","six", "",""),
PART_8 ("","","seven","",""), PART_8 ("","","seven","",""),
PART_9 ("","","eight","",""), PART_9 ("","","eight","",""),
PART_10("","","nine", "",""), PART_10("","","nine", "",""),

View file

@ -52,11 +52,11 @@ public enum BaseGlyphSet implements BãßBȍőnGlyphSetʸᴰ<BaseGlyphSet> {
GREEK_HEX(GREEK.BȍőnGlyphSetNumber10(), GREEK_HEX(GREEK.BȍőnGlyphSetNumber10(),
new BaseGlyphSetNumber("ō","α","β","γ","δ","ε","ϝ","ζ","η","θ","ι","κ","λ","μ","ν","ξ"), new BaseGlyphSetNumber("ō","α","β","γ","δ","ε","ϝ","ζ","η","θ","ι","κ","λ","μ","ν","ξ"),
GREEK.BȍőnGlyphSetNumber36()), GREEK.BȍőnGlyphSetNumber36()),
CYRILLIC(new BaseGlyphSetNumber("","А","В","Г","Д","Є","Ѕ","З","И","Ѳ"), CYRILLIC(new BaseGlyphSetNumber("Ф","А","В","Г","Д","Є","Ѕ","З","И","Ѳ"),
LATIN_BASIC.BȍőnGlyphSetNumber16(), LATIN_BASIC.BȍőnGlyphSetNumber16(),
new BaseGlyphSetNumber("А","В","Г","Д","Є","Ѕ","З","И","Ѳ","І","К","Л","М","Н","Ѯ","Ѻ","П","Ч","Р","С","Т","Ѵ","Ф","Х","Ѱ","Ѿ","Ц")), new BaseGlyphSetNumber("А","В","Г","Д","Є","Ѕ","З","И","Ѳ","І","К","Л","М","Н","Ѯ","Ѻ","П","Ч","Р","С","Т","Ѵ","Ф","Х","Ѱ","Ѿ","Ц")),
CYRILLIC_HEX(CYRILLIC.BȍőnGlyphSetNumber10(), CYRILLIC_HEX(CYRILLIC.BȍőnGlyphSetNumber10(),
new BaseGlyphSetNumber("","А","В","Г","Д","Є","Ѕ","З","И","Ѳ","҂"," ҈"," ҉","","",""), new BaseGlyphSetNumber("Ф","А","В","Г","Д","Є","Ѕ","З","И","Ѳ","҂"," ҈"," ҉","","",""),
CYRILLIC.BȍőnGlyphSetNumber36()), CYRILLIC.BȍőnGlyphSetNumber36()),
BENGALI(new BaseGlyphSetNumber("","","","","","","","","",""), BENGALI(new BaseGlyphSetNumber("","","","","","","","","",""),
LATIN_BASIC.BȍőnGlyphSetNumber16(), LATIN_BASIC.BȍőnGlyphSetNumber16(),
@ -64,6 +64,12 @@ public enum BaseGlyphSet implements BãßBȍőnGlyphSetʸᴰ<BaseGlyphSet> {
BENGALI_HEX(BENGALI.BȍőnGlyphSetNumber10(), BENGALI_HEX(BENGALI.BȍőnGlyphSetNumber10(),
new BaseGlyphSetNumber("","","","","","","","","","","জ্ঞ","ক্ষ","","","",""), new BaseGlyphSetNumber("","","","","","","","","","","জ্ঞ","ক্ষ","","","",""),
BENGALI.BȍőnGlyphSetNumber36()), BENGALI.BȍőnGlyphSetNumber36()),
THAI(new BaseGlyphSetNumber("","","","","","","","","",""),
LATIN_BASIC.BȍőnGlyphSetNumber16(),
new BaseGlyphSetNumber("","","","","","","","","","","","","","","","","","","","","","","","","","","")),
THAI_HEX(THAI.BȍőnGlyphSetNumber10(),
new BaseGlyphSetNumber("","","","","","","","","","","","","","","",""),
THAI.BȍőnGlyphSetNumber36()),
RUNIC(new BaseGlyphSetNumber("","","","","","","","","",""), RUNIC(new BaseGlyphSetNumber("","","","","","","","","",""),
LATIN_BASIC.BȍőnGlyphSetNumber16(), LATIN_BASIC.BȍőnGlyphSetNumber16(),
@ -84,10 +90,16 @@ public enum BaseGlyphSet implements BãßBȍőnGlyphSetʸᴰ<BaseGlyphSet> {
KOREAN_HEX.BȍőnGlyphSetNumber16().withAltGlyphSet(LATIN_TOP), KOREAN_HEX.BȍőnGlyphSetNumber16().withAltGlyphSet(LATIN_TOP),
KOREAN_HEX.BȍőnGlyphSetNumber36()), KOREAN_HEX.BȍőnGlyphSetNumber36()),
CHINA_FINANCIAL_T(new BaseGlyphSetNumber(v -> T10PartDecimal.PART_1.BãßVoorElk(x -> v.add(x.BȍőnChinaKey()))), LATIN_BASIC.BȍőnGlyphSetNumber16(), null), CHINA(
CHINA_FINANCIAL_S(new BaseGlyphSetNumber("","","","","","","","","",""), LATIN_BASIC.BȍőnGlyphSetNumber16(), null), new BaseGlyphSetNumber("","","","","","","","","",""), LATIN_BASIC.BȍőnGlyphSetNumber16(), null),
CHINA_NORMAL_T(new BaseGlyphSetNumber("","","","","","","","","",""), LATIN_BASIC.BȍőnGlyphSetNumber16(), null), CHINA_FORMAL(
CHINA_NORMAL_S(new BaseGlyphSetNumber("","","","","","","","","",""), LATIN_BASIC.BȍőnGlyphSetNumber16(), null), new BaseGlyphSetNumber(v -> T10PartDecimal.PART_1.BãßVoorElk(x -> v.add(x.BȍőnChinaKey()))), LATIN_BASIC.BȍőnGlyphSetNumber16(), null),
CHINA_FORMAL_OLD(
new BaseGlyphSetNumber("","","","","","","","","",""), LATIN_BASIC.BȍőnGlyphSetNumber16(), null),
JAPAN(
CHINA.BȍőnGlyphSetNumber10(), LATIN_BASIC.BȍőnGlyphSetNumber16(), null),
JAPAN_FORMAL(
new BaseGlyphSetNumber("","","","","","","","","",""), LATIN_BASIC.BȍőnGlyphSetNumber16(), null),
ARABIC(new BaseGlyphSetNumber("٠","١","٢","٣","٤","٥","٦","٧","٨","٩"), ARABIC(new BaseGlyphSetNumber("٠","١","٢","٣","٤","٥","٦","٧","٨","٩"),
LATIN_BASIC.BȍőnGlyphSetNumber16(), LATIN_BASIC.BȍőnGlyphSetNumber16(),

Binary file not shown.

View file

@ -36,24 +36,19 @@ public class ImGuiSetup {
} }
private static void initFonts(final ImGuiIO io) { private static void initFonts(final ImGuiIO io) {
io.getFonts().addFontDefault();
ImFontConfig fontConfig = new ImFontConfig(); ImFontConfig fontConfig = new ImFontConfig();
fontConfig.setMergeMode(true);
ImFontGlyphRangesBuilder fontBuilder = new ImFontGlyphRangesBuilder(); ImFontGlyphRangesBuilder fontBuilder = new ImFontGlyphRangesBuilder();
addRangeUnicodePlane0(fontBuilder); addRangeUnicodePlane0(fontBuilder);
final short[] glyphRanges = fontBuilder.buildRanges(); final short[] glyphRanges = fontBuilder.buildRanges();
io.getFonts().addFontFromMemoryTTF(Gdx.files.internal("font/code2000.ttf").readBytes(), 24, fontConfig, glyphRanges);
io.getFonts().addFontFromMemoryTTF(Gdx.files.internal("font/noto-sans-cjkjp-medium.otf").readBytes(), 14, fontConfig, glyphRanges); fontConfig.setMergeMode(true);
io.getFonts().addFontFromMemoryTTF(Gdx.files.internal("font/free-sans.ttf").readBytes(), 14, fontConfig, glyphRanges); // note: just for 3 sub chars for SUBHEX, but still missing 2 chars from T12 alt1 clock
io.getFonts().addFontFromMemoryTTF(Gdx.files.internal("font/roboto-bold.ttf").readBytes(), 14, fontConfig, glyphRanges); io.getFonts().addFontFromMemoryTTF(Gdx.files.internal("font/free-sans.ttf").readBytes(), 24, fontConfig, glyphRanges);
io.getFonts().addFontFromMemoryTTF(Gdx.files.internal("font/arslan-wessam.ttf").readBytes(), 14, fontConfig, glyphRanges);
io.getFonts().addFontFromMemoryTTF(Gdx.files.internal("font/norse-kawl.otf").readBytes(), 14, fontConfig, glyphRanges);
fontConfig.destroy(); fontConfig.destroy();
} }
private static void addRangeUnicodePlane0(ImFontGlyphRangesBuilder fontBuilder) { private static void addRangeUnicodePlane0(ImFontGlyphRangesBuilder fontBuilder) {
for (int c=0x0100;c<=0xFFEF;c++) { for (int c=0x0001;c<=0xFFEF;c++) {
StringBuilder buf = new StringBuilder(); StringBuilder buf = new StringBuilder();
buf.append(""+(char)c); buf.append(""+(char)c);
fontBuilder.addText(buf.toString()); fontBuilder.addText(buf.toString());

View file

@ -1,24 +1,17 @@
package love.distributedrebirth.gdxapp.screen; package love.distributedrebirth.gdxapp.screen;
import java.util.ArrayList;
import java.util.List;
import imgui.ImGui; import imgui.ImGui;
import imgui.flag.ImGuiCond; import imgui.flag.ImGuiCond;
import imgui.flag.ImGuiTableFlags; import imgui.flag.ImGuiTableFlags;
import imgui.type.ImBoolean; import imgui.type.ImBoolean;
import imgui.type.ImInt;
import love.distributedrebirth.bassboonyd.BãßBȍőnAuthorInfoʸᴰ; import love.distributedrebirth.bassboonyd.BãßBȍőnAuthorInfoʸᴰ;
import love.distributedrebirth.gdxapp.GDXAppMain; import love.distributedrebirth.gdxapp.GDXAppMain;
import love.distributedrebirth.gdxapp.ImGuiRendererMain; import love.distributedrebirth.gdxapp.ImGuiRendererMain;
import love.distributedrebirth.numberxd.glyph.BaseGlyphSet; import love.distributedrebirth.numberxd.glyph.BaseGlyphSet;
import love.distributedrebirth.numberxd.glyph.BaseGlyphSetNumber;
@BãßBȍőnAuthorInfoʸᴰ(name = "willemtsade", copyright = "©Δ∞ 仙上主天") @BãßBȍőnAuthorInfoʸᴰ(name = "willemtsade", copyright = "©Δ∞ 仙上主天")
public class SystemBaseGlyphRenderer extends ImGuiRendererMain { public class SystemBaseGlyphRenderer extends ImGuiRendererMain {
private ImInt selectedGlyphPart = new ImInt();
public SystemBaseGlyphRenderer(GDXAppMain main) { public SystemBaseGlyphRenderer(GDXAppMain main) {
super(main); super(main);
} }
@ -27,83 +20,45 @@ public class SystemBaseGlyphRenderer extends ImGuiRendererMain {
public void render(ImBoolean widgetOpen) { public void render(ImBoolean widgetOpen) {
ImGui.setNextWindowPos(200, 200, ImGuiCond.FirstUseEver); ImGui.setNextWindowPos(200, 200, ImGuiCond.FirstUseEver);
ImGui.setNextWindowSize(640, 480, ImGuiCond.FirstUseEver); ImGui.setNextWindowSize(640, 480, ImGuiCond.FirstUseEver);
if (ImGui.begin("Base glyph", widgetOpen)) { if (ImGui.begin("Base Glyph Set", widgetOpen)) {
List<BaseGlyphSet> bases = new ArrayList<>();
for (BaseGlyphSet glyphSet:BaseGlyphSet.values()) {
bases.add(glyphSet);
}
String[] items = new String[bases.size()];
for (int i=0;i<items.length;i++) {
items[i] = bases.get(i).BȍőnNaam();
}
String selectedItem = items[selectedGlyphPart.get()];
BaseGlyphSet glyphSet = BaseGlyphSet.valueOf(selectedItem);
ImGui.text("Glyph:");
ImGui.sameLine();
ImGui.combo("Set", selectedGlyphPart, items);
int flags = ImGuiTableFlags.ScrollX | ImGuiTableFlags.RowBg | ImGuiTableFlags.BordersOuter | ImGuiTableFlags.BordersV; int flags = ImGuiTableFlags.ScrollX | ImGuiTableFlags.RowBg | ImGuiTableFlags.BordersOuter | ImGuiTableFlags.BordersV;
ImGui.beginTable("base-part", 7, flags); ImGui.beginTable("base-part", 3, flags);
ImGui.tableSetupColumn("Example"); ImGui.tableSetupColumn("Language");
ImGui.tableSetupColumn("tel10"); ImGui.tableSetupColumn("10Numbers");
ImGui.tableSetupColumn("hon10"); ImGui.tableSetupColumn("16Numbers");
ImGui.tableSetupColumn("tel16");
ImGui.tableSetupColumn("hon16");
ImGui.tableSetupColumn("tel36");
ImGui.tableSetupColumn("hon36");
ImGui.tableHeadersRow(); ImGui.tableHeadersRow();
int[] numberSet = {0,1,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23, for (BaseGlyphSet set:BaseGlyphSet.values()) {
24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42};
for (int number:numberSet) {
int number100 = number * 1;
BaseGlyphSetNumber number10 = glyphSet.BȍőnGlyphSetNumber10();
BaseGlyphSetNumber number16 = glyphSet.BȍőnGlyphSetNumber16();
BaseGlyphSetNumber number36 = glyphSet.BȍőnGlyphSetNumber36();
ImGui.tableNextRow(); ImGui.tableNextRow();
ImGui.tableNextColumn(); ImGui.tableNextColumn();
ImGui.text(Integer.toString(number)); ImGui.text(set.BȍőnNaam());
ImGui.tableNextColumn();
if (number10 != null) { ImGui.text(print10Numbers(set));
ImGui.tableNextColumn(); ImGui.tableNextColumn();
ImGui.text(glyphSet.BȍőnPrintGlyphSetNumber10(number, 50)); ImGui.text(print16Numbers(set));
ImGui.tableNextColumn();
ImGui.text(glyphSet.BȍőnPrintGlyphSetNumber10(number100, 500));
} else {
ImGui.tableNextColumn();
ImGui.text("");
ImGui.tableNextColumn();
ImGui.text("");
}
if (number16 != null) {
ImGui.tableNextColumn();
ImGui.text(glyphSet.BȍőnPrintGlyphSetNumber16(number, 50));
ImGui.tableNextColumn();
ImGui.text(glyphSet.BȍőnPrintGlyphSetNumber16(number100, 500));
} else {
ImGui.tableNextColumn();
ImGui.text("");
ImGui.tableNextColumn();
ImGui.text("");
}
if (number36 != null) {
ImGui.tableNextColumn();
ImGui.text(glyphSet.BȍőnPrintGlyphSetNumber36(number, 50));
ImGui.tableNextColumn();
ImGui.text(glyphSet.BȍőnPrintGlyphSetNumber36(number100, 500));
} else {
ImGui.tableNextColumn();
ImGui.text("");
ImGui.tableNextColumn();
ImGui.text("");
}
} }
ImGui.endTable(); ImGui.endTable();
} }
ImGui.end(); ImGui.end();
} }
private String print10Numbers(BaseGlyphSet set) {
StringBuilder buf = new StringBuilder();
for (int i=0;i<10;i++) {
buf.append(set.BȍőnGlyphSetNumber10().BȍőnCharFor(i));
buf.append(set.BȍőnGlyphSetNumber10().BȍőnCharSeperator());
}
return buf.toString();
}
private String print16Numbers(BaseGlyphSet set) {
StringBuilder buf = new StringBuilder();
for (int i=0;i<16;i++) {
buf.append(set.BȍőnPrintGlyphSetNumber16(i, 99));
buf.append(" ");
}
return buf.toString();
}
} }