Thanks for you comments. The answer is yes, as you guessed. Typically, native GetGlyphOutlineW(hdc, ' ', GGO_BITMAP, &gm, 0, NULL, ...) returns gm.gmBlackBoxX = 1 instead of 0. Unfortunately, Wine's didn't, and existing source codes (winex11, gdiplus, gdi32) expect 0 in this case.
I don't think the existing code for finding the mask size would have a problem with gmBlackBoxX being 0. But it would be best to skip updating min_x, min_y, max_x, and max_y in this case, since we don't really need the mask to include the position of an empty glyph.
Does Wine's GGO return a non-zero value currently? That would mean a regression in gdiplus drawing only empty glyphs when you fix GGO.
Native GGO returns GDI_ERROR in GetGlyphOutlineW(hdc, ' ', GGO_BITMAP, &gm, bufsize, buf, ...) case. Please note that bufsize and buf are specified and guess they aren't null.
The second loop is for creating mask bitmaps. We don't need to update bitmaps if the character is empty. However, we also need to update the bitmap mask after that character. So, I just ignore the error and continue at that point.
I think a comment saying just /* empty glyph */ inside the if blocks for these new cases would make the code much clearer.