From 2547bc80e34243be8a5395b80d7832a770ec2f30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20Fabian=20Kr=C3=BCger?= Date: Mon, 6 Jul 2020 17:40:53 +0200 Subject: [PATCH] Improved Type3 handling --- luametalatex-pdf-font-pk.lua | 3 ++- luametalatex-pdf-font.lua | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/luametalatex-pdf-font-pk.lua b/luametalatex-pdf-font-pk.lua index 05243e8..e614a8a 100644 --- a/luametalatex-pdf-font-pk.lua +++ b/luametalatex-pdf-font-pk.lua @@ -1,4 +1,5 @@ local read_pk = require'luametalatex-font-pk' +local strip_floats = require'luametalatex-pdf-utils'.strip_floats return function(pdf, fontdir, usedcids) local pk = read_pk(fontdir.name) local designsize = pk.designsize/1044654.326 -- 1044654.326=2^20*72/72.27 -- designsize in bp @@ -24,5 +25,5 @@ return function(pdf, fontdir, usedcids) glyph.dx/2^16, glyph.dy, left, lower, right, upper, glyph.w, glyph.h, left, lower, glyph.w, glyph.h, glyph.data ))) end - return bbox, matrix, '[' .. table.concat(widths, ' ') .. ']', '<<' .. table.concat(charprocs) .. '>>' + return bbox, matrix, pdf:indirect(nil, strip_floats('[' .. table.concat(widths, ' ') .. ']')), '<<' .. table.concat(charprocs) .. '>>' end diff --git a/luametalatex-pdf-font.lua b/luametalatex-pdf-font.lua index 70f5ed3..a047301 100644 --- a/luametalatex-pdf-font.lua +++ b/luametalatex-pdf-font.lua @@ -1,3 +1,5 @@ +local strip_floats = require'luametalatex-pdf-utils'.strip_floats + local tounicode = { [-3] = require'luametalatex-pdf-font-cmap3', require'luametalatex-pdf-font-cmap1', @@ -254,8 +256,8 @@ local function buildfont3(pdf, fontdir, usedcids) local enc = cidmap1byte(pdf) local bbox, matrix, widths, charprocs = buildfontpk(pdf, fontdir, usedcids) -- TOOD local touni = pdf:stream(nil, "", tounicode[1](fontdir, usedcids)) -- Done late to allow for defaults set from the font file - return string.format( - "<>", + return strip_floats(string.format( + "<>", -- "<>", bbox[1], bbox[2], bbox[3], bbox[4], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5], matrix[6], @@ -265,7 +267,7 @@ local function buildfont3(pdf, fontdir, usedcids) usedcids[#usedcids][1], widths, touni - ) -- , descriptor) -- TODO + )) -- , descriptor) -- TODO end return function(pdf, fontdir, usedcids) if fontdir.format == "type3" then