Is font TrueType

Is font TrueType

Post by Yoerde » Fri, 27 Jun 2003 12:07:44



Hi,

I'm looking for a fast way to find out if a font is a TrueType font.

I wanted to use a function like the following:

function IsTrueTypeFont(aFont: TFont): Boolean;
var
    LogFont: TLogFont;
begin

    Result := LogFont.lfOutPrecision in [OUT_TT_ONLY_PRECIS, OUT_TT_PRECIS];
end;

but most of the members of LogFont are 0 no matter which font I
check.

Do I have to iterate through all LogFonts on the system to find the
one that matches the name of aFont?

Thanks in advance
Yoerdes

 
 
 

Is font TrueType

Post by Charles Hacke » Fri, 27 Jun 2003 12:29:09



> I'm looking for a fast way to find out if a font is a TrueType font.

 function IsTrueType(const FaceName: String): Boolean;
 //by Steve Schafer
   var
     Canvas: TCanvas;
     DC: THandle;
     TextMetric: TTextMetric;
   begin
   Canvas := TCanvas.Create;
   try
     DC := GetDC(GetDesktopWindow);
     try
       Canvas.Handle := DC;
       Canvas.Font.Name := FaceName;
       GetTextMetrics(Canvas.Handle, TextMetric);
       Result := (TextMetric.tmPitchAndFamily and TMPF_TRUETYPE) <> 0;
     finally
       ReleaseDC(GetDesktopWindow, DC) end;
   finally
     Canvas.Free
   end
end;

--
Charles Hacker
Lecturer in Electronics and Computing
School of Engineering
Griffith University - Gold Coast
Australia

 
 
 

Is font TrueType

Post by Paul Nicholl » Fri, 27 Jun 2003 12:34:50


I use this code that uses the canvas to check the font type:

function FontIsTrueType(CV: TCanvas): Boolean;
var
  TextMetric: TTextMetric;
begin
  GetTextMetrics(CV.Handle, TextMetric);
  Result := (TextMetric.tmPitchAndFamily and TMPF_TRUETYPE) <> 0;
end;


> Hi,

> I'm looking for a fast way to find out if a font is a TrueType font.

> I wanted to use a function like the following:

> function IsTrueTypeFont(aFont: TFont): Boolean;
> var
>     LogFont: TLogFont;
> begin

>     Result := LogFont.lfOutPrecision in [OUT_TT_ONLY_PRECIS,
OUT_TT_PRECIS];
> end;

> but most of the members of LogFont are 0 no matter which font I
> check.

> Do I have to iterate through all LogFonts on the system to find the
> one that matches the name of aFont?

> Thanks in advance
> Yoerdes

 
 
 

Is font TrueType

Post by Yoerde » Sat, 28 Jun 2003 01:55:59



> I use this code that uses the canvas to check the font type:

> function FontIsTrueType(CV: TCanvas): Boolean;
> var
>   TextMetric: TTextMetric;
> begin
>   GetTextMetrics(CV.Handle, TextMetric);
>   Result := (TextMetric.tmPitchAndFamily and TMPF_TRUETYPE) <> 0;
> end;

This works great since I already have a canvas.

Thanks to both of you.
Yoerdes