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

Flávio Etrusco flavio.etrusco at gmail.com
Tue Jun 21 00:39:34 CEST 2011


On Mon, Jun 20, 2011 at 5:21 PM, Alberto Narduzzi
<albertonarduzzi at yahoo.com> wrote:
>>     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.

True, but the exception can _appear_ to be raised there since 'Font'
is a property and has a setter, and we usually don't use FPC units
compiled with debugging info.


>
> 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.
>

TFreeTypeFont constructor doesn't receive a font name, so...

I don't have freetype installed right now (I'm on Windows) so I can't
test, but maybe you could try font.AllocateResources or
FontMgr.RequestFont.

Best regards,
Flávio




More information about the Lazarus mailing list