Skip to content

Commit

Permalink
fix: resolve font renderer issues
Browse files Browse the repository at this point in the history
resolve underlines and strikethrough not working in some situations,
closes #7
resolve unicode characters rendering too far apart, closes #8
  • Loading branch information
DJtheRedstoner committed Sep 17, 2021
1 parent 86de806 commit 3951c49
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/main/java/club/sk1er/patcher/hooks/FontRendererHook.java
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,11 @@ public boolean renderStringAtPos(String text, boolean shadow) {
final Deque<RenderPair> underline = new LinkedList<>();
final Deque<RenderPair> strikethrough = new LinkedList<>();

value.setLastRed(red);
value.setLastGreen(green);
value.setLastBlue(blue);
value.setLastAlpha(alpha);

for (int messageChar = 0; messageChar < text.length(); ++messageChar) {
char letter = text.charAt(messageChar);

Expand Down Expand Up @@ -306,7 +311,8 @@ public boolean renderStringAtPos(String text, boolean shadow) {
adjustOrAppend(underline, this.fontRenderer.posX, effectiveWidth, value.getLastRed(), value.getLastGreen(), value.getLastBlue(), value.getLastAlpha());
}

this.fontRenderer.posX += effectiveWidth;
// Intentional cast to int to round down, see FontRenderer#doDraw
this.fontRenderer.posX += (int) effectiveWidth;
}
}

Expand Down

0 comments on commit 3951c49

Please sign in to comment.