Fastest API for rendering text in Windows Forms?

后端 未结 6 1998
情深已故
情深已故 2020-12-29 10:49

We need to optimize the text rendering for a C# Windows Forms application displaying a large number of small strings in an irregular grid. At any time there can be well ove

6条回答
  •  [愿得一人]
    2020-12-29 11:33

    From recent experience, fastest text output is achieved via ExtTextOut with ETO_GLYPH_INDEX flag. This comes at a price, and it’s that you aren’t printing characters anymore, but font glyphs directly. This means that you need to translate your regular character strings to glyph indexes strings prior calling ExtTextOut, either by calling GetCharacterPlacement everytime, or calling this function just once to build your own translation table, that will be valid until a new font is selected in the DC. Remember that glyph indexes are 16bit, so you can store them in a Unicode string and call ExtTextOutW version regardless of original string character size.

提交回复
热议问题