My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

fontutils.h 2.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  4. *
  5. * Based on Sprinter and grbl.
  6. * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. *
  21. */
  22. /**
  23. * @file fontutils.h
  24. * @brief help functions for font and char
  25. * @author Yunhui Fu (yhfudev@gmail.com)
  26. * @version 1.0
  27. * @date 2016-08-19
  28. * @copyright GPL/BSD
  29. */
  30. #pragma once
  31. #include <stdlib.h>
  32. #include <stdint.h> // uint32_t
  33. #include "../HAL/shared/Marduino.h"
  34. #include "../core/macros.h"
  35. #define MAX_UTF8_CHAR_SIZE 4
  36. // Use a longer character type (if needed) because wchar_t is only 16 bits wide
  37. #ifdef MAX_UTF8_CHAR_SIZE
  38. #if MAX_UTF8_CHAR_SIZE > 2
  39. typedef uint32_t lchar_t;
  40. #else
  41. typedef wchar_t lchar_t;
  42. #endif
  43. #else
  44. #define wchar_t uint32_t
  45. #endif
  46. // read a byte from ROM or RAM
  47. typedef uint8_t (*read_byte_cb_t)(const uint8_t * str);
  48. uint8_t read_byte_ram(const uint8_t *str);
  49. uint8_t read_byte_rom(const uint8_t *str);
  50. typedef uint16_t pixel_len_t;
  51. #define PIXEL_LEN_NOLIMIT ((pixel_len_t)(-1))
  52. /* Perform binary search */
  53. typedef int (* pf_bsearch_cb_comp_t)(void *userdata, size_t idx, void * data_pin);
  54. int pf_bsearch_r(void *userdata, size_t num_data, pf_bsearch_cb_comp_t cb_comp, void *data_pinpoint, size_t *ret_idx);
  55. /* Get the character, decoding multibyte UTF8 characters and returning a pointer to the start of the next UTF8 character */
  56. const uint8_t* get_utf8_value_cb(const uint8_t *pstart, read_byte_cb_t cb_read_byte, lchar_t &pval);
  57. inline const char* get_utf8_value_cb(const char *pstart, read_byte_cb_t cb_read_byte, lchar_t &pval) {
  58. return (const char *)get_utf8_value_cb((const uint8_t *)pstart, cb_read_byte, pval);
  59. }
  60. /* Returns length of string in CHARACTERS, NOT BYTES */
  61. uint8_t utf8_strlen(const char *pstart);
  62. uint8_t utf8_strlen_P(PGM_P pstart);
  63. inline uint8_t utf8_strlen(FSTR_P fstart) { return utf8_strlen_P(FTOP(fstart)); }
  64. /* Returns start byte position of desired char number */
  65. uint8_t utf8_byte_pos_by_char_num(const char *pstart, const uint8_t charnum);
  66. uint8_t utf8_byte_pos_by_char_num_P(PGM_P pstart, const uint8_t charnum);