]> git.donarmstrong.com Git - lilypond.git/commitdiff
* scm/output-gnome.scm (text): Hello world, again.
authorJan Nieuwenhuizen <janneke@gnu.org>
Mon, 13 Dec 2004 20:00:08 +0000 (20:00 +0000)
committerJan Nieuwenhuizen <janneke@gnu.org>
Mon, 13 Dec 2004 20:00:08 +0000 (20:00 +0000)
* scm/output-svg.scm (named-glyph): New function.  Hello world!

* lily/modified-font-metric.cc (index_to_charcode): New method.

* lily/font-metric.cc (ly:font-glyph-name-to-charcode): Use it in
new function.
(ly:font-glyph-to-index): Remove.

ChangeLog
lily/font-metric.cc
lily/include/modified-font-metric.hh
lily/modified-font-metric.cc
scm/lily-library.scm
scm/output-gnome.scm
scm/output-svg.scm

index b339b7e0f4d57cc9ae0247323f7957d944f5349a..989cd1c79ffc86f8514b95814fe1714b7055ea80 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,14 +1,17 @@
 2004-12-13  Jan Nieuwenhuizen  <janneke@gnu.org>
 
+       * scm/output-gnome.scm (text): Hello world, again.
+
+       * scm/output-svg.scm (named-glyph): New function.  Hello world!
+
+       * lily/modified-font-metric.cc (index_to_charcode): New method.
+
        * lily/include/font-metric.hh (index_to_charcode): New function.
 
        * lily/font-metric.cc (ly:font-glyph-name-to-charcode): Use it in
        new function.
        (ly:font-glyph-to-index): Remove.
 
-       * lily/font-metric.cc ("ly:font-glyph-name-to-charcode"): Bugfix:
-       use original font.
-
 2004-12-12  Han-Wen Nienhuys  <hanwen@xs4all.nl>
 
        * lily/open-type-font.cc (make_index_to_charcode_map): new method.
