QFontInfo 未返回正确的字体系列
我正在尝试使用 Apple 在 Snow Leopard 上提供的仅盲文字体(称为 Apple Braille
)来模拟盲文显示。
我正在尝试使用 Qt 4.7.3 来完成这项工作,但到目前为止我还没有成功地尝试让它加载字体。检查下面的代码:
#include <QCoreApplication>
#include <QDebug>
#include <QFontDatabase>
#include <QFontInfo>
#include <QStringList>
Q_DECL_EXPORT int main(int argc, char *argv[])
{
QScopedPointer<QCoreApplication> app(new QCoreApplication(argc, argv));
int id = QFontDatabase::addApplicationFont(
"/System/Library/Fonts/Apple Braille Outline 8 Dot.ttf");
qDebug() << "Registered font Family is"
<< QFontDatabase::applicationFontFamilies(id).join(",");
QFont desired_font("Apple Braille");
qDebug() << "Got" << QFontInfo(desired_font).family();
return app->exec();
}
我在控制台上得到的是:
注册字体系列是“Apple Braille”
获得“Helvetica”
不知何故它正在加载正确的字体,但不使用它。我已使用 Font Book.app
检查了字体文件,它是有效的 True Type 字体。 Qt 没有返回错误,那么我该怎么做才能让它加载并使用字体呢?
I am trying to use a Braille-only font that Apple made available on Snow Leopard, called Apple Braille
to simulate a braille display.
I'm trying to use Qt 4.7.3 for the job, but so far I've had no luck trying to get it to load the font. Check my code bellow:
#include <QCoreApplication>
#include <QDebug>
#include <QFontDatabase>
#include <QFontInfo>
#include <QStringList>
Q_DECL_EXPORT int main(int argc, char *argv[])
{
QScopedPointer<QCoreApplication> app(new QCoreApplication(argc, argv));
int id = QFontDatabase::addApplicationFont(
"/System/Library/Fonts/Apple Braille Outline 8 Dot.ttf");
qDebug() << "Registered font Family is"
<< QFontDatabase::applicationFontFamilies(id).join(",");
QFont desired_font("Apple Braille");
qDebug() << "Got" << QFontInfo(desired_font).family();
return app->exec();
}
What I get on my console is:
Registered font Family is "Apple Braille"
Got "Helvetica"
Somehow it is loading the correct font, but not using it. I've checked the font file with Font Book.app
and it is a valid True Type font. Qt is not returning an error, so what can I do to get it to load and use the font?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论