AmberWat / NegativeSpaceFont

Minecraft resource pack with negative and positive size spaces
Creative Commons Attribution 4.0 International
265 stars 17 forks source link

[Question] space.-0,5 ? #4

Closed YaseiCoding closed 2 years ago

YaseiCoding commented 2 years ago

Hi, I have come across a problem regarding custom characters with odd height.

2 characters of even height(e.g. 10) are spaced out by exactly 1 space. They can be snug perfectly together using "space.-1": image

Using the same logic 2 characters of odd height(e.g. 9) are spaced out by 1,5 space. after using "space.-1" there's still 0,5 space left: image (Ignore different vertical offset from the first image. Just different Ascent values)

In both scenarios the characters on the left are just entered after each other and on the right there's a "space.-1" between them So basically I was wondering if there was a possibility to create something like "space.-0,5" to overcome this problem

SoSeDiK commented 2 years ago

As one way to snap them, you can keep your image the same, but increase the canvas by 1 pixel. So you'll still have 9 pixels and 1 extra that'll be empty. Then you should be able to move the image precisely by pixels I believe.

AmberWat commented 2 years ago

The reason why space.-0.5 isn't in the pack is because of limitations of bitmap based font providers that force snapping to a whole unit. The technical reason is that the final step for calculating width basically looks like this: int(width + 0.5) + 1

However, a ttf (TrueType Font) based solution would be more flexible. I could include some fractional sizes in the next release since the bug that caused them to crash the game (on systems with integrated Intel graphics) is fixed in 1.17 and up.

Please do let me know if there are any particular sizes beyond -0.5 that you'd want, or any other features for that matter.

In the meantime you can work around it, as already mentioned. Pad your textures with empty space to make the dimensions even. If you find that the game is cropping away the empty space, paint in some pixels using a low but non-zero alpha value.

YaseiCoding commented 2 years ago

As one way to snap them, you can keep your image the same, but increase the canvas by 1 pixel. So you'll still have 9 pixels and 1 extra that'll be empty. Then you should be able to move the image precisely by pixels I believe.

I don't think this would work as I've discovered it's more about the width of the character rather than height, so even if I increased the canvas by 1, I'd have to increase the character height in my font which would basically not change anything

YaseiCoding commented 2 years ago

The reason why space.-0.5 isn't in the pack is because of limitations of bitmap based font providers that force snapping to a whole unit. The technical reason is that the final step for calculating width basically looks like this: int(width + 0.5) + 1

However, a ttf (TrueType Font) based solution would be more flexible. I could include some fractional sizes in the next release since the bug that caused them to crash the game (on systems with integrated Intel graphics) is fixed in 1.17 and up.

Please do let me know if there are any particular sizes beyond -0.5 that you'd want, or any other features for that matter.

In the meantime you can work around it, as already mentioned. Pad your textures with empty space to make the dimensions even. If you find that the game is cropping away the empty space, paint in some pixels using a low but non-zero alpha value.

Thanks for the information. I will definitely look forward to the next release. As for other fractional sizes I've never seen anything causing a need for spaces other than space.-0.5, but probably adding space.-0.1 as a precaution would not hurt.

Also I have a little question regarding the ttf font. Is it possible to use the translations with only the ttf installed instead of the normal font? I just couldn't get it to work.

AmberWat commented 2 years ago

Is it possible to use the translations with only the ttf installed instead of the normal font?

You can't use only the TTF and get translations. The translations are stored in a separate file from the font (no matter the type of font) so you might be able to just copy the lang folder. But if you have a TTF file it's from an old version that might be incompatible.

I plan to generate a version for testing by the end of the week, with a fresh TTF file and translations to go with it.

AmberWat commented 2 years ago

Testing release v4.99-TEST is now available. Please read the updated README file included, try it out and let me know if you have any feedback.

YaseiCoding commented 2 years ago

Testing release v4.99-TEST is now available. Please read the updated README file included, try it out and let me know if you have any feedback.

I don't have time right now but I'll check it out in 3 or 4 days

YaseiCoding commented 2 years ago

A little late, but I tested the pack and it's perfect. Exactly what I needed. Thanks