有没有办法在Cimg中更改文本的字体?

时间:2010-04-23 16:41:14

标签: visual-c++ graphics cimg

我想知道我是否可以在Cimg图形库draw_text函数中绘制文本并将文本字体更改为另一种字体?

3 个答案:

答案 0 :(得分:2)

您无法在CImg中加载自己的字体,但是您可以使用freetype看到加载自定义字体的示例https://github.com/tttzof351/CImgAndFreetype,并使用cimg在位图上呈现文本。

答案 1 :(得分:1)

没有。 CImg的文字绘图非常简单。

CImg<T>& draw_text(const int x0, const int y0,
                   const char *const text,
                   const int, const tc *const background_color,
                   const float opacity, const CImgList<t>& font, ...)

font只是CImgList个字母(即font[letter-'a']是“字母”的图像)。您可以自己创建或使用其中一个内置选项:

static const CImgList<T>& font(const unsigned int font_height, 
                               const bool variable_size=true);

static CImgList<T> _font(const unsigned int *const font, 
                         const unsigned int w, const unsigned int h, 
                         const bool variable_size)

其中font这里是CImg.h顶部的预定义字体之一,例如font12x24

答案 2 :(得分:0)

假设您的意思是this Cimg库,draw_text的一些重载采用名为“font”的参数。这似乎是一个合理的起点...

相关问题