/src/linebreak/linebreak.h

http://ftk.googlecode.com/ · C Header · 87 lines · 30 code · 11 blank · 46 comment · 0 complexity · 905f2cab3cadd73f4e2e888bbcebd918 MD5 · raw file

  1. /* vim: set tabstop=4 shiftwidth=4: */
  2. /*
  3. * Line breaking in a Unicode sequence. Designed to be used in a
  4. * generic text renderer.
  5. *
  6. * Copyright (C) 2008-2010 Wu Yongwei <wuyongwei at gmail dot com>
  7. *
  8. * This software is provided 'as-is', without any express or implied
  9. * warranty. In no event will the author be held liable for any damages
  10. * arising from the use of this software.
  11. *
  12. * Permission is granted to anyone to use this software for any purpose,
  13. * including commercial applications, and to alter it and redistribute
  14. * it freely, subject to the following restrictions:
  15. *
  16. * 1. The origin of this software must not be misrepresented; you must
  17. * not claim that you wrote the original software. If you use this
  18. * software in a product, an acknowledgement in the product
  19. * documentation would be appreciated but is not required.
  20. * 2. Altered source versions must be plainly marked as such, and must
  21. * not be misrepresented as being the original software.
  22. * 3. This notice may not be removed or altered from any source
  23. * distribution.
  24. *
  25. * The main reference is Unicode Standard Annex 14 (UAX #14):
  26. * <URL:http://www.unicode.org/reports/tr14/>
  27. *
  28. * When this library was designed, this annex was at Revision 19, for
  29. * Unicode 5.0.0:
  30. * <URL:http://www.unicode.org/reports/tr14/tr14-19.html>
  31. *
  32. * This library has been updated according to Revision 24, for
  33. * Unicode 5.2.0:
  34. * <URL:http://www.unicode.org/reports/tr14/tr14-24.html>
  35. *
  36. * The Unicode Terms of Use are available at
  37. * <URL:http://www.unicode.org/copyright.html>
  38. */
  39. /**
  40. * @file linebreak.h
  41. *
  42. * Header file for the line breaking algorithm.
  43. *
  44. * @version 2.0, 2010/01/03
  45. * @author Wu Yongwei
  46. */
  47. #ifndef LINEBREAK_H
  48. #define LINEBREAK_H
  49. #include <stddef.h>
  50. #ifdef __cplusplus
  51. extern "C" {
  52. #endif
  53. #define LINEBREAK_VERSION 0x0200 /**< Version of the library linebreak */
  54. extern const int linebreak_version;
  55. #ifndef LINEBREAK_UTF_TYPES_DEFINED
  56. #define LINEBREAK_UTF_TYPES_DEFINED
  57. typedef unsigned char utf8_t; /**< Type for UTF-8 data points */
  58. typedef unsigned short utf16_t; /**< Type for UTF-16 data points */
  59. typedef unsigned int utf32_t; /**< Type for UTF-32 data points */
  60. #endif
  61. #define LINEBREAK_MUSTBREAK 0 /**< Break is mandatory */
  62. #define LINEBREAK_ALLOWBREAK 1 /**< Break is allowed */
  63. #define LINEBREAK_NOBREAK 2 /**< No break is possible */
  64. #define LINEBREAK_INSIDEACHAR 3 /**< A UTF-8/16 sequence is unfinished */
  65. void init_linebreak(void);
  66. void set_linebreaks_utf8(
  67. const utf8_t *s, size_t len, const char* lang, char *brks);
  68. void set_linebreaks_utf16(
  69. const utf16_t *s, size_t len, const char* lang, char *brks);
  70. void set_linebreaks_utf32(
  71. const utf32_t *s, size_t len, const char* lang, char *brks);
  72. int is_line_breakable(utf32_t char1, utf32_t char2, const char* lang);
  73. #ifdef __cplusplus
  74. }
  75. #endif
  76. #endif /* LINEBREAK_H */