3030#include <string.h>
3131
3232#ifdef RAQM_SHEENBIDI
33+ #ifdef RAQM_SHEENBIDI_GT_2_9
34+ #include <SheenBidi/SheenBidi.h>
35+ #else
3336#include <SheenBidi.h>
37+ #endif
3438#else
3539#ifdef HAVE_FRIBIDI_SYSTEM
3640#include <fribidi.h>
@@ -546,34 +550,32 @@ raqm_set_text (raqm_t *rq,
546550 return true;
547551}
548552
549- static void *
550- _raqm_get_utf8_codepoint (const void * str ,
553+ static const char *
554+ _raqm_get_utf8_codepoint (const char * str ,
551555 uint32_t * out_codepoint )
552556{
553- const char * s = (const char * )str ;
554-
555- if (0xf0 == (0xf8 & s [0 ]))
557+ if (0xf0 == (0xf8 & str [0 ]))
556558 {
557- * out_codepoint = ((0x07 & s [0 ]) << 18 ) | ((0x3f & s [1 ]) << 12 ) | ((0x3f & s [2 ]) << 6 ) | (0x3f & s [3 ]);
558- s += 4 ;
559+ * out_codepoint = ((0x07 & str [0 ]) << 18 ) | ((0x3f & str [1 ]) << 12 ) | ((0x3f & str [2 ]) << 6 ) | (0x3f & str [3 ]);
560+ str += 4 ;
559561 }
560- else if (0xe0 == (0xf0 & s [0 ]))
562+ else if (0xe0 == (0xf0 & str [0 ]))
561563 {
562- * out_codepoint = ((0x0f & s [0 ]) << 12 ) | ((0x3f & s [1 ]) << 6 ) | (0x3f & s [2 ]);
563- s += 3 ;
564+ * out_codepoint = ((0x0f & str [0 ]) << 12 ) | ((0x3f & str [1 ]) << 6 ) | (0x3f & str [2 ]);
565+ str += 3 ;
564566 }
565- else if (0xc0 == (0xe0 & s [0 ]))
567+ else if (0xc0 == (0xe0 & str [0 ]))
566568 {
567- * out_codepoint = ((0x1f & s [0 ]) << 6 ) | (0x3f & s [1 ]);
568- s += 2 ;
569+ * out_codepoint = ((0x1f & str [0 ]) << 6 ) | (0x3f & str [1 ]);
570+ str += 2 ;
569571 }
570572 else
571573 {
572- * out_codepoint = s [0 ];
573- s += 1 ;
574+ * out_codepoint = str [0 ];
575+ str += 1 ;
574576 }
575577
576- return ( void * ) s ;
578+ return str ;
577579}
578580
579581static size_t
@@ -585,42 +587,41 @@ _raqm_u8_to_u32 (const char *text, size_t len, uint32_t *unicode)
585587
586588 while ((* in_utf8 != '\0' ) && (in_len < len ))
587589 {
588- in_utf8 = _raqm_get_utf8_codepoint (in_utf8 , out_utf32 );
590+ const char * out_utf8 = _raqm_get_utf8_codepoint (in_utf8 , out_utf32 );
591+ in_len += out_utf8 - in_utf8 ;
592+ in_utf8 = out_utf8 ;
589593 ++ out_utf32 ;
590- ++ in_len ;
591594 }
592595
593596 return (out_utf32 - unicode );
594597}
595598
596- static void *
597- _raqm_get_utf16_codepoint (const void * str ,
598- uint32_t * out_codepoint )
599+ static const uint16_t *
600+ _raqm_get_utf16_codepoint (const uint16_t * str ,
601+ uint32_t * out_codepoint )
599602{
600- const uint16_t * s = (const uint16_t * )str ;
601-
602- if (s [0 ] > 0xD800 && s [0 ] < 0xDBFF )
603+ if (str [0 ] >= 0xD800 && str [0 ] <= 0xDBFF )
603604 {
604- if (s [1 ] > 0xDC00 && s [1 ] < 0xDFFF )
605+ if (str [1 ] >= 0xDC00 && str [1 ] <= 0xDFFF )
605606 {
606- uint32_t X = ((s [0 ] & ((1 << 6 ) - 1 )) << 10 ) | (s [1 ] & ((1 << 10 ) - 1 ));
607- uint32_t W = (s [0 ] >> 6 ) & ((1 << 5 ) - 1 );
607+ uint32_t X = ((str [0 ] & ((1 << 6 ) - 1 )) << 10 ) | (str [1 ] & ((1 << 10 ) - 1 ));
608+ uint32_t W = (str [0 ] >> 6 ) & ((1 << 5 ) - 1 );
608609 * out_codepoint = (W + 1 ) << 16 | X ;
609- s += 2 ;
610+ str += 2 ;
610611 }
611612 else
612613 {
613614 /* A single high surrogate, this is an error. */
614- * out_codepoint = s [0 ];
615- s += 1 ;
615+ * out_codepoint = str [0 ];
616+ str += 1 ;
616617 }
617618 }
618619 else
619620 {
620- * out_codepoint = s [0 ];
621- s += 1 ;
621+ * out_codepoint = str [0 ];
622+ str += 1 ;
622623 }
623- return ( void * ) s ;
624+ return str ;
624625}
625626
626627static size_t
@@ -632,9 +633,10 @@ _raqm_u16_to_u32 (const uint16_t *text, size_t len, uint32_t *unicode)
632633
633634 while ((* in_utf16 != '\0' ) && (in_len < len ))
634635 {
635- in_utf16 = _raqm_get_utf16_codepoint (in_utf16 , out_utf32 );
636+ const uint16_t * out_utf16 = _raqm_get_utf16_codepoint (in_utf16 , out_utf32 );
637+ in_len += (out_utf16 - in_utf16 );
638+ in_utf16 = out_utf16 ;
636639 ++ out_utf32 ;
637- ++ in_len ;
638640 }
639641
640642 return (out_utf32 - unicode );
@@ -1114,12 +1116,12 @@ _raqm_set_spacing (raqm_t *rq,
11141116 {
11151117 if (_raqm_allowed_grapheme_boundary (rq -> text [i ], rq -> text [i + 1 ]))
11161118 {
1117- /* CSS word seperators , word spacing is only applied on these.*/
1119+ /* CSS word separators , word spacing is only applied on these.*/
11181120 if (rq -> text [i ] == 0x0020 || /* Space */
11191121 rq -> text [i ] == 0x00A0 || /* No Break Space */
11201122 rq -> text [i ] == 0x1361 || /* Ethiopic Word Space */
1121- rq -> text [i ] == 0x10100 || /* Aegean Word Seperator Line */
1122- rq -> text [i ] == 0x10101 || /* Aegean Word Seperator Dot */
1123+ rq -> text [i ] == 0x10100 || /* Aegean Word Separator Line */
1124+ rq -> text [i ] == 0x10101 || /* Aegean Word Separator Dot */
11231125 rq -> text [i ] == 0x1039F || /* Ugaric Word Divider */
11241126 rq -> text [i ] == 0x1091F ) /* Phoenician Word Separator */
11251127 {
@@ -2167,6 +2169,10 @@ _raqm_ft_transform (int *x,
21672169 * y = vector .y ;
21682170}
21692171
2172+ #if !HB_VERSION_ATLEAST (10 , 4 , 0 )
2173+ # define hb_ft_font_get_ft_face hb_ft_font_get_face
2174+ #endif
2175+
21702176static bool
21712177_raqm_shape (raqm_t * rq )
21722178{
@@ -2199,7 +2205,7 @@ _raqm_shape (raqm_t *rq)
21992205 hb_glyph_position_t * pos ;
22002206 unsigned int len ;
22012207
2202- FT_Get_Transform (hb_ft_font_get_face (run -> font ), & matrix , NULL );
2208+ FT_Get_Transform (hb_ft_font_get_ft_face (run -> font ), & matrix , NULL );
22032209 pos = hb_buffer_get_glyph_positions (run -> buffer , & len );
22042210 info = hb_buffer_get_glyph_infos (run -> buffer , & len );
22052211
0 commit comments