Open SolarLune opened 4 years ago
Yup, validated this bug. The translations does its best but cant always determine the context of pointers. I will spend some more time and investigate futher.
Can you please test that this is the correct solution?
Hello!
No, this isn't working; I'm getting:
goroutine 1 [running, locked to thread]:
github.com/lachee/raylib-goplus/raylib.LoadFontEx(0xc000022140, 0x41, 0xa, 0x7e, 0x0, 0x0, 0x0, 0x0)
/home/solarlune/Documents/Projects/Go/raylib-goplus/raylib/text_gen.go:47 +0x3d4
main.main()
/home/solarlune/Documents/Projects/Go/MasterPlan/main.go:35 +0x265
exit status 2
I'm also getting the same error regardless of what number I pass in, just with a different index out of range number.
hmm, alright I will revisit what I have done.
I believe what it's supposed to take is an array of integers (probably int32's), indicating which specific Unicode code points (character symbols, like a
, Q
, or チ
) to load out of the font. This is probably done because some languages, like Japanese, have too many characters to load all of them at the same time on the same texture (or at least, one can't load them all along with all other characters for all other languages in the spaces reserved between those and Latin characters). See this rather helpful Unicode block article on Wikipedia. In the article, they're represented using hex ranges.
So to work around this, one should be able to specify which symbols to load into the font structure, using an array. See Raysan's comment here. I don't believe raylib-go currently does this correctly either, just for the record.
Hi, I compared this with raylib-go and it passes a pointer to int for fontChars. This changes the behaviour of this function in raylib
CharInfo *LoadFontData(const char *fileName, int fontSize, int *fontChars, int charsCount, int type)
If fontChars is null it will auto generate the array.
I have tested using similar logic that raylib go uses and if this value is null a valid font will be returned. This however only returns a point to font and not the number of font characters returned.
You can copy the raylib-go binding and add a pointer to the returned Font type.
Then load the font like so:
font := *LoadFontEx(filename, fontSize, nil, charCount)
This solved the compile issues for me.
You can copy the raylib-go binding and add a pointer to the returned Font type.
Then load the font like so:
font := *LoadFontEx(filename, fontSize, nil, charCount)
This solved the compile issues for me.
Yes, however I am trying to "Goificate" this function to something that makes sense. Behind the scenes raylib treats it as an array of ints. Because of this, this library should allow you to pass a slice of ints to it.
Hello!
Describe the bug
LoadFontEx()
should be able to take a pointer to an array of ints for the fontChars argument; instead it just accepts a single integer. This prevents you from specifying a range of characters to load when loading the font, I believe. See the cheatsheet.