adafruit / Adafruit-GFX-Library

Adafruit GFX graphics core Arduino library, this is the 'core' class that all our other graphics libraries derive from
https://learn.adafruit.com/adafruit-gfx-graphics-library
Other
2.32k stars 1.53k forks source link

Missing imports in font files for PlatformIO #416

Closed MarcelRobitaille closed 1 year ago

MarcelRobitaille commented 1 year ago

Thank you for the Amazing library.

However, I prefer to use PlatformIO over the Arduino IDE. This mostly works, but I get compilation errors in all the font .h files I import. I have to open that file and add #include <Adafruit_GFX.h> in the top. This is a little bit annoying because I have to redo this every time PlatformIO re-downloads the library and undoes my local change.

Would you accept a pull-request making this change? I know this library doesn't officially support PlatformIO, but I don't think this addition would cause any problems for anyone uses Arduino IDE.

Here are the errors I am getting:

In file included from src/GxEPD2_Example/main.cpp:50:
.pio/libdeps/library_example_2_7/Adafruit GFX Library/Fonts/FreeMonoBold9pt7b.h:1:7: error: 'uint8_t' does not name a type
    1 | const uint8_t FreeMonoBold9pt7bBitmaps[] PROGMEM = {
      |       ^~~~~~~
.pio/libdeps/library_example_2_7/Adafruit GFX Library/Fonts/FreeMonoBold9pt7b.h:87:7: error: 'GFXglyph' does not name a type
   87 | const GFXglyph FreeMonoBold9pt7bGlyphs[] PROGMEM = {
      |       ^~~~~~~~
.pio/libdeps/library_example_2_7/Adafruit GFX Library/Fonts/FreeMonoBold9pt7b.h:184:7: error: 'GFXfont' does not name a type
  184 | const GFXfont FreeMonoBold9pt7b PROGMEM = {(uint8_t *)FreeMonoBold9pt7bBitmaps,
      |       ^~~~~~~

The reason is that PlatformIO is closer to pure C++. The font files use GFXfont, which is not imported.

Here is an example of my proposed change:

#include <Adafruit_GFX.h>

const uint8_t FreeMonoBold9pt7bBitmaps[] PROGMEM = {
...