The CreateTextFormat method expects a fontFamilyName parameter. How do I create an IDWriteTextFormat that uses the default UI font?
相关问题
- Sorting 3 numbers without branching [closed]
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- thread_local variables initialization
- What uses more memory in c++? An 2 ints or 2 funct
相关文章
- 如何让cmd.exe 执行 UNICODE 文本格式的批处理?
- 怎么把Windows开机按钮通过修改注册表指向我自己的程序
- Warning : HTML 1300 Navigation occured?
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- Which is the best way to multiply a large and spar
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
Please note, that all code here is done without any checks (too many methods here return HRESULT, would blow this example up!).
For acquiring the system wide font you should use this:
(This is from another stackoverflow question!)
for paint now use this:
A bit changed from this question!
This solution is really raw and in my opinion ugly.
Alternative solution do get the IDWriteFont (looks ugly but is fine):
Even without checks, code runs on my computer without any problems and gives me the same result as the first solution (Windows 10, Font family name is Segoe UI).
Sources: General Microsoft DirectWrite API documentation
CreateIndirectFont Documentation
How to enumerate font families, Microsoft documentation