Skip to content

Commit

Permalink
src/: cope with MuPDF master change to fz_stext_char.
Browse files Browse the repository at this point in the history
Member is renamed, and srgb values now have non-zero s.
  • Loading branch information
julian-smith-artifex-com committed Nov 15, 2024
1 parent fb905b1 commit 4a83e3f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
9 changes: 7 additions & 2 deletions src/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)))

Expand Down Expand Up @@ -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)
Expand Down
8 changes: 6 additions & 2 deletions src/extra.i
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand All @@ -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);

Expand Down

0 comments on commit 4a83e3f

Please sign in to comment.