You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Title: Bug in Font Loading Method - Incorrect Character Conversion
Description:
I'm using the 'STREGAsGate/Raylib' library, which provides a method called loadFontEx(...) to load font files into the VRAM. However, it seems that the current implementation of this method is using .utf8 to convert characters to code points, which results in incorrect behavior. Instead, the method should be using .unicodeScalars for accurate code point conversion.
Here is the original implementation of loadFontEx(...):
/// Load font from file with extended parameters
@inlinablestaticfunc loadFontEx(_ fileName:String, _ fontSize:Int32, _ fontChars:[Character]?=nil)->Font{return fileName.withCString{ cString inif fontChars ==nil{returnRaylibC.LoadFontEx(cString, fontSize,nil,0)}else{varchars:[Int32]= fontChars!.compactMap({$0.utf8.first}).map({Int32($0)})return chars.withUnsafeMutableBufferPointer{ bufferPointer inreturnRaylibC.LoadFontEx(cString, fontSize, bufferPointer.baseAddress,Int32(bufferPointer.count))}}}}
To fix this bug, I suggest modifying the implementation to use .unicodeScalars for character to code point conversion. Here is the updated implementation:
/// Load font from file with extended parameters (fixed bug in character conversion)
@inlinablestaticfunc loadFontEx(_ fileName:String, _ fontSize:Int32, _ fontChars:[Character]?=nil)->Font{return fileName.withCString{ cString inif fontChars ==nil{returnRaylibC.LoadFontEx(cString, fontSize,nil,0)}else{varchars:[Int32]= fontChars!.map({Int32($0.unicodeScalars.first?.value ??0)})return chars.withUnsafeMutableBufferPointer{ bufferPointer inreturnRaylibC.LoadFontEx(cString, fontSize, bufferPointer.baseAddress,Int32(bufferPointer.count))}}}}
By making this change, the font loading method should now handle character to code point conversion correctly, resolving the issue with incorrect font loading.
For further information/reproducing take a look into this discord conversation on the Raylib server. If you have any questions or need further assistance, feel free to reach out to me. I'd be happy to help!
The text was updated successfully, but these errors were encountered:
Title: Bug in Font Loading Method - Incorrect Character Conversion
Description:
I'm using the 'STREGAsGate/Raylib' library, which provides a method called loadFontEx(...) to load font files into the VRAM. However, it seems that the current implementation of this method is using .utf8 to convert characters to code points, which results in incorrect behavior. Instead, the method should be using .unicodeScalars for accurate code point conversion.
Here is the original implementation of loadFontEx(...):
To fix this bug, I suggest modifying the implementation to use .unicodeScalars for character to code point conversion. Here is the updated implementation:
By making this change, the font loading method should now handle character to code point conversion correctly, resolving the issue with incorrect font loading.
For further information/reproducing take a look into this discord conversation on the Raylib server. If you have any questions or need further assistance, feel free to reach out to me. I'd be happy to help!
The text was updated successfully, but these errors were encountered: