As an example of using the Cairo PDF interface, let's draw the glyphs of a font.
showhfont.cpp
int main(int argc, char *argv[]) {
cairo_surface_t *surface;
cairo_t *cr;
surface = cairo_pdf_surface_create("hersheyfont.pdf", 720, 360);
cr = cairo_create(surface);
cairo_set_source_rgb(cr, 0, 0, 0);
cairo_set_line_width(cr, 1);
draw_font(cr, font, 720, 360);
cairo_stroke(cr);
cairo_show_page(cr);
cairo_surface_destroy(surface);
cairo_destroy(cr);
return 0;
}
A Hershey vector font.
Definition font.hpp:19
Compile, e.g.
g++ -o showhfont $(pkg-config --cflags --libs cairo) -I./include/ src/showhfont.cpp src/glyph.cpp src/font.cpp src/string.cpp src/hershey_cairo.cpp
Run, e.g.
./showhfont complexscript