public static Font get(Style style) { Font font; if (!fontCache.TryGetValue(uidOf(style), out font)) { fontCache[uidOf(style)] = font = createFont(style); } return font; }
protected Document() { rows = new DocumentRowCollection(); style = new Style(); style.FontName = Control.DefaultFont.Name; style.FontHeight = Control.DefaultFont.SizeInPoints; style.Foreground = Color.Black; style.Background = Color.White; }
public virtual Style combine(Style style) { Style result = new Style(); result.fontHeight = fontHeight; result.fontName = fontName; result.foreground = foreground; result.background = background; if (style.fontName != null) result.fontName = style.fontName; if (style.fontHeight > 0) result.fontHeight = style.fontHeight; if (!style.foreground.IsEmpty) result.foreground = style.foreground; if (!style.background.IsEmpty) result.background = style.background; result.fontStyle |= style.fontStyle; return result; }
private static string uidOf(Style style) { return style.FontName + ", " + style.FontHeight + "pt, " + style.FontStyle; }
private static Font createFont(Style style) { return new Font(style.FontName, style.FontHeight, style.FontStyle); }
public static Brush getForeground(Style style) { return getSolid(style.Foreground); }