Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Font Scaling (Read 5213 times)
blazetopher
YaBB Newbies
*
Offline



Posts: 9
Joined: Dec 27th, 2006
Font Scaling
Jan 12th, 2007 at 4:25pm
Print Post  
Hello all,

I've come to a tough spot with font scaling in my flowchart controls.  The troubles come when scaling is applied to the flow chart (either when the user zooms in/out, or when they print preview-FitToPage) and the fonts do not scale with the zoom factor.

I understand from other posts and the FAQ that font scaling will work perfectly well if the GraphicsUnit of the font is set to World.  I have done this, and it works fine.  The problem is that I'm allowing the user to "format" the font they use in any given box of the flowchart (via a .NET font dialog) and when they choose a font, the "new" font for the box has GraphicsUnits of point.  The newly selected font then does not scale when zoomed or print previewed.

I've looked around the web for "GraphicsUnit Conversion" without much luck and was hoping someone here had encountered the same hurdle.  I'd be open to pretty much any solution that someone might have.

Thanks in advance,
Blaze
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Font Scaling
Reply #1 - Jan 12th, 2007 at 6:40pm
Print Post  
Hi,

You can call the following method to convert from Point to FlowChart.MeasureUnit:

Code
Select All
private float convert(float size, GraphicsUnit from, GraphicsUnit to)
{
	float fromFactor = inch(from);
	float toFactor = inch(to);

	return toFactor * size / fromFactor;
}

float inch(GraphicsUnit unit)
{
	switch (unit)
	{
		case GraphicsUnit.Display:
			return 100;
		case GraphicsUnit.Document:
			return 300;
		case GraphicsUnit.Inch:
			return 1;
		case GraphicsUnit.Millimeter:
			return 25.4f;
		case GraphicsUnit.Pixel:
			return 96;
		case GraphicsUnit.Point:
			return 72;
	}

	return 96;
}
 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
blazetopher
YaBB Newbies
*
Offline



Posts: 9
Joined: Dec 27th, 2006
Re: Font Scaling
Reply #2 - Jan 17th, 2007 at 2:27pm
Print Post  
Excellent - thank you very much.  I had solved the issue using static conversion factors but this is a much more flexible solution.

Thanks,
Blaze
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Font Scaling
Reply #3 - Jan 17th, 2007 at 2:39pm
Print Post  
Actually the Pixel case is incorrect - it should return the Windows' DPI value for the display, however I couldn't find how to get it from .NET.

Stoyan
  
Back to top
 
IP Logged
 
blazetopher
YaBB Newbies
*
Offline



Posts: 9
Joined: Dec 27th, 2006
Re: Font Scaling
Reply #4 - Jan 18th, 2007 at 12:23pm
Print Post  
I believe the following would work for the pixel case.

Graphics g = this.CreateGraphics();
                   return g.DpiX;


As a follow up, my zooming now works wonderfully, but I'm having a related problem with the cursor for the flowchart.  Namely, when the user selects "zoom to rectangle" (the method for which follows the instructions you laid forth in another post) from the right-click menu, I set the flowchart.cursor = cursors.cross....but when I run the code, it stays the default cursor.
When I step through the code, the cursor turns into a cross, but then immediately goes back to the default when the code steps into the mousemove event....

Any ideas??

Thanks again,
Blaze
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Font Scaling
Reply #5 - Jan 18th, 2007 at 1:04pm
Print Post  
The Cursor property is defined in the base Control class and FlowChart.NET doesn't use it. Try setting the CurPointer property if you use a box to draw the zoom rectangle. CurPointer should be displayed while the user is creating the box.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
blazetopher
YaBB Newbies
*
Offline



Posts: 9
Joined: Dec 27th, 2006
Re: Font Scaling
Reply #6 - Jan 18th, 2007 at 1:14pm
Print Post  
Perfect!  Thanks!
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint