Skip to content

Commit a2d93d9

Browse files
committed
Avoid using a 1-element array for the font bitmap.
1 parent a19c71c commit a2d93d9

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/renderer/base/FontResource.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ namespace
7272
DWORD dfReserved1[4];
7373
GLYPHENTRY dfCharTable[CHAR_COUNT];
7474
CHAR szFaceName[LF_FACESIZE];
75-
BYTE bitmaps[1];
7675
};
7776
#pragma pack(pop)
7877
}
@@ -131,7 +130,7 @@ void FontResource::_regenerateFont()
131130
fontResource.dfFirstChar = L' ';
132131
fontResource.dfLastChar = fontResource.dfFirstChar + CHAR_COUNT - 1;
133132
fontResource.dfFace = offsetof(FONTINFO, szFaceName);
134-
fontResource.dfBitsOffset = offsetof(FONTINFO, bitmaps);
133+
fontResource.dfBitsOffset = sizeof(FONTINFO);
135134
fontResource.dfFlags = DFF_FIXED | DFF_1COLOR;
136135

137136
// We use the steady_clock to create a unique name for the font.
@@ -150,7 +149,8 @@ void FontResource::_regenerateFont()
150149
// Raster fonts aren't generally scalable, so we need to resize the bit
151150
// patterns for the character glyphs to the requested target size, and
152151
// copy the results into the resource structure.
153-
_resizeBitPattern({ fontResource.bitmaps, fontBitmapSize });
152+
auto fontResourceSpan = gsl::span<byte>(fontResourceBuffer);
153+
_resizeBitPattern(fontResourceSpan.subspan(fontResource.dfBitsOffset));
154154

155155
DWORD fontCount = 0;
156156
_resourceHandle.reset(AddFontMemResourceEx(&fontResource, fontResourceSize, nullptr, &fontCount));

0 commit comments

Comments
 (0)