C 中的字体规格

发布于 2024-09-11 04:21:14 字数 91 浏览 1 评论 0原文

我想知道 C 中是否有任何库可用于计算字体规格(基本上我想知道特定字体字符串的宽度)。 QT 有 QFontMetrics。有什么办法可以在 C 中获得类似的数据吗?

I wanted to know if there is any library in C available for calculating the Font Metrics (Basically i wanted to know the width of a string of Particular Font).
QT has QFontMetrics. Is there any way I can get similar data in C.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

黑凤梨 2024-09-18 04:21:14

我不会说只使用 FreeType,除非您所在的系统使用 X 作为图形显示。如果您使用的是 Windows,请使用 Windows API 来获取字体规格信息,而在 Mac 上则使用 Cocoa 提供的任何内容。

如果您告诉我们您想做什么也可能会有所帮助。

编辑:由于您的库的输出旨在由特定的 GUI 应用程序使用,因此您可能希望使用相同的 GUI 库来获取应用程序正在使用的字体规格信息。更好的是让应用程序向库提供指标信息,或者可以提供该信息的回调方法。然后,库甚至不必知道字体规格是如何导出的,从而减少了不必要的依赖性。这也意味着您可以在 GUI 应用程序中使用 Qt (C++),但仍然用 C 编写库,而不必找出从 C 调用 C++ 的方法,这是非常困难的,特别是如果您尝试这样做的话跨平台。

I wouldn't say just use FreeType, unless you are on a system that uses X as the graphics display. If you are on Windows, use the Windows API to get font metrics information and on Mac use whatever Cocoa provides.

It might also help if you told us what you are trying to do.

EDIT: Since the output of your library is intended to be consumed by a particular GUI app, you will probably want to use the same GUI library to get the font metrics information as the app is using. Even better would be to have the app provide metrics information to the library, or a callback method that can provide that information. Then the library doesn't even have to know how the font metrics were derived, reducing an unnecessary dependency. This also means that you can use Qt (C++) in your GUI app, but still write your library in C and not have to figure out a way to call C++ from C, which is very difficult, especially if you are trying to make it cross-platform.

丢了幸福的猪 2024-09-18 04:21:14

C(只是)一种编程语言。按照设计,C 根本没有嵌入函数,甚至文件 I/O 也没有。

因此,您必须指出您正在使用什么图形/GUI 平台。

C is (just) a programming language. By design C has no embedded functions at all, not even for File I/O.

So you will have to indicate what Graphics/GUI platform you are using.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文