Aligning text on the same line with different size fonts

M

Mike Grace

Hi,

I am printing a line of text which uses 2 different fonts. It is actually
broken into 2 and drawn separately. Because one font is bigger than the
other, I need to align the smaller font onto the same base line as the
larger font.

By getting the ascent of each font and obtaining the difference, I thought I
could add it onto the smaller fonts y position thus aligning the font.

The trouble is the font metric GetCellAscent() returns "design units"
(whatever they are) but my page is in inches. (This seems odd because I can
pass my Graphics object to the getHeight() method and get that returned in
inches.

How can I convert design units to inches or pixels or any of the other units
that a Graphics object can have?

Is there a conversion function? I cannot find anything in the msdn docs.

Can anyone help?

Mike
 
Y

Ying-Shen Yu[MSFT]

Hi Mike,
I apologize for the long delay.
Here is an article in MSDN which talks about how to convert the design unit
to pixel.
http://msdn.microsoft.com/library/en-us/gdicpp/gdiplus/usinggdiplus/usingext
andfonts/obtainingfontmetrics.asp?frame=true
Then, You may set your Graphics object to Pixel to use it directly or
convert it to inch.
You may get the pixels per inch information from Graphics.DpiX, and DpiY.
Thanks!
If you still have problem on this issue, please let me know!


Best regards,

Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
You should not reply this mail directly, "Online" should be removed before
sending, Thanks!

--------------------
| From: "Mike Grace" <[email protected]>
| Subject: Aligning text on the same line with different size fonts
| Date: Tue, 30 Sep 2003 15:54:01 +0100
| Lines: 25
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <#[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.windowsforms
| NNTP-Posting-Host: host217-34-100-57.in-addr.btopenworld.com 217.34.100.57
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.windowsforms:53453
| X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
|
| Hi,
|
| I am printing a line of text which uses 2 different fonts. It is actually
| broken into 2 and drawn separately. Because one font is bigger than the
| other, I need to align the smaller font onto the same base line as the
| larger font.
|
| By getting the ascent of each font and obtaining the difference, I
thought I
| could add it onto the smaller fonts y position thus aligning the font.
|
| The trouble is the font metric GetCellAscent() returns "design units"
| (whatever they are) but my page is in inches. (This seems odd because I
can
| pass my Graphics object to the getHeight() method and get that returned in
| inches.
|
| How can I convert design units to inches or pixels or any of the other
units
| that a Graphics object can have?
|
| Is there a conversion function? I cannot find anything in the msdn docs.
|
| Can anyone help?
|
| Mike
|
|
|
 
J

Joe White

That URL returns a "Page Not Found" (yes, I removed the line break and
pasted it into the Address bar). It should be ".../usingtextandfonts/..."
(somehow one of the "t"s got dropped when you pasted the URL)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top