<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[How to use the fonts available in &#x2F;Arduino&#x2F;libraries&#x2F;M5GFX&#x2F;src&#x2F;lgfx&#x2F;Fonts&#x2F;GFXFF]]></title><description><![CDATA[<p dir="auto">I have used the example "RTC_Clock" from the M5Core_Ink library as attached. The sketch works fine on my M5CoreInk module. I would like to modify the fonts however and I find that only AsciiFont24x48 and  AsciiFont8x16 are available to use. Even though some other fonts are available under <em>/Arduino/libraries/M5GFX/src/lgfx/Fonts</em> if I try and use them in place of AsciiFont24x48 in the sketch below I get the error <em>"'FontXXX' was not declared in this scope"</em>. How do I declare these additional fonts?</p>
<p dir="auto">Also, I have seen that the Library MGFX has lots of fonts under <em>/M5GFX/src/lgfx/Fonts/GFXFF</em>. But I cannot find a simple example of using the M5GFX library to display a text string, any help would be appreciated.</p>
<p dir="auto">One final point, if I include the M5GFX library tn the RTC_Clock sketch the compiler complains that AsciiFont24x48 is ambiguous as it has found two versions, how do I fix this?</p>
<pre><code>#include "M5CoreInk.h"
#include &lt;WiFi.h&gt;
#include "time.h"

const char* ssid             = "YOUR_SSID";
const char* password         = "YOUR_PASSWORD";
const char* ntpServer        = "pool.ntp.org";
const long gmtOffset_sec     = 3600;
const int daylightOffset_sec = 3600;

// every hour at minute 45 do a full ink display refresh
#define FULL_REFRESH_MINUTE (45)

Ink_Sprite TimePageSprite(&amp;M5.M5Ink);

void printLocalTimeAndSetRTC() {
    struct tm timeinfo;

    if (getLocalTime(&amp;timeinfo) == false) {
        Serial.println("Failed to obtain time");
        return;
    }
    Serial.println(&amp;timeinfo, "%A, %B %d %Y %H:%M:%S");

    RTC_TimeTypeDef time;
    time.Hours   = timeinfo.tm_hour;
    time.Minutes = timeinfo.tm_min;
    time.Seconds = timeinfo.tm_sec;
    M5.rtc.SetTime(&amp;time);

    RTC_DateTypeDef date;
    date.Date  = timeinfo.tm_mday;
    date.Month = timeinfo.tm_mon + 1;
    date.Year  = timeinfo.tm_year + 1900;
    M5.rtc.SetDate(&amp;date);
}

void getNTPTime() {
    // Try to connect for 10 seconds
    uint32_t connect_timeout = millis() + 10000;

    Serial.printf("Connecting to %s ", ssid);
    WiFi.begin(ssid, password);
    while ((WiFi.status() != WL_CONNECTED) &amp;&amp; (millis() &lt; connect_timeout)) {
        delay(500);
        Serial.print(".");
    }
    if (WiFi.status() != WL_CONNECTED) {
        // WiFi connection failed - set fantasy time and date
        RTC_TimeTypeDef time;
        time.Hours   = 6;
        time.Minutes = 43;
        time.Seconds = 50;
        M5.rtc.SetTime(&amp;time);

        RTC_DateTypeDef date;
        date.Date  = 4;
        date.Month = 12;
        date.Year  = 2020;
        M5.rtc.SetDate(&amp;date);
        return;
    }

    Serial.println("Connected");

    configTime(gmtOffset_sec, daylightOffset_sec, ntpServer);
    printLocalTimeAndSetRTC();

    WiFi.disconnect(true);
    WiFi.mode(WIFI_OFF);
}

void drawTimeAndDate(RTC_TimeTypeDef time, RTC_DateTypeDef date) {
    char buf[11];

    snprintf(buf, 6, "%02d:%02d", time.Hours, time.Minutes);
    TimePageSprite.drawString(40, 20, buf, &amp;AsciiFont24x48);
    snprintf(buf, 11, "%02d.%02d.%02d", date.Date, date.Month,
             date.Year - 2000);
    TimePageSprite.drawString(4, 70, buf, &amp;AsciiFont24x48);
}

void setup() {
    // Check power on reason before calling M5.begin()
    //  which calls Rtc.begin() which clears the timer flag.
    Wire1.begin(21, 22);
    uint8_t data = M5.rtc.ReadReg(0x01);

    M5.begin();
    // Green LED - indicates ESP32 is running
    digitalWrite(LED_EXT_PIN, LOW);

    if (M5.M5Ink.isInit() == false) {
        Serial.printf("Ink Init failed");
        while (1) delay(100);
    }

    RTC_TimeTypeDef time;
    RTC_DateTypeDef date;

    // Check timer flag
    if ((data &amp; 0b00000100) == 0b00000100) {
        Serial.println("Power on by: RTC timer");
        M5.rtc.GetTime(&amp;time);
        M5.rtc.GetDate(&amp;date);
        // Full refresh once per hour
        if (time.Minutes == FULL_REFRESH_MINUTE - 1) {
            M5.M5Ink.clear();
        }
    } else {
        Serial.println("Power on by: power button");
        M5.M5Ink.clear();
        // Fetch current time from Internet
        getNTPTime();
        M5.rtc.GetTime(&amp;time);
        M5.rtc.GetDate(&amp;date);
    }

    // After every shutdown the sprite is created anew.
    // But the sprite doesn't know about the current image on the
    //  ink display therefore the same time and date, as have been
    //  drawn before the shutdown, are redrawn.
    // This is required, else drawing new time and date only adds
    //  pixels to the already drawn pixels instead of clearing the
    //  previous time and date and then draw the new time and date.
    TimePageSprite.creatSprite(0, 0, 200, 200);

    drawTimeAndDate(time, date);
    TimePageSprite.pushSprite();

    // Wait until full minute, e.g. seconds are 0
    while ((time.Seconds != 0)) {
        M5.rtc.GetTime(&amp;time);
        delay(200);
    }
    M5.rtc.GetDate(&amp;date);

    // Draw new time and date
    drawTimeAndDate(time, date);
    TimePageSprite.pushSprite();

    Serial.printf("Shutdown...\n");
    Serial.flush();

    // Full refresh once per hour
    if (time.Minutes == FULL_REFRESH_MINUTE - 1) {
        // Allow extra time for full ink refresh
        // Shutdown for 55 seconds only
        M5.shutdown(55);
        return;
    }
    // Shutdown for 58 seconds
    M5.shutdown(58);
}

void loop() {
}
</code></pre>
]]></description><link>https://community.m5stack.com/topic/5775/how-to-use-the-fonts-available-in-arduino-libraries-m5gfx-src-lgfx-fonts-gfxff</link><generator>RSS for Node</generator><lastBuildDate>Tue, 10 Mar 2026 18:51:53 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/5775.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 05 Nov 2023 09:49:04 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to use the fonts available in &#x2F;Arduino&#x2F;libraries&#x2F;M5GFX&#x2F;src&#x2F;lgfx&#x2F;Fonts&#x2F;GFXFF on Mon, 06 Nov 2023 08:04:09 GMT]]></title><description><![CDATA[<p dir="auto">I have found out how to use the fonts within the M5GFX library;</p>
<pre><code class="language-cpp">#include &lt;Arduino.h&gt;
#include &lt;M5GFX.h&gt;
M5GFX display;

void setup() {
  display.begin();
  display.setTextDatum(middle_center);
  uint16_t x = display.width() / 2;
  uint16_t y = display.height() / 2;
  display.setFont(&amp;fonts::FreeMonoBold24pt7b);
  display.drawString("Test", x, y);
}

void loop() {
}
</code></pre>
]]></description><link>https://community.m5stack.com/post/22660</link><guid isPermaLink="true">https://community.m5stack.com/post/22660</guid><dc:creator><![CDATA[Steve1]]></dc:creator><pubDate>Mon, 06 Nov 2023 08:04:09 GMT</pubDate></item></channel></rss>