News
Photos
Articles
Components
Applications
Kleinkunst

FontComboBox and FontManager

Version 1.1
April 2007
C#
.NET 2.0
open source

This library contains 3 .NET 2.0 components for managing and displaying fonts.

  • FontComboBox : This component is derived from the standard ComboBox and it displays a list of all installed Windows fonts and optionally the most recently used fonts and the predefined fonts of a theme. There are a lot of options to indicate which fonts have to be displayed and the preview text can be set (e.g. a pangram like "The quick brown fox jumps over the lazy dog")

  • FontManager : This component contains a list (list of generic FontItems) with all available Windows fonts. A FontItem has some extra info like the PanoseFontFamilyType (via Win32 GDI32 function GetOutlineTextMetrics). Also theme and recently used fonts are stored in this component.

  • FontItemDrawEngine : Parent class for drawing the items of the FontComboBox. 2 derived components SimpleFontItem DrawEngine (simple listbox) and ModernFontItem DrawEngine (modern look with XP/Vista thema support (VisualStyleElement)) are included but you can create your own. The FontItemDrawEngine component has tobe linked to a FontComboBox.

All sources and a fully implemented demo application are provided.

 

Class diagram:

 

All components are provided with the necessary design-time features (attributes like ToolBoxBitmap, Category, Description and Localizable, derived ExpandableObjectConverter class with Reflection, ...) Of course you can set all properties and methods in code.

C# example:

private void InitializeFontComboManager()
{
  fontComboBox1.FontItemDrawEngine = new ScipBe.Controls.ModernFontItemDrawEngine();
  (fontComboBox1.FontItemDrawEngine as ScipBe.Controls.ModernFontItemDrawEngine)
    .PangramText = "The quick brown fox jumps over the lazy dog";
  fontComboBox1.OptionsView.ShowInstalledFonts = true;
  fontComboBox1.OptionsView.ShowRecentlyUsedFonts = true;
  fontComboBox1.OptionsView.ShowSymbolFonts = true;
  fontComboBox1.OptionsBehavior.AddSelectedFontToRecentlyUsed = true;
    
  fontManager1.RecentlyUsedFontsTitle = "Recently used fonts";
  fontManager1.ThemeFontsTitle = "Theme fonts";
  fontManager1.InstalledFontsTitle = 'Installed Windows fonts";
    
  fontManager1.RecentlyUsedFontItems.Add("Arial");
  fontManager1.ThemeFontItems.Add("Calibri", "body");
}

private void buttonShowFont_Click(object sender, EventArgs e)
{
  if (fontComboBox1.SelectedItem != null)
    MessageBox.Show(fontComboBox1.SelectedItem.ToString() 
      + ' ' + (fontComboBox1.SelectedItem as ScipBe.Controls.FontItem)
      .TextMetrics.PanoseFamilyType.ToString());
}

Copyrights and distribution

  • These components are open source (Mozilla Public License 1.1) and may be freely distributed.
  • The author doesn't give a warranty for error free running of these components and he doesn't give any support.
  • See source code for history and more information about the classes, interfaces, properties, methods, events, ...

Download

FontComboBox and FontManager components
  • Contents: Components and demo program with sources (C#, .NET 2.0, Visual Studio 2005)
  • Version: 1.1 (2007-07-04)
  • File size: 127.03 Kb
  • Author: Stefan Cruysberghs
Download now