To get a list of fonts available we have to use EnumFontFamilies or EnumFonts Win32 API functions. For a description of the differences between those two functions please refer to Win32 SDK documentation. I'll use the first one (EnumFontFalimiles) for this example.

Win32 API provides several enumeration functions for various tasks. There are functions capable of enumerating installed fonts, printers and so on. All those enumerating functions require you to pass a callback function, actually the function pointer, as one of its parameters.

A callback function is one function coded and provided to the system by the programmer. The system uses the function, the programmer passes as a parameter to an EnumXXXX function, to pass the requested information back.

Here is how you might code a call to EnumFontFamilies function:

DC := GetDC(0); { get screen's device context }
EnumFontFamilies(DC, nil, @EnumFontsProc, LongInt(ComboBox1));
ReleaseDC(0, DC); { release device context }

The first parameter, DC, is a device context. Check "Device Contexts" topic of the Win32 SDK for more info on device contexts. We are passing screen's device context here since we are interested for screen fonts.

The second parameter is a PChar specifying the family name of the desired fonts. Since we want all the available information we pass nil.

The third parameter is the pointer to the callback function we provide. We didn't actually code it yet. We'll do that in a minute. As you know the "@ operator returns the address of a variable, or of a function, procedure, or method; that is, @ constructs a pointer to its operand" as Delphi's online help states.

The last parameter is a Longint. Anything that could be typecasted as a LongInt could be passed here. It's up to us to decide what to pass.
Remember, an object could be typecasted to a LongInt as
and then pass it to the function.

Here is how the EnumFontsProc, the callback function provided by the programmer, might look like:

function EnumFontsProc(var EnumLogFont: TEnumLogFont; var TextMetric: TNewTextMetric; FontType: Integer; Data: LPARAM): Integer; stdcall;
FontName: string;
CB : TComboBox;
CB := TComboBox(Data);
FontName := StrPas(EnumLogFont.elfLogFont.lfFaceName);
if (CB.Items.IndexOf(FontName) < 0) then if (FontType = TRUETYPE_FONTTYPE) then CB.Items.Add(FontName); Result := 1; end; For a complete description of the TEnumLogFont and TNewTextMetric please refer to Win32 SDK. I think it's enough to say that they hold all the info the system could provide us regarding a font. They are declared in Windows.pas. The FontType could be one of the following integer constants declared in Windows.pas too RASTER_FONTTYPE = 1; DEVICE_FONTTYPE = 2; TRUETYPE_FONTTYPE = 4; Here is how this mechanism works: Windows randomly selects one font of each available type family, since we have passed nil as the second parameter to EnumFontFamilies, and passes the available information for that font to your callback function, EnumFontsProc in this case. The enumeration will continue until either the callback return 0 (we constantly retrun 1) or there are no more fonts to enumerate. Inside the EnumFontsProc we might examine each font passed and do what we want to do with the available information. In the above code I just add the FontNames to a ComboBox items. Following is a class I've coded to make the task easier: type TFontType = (ftRaster, ftDevice, ftTrueType); (*----------------------------------------------------------------------------------*) TFontInfo = class private FShortName : string; FFullName : string; FStyle : string; FLF : TLogFont; FFontType : TFontType; FTM : TNewTextMetric; public property FullName : string read FFullName ; property ShortName : string read FShortName; property Style : string read FStyle ; property FontType : TFontType read FFontType ; property TM : TNewTextMetric read FTM ; property LF : TLogFont read FLF ; end; (*----------------------------------------------------------------------------------*) TFontList = class private procedure ClearList; procedure AddFont(EnumLogFont: TEnumLogFont; TextMetric: TNewTextMetric; FontType: Integer); public List : TStringList; constructor Create; destructor Destroy; override; procedure RefreshFontInfo; end; { TFontList } (*----------------------------------------------------------------------------------*) constructor TFontList.Create; begin inherited Create; List := TStringList.Create; List.Sorted := True; end; (*----------------------------------------------------------------------------------*) destructor TFontList.Destroy; begin ClearList; inherited Destroy; end; (*----------------------------------------------------------------------------------*) procedure TFontList.ClearList; begin while List.Count > 0 do
function EnumFontsProc(var EnumLogFont: TEnumLogFont; var TextMetric: TNewTextMetric; FontType: Integer; Data: LPARAM): Integer; stdcall;
FontList : TFontList;
FontList := TFontList(Data);
FontList.AddFont(EnumLogFont, TextMetric, FontType);
Result := 1;
procedure TFontList.AddFont(EnumLogFont: TEnumLogFont; TextMetric: TNewTextMetric; FontType: Integer);
FI : TFontInfo;
FI := TFontInfo.Create;

FI.FShortName := StrPas(EnumLogFont.elfLogFont.lfFaceName);
FI.FFullName := StrPas(EnumLogFont.elfFullName);
FI.FStyle := StrPas(EnumLogFont.elfStyle);
FI.FLF := EnumLogFont.elfLogFont;

case FontType of
RASTER_FONTTYPE : FI.FFontType := ftRaster;
DEVICE_FONTTYPE : FI.FFontType := ftDevice;
TRUETYPE_FONTTYPE : FI.FFontType := ftTrueType;

FI.FTM := TextMetric;

List.AddObject(FI.FShortName, FI);
procedure TFontList.RefreshFontInfo;
DC := GetDC(0);
EnumFontFamilies(DC, nil, @EnumFontsProc, Longint(Self));
ReleaseDC(0, DC);

And here is an example use:

procedure TForm1.Button1Click(Sender: TObject);
FontList : TFontList;
FontList := TFontList.Create;

36 Responses so far.

  1. Anonymous says:

    Howdy would you mind letting me know which web host you're using? I've loaded your blog in 3 different browsers
    and I must say this blog loads a lot quicker then most. Can you recommend a good web hosting provider at a reasonable price?
    Thanks, I appreciate it!
    My web site: easy diets that work

  2. Anonymous says:

    Yesterday, while I was at work, my cousin stole my apple ipad and tested to see if it can survive a 40 foot
    drop, just so she can be a youtube sensation. My apple ipad
    is now destroyed and she has 83 views. I know this is completely off topic but I had to share it with someone!

    My web-site :: best registry cleaner

  3. Anonymous says:

    I quite like reading a post that can make people think.
    Also, thank you for allowing me to comment!

    my webpage; Minecraft Lets Play

  4. Anonymous says:

    I like the helpful information you provide in your articles.
    I'll bookmark your weblog and check again here regularly. I am quite certain I'll learn plenty
    of new stuff right here! Good luck for the next!

    Also visit my webpage :: walking calculator

  5. Anonymous says:

    I have been surfing on-line more than 3 hours as of late,
    but I never found any attention-grabbing article like yours.
    It is lovely worth sufficient for me. In my view, if all website owners
    and bloggers made good content as you probably did, the web will probably be a lot more useful than ever before.

    my web-site :: Action RPG

  6. Anonymous says:

    IIka it must have figured you lured me

    My webpage -

  7. Anonymous says:

    To begin with, allow me to state that your page is actually
    very good. I love the theme that you have got. It had been extremely effortless on the eye.

    Appreciate your own write-up furthermore.
    Just subscribed to your very own feed to assure
    we won't become devoid out on any kind of the most recent. Excellent job! Cheers to a successful enterprise

    my blog; bad acne pictures

  8. Anonymous says:

    This is my first time visit at here and i am genuinely pleassant to read all at single place.

    Here is my webpage; rosacea relief serum

  9. Anonymous says:

    hello!,I like your authorship very so a great deal!
    proportion we be in contact more approximately your very own
    post on AOL? we require a specialist on this area to solve my issue.
    Possibly that's you! Having a look forward to observe you.

    Feel free to surf to my blog :: google adwords

  10. Anonymous says:

    Attractive section of content. I just stumbled upon your site
    and in accession capital to claim that I acquire in fact loved account your blog posts.
    Anyway I'll be subscribing to your augment and even I achievement you get admission to consistently quickly.

    Take a look at my page ... cellulite treatment reviews

  11. Anonymous says:

    Woah! I'm really digging the template/theme of this blog. It's simple, yet
    effective. A lot of times it's very hard to get that "perfect balance" between superb usability and visual appearance. I must say you've
    done a very good job with this. Also, the blog loads extremely quick for me on Safari.

    Superb Blog!

    Stop by my weblog: Bukkit Setup

  12. Anonymous says:

    Keep on working, great job!

    Feel free to surf to my web page - Minecraft Part 1

  13. Anonymous says:

    Good post. I learn something new and challenging on blogs I stumbleupon on a
    daily basis. It's always helpful to read through articles from other writers and use something from other web sites.

    My blog post :: Bukkit Setup

  14. Anonymous says:

    Simply wanna admit that this is extremely convenient,
    Many thanks for taking your time for you write this.

    Here is my weblog ... internet marketing affiliate article online business make money

  15. Anonymous says:

    Advantageously, the article is definitely in fact
    the best topic on curing acne naturally.
    we concur with your conclusions and will excitedly look
    forward to the long-term updates. Simply suggesting thanks a lot will not simply be enough,
    for the great understanding in your very own authorship.

    I will immediately grab your rss supply to stay abreast of any

    my website ... lucioferrelllfa

  16. Anonymous says:

    you're really a good webmaster. The web site loading speed is amazing. It sort of feels that you are doing any unique trick. Furthermore, The contents are masterpiece. you have performed a fantastic activity on this topic!

    my web site :: dermefface fx7 - -

  17. Anonymous says:

    Howdy! I know this is kinda off topic but I was wondering if you knew where I could locate a captcha plugin for my comment form?
    I'm using the same blog platform as yours and I'm having difficulty finding one?

    Thanks a lot!

    Here is my web blog internet marketing ()

  18. Anonymous says:

    Fabulous, what a web site it is! This web site
    presents helpful data to us, keep it up.

    Feel free to visit my site: fruit loops beat

  19. Anonymous says:

    I blog quite often and I really thank you for your information.
    This great article has really peaked my interest. I am going to book
    mark your site and keep checking for new details about once per
    week. I opted in for your Feed too.

    Also visit my web-site :: tips To lose weight in 1 week

  20. Anonymous says:

    I am regular reader, how are you everybody? This article posted at this
    web site is genuinely nice.

    My blog post ... alteril 60 count

  21. Anonymous says:

    Hi there! This post could not be written any better!

    Reading through this post reminds me of my previous room mate!
    He always kept talking about this. I will forward this post to him.
    Pretty sure he will have a good read. Many thanks for

    My weblog: telecharger subway surfers

  22. Anonymous says:

    Hmm is anyone else experiencing problems with
    the images on this blog loading? I'm trying to find out if its
    a problem on my end or if it's the blog.
    Any responses would be greatly appreciated.

    Here is my web blog; ganhar dinheiro

  23. Anonymous says:

    Pretty section of content. I just stumbled upon your website and in accession capital
    to assert that I get actually enjoyed account your blog posts.
    Any way I will be subscribing to your augment and even I achievement you access consistently rapidly.

    Feel free to surf to my blog ... adult sex toys, adult toys, xxx toys, adult online store

  24. Anonymous says:

    Yes! Finally something about american dream.

    Also visit my blog: After effects Animation Logo

  25. Anonymous says:

    Great article! That is the type of information that are supposed to be shared around the
    web. Shame on the seek engines for no longer positioning this
    submit higher! Come on over and seek advice from my web site .
    Thanks =)

    Also visit my site sua dumex

  26. Anonymous says:

    This is really interesting, You're a very skilled blogger.
    I have joined your feed and look forward to seeking more of your
    fantastic post. Also, I've shared your site in my social networks!

    Here is my web site :: have a healthy lifestyle with daily vitamins

  27. Anonymous says:

    What a data of un-ambiguity and preserveness of precious familiarity regarding unexpected emotions.

    My site: throne rush hack toolthrone rush cheats (

  28. Anonymous says:

    I all the time used to read piece of writing in news papers
    but now as I am a user of net thus from now I am using net for articles or reviews, thanks to web.

    Here is my blog - minecraft games

  29. Anonymous says:

    Provided that you simply will communicate via the web with customers from various corners with the world, and also with clientele from diverse backgrounds,
    and diverse numbers of education, a significant volume of basic culture can help you stay just one step facing another ladyboy chat
    model. They include the biggest webcam company about the internet today
    and also have countless thousands of viewers online watching the cam-models
    at any one time. It can affect your job as well as dollars earning potential.

    Feel free to visit my web site - webcam models reviews, ,

  30. Anonymous says:

    It's impressive that you are getting ideas from this
    paragraph as well as from our discussion made at this place.

    Have a look at my blog; feliz aniversario amiga

  31. Anonymous says:

    I all the time emailed this website post page to all my contacts, since if like to read it then my contacts
    will too.

    Here is my web site; free games

Post a Comment

Thank you for your comment.

Any request and idea are welcome.