How can we extract the actual font family from CompositeFontFamily applied to a run in WPF RichTextBox

An integral font family is the FontFamilies collection. When applying a composite font to a run, depending on the text, the corresponding font from its font collection is applied.

How can we get which actual font is used in the run on which the composite font was applied?

EDIT2 : suppose I have a run

<Run Text="Some text with different unicode characters not available in applied FontFamily" FontFamily="Global User Interface"/>

Now, if I check run.FontFamily, it returns a "Global User Interface", but the actual font used is one of the FontFamily collection of this composite font. So, I want to know what font it is?

EDIT1 . One way that I can think of is to find it the way WPF applies the font. For each language, a composite font defines a set of fonts corresponding to a specified range of characters. Thus, we can find each character in the run of the text, and then find the font corresponding to this character in the fontfamilymap file for the current language.

Is it correct? Are there any cases where he may fail? Is this the only way? Is there any API \ easy way instead?

thank

+3
source share

Source: https://habr.com/ru/post/1763552/


All Articles