Font problem

It seems that the Cambria Math font has recently acquired an extremely large 
Ascent and Descent. Has it perhaps always been that way and I've never 
noticed it before, or is it something recent, perhaps a Vista thing? Try the 
following code for example. For Arial and Times New Roman (and virtually all 
other fonts) I am getting pretty much exactly what I would expect (a 
TextHeight that is a bit larger than the point size) but for Cambria Math I 
am getting an extremely large TextHeight (I get exactly the same results 
using GDI32 methods). At this end (on my Vista Business laptop and my Vista 
Home Premium desktop which both run at the standard 96 dpi) I get 15.75/18 
for Arial and 15.75/17.25 for Times New Roman, which both seem okay, but I 
get 15.75/87.75 for Cambria Math, which seems extraordinary.

Mike

Private Sub Command1_Click()
ScaleMode = vbPoints
Caption = "All sizes are in Points " & _
  "(point size first followed by TextHeight)"
Font.Name = "Arial"
Font.Size = 16
Print Font.Name; Font.Size; TextHeight("x")
Print "Seems okay"
Font.Name = "Cambria Math"
Font.Size = 16
Print Font.Name; Font.Size; TextHeight("x")
Print "Very odd?"
Font.Name = "Times New Roman"
Font.Size = 16
Print Font.Name; Font.Size; TextHeight("x")
Print "Seems okay"
End Sub




0
Mike
3/28/2010 8:44:35 AM
vb.general.discussion 1016 articles. 0 followers. Follow

11 Replies
2494 Views

Similar Articles

[PageSpeed] 30

"Mike Williams" <Mike@WhiskyAndCoke.com> wrote in message 
news:OIiWmLlzKHA.3884@TK2MSFTNGP06.phx.gbl...
> It seems that the Cambria Math font has recently acquired an extremely 
> large Ascent and Descent. Has it perhaps always been that way and I've 
> never noticed it before, or is it something recent, perhaps a Vista thing? 
> Try the following code for example. For Arial and Times New Roman (and 
> virtually all other fonts) I am getting pretty much exactly what I would 
> expect (a TextHeight that is a bit larger than the point size) but for 
> Cambria Math I am getting an extremely large TextHeight (I get exactly the 
> same results using GDI32 methods). At this end (on my Vista Business 
> laptop and my Vista Home Premium desktop which both run at the standard 96 
> dpi) I get 15.75/18 for Arial and 15.75/17.25 for Times New Roman, which 
> both seem okay, but I get 15.75/87.75 for Cambria Math, which seems 
> extraordinary.

I got the exact same number here in XP+SP2. I am using VB6+SP5 with SP6 
runtime.


0
Nobody
3/28/2010 9:27:04 AM
"Nobody" <nobody@nobody.com> schrieb im Newsbeitrag 
news:Oa22WjlzKHA.1796@TK2MSFTNGP02.phx.gbl...
> "Mike Williams" <Mike@WhiskyAndCoke.com> wrote in message 
> news:OIiWmLlzKHA.3884@TK2MSFTNGP06.phx.gbl...
>> It seems that the Cambria Math font has recently acquired an extremely large 
>> Ascent and Descent. Has it perhaps always been that way and I've never 
>> noticed it before, or is it something recent, perhaps a Vista thing? Try the 
>> following code for example. For Arial and Times New Roman (and virtually all 
>> other fonts) I am getting pretty much exactly what I would expect (a 
>> TextHeight that is a bit larger than the point size) but for Cambria Math I 
>> am getting an extremely large TextHeight (I get exactly the same results 
>> using GDI32 methods). At this end (on my Vista Business laptop and my Vista 
>> Home Premium desktop which both run at the standard 96 dpi) I get 15.75/18 
>> for Arial and 15.75/17.25 for Times New Roman, which both seem okay, but I 
>> get 15.75/87.75 for Cambria Math, which seems extraordinary.
>
> I got the exact same number here in XP+SP2. I am using VB6+SP5 with SP6 
> runtime.
>
>



Hmmm,

I just went to Control Panel / Fonts on my Vista Home Premium 32-bit system
and clicked on 'Cambria & Cambria Math'. It's a True Type Collection.
It displays Cambria as usual, but when you switch to Cambria Math it shows
this font with extremely space between the lines. My guess is there are
mathematical symbols in this font which need this height. They didn't bother
with Italic, Bold or Bold Italic versions of Cambria Math.

Helmut.



0
Helmut
3/28/2010 11:13:51 AM
"Helmut Meukel" <NoSpam@NoProvider.de> wrote in message news:%

> I just went to Control Panel / Fonts on my Vista Home Premium
> 32-bit system and clicked on 'Cambria & Cambria Math' . . . It
> displays Cambria as usual, but when you switch to Cambria Math
> it shows this font with extremely space between the lines.

It's probably always been like that, and I haven't noticed before. I never 
actually use that font and I only noticed it because I was writing a little 
utility for somebody and I came across it in the process.

> They didn't bother with Italic, Bold or Bold Italic versions
> of Cambria Math.

No, they didn't produce a special italic or bold fontface for it, although 
you can of course get simulated bold and/or italic in the normal way that 
you can get them for any other font that does not have its own specially 
designed italic or bold font face, simply by specifying bold or italic in 
the usual way.

> My guess is there are mathematical symbols in this font which
> need this height.

You're probably right there, although I did have a quick look through lots 
of the characters using Unicode view in CharacterMap and I couldn't find 
any. Even the special math characters that you might expect would be large 
in relation to the other characters were not so huge as to occupy anywhere 
near the full available character cell height . . but hey, what I know about 
math or math fonts can be written on the back of a postage stamp, so that 
doesn't mean very much ;-)

Mike



0
Mike
3/28/2010 12:49:17 PM
I've noticed this for Symath.

