u8g2_config_fonts.pl 588 B

123456789101112131415161718192021222324252627282930313233
  1. #!/usr/bin/perl -w
  2. my @font_selection;
  3. # scan provided header file for CONFIG_U8G2_FONT_SELECTION entry
  4. while (<STDIN>) {
  5. if (/^\s*#\s*define\s+CONFIG_U8G2_FONT_SELECTION\s+"([^"]+)"/) {
  6. @font_selection = split(/,/, $1);
  7. last;
  8. }
  9. }
  10. if (@font_selection > 0) {
  11. print << 'HEADER';
  12. #ifndef _U8G2_FONTS_H
  13. #define _U8G2_FONTS_H
  14. #define U8G2_FONT_TABLE_ENTRY(font)
  15. #define U8G2_FONT_TABLE \
  16. HEADER
  17. foreach my $font (@font_selection) {
  18. print(" U8G2_FONT_TABLE_ENTRY($font) \\\n");
  19. }
  20. print << 'FOOTER';
  21. #endif /* _U8G2_FONTS_H */
  22. FOOTER
  23. }