开发者

Unusual Font Conversion

I have the following string in a file, and it needs to be converted back to a Font object. But I'm not sure how to do this one:

font string开发者_如何学C:

[Font: Name=Segoe UI, Size=14, Units=3, GdiCharSet=1, GdiVerticalFont=False]

I appreciate any help at all, thank you

bael


Check out my FontBuilder class in the CC.Utilities library. It does exactly what you want and provides an extension method ToStringEx() to cover the FontStyle property that Font.ToString() is missing.

I originally wrote it so I could store a Font in the registry

Edit: Here are the specific files it you're not interested in the whole thing:

FontBuilder: http://ccutilities.codeplex.com/SourceControl/changeset/view/40596#648008 FontExtensions: http://ccutilities.codeplex.com/SourceControl/changeset/view/40596#664902


There are various Font constructors, this one appears to fit the bill:

Font Constructor (String, Single, FontStyle, GraphicsUnit, Byte, Boolean)

Initializes a new Font using the specified size, style, unit, and character set.

Parameters

familyName
Type: System.String
A string representation of the FontFamily for the new Font.

emSize
Type: System.Single
The em-size of the new font in the units specified by the unit parameter.

style
Type: System.Drawing.FontStyle
The FontStyle of the new font.

unit
Type: System.Drawing.GraphicsUnit
The GraphicsUnit of the new font.

gdiCharSet
Type: System.Byte
A Byte that specifies a GDI character set to use for this font.

gdiVerticalFont
Type: System.Boolean
A Boolean value indicating whether the new Font is derived from a GDI vertical font.

Unless I've misread your string of course.

You would need to parse the string to pass the appropriate values to the constructor.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