For such a simple requirement you can use cairo
, just adjust the png sizes and font:
#include <cairo.h>
int main(void)
{
cairo_surface_t *surface;
cairo_t *cr;
surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 250, 50);
cr = cairo_create(surface);
cairo_set_source_rgb(cr, 0, 0, 0);
cairo_select_font_face(cr, "Sans", CAIRO_FONT_SLANT_NORMAL,
CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size(cr, 40.0);
cairo_move_to(cr, 10.0, 35.0);
cairo_show_text(cr, "Hello world!");
cairo_surface_write_to_png(surface, "image.png");
cairo_destroy(cr);
cairo_surface_destroy(surface);
return 0;
}
Since you are on ubuntu:
sudo apt-get install -y libcairo2-dev
And compile with:
gcc demo.c -o demo `pkg-config --cflags --libs cairo`
For more complex uses, you should combine cairo
with pango
:
https://fossies.org/linux/pango/examples/cairosimple.c