Nikolay Sivov (@nsivov) commented about dlls/gdiplus/graphics.c:
struct gdip_font_link_section *section;
- DWORD font_codepages, string_codepages;
DWORD string_codepages;
WORD *glyph_indices;
list_init(&info->font_link_info.sections); info->font_link_info.base_font = base_font;
glyph_indices = calloc(length, sizeof(*glyph_indices));
GetGlyphIndicesW(info->hdc, info->string, length, glyph_indices, GGI_MARK_NONEXISTING_GLYPHS);
/* Newlines won't have a glyph but don't need a fallback */
for (progress = 0; progress < length; progress++)
if (info->string[progress] == '\r' || info->string[progress] == '\n')
glyph_indices[progress] = 0;
Handling this as a special case is most likely wrong, but if it works for now so be it.
Regarding approach in general, yes, it seems preferable to use same font when it works, so sequences like "<latin1><japanese><latin2>" wouldn't use Japanese font for <latin2> range. I can only say that in directwrite it's handled differently - fallback is not going to be applied for all three ranges at once from this example, it will be applied per-range. Chromium layout does this differently, by nesting fallbacks to get more consistent output.
I don't know what gdi+ is doing, but if you've tested this, it's good enough I think.