[gs-devel] Type42 FontBBox ignored
David Newall
ghostscript at davidnewall.com
Mon May 31 04:09:31 UTC 2021
I'm trying to change the line height for a font by redefining FontBBox
using the following code:
/RedefinedFont /OriginalFont findfont dup length dict begin
{ 1 index /FID ne 2 index /UniqueID ne and 2 index /XUID ne and {def} {pop pop} ifelse } forall
[(Original FontBBox)/FontBBox load]==
/FontBBox [ /FontBBox load aload pop dup dup 5 -1 roll sub 1.3 mul sub 3 1 roll ] def % increase line height by 30%
[(Redefined FontBBox)/FontBBox load]==
/FontName 1 index def
currentdict
end definefont
[(Stored FontBBox)/RedefinedFont findfont /FontBBox get]==
This works with a type 42 font embedded in the PostScript that I send to
a PS printer (HP 9050) but not using GhostScript 9.26 on Ubuntu 16.04.
FontBBox is correctly recalculated but the original FontBBox is restored
after definefont. For example, having re-encoded NimbusRoman-Regular as
type 42 using FontForge, I get the following trace output:
[(Original FontBBox) {-0.168 -0.281 1.0 1.053}]
[(redefined FontBBox) [-0.168 -0.681199908 1.0 1.053]]
[(Stored FontBBox) [-0.168 -0.281 1.0 1.053]]
Note that the type of FontBBox has been changed from an executable
array, which is consistent with how I redefined it, but the values are
the original ones.
If I remove FontBBox from the type 42 definition, the dictionary
returned by findfont has no FontBBox, as one would expect. If there is
a FontBBox, it doesn't, no matter what values are given in the original
definition, the result of definefont always uses recalculated values.
Obviously I can work around this by only using type 1 fonts but I'd
really like it to work as expected with type 42.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ghostscript.com/pipermail/gs-devel/attachments/20210531/5c32b78f/attachment.htm>
More information about the gs-devel
mailing list