tailmatch ==> true
% ==> false
/tailmatch {
2 copy length 1 index length .min
dup 2 index length exch sub exch getinterval
1 index eq {
length 1 index length exch sub
0 exch getinterval //true
} {
pop //false
} ifelse
} bind executeonly def
/makeboldfont {
16 dict begin
/strokewidth exch def
/basecidfont exch def
/FontMatrix [ 1 0 0 1 0 0 ] def
/CIDFontName /.boldfont def
/CIDFontType 1 def
/basefont-H /.basefont-H /Identity-H [ basecidfont ] composefont def
/basefont-V /.basefont-V /Identity-V [ basecidfont ] composefont def
/CIDSystemInfo dup basecidfont exch get def
/FontBBox [ basecidfont /FontBBox get cvx exec
4 2 roll basecidfont /FontMatrix get transform
4 2 roll basecidfont /FontMatrix get transform
] def
/tmpstr 2 string def
/BuildGlyph {
gsave
exch begin
dup 256 idiv tmpstr exch 0 exch put
256 mod tmpstr exch 1 exch put
rootfont /WMode known { rootfont /WMode get 1 eq } { //false } ifelse
{ basefont-V } { basefont-H } ifelse setfont
strokewidth setlinewidth
1 setlinejoin
newpath
0 0 moveto tmpstr //false charpath stroke
0 0 moveto tmpstr show
currentpoint setcharwidth
end
grestore
} bind def
currentdict
end
dup /CIDFontName get exch /CIDFont defineresource
} bind executeonly def
% findCIDFont
% CIDFont-resource is not modified.
% In various places we do:
% "findCIDFont dup /OrigFont .knownget {exch pop} if"
% because the CIDFont we find may have been "patched" to apply metrics from
% the PDF file (W, W2, etc). We want to avoid applying those metrics more
% than once, hence retrieving the original, unpatched CIDFont dictionary,
% if it exists.
/findCIDFont {
{
dup /CIDFont resourcestatus {
pop pop dup /CIDFont findresource
dup /Path known
1 index /ResourcePath known or
{ exch pop exit }
{ pop dup /CIDFont undefineresource }
ifelse
} if
.remove_font_name_prefix
dup dup length string cvs
(,Bold) tailmatch {
exch pop
% If we're substituting a standard weight font for a
% "Light,Bold" font, don't artificially bolden further
dup (Light) tailmatch
{
pop cvn findCIDFont
dup /OrigFont .knownget {exch pop} if
dup /FontName .knownget
{
(Light) tailmatch exch pop
}
{
//true
} ifelse
{
0.03 makeboldfont
} if
}
{
pop
cvn findCIDFont
dup /OrigFont .knownget {exch pop} if
0.03 makeboldfont
} ifelse
exit
} if
(,Italic) tailmatch {
exch pop
cvn findCIDFont
dup /OrigFont .knownget {exch pop} if
[ 1 0 0.3 1 0 0 ] makefont
exit
} if
(,BoldItalic) tailmatch {
exch pop
% see above
dup (Light) tailmatch
{
pop cvn findCIDFont
dup /OrigFont .knownget {exch pop} if
dup /FontName .knownget
{
(Light) tailmatch exch pop
}
{
//true
} ifelse
{
0.03 makeboldfont
} if
}
{
pop
cvn findCIDFont
dup /OrigFont .knownget {exch pop} if
0.03 makeboldfont
} ifelse
[ 1 0 0.3 1 0 0 ] makefont
exit
} if
QUIET not {
(Can't find CID font ") print dup =string cvs print (".) = flush
} if
pop
1 index /CIDSystemInfo oget begin Registry (-) Ordering end
concatstrings concatstrings
cvn
QUIET not {
(Attempting to substitute CID font ) print dup ==only
( for ) print 1 index ==only (, see doc/Use.htm#CIDFontSubstitution.) = flush
} if
exch pop
dup /CIDFont resourcestatus {
pop pop /CIDFont { findresource } stopped
{pop}{exit} ifelse
} if
QUIET not {
(The substitute CID font ") print dup =string cvs print
(" is not provided either. ) print
} if
PDFNOCIDFALLBACK {
PDFSTOPONERROR {
(Will exit with error.) = flush
}
{
(Will attempt to continue, but content may be missing.) = flush
} ifelse
exit
} if
QUIET not {
(attempting to use fallback CIDFont.) print
(See doc/Use.htm#CIDFontSubstitution.) = flush
} if
PDFNOCIDFALLBACK not {
% This previously worked by loading the substitute font, and using that
% as a "template" to create a new CIDFont dictionary with the CIDSystemInfo
% dict appropriate for the requested font.
% This, however, caused problems with the CIDMap and thus broke pdfwrite.
% Hence, we now modify the CIDFont resource .map dictionary on the fly
% so it includes an appropriate mapping, so the subsitute font is loaded
% from the beginning with the correct ordering and supplement settings.
/CIDFont /Category findresource /.map get dup /CIDFallBack .knownget {
dup type /dicttype eq {
dup /FileType get /TrueType eq {
currentglobal
4 1 roll
dup gcheck setglobal
dup length dict copy dup
6 index /CIDSystemInfo oget dup /Ordering oget exch /Supplement get
% we have to copy the string, for VM correctness
exch dup length string copy exch 2 array astore
/CSI exch put 2 index exch .forceput
exch setglobal
{
% This *should* not execute arbitrary Postscript, so we ought to
% be safe running in a stopped context, in knowledge we know how
% to clean up afterwards - this would not be safe if CIDFallBack
% were a "real" CIDFont.
/CIDFont findresource
}
% if the above fails, try just using the CIDFallBack font directly
stopped
{
pop
% First, since it didn't work, remove the entry from the CIDFont category
% .map dictionary.
currentglobal exch
/CIDFont /Category findresource /.map get
dup gcheck setglobal
exch undef
setglobal
(Warning: falling back to Identity ordering\n) print flush
/CIDFallBack /CIDFont findresource
} if
exit
} executeonly if
} if
} if
pop pop pop
/CIDFallBack
QUIET not {
(The fallback CID font ") print dup =string cvs print
(" is not provided. ) print
( Finally attempting to use ArtifexBullet.\n) print flush
}if
% We'll just use Identity for this, we have only one glyph anyway.
/ArtifexBullet /CIDFont resourcestatus {
pop pop pop
/ArtifexBullet /CIDFont findresource
exit
}
{
pop /ArtifexBullet
} ifelse
QUIET not {
(The CID font ") print dup =string cvs print
(" is not provided. ) print
PDFSTOPONERROR
{
(Will exit with error.) = flush
}
{
(Will continue, but content may be missing.) = flush
} ifelse
} if
} executeonly if
/findresource cvx /undefined signalerror
} executeonly loop
} bind executeonly odef
/buildCIDType0 { %