Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to tell if a selected font is a True Type font Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
30-Aug-02
Category
Graphic
Language
Delphi 2.x
Views
72
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Tomas Rutkauskas

How to tell if a selected font is a True Type font

Answer:

Solve 1:

1   uses
2     SysUtils, WinTypes, Classes, Forms, Dialogs, StdCtrls, Controls;
3   
4   function isTrueType(FontName: string): Boolean;
5     procedure Button1Click(Sender: TObject);
6   
7       procedure TForm1.Button1Click(Sender: TObject);
8       begin
9         if isTrueType('Courier') then
10          showmessage('Is a true type font')
11        else
12          showmessage('Not true type');
13      end;
14  
15      function EnumFontFamProc(var LogFont: TLogFont; var TextMetric: TTextMetric;
16        FontType: Integer; TF: TForm1): Integer; export; stdcall;
17      begin
18        Result := 1;
19        if FontType and TRUETYPE_FONTTYPE > 0 then
20          Result := 0; {stop enumerating}
21      end;
22  
23      function TForm1.isTrueType(FontName: string): Boolean;
24      var
25        Buffer: array[0..255] of Char;
26      begin
27        StrPCopy(Buffer, FontName);
28        result := (EnumFontFamilies(Canvas.Handle, Buffer, @EnumFontFamProc, 
29  LongInt(Self)) = false);
30      end;


Solve 2:

31  function IsTrueType(const FaceName: string): Boolean;
32  var
33    Canvas: TCanvas;
34    DC: THandle;
35    TextMetric: TTextMetric;
36  begin
37    Canvas := TCanvas.Create;
38    try
39      DC := GetDC(GetDesktopWindow);
40      try
41        Canvas.Handle := DC;
42        Canvas.Font.Name := FaceName;
43        GetTextMetrics(Canvas.Handle, TextMetric);
44        Result := (TextMetric.tmPitchAndFamily and TMPF_TRUETYPE) <> 0;
45      finally
46        ReleaseDC(GetDesktopWindow, DC);
47      end;
48    finally
49      Canvas.Free;
50    end;
51  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC