有没有办法在Cimg中改变文本的字体?
答
不。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
预定义的字体之一。
答
您无法在CImg中加载自己的字体,但您可以看到使用freetype加载自定义字体的示例https://github.com/tttzof351/CImgAndFreetype,并使用cimg在位图上呈现文本。