Except from that, the textheight in VB is always the same.

*************************************************************************************
sample
*************************************************************************************
Private Sub Form_Load()

  Form1.ScaleMode = vbPixels

End Sub
Private Sub Form_Paint()

  Form1.Font.Name = "Times New Roman"
  Form1.Font.Size = 24

  Form1.Print Form1.Font.Name
  Form1.Print Form1.Font.Name
  Form1.Print Form1.Font.Size
  Form1.Print "x"
  Form1.Print Form1.TextWidth("x") & " " & Form1.TextHeight("x")
  Form1.Print "X"
  Form1.Print Form1.TextWidth("X") & " " & Form1.TextHeight("X")
  Form1.Print "h"
  Form1.Print Form1.TextWidth("h") & " " & Form1.TextHeight("h")
  Form1.Print "gh"
  Form1.Print Form1.TextWidth("gh") & " " & Form1.TextHeight("gh")

End Sub

Output:

Times New Roman
24
15 36
23 36
15 36
30 36

Width and height measured in paint (pixels):

x 15 14
X 22 21
h 15 22
gh 29 29

Distance bottom of line to bottom of next line:

36 pixels

*************************************************************************************
end sample
*************************************************************************************
0
sven2000
3/28/2010 2:08:42 PM
"sven2000" <sven2000@gmail.com> wrote in message 
news:483a013e-4cac-42e8-b592-77c3e11f7898@k13g2000yqe.googlegroups.com...

> I've noticed this for Symath.
> Except from that, the textheight in VB is always the same.
>  Form1.Print "x"
>  Form1.Print Form1.TextWidth("x") & " " & Form1.TextHeight("x")
>  Form1.Print "X"
>  Form1.Print Form1.TextWidth("X") & " " & Form1.TextHeight("X")

The TextHeight of a font of any specific size and type is the sum of its 
Ascent and Descent (or the overall height of a character cell or the 
distance from the top of one line of text to the top of the next line in a 
normally printed block of text if you prefer to look at it in either of 
those ways). It is the same for all characters in the font, so the character 
"x" and the character"X" and the character "." all have the same TextHeight 
(except that the VB TextHeight function, as opposed to the GDI32 
GettextExtentPoint32 function, assumes that any string containing a line 
feed or a carriage consists of two or more printed lines and so VB 
TextHeight returns two or three or more times the normal value for any 
string containing either of those characters). So, the characters "X" and 
"x" and "." all have the same TextHeight. It is their TextWidths that are 
different (in a proportionaly spaced font, which most fonts are). If you 
instead want to get the height of the actual "drawn part" of a specific 
character, and its placement within the character cell (which of course is 
different for different characters) then you can use the GetGlyphOutline 
function, although that is not necessary for most jobs. Regarding the Ascent 
and Descent and various other things and how they relate to the overall 
TextHeight here is some code that produces a more graphical explanation of 
it (paste it into a VB Form):

Mike

Option Explicit
Private Declare Function GetTextMetrics Lib "gdi32" _
  Alias "GetTextMetricsA" (ByVal hdc As Long, _
  lpMetrics As TEXTMETRIC) As Long
Private Type TEXTMETRIC
  tmHeight As Long
  tmAscent As Long
  tmDescent As Long
  tmInternalLeading As Long
  tmExternalLeading As Long
  tmAveCharWidth As Long
  tmMaxCharWidth As Long
  tmWeight As Long
  tmOverhang As Long
  tmDigitizedAspectX As Long
  tmDigitizedAspectY As Long
  tmFirstChar As Byte
  tmLastChar As Byte
  tmDefaultChar As Byte
  tmBreakChar As Byte
  tmItalic As Byte
  tmUnderlined As Byte
  tmStruckOut As Byte
  tmPitchAndFamily As Byte
  tmCharSet As Byte
End Type
Private Const DEFAULT_QUALITY As Byte = 0
Private Const DRAFT_QUALITY As Byte = 1
Private Const NONANTIALIASED_QUALITY As Byte = 3
Private Const ANTIALIASED_QUALITY As Byte = 4
Private Const CLEARTYPE_COMPAT_QUALITY As Byte = 5
Private Const CLEARTYPE_QUALITY As Byte = 6

Private Sub Form_Load()
' A graphical representation of the various
' Font details (by Mike Williams).
Dim fName As String, fSize As Single
Dim sampleText As String
fName = "Times New Roman"
fSize = 72
sampleText = "MjtplqdgfH0123"
Dim mymetrics As TEXTMETRIC, savey As Single
Dim InternalLeading As Single
Dim Ascent As Single
Dim Descent As Single
Dim ExternalLeading As Single
Dim txtHeight As Single
Me.AutoRedraw = True
Me.Show
Me.BackColor = vbWhite
Me.Width = Me.ScaleX(7.6, vbInches, vbTwips)
Me.Height = Me.ScaleY(5.7, vbInches, vbTwips)
Me.Line (0, 0)-(Me.ScaleWidth, Me.ScaleHeight), _
  RGB(200, 100, 255), BF
Me.ScaleMode = vbPoints
Me.Font.Name = fName
Me.Font.Size = fSize ' 72 points = 1 inch
Me.Font.Italic = False
Me.Font.Bold = False
txtHeight = Me.TextHeight("some text")
GetTextMetrics Me.hdc, mymetrics
InternalLeading = Me.ScaleY(mymetrics.tmInternalLeading, _
                                 vbPixels, Me.ScaleMode)
Ascent = Me.ScaleY(mymetrics.tmAscent, _
               vbPixels, Me.ScaleMode)
Descent = Me.ScaleY(mymetrics.tmDescent, _
               vbPixels, Me.ScaleMode)
