No, this is not working either. (it just rewrites the idea to set bit 1 for italic and bit 2 for bold styles in a different way (*) ). I tested Ubuntu and OpenSUSE (gtk2), as well as Mint (gkt2, qt), and in none of them the styles are displayed. When I add
with eLogFont do
DebugLn(Format('Name: %s, Style: %s - lfWeight: %d, lfItalic: %d', [
elfLogFont.lfFaceName, elfStyle, elfLogFont.lfWeight, elfLogFont.lfItalic
]));
after the "begin" of EnumFamilyFonts I see in the console output window that the elfLogFont members lfWeight and lfItalic are not reported correctly in Linux. lfWeight is always 400 (= FW_NORMAL) and lfItalic is always 0 (= false), no matter what eLogFont.elfStyle says.
It would be tempting to extract the missing font style from the eLogFont.elfStyle string, but this is deceiving because the string is localized - at least on Windows.
So, I think it must be accepted that this example does not work on Linux.
But maybe the Linux experts have better ideas...
-----------------
(*)
I think that part can still be improved and coded in a way analogous to SelectFont:
// collect styles
s :=eLogFont.elfStyle;
if LStyles.IndexOf(s)<0 then begin
// encode italic (bit 1), bold (bit 2) -- see SelectFont()
n := 0;
if eLogFont.elfLogFont.lfItalic <> 0 then
n := n or 1;
if eLogFont.elfLogFont.lfWeight > FW_MEDIUM then
n := n or 2;
LStyles.AddObject(eLogFont.elfStyle, TObject(ptrint(n)));
end;