1 #ifndef SCRIPT_IDENTIFY_H_ 2 #define SCRIPT_IDENTIFY_H_ 3 4 #include <stdint.h> 5 6 #include <harfbuzz-shaper.h> 7 8 static const uint32_t HB_InvalidCodePoint = 0xffffffffu; 9 10 // ----------------------------------------------------------------------------- 11 // Return the next Unicode code point from a UTF-16 vector 12 // chars: a pointer to @len words 13 // iter: (input/output) an index into @chars. This is updated. 14 // returns: HB_InvalidCodePoint on error and the code point otherwise. 15 // ----------------------------------------------------------------------------- 16 uint32_t utf16_to_code_point(const uint16_t *chars, size_t len, ssize_t *iter); 17 18 // ----------------------------------------------------------------------------- 19 // Like the above, except that the code points are traversed backwards. Thus, 20 // on the first call, |iter| should be |len| - 1. 21 // ----------------------------------------------------------------------------- 22 uint32_t utf16_to_code_point(const uint16_t *chars, size_t len, ssize_t *iter); 23 24 // ----------------------------------------------------------------------------- 25 // Return the script of the given code point 26 // ----------------------------------------------------------------------------- 27 HB_Script code_point_to_script(uint32_t cp); 28 29 // ----------------------------------------------------------------------------- 30 // Find the next script run in a UTF-16 string. 31 // 32 // A script run is a subvector of codepoints, all of which are in the same 33 // script. A run will never cut a surrogate pair in half at either end. 34 // 35 // num_code_points: (output, maybe NULL) the number of code points in the run 36 // output: (output) the @pos, @length and @script fields are set on success 37 // chars: the UTF-16 string 38 // len: the length of @chars, in words 39 // iter: (in/out) the current index into the string. This should be 0 for the 40 // first call and is updated on exit. 41 // 42 // returns: non-zero if a script run was found and returned. 43 // ----------------------------------------------------------------------------- 44 char hb_utf16_script_run_next(unsigned *num_code_points, HB_ScriptItem *output, 45 const uint16_t *chars, size_t len, ssize_t *iter); 46 47 // ----------------------------------------------------------------------------- 48 // This is the same as above, except that the input is traversed backwards. 49 // Thus, on the first call, |iter| should be |len| - 1. 50 // ----------------------------------------------------------------------------- 51 char hb_utf16_script_run_prev(unsigned *num_code_points, HB_ScriptItem *output, 52 const uint16_t *chars, size_t len, ssize_t *iter); 53 54 #endif 55