Windows has a builtin text rasterizer. Let's use it!
I recommend checking out the images below at 1:1 pixel scale and switch between them. DirectWrite looks quite nice. Otherwise, it also features the ability to load system fonts and font fallback.
To make the former possible, this PR introduces the AddFontFromFamily API.
stb_truetype, 100% scale:
DirectWrite, 100% scale:
stb_truetype, 150% scale:
DirectWrite, 150% scale:
Activity
6@ocornut I believe this unfortunately prevents the font fallback that this PR introduces from working. Would you be open to revising the API again?
My PR permits you to request the font "Segoe UI" but render e.g. "木" anyway. map_codepoint_with_fallback() performs font fallback and resolves to a tuple of ("SimSun", 12345) for "木". The new font_src_get_glyph_index_from_codepoint complicates this, since it only returns a glyph index, but no font face to associate it with.
It's possible to work around this by returning a fake (tagged) glyph index. But I'm not sure if that's something you'd like to see merged.
Would you be open to revising the API again?
yes
Hello,
I have rebased this over latest (fixed minor conflicts) but due to a recent change
in ImFontLoadersignature it doesn't work anymore. I thought I'd easily fix it but I wasn't sure how to adapt some detailsmap_codepoint_with_fallback(), maybe you'd more easily adapt it.The new design introduced for #9559 allows loading glyphs from codepoint or font index. See commits: 7263a23f1beab16c72b4a72a036fd822313cfc4e, dfa3c0c0bb7d694348855b3a67ff95d0319a2d61, 09d740ba3292a8609481a17e5b20f16df3f34377, 46ff5a7aab3c091fe8e4e427fea2cabffcf0478d
Old signatures:
New signatures: