Skip to content

Font not working with libcairo, producing normal text #14

@ghoomfrog

Description

@ghoomfrog
#include <cairo/cairo.h>
#define FSIZE 32

int main() {
  char *text = "toki";
  cairo_surface_t *surf = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 120, 120);
  cairo_t *cr = cairo_create(surf);
  cairo_select_font_face(cr, "linja pona 4.2", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
  cairo_set_font_size(cr, FSIZE);
  cairo_set_source_rgb(cr, 1, 1, 1);
  cairo_paint(cr);
  cairo_set_source_rgb(cr, 0, 0, 0);
  cairo_move_to(cr, 0, FSIZE/1.25);
  cairo_show_text(cr, text);
  cairo_fill(cr);
  cairo_surface_write_to_png(surf, "img.png");
  cairo_surface_destroy(surf);
  cairo_destroy(cr);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions