Skip to content

Commit 41b89f2

Browse files
src/: cope with MuPDF master change to fz_stext_char.
Member is renamed, and srgb values now have non-zero s.
1 parent 6f11085 commit 41b89f2

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

src/__init__.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16548,7 +16548,10 @@ def __str__(self):
1654816548
style.size = ch.m_internal.size
1654916549
style.flags = flags
1655016550
style.font = JM_font_name(mupdf.FzFont(mupdf.ll_fz_keep_font(ch.m_internal.font)))
16551-
style.color = ch.m_internal.color
16551+
if mupdf_version_tuple >= (1, 26):
16552+
style.color = ch.m_internal.argb
16553+
else:
16554+
style.color = ch.m_internal.color
1655216555
style.asc = JM_font_ascender(mupdf.FzFont(mupdf.ll_fz_keep_font(ch.m_internal.font)))
1655316556
style.desc = JM_font_descender(mupdf.FzFont(mupdf.ll_fz_keep_font(ch.m_internal.font)))
1655416557

@@ -21058,10 +21061,12 @@ def sRGB_to_rgb(srgb: int) -> tuple:
2105821061
There is **no error checking** for performance reasons!
2105921062

2106021063
Args:
21061-
srgb: (int) RRGGBB (red, green, blue), each color in range(255).
21064+
srgb: (int) SSRRGGBB (red, green, blue), each color in range(255).
21065+
With MuPDF < 1.26, `s` is always 0.
2106221066
Returns:
2106321067
Tuple (red, green, blue) each item in interval 0 <= item <= 255.
2106421068
"""
21069+
srgb &= 0xffffff
2106521070
r = srgb >> 16
2106621071
g = (srgb - (r << 16)) >> 8
2106721072
b = srgb - (r << 16) - (g << 8)

src/extra.i

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3045,7 +3045,7 @@ mupdf::FzRect JM_make_spanlist(
30453045
float size = -1;
30463046
int flags = -1;
30473047
const char *font = "";
3048-
int color = -1;
3048+
unsigned int color = -1;
30493049
float asc = 0;
30503050
float desc = 0;
30513051
};
@@ -3064,7 +3064,11 @@ mupdf::FzRect JM_make_spanlist(
30643064
style.size = ch.m_internal->size;
30653065
style.flags = flags;
30663066
style.font = JM_font_name(ch.m_internal->font);
3067-
style.color = ch.m_internal->color;
3067+
#if (FZ_VERSION_MAJOR > 1 || (FZ_VERSION_MAJOR == 1 && FZ_VERSION_MINOR >= 26))
3068+
style.color = ch.m_internal->argb;
3069+
#else
3070+
style.color = ch.m_internal->color;
3071+
#endif
30683072
style.asc = JM_font_ascender(ch.m_internal->font);
30693073
style.desc = JM_font_descender(ch.m_internal->font);
30703074

0 commit comments

Comments
 (0)