2

I'm using a TJvWizard component and I want to set its header Title font to use Segoe UI Light. In my form OnCreate method I'm doing the following:

procedure TForm1.FormCreate(Sender: TObject);
var
  i: Integer;
begin
  for i := 0 to JvWizard1.PageCount - 1 do
  begin
    JvWizard1.Pages[i].Header.ParentFont := false;
    JvWizard1.Pages[i].Header.Title.Font.Size := 16;
    JvWizard1.Pages[i].Header.Title.Font.Name := 'Segoe UI Light';
  end;
end;

This code sets the font size correctly but the Font doesn't change to Segoe UI Light, instead it keeps using the parent font (which is Segoe UI.)

As a workaround, I did this:

procedure TForm1.FormCreate(Sender: TObject);
var
  i: Integer;
  f: TFont;
begin
  f := TFont.Create;
  f.Name := 'Segoe UI Light';
  f.Size := 16;
  for i := 0 to JvWizard1.PageCount - 1 do
  begin
    JvWizard1.Pages[i].Header.Title.Font.Assign(f);
  end;
  f.Free;
end;

This does the trick, but it smells funny to me. Also, I don't know how Assign works. Does it keeps a reference? Should I keep the f.Free line?

Edit: As additional information, I have Office 2013 installed with a fairly recent version of these fonts. I've also observed that I cannot select Segoe UI Light in other applications, for example, InkScape.

Also, in the Delphi property editor, I can select it using the Font select dialog, but the name "Segoe UI Light" doesn't appear; instead, I have to select Segoe UI and in the Font Style list I select the Light style.

Font dialog

Also, selecting the font name using the drop-down list doesn't work either:

Font name from Property Inspector not set

So, I think this has to do with the font version I have, and some extended properties (in fact, in my Fonts folder I can only see Segoe UI, and opening it will open 10 windows.)

Segoe UI in the Windows Font folder

I'm still looking around for a workaround (this sounds like it may be related, but they didn't follow it)

Leonardo Herrera
  • 8,388
  • 5
  • 36
  • 66
  • I cannot reproduce what you described. The font *type* and size were correctly changed in a plain Delphi 2009 project using `TJvWizard` from JVCL Version 3.45. For being sure I rather tested it with visually incommutable font (Webdings), but even with Segoe UI Light there was no problem on my side. – TLama Aug 07 '13 at 18:15
  • Did you try with the wizard font already set up as Segoe UI? – Leonardo Herrera Aug 07 '13 at 18:40
  • That makes no difference. From a quick view in the source I can't see anything wrong. The `Title.Font` font change event is being assigned [`here`](https://github.com/project-jedi/jvcl/blob/master/jvcl/run/JvWizard.pas#L1686) and that `FontChange` event method sets the page header's `ParentFont` to False and causes the whole page header to invalidate, which in turn draws the header by the newly assigned font properties. So even if you'd change it at runtime (I mean, not at form creation), it should work properly. But maybe I overlooked something. – TLama Aug 07 '13 at 19:08
  • @TLama - check my update. I think this has to be with some special styles in modern fonts - semi light, light, semi bold, etc. I've seen some posts around with similar issues, and the same happens to me in a totally unrelated program (InkScape.) – Leonardo Herrera Aug 12 '13 at 19:22

0 Answers0