BloCamLimb / ModernUI

Modern desktop framework from low-level 3D graphics API to high-level view model, for development of 2D/3D rendering software or game engine, with internationalization support and many new technologies.
GNU Lesser General Public License v3.0
281 stars 13 forks source link

[Bug] Font issue on first letter of appended components when changing colors. #234

Closed lanAnderson closed 6 hours ago

lanAnderson commented 2 weeks ago

Describe the bug

When appending two component that have different fonts, changing the color of the second component causes its first letter to use the font from the first component.


To Reproduce/Expected behavior/Screenshots

Working as expected:

2024-08-29_06 13 38

      MutableComponent component1 = Component.literal("Test1 ")
          .withStyle(Style.EMPTY.withFont(Minecraft.ALT_FONT));

      MutableComponent component2 = Component.literal("Test2")
          .withStyle(Style.EMPTY.withFont(Minecraft.DEFAULT_FONT));

      MutableComponent finalComponent = component1.append(component2);

      mc.font.drawShadow(graphics, finalComponent, 10, 10, 0xffffff);

Adding a color to second component causes its first letter to continue using the font of the first component:

2024-08-29_06 13 58

      MutableComponent component1 = Component.literal("Test1 ")
          .withStyle(Style.EMPTY.withFont(Minecraft.ALT_FONT));

      MutableComponent component2 = Component.literal("Test2")
          .withStyle(Style.EMPTY.withFont(Minecraft.DEFAULT_FONT).withColor(ChatFormatting.RED));

      MutableComponent finalComponent = component1.append(component2);

      mc.font.drawShadow(graphics, finalComponent, 10, 10, 0xffffff);

Environment

I basically use a custom bitmap font for icons, and when the text color is changed it cause the first letter of the text appended to the icon to use the incorrect font.

BloCamLimb commented 2 weeks ago

Fixed in https://github.com/BloCamLimb/ModernUI-MC/commit/011cb5adea7f240046faf2beeb95d066d642d76f

BloCamLimb commented 6 hours ago

Fixed in 3.11