]> git.donarmstrong.com Git - lilypond.git/commitdiff
Add Output_def argument to Font_metric::text_stencil().
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sat, 13 Mar 2010 06:03:47 +0000 (03:03 -0300)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Mon, 22 Mar 2010 12:56:27 +0000 (09:56 -0300)
Side effects:

- remove fontify-text, fontify-white-text

- remove ly:text-dimension

- remove output-ps.scm (text ) output expression.

lily/font-metric-scheme.cc
lily/font-metric.cc
lily/include/font-metric.hh
lily/include/modified-font-metric.hh
lily/include/pango-font.hh
lily/modified-font-metric.cc
lily/pango-font.cc
lily/text-interface.cc
scm/output-ps.scm
scm/safe-lily.scm
scm/stencil.scm

index 7f57e5d1c35c65e70f7711a89b16a211036a3bd1..faa007aac57ad7683c9870f6ad3a8873f977825f 100644 (file)
@@ -119,25 +119,6 @@ LY_DEFINE (ly_font_glyph_name_to_charcode, "ly:font-glyph-name-to-charcode",
   return scm_from_unsigned_integer (fm->index_to_charcode (fm->name_to_index (ly_scm2string (name))));
 }
 
-LY_DEFINE (ly_text_dimension, "ly:text-dimension",
-          2, 0, 0,
-          (SCM font, SCM text),
-          "Given the font metric in @var{font} and the string @var{text},"
-          " compute the extents of that text in that font.  The return"
-          " value is a pair of number-pairs.")
-{
-  Box b;
-  Modified_font_metric *fm = dynamic_cast<Modified_font_metric *>
-    (unsmob_metrics (font));
-
-  LY_ASSERT_SMOB (Font_metric, font, 1);
-  LY_ASSERT_TYPE (scm_is_string, text, 2);
-  Stencil stc (fm->text_stencil (ly_scm2string (text), false));
-  return scm_cons (ly_interval2scm (stc.extent (X_AXIS)),
-                  ly_interval2scm (stc.extent (Y_AXIS)));
-}
-
-
 /*
   TODO: when are non string retvals allowed?
  */
index 291aa2333a0b2f1885b7226f427175fd1dff4680..1ff7e47fc0714ddb4e9823d5963c0ca7ee16fde2 100644 (file)
@@ -189,8 +189,11 @@ Font_metric::sub_fonts () const
 }
 
 Stencil
-Font_metric::text_stencil (string, bool) const
+Font_metric::text_stencil (Output_def* state,
+                           string, bool) const
 {
+  (void) state;
+  
   programming_error ("Cannot get a text stencil from this font");
   return Stencil (Box (), SCM_EOL);
 }
index 7c83f94095598ba4220e6a544e98285db5520d61..04e78f8e378c84191a27bf1cd8af56c01f249757 100644 (file)
@@ -39,7 +39,10 @@ public:
   SCM description_;
   string file_name_;
 
-  virtual Stencil text_stencil (string, bool) const;
+  // Return stencil for given string. output_state may be modified to
+  // record the font.
+  virtual Stencil text_stencil (Output_def* output_state,
+                                string text, bool music) const;
 
   // ugh.
   virtual Box text_dimension (string) const;
index 7fa70e365dd2ecf581e898096d7b7b08c6ec88da..35b7d5b4ccdb19c403cd9b58fda8d36e3362e6de 100644 (file)
@@ -28,7 +28,7 @@ struct Modified_font_metric : public Font_metric
 public:
   Box text_dimension (string) const;
   Box word_dimension (string) const;
-  Stencil text_stencil (string, bool) const;
+  Stencil text_stencil (Output_def* output_state, string, bool) const;
 
   static SCM make_scaled_font_metric (Font_metric *fm, Real magnification);
   size_t count () const;
index b87550f716646be6bbd9efb409fddcc2d962939b..31ce425485a81c70ade4ad9534bf70a249c6afbb 100644 (file)
@@ -53,7 +53,8 @@ public:
 
   Stencil pango_item_string_stencil (PangoGlyphItem const *, bool) const;
 
-  virtual Stencil text_stencil (string, bool) const;
+  virtual Stencil text_stencil (Output_def* output_state,
+                                string text, bool music) const;
   virtual void derived_mark () const;
 };
 
index 47b19618bda1126e14cc429bfb528c68f8530b62..539a27173d920eb78e62bab2fc178b1eed1b9b10 100644 (file)
@@ -113,12 +113,13 @@ Modified_font_metric::derived_mark () const
 }
 
 Stencil
