mf_config.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /* Configuration constants for mcufont. */
  2. #ifndef _MF_CONFIG_H_
  3. #define _MF_CONFIG_H_
  4. #ifdef __AVR__
  5. #include <avr/pgmspace.h>
  6. #elif defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)
  7. #include <pgmspace.h>
  8. #else
  9. #include <stdint.h>
  10. #define PROGMEM
  11. #define pgm_read_byte(addr) (*(const unsigned char *)(addr))
  12. #define pgm_read_word(addr) (*(const uint16_t *)(addr))
  13. #endif /* __AVR__ */
  14. /*******************************************************
  15. * Configuration settings related to build environment *
  16. *******************************************************/
  17. /* Name of the file that contains all the included fonts. */
  18. #ifndef MF_FONT_FILE_NAME
  19. #define MF_FONT_FILE_NAME "fonts.h"
  20. #endif
  21. /*****************************************
  22. * Configuration settings related to API *
  23. *****************************************/
  24. /* Encoding for the input data.
  25. * With the unicode encodings, the library supports the range of unicode
  26. * characters 0x0000-0xFFFF (the Basic Multilingual Plane).
  27. *
  28. * ASCII: Plain ascii (somewhat works with ISO8859-1 also)
  29. * UTF8: UTF8 encoding (variable number of bytes)
  30. * UTF16: UTF16 encoding (2 bytes per character, compatible with UCS-2)
  31. * WCHAR: Use compiler's wchar_t (usually same as UTF16)
  32. */
  33. #define MF_ENCODING_ASCII 0
  34. #define MF_ENCODING_UTF8 1
  35. #define MF_ENCODING_UTF16 2
  36. #define MF_ENCODING_WCHAR 3
  37. #ifndef MF_ENCODING
  38. #define MF_ENCODING MF_ENCODING_UTF8
  39. #endif
  40. /************************************************************************
  41. * Configuration settings related to visual appearance of rendered text *
  42. ************************************************************************/
  43. /* Minimum space between characters, in percents of the glyph width.
  44. * Increasing this causes the kerning module to leave more space between
  45. * characters.
  46. */
  47. #ifndef MF_KERNING_SPACE_PERCENT
  48. #define MF_KERNING_SPACE_PERCENT 15
  49. #endif
  50. /* Minimum space between characters, in pixels. Added to the percentual
  51. * spacing. This pixel-based value guarantees enough space even with small
  52. * fonts.
  53. */
  54. #ifndef MF_KERNING_SPACE_PIXELS
  55. #define MF_KERNING_SPACE_PIXELS 3
  56. #endif
  57. /* Maximum adjustment done by the kerning algorithm, as percent of the
  58. * glyph width.
  59. */
  60. #ifndef MF_KERNING_LIMIT
  61. #define MF_KERNING_LIMIT 20
  62. #endif
  63. /* Spacing of tabulator stops. The value is multiplied by the width of the
  64. * 'm' character in the current font.
  65. */
  66. #ifndef MF_TABSIZE
  67. #define MF_TABSIZE 8
  68. #endif
  69. /*************************************************************************
  70. * Configuration settings to strip down library to reduce resource usage *
  71. *************************************************************************/
  72. /* Enable or disable the kerning module.
  73. * Disabling it saves some code size and run time, but causes the spacing
  74. * between characters to be less consistent.
  75. */
  76. #ifndef MF_USE_KERNING
  77. #define MF_USE_KERNING 1
  78. #endif
  79. /* Enable or disable the advanced word wrap algorithm.
  80. * If disabled, uses a simpler algorithm.
  81. */
  82. #ifndef MF_USE_ADVANCED_WORDWRAP
  83. #define MF_USE_ADVANCED_WORDWRAP 1
  84. #endif
  85. /* Enable of disable the justification algorithm.
  86. * If disabled, mf_render_justified renders just left-aligned.
  87. */
  88. #ifndef MF_USE_JUSTIFY
  89. #define MF_USE_JUSTIFY 1
  90. #endif
  91. /* Enable or disable the center and right alignment code.
  92. * If disabled, any alignment results in MF_ALIGN_LEFT.
  93. */
  94. #ifndef MF_USE_ALIGN
  95. #define MF_USE_ALIGN 1
  96. #endif
  97. /* Enable or disable the support for tab alignment.
  98. * If disabled, tabs will be rendered as regular space character.
  99. */
  100. #ifndef MF_USE_TABS
  101. #define MF_USE_TABS 1
  102. #endif
  103. /* Number of vertical zones to use when computing kerning.
  104. * Larger values give more accurate kerning, but are slower and use somewhat
  105. * more memory. There is no point to increase this beyond the height of the
  106. * font.
  107. */
  108. #ifndef MF_KERNING_ZONES
  109. #define MF_KERNING_ZONES 16
  110. #endif
  111. /* Add extern "C" when used from C++. */
  112. #ifdef __cplusplus
  113. #define MF_EXTERN extern "C"
  114. #else
  115. #define MF_EXTERN extern
  116. #endif
  117. #endif