codesearch.c 912 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include "u8g2.h"
  4. /* both arrays are NULL terminated */
  5. extern const uint8_t *u8g2_font_list[];
  6. extern char *u8g2_font_names[];
  7. u8g2_t u8g2;
  8. int main(int argc, char **argv)
  9. {
  10. int i, is_found;
  11. uint16_t encoding;
  12. if ( argc <= 1 )
  13. {
  14. printf("codesearch encoding\n");
  15. }
  16. else
  17. {
  18. encoding = atoi(argv[1]);
  19. u8g2_Setup_null(&u8g2, U8G2_R0, u8x8_byte_empty, u8x8_dummy_cb);
  20. i = 0;
  21. is_found = 0;
  22. while( u8g2_font_list[i] != NULL )
  23. {
  24. u8g2_SetFont(&u8g2, u8g2_font_list[i]);
  25. if ( u8g2_IsGlyph(&u8g2, encoding) )
  26. {
  27. if ( is_found == 0 )
  28. {
  29. printf("encoding '%d' available in the following fonts:\n", encoding);
  30. is_found = 1;
  31. }
  32. printf("%s\n", u8g2_font_names[i]);
  33. }
  34. i++;
  35. }
  36. if ( is_found == 0 )
  37. {
  38. printf("encoding '%d' is not available in any font.\n", encoding);
  39. }
  40. }
  41. return 0;
  42. }