Enumerate fonts in C #

Source: Internet
Author: User

Each font in C # is represented by the fontfamily class, as follows:
fontfamily = new fontfamily ("Arial ");
Font font = new font (
fontfamily,
8,
fontstyle. regular,
graphicsunit. point);
rectanglef rectf = new rectanglef (10, 10,500,500);
solidbrush = new solidbrush (color. black);

String familyname;
String familylist = "";
Fontfamily [] fontfamilies; // defines an array of font classes for loading font information.
// Obtain all fonts installed by the system using the families attribute of the installedfontcollection class
Installedfontcollection = new installedfontcollection ();
// Get the array of fontfamily objects.
Fontfamilies = installedfontcollection. Families;
// Print the font information cyclically
Int COUNT = fontfamilies. length;
For (Int J = 0; j <count; ++ J)
{
Familyname = fontfamilies [J]. Name;
Familylist = familylist + familyname;
Familylist = familylist + ",";
}
// Draw the large string (list of all families) in a rectangle.
E. Graphics. drawstring (familylist, Font, solidbrush, rectf );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.