ArticleDirectory
I wrote how to change the font style, and then I wrote about how to change the font size? When you observe the font category, you will find that the public attributes it provides are read-only. this means to change the font size. You need to create a new object with the same attributes as the previous one except the font size. here is a convenient method: Static Public Font changefontsize (Font font, Float Fontsize)
{
If (Font ! = Null )
{
Float Currentsize = Font. size;
If (Currentsize ! = Fontsize)
{
Font= NewFont (font. Name, fontsize,
Font. style, Font. Unit,
Font. gdicharset, Font. gdiverticalfont );
}
}
Return Font;
}
For example, to enlarge the font of a tag by two times: Label. Font=Changefontsize (Label. Font, label. Font. Size* 2);Graphics Unit
Note that the above methods use the same graphic unit (points, pixels, millimeters, and so on). For a font, you may want"Heavy Load"This method uses a specific unit:
Static Public Font changefontsize (Font font, Float Fontsize, graphicsunit Unit)
{
If (Font ! = Null )
{
Float Currentsize = Font. size;
If (Currentsize ! = Fontsize)
{
Font= NewFont (font. Name, fontsize,
Font. style, unit,
Font. gdicharset, Font. gdiverticalfont );
}
}
Return Font;
}
For example, set the font of a label to 12 pixels: Label. Font=Changefontsize (Label. Font,12.0f, Graphicsunit. pixel );