ExternalLeading = Me.ScaleY(mymetrics.tmExternalLeading, _
                                 vbPixels, Me.ScaleMode)
Me.CurrentX = 0: Me.CurrentY = 0
Me.FontTransparent = True
Me.Print sampleText
Me.FontTransparent = False
Me.Print sampleText
savey = Me.CurrentY
Me.Line (0, InternalLeading)- _
  (Me.ScaleWidth, InternalLeading), vbYellow
Me.Line (0, Ascent)- _
  (Me.ScaleWidth, Ascent), vbGreen
Me.Line (0, Ascent + Descent)- _
  (Me.ScaleWidth, Ascent + Descent), vbBlue
If mymetrics.tmExternalLeading > 0 Then
  Me.Line (0, Ascent + Descent + ExternalLeading)- _
  (Me.ScaleWidth, Ascent + Descent + ExternalLeading), vbRed
End If
' Capital letters (A - Z) and numbers (0 - 9)in most fonts
' start a little after the External Leading and extend down
' to the Ascent line, and the centre of those characters is
' usually about 0.48 of the overall "TextHeight" down from
' the top of the character cell. The following code will
' therefore draw a line approximately through the centre
' of these characters on most (but  not all) fonts.
Me.Line (0, txtHeight * 0.48)- _
  (Me.ScaleWidth, txtHeight * 0.48), vbWhite
Me.CurrentX = 0
Me.CurrentY = savey
Me.Font.Name = "Arial"
Me.Font.Size = 8
Me.Print " The example text is " & fName & " " _
         & Format(fSize, "0.0") & " points"
Me.Print " Internal Leading = " & InternalLeading & " points"
Me.Print " Ascent = " & Ascent & " points"
Me.Print " Descent = " & Descent & " points"
Me.Print " External Leading = " & ExternalLeading & " points"
Me.Print " Total Height (Ascent + Descent) = " _
         & Ascent + Descent & " points"
Me.Print " VB TextHeight returns " & txtHeight & " points"
Me.Print " The point size is the Ascent plus the Descent";
Me.Print " minus the Internal Leading = ";
Me.Print Ascent + Descent - InternalLeading
Me.FontTransparent = True
Me.Print
Me.Print " Internal Leading is from the top down to the";
Me.Print " yellow line."
Me.Print " Ascent is from the top down to the green line";
Me.Print " (called the Baseline)";
Me.Print " and it includes the Internal Leading."
Me.Print " Descent is from the green line down to the blue";
Me.Print " line."
Me.Print " The overall height is equal to Ascent plus";
Me.Print " Descent and is equal to the VB TextHeight."
Me.Print " The point size is from the yellow line down to";
Me.Print " the blue line and is equal to Ascent plus Descent";
Me.Print " minus Internal Leading."
If mymetrics.tmExternalLeading > 0 Then
  Me.Print " The External Leading is from the blue line to";
  Me.Print " the red line and is ignored."
Else
  Me.Print " This font has zero external leading."
End If
Me.Print " The white line is typically 0.48 of the TextHeight";
Me.Print " down from the top and runs approximately through the ";
Me.Print " centre of capital letters and numerals."
Me.Print " NOTE: If you use a negative value (normal practice)";
Me.Print " for the desired font size when using the ";
Me.Print " CreateFontIndirect API the system will attempt"
Me.Print " to give you a font where the distance from the yellow";
Me.Print " line to the blue line is equal to the requested value. ";
Me.Print " If you use a positive value the"
Me.Print " system will attempt to give you a font where the overall";
Me.Print " height is equal to the requested value. In both cases";
Me.Print " however all of the above elements "
Me.Print " will be present. (Using a positive value is effectively ";
Me.Print " the same as asking for a slightly smaller font.)"
End Sub




0
Mike
3/28/2010 4:45:03 PM
"Mike Williams" <Mike@WhiskyAndCoke.com> wrote in message 
news:OIiWmLlzKHA.3884@TK2MSFTNGP06.phx.gbl...

> It seems that the Cambria Math font has recently acquired an extremely 
> large Ascent and Descent. Has it perhaps always been that way and I've 
> never noticed it before, or is it something recent, perhaps a Vista thing?

I wrote an owner-draw combo box in...well, let's just say "another 
language"...to draw each font name in its own font and I ran into exactly 
the same thing you're seeing. XP SP2. 


0
Jeff
3/29/2010 8:52:59 PM
Thanks Mike, that's very helpful.

Two questions, though. As it says the ascent includes the internal
leading. This is not true normally in font metrics, right? And there's
a white center line, but there's no x-height?
0
sven2000
4/7/2010 8:56:09 PM
"sven2000" <sven2000@gmail.com> wrote in message 
news:72a6c676-4657-4ac3-912e-6249b344f500@30g2000yqi.googlegroups.com...

> Thanks Mike, that's very helpful.
> Two questions, though. As it says the ascent includes the
> internal leading. This is not true normally in font metrics,
> right?

In the TextMetric structure the tmAscent is from the base line to the top 
and the tmDescent is from the base line to the bottom. The total of these 
two is the tmHeight, which is the total height and which is the same as 
would, for example, be returned by the VB TextHeight function. The 
tmInternalLeading is measured from the top and is contained within the 
overall Height (usually quite small and almost always entirely within the 
Ascent portion). In most fonts that I've seen it usually extends down to 
just above the top edge of the capital letters.

    http://msdn.microsoft.com/en-us/library/dd145132(VS.85).aspx

> And there's a white center line, but there's no x-height?