index bbb38dc91a346da4d93a49494ba11007f9347206..9686b7b54dbc5c853b5c453bc6c6ab336b2085fa 100644 (file)
@@ -183,13 +183,7 @@ LY_DEFINE (ly_font_index_to_charcode, "ly:font-index-to-charcode",
   SCM_ASSERT_TYPE (fm, font, SCM_ARG1, __FUNCTION__, "font-metric");
   SCM_ASSERT_TYPE (scm_is_integer (index), index, SCM_ARG2, __FUNCTION__, "index");
 
-  unsigned charcode;
-  if (Modified_font_metric* mfm = dynamic_cast<Modified_font_metric*> (fm))
-    charcode = mfm->original_font ()->index_to_charcode (ly_scm2int (index));
-  else
-    charcode = fm->index_to_charcode (ly_scm2int (index));
-
-  return scm_from_unsigned_integer (charcode);
+  return scm_from_unsigned_integer (fm->index_to_charcode (ly_scm2int (index)));
 }
 
 LY_DEFINE (ly_font_glyph_name_to_charcode, "ly:font-glyph-name-to-charcode",
@@ -201,20 +195,10 @@ LY_DEFINE (ly_font_glyph_name_to_charcode, "ly:font-glyph-name-to-charcode",
   SCM_ASSERT_TYPE (fm, font, SCM_ARG1, __FUNCTION__, "font-metric");
   SCM_ASSERT_TYPE (scm_is_string (name), name, SCM_ARG2, __FUNCTION__, "string");
 #if 1
-  unsigned charcode;
-  if (Modified_font_metric* mfm = dynamic_cast<Modified_font_metric*> (fm))
-    charcode = mfm->original_font ()->index_to_charcode (mfm->original_font ()->name_to_index (ly_scm2string (name)));
-  else
-    charcode = fm->index_to_charcode (fm->name_to_index (ly_scm2string (name)));
+  return scm_from_unsigned_integer (fm->index_to_charcode (fm->name_to_index (ly_scm2string (name))));
 #else
-  unsigned charcode;
-  if (Modified_font_metric* mfm = dynamic_cast<Modified_font_metric*> (fm))
-    charcode = mfm->original_font ()->glyph_name_to_charcode (ly_scm2string (name));
-  else
-    charcode = fm->glyph_name_to_charcode (ly_scm2string (name));
+  return scm_from_unsigned_integer (fm->glyph_name_to_charcode (ly_scm2string (name)));
 #endif
-
-  return scm_from_unsigned_integer (charcode);
 }
 
 LY_DEFINE (ly_text_dimension,"ly:text-dimension",
@@ -259,7 +243,6 @@ LY_DEFINE (ly_font_name,"ly:font-name",
       
   SCM_ASSERT_TYPE (fm, font, SCM_ARG1, __FUNCTION__, "font-metric");
 
-
   if (Modified_font_metric* mfm = dynamic_cast<Modified_font_metric*> (fm))
     return ly_font_name (mfm->original_font ()->self_scm ());
   else if (Adobe_font_metric* afm = dynamic_cast<Adobe_font_metric*> (fm))
@@ -267,8 +250,6 @@ LY_DEFINE (ly_font_name,"ly:font-name",
   return SCM_BOOL_F;
 }
 
-
-
 LY_DEFINE (ly_font_magnification,"ly:font-magnification", 1 , 0, 0,
          (SCM font),
           "Given the font metric @var{font}, return the "
index 79ade2db860d856386c57917132b3fb072c628ed..277d61f8942fef4efd95c941f955759a60fdd3e4 100644 (file)
@@ -23,6 +23,7 @@ public:
   virtual Offset get_indexed_wxwy (int) const;
   virtual Offset attachment_point (String) const;
   virtual int name_to_index (String) const;
+  virtual unsigned index_to_charcode (int) const;
   virtual String coding_scheme () const;
   virtual Font_metric *original_font () const;  
   
index f92b534ad4d94caf271a414d45a270aca72a8af9..bac7d43993910ae76ae56836a4cc89c00e2067ac 100644 (file)
@@ -154,6 +154,12 @@ Modified_font_metric::name_to_index (String s) const
   return orig_->name_to_index (s);
 }
 
+unsigned
+Modified_font_metric::index_to_charcode (int i) const
+{
+  return orig_->index_to_charcode (i);
+}
+
 int
 Modified_font_metric::index_to_ascii (int k) const
 {
index 5dafe99744e7eeebd0d3ebb1c2e717a7391f2083..fa5e93d5c422581a3a7044118005f62d34b8945c 100644 (file)
@@ -344,3 +344,11 @@ possibly turned off."
 
 (define-public (char->unicode-index font char)
   (ly:font-index-to-charcode font (char->integer char)))
+
+(define-public (otf-name-mangling font family)
+  ;; Hmm, family is bigcheese20/26?
+  (if (string=? (substring family 0 (min (string-length family) 9))
+               "bigcheese")
+      "LilyPond"
+      family))
+
index 92744346ca460746da2d59fa357e6534be15a452..e44781a6a238c5d3c52c57ff8588286ff312f181 100644 (file)
 ;;;    - lilylib.
 ;;;  * Release schedule and packaging of dependencies.  This hack
 ;;;    depends on several CVS and TLA development sources.  In the works.
-;;;  * Maybe we need to have a unicode mapping somehow, we could
-;;;   - use OpenType instead of Type1
-;;;     http://lists.gnu.org/archive/html/lilypond-devel/2004-05/msg00098.html
-;;;   - or fix the pangofc-afm-decoder and add it to Pango (no chance?)
-;;;     or have fontconfig read AFM files
-;;;     http://lists.gnu.org/archive/html/lilypond-devel/2004-05/msg00103.html
 
 ;;; You need:
 ;;;
@@ -132,14 +126,10 @@ lilypond -fgnome input/simple-song.ly
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; globals
 
-;; junkme
-(define system-origin '(0 . 0))
-
 ;;; set by framework-gnome.scm
 (define canvas-root #f)
 (define output-scale #f)
 
-
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; helper functions
 
@@ -148,9 +138,15 @@ lilypond -fgnome input/simple-song.ly
   (force-output (current-error-port)))
 
 (define (debugf string . rest)
-  (if #t
+  (if #f
       (apply stderr (cons string rest))))
 
+(define (list->offsets accum coords)
+  (if (null? coords)
+      accum
+      (cons (cons (car coords) (cadr coords))
+           (list->offsets accum (cddr coords)))))
+
 (define (utf8 i)
   (cond
    ((< i #x80) (list (integer->char i)))
@@ -177,6 +173,13 @@ lilypond -fgnome input/simple-song.ly
    string-append
    (map (lambda (x) (char->utf8-string font x)) (string->list string))))
 
+(define (music-font? font)
+  (let ((encoding (ly:font-encoding font))
+       (family (font-family font)))
+    (or (memq encoding '(fetaMusic fetaBraces))
+       (string=? (substring family 0 (min (string-length family) 9))
+                 "bigcheese"))))
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; stencil outputters
 ;;;
@@ -270,7 +273,7 @@ lilypond -fgnome input/simple-song.ly
     bezier))
 
 (define (char font i)
-  (text font (integer->char i)))
+  (text font (ly:font-index-to-charcode (integer->char i))))
 
 ;; FIXME: naming
 (define (filledbox breapth width depth height)
@@ -293,9 +296,7 @@ lilypond -fgnome input/simple-song.ly
     ;; FIXME ugly hack to skip #unspecified ...
     (if (and item (not (eq? item (if #f #f))))
        (begin
-         (move item
-               (* output-scale (+ (car system-origin) x))
-               (* output-scale (- (car system-origin) y)))
+         (move item (* output-scale x) (* output-scale (- y)))
          (affine-relative item output-scale 0 0 output-scale 0 0)
          item)
        #f)))
@@ -318,16 +319,7 @@ lilypond -fgnome input/simple-song.ly
     (set-path-def props def)
     props))
 
-(define (list->offsets accum coords)
-  (if (null? coords)
-      accum
-      (cons (cons (car coords) (cadr coords))
-           (list->offsets accum (cddr coords)))))
-
 (define (named-glyph font name)
-  (debugf "glyph:~S\n" name)
-  (debugf "index:~S\n" (ly:font-glyph-name-to-charcode font name))
-  (debugf "font:~S\n" (font-family font))
   (text font (ly:font-glyph-name-to-charcode font name)))
 
 (define (polygon coords blotdiameter)
@@ -362,21 +354,11 @@ lilypond -fgnome input/simple-song.ly
       #:join-style 'round)))
 
 (define (text font s)
+
   (define (pango-font-name font)
     (stderr "FONT-NAME:~S:~S\n" (ly:font-name font) (ly:font-design-size font))
-    
-    (let ((family (font-family font)))
-      ;; Hmm, family is bigcheese20?
-      (if (string=? (substring family 0 (min (string-length family) 9))
-                                            "bigcheese")
-         (begin
-           ;; FIXME: FONT-NAME:#f:8.85678704856787
-           ;;(format #f "~S, ~S" (ly:font-name font) (ly:font-design-size font))
-           (stderr "BIGCHEESE\n")
-         "LilyPond 20"
-         )
-         family)))
-  
+    (otf-name-mangling font (font-family font)))
+
   (define (pango-font-size font)
     (let* ((designsize (ly:font-design-size font))
           (magnification (* (ly:font-magnification font)))
@@ -402,18 +384,15 @@ lilypond -fgnome input/simple-song.ly
       
       scaling))
 
-  (let ((encoding (ly:font-encoding font)))
-    (make <gnome-canvas-text>
-      #:parent (canvas-root)
-      ;; ugh, experimental placement corections
-      ;; #:x 0.0 #:y 0.0
-      #:x 0.0 #:y (if (memq encoding '(fetaMusic fetaBraces)) 0.15 0.69)
-      #:anchor (if (memq encoding '(fetaMusic fetaBraces)) 'west 'south-west)
-      #:font (pango-font-name font)
-      #:size-points (pango-font-size font)
-      #:size-set #t
-      #:text (if (char? s)
-                (char->utf8-string font s)
-                (if (integer? s)
-                    (integer->utf8-string font s)
-                    (string->utf8-string font s))))))
+  (make <gnome-canvas-text>
+    #:parent (canvas-root)
+    ;; ugh, experimental placement corections
+    ;; #:x 0.0 #:y 0.0
+    #:x 0.0 #:y (if (music-font? font) 0.15 0.69)
+    #:anchor (if (music-font? font) 'west 'south-west)
+    #:font (pango-font-name font)
+    #:size-points (pango-font-size font)
+    #:size-set #t
+    #:text (if (integer? s)
+              (integer->utf8-string font s)
+              (string->utf8-string font s))))
index 6b4cf35dcc2663a4e947aed3330e1e79f981b489..ab923e94a226a9ea2bd5afe3efdd9cf888fec638 100644 (file)
@@ -6,26 +6,6 @@
 
 ;;;; http://www.w3.org/TR/SVG11
 
-;;; FIXME
-
-;;; * sodipodi gets confuseed by dashes in font names.
-;;;
-;;;   removing feta-nummer*.pfa (LilyPond-feta-nummer),
-;;;   feta-braces*.pfa (LilyPond-feta-braces), feta-din*.pfa
-;;;   (LilyPond-feta-din) from font path shows feta fonts in sodipodi.
-;;;
-;;; * inkscape fails to map Feta fonts to private use area (PUA) E000
-;;;   (sodipodi is fine).
-
-;;; * maybe we need to have a unicode mapping somehow, we could
-;;;   - use OpenType instead of Type1
-;;; http://lists.gnu.org/archive/html/lilypond-devel/2004-05/msg00098.html
-;;;
-;;;   - or fix the pangofc-afm-decoder and add it to Pango (no chance?)
-;;;     or have fontconfig read AFM files
-;;;  http://lists.gnu.org/archive/html/lilypond-devel/2004-05/msg00103.html
-
-
 (debug-enable 'backtrace)
 (define-module (scm output-svg))
 (define this-module (current-module))
@@ -47,7 +27,6 @@
   (if #f
       (apply stderr (cons string rest))))
 
-
 (define (dispatch expr)
   (let ((keyword (car expr)))
     (cond
     (debugf "design:~S\n" designsize)
     scaling))
 
+(define (integer->entity integer)
+  (format #f "&#x~x;" integer))
+                  
 (define (char->entity font char)
-  (format #f "&#x~x;" (char->unicode-index font char)))
+  (integer->entity (char->unicode-index font char)))
                   
 (define (string->entities font string)
   (apply string-append
   (let* ((encoding (ly:font-encoding font))
         (anchor (if (memq encoding '(fetaMusic fetaBraces)) 'start 'start)))
    (format #f "font-family:~a;font-size:~a;text-anchor:~S;"
-          (font-family font) (font-size font) anchor)))
+          (otf-name-mangling font (font-family font))
+          (font-size font) anchor)))
 
 (define (fontify font expr)
    (tagify "text" expr (cons 'style (svg-font font))))
 
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
-
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; stencil outputters
 ;;;
 (define (filledbox breapth width depth height)
   (round-filled-box breapth width depth height 0))
 
+(define (named-glyph font name)
+  (dispatch
+   `(fontify ,font ,(tagify "tspan"
+                           (integer->entity
+                            (ly:font-glyph-name-to-charcode font name))))))
+
 (define (placebox x y expr)
   (tagify "g"
          ;; FIXME -- JCN