[
https://issues.apache.org/jira/browse/PDFBOX-2518?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17924937#comment-17924937
]
Tilman Hausherr commented on PDFBOX-2518:
-----------------------------------------
I've had another look at this, by using a font {{ZX______.PFB}} I found on
github. It can be tested by calling {{new PDType1Font(doc, is)}} or by using
the HelloWorldType1 example. The "bind" problem is easy to handle by adding it
to {{readDef()}} however there's more... it then fails in this line:
{code:java}
/Blend 3 dict dup begin
/FontBBox{{-55 -112 -286 -275 }{-261 -261 -261 -262 }{424 1156 1389 1981 }{811
915 839 970 }}def
/Private 14 dict def
end def
{code}
I suspected this is a nested dictionay and asked ChatGPT to reformat and here's
what this is:
{code:java}
/Blend 3 dict dup begin
/FontBBox {
{-55 -112 -286 -275 }
{-261 -261 -261 -262 }
{424 1156 1389 1981 }
{811 915 839 970 }
} def
/Private 14 dict def
end def
{code}
So yes... and here's the whole PostScript reformatted:
{code:java}
22 dict begin
/FontInfo 14 dict dup begin
/version (001.002) readonly def
/Notice (Copyright (c) 1993, 1994, 1999 Adobe Systems Incorporated. All
Rights Reserved.) readonly def
/FullName (Adobe Sans MM) readonly def
/FamilyName (Adobe Sans MM) readonly def
/Weight (All) readonly def
/isFixedPitch false def
/ItalicAngle 0 def
/UnderlinePosition -100 def
/UnderlineThickness 50 def
/BlendDesignPositions [ [0 0] [1 0] [0 1] [1 1] ] def
/BlendDesignMap [[[50 0][1450 1]][[50 0][1450 1]]] def
/BlendAxisTypes [/Weight /Width ] def
end readonly def
/FontName /AdobeSansMM def
/Encoding StandardEncoding def
/PaintType 0 def
/FontType 1 def
/DesignVector [470 820] def
/NormDesignVector [0.29999 0.54999 ] def
/WeightVector [0.31502 0.13499 0.38499 0.16499 ] def
/$Blend {0.13 mul exch 0.38 mul add exch 0.16 mul add add } bind def
/FontMatrix [0.001 0 0 0.001 0 0] def
/UniqueID 44278 def
/XUID [1 44278 20645 8847 25231 10813] def
/FontBBox{-187.92 -261.16 1151.21 862.04 } readonly def
/Blend 3 dict dup begin
/FontBBox {
{-55 -112 -286 -275 }
{-261 -261 -261 -262 }
{424 1156 1389 1981 }
{811 915 839 970 }
} def
/Private 14 dict def
end def
/shareddict where
{
pop currentshared { setshared }
true setshared shareddict
}
{ {} userdict }
ifelse dup
/makeblendedfont where {
/makeblendedfont get dup type /operatortype eq {
pop false
} {
0 get dup type /integertype ne
{pop false}
{11 lt} ifelse
} ifelse
}
{ true } ifelse
/makeblendedfont {
11 pop
2 copy length exch /WeightVector get length eq {
dup 0 exch {add} forall 1 sub abs .001 gt }
{ true } ifelse {
/makeblendedfont cvx errordict /rangecheck get exec
} if
exch dup dup maxlength dict begin {
false {/FID /UniqueID /XUID } { 3 index eq or } forall
{ pop pop } { def } ifelse
} forall
/XUID 2 copy known {
get dup length 2 index length sub dup 0 gt {
exch dup length array copy
exch 2 index {65536 mul cvi 3 copy put pop 1 add} forall
pop /XUID exch def
} { pop pop } ifelse
} { pop pop } ifelse
{ /Private /FontInfo } {
dup load dup maxlength dict begin {
false { /UniqueID /XUID } { 3 index eq or } forall
{ pop pop } { def } ifelse
} forall currentdict end def
} forall
dup /WeightVector exch def
dup /$Blend exch [
exch false exch
dup length 1 sub -1 1 {
1 index dup length 3 -1 roll sub get
dup 0 eq {
pop 1 index {/exch load 3 1 roll} if
/pop load 3 1 roll
} {
dup 1 eq {pop}
{2 index {/exch load 4 1 roll} if
3 1 roll /mul load 3 1 roll }
} ifelse
1 index {/add load 3 1 roll} if
exch pop true exch
} ifelse
} cvx def
{2 copy length exch length ne {
/makeblendedfont cvx errordict /typecheck get exec
} if
0 0 1 3 index length 1 sub {
dup 4 index exch get exch 3 index exch get mul add
} for
exch pop exch pop}
{{
dup type dup dup /arraytype eq exch /packedarraytype eq or {
pop 1 index /ForceBold eq {
5 index 0 0 1 3 index length 1 sub {
dup 4 index exch get {2 index exch get add } {pop} ifelse
} for exch pop exch pop
2 index /ForceBoldThreshold get gt 3 copy
} {
{length 1 index length ne { pop false } {
true exch { type dup /integertype eq exch /realtype eq exch
or and } forall
} ifelse }
}
} 2 copy 8 index exch exec {pop 5 index 5 index exec}
{exch dup length array 1 index xcheck { cvx } if
dup length 1 sub 0 exch 1 exch {
dup 3 index exch get dup type dup /arraytype eq exch
/packedarraytype eq or {
dup 10 index 6 index exec {
9 index exch 9 index exec
} if } if
2 index 3 1 roll put
} for exch pop exch pop
} ifelse 3 copy }
1 index dup /StemSnapH eq exch /StemSnapV eq or {
dup length 1 sub {dup 0 le { exit } if
dup dup 1 sub 3 index exch get exch 3 index exch get 2 copy eq {
pop 2 index 2 index 0 put 0
} if le {1 sub}
{dup dup 1 sub 3 index exch get exch 3 index exch get
3 index exch 3 index 1 sub exch put
3 copy put pop
2 copy exch length 1 sub lt {1 add} if
} ifelse} loop pop
dup 0 get 0 le {
dup 0 exch {0 gt { exit } if 1 add} forall
dup 2 index length exch sub getinterval
} if
} if
} ifelse put }
{/dicttype eq {6 copy 3 1 roll get exch 2 index exec}
{/makeblendedfont cvx errordict /typecheck get exec} ifelse } ifelse pop pop }
forall pop pop pop pop }
currentdict Blend 2 index exec
currentdict end } bind put
/$fbf {
FontDirectory counttomark 3 add -1 roll known {
cleartomark pop findfont
} {
] exch findfont exch makeblendedfont
dup /Encoding currentfont /Encoding get put definefont
} ifelse currentfont /ScaleMatrix get makefont setfont
} bind put
} { pop pop } ifelse exec
/NormalizeDesignVector {
exch 50 sub 1400 div
exch 50 sub 1400 div
} bind def
/ConvertDesignVector {
1 index 1 2 index sub mul 3 1 roll
1 2 index sub 1 index mul 3 1 roll
1 index 1 index mul 3 1 roll
pop pop
0 1 1 3 {index add} for 1 exch sub 4 1 roll
} bind def
/$mmff_origfindfont where {
pop save { restore } { pop pop }
} { {} { def } } ifelse
/setshared where { pop true } { false } ifelse
currentdict dup systemdict ne {end} if
0 {currentdict systemdict eq { 1 add end} {exit} ifelse } loop
/findfont where pop
exch {systemdict begin} repeat
exch dup systemdict eq {pop}{begin}ifelse
dup systemdict eq {
pop { currentshared {{}} { true setshared { false setshared } } ifelse
shareddict }
{{} userdict } ifelse begin
} { begin { currentdict scheck } { false } ifelse {
currentshared {{}} { true setshared { false setshared } } ifelse
} { {} } ifelse } ifelse
/$mmff_origfindfont /findfont load 3 index exec
/findfont {
dup FontDirectory exch known
{ dup FontDirectory exch get /FontType get 3 ne}
{ dup SharedFontDirectory exch known
{ dup SharedFontDirectory exch get /FontType get 3 ne}
{ false} ifelse} ifelse
{$mmff_origfindfont} { dup dup length string cvs (_) search {
cvn dup dup FontDirectory exch known exch SharedFontDirectory exch
known or {
true} {
dup length 7 add string dup 0 (%font%) putinterval
dup 2 index 6 exch dup length string cvs putinterval
{ status } stopped { pop false } if {
pop pop pop pop true} {false} ifelse
} ifelse {
$mmff_origfindfont begin pop
[ exch { (_) search { { cvr } stopped { pop pop } {
exch pop exch } ifelse
} { pop exit } ifelse } loop false /FontInfo where {
pop FontInfo /BlendAxisTypes 2 copy known {
get length counttomark 2 sub eq exch pop
} { pop pop } ifelse } if {
NormalizeDesignVector
ConvertDesignVector
] currentdict exch makeblendedfont
2 copy exch /FontName exch put
definefont
} { cleartomark $mmff_origfindfont } ifelse end
} { pop pop pop $mmff_origfindfont } ifelse
} { pop $mmff_origfindfont } ifelse } ifelse
} bind 3 index exec
/SharedFontDirectory dup where { pop pop } { 0 dict 3 index exec } ifelse
end exec pop exec
{code}
I was wondering what happens after "/shareddict" and asked ChatGPT:
{quote}h3. Summary of what the program is doing:
* *Managing shared font data:* The program checks whether a shared font
dictionary exists ({{{}/shareddict{}}}) and updates the current font data
accordingly.
* *Blending logic:* It calculates and applies font blending transformations
using vectors like {{WeightVector}} and {{{}$Blend{}}}.
* *Font creation and encoding:* The program processes font data to create or
manipulate fonts, blending them if necessary, and then applying the new font
definitions with updated attributes like encoding and scale.
* *Design vector normalization:* It adjusts the design vectors to normalize
the scaling of the font.
This section seems to be part of a larger font-handling routine that allows for
flexible manipulation of font attributes, possibly for creating variable fonts
or custom font blends.
{quote}
So... uh, I doubt we can ever handle this file.
> Found Token[kind=NAME, text=bind] but expected ND
> -------------------------------------------------
>
> Key: PDFBOX-2518
> URL: https://issues.apache.org/jira/browse/PDFBOX-2518
> Project: PDFBox
> Issue Type: Bug
> Components: Parsing
> Affects Versions: 2.0.0
> Reporter: Simon Steiner
> Priority: Major
> Labels: type1font
>
> SEVERE: Error parsing font /opt/Adobe/Reader9/Resource/Font/ZX______.PFB
> java.io.IOException: Found Token[kind=NAME, text=bind] but expected ND
> at org.apache.fontbox.type1.Type1Parser.readDef(Type1Parser.java:699)
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]