The TEXTMETRIC structure (used by the GetTextMetrics function) does not 
include an entry for the x-height. There is an x-height entry in the more 
detailed OUTLINETEXTMETRIC structure (as used by the GetOutlineTextMetric 
function) but according to the MS docs the x-height entry is not supported. 
If you want to get an idea of the x-height then you could use the 
GetGlyphOutline function which can tell you the size and position within the 
cell of the "black box" that exactly fits over the shape of the glyph of any 
character you pass to it. However, having said that, I think that there are 
some fonts where, as odd as it seems, the character "x" is not actually the 
same height as the x-height of the font.

I'm pretty sure that GDI+ can tell you the x-height of most fonts, and also 
other things such as the CapsHeight etc, but I don't "do" GDI+ so I can't 
help you on that one.

Mike


0
Mike
4/7/2010 11:35:22 PM
"sven2000" <sven2000@gmail.com> wrote in message 
news:72a6c676-4657-4ac3-912e-6249b344f500@30g2000yqi.googlegroups.com...

> Thanks Mike, that's very helpful.
> Two questions, though. As it says the ascent includes
> the internal leading. This is not true normally in font
> metrics, right?

Further to my previous reponse to this question, I've just realised what you 
actually meant by it.

In my previous response I assumed that you were asking me to confirm, or 
that you were querying, what I had said in my earlier messages regarding 
GDI32, and so when I answered it I reaffirmed that the Internal Leading as 
far as the GDI GetTextMetrics function is concerned is included in the 
Ascent and actually forms a part of it, which is in fact the case as is 
shown in the example code I had earlier posted which gives a graphical 
repesentation of the information returned by the GDI32 GetTextMetrics 
function.

However, I've just realised that you had actually accepted that point but 
that you were saying the inclusion of the Internal Leading within the Ascent 
is not normally the practise generally in font metrics, rather than 
specifically in Windows GDI. In that case you are of course correct because 
(as far as I know) most systems other than Windows GDI which deal with fonts 
do no treat them in that manner, and the various "leadings" are /not/ 
considered to be part of either the Ascent or the Descent of a font, which 
makes sense of course because the "leadings" actually were lumps of lead 
back in the old days, although in recent years people seem to be moving away 
from the "leading" term and using other names for it.

Certainly the people at Apple do not see any Leading as being part of the 
Ascent, and neither do most people, I would suspect. So, you're right in 
that respect, and Windows (at least Windows GDI32) is the "odd one out" (and 
it would appear that GDI+ and .Nxt are "the odd one out" as well, as 
mentioned below. It seems to be a general "MS Windows" thing).

Whether Micro$oft intended it that way, or whether it was just something 
which came about purely because of the fact that no one person is really in 
charge of anything at Micro$oft, is anybody's guess! It's not always easy to 
find really detailed information about stuff like that on MSDN, and when you 
do find it you often find that one piece of information entirely contradicts 
another, even on the same page! Micro$oft have never been any good at 
writing help files or documentation in a way that is really helpful, and 
they are often either so incomplete, or sometimes so "overly complete" in 
some respects and "incomplete" in other respects, that they are worse than 
useless!

I've just had a look for some information on MSDN to see what I can find 
regarding Ascent and Descent and Leading etc (and how it is seen by 
Micro$oft) and to see whether it has changed since GDI32, but (as usual) I 
came away more confused than I was when I went there! The reason, as usual, 
is that the MSDN page I found contains conflicting information!

    http://msdn.microsoft.com/en-us/library/ms533824(v=VS.85).aspx

Like most Micro$oft things these days, it deals with GDI+ rather thanGDI32 
(although that of course is specifically what I was looking for) and the 
examples are in .Nxt so I cannot (or rather I am not prepared to!) try them 
for myself.

If you look at the nice little drawings at the top of the page (the drawings 
of the letter Q) you will see quite clearly that /in the drawings/ the 
Ascent and Descent together form the font size, and they do /not/ inlcude 
any form of leading (either internal or external). So, judging solely by the 
labelled drawings it looks as though Micro$oft have had a change of heart 
and have moved to comply with Apple and most other people in this respect . 
..

.. . However, if you look at the output from the Micro$oft example .Nxt code 
on the very same page (which uses GDI+ stuff and the output of which is 
shown below the code) you will see a different story. Font sizes are 
normally expressed in pixels (rather than points) in .Nxt and also GDI+ 
allows floating point values when dealing with them, so there are some 
differences but it is easy to account for them. In the example they have 
used a 16 pixel Arial font and the output shows the font size as being 16.00 
pixels, the Ascent as being 14.48 pixels and the Descent as being 3.39 
pixels. So, the total of the values returned for the Ascent and Descent is 
18.19 pixels, 2.19 pixels greater than the font size, and between them they 
clearly include the "leading" (totally contrary to the labelled drawing of 
the letter Q at the top of the page!). In fact, if you do a bit of peddling 
around in VB6 using very large font sizes to compensate for the fact that we 
cannot use floating point values with GDI32 font stuff you will see that for 
the Arial font the typical Internal Leading is 0.12 times the font size 
(when both are expressed in the same units). So, for a typical 16.00 pixel 
Arial font we would expect the Internal Leading to be 1.92 pixels, giving a 
total of 17.92 pixels. Therefore, the total of Ascent and Descent returned 
by the .Nxt GDI+ code (18.19 pixels) clearly includes /all/ of the expected 
value for Internal Leading. In fact it might even include the External 
Leading as well, which is a much smaller amount and which is ignored in VB6 
and GDI32.

Naturally you need to make allowances for the differences between the two 
systems and for the fact that the font stuff in GDI+ uses floating point 
values whereas GDI32 does not, but it is quite clear that the drawing at the 
top of that MSDN page shows that the Internal Leading (or any other kind of 
leading) is NOT included in the Ascent and Descent, whereas the actual .Nxt 
code on the very same MSDN page and the GDI+ results it returns clearly 
shows quite the opposite!

Typical Micro$oft stuff, that ;-)

