Fixed ttf4d rendering

This commit is contained in:
Willem Cazander 2022-03-18 16:05:38 +01:00
parent 5679699282
commit 05993d3768
6 changed files with 51 additions and 43 deletions

View file

@ -10,14 +10,8 @@ import love.distributedrebirth.unicode4d.draw.DrawGlyphPath.ImGlyphQuadCurveTo;
public class ImCharacter {
private final DrawCharacter drawChar;
public ImCharacter(DrawCharacter drawChar) {
this.drawChar = drawChar;
}
public void render() {
ImVec2 size = new ImVec2(35f, 50f);
public static void render(DrawCharacter drawChar) {
ImVec2 size = new ImVec2(22f, 26f);
ImGui.invisibleButton("canvas", size.x, size.y);
ImVec2 p0 = ImGui.getItemRectMin();
ImVec2 p1 = ImGui.getItemRectMax(); // p1 = p0 + size
@ -26,12 +20,12 @@ public class ImCharacter {
// draw unicode4D
float xOff = p0.x;
float yOff = p0.y + 35f;
float yOff = p0.y + 19f;
float yFlip = -1f;
float scale = 0.0165f;
float scale = 0.0090f;
ImGlyphPathCommand first = null;
ImGlyphPathCommand prev = null;
int color = ImColor.intToColor(255, 127, 63, 255);
int color = ImColor.intToColor(255, 255, 255, 255);
for (ImGlyphPathCommand cmd: drawChar.getGlyphPath().getPath()) {
if (cmd.isImGlyphMoveTo()) {
first = cmd;
@ -72,8 +66,8 @@ public class ImCharacter {
color);
}
}
drawList.addQuad(p0.x, p0.y, p0.x+size.x, p0.y, p1.x, p1.y, p0.x, p0.y+size.y,
ImColor.intToColor(127, 127, 255, 255), 1f);
//drawList.addQuad(p0.x, p0.y, p0.x+size.x, p0.y, p1.x, p1.y, p0.x, p0.y+size.y,
// ImColor.intToColor(127, 127, 255, 255), 1f);
drawList.popClipRect();
}
}

View file

@ -42,7 +42,7 @@ public class TestConvFont {
try {
// NOTE: Are in order like the FontAtlas of ImGui
String in = "../gdxapp4d-chain-font-unicode4d/target/chain2/";
String out = "../gdxapp4d-chain-font-unicode4d/target/chain/";
String out = "../gdxapp4d-chain-font-unicode4d/src/main/chain/";
conf("code-2000", new File(in+"plane0/code-2000.ttf.xml"), new File(out+"plane0/code-2000.ttf4d"));
conf("fa-solid-900", new File(in+"plane0/fa-solid-900.ttf.xml"), new File(out+"plane0/fa-solid-900.ttf4d"));
@ -182,7 +182,11 @@ public class TestConvFont {
CodePointᶻᴰ.INSTANCE.setCommand(point.getValue(T02PartBinary.PART_1), CodePointCommandᶻᴰ.NOP);
CodePointᶻᴰ.INSTANCE.setCommand(point.getValue(T02PartBinary.PART_2), CodePointCommandᶻᴰ.NOP);
unicode = Integer.parseInt(atts.getValue("unicode"), 16);
String unicodeStr = atts.getValue("unicode");
if (unicodeStr.startsWith("0000, ")) {
unicodeStr = unicodeStr.substring(7);
}
unicode = Integer.parseInt(unicodeStr, 16);
unicodePlane2 = UnicodePlaneᶻᴰ.valueOfUnicode(unicode);
int xMax = Integer.parseInt(atts.getValue("xMax"));
int yMax = Integer.parseInt(atts.getValue("yMax"));