We help IT Professionals succeed at work.

How to find available sizes of a given font?

czechmate asked
Hi, I want to display font sizes (in a combo) that are
available to a particular font.  I looked in Borland
RichEdit demo, they use this function to enumerate fonts:

function EnumFontsProc(var LogFont: TLogFont; var TextMetric: TTextMetric;
  FontType: Integer; Data: Pointer): Integer; stdcall;
  Result := 1;

To increase or decrease a font size they use UpDown
linked to Edit and assign new size to


CurrText, in turn, is implemented like this:

function TMainForm.CurrText: TTextAttributes;
  if Editor.SelLength > 0 then
     Result := Editor.SelAttributes
     Result := Editor.DefAttributes;

UpDown value changes in steps of 1 and that does not
work very well.  Certain sizes produce no visible change,
simply (I think) because a particular font size is not

So when user selects different font how can I get the
available sizes?  I am using Delphi 5.


Watch Question

Why dont use the FontDialog.

Drop a FontDialog, palette Dialogs in a Form

and a Button with this code on the OnClick event:

Maybe with this it is enough

Most applications don't enumarate the fonts, but instead put some numbers themselves. Now when you click you change the font size to whatever in the combo box. You can notice that effect in WordPad, and even Microsoft Word.

So simply put the font sizes that you'd like to see, as well as a font dialog so they can manipulate the font further more.

Usually the size start at about 8 and end at about 72 or so. Those are not enumarated but are simply added during construction of the apps.
I meant to say don't enumerate the font sizes, they DO enumarate the fonts.
Mohammed NasmanSoftware Developer

  the true type fonts can be resize to any size even more than 300 or 400, but with windows there some fonts not true type and with limit size like "MS Sans Serif" this font has a limit size from 8 to 24, and if you resize it to more than that, they font will not show well, so if you want fonts to be resized, choose true type like arial or times new roman
if you want to list all availbe fonts in ur system, use screen.fonts as :

  ListBox1.Items := Screen.Fonts;

to check if the font is true type or not, see this link, it's for simonet one of the experts in delphi area
Go to http://www.lmc-mediaagentur.de/dpool.htm. Select SEARCH and type font .

At 34th position you can see next tip :
How to enum font sizes like TFontDialog does.  

I don't put here the tip , I wish to respect the author .        

I put again the URL because the '.' return a rong address .


Sorry... me agin .
Go to SEARCH ... choice TIPS ONLY ... type 'font' in search combo . Then select 34th result .


Thanks guys for the words of wisdom:)  Looks like
Viktornet and Mnasman are right in saying the sizes are
determined by the app, however that seems to apply to TT
fonts only.  For raster fonts, the algo Ginsonic pointed
me to actually does the job.  So I am having hard time
deciding who gets the points:))

Any ideas?


And the points go to ginsonic.  Thanks for the tip,

Explore More ContentExplore courses, solutions, and other research materials related to this topic.