diff --git a/src/__init__.py b/src/__init__.py index 16631129a..bd66a643e 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -16548,7 +16548,10 @@ def __str__(self): style.size = ch.m_internal.size style.flags = flags style.font = JM_font_name(mupdf.FzFont(mupdf.ll_fz_keep_font(ch.m_internal.font))) - style.color = ch.m_internal.color + if mupdf_version_tuple >= (1, 26): + style.color = ch.m_internal.argb + else: + style.color = ch.m_internal.color style.asc = JM_font_ascender(mupdf.FzFont(mupdf.ll_fz_keep_font(ch.m_internal.font))) style.desc = JM_font_descender(mupdf.FzFont(mupdf.ll_fz_keep_font(ch.m_internal.font))) @@ -21058,10 +21061,12 @@ def sRGB_to_rgb(srgb: int) -> tuple: There is **no error checking** for performance reasons! Args: - srgb: (int) RRGGBB (red, green, blue), each color in range(255). + srgb: (int) SSRRGGBB (red, green, blue), each color in range(255). + With MuPDF < 1.26, `s` is always 0. Returns: Tuple (red, green, blue) each item in interval 0 <= item <= 255. """ + srgb &= 0xffffff r = srgb >> 16 g = (srgb - (r << 16)) >> 8 b = srgb - (r << 16) - (g << 8) diff --git a/src/extra.i b/src/extra.i index 0b5b8c6f9..5c1d7910f 100644 --- a/src/extra.i +++ b/src/extra.i @@ -3045,7 +3045,7 @@ mupdf::FzRect JM_make_spanlist( float size = -1; int flags = -1; const char *font = ""; - int color = -1; + unsigned int color = -1; float asc = 0; float desc = 0; }; @@ -3064,7 +3064,11 @@ mupdf::FzRect JM_make_spanlist( style.size = ch.m_internal->size; style.flags = flags; style.font = JM_font_name(ch.m_internal->font); - style.color = ch.m_internal->color; + #if (FZ_VERSION_MAJOR > 1 || (FZ_VERSION_MAJOR == 1 && FZ_VERSION_MINOR >= 26)) + style.color = ch.m_internal->argb; + #else + style.color = ch.m_internal->color; + #endif style.asc = JM_font_ascender(ch.m_internal->font); style.desc = JM_font_descender(ch.m_internal->font);