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

Submitted by:  Thong Nguyen <tum>
Submitted on:  Sun 21 Nov 2004 01:33:05 AM UTC  
 
Category: NoneSeverity: 1 - Wish
Item Group: NoneStatus: Fixed
Privacy: PublicAssigned to: None
Open/Closed: Closed

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

fixed in cvs

Deryk Robosson <drobosson>
Project 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>
Project Member

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

Do you think this task is very important?
If so, you can click here to add your encouragement to it.
This task has 0 encouragements so far.

Only logged-in users can vote.

 

Please enter the title of George Orwell's famous dystopian book (it's a date):

 

 

Follow 2 latest changes.

Date Changed By Updated Field Previous Value => Replaced By
Tue 02 Aug 2005 12:24:36 PM UTCdrobossonStatusNone=>Fixed
  Open/ClosedOpen=>Closed

Back to the top


Powered by Savane 3.1-cleanup1