Here (below) is a "rough and ready" modification of the code I posted 
previously which I have changed to use pixels throughout instead of points 
and which displays the VB6 (GDI32) details of a 160 pixel Arial font. You 
should be able to compare the output of it with the output of the GDI+ 16 
pixel Arial font .Nxt code shown on the MSDN page and you'll see what I mean 
(the outputs of the code below should of course be divided by 10 in your 
head to make the comparison . . I've avoided doing the "divide by ten" in 
code so as to make it obvious that it is pulling in the correct results). 
Whoever made and labelled the drawings of the font characters on that MSDN 
page clearly knows what the Ascent and Descent of a font SHOULD be, but he 
then appears to have totally ignored the output of the code he included on 
the same MSDN page, which clearly shows that Windows thinks quite the 
opposite!

Mike

Option Explicit
Private Declare Function GetTextMetrics Lib "gdi32" _
  Alias "GetTextMetricsA" (ByVal hdc As Long, _
  lpMetrics As TEXTMETRIC) As Long
Private Type TEXTMETRIC
  tmHeight As Long
  tmAscent As Long
  tmDescent As Long
  tmInternalLeading As Long
  tmExternalLeading As Long
  tmAveCharWidth As Long
  tmMaxCharWidth As Long
  tmWeight As Long
  tmOverhang As Long
  tmDigitizedAspectX As Long
  tmDigitizedAspectY As Long
  tmFirstChar As Byte
  tmLastChar As Byte
  tmDefaultChar As Byte
  tmBreakChar As Byte
  tmItalic As Byte
  tmUnderlined As Byte
  tmStruckOut As Byte
  tmPitchAndFamily As Byte
  tmCharSet As Byte
End Type
Private Const DEFAULT_QUALITY As Byte = 0
Private Const DRAFT_QUALITY As Byte = 1
Private Const NONANTIALIASED_QUALITY As Byte = 3
Private Const ANTIALIASED_QUALITY As Byte = 4
Private Const CLEARTYPE_COMPAT_QUALITY As Byte = 5
Private Const CLEARTYPE_QUALITY As Byte = 6

Private Sub Form_Load()
' A graphical representation of the various
' Font details (by Mike Williams).
Dim fName As String, pixelSize As Single, y As Single
Dim sampleText As String
fName = "Arial"
Me.ScaleMode = vbPixels
Me.Font.Name = fName
' set font size to 160 pixels (not points)
pixelSize = 160
' set point size so as to achieve a 160 pixel font
Me.Font.Size = Me.ScaleY(pixelSize, vbPixels, vbPoints)
Me.Font.Italic = False
Me.Font.Bold = False
sampleText = "QtjM"
Dim mymetrics As TEXTMETRIC, savey As Single
Dim InternalLeading As Single
Dim Ascent As Single
Dim Descent As Single
Dim ExternalLeading As Single
Dim txtHeight As Single
Me.AutoRedraw = True
Me.Show
Me.BackColor = vbWhite
Me.Width = Me.ScaleX(900, vbPixels, vbTwips)
Me.Height = Me.ScaleY(680, vbPixels, vbTwips)
Me.Line (0, 0)-(Me.ScaleWidth, Me.ScaleHeight), _
  RGB(200, 100, 255), BF
txtHeight = Me.TextHeight("some text")
GetTextMetrics Me.hdc, mymetrics
InternalLeading = mymetrics.tmInternalLeading
Ascent = mymetrics.tmAscent
Descent = mymetrics.tmDescent
ExternalLeading = mymetrics.tmExternalLeading
Me.CurrentX = 0: Me.CurrentY = 0
Me.FontTransparent = True
Me.Print sampleText;
y = Me.TextHeight("x")
Me.Font.Name = "Times New Roman"
Me.Print "  " & sampleText;
Me.CurrentY = Me.CurrentY + y
Me.CurrentX = 0
Me.Font.Name = "Arial"
Me.FontTransparent = False
Me.Print sampleText;
Me.Font.Name = "Times New Roman"
Me.Print "  " & sampleText;
Me.CurrentY = Me.CurrentY + y
savey = Me.CurrentY
Me.Line (0, InternalLeading)- _
  (Me.ScaleWidth, InternalLeading), vbYellow
Me.Line (0, Ascent)- _
  (Me.ScaleWidth, Ascent), vbGreen
Me.Line (0, Ascent + Descent)- _
  (Me.ScaleWidth, Ascent + Descent), vbBlue
If mymetrics.tmExternalLeading > 0 Then
  Me.Line (0, Ascent + Descent + ExternalLeading)- _
  (Me.ScaleWidth, Ascent + Descent + ExternalLeading), vbRed
End If
' Capital letters (A - Z) and numbers (0 - 9)in most fonts
' start a little after the External Leading and extend down
' to the Ascent line, and the centre of those characters is
' usually about 0.48 of the overall "TextHeight" down from
' the top of the character cell. The following code will
' therefore draw a line approximately through the centre
' of these characters on most (but  not all) fonts.
Me.Line (0, txtHeight * 0.48)- _
  (Me.ScaleWidth, txtHeight * 0.48), vbWhite
Me.CurrentX = 0
Me.CurrentY = savey
Me.Font.Name = "Arial"
Me.Font.Size = 8
Me.Print " The following details are for Arial " _
         & Format(pixelSize) & " pixels (The Times New Roman is also 
displayed purely so you can compare the Q glyph)"
Me.Print " Internal Leading = " & InternalLeading & " pixels"
Me.Print " Ascent = " & Ascent & " pixels"
Me.Print " Descent = " & Descent & " pixels"
Me.Print " External Leading = " & ExternalLeading & " pixels"
Me.Print " Total Height (Ascent + Descent) = " _
         & Ascent + Descent & " pixels"
