bugDotGNU Portable.NET - Bugs: bug #11074, Font.SizeInPoints fails with...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #11074: Font.SizeInPoints fails with NullReferenceException

Submitter:  Thong Nguyen <tum>
Submitted:  Sun 21 Nov 2004 01:33:05 AM UTC
   
 
Category:  None Severity:  1 - Wish
Item Group:  None Status:  Fixed
Privacy:  Public Assigned to:  None
Open/Closed:  Closed

Tue 02 Aug 2005 12:24:36 PM UTC, comment #1: 

fixed in cvs

Deryk Robosson <drobosson>
Group Member
Sun 21 Nov 2004 01:33:05 AM UTC, original submission:  

The following program fails with a NullReferenceException:

using System;
using System.Drawing;

public class Test
{
public static void Main()
{
Font font = new Font("Arial", 10, GraphicsUnit.Pixel);

Console.WriteLine(font.SizeInPoints);
}
}


Note that it only fails if the GraphicsUnit is Pixel (or World).

The reason for failure is that Font.SizeInPoints tries to dereference the Font.toolkit field which is null.  The solution is to use ToolkitManager.Toolkit instead of Font.toolkit but I thought I would submit this as a bug because there may be some esoteric reason as to why there is a local "toolkit" field in font which doesn't seem to be used much but is a source of problems for fonts when created in certain ways.

The other solution would be to set Font.toolkit to ToolkitManager.Toolkit if no toolkit is provided in the Font constructor.


Comments and suggestions would be helpful..

Thong Nguyen <tum>
Group Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

 

Follow 2 latest changes.

Date Changed by Updated Field Previous Value => Replaced by
2005-08-02 drobosson StatusNone Fixed
    Open/ClosedOpen Closed

Back to the top

Powered by Savane 3.13-0329.
Corresponding source code