pyscripter 689 Posted December 20, 2021 (edited) There are a few choices when it comes to native processing and rendering of Unicode text in Windows applications. Namely, GDI, GDI+, UniScribe and DirectWrite. I have been doing some research in the process of updating/fixing the Unicode handling in SynEdit. It appears that the future lies with DirectWrite. Here are some reasons: WPF is based on DirectWrite Recent Microsoft applications, such as the Windows Terminal, use DirectWrite The Windows App SDK (new name of Project Reunion) is using a new cross-platform version of DirectWrite called DWriteCore, which is mostly compatible with DirectWrite. So presumably, switching to DWriteCore, if needed, would be easy. DirectWrite has many advantages including: Can play with GDI well, so you can mix the two. Supports color fonts Handles Unicode such as emojis reasonably well. Supports bi-directional text (e.g. mixing Arabic with English) Provides GPU acceleration. The downside is that it is fairly complex and there is not much Delphi Code that is using DirectWrite. Also the Delphi header translations have bugs and have not been updated for years (see [RSP-36642] CreateGdiCompatibleTextLayout is declared wrongly in Winapi.D2D1 - Embarcadero Technologies for instance). Further to the discussion in Unicode string - how element iterating? - RTL and Delphi Object Pascal - Delphi-PRAXiS [en] (delphipraxis.net), I have created a little demo which showcases rendering complex Unicode text with DirectWrite and also provides a Grapheme enumerator for Delphi strings also based on DirectWrite. Here is a screenshot. The ListBox shows the graphemes of the text. It is custom painted with DirectWrite. The Emoji consists of 7 unicode codepoints. See also fdwr/TextLayoutSampler: Utility to display text via multiple Windows API's simultaneously (D2D, DWrite, GDI, GDI+). (github.com) The source code of the project is attached. DirectWriteTest.zip Edited December 20, 2021 by pyscripter 4 Share this post Link to post
Vandrovnik 214 Posted December 20, 2021 I would also vote for DirectWrite. When I switched to Direct2D and DirectWrite, I have used https://github.com/CMCHTPC/DelphiDX12 instead of Emba's units, which were buggy and did not contain "new" things (like printing support for Direct2D). 1 Share this post Link to post
Dimon_II 0 Posted December 14, 2022 I couldn't figure out how to load DWriteFactory fonts. Can you show an example where the emoji font is loaded dynamically (from resources/memory, non directly font file)? The AddFontMemResourceEx function only makes private fonts(invisible to DirectWrite), and AddFontResourceExW doesn't work for me. Share this post Link to post
Alexander Sviridenkov 356 Posted December 14, 2022 Code is not simple, you shoud implement IDWriteFontCollectionLoader, IDWriteFontFileEnumerator, IDWriteFontFileStream, IDWriteFontFileLoader interfaces and use Factory.CreateCustomFontCollection. Share this post Link to post
Dimon_II 0 Posted December 14, 2022 (edited) Guys, I have zero skill in DirectDraw... I just need to draw 1 color glyph with standard tools. I already create a program that aligns monochrome glyphs. Git: FontFit But in "the whole big Internet" there was only one free program for adding colored glyphs, and it has no scaling... OpenType SVG Font Editor (already slightly modified by a friend elricbk ) And I really want to make a more functional analogue. FreeWare-OpenSource. Edited December 14, 2022 by Dimon_II Share this post Link to post