aboutsummaryrefslogtreecommitdiff
path: root/font.h
blob: 0f2c9833a56fb5b5ad4b3647aeb26a75d974d7f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#pragma once

#include <stdbool.h>
#include <threads.h>

#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_LCD_FILTER_H
#include <cairo.h>

#include "tllist.h"
//#include "terminal.h"

typedef tll(const char *) font_list_t;

struct glyph {
    wchar_t wc;

    void *data;
    cairo_surface_t *surf;
    int left;
    int top;

#if 0
    int format;
    int width;
    int height;
    int stride;
#endif
};

typedef tll(struct glyph) hash_entry_t;

struct font {
    FT_Face face;
    int load_flags;
    int render_flags;
    FT_LcdFilter lcd_filter;
    struct {
        double position;
        double thickness;
    } underline;
    struct {
        double position;
        double thickness;
    } strikeout;

    bool is_fallback;
    tll(char *) fallbacks;

    //struct glyph cache[256];
    hash_entry_t **cache;
    mtx_t lock;
};

bool font_from_name(font_list_t names, const char *attributes, struct font *result);
const struct glyph *font_glyph_for_utf8(struct font *font, const char *utf8);
void font_destroy(struct font *font);