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 get the font family when the user selects a 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
12-Oct-02
Category
Graphic
Language
Delphi 2.x
Views
69
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Jonas Bilinkevicius

Windows organizes fonts by family and categorizes families with five family names. 
A sixth name ("Dontcare") allows an application to use the default font. These 
family names correspond to constants found in the WINGDI.H file: FF_DECORATIVE, 
FF_DONTCARE, FF_MODERN, FF_ROMAN, FF_SCRIPT, and FF_SWISS. An application uses 
these constants when it creates a font, selects a font, or retrieves information 
about a font. Fonts within a family are distinguished by size (10 point, 24 point, 
and so on) and style (regular, italic, and so on). However, it doesn't say how I 
can get that setting for any given font. Is there a way to use GetObject to do this?

Answer:

The following table describes the font-family names:

Font-family name: Description
Decorative: Specifies a novelty font. An example is Old English.
Dontcare: Specifies a generic family name. This name is used when information about 
a font does not exist or does not matter.
Modern: Specifies a monospace font with or without serifs. Monospace fonts are 
usually modern; examples include Pica, Elite, and Courier New.
Roman: Specifies a proportional font with serifs. An example is Times New Roman.
Script: Specifies a font that is designed to look like handwriting; examples 
include Script and Cursive.
Swiss: Specifies a proportional font without serifs. An example is Arial.

Here's a sample method, using the form's font:

1   procedure TForm1.Button1Click(Sender: TObject);
2   var
3     LogFont: TLogFont;
4     BytesReturned: integer;
5     s: string;
6   begin
7     BytesReturned := GetObject(Font.Handle, sizeof(LogFont), @LogFont);
8     if BytesReturned = 0 then
9     begin
10      caption := 'Failed';
11      exit;
12    end;
13    case LogFont.lfPitchAndFamily and $F0 of
14      FF_DONTCARE: s := 'Don''t care, or don''t know.';
15      FF_ROMAN: s := 'Variable stroke width, serifed.';
16      FF_SWISS: s := 'Variable stroke width, sans-serifed.';
17      FF_MODERN: s := 'Constant stroke width, serifed or sans-serifed.';
18      FF_SCRIPT: s := 'Script; Cursive, etc.';
19      FF_DECORATIVE: s := 'Decorative: Old English, etc.';
20    end;
21    caption := s;
22  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