From: Han-Wen Nienhuys Date: Fri, 19 Nov 2004 22:41:54 +0000 (+0000) Subject: * scm/output-ps.scm (new-text): new function. Use glyphshow to X-Git-Tag: release/2.5.14~525 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=db0dc7f97101c1e386353be2775d14cc375d0238;p=lilypond.git * scm/output-ps.scm (new-text): new function. Use glyphshow to show glyphs. * scm/encoding.scm (decode-byte-string): new function. --- diff --git a/ChangeLog b/ChangeLog index fa9e180ed4..8426c20012 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2004-11-19 Han-Wen Nienhuys + * scm/output-ps.scm (new-text): new function. Use glyphshow to + show glyphs. + + * scm/encoding.scm (decode-byte-string): new function. + * scripts/convert-ly.py (conv): add warning about set-global-staff-size. diff --git a/VERSION b/VERSION index 7a3bd85580..eaee5216d6 100644 --- a/VERSION +++ b/VERSION @@ -1,6 +1,6 @@ PACKAGE_NAME=LilyPond MAJOR_VERSION=2 MINOR_VERSION=5 -PATCH_LEVEL=0 -MY_PATCH_LEVEL=hwn1 +PATCH_LEVEL=1 +MY_PATCH_LEVEL= diff --git a/lily/font-select.cc b/lily/font-select.cc index 0613840b00..5e40842d4c 100644 --- a/lily/font-select.cc +++ b/lily/font-select.cc @@ -87,7 +87,6 @@ get_font_by_design_size (Output_def *layout, Real requested, Font_metric *fm = unsmob_metrics (scm_force (SCM_VECTOR_REF (font_vector, i))); return find_scaled_font (layout, fm, requested / size, input_encoding); - } Font_metric* diff --git a/scm/encoding.scm b/scm/encoding.scm index dc10d1f116..d22223f496 100644 --- a/scm/encoding.scm +++ b/scm/encoding.scm @@ -63,10 +63,10 @@ vector of symbols." (define (get-coding-from-file file-name) "Read FILE-NAME, return a list containing encoding vector and table" (let* ((coding (read-encoding-file file-name)) - (com (car coding)) - (vec (cdr coding)) - (tab (make-encoding-table vec))) - (list com vec tab))) + (command (car coding)) + (vector (cdr coding)) + (table (make-encoding-table vector))) + (list command vector table))) ;; coding-alist maps NAME -> (list FILE-NAME COMMAND VECTOR TAB) (define coding-alist @@ -130,3 +130,23 @@ vector of symbols." (define-public (get-coding-table coding-name) (cadddr (get-coding coding-name))) + + +(define-public (decode-byte-string encoding-name str) + "Return vector of glyphname symbols that correspond to string, +assuming that STR is byte-coded using ENCODING-NAME." + + (let* + ((coding-vector (get-coding-vector encoding-name)) + (len (string-length str)) + (output-vector (make-vector len '.notdef)) + ) + + + (do + ((idx 0 (1+ idx))) + ((>= idx len) output-vector) + (vector-set! output-vector idx + (vector-ref coding-vector + (char->integer (string-ref str idx)))) + ))) diff --git a/scm/lily-library.scm b/scm/lily-library.scm index 0ec8b3195d..acf7ff41e1 100644 --- a/scm/lily-library.scm +++ b/scm/lily-library.scm @@ -123,9 +123,17 @@ found." )) ;;;;;;;;;;;;;;;; -;; hash - +;; vector +(define-public (vector-for-each proc vec) + (do + ((i 0 (1+ i))) + ((>= i (vector-length vec)) vec) + + (vector-set! vec i + (proc (vector-ref vec i))))) +;;;;;;;;;;;;;;;; +;; hash (if (not (defined? 'hash-table?)) ; guile 1.6 compat (begin diff --git a/scm/output-ps.scm b/scm/output-ps.scm index d9788b292c..8f937d79d8 100644 --- a/scm/output-ps.scm +++ b/scm/output-ps.scm @@ -209,7 +209,7 @@ (ly:numbers->string (list x y width height blotdiam)) " draw_round_box")) -(define (text font s) +(define (old-text font s) (let* ;; ugh, we should find a better way to @@ -241,6 +241,31 @@ (string-join (reverse commands))) )) +(define (new-text font s) + (let* + ((space-length (cdar (ly:text-dimension font "t"))) + (space-move (string-append (number->string space-length) " 0.0 rmoveto ")) + + (input-enc (assoc-get 'input-name + (ly:font-encoding-alist font) + 'latin1)) + (out-vec (decode-byte-string input-enc s))) + + + (string-append + (ps-font-command font) " setfont " + (string-join + (vector->list + (vector-for-each + + (lambda (sym) + (if (eq? sym 'space) + space-move + (string-append "/" (symbol->string sym) " glyphshow"))) + out-vec))) + ))) + +(define text old-text) (define (white-text scale s) (let ((mystring (string-append "(" s ") " (number->string scale) " /Helvetica-bold "