How to get information about a substituted font?

I am presently reviewing collaboratively a book. I work on spelling, contents, meaning, … I keep the styles just as they are configured. Fonts requested by the various styles are not installed on my computer. Consequently some substitute is used.

I sent back my revision both as ODT and PDF (because I changed paragraph wording, removed empty lines, swapped blocks of text, edited some styles, …). Modifying geometric properties of styles impacts final layout. Since my effective fonts are not the ones requested by the styles, I sent back deliberately a PDF so that the original author could see what I had on my screen.

He commented he found my fonts more pleasant than his and enquired which they were.

Since the effective fonts result from automatic built-in substitution, I don’t know which were chosen.

I found this proposal but as of 7.5.3.2 it is not yet implemented.

Does anyone know if LO has some substitution dictionary either in user profile or global library? Is this a responsibility of the font renderer? But it should probably report back to Writer in order for this latter to correctly break lines. How can I know for sure which font was used?

In case the feature is in the OS, I am under Fedora 38 with KDE Plasma desktop. Still X11, not yet Wayland.

Can this help somehow? :

https://wiki.documentfoundation.org/LibreOffice_Localization_Guide/Advanced_Source_Code_Modifications#Font_Fallback

Thanks, @Hrbrgr. I had something like this XML in my mind. Unfortunately There is no such file in my Linux box. What I find in my user profile is already modified by some template and anyway I can’t see the basic substitution table.
When I search with the original font name, there is no hit. A generic key like “sans serif” returns nothing relevant.

@ajlittoz: you might want to try XFontMappingUse interface, which you might obtain by creating an instance of com.sun.star.awt.Toolkit service. It appeared in v.7.3. It provides you a “log” of the mapping events.

Thanks @mikekaganski; it looks it is exactly what I’m looking for. However there is a catch: I am absolutely totally ignorant in macros. All I want to know is which font is substituted so that I can tell which one was used. The other person wants to check its aesthetics “value”.

Would some macro “regular” be kind enough to write one for me? Ideally I’d pass a font name and retrieve the actual font.

Please start the first one, then open, type, export, whatever; in the end, run the second, to get a list of “requested font and what was used for the substitution”. But possibly the MsgBox would be unable to display all of them - then we’d need to put it to a document…

sub StartFontMappingTracking
  xFontMappingUse = CreateUnoService("com.sun.star.awt.Toolkit")
  xFontMappingUse.startTrackingFontMappingUse()
end sub

sub EndFontMappingTracking
  xFontMappingUse = CreateUnoService("com.sun.star.awt.Toolkit")
  seqItems = xFontMappingUse.finishTrackingFontMappingUse()
  s = ""
  
  for each item in seqItems
    if (UBound(item.usedFonts) <> LBound(item.usedFonts)) or (item.originalFont <> item.usedFonts(UBound(item.usedFonts))) then
      if Len(s) <> 0 then s = s + Chr(10)
      s = s + item.originalFont
      for each subitem in item.usedFonts
        s = s + Chr(10) + Chr(9) + subitem
      next subitem
    end if
  next item
  
  MsgBox s
end sub
1 Like

Note that this can’t work. Mapping works not on fonts, but on individual glyphs. E.g., you put some font name to the font box, absent on the system. Then you type. You start typing “abc”, and some Font1 is used for rendering. Then you type some Greek, Arabic, Japanese, emoji, Thai, whatever. And it turns out that some glyphs are absent in the Font1, and Font2 is used instead for them; and Font3, …, FontN, as necessary.

@mikekaganski Thanks a lot. Quite difficult to read because I don’t know how the code works here (in LO or the font renderer), but I think I get the idea.
I got a really unexpected result! Google is now colonising Linux territory: Google fonts are installed by default and you can’t remove them lest your system becomes unusable. So, where I expected Liberation Sans or FreeSans to be substituted for Adobe Garamond Pro, the macros reported Noto Sans. You can never guess.