-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpcf_font.h
169 lines (130 loc) · 3.71 KB
/
pcf_font.h
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/*
* pcf_font.h
*
* Created on: 2012/03/12
* Author: murakamimasayuki
*/
#ifndef PCF_FONT_H_
#define PCF_FONT_H_
#include "stm32f4xx_hal.h"
#include "fat.h"
#define PCF_PROPERTIES (1<<0)
#define PCF_ACCELERATORS (1<<1)
#define PCF_METRICS (1<<2)
#define PCF_BITMAPS (1<<3)
#define PCF_INK_METRICS (1<<4)
#define PCF_BDF_ENCODINGS (1<<5)
#define PCF_SWIDTHS (1<<6)
#define PCF_GLYPH_NAMES (1<<7)
#define PCF_BDF_ACCELERATORS (1<<8)
typedef struct toc_entry {
uint32_t type;
uint32_t format;
uint32_t size;
uint32_t offset;
} toc_entry;
typedef struct metric_data_typedef {
int8_t left_sided_bearing, \
right_sided_bearing, \
character_width, \
character_ascent, \
character_descent;
}metric_data_typedef;
typedef struct encode_info_typedef {
uint16_t min_char_or_byte2, \
max_char_or_byte2, \
min_byte1, \
max_byte1, \
default_char;
}encode_info_typedef;
typedef struct metrics_table_typedef {
uint32_t size, offset;
MY_FILE fp;
}metrics_table_typedef;
typedef struct bitmap_table_typedef {
uint32_t size, offset;
MY_FILE fp_offset, fp_bitmap;
}bitmap_table_typedef;
typedef struct encode_table_typedef {
uint32_t size, offset, glyphindeces;
MY_FILE fp;
}encode_table_typedef;
typedef struct pcf_typedef{
uint32_t dst_gram_addr;
int pixelFormat, alphaSoftBlending, enableShadow;
int color, colorT, colorShadow, size;
} pcf_typedef;
typedef struct{
union{
uint16_t d16;
struct {
uint16_t B : 5;
uint16_t G : 6;
uint16_t R : 5;
};
}color;
}pixel_fmt_rgb565_typedef;
typedef struct{
union{
uint16_t d16;
struct {
uint16_t B : 4;
uint16_t G : 4;
uint16_t R : 4;
uint16_t A : 4;
};
}color;
}pixel_fmt_argb4444_typedef;
typedef struct {
int offsetX, offsetY, enable;
int color;
}text_shade_typedef;
typedef struct {
int startPosX, startPosY, \
borderCols, spaceBetweenLines;
pcf_typedef pcf;
int color;
text_shade_typedef shade;
}text_conf_typedef;
typedef struct cache_typedef {
void *start_address;
int glyph_count;
}cache_typedef;
typedef struct metrics {
uint8_t hSpacing;
}metrics_typedef;
#define PCF_METRICS_DEFAULT_HSPACING 2
#define C_FONT_UNDEF_CODE 0x0080
typedef struct {
uint32_t table_count;
metrics_table_typedef metrics_tbl;
bitmap_table_typedef bitmap_tbl;
encode_table_typedef enc_tbl;
encode_info_typedef enc_info;
cache_typedef cache;
metrics_typedef metrics;
int8_t isOK, ext_loaded;
}pcf_font_typedef;
extern pcf_font_typedef pcf_font;
#define PCF_PIXEL_FORMAT_RGB565 0
#define PCF_PIXEL_FORMAT_ARGB4444 1
#define PCF_RENDER_FUNC_C_PCF() do{LCD_FUNC.putChar = C_PCFPutChar; \
LCD_FUNC.putWideChar = C_PCFPutChar; \
LCD_FUNC.getCharLength = C_PCFGetCharPixelLength;}while(0)
#define PCF_RENDER_FUNC_PCF() do{LCD_FUNC.putChar = PCFPutChar; \
LCD_FUNC.putWideChar = PCFPutChar; \
LCD_FUNC.getCharLength = PCFGetCharPixelLength;}while(0)
extern const char internal_flash_pcf_font[];
extern char _sizeof_internal_flash_pcf_font[];
extern int PCFFontInit(int id);
extern void PCFPutChar(uint16_t code, void *cp);
extern void PCFPutString(const uint16_t *uni_str, int n, pcf_typedef *pcf);
extern void PCFPutString16px(const uint16_t *uni_str, int n, pcf_typedef *pcf);
extern uint16_t PCFGetCharPixelLength(uint16_t code, uint16_t font_width);
extern int C_PCFFontInit(uint32_t fileAddr, size_t fileSize);
extern void C_PCFPutChar(uint16_t code, void *cp);
extern void C_PCFPutChar16px(uint16_t code, void *cp);
extern void C_PCFPutString(const uint16_t *uni_str, int n, pcf_typedef *pcf);
extern void C_PCFPutString16px(const uint16_t *uni_str, int n, pcf_typedef *pcf);
extern uint16_t C_PCFGetCharPixelLength(uint16_t code, uint16_t font_width);
#endif /* PCF_FONT_H_ */