Use unicode standard 0xA0-0xFF for Latin 1 characters (#1263)

* Update chars 0xA0-0xFF to match unicode

* Update ui_text.hpp

Update chars 0xA0-0xFF to match unicode

* Use unicode 0xB0 for degree character

* Clang
This commit is contained in:
Mark Thompson 2023-07-12 07:14:00 -05:00 committed by GitHub
parent 6b4f1a552e
commit a44e8b9921
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 4 deletions

View File

@ -84,8 +84,8 @@ class GeoPos : public View {
Labels labels_position{ Labels labels_position{
{{1 * 8, 0 * 16}, "Alt:", Color::light_grey()}, {{1 * 8, 0 * 16}, "Alt:", Color::light_grey()},
{{1 * 8, 1 * 16}, "Lat: \x90 ' \"", Color::light_grey()}, // 0x90 is degree ° symbol in our 8x16 font {{1 * 8, 1 * 16}, "Lat: \xB0 ' \"", Color::light_grey()}, // 0xB0 is degree ° symbol in our 8x16 font
{{1 * 8, 2 * 16}, "Lon: \x90 ' \"", Color::light_grey()}, {{1 * 8, 2 * 16}, "Lon: \xB0 ' \"", Color::light_grey()},
}; };
NumberField field_altitude{ NumberField field_altitude{

View File

@ -24,11 +24,26 @@
namespace ui { namespace ui {
Glyph Font::glyph(const char c) const { Glyph Font::glyph(const char c) const {
size_t index;
if (c < c_start) { if (c < c_start) {
// Non-display C0 Control characters - map to blank (index 0)
return {w, h, data}; return {w, h, data};
} }
const size_t index = c - c_start;
if (index >= c_count) { // Handle gap in glyphs table for C1 Control characters 0x80-0x9F
if (c < C1_CONTROL_CHARS_START) {
// ASCII chars <0x80:
index = c - c_start;
} else if (c >= C1_CONTROL_CHARS_START + C1_CONTROL_CHARS_COUNT) {
// Latin 1 chars 0xA0-0xFF
index = c - c_start - C1_CONTROL_CHARS_COUNT;
} else {
// C1 Control characters - map to blank
return {w, h, data};
}
if (index >= c_count) { // Latin Extended characters > 0xFF - not supported
return {w, h, data}; return {w, h, data};
} else { } else {
return {w, h, &data[index * data_stride]}; return {w, h, &data[index * data_stride]};

View File

@ -28,6 +28,10 @@
#include "ui.hpp" #include "ui.hpp"
// C1 Control Characters are an unprintable range of glyphs missing from the font files
#define C1_CONTROL_CHARS_START 0x80
#define C1_CONTROL_CHARS_COUNT 32
namespace ui { namespace ui {
class Glyph { class Glyph {