Interpretation of constructor Font (String name, int style, int size) in Java __java language

Source: Internet
Author: User
Tags bitmask
Font (String name,int style,int size)
Creates a new Font based on the specified name, style, and point size.

The font name can be a font appearance name or a font family name. It is used with styles to find the right font appearance. If a font family name is specified, the style parameter is used to select the most appropriate appearance from the series. If you specify a font appearance name, merge the style and style parameters of the appearance to find the most matching font from the same series. For example, if you specify the skin name "Arial Bold" and the style font.italic, the font system looks in the Arial series for both bold and italic, and you can associate the font instance with the physical font appearance, "Arial Bold Italic." Merges a style parameter with the style of the specified skin, rather than performing an add or subtract operation. This means that specifying bold and bold styles does not double the bold font, and specifying bold and normal styles does not change the font.

If you cannot find the appearance of the required style, the font system can apply a style design algorithm to get the style you want. For example, if Italic is required, but there is no italic appearance available, you can skew the normal look by using an algorithm.

Font name lookup is case-sensitive, and you can use the capitalization conversion rules for the US locale. Parameters:

Name-font names. This can be the font skin name or font family name, and can represent the logical or physical font found in this graphicsenvironment. The series names for logical fonts are: Dialog, Dialoginput, monospaced, Serif, or Sansserif. If name is null, the logical font name for the new font (returned by GetName () is set to "Default").

The Style-font style constant. A style parameter is an integer bitmask that can be PLAIN, or a bitwise of BOLD and Italic, or (for example, italic or bold| Italic). If the style parameter does not conform to any one of the expected integer bitmask, the style is set to PLAIN.

Size-font point size//Get all fonts in the system

string[] FontNames = Graphicsenvironment.getlocalgraphicsenvironment (). Getavailablefontfamilynames ();
for (int i=0;i<fontnames.length;i++)
System.out.print (fontnames[i]+ "");






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.