/// <summary> /// Looks for font information in the specified string and returns a new /// font based on this information, otherwise it returns the default font. /// </summary> /// <remarks> /// A text font is typically indicated by having a marker at the beginning of the /// text string which is of the form {\VerdanaBold10}. Sometimes the backslash is /// replaced with the ampersand xml marker. These markers map to TextStyle elements /// in the Wix document that give you the actual font information. /// </remarks> Font GetFont(string text, Font defaultFont) { // Property references a text style? string textStyleName = String.Empty; Match propertyMatch = Regex.Match(text, @"^\[(.*?)\]"); if (propertyMatch.Success) { string propertyName = propertyMatch.Groups[1].Value; string propertyValue = document.GetProperty(propertyName); if (propertyValue.Length > 0) { textStyleName = ParseTextStyleName(propertyValue); } } // Font defined by text style? if (textStyleName.Length == 0) { textStyleName = ParseTextStyleName(text); } // Default UI font style set? if (textStyleName.Length == 0) { textStyleName = GetDefaultUIFontStyle(); } // Look for text style. if (textStyleName.Length > 0) { return(GetTextStyleFont(textStyleName, defaultFont)); } return(defaultFont); }