diff options
-rw-r--r-- | include/mupdf/fitz/font.h | 10 | ||||
-rw-r--r-- | include/mupdf/xps.h | 8 | ||||
-rw-r--r-- | source/fitz/draw-glyph.c | 12 | ||||
-rw-r--r-- | source/fitz/font.c | 10 | ||||
-rw-r--r-- | source/fitz/stext-device.c | 6 | ||||
-rw-r--r-- | source/fitz/stext-output.c | 20 | ||||
-rw-r--r-- | source/fitz/svg-device.c | 2 | ||||
-rw-r--r-- | source/fitz/trace-device.c | 2 | ||||
-rw-r--r-- | source/html/html-layout.c | 6 | ||||
-rw-r--r-- | source/pdf/pdf-device.c | 4 | ||||
-rw-r--r-- | source/pdf/pdf-op-run.c | 2 | ||||
-rw-r--r-- | source/tools/murun.c | 3 | ||||
-rw-r--r-- | source/xps/xps-glyphs.c | 26 |
13 files changed, 56 insertions, 55 deletions
diff --git a/include/mupdf/fitz/font.h b/include/mupdf/fitz/font.h index f8529c3b..8f6aa902 100644 --- a/include/mupdf/fitz/font.h +++ b/include/mupdf/fitz/font.h @@ -30,7 +30,7 @@ typedef struct fz_font_s fz_font; if not a freetype handled font. (Cast to void * to avoid nasty header exposure). */ -void *fz_font_ft_face(fz_font *font); +void *fz_font_ft_face(fz_context *ctx, fz_font *font); /* fz_font_t3_procs: Retrieve the Type3 procs @@ -41,7 +41,7 @@ void *fz_font_ft_face(fz_font *font); Returns the t3_procs pointer. Will be NULL for a non type-3 font. */ -fz_buffer **fz_font_t3_procs(fz_font *font); +fz_buffer **fz_font_t3_procs(fz_context *ctx, fz_font *font); /* ft_error_string: map an FT error number to a @@ -113,7 +113,7 @@ typedef struct Returns a pointer to the shaper data structure (or NULL if font is NULL). */ -fz_shaper_data_t *fz_font_shaper_data(fz_font *font); +fz_shaper_data_t *fz_font_shaper_data(fz_context *ctx, fz_font *font); /* fz_font_name: Retrieve a pointer to the name of the font. @@ -123,7 +123,7 @@ fz_shaper_data_t *fz_font_shaper_data(fz_font *font); Returns a pointer to an internal copy of the font name. Will never be NULL, but may be the empty string. */ -const char *fz_font_name(fz_font *font); +const char *fz_font_name(fz_context *ctx, fz_font *font); /* fz_font_bbox: Retrieve a pointer to the font bbox. @@ -133,7 +133,7 @@ const char *fz_font_name(fz_font *font); Returns a pointer to the font bbox (or NULL if the font is NULL). */ -fz_rect *fz_font_bbox(fz_font *font); +fz_rect *fz_font_bbox(fz_context *ctx, fz_font *font); /* fz_new_font_context: Initialise the font context. diff --git a/include/mupdf/xps.h b/include/mupdf/xps.h index e0f49b3d..c5350e58 100644 --- a/include/mupdf/xps.h +++ b/include/mupdf/xps.h @@ -141,10 +141,10 @@ struct xps_glyph_metrics_s float hadv, vadv, vorg; }; -int xps_count_font_encodings(fz_font *font); -void xps_identify_font_encoding(fz_font *font, int idx, int *pid, int *eid); -void xps_select_font_encoding(fz_font *font, int idx); -int xps_encode_font_char(fz_font *font, int key); +int xps_count_font_encodings(fz_context *ctx, fz_font *font); +void xps_identify_font_encoding(fz_context *ctx, fz_font *font, int idx, int *pid, int *eid); +void xps_select_font_encoding(fz_context *ctx, fz_font *font, int idx); +int xps_encode_font_char(fz_context *ctx, fz_font *font, int key); void xps_measure_font_glyph(fz_context *ctx, xps_document *doc, fz_font *font, int gid, xps_glyph_metrics *mtx); diff --git a/source/fitz/draw-glyph.c b/source/fitz/draw-glyph.c index 93bd62b3..a0c47b74 100644 --- a/source/fitz/draw-glyph.c +++ b/source/fitz/draw-glyph.c @@ -175,7 +175,7 @@ fz_subpixel_adjust(fz_context *ctx, fz_matrix *ctm, fz_matrix *subpix_ctm, unsig fz_glyph * fz_render_stroked_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix *trm, const fz_matrix *ctm, const fz_stroke_state *stroke, const fz_irect *scissor) { - if (fz_font_ft_face(font)) + if (fz_font_ft_face(ctx, font)) { fz_matrix subpix_trm; unsigned char qe, qf; @@ -191,7 +191,7 @@ fz_render_stroked_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix *trm, fz_pixmap * fz_render_stroked_glyph_pixmap(fz_context *ctx, fz_font *font, int gid, fz_matrix *trm, const fz_matrix *ctm, const fz_stroke_state *stroke, const fz_irect *scissor) { - if (fz_font_ft_face(font)) + if (fz_font_ft_face(ctx, font)) { fz_matrix subpix_trm; unsigned char qe, qf; @@ -252,7 +252,7 @@ fz_render_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix *ctm, fz_colo int do_cache, locked, caching; fz_glyph_cache_entry *entry; unsigned hash; - int is_ft_font = !!fz_font_ft_face(font); + int is_ft_font = !!fz_font_ft_face(ctx, font); fz_var(locked); fz_var(caching); @@ -312,7 +312,7 @@ fz_render_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix *ctm, fz_colo { val = fz_render_ft_glyph(ctx, font, gid, &subpix_ctm, key.aa); } - else if (fz_font_t3_procs(font)) + else if (fz_font_t3_procs(ctx, font)) { /* We drop the glyphcache here, and execute the t3 * glyph code. The danger here is that some other @@ -414,7 +414,7 @@ fz_render_glyph_pixmap(fz_context *ctx, fz_font *font, int gid, fz_matrix *ctm, unsigned char qe, qf; fz_matrix subpix_ctm; float size = fz_subpixel_adjust(ctx, ctm, &subpix_ctm, &qe, &qf); - int is_ft_font = !!fz_font_ft_face(font); + int is_ft_font = !!fz_font_ft_face(ctx, font); if (size <= MAX_GLYPH_SIZE) { @@ -432,7 +432,7 @@ fz_render_glyph_pixmap(fz_context *ctx, fz_font *font, int gid, fz_matrix *ctm, { val = fz_render_ft_glyph_pixmap(ctx, font, gid, &subpix_ctm, fz_text_aa_level(ctx)); } - else if (fz_font_t3_procs(font)) + else if (fz_font_t3_procs(ctx, font)) { val = fz_render_t3_glyph_pixmap(ctx, font, gid, &subpix_ctm, NULL, scissor); } diff --git a/source/fitz/font.c b/source/fitz/font.c index c5e6503e..6d86133c 100644 --- a/source/fitz/font.c +++ b/source/fitz/font.c @@ -1543,22 +1543,22 @@ fz_encode_character_with_fallback(fz_context *ctx, fz_font *user_font, int unico return *out_font = user_font, 0; } -const char *fz_font_name(fz_font *font) +const char *fz_font_name(fz_context *ctx, fz_font *font) { return font ? font->name : ""; } -fz_buffer **fz_font_t3_procs(fz_font *font) +fz_buffer **fz_font_t3_procs(fz_context *ctx, fz_font *font) { return font ? font->t3procs : NULL; } -fz_rect *fz_font_bbox(fz_font *font) +fz_rect *fz_font_bbox(fz_context *ctx, fz_font *font) { return font ? &font->bbox : NULL; } -void *fz_font_ft_face(fz_font *font) +void *fz_font_ft_face(fz_context *ctx, fz_font *font) { return font ? font->ft_face : NULL; } @@ -1568,7 +1568,7 @@ fz_font_flags_t *fz_font_flags(fz_font *font) return font ? &font->flags : NULL; } -fz_shaper_data_t *fz_font_shaper_data(fz_font *font) +fz_shaper_data_t *fz_font_shaper_data(fz_context *ctx, fz_font *font) { return font ? &font->shaper_data : NULL; } diff --git a/source/fitz/stext-device.c b/source/fitz/stext-device.c index 007a6a2a..c5073455 100644 --- a/source/fitz/stext-device.c +++ b/source/fitz/stext-device.c @@ -784,9 +784,9 @@ static void fz_stext_extract(fz_context *ctx, fz_stext_device *dev, fz_text_span *span, const fz_matrix *ctm, fz_stext_style *style) { fz_font *font = span->font; - FT_Face face = fz_font_ft_face(font); - fz_buffer **t3procs = fz_font_t3_procs(font); - fz_rect *bbox = fz_font_bbox(font); + FT_Face face = fz_font_ft_face(ctx, font); + fz_buffer **t3procs = fz_font_t3_procs(ctx, font); + fz_rect *bbox = fz_font_bbox(ctx, font); fz_matrix tm = span->trm; fz_matrix trm; float adv; diff --git a/source/fitz/stext-output.c b/source/fitz/stext-output.c index 39d97dc3..a6c51cb8 100644 --- a/source/fitz/stext-output.c +++ b/source/fitz/stext-output.c @@ -8,23 +8,23 @@ /* XML, HTML and plain-text output */ -static int font_is_bold(fz_font *font) +static int font_is_bold(fz_context *ctx, fz_font *font) { - FT_Face face = fz_font_ft_face(font); + FT_Face face = fz_font_ft_face(ctx, font); if (face && (face->style_flags & FT_STYLE_FLAG_BOLD)) return 1; - if (strstr(fz_font_name(font), "Bold")) + if (strstr(fz_font_name(ctx, font), "Bold")) return 1; return 0; } -static int font_is_italic(fz_font *font) +static int font_is_italic(fz_context *ctx, fz_font *font) { - FT_Face face = fz_font_ft_face(font); + FT_Face face = fz_font_ft_face(ctx, font); const char *name; if (face && (face->style_flags & FT_STYLE_FLAG_ITALIC)) return 1; - name = fz_font_name(font); + name = fz_font_name(ctx, font); if (strstr(name, "Italic") || strstr(name, "Oblique")) return 1; return 0; @@ -55,14 +55,14 @@ fz_print_style_end(fz_context *ctx, fz_output *out, fz_stext_style *style) static void fz_print_style(fz_context *ctx, fz_output *out, fz_stext_style *style) { - const char *name = fz_font_name(style->font); + const char *name = fz_font_name(ctx, style->font); const char *s = strchr(name, '+'); s = s ? s + 1 : name; fz_printf(ctx, out, "span.s%d{font-family:\"%s\";font-size:%gpt;", style->id, s, style->size); - if (font_is_italic(style->font)) + if (font_is_italic(ctx, style->font)) fz_printf(ctx, out, "font-style:italic;"); - if (font_is_bold(style->font)) + if (font_is_bold(ctx, style->font)) fz_printf(ctx, out, "font-weight:bold;"); fz_printf(ctx, out, "}\n"); } @@ -319,7 +319,7 @@ fz_print_stext_page_xml(fz_context *ctx, fz_output *out, fz_stext_page *page) fz_printf(ctx, out, "</span>\n"); } style = ch->style; - name = fz_font_name(style->font); + name = fz_font_name(ctx, style->font); s = strchr(name, '+'); s = s ? s + 1 : name; fz_printf(ctx, out, "<span bbox=\"%g %g %g %g\" font=\"%s\" size=\"%g\">\n", diff --git a/source/fitz/svg-device.c b/source/fitz/svg-device.c index 1484dddd..7397d059 100644 --- a/source/fitz/svg-device.c +++ b/source/fitz/svg-device.c @@ -274,7 +274,7 @@ svg_dev_text_span(fz_context *ctx, svg_device *sdev, const fz_matrix *ctm, const fz_printf(ctx, out, " transform=\"matrix(%g,%g,%g,%g,%g,%g)\"", local_trm.a, local_trm.b, local_trm.c, local_trm.d, local_trm.e, local_trm.f); fz_printf(ctx, out, " font-size=\"%g\"", size); - fz_printf(ctx, out, " font-family=\"%s\"", fz_font_name(span->font)); + fz_printf(ctx, out, " font-family=\"%s\"", fz_font_name(ctx, span->font)); /* Leading (and repeated) whitespace presents a problem for SVG * text, so elide it here. */ diff --git a/source/fitz/trace-device.c b/source/fitz/trace-device.c index bcb68bf8..881d7567 100644 --- a/source/fitz/trace-device.c +++ b/source/fitz/trace-device.c @@ -39,7 +39,7 @@ static void fz_trace_text_span(fz_context *ctx, fz_output *out, fz_text_span *span) { int i; - fz_printf(ctx, out, "<span font=\"%s\" wmode=\"%d\"", fz_font_name(span->font), span->wmode); + fz_printf(ctx, out, "<span font=\"%s\" wmode=\"%d\"", fz_font_name(ctx, span->font), span->wmode); fz_printf(ctx, out, " trm=\"%g %g %g %g\">\n", span->trm.a, span->trm.b, span->trm.c, span->trm.d); for (i = 0; i < span->len; i++) { diff --git a/source/html/html-layout.c b/source/html/html-layout.c index 0d0e5aed..df119b1a 100644 --- a/source/html/html-layout.c +++ b/source/html/html-layout.c @@ -885,7 +885,7 @@ static int walk_string(string_walker *walker) hb_lock(ctx); fz_try(ctx) { - face = fz_font_ft_face(walker->font); + face = fz_font_ft_face(ctx, walker->font); walker->scale = face->units_per_EM; fterr = FT_Set_Char_Size(face, walker->scale, walker->scale, 72, 72); if (fterr) @@ -905,7 +905,7 @@ static int walk_string(string_walker *walker) if (!quickshape) { - fz_shaper_data_t *hb = fz_font_shaper_data(walker->font); + fz_shaper_data_t *hb = fz_font_shaper_data(ctx, walker->font); if (hb->shaper_handle == NULL) { Memento_startLeaking(); /* HarfBuzz leaks harmlessly */ @@ -1990,7 +1990,7 @@ void fz_print_css_style(fz_context *ctx, fz_css_style *style, int boxtype, int n) { indent(n); printf("font_size %g%c\n", style->font_size.value, style->font_size.unit); - indent(n); printf("font %s\n", style->font ? fz_font_name(style->font) : "NULL"); + indent(n); printf("font %s\n", style->font ? fz_font_name(ctx, style->font) : "NULL"); indent(n); printf("width = %g%c;\n", style->width.value, style->width.unit); indent(n); printf("height = %g%c;\n", style->height.value, style->height.unit); if (boxtype == BOX_BLOCK) diff --git a/source/pdf/pdf-device.c b/source/pdf/pdf-device.c index ccf63e42..f2fd75fc 100644 --- a/source/pdf/pdf-device.c +++ b/source/pdf/pdf-device.c @@ -384,7 +384,7 @@ pdf_dev_font(fz_context *ctx, pdf_device *pdev, fz_font *font) if (gs->font >= 0 && pdev->cid_fonts[gs->font] == font) return; - if (fz_font_t3_procs(font)) + if (fz_font_t3_procs(ctx, font)) fz_throw(ctx, FZ_ERROR_GENERIC, "pdf device does not support type 3 fonts"); if (fz_font_flags(font)->ft_substitute) fz_throw(ctx, FZ_ERROR_GENERIC, "pdf device does not support substitute fonts"); @@ -470,7 +470,7 @@ pdf_dev_text_span(fz_context *ctx, pdf_device *pdev, fz_text_span *span) if (fabsf(dx) > 0 || fabsf(dy) > 0) fz_buffer_printf(ctx, gs->buf, "%f %f %f %f %f %f Tm\n", tm.a, tm.b, tm.c, tm.d, tm.e, tm.f); - if (fz_font_t3_procs(span->font)) + if (fz_font_t3_procs(ctx, span->font)) fz_buffer_printf(ctx, gs->buf, "<%02x> Tj\n", it->gid); else fz_buffer_printf(ctx, gs->buf, "<%04x> Tj\n", it->gid); diff --git a/source/pdf/pdf-op-run.c b/source/pdf/pdf-op-run.c index ff3034fe..bfee0866 100644 --- a/source/pdf/pdf-op-run.c +++ b/source/pdf/pdf-op-run.c @@ -926,7 +926,7 @@ pdf_show_char(fz_context *ctx, pdf_run_processor *pr, int cid) /* If we are a type3 font within a type 3 font, or are otherwise * uncachable, then render direct. */ - render_direct = (!fz_font_ft_face(fontdesc->font) && pr->nested_depth > 0) || !fz_glyph_cacheable(ctx, fontdesc->font, gid); + render_direct = (!fz_font_ft_face(ctx, fontdesc->font) && pr->nested_depth > 0) || !fz_glyph_cacheable(ctx, fontdesc->font, gid); /* flush buffered text if rendermode has changed */ if (!pr->text || gstate->render != pr->text_mode || render_direct) diff --git a/source/tools/murun.c b/source/tools/murun.c index ea9e1d51..e3588954 100644 --- a/source/tools/murun.c +++ b/source/tools/murun.c @@ -2185,8 +2185,9 @@ static void ffi_new_Font(js_State *J) static void ffi_Font_getName(js_State *J) { + fz_context *ctx = js_getcontext(J); fz_font *font = js_touserdata(J, 0, "fz_font"); - js_pushstring(J, fz_font_name(font)); + js_pushstring(J, fz_font_name(ctx, font)); } static void ffi_Font_encodeCharacter(js_State *J) diff --git a/source/xps/xps-glyphs.c b/source/xps/xps-glyphs.c index 1296d6f9..82daf768 100644 --- a/source/xps/xps-glyphs.c +++ b/source/xps/xps-glyphs.c @@ -20,31 +20,31 @@ static inline int unhex(int a) } int -xps_count_font_encodings(fz_font *font) +xps_count_font_encodings(fz_context *ctx, fz_font *font) { - FT_Face face = fz_font_ft_face(font); + FT_Face face = fz_font_ft_face(ctx, font); return face->num_charmaps; } void -xps_identify_font_encoding(fz_font *font, int idx, int *pid, int *eid) +xps_identify_font_encoding(fz_context *ctx, fz_font *font, int idx, int *pid, int *eid) { - FT_Face face = fz_font_ft_face(font); + FT_Face face = fz_font_ft_face(ctx, font); *pid = face->charmaps[idx]->platform_id; *eid = face->charmaps[idx]->encoding_id; } void -xps_select_font_encoding(fz_font *font, int idx) +xps_select_font_encoding(fz_context *ctx, fz_font *font, int idx) { - FT_Face face = fz_font_ft_face(font); + FT_Face face = fz_font_ft_face(ctx, font); FT_Set_Charmap(face, face->charmaps[idx]); } int -xps_encode_font_char(fz_font *font, int code) +xps_encode_font_char(fz_context *ctx, fz_font *font, int code) { - FT_Face face = fz_font_ft_face(font); + FT_Face face = fz_font_ft_face(ctx, font); int gid = FT_Get_Char_Index(face, code); if (gid == 0 && face->charmap && face->charmap->platform_id == 3 && face->charmap->encoding_id == 0) gid = FT_Get_Char_Index(face, 0xF000 | code); @@ -55,7 +55,7 @@ void xps_measure_font_glyph(fz_context *ctx, xps_document *doc, fz_font *font, int gid, xps_glyph_metrics *mtx) { int mask = FT_LOAD_NO_SCALE | FT_LOAD_IGNORE_TRANSFORM; - FT_Face face = fz_font_ft_face(font); + FT_Face face = fz_font_ft_face(ctx, font); FT_Fixed hadv = 0, vadv = 0; fz_lock(ctx, FZ_LOCK_FREETYPE); @@ -151,15 +151,15 @@ xps_select_best_font_encoding(fz_context *ctx, xps_document *doc, fz_font *font) int i, k, n, pid, eid; - n = xps_count_font_encodings(font); + n = xps_count_font_encodings(ctx, font); for (k = 0; xps_cmap_list[k].pid != -1; k++) { for (i = 0; i < n; i++) { - xps_identify_font_encoding(font, i, &pid, &eid); + xps_identify_font_encoding(ctx, font, i, &pid, &eid); if (pid == xps_cmap_list[k].pid && eid == xps_cmap_list[k].eid) { - xps_select_font_encoding(font, i); + xps_select_font_encoding(ctx, font, i); return; } } @@ -429,7 +429,7 @@ xps_parse_glyphs_imp(fz_context *ctx, xps_document *doc, const fz_matrix *ctm, is = xps_parse_glyph_index(is, &glyph_index); if (glyph_index == -1) - glyph_index = xps_encode_font_char(font, char_code); + glyph_index = xps_encode_font_char(ctx, font, char_code); xps_measure_font_glyph(ctx, doc, font, glyph_index, &mtx); if (is_sideways) |