Ggez: Trailing white-spaces are not accounted in text width calcluations

Created on 29 Sep 2019  路  3Comments  路  Source: ggez/ggez

Describe the bug
Trailing white-spaces are not accounted for in Text::width(...) in ggez 0.5.1

To Reproduce
See gist

Expected behavior
Text::width(...) should account for trailing spaces in the calculation.

Screenshots or pasted code
Output from gist

$ cargo run --example singlespacewidth.rs 
Note: Release mode will improve performance greatly.
    e.g. use `cargo run --example text --release`
Empty Text Width: 0
Single-space Text Width: 0
Char: 9
Char with 3 trailing spaces: 9
Char with 3 leading spaces: 40
Spaces bounded: 51
Type-CODE bug

Most helpful comment

That's a fine idea, actually. The main problem there is that a space might not have only one width in a variable-width font...

Per https://github.com/alexheretic/glyph-brush/issues/60 glyph_brush only really cares about glyphs that actually get drawn, which seems pretty reasonable. Dunno what else to do, so I've upstreamed asking for advice: https://github.com/alexheretic/glyph-brush/issues/75

All 3 comments

Whew. Sorry for putting this off for so long. Not sure what the correct behavior should be, since I've seen this "don't count the size of spaces" behavior for other things... and in some cases, such as making justified text, it's obviously the Right Thing. So, hmm.

Hmm, why not add another method that will return a text's width with spaces?

That's a fine idea, actually. The main problem there is that a space might not have only one width in a variable-width font...

Per https://github.com/alexheretic/glyph-brush/issues/60 glyph_brush only really cares about glyphs that actually get drawn, which seems pretty reasonable. Dunno what else to do, so I've upstreamed asking for advice: https://github.com/alexheretic/glyph-brush/issues/75

Was this page helpful?
0 / 5 - 0 ratings

Related issues

t-veor picture t-veor  路  5Comments

icefoxen picture icefoxen  路  4Comments

Joe23232 picture Joe23232  路  4Comments

icefoxen picture icefoxen  路  4Comments

icefoxen picture icefoxen  路  5Comments