Strange behavior TFontDialog component lazarus / 31-LCL ---------------------------------------------------------------------- zoltanleo · 2022-05-17 21:58 Hi folks. Please help me figure out how it works TFontDialog component. When I use it under Windows I can set the font color via the Dialog Option (fig 1). When using Linux (GTK2) I can't set the font color using FontDialog at all. (fig 2). When I use the FontDialog under Darwin, I can select the font color as well as some font styles in the dialog, but they are not applied after Execute method is executed (fig 3). Some code Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.Button1Click(Sender: TObject);begin  FontDialog1.Font.Assign(Label1.Font);  if FontDialog1.Execute then  begin    Label1.Font.Assign(FontDialog1.Font);    StaticText1.Font.Assign(FontDialog1.Font);  end;end; procedure TForm1.Button2Click(Sender: TObject);var  aLogFont: TLogFont;begin  //uses LCLType  //see also https://docs.microsoft.com/en- us/windows/win32/api/wingdi/ns-wingdi-logfonta  with aLogFont do  begin    lfCharSet:= Label1.Font.CharSet;    lfHeight:= Label1.Font.Height;     if (fsBold in Label1.Font.Style)      then lfWeight:= FW_BOLD      else lfWeight:= FW_NORMAL;     lfItalic:= Byte(fsItalic in Label1.Font.Style);    lfStrikeOut:= Byte(fsStrikeOut in Label1.Font.Style);    lfUnderline:= Byte(fsUnderline in Label1.Font.Style);     lfOrientation:= Label1.Font.Orientation;    lfOutPrecision:= OUT_DEFAULT_PRECIS;    lfClipPrecision:= CLIP_DEFAULT_PRECIS;    lfQuality:= Byte(Label1.Font.Quality);    lfPitchAndFamily:= Byte(Label1.Font.Pitch);    lfFaceName:= Label1.Font.Name;  end;  FontDialog1.Font.Assign(aLogFont);   if FontDialog1.Execute then  begin    with aLogFont do    begin      lfCharSet:= FontDialog1.Font.CharSet;      lfHeight:= FontDialog1.Font.Height;       if (fsBold in FontDialog1.Font.Style)      then lfWeight:= FW_BOLD        else lfWeight:= FW_NORMAL;       lfItalic:= Byte(fsItalic in FontDialog1.Font.Style);      lfStrikeOut:= Byte(fsStrikeOut in FontDialog1.Font.Style);      lfUnderline:= Byte(fsUnderline in FontDialog1.Font.Style);       lfOrientation:= FontDialog1.Font.Orientation;      lfOutPrecision:= OUT_DEFAULT_PRECIS;      lfClipPrecision:= CLIP_DEFAULT_PRECIS;      lfQuality:= Byte(FontDialog1.Font.Quality);      lfPitchAndFamily:= Byte(FontDialog1.Font.Pitch);      lfFaceName:= FontDialog1.Font.Name;    end;     Label1.Font.Assign(aLogFont);    StaticText1.Font.Assign(aLogFont);  end;end;                         Does this mean that I'm using the component incorrectly? Or it's a bug? I made a test project for experiments (see attachment) ---------------------------------------------------------------------- PascalDragon · 2022-05-18 06:57 Quote from: zoltanleo on May 17, 2022, 11:58:18 pmWhen I use it under Windows I can set the font color via the Dialog Option (fig 1). When using Linux (GTK2) I can't set the font color using FontDialog at all. (fig 2). When I use the FontDialog under Darwin, I can select the font color as well as some font styles in the dialog, but they are not applied after Execute method is executed (fig 3). As Lazarus uses the native font dialog not every option might be supported on every OS. E.g. on GTK2 the dialog doesn't allow you to change the color so that is simply not supported then. On Windows at least there is handling for colors in the dialog related code, so if that doesn't work this might be a bug. On macOS (I assume Cocoa) this might be a bug as well, at least if the LCL in general supports such styles. ---------------------------------------------------------------------- zoltanleo · 2022-05-18 07:56 Hi PascalDragon Thank U for answer. Does this fact mean that I have to create my own dialog in order to achieve the desired result? ---------------------------------------------------------------------- zeljko · 2022-05-18 10:54 Maybe it's time to create LCL FontDialog, similar to win32, qt/qt5 also have fontdialog without color and eg choose only monospace font. ---------------------------------------------------------------------- zoltanleo · 2022-05-19 11:52 Quote from: zeljko on May 18, 2022, 12:54:37 pmMaybe it's time to create LCL FontDialog, similar to win32, qt/qt5 also have fontdialog without color and eg choose only monospace font. I agree.  For my application, I had to write my own analogue of the dialog box. Also, there is a similar project in the Lazarus "Example" folder ---------------------------------------------------------------------- zoltanleo · 2022-05-20 04:50 Hmmm.... I found that for nix OS, some TWinControl  descendans cannot have the font style fsStrikeOut and fsUnderline. But descendants of TGraphicControl (e.g. TLabel) display these styles correctly. What is it: a bug or a feature? ---------------------------------------------------------------------- trev · 2022-05-20 05:18 What does the Lazarus restriction browser show? ---------------------------------------------------------------------- skalogryz · 2022-05-24 04:47 Quote from: zoltanleo on May 17, 2022, 11:58:18 pmWhen I use the FontDialog under Darwin, I can select the font color as well as some font styles in the dialog, but they are not applied after Execute method is executed (fig 3).fixed here: https://github.com/skalogryz/La zarus/commit/8d136662f3a6ef9dd2813b612f71d8378d635dfa ---------------------------------------------------------------------- zeljko · 2022-05-24 06:11 Quote from: zoltanleo on May 20, 2022, 06:50:25 amHmmm.... I found that for nix OS, some TWinControl  descendans cannot have the font style fsStrikeOut and fsUnderline. But descendants of TGraphicControl (e.g. TLabel) display these styles correctly. What is it: a bug or a feature? It works with qt and qt5 widgetset. ---------------------------------------------------------------------- zoltanleo · 2022-05-25 15:58 Quote from: skalogryz on May 24, 2022, 06:47:18 amQuote from: zoltanleo on May 17, 2022, 11:58:18 pmWhen I use the FontDialog under Darwin, I can select the font color as well as some font styles in the dialog, but they are not applied after Execute method is executed (fig 3).fixed here: https://github.com/skalogryz/Lazarus/commit/8d136662f3a 6ef9dd2813b612f71d8378d635dfa Can you create a ticket in the bug tracker or provide a link if the topic exists? Upd: the ticket is already exists https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/39765