Getting Font and Color Information for Text Colorization

The process that renders or displays colorized text in user interface (UI) elements depends on the type of project, its technology, and developer preferences. The Fonts and Colors property page stores the settings.

Most implementations that display colorized text need the T:Microsoft.VisualStudio.Shell.Interop.IVsFontAndColorDefaults and associated interfaces for presenting, retrieving, and storing text display settings.

Note

When customizing the core editor (which supports the Text EditorCategory), it is strongly recommended that you use the coloring technology in the language service. For more information, see Font and Color Overview.

Getting Default Font and Color Information

All the Fonts and Colors settings of any window displaying text should be specified in the Display Items of one Category. For more information, see Fonts and Colors, Environment, Options Dialog Box.

To colorize, a VSPackage must obtain current Fonts and Colors settings. A VSPackage can accomplish this in the following ways, depending on its needs:

To ensure that the results obtained by polling are up-to date, it may be useful to use the IVsFontAndColorCacheManager interface to determine if an update is needed prior to calling the retrieval methods of the IVsFontAndColorStorage interface.

After you have obtained font and color information, parse the text to be displayed to identify elements requiring colorization and then display the text in the window using the appropriate fonts and colors.

See Also

Reference

IVsFontAndColorDefaultsProvider

IVsFontAndColorDefaults

Working with Color (Image Editor for Icons)

Other Resources

Using Fonts and Text

GDI (graphics device interface)