Me.Print " VB TextHeight returns " & txtHeight & " pixels"
Me.Print " The font size is the Ascent plus the Descent";
Me.Print " minus the Internal Leading = ";
Me.Print Ascent + Descent - InternalLeading & " pixels"
Me.FontTransparent = True
Me.Print
Me.Print " Internal Leading is from the top down to the";
Me.Print " yellow line."
Me.Print " Ascent is from the top down to the green line";
Me.Print " (called the Baseline)";
Me.Print " and it includes the Internal Leading."
Me.Print " Descent is from the green line down to the blue";
Me.Print " line."
Me.Print " The overall height is equal to Ascent plus";
Me.Print " Descent and is equal to the VB TextHeight."
Me.Print " The point size is from the yellow line down to";
Me.Print " the blue line and is equal to Ascent plus Descent";
Me.Print " minus Internal Leading."
If mymetrics.tmExternalLeading > 0 Then
  Me.Print " The External Leading is from the blue line to";
  Me.Print " the red line and is ignored."
Else
  Me.Print " This font has zero external leading."
End If
Me.Print " The white line is typically 0.48 of the TextHeight";
Me.Print " down from the top and runs approximately through the ";
Me.Print " centre of capital letters and numerals."
Me.Print " NOTE: If you use a negative value (normal practice)";
Me.Print " for the desired font size when using the ";
Me.Print " CreateFontIndirect API the system will attempt"
Me.Print " to give you a font where the distance from the yellow";
Me.Print " line to the blue line is equal to the requested value. ";
Me.Print " If you use a positive value the"
Me.Print " system will attempt to give you a font where the overall";
Me.Print " height is equal to the requested value. In both cases";
Me.Print " however all of the above elements "
Me.Print " will be present. (Using a positive value is effectively ";
Me.Print " the same as asking for a slightly smaller font.)"
End Sub



0
Mike
4/9/2010 3:46:53 PM
"sven2000" <sven2000@gmail.com> wrote in message 
news:72a6c676-4657-4ac3-912e-6249b344f500@30g2000yqi.googlegroups.com...

> As it says the ascent includes the internal
> leading . . .

Actually, looking at what I just posted I seemsto have got one of the 
numbers just slightly wrong (had so many different windows open here!). 
Regarding the details on the MSDN page I was talking about I said . .

> In the example they have used a 16 pixel Arial font and the output
> shows the font size as being 16.00 pixels, the Ascent as being 14.48
> pixels and the Descent as being 3.39 pixels. So, the total of the
> values returned for the Ascent and Descent is 18.19 pixels . .

The sum of 14.48 and 3.39 for the GDI+ (.Nxt) code on that page is of course 
17.87 (don't know where I got that 18.19 from!) and that 17.87 is pretty 
much exactly the same as the total of the Ascent and Descent as would be 
returned by our VB (GDI32) code after allowing for the fact that we cannot 
use floating point values (because a ten times larger GDI32 font returns 178 
pixels for the sum of Ascent and Descent). So, that shows even more clearly 
that Micro$oft are still including the Internal Leading as part of the 
Ascent and Descent in GDI+ and .Nxt, just as they do in GDI32, and that they 
are still apparently "the odd one out" in the font business. The only real 
difference is the fact that the GDI+ (.Nxt) code on the MSDN page also shows 
a figure of 18.40 pixels for the total "line spacing" (the distance between 
one line of text and the next). That is a difference of 0.53 pixels from the 
17.87 sum of Ascent and descent (which includes the Internal Leading) and it 
is certainly more than just coincidence (if you check the output from the 
VB6 code I posted or if you write your own) that 0.53 pixels is pretty much 
exactly what you would expect for the "External Leading" (as opposed to the 
"Internal Leading") of a 12 pixel Arial font.

So, clearly Microsoft /do/ still include the Internal Leading in the Ascent 
and Descent (and still continue to do so in GDI+ and .Nxt) and the only 
difference is that in GDI+ and .Nxt they also include the relatively small 
External Leading value in the total line spacing (something which VB6 and 
GDI32 does not do).

So, after all that "waffle" in all these messages, the answers to your 
supplementary question are:

    Yes, Micro$oft /do/ include the Internal Leading within the Ascent in 
GDI32, and . .

    Yes, they apparently continue to do so in GDI+ and .Nxt, and . .

    Yes, they are unusual in that respect ;-)

Mike





0
Mike
4/9/2010 4:57:40 PM
Hi Mike, Thanks for the elaborate replies.I've been looking into it a
bit and I found it to confusing. I decided to just print the glyph on
the form and use the point method to scan the glyph for all relevant
metrics and store them in a table.

0
sven2000
4/30/2010 3:32:21 PM
Reply:

Similar Artilces:

font substitution
I accidently substituted curlz for bodini and clicked make permanent. Now every document, including a 15 year old document shows bodini as curlz. I've tried deleting all of the preferences I could find and even deleted Microsoft Office and reinstalled it. The problem still exists. Short of buying a new computer, does anyone have a solution. Mks Hello - No need to panic :)... Open an existing doc where the substitution was made, then go to Word Menu>Preferences>Compatibility. Click the Font Substitution button & You'll find Bodoni listed in the window. Select it from th...

Outlook2003 problems.
I have OL2003 on both a laptop and office machine at home. OL is set identically on both machines and the email accounts (Two) are set the same as well. my problem is that my office machine will not send onto one account. the laptop sends fine. could it be a setting in Norton? Also last weekend we seem to have lost 6/7 mails from customers who claim to have mailed orders and not recieved any bounce back but we also recieved no emails. is this normal it was with two isp's. ...

