public void Set(ref FontOptions options) { Hinting = options.Hinting; AntiAliasing = (options.Flags & FontFlags.AntiAliasing) == FontFlags.AntiAliasing; Bold = (options.Flags & FontFlags.Bold) == FontFlags.Bold; Italic = (options.Flags & FontFlags.Italic) == FontFlags.Italic; }
public Font(string fontFamily, FontOptions options, int size) { FontFamily = fontFamily; FontFilename = ""; Options = options; Size = size; }
public void OptionNames() { var s = new FontOptions(); var names = s.GetOptionNames(); Assert.AreEqual(propertyNames.Count, names.Count); }
public void Resolve_Font() { if (0 == (StyleFlags & EPropertySystemDirtFlags.NeedsToResolveFont)) { return; } if (!(FontSize == oldFontSize)) { oldFontSize = FontSize; Notify_Unit_Scale_Change(ECssUnit.EM); Notify_Unit_Scale_Change(ECssUnit.EX); Notify_Unit_Scale_Change(ECssUnit.CH); } #if DISABLE_FONT_SYSTEM #else // Get font from font factory, which will help cache identical fonts FontOptions fontOptions = new FontOptions(FontFamily, FontSize, FontWeight, FontStyle); Font = FontFactory.Get(fontOptions); // XXX: Find the new equivalent of the below code once the new rendering system is finished // Flag our elements font dirty flag so it updates whatever is using it //this.Flag(EElementDirtyFlags.Font); #endif // Remove font dirt flag ClearFlag(EPropertySystemDirtFlags.NeedsToResolveFont); }
public Font(string fontFamily, string fontFilename, string windowsFontFamily, FontOptions options, int size) { FontFamily = fontFamily; FontFilename = fontFilename; WindowsFontFamily = windowsFontFamily; Options = options; Size = size; }
private void SetFontOptions(FontOptions value) { lblBackgroundColorSelector.BackColor = value.BackgroundColor.ToWinFormsColor(); lblTextColorSelector.BackColor = value.TextColor.ToWinFormsColor(); cbxFontWeight.SelectedItem = value.Weight; cbxFontStyle.SelectedItem = value.Style; chkUnderline.Checked = value.Underline; }
private static void OnFontOptionsChanged(DependencyObject dependencyObject, FontOptions oldFontOptions, FontOptions newFontOptions) { var textBlock = (TextBlock)dependencyObject; textBlock.ClearValue <IDisposable>(FontOptionsDisposerProperty, i => i.DisposeExchange()); if (newFontOptions != null) { textBlock.SetValue <IDisposable>(FontOptionsDisposerProperty, newFontOptions.Attach(textBlock)); } }
public static HighlightingColor ToHighlightingColor(this FontOptions options) { return(new HighlightingColor { Foreground = new SimpleHighlightingBrush(options.TextColor), Background = new SimpleHighlightingBrush(options.BackgroundColor), FontWeight = options.Weight, FontStyle = options.Style, Underline = options.Underline, }); }
public void Reset() { lock (_lock) { _parser = null; _font = null; _imaging = null; _output = null; _tracelog = null; } }
public TwoLineTextBlockControl() { _fontOptions = new FontOptions(); _fontObserverDisposer = _fontOptions.Observe(this); _fontOptions.PropertyChanged += FontOptionsOnPropertyChanged; _textMeasure = TextMeasureHelper.GetTextMeasure(new FontOptionsStruct(_fontOptions)); _panel = new TwoLineTextBlockPanel(CreateTextBlock(), CreateTextBlock()); ChildInternal = _panel; }
static Interface() { loadCursors(); loadStyling(); findAvailableTemplates(); FontRenderingOptions = new FontOptions(); FontRenderingOptions.Antialias = Antialias.Subpixel; FontRenderingOptions.HintMetrics = HintMetrics.On; FontRenderingOptions.HintStyle = HintStyle.Medium; FontRenderingOptions.SubpixelOrder = SubpixelOrder.Rgb; }
public static Font Get(string fontFamily, FontOptions options, int size) { var key = new FontRef(fontFamily, options, size); Font font; if (!_fonts.TryGetValue(key, out font)) { font = new Font(fontFamily, options, size); _fonts.TryAdd(key, font); } return(font); }
/// <summary> /// 创建字体绘画工具。 /// </summary> /// <param name="font">给定的 <see cref="FontOptions"/>。</param> /// <param name="color">给定的字体颜色。</param> /// <returns>返回 <see cref="SKPaint"/>。</returns> public static SKPaint CreatePaint(this FontOptions font, string color) { var paint = new SKPaint(); paint.IsAntialias = true; paint.Color = color.AsColor(); // paint.StrokeCap = SKStrokeCap.Round; paint.Typeface = SKTypeface.FromFile(font.File); paint.TextSize = font.Size; return(paint); }
public void SmallPercentageCustom() { var propertyIndex = 2; var expectedValue = r.Next(5, 8) * 10; var src = new FontOptions { SmallPercentage = expectedValue }; var so = PopulateOptions(src); AssertPopulatedProperty(so, propertyIndex, CreatePercentageValue(expectedValue)); }
static void SetupContext(Context g, string fontName, FontSlant fontSlant, FontWeight fontWeight, double fontSize) { FontOptions fo = new FontOptions(); fo.Antialias = Antialias.Gray; fo.HintStyle = HintStyle.Full; g.FontOptions = fo; g.SelectFontFace(fontName, fontSlant, fontWeight); g.SetFontSize(fontSize); g.Color = new Color(1.0, 1.0, 1.0); }
internal Font(Workbook wb, FontRecord f) : base(wb) { _height = f.FontHeight; _options = f.Options; _color = wb.Palette.GetColor(f.ColorIdx); _boldNess = f.Boldness; _escapement = f.Escapement; _underline = f.Underline; _family = f.FontFamily; _characterSet = f.CharacterSet; _fontName = f.FontName; }
private static void OnFontOptionsSourceChanged(DependencyObject dependencyObject, FrameworkElement oldFrameworkElement, FrameworkElement newFrameworkElement) { var textBlock = (TextBlock)dependencyObject; if (newFrameworkElement != null) { SetFontOptions(textBlock, FontOptions.FromElement(newFrameworkElement)); } else { textBlock.ClearValue(FontOptionsProperty); } }
private FontOptions GetFontOptions() { var options = new FontOptions { BackgroundColor = lblBackgroundColorSelector.BackColor.ToWpfColor(), TextColor = lblTextColorSelector.BackColor.ToWpfColor(), Weight = (FontWeight)cbxFontWeight.SelectedItem, Style = (FontStyle)cbxFontStyle.SelectedItem, Underline = chkUnderline.Checked }; return(options); }
public void PrimaryCustom() { var propertyIndex = 0; var expectedValue = GetRandomFontFamilyNames(fontFamilies, 3); var src = new FontOptions { Primary = expectedValue }; var so = PopulateOptions(src); AssertPopulatedProperty(so, propertyIndex, CreateStringList(expectedValue, ListStylingAttribute.DefaultDelimiter)); }
public void EmptyContructor() { var src = new FontOptions { }; var so = PopulateOptions(src); Assert.AreEqual(0, so.Count); so = PopulateOptions(src, true); Assert.AreEqual(3, so.Count); }
public void SmallPercentageDefault() { var propertyIndex = 2; var expectedValue = FontOptions.Defaults.SmallPercentage; var src = new FontOptions { }; var so = PopulateOptions(src); AssertEmptyProperty(so, propertyIndex); so = PopulateOptions(src, true); AssertPopulatedProperty(so, propertyIndex, CreatePercentageValue(expectedValue)); }
public void PrimaryDefault() { var propertyIndex = 0; var expectedValue = FontOptions.Defaults.Primary; var src = new FontOptions { }; var so = PopulateOptions(src); AssertEmptyProperty(so, propertyIndex); so = PopulateOptions(src, true); AssertPopulatedProperty(so, propertyIndex, CreateStringList(expectedValue, ListStylingAttribute.DefaultDelimiter)); }
public ActionResult CreateAnnotation(string connectionId, string userId, string privateKey, string fileId, byte type, string message, Rectangle rectangle, int pageNumber, Point annotationPosition, string svgPath, DrawingOptions drawingOptions, FontOptions font, string callback = null) { try { var result = _annotationSvc.CreateAnnotation(connectionId, fileId, type, message, rectangle, pageNumber, annotationPosition, svgPath, drawingOptions, font); return(this.JsonOrJsonP(result, callback)); } catch (AnnotatorException e) { return(this.JsonOrJsonP(new FailedResponse { Reason = e.Message }, callback)); } }
void OnFontChanged(object sender, EventArgs e) { font = App.Current.ClientFont; TextDecorations = new TextDecorationCollection(); if (font.Style.HasFlag(Protocol.FontStyle.Underline)) { TextDecorations.Add(System.Windows.TextDecorations.Underline); } NotifyPropertyChanged("FontFamily"); NotifyPropertyChanged("FontWeight"); NotifyPropertyChanged("FontStyle"); NotifyPropertyChanged("FontColor"); NotifyPropertyChanged("TextDecorations"); }
private GameObject CreateText(string txt, FontId fontId, float size, Vector3 newPosition, TextAnchor newAchor) { // A custom method that creates a gameobject based on the fontPrefab and write the string in it FontOptions fontOptions = UFE.GetFont(fontId); if (fontOptions.fontPrefab == null) { Debug.LogError("Font prefab not found! Make sure you have all font prefabs set in the Global Editor"); } GameObject guiTextGO = (GameObject)Instantiate(fontOptions.fontPrefab, newPosition, Quaternion.identity); guiTextGO.guiText.anchor = newAchor; guiTextGO.guiText.text = txt; guiTextGO.transform.localScale *= size; return(guiTextGO); }
public void Get(out FontOptions options) { options = new FontOptions(); options.Hinting = Hinting; if (AntiAliasing) { options.Flags |= FontFlags.AntiAliasing; } if (Bold) { options.Flags |= FontFlags.Bold; } if (Italic) { options.Flags |= FontFlags.Italic; } }
protected override void OnStartup(StartupEventArgs e) { log.Info("========= Application Startup ========="); emoticonManager.LoadEmoticons(); string DefaultFontFamily = "Segoe UI"; Color DefaultFontColor = Colors.Black; var settings = Client.Properties.Settings.Default; var fontFamily = settings.FontFamily; if (Fonts.SystemFontFamilies.FirstOrDefault(family => family.Source == fontFamily) == null) { fontFamily = DefaultFontFamily; } Color fontColor = DefaultFontColor; try { fontColor = ColorConverter.ConvertFromString(settings.FontColor) as Color? ?? Colors.Black; } catch (FormatException) // If the font color from settings is invalid, we stick with the default { } FontStyle fontStyle = (settings.FontBold ? FontStyle.Bold : 0) | (settings.FontItalic ? FontStyle.Italic : 0) | (settings.FontUnderline ? FontStyle.Underline : 0); ClientFont = new FontOptions(fontFamily, fontColor, fontStyle); if (statusBrushMap.Count == 0) { statusBrushMap.Add(UserStatus.Available, Resources["AvailableBrush"] as SolidColorBrush); statusBrushMap.Add(UserStatus.Away, Resources["AwayBrush"] as SolidColorBrush); statusBrushMap.Add(UserStatus.Busy, Resources["BusyBrush"] as SolidColorBrush); statusBrushMap.Add(UserStatus.Offline, Resources["OfflineBrush"] as SolidColorBrush); statusBrushMap.Add(UserStatus.Unknown, Resources["OfflineBrush"] as SolidColorBrush); } IViewController views = this as IViewController; views.Navigate(views.CreateLoginView()); base.OnStartup(e); }
/// <summary> /// The constructor for the record. /// </summary> /// <param name="biff">The GenericBiff record that should contain the correct type and data for the FONT record.</param> /// <exception cref="InvalidRecordIdException"> /// An InvalidRecordIdException is thrown if biff contains an invalid type or invalid data. /// </exception> public FontRecord(GenericBiff biff) { if(biff.Id == (ushort)RecordType.Font) { BinaryReader reader = new BinaryReader(biff.GetDataStream()); _fontHeight = reader.ReadUInt16(); _options = (FontOptions)reader.ReadUInt16(); _colorIdx = reader.ReadUInt16(); _boldness = new FontBoldness(reader.ReadUInt16()); _escapement = (FontEscape)reader.ReadUInt16(); _underline = (FontUnderline)reader.ReadByte(); _fontFamily = (FontFamily)reader.ReadByte(); _characterSet = (FontCharacterSet)reader.ReadByte(); /* byte reserved = */ reader.ReadByte(); byte len = reader.ReadByte(); _fontName = Reader.ReadComplexString(reader, len); } else throw new InvalidRecordIdException(biff.Id, RecordType.Font); }
public static FileInfo FindFontFile(string fontFamily, FontOptions options = FontOptions.None) { if ((options & FontOptions.Bold) == FontOptions.Bold) { fontFamily += " Bold"; } if ((options & FontOptions.Italic) == FontOptions.Italic) { fontFamily += " Italic"; } switch (Environment.OSVersion.Platform) { case PlatformID.Win32NT: var _fontsKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Windows NT\\CurrentVersion\\Fonts"); var fontFileName = (string)(_fontsKey.GetValue(fontFamily) ?? _fontsKey.GetValue(fontFamily + " (TrueType)")); fontFileName = Path.Combine(@"C:\Windows\Fonts\", fontFileName); return(File.Exists(fontFileName) ? new FileInfo(fontFileName) : null); case PlatformID.Unix: case PlatformID.MacOSX: var basePath = Path.Combine("/Library/Fonts/", fontFamily); if (File.Exists(basePath + ".ttf")) { return(new FileInfo(basePath + ".ttf")); } else if (File.Exists(basePath + ".ttc")) { return(new FileInfo(basePath + ".ttc")); } else { return(null); } default: throw new NotSupportedException("TrueType loading is not supported on OS version " + Environment.OSVersion.Platform.ToString()); } }
/// <summary> /// Sets up the context. Must be executed in the main thread, as it is not thread safe. /// </summary> /// <param name="ctx">The context to set up the CairoFont with.</param> public void SetupContext(Context ctx) { ctx.SetFontSize(GuiElement.scaled(UnscaledFontsize)); ctx.SelectFontFace(Fontname, Slant, FontWeight); CairoFontOptions = new FontOptions(); //Antialias.Best does not work on Linux it completely borks the font CairoFontOptions.Antialias = Antialias.Subpixel; ctx.FontOptions = CairoFontOptions; if (Color != null) { if (Color.Length == 3) { ctx.SetSourceRGB(Color[0], Color[1], Color[2]); } if (Color.Length == 4) { ctx.SetSourceRGBA(Color[0], Color[1], Color[2], Color[3]); } } }
/// <summary> /// The constructor for the record. /// </summary> /// <param name="biff">The GenericBiff record that should contain the correct type and data for the FONT record.</param> /// <exception cref="InvalidRecordIdException"> /// An InvalidRecordIdException is thrown if biff contains an invalid type or invalid data. /// </exception> public FontRecord(GenericBiff biff) { if (biff.Id == (ushort)RecordType.Font) { BinaryReader reader = new BinaryReader(biff.GetDataStream()); _fontHeight = reader.ReadUInt16(); _options = (FontOptions)reader.ReadUInt16(); _colorIdx = reader.ReadUInt16(); _boldness = new FontBoldness(reader.ReadUInt16()); _escapement = (FontEscape)reader.ReadUInt16(); _underline = (FontUnderline)reader.ReadByte(); _fontFamily = (FontFamily)reader.ReadByte(); _characterSet = (FontCharacterSet)reader.ReadByte(); byte reserved = reader.ReadByte(); byte len = reader.ReadByte(); _fontName = Reader.ReadComplexString(reader, len); } else { throw new InvalidRecordIdException(biff.Id, RecordType.Font); } }
public Font(string fontFamily, FontOptions options, int size) { FontFamily = fontFamily; Options = options; Size = size; }
public static Font Get(string name, FontOptions options, int size) { List<Font> fonts; if (!_fonts.TryGetValue(name, out fonts)) { fonts = new List<Font>(1); _fonts.Add(name, fonts); } var font = fonts.FirstOrDefault(f => f.FontFamily == name && f.Options == options && f.Size == size); if (font == null) { font = new Font(name, options, size); fonts.Add(font); } return font; }