Files
OptoTest/OpticalChannelTester/Font_Cyrillic.h

58 lines
2.4 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#pragma once
#include <Arduino.h>
// Compact 5x7 uppercase Cyrillic font. Lowercase UTF-8 letters are deliberately
// rendered with the same uppercase glyphs: at 5x7 pixels this is considerably
// clearer than trying to preserve lowercase shapes.
namespace CyrillicFont {
constexpr uint8_t WIDTH = 5;
constexpr uint8_t HEIGHT = 7;
constexpr uint8_t ADVANCE = 6;
// Rows are stored top-to-bottom; the low five bits are pixels left-to-right.
const uint8_t GLYPHS[][HEIGHT] PROGMEM = {
{0x0E, 0x11, 0x11, 0x1F, 0x11, 0x11, 0x11}, // А
{0x1F, 0x10, 0x10, 0x1E, 0x11, 0x11, 0x1E}, // Б
{0x1E, 0x11, 0x11, 0x1E, 0x11, 0x11, 0x1E}, // В
{0x1F, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10}, // Г
{0x0E, 0x0A, 0x0A, 0x0A, 0x11, 0x1F, 0x11}, // Д
{0x1F, 0x10, 0x10, 0x1E, 0x10, 0x10, 0x1F}, // Е
{0x15, 0x15, 0x0E, 0x04, 0x0E, 0x15, 0x15}, // Ж
{0x0E, 0x11, 0x01, 0x06, 0x01, 0x11, 0x0E}, // З
{0x11, 0x13, 0x15, 0x15, 0x19, 0x11, 0x11}, // И
{0x0A, 0x11, 0x13, 0x15, 0x19, 0x11, 0x11}, // Й
{0x11, 0x12, 0x14, 0x18, 0x14, 0x12, 0x11}, // К
{0x07, 0x09, 0x09, 0x09, 0x11, 0x11, 0x11}, // Л
{0x11, 0x1B, 0x15, 0x15, 0x11, 0x11, 0x11}, // М
{0x11, 0x11, 0x11, 0x1F, 0x11, 0x11, 0x11}, // Н
{0x0E, 0x11, 0x11, 0x11, 0x11, 0x11, 0x0E}, // О
{0x1F, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11}, // П
{0x1E, 0x11, 0x11, 0x1E, 0x10, 0x10, 0x10}, // Р
{0x0F, 0x10, 0x10, 0x10, 0x10, 0x10, 0x0F}, // С
{0x1F, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04}, // Т
{0x11, 0x11, 0x11, 0x0F, 0x01, 0x11, 0x0E}, // У
{0x04, 0x0E, 0x15, 0x15, 0x0E, 0x04, 0x04}, // Ф
{0x11, 0x11, 0x0A, 0x04, 0x0A, 0x11, 0x11}, // Х
{0x12, 0x12, 0x12, 0x12, 0x12, 0x1E, 0x01}, // Ц
{0x11, 0x11, 0x11, 0x0F, 0x01, 0x01, 0x01}, // Ч
{0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x1F}, // Ш
{0x15, 0x15, 0x15, 0x15, 0x15, 0x1E, 0x01}, // Щ
{0x18, 0x08, 0x08, 0x0E, 0x09, 0x09, 0x0E}, // Ъ
{0x11, 0x11, 0x11, 0x1D, 0x15, 0x15, 0x1D}, // Ы
{0x10, 0x10, 0x10, 0x1E, 0x11, 0x11, 0x1E}, // Ь
{0x0E, 0x11, 0x01, 0x07, 0x01, 0x11, 0x0E}, // Э
{0x12, 0x15, 0x15, 0x1D, 0x15, 0x15, 0x12}, // Ю
{0x0F, 0x11, 0x11, 0x0F, 0x05, 0x09, 0x11} // Я
};
inline const uint8_t *glyph(uint32_t codepoint) {
if (codepoint >= 0x0430U && codepoint <= 0x044FU) codepoint -= 0x20U;
if (codepoint == 0x0401U || codepoint == 0x0451U) codepoint = 0x0415U; // Ё -> Е
if (codepoint < 0x0410U || codepoint > 0x042FU) return nullptr;
return GLYPHS[codepoint - 0x0410U];
}
} // namespace CyrillicFont