Trying to print strings consisting of other than ASCII-only characters
lead to exploring character maps in FPS. This lead to the following
findings:
======================================================================
The code below will result in the error also shown below. The masked
integer map maps the character to be displayed to a glyph that does
not have a "encoding from integer to glyph" (i.e. it's code is -1).
If a glyph has a code below 128 it is shown using "character show
method". But this should only happen for codes in the range 0-127,
and not with code -1.
(let* ((int-map (mask-int-map '((1 . "adieresis")) base-int-map))
(font (font "Helvetica" 10 int-map)))
(show-w/ps2-text-channel (current-output-port)
(paint-glyphpath (int->glyphpath font 1))))
Error: exception
"wrong-type-argument"
(ascii->char -1)
"note: INTEGER->CHAR doesn't use ASCII; open ASCII and use ASCII->CHAR"
This patch makes the check include a lower boundary which catches the
case of having code -1.
*** fps.glyph.scm.orig Fri Aug 23 15:43:16 2002
--- fps.glyph.scm Sat Mar 1 22:26:57 2003
***************
*** 294,300 ****
(let ((glyph (font-int-map-ref map int)))
(if (glyph? glyph)
(let ((code (glyph:code glyph)))
! (if (< code 128)
(ascii->char code)
glyph))
error-tag))
--- 294,300 ----
(let ((glyph (font-int-map-ref map int)))
(if (glyph? glyph)
(let ((code (glyph:code glyph)))
! (if (< -1 code 128)
(ascii->char code)
glyph))
error-tag))
======================================================================
The code below will result in only the first glyph being shown, as
opposed to all as one could expect. This is because there seems to be
a trivial error (though not too easy to track down when one doesn't
know...) in vector-for-each that makes it apply the proc on only the
first element of the vector, as opposed to all elements as one could
expect.
(let* ((char-map (mask-char-map '((#\a . "adieresis")
(#\o . "odieresis")
(#\u . "udieresis"))
base-char-map))
(font (font "Helvetica" 10 char-map)))
(show-w/ps2-text-channel (current-output-port)
(paint-glyphpath
(simple-string->glyphpath font "aou"))))
The below patch corrects this. It also corrects string-for-each which
seems to have the same error due to supposedly copy-and-paste, but
isn't used anywhere in FPS as far as I can tell.
*** fps.util.scm.orig Thu Oct 31 20:07:18 1996
--- fps.util.scm Sat Mar 1 23:04:35 2003
***************
*** 149,155 ****
(let ((len (vector-length vec)))
(let loop ((n 0))
(if (< n len)
! (proc (vector-ref vec n))))))
(define (vector-reduce proc seed vec)
(let* ((len (vector-length vec))
--- 149,157 ----
(let ((len (vector-length vec)))
(let loop ((n 0))
(if (< n len)
! (begin
! (proc (vector-ref vec n))
! (loop (+ n 1)))))))
(define (vector-reduce proc seed vec)
(let* ((len (vector-length vec))
***************
*** 171,177 ****
(let ((len (string-length str)))
(let loop ((n 0))
(if (< n len)
! (proc (string-ref str n))))))
;; Utiltiy procedure. Puts out PostScript numerals. i.e. integers
--- 173,181 ----
(let ((len (string-length str)))
(let loop ((n 0))
(if (< n len)
! (begin
! (proc (string-ref str n))
! (loop (+ n 1)))))))
;; Utiltiy procedure. Puts out PostScript numerals. i.e. integers
======================================================================
Ignoring the more innocent spelling errors in the documentation, there
are some errors in the examples for mask-char-map and int-char-map
which could use some correcting to avoid errors when copy-and-pasting
from the documentation examples:
The mask-char-map and int-char-map examples in fps-ref.txt need to
quote the alists and insert dots between keys and values.
|