diff --git a/src/text_font.cc b/src/text_font.cc index cd43447..df76706 100644 --- a/src/text_font.cc +++ b/src/text_font.cc @@ -125,9 +125,18 @@ int textFontLoad(int font) goto out; } - if (fileRead(textFontDescriptor, sizeof(TextFontDescriptor), 1, stream) != 1) { - goto out; - } + // NOTE: Original code reads entire descriptor in one go. This does not work + // in x64 because of the two pointers. + + if (fileRead(&(textFontDescriptor->glyphCount), 4, 1, stream) != 1) goto out; + if (fileRead(&(textFontDescriptor->lineHeight), 4, 1, stream) != 1) goto out; + if (fileRead(&(textFontDescriptor->letterSpacing), 4, 1, stream) != 1) goto out; + + int glyphsPtr; + if (fileRead(&glyphsPtr, 4, 1, stream) != 1) goto out; + + int dataPtr; + if (fileRead(&dataPtr, 4, 1, stream) != 1) goto out; textFontDescriptor->glyphs = (TextFontGlyph*)internal_malloc(textFontDescriptor->glyphCount * sizeof(TextFontGlyph)); if (textFontDescriptor->glyphs == NULL) {