Loading
柚木鉉の空間
0%
INITIALIZING
首页 文章 标签 归档 友链 推广 搜索
文档编号 // 6BA4E7 在线

JUCE 使用内部字库显示中文等字体

2019-09-18
更新: 2026-04-25
1052 字符
这篇文章写于 2019,已经超过 7 年了。内容可能已经过时。

1.将字体文件放入项目内

2.在项目的initialise中加入

Typeface::Ptr getTypefaceForFont(const Font &f);
LookAndFeel::setDefaultLookAndFeel(&customLookAndFeel);

EG:

void initialise (const String& commandLine) override
{
// This method is where you should put your application's initialisation code..
Typeface::Ptr getTypefaceForFont(const Font &f);
LookAndFeel::setDefaultLookAndFeel(&customLookAndFeel);
mainWindow.reset (new MainWindow (getApplicationName()));
}

然后在Main文件中的私有类加入

class CustomFontLookAndFeel : public LookAndFeel_V4 {
public:
CustomFontLookAndFeel() {
LookAndFeel::setDefaultLookAndFeel(this);
}

static const Font getCustomFont() {
static auto typeface = Typeface::createSystemTypefaceFor(BinaryData::SiHei_otf, BinaryData::SiHei_otfSize);
return Font(typeface);
}
Typeface::Ptr getTypefaceForFont(const Font &f) override {
return getCustomFont().getTypeface();
}
private:
} customLookAndFeel;

其中SiHei_otf是字体文件文件名称

WeChat Pay 微信
Alipay 支付宝
导航 // 相关文章
目录