Updated raqm to 0.10.3

This commit is contained in:
Andrew Murray 2025-08-06 09:00:36 +10:00
parent 1e76b758f6
commit 4f8ac76407
5 changed files with 65 additions and 43 deletions

View File

@ -2,7 +2,7 @@
# install raqm
archive=libraqm-0.10.2
archive=libraqm-0.10.3
./download-and-extract.sh $archive https://raw.githubusercontent.com/python-pillow/pillow-depends/main/$archive.tar.gz

View File

@ -1,7 +1,7 @@
The MIT License (MIT)
Copyright © 2015 Information Technology Authority (ITA) <foss@ita.gov.om>
Copyright © 2016-2023 Khaled Hosny <khaled@aliftype.com>
Copyright © 2016-2025 Khaled Hosny <khaled@aliftype.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -1,3 +1,19 @@
Overview of changes leading to 0.10.3
Tuesday, August 5, 2025
====================================
Fix raqm_set_text_utf8/utf16 reading beyond len for multibyte.
Support building against SheenBidi 2.9.
Fix deprecation warning with latest HarfBuzz.
Overview of changes leading to 0.10.2
Sunday, September 22, 2024
====================================
Fix Unicode codepoint conversion from UTF-16.
Overview of changes leading to 0.10.1
Wednesday, April 12, 2023
====================================

View File

