How to determine Height/Width of Font

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Can someone please help!!

I am trying to figure out what a font is?
Assume I am working with a fixed font say Courier 10 point font

Question 1: What does this mean 10 point font
Question 2: How do I determine how many characters I can get on a line
Question 3: How do I determine how many lines I can get on a page. Assume no margins
Question 4: Does their exist some kind of refernce table that will equate a font with chars/line and #lines/page

Thank

Ada


I've read where there are 72 points in an inch but I think this equates to height and not widt
 
Unless you are using a monospace font, you can't pre-determine the information
that you want. (In a monospace font, the character cell width is the same for
all glyphs (characters) in the font.)

Most fonts are *not* monospace, which means that the character cell widths are
different for the different glyphs. For example, W is wider than i.
Additionally, kerning comes into play, which essentially means that when glyphs
are drawn, they may actually be spaced closer together then their actual width.

About the only way to really determine what will fit on a line/page is to draw
it (or use the draw routines to calculate) the actual text being represented.
Look up DrawText DT_CALCRECT in MSDN to see numerous articles on the topic
(most will be C++, but will give you an idea of what you need to do).

If you are using a monospace font, you can get the cell dimensions from the
text metrics.
 
Julie:

First, thansk for your reply.
But I am unfamiliar with C++.
Please correct me if I am wrong, but I thought that a Courier was a fixed width font. Meaning the letter w takes up the same space as the letter i.

Anyway, I'm surprised that their isn't a cross reference table or some sort or fomula.

Are you awar of any additional info?

Adam





----- Julie J. wrote: -----

Unless you are using a monospace font, you can't pre-determine the information
that you want. (In a monospace font, the character cell width is the same for
all glyphs (characters) in the font.)

Most fonts are *not* monospace, which means that the character cell widths are
different for the different glyphs. For example, W is wider than i.
Additionally, kerning comes into play, which essentially means that when glyphs
are drawn, they may actually be spaced closer together then their actual width.

About the only way to really determine what will fit on a line/page is to draw
it (or use the draw routines to calculate) the actual text being represented.
Look up DrawText DT_CALCRECT in MSDN to see numerous articles on the topic
(most will be C++, but will give you an idea of what you need to do).

If you are using a monospace font, you can get the cell dimensions from the
text metrics.
 
In c#, you can use the Graphics objects MeasureString property to measure
how many pixels a a string will take given a particular font.

You can't really have a "table" of chars/line or lines/page even with a
monospace font because you'd need different tables based on:

1) what font are you in?
2) what size font is it?
3) is it bold, italic?
4) what size is the client of the window?
5) what size fonts does the user have? (large / small / 132%)

I'm sure people can come up with lots more, and this doesn't touch on
kerning or cleartype settings, etc. Basically, use measurestring or
similar.


Adam said:
Julie:

First, thansk for your reply.
But I am unfamiliar with C++.
Please correct me if I am wrong, but I thought that a Courier was a fixed
width font. Meaning the letter w takes up the same space as the letter i.
Anyway, I'm surprised that their isn't a cross reference table or some sort or fomula.

Are you awar of any additional info?

Adam





----- Julie J. wrote: -----

Unless you are using a monospace font, you can't pre-determine the information
that you want. (In a monospace font, the character cell width is the same for
all glyphs (characters) in the font.)

Most fonts are *not* monospace, which means that the character cell widths are
different for the different glyphs. For example, W is wider than i.
Additionally, kerning comes into play, which essentially means that when glyphs
are drawn, they may actually be spaced closer together then their actual width.

About the only way to really determine what will fit on a line/page is to draw
it (or use the draw routines to calculate) the actual text being represented.
Look up DrawText DT_CALCRECT in MSDN to see numerous articles on the topic
(most will be C++, but will give you an idea of what you need to do).

If you are using a monospace font, you can get the cell dimensions from the
text metrics.
equates to height and not width
 
Phil:

OK but let's say I know my font. Its Courier 10 point.

Do you know what this means Courier 10 point?
I know Courier is a fixed font. But I don't know what 10 point means. is it 10 points high? What about the width?
Can you define what a 10 point COurier font is in terms of height, width?

----- Philip Rieck wrote: -----

In c#, you can use the Graphics objects MeasureString property to measure
how many pixels a a string will take given a particular font.

You can't really have a "table" of chars/line or lines/page even with a
monospace font because you'd need different tables based on:

1) what font are you in?
2) what size font is it?
3) is it bold, italic?
4) what size is the client of the window?
5) what size fonts does the user have? (large / small / 132%)

