Manual width
Last updated
Last updated
Unfortunately, not everything is perfect. While working on this plugin, I spent well more than two weeks experimenting and puzzling with width calculation. Width calculation is needed, so that we can know the width of a text line in order to start a new line at the correct position:
I've figured out how to calculate it correctly for the default symbols, but legacy symbols are not so easy. Having spent countless of hours on it, I suppose there either isn't a straightforward solution or I'm just too dumb to figure it out. Either way, the situation is that some characters have wrong widths, which can cause the new lines to be offset like so:
In order for users to be able to fix that, I added a file where you can manually insert widths for characters. It's located in plugins/Tooltips/.data/widths.yml
and looks somewhat like this:
In this file, you insert a character followed by the amount of decimal pixels, which will define it's width.
Let's say we want to fix the ᄚ
character. Best way to check if the character is broken, is to paste it a lot of times and check with /tt sendpreset default PLAYER ᄚᄚᄚᄚᄚᄚ\na
. With that, you can see that the last a
character becomes offset:
To fix that, in the widths.yml file define its width like so:
After which, you can do /tt reload and try the same command again:
As you can see, tha a
is now aligned properly.
If you test the character, and your a
goes to the right, it means that the current width is too small, so you have to try something bigger:
If a
goes to the left, it means your width is too big:
It's about experimentation. Try random values until you find one that aligns the a
perfectly. You can test it easily by just editing & saving the widths.yml
file and then reloading.