@ -33,9 +33,9 @@
#define RAQM_VERSION_MAJOR 0
#define RAQM_VERSION_MINOR 10
#define RAQM_VERSION_MICRO 1
#define RAQM_VERSION_MICRO 3
#define RAQM_VERSION_STRING "0.10.1"
#define RAQM_VERSION_STRING "0.10.3"
#define RAQM_VERSION_ATLEAST(major,minor,micro) \
((major)*10000+(minor)*100+(micro) <= \

View File

@ -30,7 +30,11 @@
#include <string.h>
#ifdef RAQM_SHEENBIDI
#ifdef RAQM_SHEENBIDI_GT_2_9
#include <SheenBidi/SheenBidi.h>
#else
#include <SheenBidi.h>
#endif
#else
#ifdef HAVE_FRIBIDI_SYSTEM
#include <fribidi.h>
@ -546,34 +550,32 @@ raqm_set_text (raqm_t *rq,
return true;
}
static void *
_raqm_get_utf8_codepoint (const void *str,
static const char *
_raqm_get_utf8_codepoint (const char *str,
uint32_t *out_codepoint)
{
const char *s = (const char *)str;
if (0xf0 == (0xf8 & s[0]))
if (0xf0 == (0xf8 & str[0]))
{
*out_codepoint = ((0x07 & s[0]) << 18) | ((0x3f & s[1]) << 12) | ((0x3f & s[2]) << 6) | (0x3f & s[3]);
s += 4;
*out_codepoint = ((0x07 & str[0]) << 18) | ((0x3f & str[1]) << 12) | ((0x3f & str[2]) << 6) | (0x3f & str[3]);
str += 4;
}
else if (0xe0 == (0xf0 & s[0]))
else if (0xe0 == (0xf0 & str[0]))
{
*out_codepoint = ((0x0f & s[0]) << 12) | ((0x3f & s[1]) << 6) | (0x3f & s[2]);
s += 3;
*out_codepoint = ((0x0f & str[0]) << 12) | ((0x3f & str[1]) << 6) | (0x3f & str[2]);
str += 3;
}
else if (0xc0 == (0xe0 & s[0]))
else if (0xc0 == (0xe0 & str[0]))
{
*out_codepoint = ((0x1f & s[0]) << 6) | (0x3f & s[1]);
s += 2;
*out_codepoint = ((0x1f & str[0]) << 6) | (0x3f & str[1]);
str += 2;
}
else
{
*out_codepoint = s[0];
s += 1;
*out_codepoint = str[0];
str += 1;
}
return (void *)s;
return str;
}
static size_t
@ -585,42 +587,41 @@ _raqm_u8_to_u32 (const char *text, size_t len, uint32_t *unicode)
while ((*in_utf8 != '\0') && (in_len < len))
{
in_utf8 = _raqm_get_utf8_codepoint (in_utf8, out_utf32);
const char *out_utf8 = _raqm_get_utf8_codepoint (in_utf8, out_utf32);
in_len += out_utf8 - in_utf8;
in_utf8 = out_utf8;
++out_utf32;
++in_len;
}
return (out_utf32 - unicode);
}
static void *
_raqm_get_utf16_codepoint (const void *str,
uint32_t *out_codepoint)
static const uint16_t *
_raqm_get_utf16_codepoint (const uint16_t *str,
uint32_t *out_codepoint)
{
const uint16_t *s = (const uint16_t *)str;
if (s[0] > 0xD800 && s[0] < 0xDBFF)
if (str[0] >= 0xD800 && str[0] <= 0xDBFF)
{
if (s[1] > 0xDC00 && s[1] < 0xDFFF)
if (str[1] >= 0xDC00 && str[1] <= 0xDFFF)
{
uint32_t X = ((s[0] & ((1 << 6) -1)) << 10) | (s[1] & ((1 << 10) -1));
uint32_t W = (s[0] >> 6) & ((1 << 5) - 1);
uint32_t X = ((str[0] & ((1 << 6) -1)) << 10) | (str[1] & ((1 << 10) -1));
uint32_t W = (str[0] >> 6) & ((1 << 5) - 1);
*out_codepoint = (W+1) << 16 | X;
s += 2;
str += 2;
}
else
{
/* A single high surrogate, this is an error. */
*out_codepoint = s[0];
s += 1;
*out_codepoint = str[0];
str += 1;
}
}
else
{
*out_codepoint = s[0];
s += 1;
*out_codepoint = str[0];
str += 1;
}
return (void *)s;
return str;
}
static size_t
@ -632,9 +633,10 @@ _raqm_u16_to_u32 (const uint16_t *text, size_t len, uint32_t *unicode)
while ((*in_utf16 != '\0') && (in_len < len))
{
in_utf16 = _raqm_get_utf16_codepoint (in_utf16, out_utf32);
const uint16_t *out_utf16 = _raqm_get_utf16_codepoint (in_utf16, out_utf32);
in_len += (out_utf16 - in_utf16);
in_utf16 = out_utf16;
++out_utf32;
++in_len;
}
return (out_utf32 - unicode);
@ -1114,12 +1116,12 @@ _raqm_set_spacing (raqm_t *rq,
{
if (_raqm_allowed_grapheme_boundary (rq->text[i], rq->text[i+1]))
{
/* CSS word seperators, word spacing is only applied on these.*/
/* CSS word separators, word spacing is only applied on these.*/
if (rq->text[i] == 0x0020 || /* Space */
rq->text[i] == 0x00A0 || /* No Break Space */
rq->text[i] == 0x1361 || /* Ethiopic Word Space */
rq->text[i] == 0x10100 || /* Aegean Word Seperator Line */
rq->text[i] == 0x10101 || /* Aegean Word Seperator Dot */
rq->text[i] == 0x10100 || /* Aegean Word Separator Line */
rq->text[i] == 0x10101 || /* Aegean Word Separator Dot */
rq->text[i] == 0x1039F || /* Ugaric Word Divider */
rq->text[i] == 0x1091F) /* Phoenician Word Separator */
{
@ -2167,6 +2169,10 @@ _raqm_ft_transform (int *x,
*y = vector.y;
}
#if !HB_VERSION_ATLEAST (10, 4, 0)
# define hb_ft_font_get_ft_face hb_ft_font_get_face
#endif
static bool
_raqm_shape (raqm_t *rq)
{
@ -2199,7 +2205,7 @@ _raqm_shape (raqm_t *rq)
hb_glyph_position_t *pos;
unsigned int len;
FT_Get_Transform (hb_ft_font_get_face (run->font), &matrix, NULL);
FT_Get_Transform (hb_ft_font_get_ft_face (run->font), &matrix, NULL);
pos = hb_buffer_get_glyph_positions (run->buffer, &len);
info = hb_buffer_get_glyph_infos (run->buffer, &len);