Hi everybody
I wanna know there is way to separate fonts by type
for example : i wanna load all arabic fonts to a combobox only

Thank you

Recommended Answers

All 2 Replies

You could enumerate the fonts you want using the EnumFontFamiliesEx API call. Specify ARABIC_CHARSET as the character set in the LogFont you supply to the routine, and have your callback routine add the font names to your combo box.

I don't have any VB code to do that but maybe this Delphi code will get you started. It should be easy enough to convert to VB.

function FontEnumerator(
  const EnumLogFontEx: TEnumLogFontEx;
  const NewTextMetricEx: PNewTextMetricEx;
        FontType: Integer;
        Strings: TStrings): Integer; stdcall;
const
  CONTINUE_ENUMERATION = 1; // Any non-zero value will do
begin
  Strings.Add(EnumLogFontEx.elfFullName);
  Result := CONTINUE_ENUMERATION;
end;

procedure GetArabicFonts(FontNames : TStrings);
var
  DC : THandle;
  LogFont : TLogFont;
begin
  DC := GetDC(GetDesktopWindow);  // We will list the fonts available in desktop window's device context
  if DC <> 0 then
  try

    FillChar(LogFont, SizeOf(LogFont), 0); // Initialise spec of fonts we want to include all fints
    LogFont.lfCharSet := ARABIC_CHARSET;   // Then narrow it down to just Arabic fonts

    EnumFontFamiliesEx(DC, LogFont, @FontEnumerator, lParam(FontNames), 0); // List the fonts

  finally
    ReleaseDC(GetDesktopWindow, DC)
  end
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  GetArabicFonts(ComboBox1.Items);
end;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.