Drop down box problem
Please can someone help me!!! I am trying to inset a drop down box int an excel spreadsheet but haven't got a clue whether I use a list box o a combo box. I want it to display first, second, third, fourth in th drop down menu so that the user can sleect one of these. The thing is don't know how to put the values in the box! Your help would be muc appreciated! :- -- Message posted from http://www.ExcelForum.com Hi use the Data / Validation - List option ... click in the cell where you want the drop down, choose Data / Validation from the menu, choose List, and in the source line ty...

Problem with xy scatter with dates
I am trying to create an x-y scatter chart where both the x values and the y values are dates. I highlight the 2 adjacent columns of date data and click on Insert>Scatter. Instead of a scatter graph, I get a line chart with 2 lines (the two data columns). The x values on the graph are simply a count of the data points as in a line chart. If the 2 columns of data are not dates, I get the correct scatter chart, but not if the x-values are dates in which case I get a line chart. How can I get a scatter chart with both x-values and y-values as dates? You could select just the Y val...

OUTLOOK Problem: GetIUMS Entry point not found
Keep getting error message titled "MICROSOFT OFFICE OUTLOOK.EX: Entry Point not found" and saying "The procedure entry point GetIUMS could not be located in the dynamic link library MSDART.DLL" I've found that hitting enter 7-8 times will get me passed this error, and I haven't found any reference to this probelm on the "assistance" screens. Can anyone help? rwlinds@comcast.net Visit Windows Update and get the latest version of MDAC. --� Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. Due to the (insert ...

How do I save data with different colored fonts in EXCEL 2003?
I have a rather large spreadsheet with some data set to different colors that mean different thigs to those of us that use it. For some reason, these color changes are not being saved when I save my spreadsheet. When I open my spreadsheet again, the colors are gone. Which version of Excel are you using? Are you sure that you're saving the spreadsheet as Excel (and not as some other file type which Excel can read)? Is the resultant file keeping a suffix of ".xls"? If not, then the data is being saved but not the formatting specifications. Next time you save the ...

Check box problem
I want to include a check box in a form I have created. It appears that to make the box checkable by users, i.e. by clicking on it, I have to lock the table/form. However, doing this prevents anyone entering text on the others parts of the table/form. Is there any way to make the box checkable without rendering the rest of the form locked please? (One workaround is to double click the box and click on the Checked option. However, this is not really a very user friendly solution for what surely should be simple.) V For a form that includes check boxes, you must add text f...

Font color #3
How do I change font color in an Excel spreadsheet so it will remain until I change it again. Clicking on font color only seems to change it for one cell. Thanks, Select all the cells whose font color you wish to change, then change the font color. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "aberry1014" <aberry1014@discussions.microsoft.com> wrote in message news:E7B8E2D9-A876-44D8-9108-0DE0C8AFCEEB@microsoft.com... > How do I change font color in an Excel spreadsheet so it will > remain until I > chang...

Conditional formatting with dates formula problem.
Hello. I appreciate help on this topic. I'm very new to excel's conditional formatting capabilities and I need help on the following: I have a worksheet where I am using columns A and B to be fashioned into a type of "reverse" library checkout card; I want to flag when 120 days have passed since an item has been checked out. All cells are blank with the exception of the formatting applied to cells in column A. For example, Condition 1 on cell A1 has the formula: =IF(ISBLANK(B1),(A1-TODAY())<120) **I've also tried =IF(ISBLANK($B1),($A1-TODAY())<120) My objecti...

POP3/IMAP co-existence problem
I've been using IMAP with Exchange 2000 server for some time, recently I started POP3 virtual server for testing purpose. Its ok to send out mails, but when replying to the sending account, error occured: The following recipient(s) could not be reached: <user> on <date> <time> A configuration error in the e-mail system caused the message to bounce between two servers or to be forwarded between two recipients I configured nothing except starting the POP3 virtual server. Can anyone help? Thanks Vincent "Vincent" <Vincent@discussions...

New Record Problem when filtering
I'm using Access 2003 and have what at first seems like a common problem. On one of my forms if a user hits the scroll button on the mouse, it scrolls to a new record which then causes problems. I don't have sufficient rights to deploy a dll file so I got around it by changing the AllowAdditions setting to "No". Theoretically that should have worked and indeed it does if I open up a form directly. But in this database I often open up a form to a particular record using the "Where Condition" argument of the DoCmd.OpenForm command. When I do that, it opens...

MS CRM
How to write organization name during instalation ? I have write as in IG - "adventure-works" and adding license key was apeared as incorrect. I do not uderstand why ? Are there another needs ? Thanks for help. Mariusz OK. I have resolved problem. ;o)Mariusz U�ytkownik "Mariusz Slany" <nospam__marsla@op.pl> napisa� w wiadomo�ci news:emdFNbvkDHA.2676@TK2MSFTNGP11.phx.gbl... > How to write organization name during instalation ? > I have write as in IG - "adventure-works" and adding license key was apeared > as incorrect. > I do not uderstand...

