dwjclark11 / Scion2D

2D Game Engine
MIT License
60 stars 8 forks source link

Text Wrapping is Incorrect #17

Open dwjclark11 opened 8 hours ago

dwjclark11 commented 8 hours ago

Description If the text is using any special characters such as !? etc with spaces with the minimal amount of wrapping, the next line will include the space before the word. This is not a desirable outcome.

Prerequisites

To Reproduce Steps to reproduce the behavior:

  1. Ensure there is a game object with a text component.
  2. Change the text to be Hello World! Hello World! Hello World! Hello World!
  3. Check to see if the wrapping is correct.

Expected behavior The text should wrap at the desired wrap size and not have spaces in front of the first word on a new line.

Actual behavior Text is not wrapping correctly and new lines start with a space in front. The space should be removed if on a new line.

Screenshots

Additional context

EX:

-- Main Lua Script!

gEntity = Entity("TextWrapTest", "")
gEntity:add_component(Transform(vec2(100, 100), vec2(1, 1), 0))
-- Add the component and set the wrap. Make sure to adjust the wrap and test multiple sizes.
gEntity:add_component(TextComponent("pixel", "Hello World! Hello World! Hello World! Hello World! ")).wrap = 400 

main = {
    [1] = {
        update = function()
            -- Nothing needed here
        end
    },
    [2] = {
        render = function()
            -- Nothing needed here
        end
    },
}
dwjclark11 commented 8 hours ago

I am currently not able to reproduce this issue. I believe it may have been fixed with 7115aa4, further investigating.

Wrap 400

image

Wrap 200

image

Wrap 175

image

TheEmperorE2 commented 7 hours ago

Hi there, Im TyberZann01. I using JoystixMonospace-Regular.ttf font. Font Size 32.0f px Padding: 4.0f or 0.0f I dont make that typo https://github.com/dwjclark11/Scion2D/commit/7115aa4a31514230f341b13aa406dfe1061ef107 and checked the latest version of this file.

1 2 3 4

This is me version of generate batches: https://pastebin.com/gUMuV5h9

dwjclark11 commented 7 hours ago

@TheEmperorE2 Thank you, I will look into this some more today!