// Get the toolkit version of this font for a specific toolkit. internal IToolkitFont GetFont(IToolkit toolkit, float dpi) { lock (this) { if (this.toolkitFont == null) { // We don't yet have a toolkit font yet. this.toolkitFont = toolkit.CreateFont(this, dpi); this.toolkit = toolkit; return(this.toolkitFont); } else if (this.toolkit == toolkit) { // Same toolkit - return the cached pen information. return(this.toolkitFont); } else { // We have a font object for another toolkit, // so dispose it and create for this toolkit. // We null out "toolkitFont" before calling // "CreateFont()" just in case an exception // is thrown while creating the toolkit font. this.toolkitFont.Dispose(); this.toolkitFont = null; this.toolkitFont = toolkit.CreateFont(this, dpi); this.toolkit = toolkit; return(this.toolkitFont); } } }
// Dispose of this object. public void Dispose() { lock (this) { if (toolkitFont != null) { toolkitFont.Dispose(); toolkitFont = null; } toolkit = null; } }
private Font(IToolkitFont font) { this.toolkit = toolkit; this.toolkitFont = font; // TODO: load the font information from the IToolkitFont }
// Get the toolkit version of this font for a specific toolkit. internal IToolkitFont GetFont(IToolkit toolkit, float dpi) { lock(this) { if(this.toolkitFont == null) { // We don't yet have a toolkit font yet. this.toolkitFont = toolkit.CreateFont(this, dpi); this.toolkit = toolkit; return this.toolkitFont; } else if(this.toolkit == toolkit) { // Same toolkit - return the cached pen information. return this.toolkitFont; } else { // We have a font object for another toolkit, // so dispose it and create for this toolkit. // We null out "toolkitFont" before calling // "CreateFont()" just in case an exception // is thrown while creating the toolkit font. this.toolkitFont.Dispose(); this.toolkitFont = null; this.toolkitFont = toolkit.CreateFont(this, dpi); this.toolkit = toolkit; return this.toolkitFont; } } }
// Dispose of this object. public void Dispose() { lock(this) { if(toolkitFont != null) { toolkitFont.Dispose(); toolkitFont = null; } toolkit = null; } }
private Font(IToolkitFont font) { _toolkit = _toolkit; _toolkitFont = font; // TODO: load the font information from the IToolkitFont }