I want to load a font from a compiled resource which is the program itself. I can load it using AddFontMemResourceEx when I was using GDI. However, direct 2D has it own Dwrite API which is not compatible with GDI. The official document suggests using CreateCustomFontFileReference
+ CreateCustomFontCollection
. Could anyone give me an example how to do it?
Take a look at the DirectWriteCustomFontSets sample in the microsoft/windows-classic-samples repo on GitHub ( here ). It demonstrates five scenarios using a custom font set, and based on your question it sounds like case 4 would apply to your situation: "Creates a custom font set using font data contained in in-memory buffers."
For this scenario, the key interface is IDWriteInMemoryFontFileLoader , which was added in the Windows 10 Creators Update (spring 2017).
The specific files in the sample project that will be most relevant are:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.