如何确定字体的高度/宽度 [英] How to determine Height/Width of Font

查看:142
本文介绍了如何确定字体的高度/宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以帮忙!!


我想弄清楚字体是什么?

假设我正在使用固定字体说Courier 10点字体


问题1:这意味着什么是10点字体

问题2:如何确定我可以在一行中获得多少个字符

问题3:如何确定页面上可以获得的行数。假设没有边距

问题4:他们是否存在某种参考表,将字体与字符/行和#lines / page等同于


感谢


Ada

我已经读过一英寸有72点的地方,但我认为这相当于身高而不是w /
>

解决方案

除非您使用的是等宽字体,否则您无法预先确定所需的信息

。 (在等宽字体中,字体单元格的宽度与

字体中的所有字形(字符)相同。)


大多数字体都不是*等宽,这意味着不同字形的字符单元格宽度不同。例如,W比i宽。

此外,字距调整起作用,这实际上意味着当绘制字形

时,它们实际上可能间隔得更近实际宽度。


关于真正确定线条/页面适合的唯一方法是绘制

it(或使用绘制例程来计算)正在表示的实际文本。

在MSDN中查找DrawText DT_CALCRECT以查看关于该主题的大量文章

(大多数将是C ++,但会让你知道什么你需要这样做。


如果你使用等宽字体,你可以从

文本指标中获取单元格尺寸。


Adam写道:


有人可以帮忙!!!

我想弄清楚字体是什么?
问题1:这意味着10点字体是什么意思?
问题2:我如何确定我可以在一行上找到多少个字符。
问题3:如何确定我可以在页面上获得多少行。假设没有边距。
问题4:他们是否存在某种类型的参考表,将字体与字符/行和#lines / page等同?

谢谢
Adam

我已经读过一英寸有72个点的地方,但我认为这等于高度而不是宽度



< blockquote> Julie:


首先,你要回复。

但我不熟悉C ++。

请纠正我,如果我错了,但我认为Courier是固定宽度的字体。这意味着字母w占据了与字母i相同的空间。


无论如何,我很惊讶他们不是交叉参考表或某种类型或公式。 />

你是否有任何其他信息?


亚当


----- Julie J写道:-----


除非您使用的是等宽字体,否则您无法预先确定所需的信息

。 (在等宽字体中,字体单元格的宽度与

字体中的所有字形(字符)相同。)


大多数字体都不是*等宽,这意味着不同字形的字符单元格宽度不同。例如,W比i宽。

此外,字距调整起作用,这实际上意味着当绘制字形

时,它们实际上可能间隔得更近实际宽度。


关于真正确定线条/页面适合的唯一方法是绘制

it(或使用绘制例程来计算)正在表示的实际文本。

在MSDN中查找DrawText DT_CALCRECT以查看关于该主题的大量文章

(大多数将是C ++,但会让你知道什么你需要这样做。


如果你使用等宽字体,你可以从

文本指标中获取单元格尺寸。


Adam写道:

有人可以帮忙!!!
我想弄清楚字体是什么?


假设我正在使用固定字体说Courier 10 point font。

问题1:这是什么我一个10磅的字体?


问题2:我如何确定一行中可以获得多少个字符。
问题3:如何确定我可以在一个页面上获得多少行。假设没有边距。
问题4:他们是否存在某种类型的参考表,它将字体与字符/行和#lines / page等同?

谢谢
Adam




< blockquote>在c#中,您可以使用Graphics对象MeasureString属性来测量

给定特定字体的字符串将占用多少像素。


你可以'真的有一张桌子使用

monospace字体的字符/行或行/页面,因为你需要基于以下的不同表:


1)你是什么字体在?

2)它是什么尺寸的字体?

3)它是粗体,斜体吗?

4)客户的大小是多少窗口?

5)用户有多大字体? (大/小/ 132%)


我相信人们可以拿出更多,而且这并没有触及

kerning或者cleartype设置等。基本上,使用measuretring或

类似。

" Adam" <一个******* @ discussions.microsoft.com>在消息中写道

新闻:DE ********************************** @ microsof t.com ...

Julie:

首先,请回答你的问题。
但我不熟悉C ++。
请纠正我,如果我错了,但我认为Courier是固定的
宽度字体。这意味着字母w占据了与字母i相同的空间。
无论如何,我很惊讶他们不是交叉参考表或一些
排序或公式。
你是什么附加信息?

Adam


----- Julie J.写道:-----

除非您使用的是等宽字体,否则您无法预先确定所需的
信息。 (在等宽字体中,字体单元格宽度为字体中所有字形(字符)的
相同。)

大多数字体*不是*等宽字体,这意味着字符单元格
宽度因不同的字形而不同。例如,W比i宽。
另外,字距调整起作用,这实际上意味着当绘制字形时
,它们实际上可以间隔得更近,然后是它们的
实际宽度。关于真正确定适合某行/页的唯一方法
是绘制它(或使用绘制例程来计算)实际文本是
表示的。在MSDN中查找DrawText DT_CALCRECT以查看关于
主题的大量文章(大多数将是C ++,但会让你知道你需要做什么)。

如果你正在使用等宽字体,您可以从文本指标中获取单元格尺寸


Adam写道:

>>有人可以帮忙!!!
>>我想弄清楚字体是什么? >假设我使用固定字体说Courier 10 point font。

>>问题1:10磅字体是什么意思?


>问题2:如何确定
行可以获得的字符数。

>问题3:如何确定页面上可以获得的行数。
假设没有保证金。 >问题4:它们是否存在某种推荐表



将字体与字符/行和#lines / page等同?

>>谢谢
>>亚当
>>我已经读过一英寸有72个点的地方,但我认为这个



等于高度而不是宽度



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.

Adam wrote:


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?

Thanks

Adam

I''ve read where there are 72 points in an inch but I think this equates to height and not width



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.

Adam wrote:

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?

Thanks
Adam
I''ve read where there are 72 points in an inch but I think this equates to height and not width




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" <an*******@discussions.microsoft.com> wrote in message
news:DE**********************************@microsof t.com...

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.

Adam wrote:

>> 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?

>> Thanks
>> Adam
>> I''ve read where there are 72 points in an inch but I think this


equates to height and not width



这篇关于如何确定字体的高度/宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