tchapi / Adafruit-GFX-Font-Customiser

A little utility to customise pixel fonts for the Adafruit GFX library
https://tchapi.github.io/Adafruit-GFX-Font-Customiser/
MIT License
90 stars 47 forks source link

Ignore any lines before font definition #35

Closed MarcelRobitaille closed 1 year ago

MarcelRobitaille commented 1 year ago

Some lines of code were added to the start of font files in this PR: https://github.com/adafruit/Adafruit-GFX-Library/pull/423

#pragma once
#include <Adafruit_GFX.h>

This change ignores such extra lines.

BillyDonahue commented 1 year ago

The tests would need to be updated to the new Adafruit-GFX files. Actually the tests should probably be checking compatibility with both the new and old fomats.

The "process and create file" function of this tool doesn't seem like it's going to preserve the header fragments that are now discarded by the import function.

tchapi commented 1 year ago

👋🏼 Hi there and thanks for the discussion

If I understand correctly the change we indeed need:

I think I'd rather have a checkbox to add the new headers automatically to any given output. Will probably give it a try if I can in the coming days

tchapi commented 1 year ago

→ Done in https://github.com/tchapi/Adafruit-GFX-Font-Customiser/commit/56be8e33498f6f3de11cf2c7243166218097e24c

MarcelRobitaille commented 1 year ago

@tchapi Thanks for your feedback and implementation. This still seems tightly tied to the current adafruit standard though. What if you saved the lines sliced away here and add those same lines back at the end. For the old format, this would just be an empty string, and it also allows the format to change upstream in the future.

const slice_index = Math.min(
  data.indexOf(font_name[0]),
  data.indexOf(font_def[0]),
  data.search(glyph_part_re),
)
window.font_preamble = data.slice(0, slice_index)
data = data.slice(slice_index)

and later

data = (window.font_preamble ?? '') + data
tchapi commented 1 year ago

It is tightly tied for now, yes, but I couldn't find any other example of different headers in the wild (do you have any?)

"Qui peut le plus peut le moins" so happy to accept your suggestion in a PR though :)