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

ref: b954c45e83a5296c1ea90fc949851984e2c2abb7 CTU-FEE-B0B35APO-Semestral-project/lib-gui/include/font.h -rw-r--r-- 1.9 KiB
b954c45e — František Boháček docs: add new todos 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#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[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;

/**
 * @brief Create font from given descriptor
 * 
 * @param descriptor 
 * @return font_t 
 */
font_t font_create(font_descriptor_t descriptor);

/**
 * @brief Get text dimensions for given font 
 * 
 * @param font 
 * @param text 
 * @return size2d_t 
 */
size2d_t font_measure_text(font_t *font, char *text);

/**
 * @brief Get font character for font from char
 * 
 * @param font 
 * @param c 
 * @return font_character_t 
 */
font_character_t font_get_character(font_t *font, char c);

/**
 * @brief Get whether font contains font character 
 * 
 * @param font 
 * @param c 
 * @return true character is in font 
 * @return false character is not in font
 */
bool font_contains_character(font_t *font, char c);

/**
 * @brief Fit text with ellipsis to get how many characters can be shown
 * 
 * @param font 
 * @param size 
 * @param text 
 * @param ellipsis 
 * @return uint16_t number of characters that can be fit
 */
uint16_t font_fit_ellipsis(font_t *font, size2d_t size, char *text, char *ellipsis);

/**
 * @brief Fit cut text without any ellipsis to get how many characters can be shown
 * 
 * @param font 
 * @param size 
 * @param text 
 * @return uint16_t 
 */
uint16_t font_fit_cut(font_t *font, size2d_t size, char *text);

extern font_descriptor_t font_rom8x16;
extern font_descriptor_t font_winFreeSystem14x16;

#endif // __FONT_H__
Do not follow this link