[cairo] cairo-ft.h

Rafał Jopek rafaljopek at hotmail.com
Sat Nov 12 09:35:53 UTC 2022


Maybe someone is trying to make a compilation of this simple codes
For me, it signals an error even though I have all the dependencies installed, we are talking about MSYS2

C:/msys64/mingw64/include/cairo/cairo-ft.h:46:10: fatal error: ft2build.h: No such file or directory
   46 | #include <ft2build.h>
        |                  ^~~~~~~~~~~~



// free-type.c
#include <stdio.h>
#include <stdlib.h>
#include <cairo/cairo.h>
#include <cairo/cairo-ft.h>
//#include <cairo.h>
//#include <cairo-ft.h>

#include <freetype2/ft2build.h>
//#include <ft2build.h>

#include FT_SFNT_NAMES_H
#include FT_FREETYPE_H
#include FT_GLYPH_H
#include FT_OUTLINE_H
#include FT_BBOX_H
#include FT_TYPE1_TABLES_H

int main()
    FT_Library value;
    FT_Error status;
    FT_Face face;

    cairo_t *c;
    cairo_surface_t *cs;
    cairo_font_face_t * ct;
    int size = 200;

    cs = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, size, size);
    c = cairo_create (cs);

    const char * filename =     "/usr/local/share/fonts/Droid/DroidSansFallbackFull.ttf";

    status = FT_Init_FreeType (& value);
    if (status != 0) {
        fprintf (stderr, "Error %d opening library.\n", status);
        exit (EXIT_FAILURE);
    status = FT_New_Face (value, filename, 0, & face);
    if (status != 0) {
        fprintf (stderr, "Error %d opening %s.\n", status, filename);
        exit (EXIT_FAILURE);
    ct = cairo_ft_font_face_create_for_ft_face (face, 0);
    cairo_set_font_face (c, ct);
    cairo_set_font_size (c, size/3);
    cairo_set_source_rgb (c, 0, 0, 0);
    cairo_move_to (c, size/6, size/3);
    cairo_show_text (c, "あい");
    cairo_set_source_rgb (c, 0.5, 0.5, 0);
    cairo_move_to (c, size/6, 5*size/6);
    cairo_show_text (c, "金柑");
    cairo_surface_write_to_png (cs, "free-type.png");
    return 0;




CFLAGS = -Wall -g `pkg-config --cflags freetype2 cairo`
LDFLAGS = `pkg-config --libs freetype2 cairo`

all: free-type.png

free-type.png: free-type

free-type: $(C)
        $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(C)

        -rm -f free-type free-type.png


Kind regards,
-- Rafał

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.cairographics.org/archives/cairo/attachments/20221112/1eb7aefd/attachment-0001.htm>

More information about the cairo mailing list