-Modified_font_metric::text_stencil (string text, bool feta) const
+Modified_font_metric::text_stencil (Output_def* state,
+                                    string text, bool feta) const
 {
   Box b;
   if (Pango_font *pf = dynamic_cast<Pango_font *> (orig_))
     {
-      Stencil stc = pf->text_stencil (text, feta);
+      Stencil stc = pf->text_stencil (state, text, feta);
 
       Box b = stc.extent_box ();
 
@@ -127,7 +128,7 @@ Modified_font_metric::text_stencil (string text, bool feta) const
       return scaled;
     }
 
-  return Font_metric::text_stencil (text, feta);
+  return Font_metric::text_stencil (state, text, feta);
 }
 
 Box
index d08a9c8f401266743eafa4b61755abdbd1438093..6d18820b97e66eb83461a68ea1002e296623d15a 100644 (file)
@@ -301,7 +301,8 @@ Pango_font::physical_font_tab () const
 }
 
 Stencil
-Pango_font::text_stencil (string str, bool music_string) const
+Pango_font::text_stencil (Output_def* state,
+                          string str, bool music_string) const
 {
   return text_stencil (str, music_string, false);
 }
index 5d20d6383f667c667ff1fe3b40f17db5010b7d65..abd31a2c696ad2d91a9f392d6b923d52cf30e5b8 100644 (file)
@@ -75,10 +75,8 @@ Text_interface::interpret_string (SCM layout_smob,
                                     SCM_BOOL_F);
   SCM music_encodings = ly_lily_module_constant ("all-music-font-encodings");
 
-  if (scm_memq (encoding, music_encodings) != SCM_BOOL_F)
-    return fm->text_stencil (str, true).smobbed_copy ();
-  else
-    return fm->text_stencil (str, false).smobbed_copy ();
+  bool is_music = (scm_memq (encoding, music_encodings) != SCM_BOOL_F);
+  return fm->text_stencil (layout, str, is_music).smobbed_copy ();
 }
 
 MAKE_SCHEME_CALLBACK_WITH_OPTARGS (Text_interface, interpret_markup, 3, 0,
index 5b5a21c7f326c29554f7bd896db4b2084605c82e..06b324b799c7abd07f10c1518ead850bd897724e 100644 (file)
 (define (resetrotation ang x y)
   "grestore  ")
 
-
-(define (text font s)
-  ;; (ly:warning (_ "TEXT backend-command encountered in Pango backend"))
-  ;; (ly:warning (_ "Arguments: ~a ~a"" font str))
-  
-  (let* ((space-length (cdar (ly:text-dimension font " ")))
-        (space-move (string-append (number->string space-length)
-                                   ;; how much precision do we need here?
-                                   " 0.0 rmoveto "))
-        (out-vec (decode-byte-string s)))
-
-    (string-append
-     (ps-font-command font) " "
-     (string-join
-      (vector->list
-       (vector-for-each
-       
-       (lambda (sym)
-         (if (eq? sym 'space)
-             space-move
-             (string-append "/" (symbol->string sym) " glyphshow")))
-       out-vec))))))
-
 (define (unknown) 
   "\n unknown\n")
 
index 894680ffc3e08d70c761bf29f577dc56a412625d..8a8faeba13cce22e5703bcd4444d1685f7c4956c 100644 (file)
    ly:stencil-translate
    ly:stencil-translate-axis
    ly:stencil?
-   ly:text-dimension
    ly:translator-description
    ly:translator-name
    ly:translator?
index ce544ef66b3c4efab15e298b28331ad77f1ddd7a..5e32f1efbb6896f918631269661f7482297ed683 100644 (file)
@@ -316,21 +316,6 @@ encloses the contents.
     (set! stencil (ly:stencil-add outer inner))
     stencil))
 
-
-(define-public (fontify-text font-metric text)
-  "Set TEXT with font FONT-METRIC, returning a stencil."
-  (let* ((b (ly:text-dimension font-metric text)))
-    (ly:make-stencil
-     `(text ,font-metric ,text) (car b) (cdr b))))
-
-(define-public (fontify-text-white scale font-metric text)
-  "Set TEXT with scale factor SCALE"
-  (let* ((b (ly:text-dimension font-metric text))
-        ;;urg -- workaround for using ps font
-         (c `(white-text ,(* 2 scale) ,text)))
-    ;;urg -- extent is not from ps font, but we hope it's close
-    (ly:make-stencil c (car b) (cdr b))))
-
 (define-public (stencil-with-color stencil color)
   (ly:make-stencil
    (list 'color color (ly:stencil-expr stencil))