~ruther/CTU-FEE-B0B35APO-Semestral-project

ref: 86290c5c3089b35acacb633472c85a0148ee17d8 CTU-FEE-B0B35APO-Semestral-project/text-viewer/include/font.h -rw-r--r-- 1.0 KiB
86290c5c — František Boháček feat: add renderer 3 years ago
                                                                                
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
#ifndef __FONT_H__
#define __FONT_H__

#include <stdint.h>
#include <stdbool.h>

typedef uint16_t font_bits_t;

typedef struct {
  const font_bits_t bits[256*16];
  const uint8_t width;
} font_character_t;

typedef struct {
  char *name;

  uint16_t height;
  uint16_t baseline;

  uint16_t first_char;

  uint16_t chars_count;
  const font_character_t *chars;

  uint16_t default_char;
} font_descriptor_t;

typedef struct {
  font_descriptor_t font;
  uint16_t size;

  uint16_t line_spacing;
  uint16_t char_spacing;
} font_t;

typedef struct {
  uint16_t x;
  uint16_t y;
} coords_t;

typedef coords_t size2d_t;

font_t font_create(font_descriptor_t descriptor);

size2d_t font_measure_text(font_t *font, char *text);

font_character_t font_get_character(font_t *font, char c);
bool font_contains_character(font_t *font, char c);

uint16_t font_fit_ellipsis(font_t *font, size2d_t size, char *text, char *ellipsis);
uint16_t font_fit_cut(font_t *font, size2d_t size, char *text);

extern font_descriptor_t font_rom8x16;

#endif // __FONT_H__
Do not follow this link