We help IT Professionals succeed at work.

Enumerate / List all available fonts

CodedK
CodedK asked
on
796 Views
Last Modified: 2008-01-09
Hi.

I need to enumerate / List all the fonts available in the system filtered by the script.
For example :
List all fonts with Script type : Symbol
List all fonts with Script type : Greek

Thanks in advance :)
Comment
Watch Question

Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Commented:
I have a solution for you
You will still have to adapt this solution slightly to your needs
Before I explain any further, try it out - this will list only fonts in GREEK characterset:

This solution uses a listbox called "Listbox1"
and a button called "sbut_GetFixFonts"

== STEP 1 ==
== Add the following function to your unit: ==
function EnumFontsProc(var LogFont: TLogFont; var TextMetric: TTextMetric;
  FontType: Integer; Data: Pointer): Integer; stdcall;
begin
if ((FontType and TrueType_FontType) <> 0) and
    ((LogFont.lfPitchAndFamily and VARIABLE_PITCH) = 0) then
  begin
  if Form1.ListBox1.Items.IndexOf(LogFont.lfFaceName) < 0 then
    Form1.ListBox1.Items.Add(LogFont.lfFaceName);
  end;
Result := 1;
end;

== Step 2 ==
== This is the button's event handler ==
== Note the line "LogFont.lfCharset := GREEK_CHARSET;" ==
== This procedure only lists fonts of GREEK characterset

procedure TForm1.sbut_GetFixFontsClick(Sender: TObject);
var
sDC: Integer;
LogFont: TLogFont;
begin
ListBox1.Items.Clear;
sDC := GetDC(0);
try
  ZeroMemory(@LogFont, sizeof(LogFont));
  LogFont.lfCharset := GREEK_CHARSET;
  EnumFontFamiliesEx(sDC, LogFont, @EnumFontsProc, 0, 0);
  finally
  ReleaseDC(0, sDC);
  end;
if ListBox1.Items.Count < 1 then
  ShowMessage('ERROR - No fonts of that type available');
end;
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
CodedKSenior Software Engineer
CERTIFIED EXPERT

Author

Commented:
Thank you all for your input. Sorry for not posting earlier :/
I've tested your codes but this is not working for me :(

If you open WordPad and go to Format--> Font.
Select "Courier New".
And check the script you will see that it supports : GreeK, Western, Hebrew, Arabic, Turkish, Baltic, Central European, Cyrillic, Vietnamese.
This info is probably stored somewhere in the fonts, i want to extract this info and scan if it supports Greek or whatever.

The results from the sources above do not match the real results in my system at all.

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.