Fix GDI zero-ink glyph handling

This commit is contained in:
gamer147
2026-08-15 10:30:32 -04:00
parent d38511665a
commit 3289948ce7
5 changed files with 107 additions and 8 deletions

View File

@@ -124,7 +124,11 @@ public sealed class WindowsGdiGlyphMaskRasterizer
int height = checked((int)metrics.BlackBoxY);
int stride = checked((width + 3) & ~3);
int expectedBytes = checked(stride * height);
if (size != expectedBytes)
// CP932 0x8140 (U+3000 IDEOGRAPHIC SPACE) is a zero-ink spacing glyph. GDI reports
// its placement as a nominal 1x1 black box but returns a zero-byte required buffer.
// Preserve those metrics and materialize the implied transparent mask; a nonzero
// short/oversized payload still means that the bitmap contract is inconsistent.
if (size != 0 && size != expectedBytes)
throw new InvalidOperationException(
$"GDI gray-4 buffer size {size} disagrees with {width}x{height}, stride {stride}.");