public FontDescription(string fontName, float size, float spacing, FontDescriptionStyle fontStyle) { this.FontName = fontName; this.Size = size; this.Style = fontStyle; this.Spacing = spacing; }
public FontDescription(string fontName, float size, float spacing, FontDescriptionStyle fontStyle, bool useKerning) { this.FontName = fontName; this.Size = size; this.Style = fontStyle; this.Spacing = spacing; this.UseKerning = useKerning; }
/// <summary> /// Initializes a new instance of FontDescription using the specified values. /// </summary> /// <param name="fontName">The name of the font, such as Times New Roman.</param> /// <param name="size">The size, in points, of the font.</param> /// <param name="spacing">The amount of space, in pixels, to insert between letters in a string.</param> /// <param name="fontStyle">The font style for the font.</param> /// <param name="useKerning">true if kerning information is used when drawing characters; false otherwise.</param> public FontDescription(string fontName, float size, float spacing, FontDescriptionStyle fontStyle, bool useKerning) { // Write to the properties so the validation is run FontName = fontName; Size = size; Spacing = spacing; Style = fontStyle; UseKerning = useKerning; characterRegions = new List <CharacterRegion> () { CharacterRegion.Default }; }
/// <summary> /// Initializes a new instance of FontDescription and initializes its members to the specified font, size, spacing, and style. /// </summary> /// <param name="fontName">The name of the font, such as Times New Roman.</param> /// <param name="size">The size, in points, of the font.</param> /// <param name="spacing">The amount of space, in pixels, to insert between letters in a string.</param> /// <param name="fontStyle">The font style for the font.</param> public FontDescription(string fontName, float size, float spacing, FontDescriptionStyle fontStyle) : this(fontName, size, spacing, fontStyle, true) { }
/// <summary> /// Initializes a new instance of FontDescription using the specified values. /// </summary> /// <param name="fontName">The name of the font, such as Times New Roman.</param> /// <param name="size">The size, in points, of the font.</param> /// <param name="spacing">The amount of space, in pixels, to insert between letters in a string.</param> /// <param name="fontStyle">The font style for the font.</param> /// <param name="useKerning">true if kerning information is used when drawing characters; false otherwise.</param> public FontDescription(string fontName, float size, float spacing, FontDescriptionStyle fontStyle, bool useKerning, List<CharacterRegion> charRegions) { // Write to the properties so the validation is run FontName = fontName; Size = size; Spacing = spacing; Style = fontStyle; UseKerning = useKerning; characterRegions = charRegions; }
/// <summary> /// Initializes a new instance of FontDescription and initializes its members to the specified font, size, spacing, and style. /// </summary> /// <param name="fontName">The name of the font, such as Times New Roman.</param> /// <param name="size">The size, in points, of the font.</param> /// <param name="spacing">The amount of space, in pixels, to insert between letters in a string.</param> /// <param name="fontStyle">The font style for the font.</param> public FontDescription(string fontName, float size, float spacing, FontDescriptionStyle fontStyle) : this(fontName, size, spacing, fontStyle, true) { }
/// <summary> /// Initializes a new instance of FontDescription using the specified values. /// </summary> /// <param name="fontName">The name of the font, such as Times New Roman.</param> /// <param name="size">The size, in points, of the font.</param> /// <param name="spacing">The amount of space, in pixels, to insert between letters in a string.</param> /// <param name="fontStyle">The font style for the font.</param> /// <param name="useKerning">true if kerning information is used when drawing characters; false otherwise.</param> public FontDescription(string fontName, float size, float spacing, FontDescriptionStyle fontStyle, bool useKerning) { // Write to the properties so the validation is run FontName = fontName; Size = size; Spacing = spacing; Style = fontStyle; UseKerning = useKerning; }
/// <summary> /// Called by the XNA Framework when importing a .spritefont file to be used as a game asset. This is the method called by the XNA Framework when an asset is to be imported into an object that can be recognized by the Content Pipeline. /// </summary> /// <param name="filename">Name of a game asset file.</param> /// <param name="context">Contains information for importing a game asset, such as a logger interface.</param> /// <returns>Resulting game asset.</returns> public override FontDescription Import(string filename, ContentImporterContext context) { var xmldoc = XElement.Load(filename, LoadOptions.PreserveWhitespace); xmldoc = xmldoc.Element("Asset"); var fontName = xmldoc.Element("FontName").Value; var fontSize = float.Parse(xmldoc.Element("Size").Value); var spacing = float.Parse(xmldoc.Element("Spacing").Value); var useKerning = false; var useKerningElement = xmldoc.Element("UseKerning"); if (useKerningElement != null) { useKerning = bool.Parse(useKerningElement.Value); } FontDescriptionStyle style = FontDescriptionStyle.Regular; var styleElement = xmldoc.Element("Style"); if (styleElement != null) { var styleVal = styleElement.Value; if (styleVal.Contains("Bold") && styleVal.Contains("Italic")) { style = FontDescriptionStyle.Bold | FontDescriptionStyle.Italic; } else { style = (FontDescriptionStyle)Enum.Parse(typeof(FontDescriptionStyle), styleVal, false); } } char?defaultCharacter = null; var defChar = xmldoc.Element("DefaultCharacter"); if (defChar != null) { defaultCharacter = defChar.Value[0]; } var characterRegions = new List <CharacterRegion> (); foreach (var region in xmldoc.Descendants("CharacterRegion")) { var Start = (int)region.Element("Start").Value[0]; var End = (int)region.Element("End").Value[0]; characterRegions.Add(new CharacterRegion((char)Start, (char)End)); } var characters = new CharacterCollection(); foreach (var r in characterRegions) { foreach (var c in r.Characters) { characters.Add(c); } } var fontDescription = new FontDescription(fontName, fontSize, spacing, style, useKerning); fontDescription.Characters = characters; fontDescription.DefaultCharacter = defaultCharacter; fontDescription.Identity = new ContentIdentity(filename); return(fontDescription); }