[Lazarus] RE : How to I publish the SearchFont method of TFontManager?

silvioprog silvioprog at gmail.com
Mon Jun 20 22:42:00 CEST 2011


2011/6/20 Alberto Narduzzi <albertonarduzzi at yahoo.com>:
>>     VFPImageCanvas.Font := VFreeTypeFont;<<-- if TTF font not exists
>> I receive an AV here.
>
> you cannot receive an AV just for assigning a (eventually...) NIL value to a
> var; as NIL, although of little use, _is_ a valid value.
>
> You may want to check the result value of your font after loading it (I have
> no clue, thou', about how you achieve this), and only then take proper
> action (i.e. default to some other font...).
>
> Cheers, A.

There is no way to verify that TFreeTypeFont found the font.

Another code that not works:

(...)
  VFreeTypeFont: TFreeTypeFont;
  VFPImageCanvas: TFPImageCanvas;
begin
  VFreeTypeFont := TFreeTypeFont.Create;
  VFPImageCanvas := TFPImageCanvas.Create(AImage);
  try
    VFreeTypeFont.Name := AFontName;
    VFreeTypeFont.Size := AFontSize;
    VFreeTypeFont.FPColor := AFontColor;
    if not Assigned(VFreeTypeFont) then
      raise Exception.Create('My custom message');
    VFPImageCanvas.Font := VFreeTypeFont;
(...)

:(

-- 
Silvio Clécio
===============================================
Blog - <silvioprog.com.br>
Twitter - <twitter.com/silvioprog>
LazSolutions - <code.google.com/p/lazsolutions>
LazWebSolutions - <code.google.com/p/lazwebsolutions>
Lazarus-BR - <groups.google.com.br/group/lazarus-br?hl=pt-BR>
===============================================
   * Conheça nosso canal IRC sobre Lazarus: #lazarus-br *
===============================================




More information about the Lazarus mailing list