silvioprog schrieb:

Another code that not works:

(...)
  VFreeTypeFont: TFreeTypeFont;
  VFPImageCanvas: TFPImageCanvas;
begin
  VFreeTypeFont := TFreeTypeFont.Create;
  VFPImageCanvas := TFPImageCanvas.Create(AImage);
  try
    VFreeTypeFont.Name := AFontName;

If VFreeTypeFont were Nil, the AV would occur here!

    VFreeTypeFont.Size := AFontSize;
    VFreeTypeFont.FPColor := AFontColor;
    if not Assigned(VFreeTypeFont) then
      raise Exception.Create('My custom message');

The following is the really critical statement, where the platform fontmanager is asked to select the (closest) installed font, and assign it to the canvas:

    VFPImageCanvas.Font := VFreeTypeFont;

Are you sure that VFPImageCanvas is not Nil???

When it definitely is the font, and not the canvas, then I'd try-except only *this* statement, and when it fails modify the FontName until no exception occurs.

When it is the font name, there should exist means to enumerate the installed fonts. At least the WinAPI allows to ask for the name of the closest font, based on general font attributes (w/o serifes...). Dunno what LCL/RTL offers for that purpose...

I also don't know how e.g. Win32 deals with *FreeType* fonts, in Delphi I've been working with *TrueType* fonts only.

DoDi


--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to