pret / pokeemerald

Decompilation of Pokémon Emerald
2.18k stars 2.32k forks source link

letter spacing not working? #2015

Open Meister-anon opened 1 month ago

Meister-anon commented 1 month ago

not 100% on this but when I attempted to use AddTextPrinterParameterized4 to shift letter spacing I found it didn't work it seemed the field was never used?

printer.letterSpacing = letterSpacing;

it gets passed to that field and then goes to AddTextPrinter function

within the function letter spacing isn't used instead minLetterSpacing is used sTempTextPrinter.minLetterSpacing = 0;

which gets defaulted to zero.

No matter what value I set letterspacing to in AddTextPrinterParameterized4 it had no effect but changing minLetterSpacing did.

So my fix was assigning letter spacing to the field

sTempTextPrinter.minLetterSpacing = sTempTextPrinter.printerTemplate.letterSpacing;

I was working in fire red when I found this, but then saw it was the same in both emerald and emerald expansion.

idk if this is the best fix or not, but its what worked for me and it seem right as the RenderText function has a condition based on the value of minLetterSpacing but by default the field is always 0.

if (textPrinter->minLetterSpacing)
        {
            textPrinter->printerTemplate.currentX += gGlyphInfo.width;
            width = textPrinter->minLetterSpacing - gGlyphInfo.width;
            if (width > 0)
            {
                ClearTextSpanDebug(textPrinter, width);
                textPrinter->printerTemplate.currentX += width;
            }
        }
Meister-anon commented 1 month ago

made extra change, in the RenderText function replaced the lines in the last codeblock


//width = textPrinter->minLetterSpacing - gGlyphInfo.width;
                width = textPrinter->minLetterSpacing;

with how it worked the spacing given by letterspacing would be determined by its diff to the glyph width for the specific character making the letterspacing field confusing to use.

With this change setting letter spacing to 2 would actually be an increase of 2. without needing to do extra math for specific width of the character. mGBA_CZvl2w2Ez4

It seems to be working, before this change had to use values at or above 8 to make a difference.

now the same changes are just from using values of 1, 3, and 0.

ps. If you attempt same fix I did you'd need to go through and make all instances of letterspacing in addtextprintparameterized etc. 0.

same thing for the letterspacing values in window templates as seen in dex listmenu etc. and functions that pass letterspacing equivalents