Viewing Outlook Messages in a Larger Font (After you click to open
I have been able to change my views to a larger font in outlook, except when I click on the message to open it, the message itself does not appear in a larger font. Please advise if this is possible, and if so, how. Thank you ...

Sync Problem MS Money --> PocketPC
Hi, When MS Money for PocketPC on my new Dell Axim x50v tries to sync with my Money-file on the desktop PC (MS Money De Luxe 2004), Active Sync asks for a password. But when I write the password (plain letters) I use when I open MS Money on the desktop, Active Sync tells me that it isn't correct! Strange ... Any clues?? Thanks in advance, Peter from Sweden Does your PDA use a password (after X minutes)? It's that password vs. your MSN passport. "Peter Fowelin" <PeterFowelin@discussions.microsoft.com> wrote in message news:74B36003-C10F-4751-A981-E925F0931...

Problem bringing up Group Policy on Domain Controller
I loaded the Group Policy snap in on my xp machine and got the following error on my Server 2000 domain controller: "The following entry in the [strings] section is too long and has been truncated" error message when you try to modify or to view GPOs in Windows server 2003, Windows XP Professional or Windows 2000. This is a well-documented and there is a hot fix. After I applied the hot fix the error was gone, but I still cannot access some group policies. Why and what can I do. My boss likes to work ar the server console and he cannot do that and is furious. You need to...

Coding problems with User defined Visible Property
Hi I have a report that my users supply to seavel groups. Some do not require certain fields so these will be hidden by using a checkbox on the relevant form. At the moment, I am using the following in code builder: Me.txt[recordNumber].Visible = Forms![Pdoptions]!chk[recordnumbersvisible] Which isn't doing the job. I've checked all the names and they are correct. This code gives me eaither a syntex error, or an expected end error, but I can find no problem. The code is sitting in the "on format" property of the detail section header, of the report I need this to work in. If...

mktime problem
Apologies if this is the woring newsgroup, I have done my best to find the right place. Please point me to a better place if appropriate. mktime seems to subtract an hours (3600 secs) from it's outputs. I ma using Visual Studio C++ 6.0 S.P. 5 on XP in the French timezone, currently we are in DST. So, for example, when I run the code below using mktime, it outputs the wrong answer: 10 hours is 36000 secs, not 32400 which is the answer it gives. What gives? Thanks, Neil #include <stdio.h> #include <time.h> void show(struct tm *tms) { fprintf(stdout, "%d %d %d %02d:%02...

Gridline problem
I am using Excel 2002 and it used to work fine when printing gridlines. I am using a Brother MFC printer and the gridlines used to print fine when I had it connected through a serial port. I've recently switched it to a USB cable and now gridlines never print, all I get is a outline around my entire area, but nothing in between. I contacted Brother and they said they thought this was a software issue. I'm not so sure, but thought I would try this anway. If anyone could help, it would be greatly appreciated. BTW, I have checked to print gridlines under File, Page Setup. W...

Problems Getting a Field to Work in a New Mail Message form
I have Outlook 2000 SR-1 using IMO (Internet Mail Only - not Exchange Server). Does anyone know of a way to make sure the From: field appears in a new mail message? For reasons too lengthy to get into, it would be very helpful for me to see the From: field (with my default email address already filled in, of course) as well as they typical To:, CC: and Subject: fields when composing a new email. I did try to create a new form (Tools >Forms >Design a Form >Message) but when I used it, the default email address did not appear. What am I doing wrong? Thanks, Sangrateo SangrateoATanonymo...

Personal.xlsb problems
If I open xl2007 via the excel.exe (or shortcut) it will load the macros contained in the personal.xlsb file. However, if I click on an existing .xlsx file, the personal.xlsb file is not loaded (not even hidden). I checked my add-ins to ensure that the personal.xlsb file is disabled (thinking excel might have thought it was corrupt), but it doesn't show disabled. So, why does xl2007 load the macros if I open a new workbook, but not when I open an existing workbook? Thanks! ...

font list
Is there a way to get a list of all the fonts used in a document? On Jun 1, 6:25=A0pm, "Peter T. Daniels" <gramma...@verizon.net> wrote: > Is there a way to get a list of all the fonts used in a document? Did this get lost in the changeover? The transition into forums doesn't seem to be finished yet. -- Stefan Blom Microsoft Word MVP (Message posted via msnews.microsoft.com) "Peter T. Daniels" <grammatim@verizon.net> wrote in message news:3a075bf7-0106-458f-8390-dae4a97668fb@c11g2000vbe.googlegroups.com... On Jun 1, 6:25 pm, "...

Can't set default font for envelopes
I've been able to set default fonts for Normal.doc but envelopes keeps forgetting the default. While in Mailing/Envelopes - I highlight and right click on the address I entered. I select the font I want (Trebuchet MS) and select DEFAULT at bottom left. The message: "You are about to change the default font to (Default) Trebuschet MS,. Do you want to change to affect all new documents based on the Normal Template?" I select YES - It doesn't work. And the Normal.docx has alread had the default set to Trebuchet MS. and seems to be holding. An earlier ...

Address list problems after migration
Hi, I found a recurring problem with my address list each time I migrate my Outlook PST files to a newly-installed PC. Before each reinstall, I will use the "Save My Settings Wizard" to export my settings and then import my mails, calendar and contacts using the Import function in Outlook. After each time this is done, I am able to access my contacts in the Contacts section. But each time I create a new mail and attempt to choose a contact in the "Select Names" window, I get an error that says : "The address list could not be displayed. The Contacts folder associated...

Is anyone else having problems with in-transits?
Hello: Is anyone else on GP 10.0 who is not on service pack 4 having issues with the use of lot-based in-transit transactions? It seems that everytime there is a lot-based in-transit that needs to be received in, the quantity available for the lot is showing "0" when there is in fact a ton of available stock at that lot. Again, is anyone else out there seeing this? I wish that I had not mentioned this new in-transit feature to this client. It has been nothing but headaches. At least, that's the case for any items attached to lots. childofthe1980s With you Child, I ha...

probleme pour envoyer certain mail
Bonjour, Je rencontre un probleme sur certain mail qui restent dans la boite d'envois d'outlook XP. Ce probleme se produits la plus part du temps lorsque le mail comporte des pieces jointes. Comment puis je faire pour remedier a mon probleme ? Merci de votre aide ; Francois. Bonjour fchiausa -- essai microsoft.public.fr.outlook. Bonne chance! -- Jocelyn Fiorello MVP - Outlook *** Messages sent to my e-mail address will NOT be answered -- please reply only to the newsgroup to preserve the message thread. *** In news:ebde804e.0404190723.2740456e@posting.google.com, fchiausa wrote...