#include <windows.h>
#include <cairo-win32.h>
#include <assert.h>

void main() {
    HFONT hfont = CreateFontW(
        12, 0, 0, 0, 400, 0, 0, 0,
        DEFAULT_CHARSET, OUT_OUTLINE_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE,
        L"Times");
    assert(hfont);

    LOGFONTW lf;
    int i = GetObjectW(hfont, sizeof LOGFONTW, &lf);
    assert(i);

    cairo_surface_t* surf = cairo_image_surface_create(CAIRO_FORMAT_RGB24, 200, 130);
    cairo_t* cairo = cairo_create(surf);

    cairo_font_face_t* font1 = cairo_win32_font_face_create_for_hfont(hfont);
    assert(CAIRO_STATUS_SUCCESS == cairo_font_face_status(font1));
    cairo_font_face_t* font2 = cairo_win32_font_face_create_for_logfontw(&lf);
    assert(CAIRO_STATUS_SUCCESS == cairo_font_face_status(font2));
    cairo_font_face_t* font3 = cairo_win32_font_face_create_for_logfontw_hfont(&lf, hfont);
    assert(CAIRO_STATUS_SUCCESS == cairo_font_face_status(font3));

    cairo_set_font_size(cairo, 40);
    cairo_set_source_rgb(cairo, 1, 1, 1);

    cairo_set_font_face(cairo, font1);
    cairo_move_to(cairo, 0, 40);
    cairo_show_text(cairo, "Hello world");
    cairo_set_font_face(cairo, font2);
    cairo_move_to(cairo, 0, 80);
    cairo_show_text(cairo, "Hello world");
    cairo_set_font_face(cairo, font3);
    cairo_move_to(cairo, 0, 120);
    cairo_show_text(cairo, "Hello world");

    cairo_surface_write_to_png(surf, "test.png");
}
