public void SetText(string text, int FontSize = 10, FontStyle fontStyle = FontStyle.Regular, int LineHeight = 60, Enumerations.TextAlignmentType textAlignmentType = Enumerations.TextAlignmentType.Center) { switch (textAlignmentType) { case Enumerations.TextAlignmentType.Center: text = PrintUtility.GetCenterAlignmentText(text, TotalCharactersPerLine); break; case Enumerations.TextAlignmentType.Right: text = PrintUtility.GetRightAlignmentText(text, TotalCharactersPerLine); break; case Enumerations.TextAlignmentType.Left: default: break; } int italic = fontStyle.ToString().Contains(FontStyle.Italic.ToString()) ? 1 : 0; int underline = fontStyle.ToString().Contains(FontStyle.Underline.ToString()) ? 1 : 0; int bold = fontStyle.ToString().Contains(FontStyle.Bold.ToString()) ? 1 : 0; Commands.Add(new Command("BematechInterface.FormataTX", () => BematechInterface.FormataTX(text, 2, italic, underline, 0, bold))); BreakLine(1); }
public void SetText(string sText, Enumerations.FontSize oFontSize = Enumerations.FontSize.Medium, FontStyle oFontStyle = FontStyle.Regular, bool bFontExpanded = false, Enumerations.TextAlignmentType oTextAlignmentType = Enumerations.TextAlignmentType.Center, bool bBreakLine = true) { string sSpaces; switch (oTextAlignmentType) { case Enumerations.TextAlignmentType.Center: sSpaces = PrintUtility.GetCenterAlignmentText(sText, TotalCharactersPerLine, oFontSize); SetText(sSpaces, oFontSize, FontStyle.Regular, bFontExpanded, Enumerations.TextAlignmentType.Left, false); break; case Enumerations.TextAlignmentType.Right: sSpaces = PrintUtility.GetRightAlignmentText(sText, TotalCharactersPerLine, oFontSize); SetText(sSpaces, oFontSize, FontStyle.Regular, bFontExpanded, Enumerations.TextAlignmentType.Left, false); break; case Enumerations.TextAlignmentType.Left: default: break; } int iItalic = oFontStyle.ToString().Contains(FontStyle.Italic.ToString()) ? 1 : 0; int iUnderline = oFontStyle.ToString().Contains(FontStyle.Underline.ToString()) ? 1 : 0; int iExpanded = bFontExpanded ? 1 : 0; int iBold = oFontStyle.ToString().Contains(FontStyle.Bold.ToString()) ? 1 : 0; Commands.Add(new Command("BematechInterface.FormataTX", () => BematechInterface.FormataTX(sText, (int)oFontSize, iItalic, iUnderline, iExpanded, iBold))); if (bBreakLine) { BreakLine(1); } }
private void SaveSetting() { Configuration config = ConfigurationManager.OpenExeConfiguration(Application.ExecutablePath); AppSettingsSection appSection = config.AppSettings; //appSection.File = config.FilePath.ToLowerInvariant(); if (appSection.Settings["FontName"] != null) { appSection.Settings["FontName"].Value = iconFontName; } else { appSection.Settings.Add("FontName", iconFontName); } if (appSection.Settings["FontSize"] != null) { appSection.Settings["FontSize"].Value = iconFontSize.ToString(); } else { appSection.Settings.Add("FontSize", iconFontSize.ToString()); } if (appSection.Settings["FontStyle"] != null) { appSection.Settings["FontStyle"].Value = iconFontStyle.ToString(); } else { appSection.Settings.Add("FontStyle", iconFontStyle.ToString()); } if (appSection.Settings["TextColor"] != null) { appSection.Settings["TextColor"].Value = ColorTranslator.ToHtml(iconForeColor); } else { appSection.Settings.Add("TextColor", ColorTranslator.ToHtml(iconForeColor)); } if (appSection.Settings["BackColor"] != null) { appSection.Settings["BackColor"].Value = ColorTranslator.ToHtml(iconBackColor); } else { appSection.Settings.Add("BackColor", ColorTranslator.ToHtml(iconBackColor)); } config.Save(ConfigurationSaveMode.Full); }
public void OnClickUpdate() { CheckString = (M4uUtil.Random(0, 2) == 0) ? CheckSuccess : CheckFail; CheckEnum = (M4uUtil.Random(0, 2) == 0) ? CheckType.OK : CheckType.NG; BoolBindingText = CheckString + "/" + CheckEnum.ToString(); var time = Time.time; var src = Color; var dst = new UnityEngine.Color(M4uUtil.Random(0f, 1f), M4uUtil.Random(0f, 1f), M4uUtil.Random(0f, 1f), 1f); StartCoroutine(UpdateColor(time, src, dst)); FontStyle = (UnityEngine.FontStyle)M4uUtil.Random(0, 4); FontSize = M4uUtil.Random(30, 50); LineSpacing = M4uUtil.Random(1f, 2f); SupportRichText = (M4uUtil.Random(0, 2) == 0); Alignment = (TextAnchor)M4uUtil.Random(3, 6); ResizeTextForBestFit = (M4uUtil.Random(0, 2) == 0); Text = "[Special]\n"; Text += "FontStyle=" + FontStyle.ToString() + "\n"; Text += "LineSpacing=" + LineSpacing + "\n"; Text += "SupportRichText=" + SupportRichText + "\n"; Text += "Alignment=" + Alignment.ToString() + "\n"; Text += "ResizeTextForBestFit=" + ResizeTextForBestFit; }
/* * Converts each of the characters into the given enumerators */ HUDFont[] FromStringToEnum(string input, FontStyle style = FontStyle.SR) { if (input == null) { return(null); } char[] charArray = input.ToCharArray(); HUDFont[] returnArray = new HUDFont[charArray.Length]; for (int i = 0; i < charArray.Length; i++) { string charName = charToName(charArray[i]); HUDFont result; // if we cannot TryParse, and it fails, we add a ? in place of that value // unless that font doesn't contain a ?, in which case we're going to use a WhiteSp if (Enum.TryParse <HUDFont>(style.ToString() + charName, out result)) { returnArray[i] = result; } else { returnArray[i] = (HUDFont)Enum.Parse(typeof(HUDFont), "WhiteSp"); // in the event there's no known symbol to match, we simply use whitespace } } return(returnArray); }
public PdfPTable Render() { var baseFont = BaseFont.CreateFont(FontName, FontEncoding, Embedded); var font = new Font(baseFont, FontSize); font.SetColor(FontColor.R, FontColor.G, FontColor.B); font.SetStyle(FontStyle.ToString()); font.SetFamily(FontType.ToString()); var cell = new PdfPCell(new Phrase(Text)) { BorderWidth = 0, VerticalAlignment = 1, HorizontalAlignment = 1 }; var tbl = new PdfPTable(1); tbl.DefaultCell.Phrase = new Phrase() { Font = font }; tbl.AddCell(cell); tbl.WidthPercentage = 100; return(tbl); }
private void CreateFont (string familyName, float emSize, FontStyle style, GraphicsUnit unit, byte charSet, bool isVertical) { #if ONLY_1_1 if (familyName == null) throw new ArgumentNullException ("familyName"); #endif originalFontName = familyName; FontFamily family; // NOTE: If family name is null, empty or invalid, // MS creates Microsoft Sans Serif font. try { family = new FontFamily (familyName); } catch (Exception){ family = FontFamily.GenericSansSerif; } setProperties (family, emSize, style, unit, charSet, isVertical); Status status = GDIPlus.GdipCreateFont (family.NativeObject, emSize, style, unit, out fontObject); if (status == Status.FontStyleNotFound) throw new ArgumentException (Locale.GetText ("Style {0} isn't supported by font {1}.", style.ToString (), familyName)); GDIPlus.CheckStatus (status); }
private void CreateFont(string familyName, float emSize, FontStyle style, GraphicsUnit unit, byte charSet, bool isVertical) { _originalFontName = familyName; FontFamily family; // NOTE: If family name is null, empty or invalid, // MS creates Microsoft Sans Serif font. try { family = new FontFamily(familyName); } catch (Exception) { family = FontFamily.GenericSansSerif; } Initialize(family, emSize, style, unit, charSet, isVertical); int status = Gdip.GdipCreateFont(new HandleRef(this, family.NativeFamily), emSize, style, unit, out _nativeFont); if (status == Gdip.FontStyleNotFound) { throw new ArgumentException($"Style {style.ToString()} isn't supported by font {familyName}."); } Gdip.CheckStatus(status); }
public override string ToString() { var lines = new List <string>(); if (NumberingFormat != null && !string.IsNullOrEmpty(NumberingFormat.ToString())) { lines.Add($"\tNumberingFormat = {{{NumberingFormat}}}"); } if (FillStyle != null && !string.IsNullOrEmpty(FillStyle.ToString())) { lines.Add($"\tFillStyle = {{{FillStyle}}}"); } if (FontStyle != null && !string.IsNullOrEmpty(FontStyle.ToString())) { lines.Add($"\tFontStyle = {{{FontStyle}}}"); } if (BordersStyle != null && !string.IsNullOrEmpty(BordersStyle.ToString())) { lines.Add($"\tBordersStyle = {{{BordersStyle}}}"); } if (Alignment != null && !string.IsNullOrEmpty(Alignment.ToString())) { lines.Add($"\tAlignment = {{{Alignment}}}"); } return(string.Join("\n", lines)); }
/// <summary> /// Required implementation of IXmlSerlializable.ReadXml. /// <para> /// Serializes the ticket and encrypts values if this is an internal /// Everest authentication request; internal requests use the isStrong /// variable whereas SDK clients do not use this mechanism. /// </para> /// </summary> /// <param name="writer">The XmlWriter stream to which the object is serialized.</param> public void WriteXml(XmlWriter writer) { writer.WriteElementString("family", familyName); writer.WriteElementString("size", size.ToString()); writer.WriteElementString("style", style.ToString()); writer.WriteElementString("unit", unit.ToString()); }
protected static PDFName CreatePostScriptFontName(Typeface typeface) { string name = typeface.FontFamily.Source.Replace(" ", ""); FontStyle style = typeface.Style; FontWeight weight = typeface.Weight; if (style != FontStyles.Normal || weight != FontWeights.Normal) { string styleString = (style == FontStyles.Normal) ? "" : style.ToString(); string weightString = (weight == FontWeights.Normal) ? "" : weight.ToString(); name = $"{name}-{weightString}{styleString}"; } // Add a random prefix of uppercase letters, like "FRDVGH+", which indicates this font is a subset. char[] chars = new char[7]; Random random = new Random(); for (int i = 0; i < 6; i++) { chars[i] = (char)random.Next('A', 'Z'); } chars[6] = '+'; return(PDFName.GetEscapedName(new string(chars) + name)); }
protected virtual Font CreateFont(string fam, double size, FontStyle style, FontWeight weigth, FontStretch stretch) { return(Font.FromName(fam + " " + style.ToString() + " " + weigth.ToString() + " " + stretch.ToString() + " " + size.ToString(CultureInfo.InvariantCulture))); }
public static string GetEmbeddedFontUrl(IFontData font, FontStyle style) { if (style == FontStyle.Regular) { return(string.Format("fonts/{0}.ttf", font.FontName)); } return(string.Format("fonts/{0} {1}.ttf", font.FontName, style.ToString())); }
public static string GetDescription(string name, float size, FontStyle style, GraphicsUnit unit, string nameAndPropertiesFormat) { string properties = string.Format("{0} {1}{2}", size, unit.ToString().ToLower(), style != FontStyle.Regular ? ", " + style.ToString().ToLower() : ""); return(string.Format(nameAndPropertiesFormat, name, properties)); }
public ExpanderAttributes(SolidColorBrush background, SolidColorBrush foreground, FontWeight fontWeight, FontStyle fontStyle) { Background = background; BackgroundColor = background.Color.ToString(); Foreground = foreground; ForegroundColor = foreground.Color.ToString(); TextFontWeight = fontWeight; TextFontWeightString = fontWeight.ToString(); TextFontStyle = fontStyle; TextFontStyleString = fontStyle.ToString(); }
public static SpriteFont GetFont(string font = null, FontStyle style = FontStyle.Regular, int size = DefaultSize) { if (font == null) { if (DefaultFont == null) { throw new DefaultFontMissingException(); } return(DefaultFont); } try { return(Fonts[$"{font}-{style.ToString().ToLower()}-{size}"]); } catch { throw new FontMissingException($"{font}-{style.ToString().ToLower()}-{size}"); } }
public static string ToHtml(this FontStyle value) { if (FontStyle.Normal == value) { return(""); } if (FontStyle.Italic == value) { return("italic"); } return(value.ToString()); }
public void WriteXml(XmlWriter writer) { writer.WriteStartElement(FontElementName); writer.WriteAttributeString(StyleAttributeName, FontStyle.ToString()); writer.WriteAttributeString(VariantAttributeName, FontVariant.ToString()); writer.WriteAttributeString(WidthAttributeName, FontWidth.ToString()); writer.WriteAttributeString(StretchAttributeName, FontStretch.ToString()); foreach (var fontSource in _sources) { fontSource.WriteXml(writer); } writer.WriteEndElement(); }
public override JObject SaveToJsonObject(StiJsonSaveMode mode) { var jObject = base.SaveToJsonObject(mode); jObject.Add(new JProperty("FontName", FontName)); jObject.Add(new JProperty("FontSize", FontSize)); jObject.Add(new JProperty("FontStyle", FontStyle.ToString())); jObject.Add(new JProperty("Unit", Unit.ToString())); jObject.Add(new JProperty("GdiCharSet", GdiCharSet)); jObject.Add(new JProperty("GdiVerticalFont", GdiVerticalFont)); return(jObject); }
private static void Set(String Prefix, Font FontArg) { String FontFamilyName = FontArg.FontFamily.Name; RegistryManager.SetValue(Prefix + "FontFamilyName", (object)FontFamilyName); float Size = FontArg.SizeInPoints; RegistryManager.SetValue(Prefix + "SizeInPoints", (object)Size.ToString()); FontStyle Style = FontArg.Style; RegistryManager.SetValue(Prefix + "Style", (object)Style.ToString()); }
private void Serialize() { appData.GetTextWrappingInfo(Wrapping.IsChecked); appData.GetCheckMissPellingsInfo(editTextBox.SpellCheck.IsEnabled); appData.GetBackgroundColor(backColor.ToString()); appData.GetFontColor(fontColor.ToString()); appData.GetFontFamily(fontFamily.ToString()); appData.GetFontSize(fontSize); appData.GetFontWeight(fontWeight.ToString()); appData.GetFontStyle(fontStyle.ToString()); appData.GetWindowHeight(this.Height); appData.GetWindowWidth(this.Width); appData.Serialize(); }
public String GetFullName() { String name = family.ToString(); if (weight != FontWeights.Normal) { name += " " + weight.ToString(); } if (style != FontStyles.Normal) { name += " " + style.ToString(); } return(name); }
public static bool SaveSetting() { string settingFilePath = System.IO.Directory.GetCurrentDirectory() + "\\setting.ini"; FileIOPermission f = new FileIOPermission(FileIOPermissionAccess.Write, System.IO.Directory.GetCurrentDirectory()); try { f.Demand(); } catch (SecurityException e) { System.Windows.MessageBox.Show("文件夹权限错误,请检查UAC权限,无法保存设置。", "弹幕派", MessageBoxButton.OK, MessageBoxImage.Warning, MessageBoxResult.OK); return(false); } FileStream fs = new FileStream(settingFilePath, FileMode.Create); StreamWriter settingFileSW = new StreamWriter(fs); try { settingFileSW.WriteLine("[Basic]"); settingFileSW.WriteLine("Num = " + NUM.ToString()); settingFileSW.WriteLine("Duration = " + DURATION.ToString()); settingFileSW.WriteLine("Speed = " + SPEED.ToString()); settingFileSW.WriteLine("[Font]"); settingFileSW.WriteLine("Background = " + background.ToString()); settingFileSW.WriteLine("Foreground = " + foreground.ToString()); settingFileSW.WriteLine("FontFamily = " + fontFamily.ToString()); settingFileSW.WriteLine("FontStyle = " + fontStyle.ToString()); settingFileSW.WriteLine("FontWeight = " + fontWeight.ToString()); settingFileSW.WriteLine("FontSize = " + fontSize.ToString()); settingFileSW.WriteLine("Opactity = " + opactity.ToString()); settingFileSW.WriteLine("Random Color = " + randomColor.ToString()); settingFileSW.WriteLine("Random FontFamily = " + randomFontFamily.ToString()); settingFileSW.Close(); fs.Close(); return(true); } catch (IOException e) { System.Windows.MessageBox.Show("写入配置文件时错误。", "云弹幕", MessageBoxButton.OK, MessageBoxImage.Warning, MessageBoxResult.OK); } if (settingFileSW != null) { settingFileSW.Close(); } if (fs != null) { fs.Close(); } return(false); }
public void setDefaultFontStyleValue(FontStyle fontStyleReset) { foreach (string item in stateOfFontStyle.Keys.ToArray()) { string[] strArr = item.Split('_'); if (fontStyleReset.ToString().Contains(strArr[strArr.Length - 1])) { stateOfFontStyle[item] = true; } else { stateOfFontStyle[item] = false; } } }
public override int GetHashCode() { StringBuilder builder = new StringBuilder(); if (FontFamily != null) { builder.Append(FontFamily.ToString()); } builder.Append(FontStyle.ToString()); builder.Append(FontStretch.ToString()); builder.Append(((ushort)FontWeight.Weight).ToString()); builder.Append(WordWrap.ToString()); builder.Append(MaximumSize.ToString()); return(builder.ToString().GetHashCode()); }
public void WriteXml(XmlWriter writer) { XmlSerializer ColorSerializer = new XmlSerializer(typeof(Color)); writer.WriteAttributeString("FontWeight", FontWeight.ToOpenTypeWeight().ToString()); writer.WriteAttributeString("FontStyle", FontStyle.ToString()); writer.WriteStartElement("BackgroundColor"); ColorSerializer.Serialize(writer, BackgroundColor); writer.WriteEndElement(); writer.WriteStartElement("ForeColor"); ColorSerializer.Serialize(writer, ForeColor); writer.WriteEndElement(); }
Alt.GUI.Temporary.Gwen.Control.MenuItem AddFontStyle(FontFamily family, FontStyle style) { if (!family.IsStyleAvailable(style)) { return(null); } Alt.GUI.Temporary.Gwen.Control.MenuItem item = m_FontStyle.AddItem(style.ToString()); item.Tag = style; m_FontStyle.SelectedItem = item; m_FontStyleMenus.Add(style, item); return(item); }
public FontForm(FontFamily family, float size, FontStyle style) { InitializeComponent(); AcceptButton = btn_OK; CancelButton = btn_Cancel; FontFamily[] fontArr = FontFamily.Families; foreach (FontFamily font in fontArr) { listBox_Font.Items.Add(font.Name); } listBox_Font.SelectedItem = family.Name; listBox_Style.SelectedItem = style.ToString(); listBox_Size.SelectedItem = size.ToString(); }
public static bool DoesFontExist(Session session, string fontFamilyName, FontStyle fontStyle) { bool result; try { using (FontFamily family = new FontFamily(fontFamilyName)) result = family.IsStyleAvailable(fontStyle); } catch (ArgumentException) { result = false; } session.Log("Return Value for " + fontFamilyName + " : " + fontStyle.ToString() + " is " + result); return(result); }
void Save() { EditorPrefs.SetInt("StoredDefault_SpaceBefore", defaultSpaceBefore); EditorPrefs.SetInt("StoredDefault_Height", defaultHeight); EditorPrefs.SetInt("StoredDefault_SpaceAfter", defaultSpaceAfter); EditorPrefs.SetInt("StoredDefault_Width", defaultWidth); EditorPrefs.SetInt("StoredDefault_InnerWidth", defaultInnerWidth); /// EditorPrefs.SetString("StoredDefault_Anchor", defaultAnchor.ToString()); EditorPrefs.SetString("StoredDefault_Style", defaultStyle.ToString()); EditorPrefs.SetInt("StoredDefault_Size", defaultSize); EditorPrefs.SetBool("StoredDefault_Box", boxEnabled); EditorPrefs.SetString("StoredDefault_FontColor", defaultColor.ToString()); EditorPrefs.SetString("StoredDefault_BoxColor", defaultBoxColor.ToString()); }
/// <summary> /// Load font style /// Author : Jerry Xu /// Date : 2008-8-19 /// </summary> private void LoadFontStyle(FontStyle style) { //Clear items lstFontStyle.Items.Clear(); //Init items lstFontStyle.Items.AddRange(FontStyleArray); //Set seleted item if (style.ToString() != string.Empty) { for (int i = 0; i < FontStyleArray.Length; i++) { if (FontStyleArray[i].Style == style) { lstFontStyle.SelectedIndex = i; } } } }
private PdfFontStyle GetPdfFontStyle(FontStyle style) { return (PdfFontStyle)Enum.Parse(typeof(PdfFontStyle), style.ToString(), false); }
private Size MeasureTextNoTrim(string text, int size, FontStyle style) { var closest = GetClosestFontSize(size); var scale = size / (float) closest; var measure = GetFont(Path.Combine(style.ToString(), closest.ToString())).MeasureString(text); return new Size((int) (Math.Round(measure.X * scale)), (int) (Math.Round(measure.Y * scale))); }
public override void DrawString(string text, Point point, Brush brush, int size, FontStyle style, Rectangle bounds, bool ignoreFormatting = false) { SetClipArea(bounds); var pos = new Vector2((int) Math.Round(point.X), (int) Math.Round(point.Y)); var closest = GetClosestFontSize(size); var colorBrush = brush as ColorBrush; var gradientBrush = brush as GradientBrush; var defaultColor = Color.Black; if (colorBrush != null) defaultColor = colorBrush.Color; if (gradientBrush != null) { UseMaskStencil(bounds); } if (!ignoreFormatting) // If formatting is enabled, parse it and render each part. { var parts = ParseFormattedText(text, defaultColor, style); foreach (var part in parts) { var font = GetFont(Path.Combine(part.Style.ToString(), closest.ToString())); var measure = MeasureTextNoTrim(part.Text, size, part.Style); var col = new ColorXNA(part.Color.R, part.Color.G, part.Color.B, defaultColor.A); manager.SpriteBatch.DrawString(font, part.Text, pos, col * (defaultColor.A / 255f), 0, Vector2.Zero, size / (float) closest, SpriteEffects.None, 0); pos = new Vector2(pos.X + (float) measure.Width, pos.Y); } } else // Draw plain string { var font = GetFont(Path.Combine(style.ToString(), closest.ToString())); var col = new ColorXNA(defaultColor.R, defaultColor.G, defaultColor.B, defaultColor.A); manager.SpriteBatch.DrawString(font, text, pos, col * (defaultColor.A / 255f), 0, Vector2.Zero, size / (float) closest, SpriteEffects.None, 0); } // If using a gradient brush, draw a gradient over the mask. if (gradientBrush != null) { UseRenderStencil(); DrawGradient(bounds, gradientBrush); EndStencil(); } ResetClipArea(); }
public static string GetDescription(string name, float size, FontStyle style, GraphicsUnit unit, string nameAndPropertiesFormat) { string properties = string.Format("{0} {1}{2}", size, unit.ToString().ToLower(), style != FontStyle.Regular ? ", " + style.ToString().ToLower() : ""); return string.Format(nameAndPropertiesFormat, name, properties); }
protected string GetFontStyleEnum(FontStyle fontStyle) { return fontStyle.ToString(); }
private static void WriteFontStyleProperty(System.Xml.XmlWriter writer, FontStyle font) { writer.WriteString(font.ToString()); }
private static string createHashString(string fontFamilyName, float pointSize, FontStyle style) { return (fontFamilyName + pointSize.ToString() + style.ToString()); }