Skip to content

Commit b1e8a42

Browse files
committed
Fix font crash
1 parent fc7df12 commit b1e8a42

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Sources/GateEngine/Resources/Text/Backends/ImageFont.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
*/
77

88
struct ImageFont: FontBackend {
9-
private let fontData:
10-
[Font.Style: (rawTexture: RawTexture, importer: any TextureImporter.Type)]
9+
private let fontData: [Font.Style: (rawTexture: RawTexture, importer: any TextureImporter.Type)]
1110
internal var nativePointSizes: [Font.Style: UInt] = [:]
1211
internal var textures: [Font.Style: Texture] = [:]
1312
internal var characterXAdvances: [Font.Style: [Float]] = [:]
@@ -67,6 +66,11 @@ struct ImageFont: FontBackend {
6766
origin: GameMath.Position2,
6867
xAdvance: inout Float
6968
) -> AlignedCharacter {
69+
if nativePointSizes[key.style] == nil {
70+
// We need to know the native font point size, and we need to load it's texture to know
71+
// So populate the style if needed
72+
_ = populate(style: key.style)
73+
}
7074
let nativePointSize = nativePointSizes[key.style]!
7175
let scaledPointSize = Float(key.pointSize - (key.pointSize % nativePointSize))
7276

0 commit comments

Comments
 (0)