]> git.donarmstrong.com Git - lilypond.git/commitdiff
Merge branch 'master' of ssh://jomand@git.sv.gnu.org/srv/git/lilypond
authorJohn Mandereau <john.mandereau@gmail.com>
Sun, 20 Apr 2008 23:47:01 +0000 (01:47 +0200)
committerJohn Mandereau <john.mandereau@gmail.com>
Sun, 20 Apr 2008 23:47:01 +0000 (01:47 +0200)
* 'master' of ssh://jomand@git.sv.gnu.org/srv/git/lilypond:
  New \rounded-box markup command
  Don't crash if someone attempts to use an OTF font for a text string.
  Shut up some warnings from gcc 4.3.

Documentation/topdocs/NEWS.tely
lily/font-metric.cc
lily/include/lily-guile.hh
scm/define-markup-commands.scm
scm/stencil.scm

index 3428c521b5441502e800ff826b369d955fda652a..6ca65b7e6085d2de8c79b02d7f115c63ebe8242c 100644 (file)
@@ -65,6 +65,10 @@ which scares away people.
 
 @end ignore
 
+@item
+Enclosing text within boxes with rounded corners is now possible,
+using the @code{rounded-box} command.
+
 @item
 @command{lilypond-book} can run any program instead of @command{latex}
 to guess the line width, thanks to @code{--latex} command line option.
index 2f61d53f3fb821746b6a64e29b98d6a867b1cbdd..655d992123f4859cbc4d73cbdf430d22fbaafc4e 100644 (file)
@@ -188,7 +188,7 @@ Stencil
 Font_metric::text_stencil (string str) const
 {
   (void) str;
-  assert (false);
+  programming_error("Cannot get a text stencil from this font");
   return Stencil (Box (), SCM_EOL);
 }
 
index 2265e249c29ff6f8d926c8b738c55a29154b88ca..30288179980b59882737786f655b922c08d1948f 100644 (file)
@@ -101,7 +101,7 @@ inline bool ly_is_equal (SCM x, SCM y)
 }
 
 inline bool ly_scm2bool (SCM x) { return SCM_NFALSEP (x); }
-inline char ly_scm2char (SCM x) { return SCM_CHAR (x); }
+inline char ly_scm2char (SCM x) { return (char)SCM_CHAR (x); }
 inline SCM ly_bool2scm (bool x) { return SCM_BOOL (x); }
 
 inline SCM ly_append2 (SCM x1, SCM x2)
index 6114e616262f8c13393e34de9d2152e68e45f733..9ddfa4982096cf906a1c99f26c5eacb8e111251e 100644 (file)
@@ -200,6 +200,24 @@ circle of diameter@tie{}0 (i.e. sharp corners)."
   (ly:round-filled-box
    xext yext blot))
 
+(define-builtin-markup-command (rounded-box layout props arg) (markup?)
+  "@cindex enclosing text in a bow with rounded corners
+   @cindex drawing boxes with rounded corners around text
+Draw a box with rounded corners around @var{arg}.  Looks at @code{thickness},
+@code{box-padding} and @code{font-size} properties to determine line
+thickness and padding around the markup; the @code{corner-radius} property
+makes possible to define another shape for the corners (default is 1)." 
+  (let* ((th (*
+             (ly:output-def-lookup layout 'line-thickness)
+             (chain-assoc-get 'thickness props 1)))
+         (rad (chain-assoc-get 'corner-radius props 1))
+        (size (chain-assoc-get 'font-size props 0))
+        (pad (* (magstep size)
+                (chain-assoc-get 'box-padding props 0.5)))
+        (m (interpret-markup layout props arg)))
+    (ly:stencil-add (rounded-box-stencil m th pad rad)
+    m)))
+
 (define-builtin-markup-command (rotate layout props ang arg) (number? markup?)
   "
 @cindex rotating text
index e4c15978b4fb6288b589a96f5648a8fa9a42637d..baa8fe8ccd626685b0f67e7e4da313a69fc0d1a8 100644 (file)
@@ -129,6 +129,19 @@ encloses the contents.
                            (interval-center x-ext)
                            (interval-center y-ext))))))
 
+(define-public (rounded-box-stencil stencil thickness padding blot)
+   "Add a rounded box around STENCIL, producing a new stencil."  
+
+  (let* ((xext (interval-widen (ly:stencil-extent stencil 0) padding))
+        (yext (interval-widen (ly:stencil-extent stencil 1) padding))
+        (outer (ly:round-filled-box
+                 (interval-widen xext thickness) (interval-widen yext thickness) blot))
+        (inner (ly:make-stencil (list 'color (x11-color 'white) (ly:stencil-expr (ly:round-filled-box 
+       (cons (+ (car xext) thickness) (- (cdr xext) thickness)) 
+       (cons (+ (car yext) thickness) (- (cdr yext) thickness)) (* blot 0.8)))))))
+    (set! stencil (ly:stencil-add outer inner))
+    stencil))
+
 
 (define-public (fontify-text font-metric text)
   "Set TEXT with font FONT-METRIC, returning a stencil."