Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend range of characters rendered by the custom font renderer #4362

Merged
merged 3 commits into from
Jan 29, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
small improvement
Wide-Cat committed Jan 29, 2024
commit 280314f5e3a36a099c7ee8c67e1b4978e452588e
Original file line number Diff line number Diff line change
@@ -102,7 +102,8 @@ public double getWidth(String string, int length) {

for (int i = 0; i < length; i++) {
int cp = string.charAt(i);
CharData c = (charMap.containsKey(cp) ? charMap.get(cp) : charMap.get(32));
CharData c = charMap.get(cp);
if (c == null) c = charMap.get(32);

width += c.xAdvance;
}
@@ -119,7 +120,8 @@ public double render(Mesh mesh, String string, double x, double y, Color color,

for (int i = 0; i < string.length(); i++) {
int cp = string.charAt(i);
CharData c = (charMap.containsKey(cp) ? charMap.get(cp) : charMap.get(32));
CharData c = charMap.get(cp);
if (c == null) c = charMap.get(32);

mesh.quad(
mesh.vec2(x + c.x0 * scale, y + c.y0 * scale).vec2(c.u0, c.v0).color(color).next(),