Vector35 / binaryninja-api

Public API, examples, documentation and issues for Binary Ninja
https://binary.ninja/
MIT License
922 stars 209 forks source link

Properly calculate width of characters #1234

Open joshwatson opened 5 years ago

joshwatson commented 5 years ago

This one is pretty self explanatory: image

plafosse commented 5 years ago

The root cause of this is the same reason we don't use subscripts for SSA. We figure that all characters in a monospace font take up the same amount of space. It's actually very non-trivial to figure out the width of a character without a dedicated library in the core. In your case one tab is one character and we therefore figure it takes the same amount of space as a normal character. I'm going to change the title to reflect the underlying issue.

plafosse commented 5 years ago

Related to: #662

joshwatson commented 5 years ago

Additionally, using emoji can add weird space as well, probably because it calculates the width of the token based on the number of bytes in the emoji's unicode sequence. However, this does not cause the same kind of bug as above, where the text falls over the boundary of the block.

plafosse commented 5 years ago

Yeah that is because the an emoji is like 4 characters that gets emitted as the width of 1 or 2 characters. Whereas a tab is 1 character which gets emitted as the width of 4 or 8. Its kinda the opposite problem

jeffli678 commented 4 years ago

Also currently a tab is displayed as 9 chars wide, which is quite weird

jeffli678 commented 4 years ago

the case for the tab is now fixed in 2307. Though the general case is not solved yet