diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2016-01-21 12:17:05 +0100 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2016-01-21 12:17:05 +0100 |
commit | 1ceb3b2acf3b8b8c1d009a01e94957698e6ec142 (patch) | |
tree | c7a93502bfe3ef9a7b507a08d26dce18b37454bc /source/fitz | |
parent | 835036fc550af059f2bc067fc39465a9bfda7c2f (diff) | |
download | mupdf-1ceb3b2acf3b8b8c1d009a01e94957698e6ec142.tar.xz |
Drop the const on fz_font.
The font is an immutable opaque structure, no need to add the const
keyword since users aren't expected or expecting to change it.
Diffstat (limited to 'source/fitz')
-rw-r--r-- | source/fitz/draw-glyph.c | 10 | ||||
-rw-r--r-- | source/fitz/font.c | 62 |
2 files changed, 30 insertions, 42 deletions
diff --git a/source/fitz/draw-glyph.c b/source/fitz/draw-glyph.c index 34489924..61a5565a 100644 --- a/source/fitz/draw-glyph.c +++ b/source/fitz/draw-glyph.c @@ -11,7 +11,7 @@ typedef struct fz_glyph_key_s fz_glyph_key; struct fz_glyph_key_s { - const fz_font *font; + fz_font *font; int a, b; int c, d; unsigned short gid; @@ -173,7 +173,7 @@ fz_subpixel_adjust(fz_context *ctx, fz_matrix *ctm, fz_matrix *subpix_ctm, unsig } fz_glyph * -fz_render_stroked_glyph(fz_context *ctx, const fz_font *font, int gid, fz_matrix *trm, const fz_matrix *ctm, const fz_stroke_state *stroke, const fz_irect *scissor) +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 (font->ft_face) { @@ -189,7 +189,7 @@ fz_render_stroked_glyph(fz_context *ctx, const fz_font *font, int gid, fz_matrix } fz_pixmap * -fz_render_stroked_glyph_pixmap(fz_context *ctx, const fz_font *font, int gid, fz_matrix *trm, const fz_matrix *ctm, const fz_stroke_state *stroke, const fz_irect *scissor) +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 (font->ft_face) { @@ -241,7 +241,7 @@ move_to_front(fz_glyph_cache *cache, fz_glyph_cache_entry *entry) } fz_glyph * -fz_render_glyph(fz_context *ctx, const fz_font *font, int gid, fz_matrix *ctm, fz_colorspace *model, const fz_irect *scissor) +fz_render_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix *ctm, fz_colorspace *model, const fz_irect *scissor) { fz_glyph_cache *cache; fz_glyph_key key; @@ -407,7 +407,7 @@ unlock_and_return_val: } fz_pixmap * -fz_render_glyph_pixmap(fz_context *ctx, const fz_font *font, int gid, fz_matrix *ctm, fz_colorspace *model, const fz_irect *scissor) +fz_render_glyph_pixmap(fz_context *ctx, fz_font *font, int gid, fz_matrix *ctm, fz_colorspace *model, const fz_irect *scissor) { fz_pixmap *val; unsigned char qe, qf; diff --git a/source/fitz/font.c b/source/fitz/font.c index 003cca0b..0350674f 100644 --- a/source/fitz/font.c +++ b/source/fitz/font.c @@ -73,10 +73,8 @@ fz_new_font(fz_context *ctx, const char *name, int use_glyph_bbox, int glyph_cou } fz_font * -fz_keep_font(fz_context *ctx, const fz_font *fontc) +fz_keep_font(fz_context *ctx, fz_font *font) { - fz_font *font = (fz_font *)fontc; /* Explicit cast away of const */ - return fz_keep_imp(ctx, font, &font->refs); } @@ -114,12 +112,10 @@ void fz_decouple_type3_font(fz_context *ctx, fz_font *font, void *t3doc) } void -fz_drop_font(fz_context *ctx, const fz_font *fontc) +fz_drop_font(fz_context *ctx, fz_font *font) { int fterr; int i; - /* Explicitly drop const */ - fz_font *font = (fz_font *)fontc; if (!fz_drop_imp(ctx, font, &font->refs)) return; @@ -416,7 +412,7 @@ fz_new_font_from_buffer(fz_context *ctx, const char *name, fz_buffer *buffer, in } static fz_matrix * -fz_adjust_ft_glyph_width(fz_context *ctx, const fz_font *font, int gid, fz_matrix *trm) +fz_adjust_ft_glyph_width(fz_context *ctx, fz_font *font, int gid, fz_matrix *trm) { /* Fudge the font matrix to stretch the glyph if we've substituted the font. */ if (font->ft_stretch && font->width_table /* && font->wmode == 0 */) @@ -463,7 +459,7 @@ pixmap_from_ft_bitmap(fz_context *ctx, int left, int top, FT_Bitmap *bitmap) /* Takes the freetype lock, and returns with it held */ static FT_GlyphSlot -do_ft_render_glyph(fz_context *ctx, const fz_font *font, int gid, const fz_matrix *trm, int aa) +do_ft_render_glyph(fz_context *ctx, fz_font *font, int gid, const fz_matrix *trm, int aa) { FT_Face face = font->ft_face; FT_Matrix m; @@ -562,7 +558,7 @@ retry_unhinted: } fz_pixmap * -fz_render_ft_glyph_pixmap(fz_context *ctx, const fz_font *font, int gid, const fz_matrix *trm, int aa) +fz_render_ft_glyph_pixmap(fz_context *ctx, fz_font *font, int gid, const fz_matrix *trm, int aa) { FT_GlyphSlot slot = do_ft_render_glyph(ctx, font, gid, trm, aa); fz_pixmap *pixmap; @@ -591,7 +587,7 @@ fz_render_ft_glyph_pixmap(fz_context *ctx, const fz_font *font, int gid, const f /* The glyph cache lock is always taken when this is called. */ fz_glyph * -fz_render_ft_glyph(fz_context *ctx, const fz_font *font, int gid, const fz_matrix *trm, int aa) +fz_render_ft_glyph(fz_context *ctx, fz_font *font, int gid, const fz_matrix *trm, int aa) { FT_GlyphSlot slot = do_ft_render_glyph(ctx, font, gid, trm, aa); fz_glyph *glyph; @@ -620,7 +616,7 @@ fz_render_ft_glyph(fz_context *ctx, const fz_font *font, int gid, const fz_matri /* Takes the freetype lock, and returns with it held */ static FT_Glyph -do_render_ft_stroked_glyph(fz_context *ctx, const fz_font *font, int gid, const fz_matrix *trm, const fz_matrix *ctm, const fz_stroke_state *state) +do_render_ft_stroked_glyph(fz_context *ctx, fz_font *font, int gid, const fz_matrix *trm, const fz_matrix *ctm, const fz_stroke_state *state) { FT_Face face = font->ft_face; float expansion = fz_matrix_expansion(ctm); @@ -716,7 +712,7 @@ do_render_ft_stroked_glyph(fz_context *ctx, const fz_font *font, int gid, const } fz_pixmap * -fz_render_ft_stroked_glyph_pixmap(fz_context *ctx, const fz_font *font, int gid, const fz_matrix *trm, const fz_matrix *ctm, const fz_stroke_state *state) +fz_render_ft_stroked_glyph_pixmap(fz_context *ctx, fz_font *font, int gid, const fz_matrix *trm, const fz_matrix *ctm, const fz_stroke_state *state) { FT_Glyph glyph = do_render_ft_stroked_glyph(ctx, font, gid, trm, ctm, state); FT_BitmapGlyph bitmap = (FT_BitmapGlyph)glyph; @@ -746,7 +742,7 @@ fz_render_ft_stroked_glyph_pixmap(fz_context *ctx, const fz_font *font, int gid, } fz_glyph * -fz_render_ft_stroked_glyph(fz_context *ctx, const fz_font *font, int gid, const fz_matrix *trm, const fz_matrix *ctm, const fz_stroke_state *state) +fz_render_ft_stroked_glyph(fz_context *ctx, fz_font *font, int gid, const fz_matrix *trm, const fz_matrix *ctm, const fz_stroke_state *state) { FT_Glyph glyph = do_render_ft_stroked_glyph(ctx, font, gid, trm, ctm, state); FT_BitmapGlyph bitmap = (FT_BitmapGlyph)glyph; @@ -776,7 +772,7 @@ fz_render_ft_stroked_glyph(fz_context *ctx, const fz_font *font, int gid, const } static fz_rect * -fz_bound_ft_glyph(fz_context *ctx, const fz_font *font, int gid, fz_rect *bounds) +fz_bound_ft_glyph(fz_context *ctx, fz_font *font, int gid, fz_rect *bounds) { FT_Face face = font->ft_face; FT_Error fterr; @@ -921,7 +917,7 @@ static const FT_Outline_Funcs outline_funcs = { }; fz_path * -fz_outline_ft_glyph(fz_context *ctx, const fz_font *font, int gid, const fz_matrix *trm) +fz_outline_ft_glyph(fz_context *ctx, fz_font *font, int gid, const fz_matrix *trm) { struct closure cc; FT_Face face = font->ft_face; @@ -1027,7 +1023,7 @@ fz_new_type3_font(fz_context *ctx, const char *name, const fz_matrix *matrix) } void -fz_prepare_t3_glyph(fz_context *ctx, const fz_font *font, int gid, int nested_depth) +fz_prepare_t3_glyph(fz_context *ctx, fz_font *font, int gid, int nested_depth) { fz_buffer *contents; fz_device *dev; @@ -1063,7 +1059,7 @@ fz_prepare_t3_glyph(fz_context *ctx, const fz_font *font, int gid, int nested_de } static fz_rect * -fz_bound_t3_glyph(fz_context *ctx, const fz_font *font, int gid, fz_rect *bounds) +fz_bound_t3_glyph(fz_context *ctx, fz_font *font, int gid, fz_rect *bounds) { fz_display_list *list; fz_device *dev; @@ -1101,7 +1097,7 @@ fz_bound_t3_glyph(fz_context *ctx, const fz_font *font, int gid, fz_rect *bounds } void -fz_run_t3_glyph(fz_context *ctx, const fz_font *font, int gid, const fz_matrix *trm, fz_device *dev) +fz_run_t3_glyph(fz_context *ctx, fz_font *font, int gid, const fz_matrix *trm, fz_device *dev) { fz_display_list *list; fz_matrix ctm; @@ -1115,7 +1111,7 @@ fz_run_t3_glyph(fz_context *ctx, const fz_font *font, int gid, const fz_matrix * } fz_pixmap * -fz_render_t3_glyph_pixmap(fz_context *ctx, const fz_font *font, int gid, const fz_matrix *trm, fz_colorspace *model, const fz_irect *scissor) +fz_render_t3_glyph_pixmap(fz_context *ctx, fz_font *font, int gid, const fz_matrix *trm, fz_colorspace *model, const fz_irect *scissor) { fz_display_list *list; fz_rect bounds; @@ -1191,14 +1187,14 @@ fz_render_t3_glyph_pixmap(fz_context *ctx, const fz_font *font, int gid, const f } fz_glyph * -fz_render_t3_glyph(fz_context *ctx, const fz_font *font, int gid, const fz_matrix *trm, fz_colorspace *model, const fz_irect *scissor) +fz_render_t3_glyph(fz_context *ctx, fz_font *font, int gid, const fz_matrix *trm, fz_colorspace *model, const fz_irect *scissor) { fz_pixmap *pixmap = fz_render_t3_glyph_pixmap(ctx, font, gid, trm, model, scissor); return fz_new_glyph_from_pixmap(ctx, pixmap); } void -fz_render_t3_glyph_direct(fz_context *ctx, fz_device *dev, const fz_font *font, int gid, const fz_matrix *trm, void *gstate, int nested_depth) +fz_render_t3_glyph_direct(fz_context *ctx, fz_device *dev, fz_font *font, int gid, const fz_matrix *trm, void *gstate, int nested_depth) { fz_matrix ctm; void *contents; @@ -1228,7 +1224,7 @@ fz_render_t3_glyph_direct(fz_context *ctx, fz_device *dev, const fz_font *font, } void -fz_print_font(fz_context *ctx, fz_output *out, const fz_font *font) +fz_print_font(fz_context *ctx, fz_output *out, fz_font *font) { fz_printf(ctx, out, "font '%s' {\n", font->name); @@ -1254,7 +1250,7 @@ fz_print_font(fz_context *ctx, fz_output *out, const fz_font *font) } fz_rect * -fz_bound_glyph(fz_context *ctx, const fz_font *font, int gid, const fz_matrix *trm, fz_rect *rect) +fz_bound_glyph(fz_context *ctx, fz_font *font, int gid, const fz_matrix *trm, fz_rect *rect) { if (font->bbox_table && gid < font->glyph_count) { @@ -1279,14 +1275,14 @@ fz_bound_glyph(fz_context *ctx, const fz_font *font, int gid, const fz_matrix *t } fz_path * -fz_outline_glyph(fz_context *ctx, const fz_font *font, int gid, const fz_matrix *ctm) +fz_outline_glyph(fz_context *ctx, fz_font *font, int gid, const fz_matrix *ctm) { if (!font->ft_face) return NULL; return fz_outline_ft_glyph(ctx, font, gid, ctm); } -int fz_glyph_cacheable(fz_context *ctx, const fz_font *font, int gid) +int fz_glyph_cacheable(fz_context *ctx, fz_font *font, int gid) { if (!font->t3procs || !font->t3flags || gid < 0 || gid >= font->glyph_count) return 1; @@ -1294,7 +1290,7 @@ int fz_glyph_cacheable(fz_context *ctx, const fz_font *font, int gid) } static float -fz_advance_ft_glyph(fz_context *ctx, const fz_font *font, int gid) +fz_advance_ft_glyph(fz_context *ctx, fz_font *font, int gid) { FT_Fixed adv; int mask; @@ -1317,7 +1313,7 @@ fz_advance_ft_glyph(fz_context *ctx, const fz_font *font, int gid) } static float -fz_advance_t3_glyph(fz_context *ctx, const fz_font *font, int gid) +fz_advance_t3_glyph(fz_context *ctx, fz_font *font, int gid) { if (gid < 0 || gid > 255) return 0; @@ -1325,12 +1321,8 @@ fz_advance_t3_glyph(fz_context *ctx, const fz_font *font, int gid) } float -fz_advance_glyph(fz_context *ctx, const fz_font *fontc, int gid) +fz_advance_glyph(fz_context *ctx, fz_font *font, int gid) { - /* Explicitly cast away the const, enable us to change a cache - * held within the font. */ - fz_font *font = (fz_font *)fontc; - if (font->ft_face) { if (gid >= 0 && gid < font->glyph_count && gid < MAX_ADVANCE_CACHE) @@ -1353,12 +1345,8 @@ fz_advance_glyph(fz_context *ctx, const fz_font *fontc, int gid) } int -fz_encode_character(fz_context *ctx, const fz_font *fontc, int ucs) +fz_encode_character(fz_context *ctx, fz_font *font, int ucs) { - /* Explicitly cast away the const, enable us to change a cache - * held within the font. */ - fz_font *font = (fz_font *)fontc; - if (font->ft_face) { if (ucs >= 0 && ucs < 0x10000) |