4.2in E-Paper 3-color weather screen
[weathermon.git] / weather_screen_color / fonts.h
diff --git a/weather_screen_color/fonts.h b/weather_screen_color/fonts.h
new file mode 100644 (file)
index 0000000..e1269c7
--- /dev/null
@@ -0,0 +1,40 @@
+typedef struct {
+  int maxSize;
+  const uint8_t* u8g2;
+} FontInfo;
+
+#define CyrFonts 4
+
+const FontInfo CyrFontArray[CyrFonts] = {
+  { 5, u8g2_font_4x6_t_cyrillic },
+  { 9, u8g2_font_6x13_t_cyrillic },
+  { 12, u8g2_font_9x15_t_cyrillic },
+  { 24, u8g2_font_inr24_t_cyrillic },
+};
+
+#define NumFonts 8
+
+const FontInfo NumFontArray[NumFonts] = {
+  { 5, u8g2_font_4x6_t_cyrillic },
+  { 9, u8g2_font_6x13_t_cyrillic },
+  { 12, u8g2_font_9x15_t_cyrillic },
+  { 16, u8g2_font_logisoso16_tf },
+  { 24, u8g2_font_logisoso24_tf },
+  { 32, u8g2_font_logisoso32_tf },
+  { 50, u8g2_font_logisoso50_tf },
+  { 92, u8g2_font_logisoso92_tn }
+};
+
+void SetCyrFont(byte size) {
+  for (byte i=0; i<CyrFonts; i++) {
+    if (CyrFontArray[i].maxSize<size) u8g2Fonts.setFont(CyrFontArray[i].u8g2);
+  }
+};
+
+void SetNumFont(byte size) {
+  for (byte i=0; i<NumFonts; i++) {
+    if (NumFontArray[i].maxSize<size) u8g2Fonts.setFont(NumFontArray[i].u8g2);
+  }
+};
+
+