Fixed ttf4d rendering
This commit is contained in:
parent
5679699282
commit
05993d3768
|
@ -3,6 +3,7 @@ package love.distributedrebirth.gdxapp4d.app.glyphdemo.apps;
|
|||
import java.util.ResourceBundle;
|
||||
|
||||
import imgui.ImGui;
|
||||
import imgui.flag.ImGuiStyleVar;
|
||||
import imgui.flag.ImGuiTableFlags;
|
||||
import love.distributedrebirth.bassboonyd.BãßBȍőnAuthorInfoʸᴰ;
|
||||
import love.distributedrebirth.gdxapp4d.vrgem4.service.VrGem4Unicode4DService;
|
||||
|
@ -60,24 +61,28 @@ public class DemoUnicodePlaneDeskApp extends AbstractDeskApp implements DeskAppR
|
|||
// Dear ImGui Assertion Failed: draw_list->_VtxCurrentIdx < (1 << 16) && "Too many vertices in ImDrawList using 16-bit indices. Read comment above"
|
||||
// Assertion Located At: /tmp/imgui/jni/imgui.cpp:4526
|
||||
|
||||
DrawCharacter drawChar2 = unicode4DService.getCharacterForUnicode('?');
|
||||
ImGui.pushStyleVar(ImGuiStyleVar.ItemSpacing, 0f, 0f);
|
||||
|
||||
DrawCharacter drawChar2 = unicode4DService.getCharacterForUnicode(' ');
|
||||
if (drawChar2 != null) {
|
||||
new ImCharacter(drawChar2).render();
|
||||
ImCharacter.render(drawChar2);
|
||||
ImGui.sameLine(); // print before beginChild to fix height of table row
|
||||
}
|
||||
|
||||
int offset = 33;
|
||||
ImGui.beginChild("row"+plane.name());
|
||||
for (int i=plane.getStart()+offset;i<plane.getStart()+17+offset;i++) {
|
||||
for (int i=plane.getStart()+offset;i<plane.getStart()+33+offset;i++) {
|
||||
DrawCharacter drawChar = unicode4DService.getCharacterForUnicode(i);
|
||||
if (drawChar != null) {
|
||||
new ImCharacter(drawChar).render();
|
||||
ImCharacter.render(drawChar);
|
||||
} else {
|
||||
ImGui.text("?");
|
||||
}
|
||||
ImGui.sameLine();
|
||||
}
|
||||
ImGui.endChild();
|
||||
|
||||
ImGui.popStyleVar();
|
||||
}
|
||||
}
|
||||
ImGui.endTable();
|
||||
|
|
|
@ -28,32 +28,24 @@ public class NotepadDeskApp extends AbstractDeskApp implements DeskAppRenderer {
|
|||
ImGui.text("Value:");
|
||||
ImGui.text(value);
|
||||
|
||||
new ImCharacter(unicode4DService.getCharacterForUnicode(new Character('ﷲ').charValue())).render();
|
||||
ImCharacter.render(unicode4DService.getCharacterForUnicode('ﷲ'));
|
||||
ImGui.sameLine();
|
||||
new ImCharacter(unicode4DService.getCharacterForUnicode(new Character('v').charValue())).render();
|
||||
ImCharacter.render(unicode4DService.getCharacterForUnicode('v'));
|
||||
ImGui.sameLine();
|
||||
new ImCharacter(unicode4DService.getCharacterForUnicode(new Character('r').charValue())).render();
|
||||
//ImGui.sameLine();
|
||||
new ImCharacter(unicode4DService.getCharacterForUnicode(new Character('G').charValue())).render();
|
||||
ImCharacter.render(unicode4DService.getCharacterForUnicode('r'));
|
||||
ImGui.sameLine();
|
||||
new ImCharacter(unicode4DService.getCharacterForUnicode(new Character('E').charValue())).render();
|
||||
ImCharacter.render(unicode4DService.getCharacterForUnicode('G'));
|
||||
ImGui.sameLine();
|
||||
new ImCharacter(unicode4DService.getCharacterForUnicode(new Character('M').charValue())).render();
|
||||
ImCharacter.render(unicode4DService.getCharacterForUnicode('E'));
|
||||
ImGui.sameLine();
|
||||
new ImCharacter(unicode4DService.getCharacterForUnicode(new Character('⁴').charValue())).render();
|
||||
ImCharacter.render(unicode4DService.getCharacterForUnicode('M'));
|
||||
ImGui.sameLine();
|
||||
new ImCharacter(unicode4DService.getCharacterForUnicode(new Character('\'').charValue())).render();
|
||||
ImCharacter.render(unicode4DService.getCharacterForUnicode('⁴'));
|
||||
|
||||
new ImCharacter(unicode4DService.getCharacterForUnicode(new Character('^').charValue())).render();
|
||||
ImCharacter.render(unicode4DService.getCharacterForUnicode('M'));
|
||||
ImGui.sameLine();
|
||||
new ImCharacter(unicode4DService.getCharacterForUnicode(new Character('ᵃ').charValue())).render();
|
||||
ImCharacter.render(unicode4DService.getCharacterForUnicode(Integer.parseInt("27d6", 16)));
|
||||
ImGui.sameLine();
|
||||
new ImCharacter(unicode4DService.getCharacterForUnicode(new Character('a').charValue())).render();
|
||||
ImGui.sameLine();
|
||||
new ImCharacter(unicode4DService.getCharacterForUnicode(new Character('A').charValue())).render();
|
||||
ImGui.sameLine();
|
||||
new ImCharacter(unicode4DService.getCharacterForUnicode(Integer.parseInt("27d6", 16))).render();
|
||||
ImGui.sameLine();
|
||||
new ImCharacter(unicode4DService.getCharacterForUnicode(new Character('仙').charValue())).render();
|
||||
ImCharacter.render(unicode4DService.getCharacterForUnicode('仙'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,15 +22,26 @@ for(let glyphIndex = 0; glyphIndex < num; glyphIndex++) {
|
|||
// JS NOTE: without calling xMin the getContours returns empty set.... :''(
|
||||
glyph.xMin;
|
||||
var contours = glyph.getContours();
|
||||
if (contours.length === 0) {
|
||||
continue; // TODO: add compound support
|
||||
}
|
||||
//space is also without contours
|
||||
// if (contours.length === 0) {
|
||||
// continue; // TODO: add compound support
|
||||
// }
|
||||
if (glyph.unicodes.length === 0) {
|
||||
continue; // with cmds, these are compound glyphs by index base only
|
||||
}
|
||||
let uni = glyph.unicodes.map(formatUnicode).join(', ');
|
||||
|
||||
let xMax = glyph.xMax;
|
||||
let yMax = glyph.yMax;
|
||||
let xMin = glyph.xMin;
|
||||
let yMin = glyph.yMin;
|
||||
if (glyph.xMax === undefined) { xMax = 0; }
|
||||
if (glyph.yMax === undefined) { yMax = 0; }
|
||||
if (glyph.xMin === undefined) { xMin = 0; }
|
||||
if (glyph.yMin === undefined) { yMin = 0; }
|
||||
|
||||
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=\""+xMin+"\" xMax=\""+xMax+"\" yMin=\""+yMin+"\" yMax=\""+yMax+"\" "+
|
||||
"leftSideBearing=\""+glyph.leftSideBearing+"\">");
|
||||
|
||||
for (let contourIndex = 0; contourIndex < contours.length; ++contourIndex) {
|
||||
|
|
|
@ -6,5 +6,7 @@ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
|||
|
||||
for FILE in `ls $1`
|
||||
do
|
||||
if [[ $FILE == *.ttf ]]; then
|
||||
node $SCRIPT_DIR/conv-font.js $1/$FILE > $2/$FILE.xml
|
||||
fi
|
||||
done
|
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -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"));
|
||||
|
|
Loading…
Reference in a new issue