diff options
author | Henry Stiles <henry.stiles@artifex.com> | 1999-10-03 08:21:45 +0000 |
---|---|---|
committer | Henry Stiles <henry.stiles@artifex.com> | 1999-10-03 08:21:45 +0000 |
commit | ee50b36ccabde111c6d77c5f9892213d53060a18 (patch) | |
tree | 35f7e38774b082c4cdbe4f4fad881903862a83c2 /gs/lib/pdf_font.ps | |
parent | 0ea97dbf2a40bc347a20134197643bc1daef6de8 (diff) |
This is the first gs593 integration it is *NOT* a release. Normally
each file is checked in with an associated log entry, in order to
check in all of the code simultaneously we batch all of the file
name's modified and change descriptions here (Note: Aladdin code changes
are documented in gs/doc/News.htm)
- pcstate.h - removes show enumeration from pcl state.
- pctop.c, pxtop.c
- gs_grestore_no_wraparound()'s is now gs_grestore_only().
- pxgstate.c
- ENUM_RETURN_CONST_STRING_PTR() now takes a gs string
argument instead of the string's data as it did
previously.
- plmain.c -
- The library no longer initializes io devices. Adds
gs_iodev_init() to main() procedure. Also, gs_c_param_list_rewrite()
is renamed to gs_c_param_list_write_more().
- pcltop.mak - adds pipe.dev for operating system pipe support.
- pctext.c, pglabel.c, pxfont.c, plfont.c
- extensive modifications to support the text api (gstext.h)
- use gs_text_enum_t instead of gs_show_enum.
- removes enumeration allocation, this is now done by the text
"begin" functions.
- update "next_char" procs and "encode char" procs to take a
glyph argument and the character argument is now passed by value
(pcl nor xl make use of the glyph argument).
- char_path_n_init() replaced with gs_charpath_begin().
- gs_show_n_init() replaced with gs_show_begin().
- gs_show_next() is now handled by gs_process_text().
- gs_release_text() added.
- gs_xyshow_n_init() replace with gs_xyshow_begin(). Passing
of x and y coordinates modified to support the new interface.
Unfortunately, we need to transform the coordinates into the
space of the font scaling matrix, that is the current ctm for
xl when the the text is processed. This differs from postscript
which appears to have the regular user->device matrix in the
graphics state during processing.
- (plfont.c) - gs_notify_init() is now part of the pfont
initialization procedure, related TODO: cut over to gs_font_alloc()
and gs_font_base_alloc().
- all gs files - removes uninitialized rcs identifiers.
KNOWN PROBLEMS:
occassional pxl and pcl crashes in gdev_mem_set_line_ptrs() when
running in color due to null base (data) pointer.
git-svn-id: http://svn.ghostscript.com/ghostpcl/trunk/ghostpcl@985 06663e23-700e-0410-b217-a244a6096597
Diffstat (limited to 'gs/lib/pdf_font.ps')
-rw-r--r-- | gs/lib/pdf_font.ps | 102 |
1 files changed, 71 insertions, 31 deletions
diff --git a/gs/lib/pdf_font.ps b/gs/lib/pdf_font.ps index dffcde41e..cd284680e 100644 --- a/gs/lib/pdf_font.ps +++ b/gs/lib/pdf_font.ps @@ -31,16 +31,21 @@ pdfdict begin % ---------------- Encodings ---------------- % % Apply a list of differences to an Encoding. -/updateencoding % <encoding> <differences> updateencoding <enc'> - { exch dup length array copy - exch 0 exch { +% Note that the differences may cause the array to grow. +/updateencoding { % <encoding> <differences> updateencoding <enc'> + % Calculate the length of the result. + exch 0 2 index { + dup type /nametype ne { exch pop } { pop 1 add } ifelse + } forall + 1 index length .max array dup 0 4 -1 roll putinterval + exch 0 exch { % Stack: enc' code element - dup type /nametype ne + dup type /nametype ne { exch pop } { 3 copy put pop 1 add } - ifelse - } forall pop - } bdef + ifelse + } forall pop +} bdef % Get the Encoding for a font. /getencoding % <base-encoding> <font-resource> getencoding <enc> @@ -59,18 +64,20 @@ pdfdict begin if } bdef +% Rename a font with a generated name. +/renamefont { % <fontdict> renamefont <font'> + dup /FontName 2 copy get genfontname dup 5 1 roll put definefont +} bind def + % Adjust a font according to the Encoding and Widths in the font resource. -/adjustfont % <font-resource> <font> adjustfont - % <font'> <changed> - { getfontencoding getfontmetrics 4 -1 roll pop .updatefont - { dup /FontName 2 copy get genfontname dup 5 1 roll put definefont } - if - } bind def +/adjustfont { % <font-resource> <font> adjustfont <font'> + getfontencoding getfontmetrics 4 -1 roll pop .updatefont { renamefont } if +} bind def % Get the (possibly modified) encoding of a font. /getfontencoding % <font-resource> <font> getfontencoding % <font-resource> <font> <encoding> - { dup /Encoding get 2 index getencoding + { dup /Encoding .knownget { 2 index getencoding } { null } ifelse } bdef % Get the metrics of a font, if specified. @@ -163,10 +170,10 @@ pdfdict begin % ---------------- Utilities ---------------- % -% Fabricate a font name by adding %'s on the end. +% Fabricate a font name by adding ?'s on the end. /genfontname % <name> genfontname <name> { dup length string cvs - { (%) concatstrings + { (?) concatstrings dup cvn FontDirectory exch known not { cvn exit } if } loop @@ -182,22 +189,49 @@ pdfdict begin 1 index /FontDescriptor knownoget { % Stack: font-res fontname fontdesc dup /Flags oget - dup 16#40 and -6 bitshift % oblique/italic - exch 16#40000 and -17 bitshift add % bold - % We should look at the serif and fixed flags, too. + dup 16#40 and -6 bitshift % 1, oblique/italic + 1 index 16#40000 and -17 bitshift add % 2, bold + exch 16#2 and 2 bitshift add % 8, serif + % We should look at the fixed flag, too. % Stack: font-res fontname fontdesc properties - exch /FontName oget exch + 1 index /FontName oget exch 1 index .fontnameproperties or .substitutefontname + % Stack: font-res fontname fontdesc substname|null Fontmap 1 index known not { % No available good substitution, use the standard one. - pop dup .substitutefont + pop 1 index .substitutefont } if QUIET not { (Substituting font ) print dup =only - ( for ) print 1 index =only (.\n) print flush + ( for ) print 2 index =only (.\n) print flush + } if + 3 -1 roll pop findfont + % Stack: font-res fontdesc font + % If this is a small-caps font, replace the CharString + % entries for a..z. + exch /Flags oget 16#20000 and 0 ne { + true .copyfontdict + dup /CharStrings 2 copy get dup length dict .copydict + 4 index /FirstChar get 97 .max + 5 index /LastChar get 122 .min 1 exch { + % Stack: font-res font' font' /CharStrings charstrings code + % Note that this only remaps a-z, not accented characters. + 5 index /Widths oget 1 index 7 index /FirstChar get sub oget + 1 string dup 0 5 -1 roll put + % Stack: font-res font' font' /CharStrings charstrings code + % width (x) + 2 index exch dup cvn exch + dup 0 2 copy get 32 sub put 4 -1 roll { + % Stack: operand (X) width + 0 setcharwidth exch pop + % ****** I HAVE ABSOLUTELY NO IDEA WHY THE NUMBER + % ****** 70 PRODUCES THE CORRECT OUTPUT HERE. + 70 70 scale 0 0 moveto show + } /exec cvx 4 packedarray cvx put + } for put + renamefont } if - exch pop findfont } { % No descriptor available, use the default algorithm. findfont @@ -397,14 +431,20 @@ readonly def } bdef % Read an embedded TrueType font. -/readtruetype % <font-resource> <stream-dict> readtruetype <font> - { % This is much simpler than readtype1, because we don't +/readtruetype { % <font-resource> <stream-dict> readtruetype <font> + % This is much simpler than readtype1, because we don't % have to deal with the tripartite .PFB format. - PDFfile fileposition 3 1 roll - true resolvestream readfontfilter .loadttfont - dup /FontName get exch definefont exch pop - PDFfile 3 -1 roll setfileposition - } bdef + PDFfile fileposition 3 1 roll + true resolvestream readfontfilter + % Stack: filepos fontres stream + 1 index /Subtype get /CIDFontType2 eq { + .loadttcidfont + } { + .loadttfont + } ifelse + exch pop + PDFfile 3 -1 roll setfileposition +} bdef % ---------------- Type 0 fonts ---------------- % @@ -594,7 +634,7 @@ drawopdict begin /d0 /setcharwidth load def /d1 /setcachedevice load def /Tf - { 1 index Page /Font rget not { 1 index /undefinedfont signalerror } if + { 1 index Page /Font rget not { 1 index /invalidfont signalerror } if resourcefont exch Tf pop } bdef end |