home *** CD-ROM | disk | FTP | other *** search
- %!
- %%VMusage: 3888 3888
- %%VMlocation: global
- %%
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %% %%
- %% This file implements the Font category resource. %%
- %% %%
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
- <<
-
- /Category /Font
-
- /ResourceFileName
- {
-
- TProFontFileName
-
- } bind
-
- /ReadSfnts {
- 10 dict begin
- dup status {
- pop pop exch pop
- } {
- 0
- } ifelse
- /bytes exch def
- (r) file
- mark exch
- {
- {
- dup
- bytes 65536 gt {65536} {bytes} ifelse
- bytes 1 index sub /bytes exch def
- string readstring pop
- exch
- bytes 0 eq {exit} if
- } loop
- } stopped
-
- {
- cleartomark
- stop
- }
- {
- pop ]
- } ifelse
- end
- } bind
-
- /ResourceRead
- {
- dup (.ttf) search
- {
- pop pop pop
- % ReadSfnts /sfnts exch def
- % 10 dict begin
- % /FontName fontname
- % dup type /nametype ne
- % {
- % dup gcheck currentglobal ne
- % {
- % dup length string copy
- % } if def
- % } if
- % /Encoding 256 array def
- % 0 1 255 {Encoding exch /.notdef put} for
- % /CharStrings 256 dict def
- % /FontMatrix [1 0 0 1 0 0] def
- % /FontBBox [-1 -1 1 1] cvx def
- % /PaintType 0 def
- % /FontType 42 def
- % /WindowsTTF true def
- % /sfnts sfnts def
- % currentdict end
- readsfntfile
- fontname exch definefont pop
- }
- {
- (.pfb) search
- {
- pop pop pop
- (r) file /PFBDecode filter cvx exec
- }
- {
- pop
- (r) file cvx exec
- } ifelse
- } ifelse
- } bind
-
-
- /FindResource
- {
- 10 dict begin
- /fontname exch def
- FontDirectory fontname known
- {
- /font FontDirectory fontname get def
- }
- {
- % (%%[ Finding ) print fontname dup length string cvs print
- % ( ]%%) = flush
- currentglobal
- fontname TProFontSubstitution
- {
- % Tell the user that font substitution is occurring and
- % why.
- {
- % dup
- % (%%[ ) print fontname dup length string cvs print
- % ( not found, using ) print
- % dup length string cvs print
- % ( ]%%) = flush
- }
- {
- dup fontname
- (%%[ Substituting ) print
- dup length string cvs print
- ( with ) print
- dup length string cvs print
- ( ]%%) = flush
- }
- ifelse
-
- % Do the actual font substitution.
- fontname exch SubstituteResource
- }
- {
- /filename fontname 256 string ResourceFileName def
- filename status
- {
- pop pop pop pop
- filename FontGCheck setglobal
- countdictstack
- mark filename {ResourceRead} stopped
- {
- (%%[ Possibly corrupt font file ]%%) = flush
- } if
- cleartomark
- countdictstack exch sub {end} repeat
- }
- {
- false setglobal
- } ifelse
- } ifelse
-
- FontDirectory fontname known
- {
- /font FontDirectory fontname get def
- }
- {
- % If we get this far, an unrecoverable problem has occurred.
- (%%[ ) print fontname dup length string cvs print
- ( could not be read, stopping ]%%) = flush
- stop
- } ifelse
-
- setglobal
- } ifelse
- font
- end
- } bind
-
-
- /DefineResource
- {
- definefont
- } bind
-
- /UndefineResource
- {
- undefinefont
- } bind
-
- /ResourceStatus {
- FontDirectory 1 index known {
- pop 0 -1 true
- } {
- 256 string ResourceFileName
- dup status {
- pop pop pop pop
- (r) file 256 string readstring pop
- %% Is this good enough? string is only 256 long....
- (%%VMusage:) search {
- pop pop 2 exch
- token pop exch token pop exch pop
- 2 copy lt {exch} if pop
- true
- } {
- pop 2 -1 true
- } ifelse
- } {
- pop false
- } ifelse
- } ifelse
- } bind
-
- /ResourceForAll {
- currentdict end
- 10 dict begin
- /cat exch def
- userdict /##_RFA_TEMP_## currentdict put
- /scratch exch def
- /proc exch def
- /template exch def
- /done false def
- currentglobal not {
- FontDirectory {
- gcheck not {
- scratch cvs dup template stringmatch {
- /proc load
- end stopped
- ##_RFA_TEMP_## begin
- {
- $error /errorname get dup /invalidexit eq {
- pop /done true def exit
- } {
- $error /command get exch
- errordict exch get exec
- } ifelse
- } if
- } {
- pop
- } ifelse
- } if
- } forall
- } if
- done not {
- FontDirectory {
- gcheck {
- scratch cvs dup template stringmatch {
- /proc load
- end stopped
- ##_RFA_TEMP_## begin
- {
- $error /errorname get dup /invalidexit eq {
- pop /done true def exit
- } {
- $error /command get exch
- errordict exch get exec
- } ifelse
- } if
- } {
- pop
- } ifelse
- } if
- } forall
- } if
- done not {
- [(%font%*) (%atmfont%*) (%ttfont%*)] {
- {
- false cat /Directory get {
- 3 index eq {3 1 roll pop pop true exit} {pop} ifelse
- } forall
- {
- dup template stringmatch {
- FontDirectory 1 index known
- 1 index (%font%_dir_) eq or not {
- scratch cvs
- /proc load
- end stopped
- ##_RFA_TEMP_## begin
- {
- $error /errorname get dup /invalidexit eq {
- pop /done true def exit
- } {
- $error /command get exch
- errordict exch get exec
- } ifelse
- } if
- } {
- pop
- } ifelse
- } {
- pop
- } ifelse
- } {
- pop
- } ifelse
- } 256 string filenameforall
- } forall
- } if
- end
- ##_RFA_TEMP_## /cat get begin
- userdict /##_RFA_TEMP_## undef
- } bind
-
- %%
- %% FontGCheck tries to decide whether the font should live in local or global
- %% VM. Type 3 fonts go in local VM, and most Type 1 go in global VM.
- %% Hybrid fonts, such as Optima, have to go in local VM so that save
- %% and restore do the right thing. The Black Book suggests that we
- %% look for an occurrence of /hires before /Subrs to decide that. However,
- %% that is in the encoded portion of the font. It appears that Optima
- %% is the only font that currently needs this, so we explicitly check
- %% the name.
- %%
- /HybridNames [ (Optima) ]
- /FGnonpsfont
- {
-
- dup (.pfb) search
- {
- pop pop pop true
- }
- {
- (.ttf) search
- {
- pop pop pop true
- }
- {
- pop false
- } ifelse
- } ifelse
-
- } bind
-
- /FontGCheck
- {
-
- FGnonpsfont
- {
- pop true
- }
- {
- 4 dict begin
- (r) file /ffile exch def
- /glob null def
- /ss 1024 string def
- {
- ffile ss readline not {pop exit} if
- (eexec) search {pop pop pop exit} if
- (/Private) search {pop pop pop exit} if
- {token} stopped {pop pop false} if {
- dup /FontType eq {
- pop token pop exch pop dup 1 eq exch 0 eq or {
- /glob true def
- } {
- /glob false def exit
- } ifelse
- } {
- /FamilyName eq {
- token pop exch pop HybridNames {
- 1 index eq {
- /glob false def exit
- } if
- } forall
- pop
- glob false eq {exit} if
- } {
- pop
- } ifelse
- } ifelse
- } if
- } loop
- glob null ne {glob} {false} ifelse
- end
- } ifelse
- }bind
-
- %% SubstituteResource is used for the situation where the font supplied
- %% by the foundry has a different name to the standard PostScript font
- %% name. Call it with /PostScriptName /FoundryName SubstituteResource.
- %% After it has finished, both fonts will have been defined in FontDirectory.
- %% [A possible optimisation might be to change Bdefinefont() so that it
- %% could add a previously defined font to the FontDirectory; currently
- %% we have to copy and redefine the font.]
- /SubstituteResource
- {
- % Save a copy of the foundry name.
- dup /foundryname exch def
-
- FindResource
- dup gcheck setglobal
- dup length dict exch
- {
- 1 index /FID eq
- {
- pop pop
- }
- {
- 1 index /OrigFontName eq
- {
- pop 2 index dup type /stringtype eq {cvn} if
- }
- {
- 1 index /FontName eq
- {
- pop 2 index dup type /stringtype eq {cvn} if
- } if
- } ifelse
- 2 index 3 1 roll put
- } ifelse
- } forall
-
- % Keep the originally requested font name around too.
- dup /TProFontName known not
- {
- dup /TProFontName foundryname dup length string cvs cvn put
- } if
-
- definefont pop
- } bind
-
- /Directory 1 dict
-
- >>
-
- /Font exch /Category defineresource
-
-
-