not-fl3 / glium_text_rusttype

Text rendering with glium and rusttype
4 stars 6 forks source link

White space doesn't have bounding box #4

Closed nanokatze closed 7 years ago

nanokatze commented 7 years ago

Therefore it isn't being drawn.

Issue happens here, space doesn't have bounding box and code returns None. Ideas how to fix this?

not-fl3 commented 7 years ago

@fst3a https://github.com/not-fl3/glium_text_rusttype/pull/5 Didnt found how to get space pixel width better. And I propose generic solution - every character with no bounding box will have some width based on font_size. At least it works for space :)

nanokatze commented 7 years ago

It works well with proportional fonts but apparently not very well with monospace. Though, doing

-    let invalid_character_width = font_size / 4;
+    let invalid_character_width = font_size / 2;

seems to fix it while doesn't make proportional fonts look bad:

monospace proportional

not-fl3 commented 7 years ago

Agreed, 2 is better than 4. I still didnt found how to do get that size from rusttype, so lets go that way. Closing this issue now.