/// <summary> /// Gets the font for the given fontname and textSize. /// </summary> /// <returns>The font.</returns> /// <param name="fontName">Font name.</param> private CTFont GetFont(string fontName, float textSize) { if (string.IsNullOrWhiteSpace(fontName)) { fontName = CGContextRenderer.DefaultFontName; } if (_font == null) { _fontName = fontName; _font = new CTFont(fontName, textSize); } if (_fontName != fontName) { _font.Dispose(); _fontName = fontName; _font = new CTFont(fontName, textSize); } if (_font.Size != textSize) { _font.Dispose(); _fontName = fontName; _font = new CTFont(fontName, textSize); } CTFont font = _font; return(font); }
private void Dispose(bool disposing) { if (disposing) { nativeFont.Dispose(); } }
internal void Dispose(bool disposing) { if (disposing) { if (nativeFont != null) { nativeFont.Dispose(); nativeFont = null; } } }
private string[] GetStyleNames(string[] fontIds) { string[] styleNames = new string[fontIds.Length]; for (int i = 0; i < fontIds.Length; i++) { var font = new CTFont(fontIds[i], UIFont.SystemFontSize); styleNames[i] = font.GetName(CTFontNameKey.Style); font.Dispose(); } return(styleNames); }
public override bool LoadFont(Font font) { font.RealSize = font.Size * Scale; CTFont sysFont = font.RendererData as CTFont; if (sysFont != null) { sysFont.Dispose(); } sysFont = new CTFont(GetSysFontName(font.FaceName, font.Bold, font.Italic), font.RealSize); font.RendererData = sysFont; return(true); }
public override void FreeFont(Font font) { if (font.RendererData == null) { return; } CTFont sysFont = font.RendererData as CTFont; if (sysFont == null) { throw new InvalidOperationException("Freeing empty font"); } sysFont.Dispose(); font.RendererData = null; }
public string GetFontStyle(string aFontName) { var vFontName = aFontName ?? _systemFontName; var vFont = new CTFont(vFontName, NSFont.SystemFontSize); var vStyle = vFont.GetName(CTFontNameKey.Style); vFont.Dispose(); if (vStyle != null) { if (vStyle.Contains("Italic")) { return("italic"); } } return("normal"); }