1

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

4

3 回答 3

2

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

于 2013-10-19T00:39:00.867 回答
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.

于 2011-03-01T23:24:26.710 回答
0

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

于 2010-04-23T23:12:47.110 回答