Page 1 of 1

Pasted text from docx does not display correctly in RichViewEdit

Posted: Sat Dec 27, 2025 4:18 pm
by joeb545
I am using Delphi Pro 13 in a Parallels ARM64 Windows VM. I created a simple FMX application with a TRichViewEdit and a TRVStyle. Next, I pasted content from a Word docx file that includes text in various styles and in tables. The content came across with Headers showing the same as in the orginal. However, all the normal sized text displayed in the RichViewEdit as bold. When I exported the content to a docx file, everything looked the same as the original Word file, although the style information did not carry over. So, the problem is the RichViewEdit did not display the content correctly. How can I fix this? I've attached the file I used for this.

FYI, the same thing happened when I imported the docx file. However, when I did the same thing using VCL, the RichViewEdit displayed everything correctly.

Re: Pasted text from docx does not display correctly in RichViewEdit

Posted: Tue Dec 30, 2025 12:03 pm
by Sergey Tkachenko
I confirm the problem.
This is a drawing issue: the text is stored as not bold, but displayed as bold.

And I'm afraid I don't know how to fix this.

As I understand it, this is a result of font auto-substitution. The document uses the font 'Aptos', which is not available to non-Microsoft applications. Can you check this by checking if 'Aptos' is in the font drop-down list.
Accordingly, the system (in this case, Direct2D) finds a substitute for the unavailable font. And in some cases, it works poorly – it finds a substitute with a bold font.
I do not know how I influence it: the component simply uses a TTextLayout for drawing and sets its Font property (to a non-bold font). The only idea that I have is to implement TRichView's own system of font substitution.

This only happens when using Direct2D, which is the default in FireMonkey.

The problem doesn't reproduce if:
1) Set GlobalUseDirect2D := False in initialization. After this, the application uses GDI+ instead of Direct2D (which is highly discouraged, as it is significantly slower).
2) If you initialize Skia4Delphi. You need to right-click the project name and select "Enable Skia," and also enable the fmxRVSkiaFM module in the "uses" section. I recommend this method.