开发者

is there a way to change the text's font in Cimg?

i wan开发者_如何学编程ted to know if i can draw a text in Cimg graphic library draw_text function and change the font of the text to another font ?


You can't load own fonts in CImg, but you can see example https://github.com/tttzof351/CImgAndFreetype for load custom fonts using freetype and render text on bitmap using cimg.


No. CImg's text drawing is very simplistic.

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 is just a CImgList of letters (i.e. font[letter-'a'] is an image of "letter"). Either make your own or use one of the built-in options:

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

or

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

where font here is one of the predefined fonts at the top of CImg.h such as font12x24.


Assuming you mean this Cimg library, a couple of the overloads of draw_text take parameters named "font". Those seem like a reasonable starting point...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