0

I am now converting a project's render engine from GDI to D2D. The GDI use "CreateFontIndirect" to assign font size "-13", font family "Segeo UI". The D2D use "CreateTextFormat" to assign font size "13", font family "Segeo UI". The effect is shown as follow picture:

enter image description here

In GDI case, the system didn't find chinese character in "Segeo UI", it will find in regedit "SystemLink" to locate the chinese font, on my machine is "YaHei". But In D2D case, the system didn't find "YaHei", Which chinese font it will choose to draw, How does it work?

bunglehead
  • 1,104
  • 1
  • 14
  • 22
zhufachang
  • 21
  • 5
  • Does this answer your question? [How does DirectWrite (CreateTextFormat) pick the fallback font(s)?](https://stackoverflow.com/questions/25693651/how-does-directwrite-createtextformat-pick-the-fallback-fonts) – Simon Mourier Dec 02 '20 at 11:38
  • Sorry, No, Is there any way to convert SystemLink to fallback? I am now working on a GDI project. The SystemLink is already exist and in different machine, there are different SystemLink list. I cannot use fallback to custom my pick font list. – zhufachang Dec 03 '20 at 01:31
  • You say "I am now working on a GDI project" but your question is about Direct2D. Direct2D is not GDI, and it uses another mechanism. – Simon Mourier Dec 03 '20 at 07:36
  • 1
    I think what @zhufachang is asking is to achieve same fallback behavior with DirectWrite, that SystemLink used to provide for GDI. There is no way to convert between them automatically, you'll have to invent something yourself. For example you can read SystemLink data, and populate your custom fallback instance with it, if possible. – bunglehead Dec 03 '20 at 15:09
  • @bunglehead ok, thanks – zhufachang Dec 07 '20 at 06:03

1 Answers1

1

It works according to DirectWrite layout logic. See IDWriteTextLayout2::SetFontFallback(), you'll be able to provide your own fallback implementation, if default configuration is not satisfactory.

Basically, layout object will call your custom fallback methods to map characters to fonts, you can then detect which characters you want to map to which font, potentially reusing system fallback implementation for cases you don't care about.

bunglehead
  • 1,104
  • 1
  • 14
  • 22
  • Is there any way to convert SystemLink to fallback? I am now working on a GDI project. The SystemLink is already exist and in different machine, there are different SystemLink list. I cannot use fallback to custom my pick font list. – zhufachang Dec 03 '20 at 01:31
  • Like I said, you'll have to manually construct mappings for your custom IDWriteFontFallback implementation, how you do it is up to you, maybe you can use SystemLink entries for that somehow. – bunglehead Dec 03 '20 at 06:09