comparison util.c @ 1572:5efeca06d942

Scale UI font size based on window size and start basing widget sizes based on font size
author Michael Pavone <pavone@retrodev.com>
date Tue, 24 Apr 2018 20:31:18 -0700
parents e94cff9cb625
children 7121daaa48c2
comparison
equal deleted inserted replaced
1571:3def7b216a5b 1572:5efeca06d942
244 *(cur_out++) = 0x80 | (code & 0x3F); 244 *(cur_out++) = 0x80 | (code & 0x3F);
245 } 245 }
246 } 246 }
247 *cur_out = 0; 247 *cur_out = 0;
248 return out; 248 return out;
249 }
250
251 int utf8_codepoint(const char **text)
252 {
253 uint8_t initial = **text;
254 (*text)++;
255 if (initial < 0x80) {
256 return initial;
257 }
258 int base;
259 uint8_t extended_bytes;
260 if ((initial & 0xE0) == 0xC0) {
261 base = 0x80;
262 initial &= 0x1F;
263 extended_bytes = 1;
264 } else if ((initial & 0xF0) == 0xE0) {
265 base = 0x800;
266 initial &= 0xF;
267 extended_bytes = 2;
268 } else if ((initial & 0xF8) == 0xF0) {
269 base = 0x10000;
270 initial &= 0x7;
271 extended_bytes = 3;
272 }
273 int value = initial;
274 for (uint8_t i = 0; i < extended_bytes; i++)
275 {
276 if ((**text & 0xC0) != 0x80) {
277 return -1;
278 }
279 value = value << 6;
280 value |= (**text) & 0x3F;
281 (*text)++;
282 }
283 return value + base;
249 } 284 }
250 285
251 char is_path_sep(char c) 286 char is_path_sep(char c)
252 { 287 {
253 #ifdef _WIN32 288 #ifdef _WIN32