I'm sure people can come up with lots more, and this doesn't touch on
kerning or cleartype settings, etc. Basically, use measurestring or
similar.


Adam said:
Julie:
But I am unfamiliar with C++.
Please correct me if I am wrong, but I thought that a Courier was a fixed
width font. Meaning the letter w takes up the same space as the letter i.
information
that you want. (In a monospace font, the character cell width is the same for
all glyphs (characters) in the font.) widths are
different for the different glyphs. For example, W is wider than i.
Additionally, kerning comes into play, which essentially means that when glyphs
are drawn, they may actually be spaced closer together then their actual width. is to draw
it (or use the draw routines to calculate) the actual text being represented.
Look up DrawText DT_CALCRECT in MSDN to see numerous articles on the topic
(most will be C++, but will give you an idea of what you need to do). from the
text metrics.
equates to height and not width
 
Yes, courier is a monospace font. There are several flavors of courier, each
may be slightly different in one respect or another.

As for some table or cross reference, I'm not aware of any such beast.

Your best bet is to research font articles in MSDN to get an understanding of
how fonts/typefaces work in Windows, and how to get the the widths that you are
after. A great article is:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dngdi/html/msdn_fontmap.asp
 
Yes, 10 points high, or 10/72 of an inch.

Which courier font are you talking about. There is Courier New (which is a
TrueType font) and Courier (which is a screen font).
 
Julie

I am referring to Courier and not Courier New

I now understand how the heigth is determined but what about the width
DO you know how if their exists a formula to determine how many characters/line I can get with a Courier 10 point font on a 8.5 width paper

Adam ----- Julie J. wrote: ----

Yes, 10 points high, or 10/72 of an inch

Which courier font are you talking about. There is Courier New (which is
TrueType font) and Courier (which is a screen font)

Adam wrote
Phil
OK but let's say I know my font. Its Courier 10 point
Do you know what this means Courier 10 point
I know Courier is a fixed font. But I don't know what 10 point means. is it 10 points high? What about the width
Can you define what a 10 point COurier font is in terms of height, width
----- Philip Rieck wrote: ----
In c#, you can use the Graphics objects MeasureString property to measur
how many pixels a a string will take given a particular font
You can't really have a "table" of chars/line or lines/page even with
monospace font because you'd need different tables based on
1) what font are you in
2) what size font is it
3) is it bold, italic
4) what size is the client of the window
5) what size fonts does the user have? (large / small / 132%
I'm sure people can come up with lots more, and this doesn't touch o
kerning or cleartype settings, etc. Basically, use measurestring o
similar
 
Adam:

If you are worried about this, I assume that you are either writing to the
printer, or painting a control or surface, is that right? Are you working
with the Graphics object in System.Drawing? If so, check the
MeasureString() method. It might be what you are after.

In order to use this, you have to know the string that you are writing in
addition to the font, and you have to have the Graphics Object applicable to
your surface (which is basically like having the Handle to the Device
Context of the device that you are writing to) It returns a SizeF
structure, which represents the height and width required, in pixels.


Adam said:
Julie:

I am referring to Courier and not Courier New.

I now understand how the heigth is determined but what about the width?
DO you know how if their exists a formula to determine how many
characters/line I can get with a Courier 10 point font on a 8.5 width
paper?
 
Okay, let's assume you're talking about a physical print out.

a point is a measurement of size such that:
12 pt = 1 pica
1 pt ~ 1/72 of an inch.
(Note that on a monitor, however, the concept of an "inch" is vague at
best. )

So a 10 point typeface should render as 5/36" high, giving about 7 lines per
inch. Note that line spacing will lower the number of lines per inch you
get.

For width, you need to know the pitch - pitch is measured in characters per
inch (and only applicable to fixed-with fonts), so the conversions are
fairly easy. A 12-pitch typeface gives 12 characters to the inch.

Courier 10 point on most windows system is a 12 pitch font, while Courier 12
is normally a 10 pitch font. Note that some typefaces may have different
width / height ratios, but this one is common.

So using a "normal" Courier 10 point on an 8.5x11 letter-size piece of paper
with no margins and 0 line spacing should give you 79 lines high (or 79.2 if
you want to fill the paper) and 102 characters wide, or about 8058 full
characters.

Note that this is the ideal with no variation for printer / driver quirks at
all, and has almost no bearing on a monitor. Also, almost all printouts
will have some line spacing and margins (many printers require at least some
margin)


Adam said:
Phil:

OK but let's say I know my font. Its Courier 10 point.

Do you know what this means Courier 10 point?
I know Courier is a fixed font. But I don't know what 10 point means. is
it 10 points high? What about the width?
 
Back
Top