From 4a99615a609eec2b84bb2341d74fac46a5998137 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Mon, 25 Jun 2018 13:15:50 +0200 Subject: Pass rect and matrix by value in geometry functions. Several things irk me about passing values as const pointers: * They can be NULL, which is not a valid value. * They require explicit temporary variables for storage. * They don't compose easily in a legible manner, requiring weird pointer passing semantics where the variable being assigned is hidden as an argument in the innermost function call. * We can't change the value through the pointer, requiring yet more local variables to hold copies of the input value. In the device interface where we pass a matrix to a function, we often find ourselves making a local copy of the matrix so we can concatenate other transforms to it. This copying is a lot of unnecessary busywork that I hope to eventually avoid by laying the groundwork with this commit. This is a rather large API change, so I apologize for the inconvenience, but I hope the end result and gain in legibility will be worth the pain. --- source/pdf/pdf-font.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/pdf/pdf-font.c') diff --git a/source/pdf/pdf-font.c b/source/pdf/pdf-font.c index b29a1a18..b540f4ec 100644 --- a/source/pdf/pdf-font.c +++ b/source/pdf/pdf-font.c @@ -1591,7 +1591,7 @@ pdf_add_font_descriptor(fz_context *ctx, pdf_document *doc, pdf_obj *fobj, fz_fo bbox.y0 = font->bbox.y0 * 1000; bbox.x1 = font->bbox.x1 * 1000; bbox.y1 = font->bbox.y1 * 1000; - pdf_dict_put_rect(ctx, fdobj, PDF_NAME(FontBBox), &bbox); + pdf_dict_put_rect(ctx, fdobj, PDF_NAME(FontBBox), bbox); pdf_dict_put_int(ctx, fdobj, PDF_NAME(ItalicAngle), 0); pdf_dict_put_int(ctx, fdobj, PDF_NAME(Ascent), face->ascender * 1000.0f / face->units_per_EM); @@ -2226,7 +2226,7 @@ pdf_add_cjk_font(fz_context *ctx, pdf_document *doc, fz_font *fzfont, int script { pdf_dict_put(ctx, fontdesc, PDF_NAME(Type), PDF_NAME(FontDescriptor)); pdf_dict_put_text_string(ctx, fontdesc, PDF_NAME(FontName), basefont); - pdf_dict_put_rect(ctx, fontdesc, PDF_NAME(FontBBox), &bbox); + pdf_dict_put_rect(ctx, fontdesc, PDF_NAME(FontBBox), bbox); pdf_dict_put_int(ctx, fontdesc, PDF_NAME(Flags), flags); pdf_dict_put_int(ctx, fontdesc, PDF_NAME(ItalicAngle), 0); pdf_dict_put_int(ctx, fontdesc, PDF_NAME(Ascent), 1000); -- cgit v1.2.3