CreateFont()nWidth参数的作用是什么? [英] What's up with CreateFont() nWidth parameter?

查看:96
本文介绍了CreateFont()nWidth参数的作用是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

文档说nWidth指定字体中字符的平均宽度(以逻辑单位)."设置此值实际上有什么作用?

我想做的就是以非常精确的宽度绘制所需的字符.我可以很容易地计算出该宽度,但是如果我将宽度用作CreateFont()中的nWidth参数,由于字符宽度的平均值,我会得到精度还是仅仅是一个近似值?

如果nWidth不精确,我将如何获得该精度?使所有字符的字体具有相同的宽度?每种字体仅使用一个字符?还有更好的主意/方法吗?肯定吗谢谢.

The documentation says that nWidth "specifies the average width (in logical units) of characters in the font." What does setting this value actually do?

What I would like to be able to do is draw a desired character at a very precise width. I can easily calculate that width but if I used my width as the nWidth parameter in CreateFont(), would I be getting precision, or just an approximation because of the average of character widths?

If nWidth isn''t precise, how would I get that precision? Make all chars the same width in a font? Use only one character per font? Any better ideas/approaches? Affirmations? Thanks.

推荐答案

Brian Bennett写道:
Brian Bennett wrote:

我是否会变得越来越精确?因为字符宽度的平均值而仅仅是一个近似值?

would I be getting precision, or just an approximation because of the average of character widths?


您将获得比例字体的近似值,等距字体的确切值.


You get an approximation for proportional fonts, the exact value for monospaced ones.

Brian Bennett写道:
Brian Bennett wrote:

如果nWidth不精确,我将如何获得该精度?使所有字符的字体具有相同的宽度?每种字体仅使用一个字符?还有更好的主意/方法吗?肯定吗?

If nWidth isn''t precise, how would I get that precision? Make all chars the same width in a font? Use only one character per font? Any better ideas/approaches? Affirmations?


您可以使用等宽字体(例如 Courier,Lucida Console,Consolas ),也可以调用GetTextExtentPoint 函数可提前知道要绘制的字符串的确切尺寸.
还可以查看 DrawTextEx 函数.

:)


You may either use a monospaced font (like, for instance, Courier, Lucida Console, Consolas) or call the GetTextExtentPoint function to know in advance the exact dimensions of the string you are about to draw.
Have also a look at the DrawTextEx function.

:)


这篇关于CreateFont()nWidth参数的作用是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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