]> git.donarmstrong.com Git - lilypond.git/commitdiff
* ly/performer-init.ly: add CueVoice to MIDI too.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Tue, 12 Apr 2005 23:38:49 +0000 (23:38 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Tue, 12 Apr 2005 23:38:49 +0000 (23:38 +0000)
* ps/music-drawing-routines.ps: new routine BeginEPSF /
EndEPSF.

* input/regression/markup-eps.ly: new file.

* scm/framework-ps.scm (write-preamble): change order: vars should
be inited before procedures.

* scm/output-ps.scm (glyph-string): break lines. 255 chars is max
for EPS files.

* scm/define-markup-commands.scm (epsfile): add epsfile command.

16 files changed:
ChangeLog
GNUmakefile.in
configure.in
input/regression/markup-eps.ly [new file with mode: 0644]
input/regression/utf-8.ly [new file with mode: 0644]
input/regression/utf8.ly [deleted file]
lily/hairpin.cc
lily/include/hairpin.hh
lily/include/source-file.hh
lily/source-file.cc
ly/performer-init.ly
ps/music-drawing-routines.ps
scm/define-grobs.scm
scm/define-markup-commands.scm
scm/framework-ps.scm
scm/output-ps.scm

index ddc9b87c037434a4511c08c395537b94e7cb079b..0670538b67dc6e9f796ab6a724705955b14e082e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,35 @@
+2005-04-13  Han-Wen Nienhuys  <hanwen@xs4all.nl>
+
+       * ly/performer-init.ly: add CueVoice to MIDI too.
+
+       * ps/music-drawing-routines.ps: new routine BeginEPSF /
+       EndEPSF.
+
+       * input/regression/markup-eps.ly: new file.
+
+       * scm/framework-ps.scm (write-preamble): change order: vars should
+       be inited before procedures.
+
+       * scm/output-ps.scm (glyph-string): break lines. 255 chars is max
+       for EPS files.
+
+       * scm/define-markup-commands.scm (epsfile): add epsfile command.
+
+2005-04-12  Han-Wen Nienhuys  <hanwen@xs4all.nl>
+
+       * configure.in (gui_b): add check for ghostscript 8.15
+
+2005-04-11  Han-Wen Nienhuys  <hanwen@xs4all.nl>
+
+       * lily/hairpin.cc (after_line_breaking): suicide the hairpinlet at
+       start of line. Fixes cresc-after-newline.ly
+
+       * lily/source-file.cc (file_line_column_string): use get_column().
+
+2005-04-10  Han-Wen Nienhuys  <hanwen@xs4all.nl>
+
+       * lily/source-file.cc (get_column): utf-8 support for column numbers.
+
 2005-04-12  Jan Nieuwenhuizen  <janneke@gnu.org>
 
        * lily/*: use message () iso progress_indication () for messages.
@@ -50,6 +82,7 @@
 
        * GNUmakefile.in: Bugfix: also link .map files.
 
+>>>>>>> 1.3423
 2005-04-09  Nicolas Sceaux  <nicolas.sceaux@free.fr>
 
        * scm/music-functions.scm (music->make-music): generate 
index ebd654aeb769f67642c7fd609a51a77ad43112c0..e5f9f0cdf57cee69535bf51e3e08c530462815fc 100644 (file)
@@ -59,6 +59,9 @@ web-uninstall:
 local-install:
        $(INSTALL) -d $(DESTDIR)$(local_lilypond_datadir)
 
+final-install:
+       @true
+
 web-ext = html midi pdf png txt ly
 
 footify = $(PYTHON) $(step-bindir)/add-html-footer.py  --name $(PACKAGE_NAME) --version $(TOPLEVEL_VERSION)
index 6c43498096d7170498d08eef77e2b1b5ceeffa28..71107fdde7131d2dc9cb40d2a79f08928e99acd1 100644 (file)
@@ -54,6 +54,8 @@ STEPMAKE_GUILE_DEVEL(REQUIRED, 1.6.5)
 STEPMAKE_MAKEINFO(REQUIRED)
 STEPMAKE_PYTHON_DEVEL(REQUIRED)
 
+STEPMAKE_PATH_PROG(GHOSTSCRIPT, gs,  OPTIONAL, 8.15)  
+
 STEPMAKE_PROGS(MFTRACE, mftrace, REQUIRED, 1.1.1)
 STEPMAKE_PATH_PROG(FONTFORGE, fontforge, REQUIRED, 20041208)
 
diff --git a/input/regression/markup-eps.ly b/input/regression/markup-eps.ly
new file mode 100644 (file)
index 0000000..d91e074
--- /dev/null
@@ -0,0 +1,17 @@
+\header {
+
+  texidoc = "The epsfile markup command reads an EPS file"
+
+}
+\version "2.5.19"
+
+#(let* ((port (open-output-file "box.eps")))
+
+  (display "%!PS-Adobe-3.0 EPSF-3.0
+%%BoundingBox: 5 5 105 105
+10 setlinewidth 10 10 moveto 0 90 rlineto 90 0 rlineto 0 -90 rlineto
+closepath stroke" port)
+
+  (close port))
+
+{ c''4-\markup { \box \epsfile #"box.eps" } } 
diff --git a/input/regression/utf-8.ly b/input/regression/utf-8.ly
new file mode 100644 (file)
index 0000000..460c714
--- /dev/null
@@ -0,0 +1,59 @@
+\version "2.5.10"
+
+%% Edit this file using a Unicode aware editor, such as GVIM, GEDIT, Emacs
+
+%{
+
+You may have to install additional fonts.
+
+Red Hat Fedora
+
+    taipeifonts fonts-xorg-truetype ttfonts-ja fonts-arabic \
+        ttfonts-zh_CN fonts-ja fonts-hebrew 
+
+Debian GNU/Linux
+
+   apt-get install emacs-intl-fonts xfonts-intl-.* \
+       ttf-kochi-gothic ttf-kochi-mincho
+
+%} 
+
+\header {
+
+  texidoc = "Various scripts may be used for texts (like titles and
+lyrics) introduced by entering them in UTF-8 encoding, and using a
+Pango based backend. Depending on the fonts installed, this fragment
+will render Japanese, Hebrew and Cyrillic.
+
+"
+  
+}
+
+japanese = \lyricmode {  
+  いろはにほへど ちりぬるを
+  わがよたれぞ  つねならむ
+  うゐのおくや  まけふこえて
+  あさきゆめみじ ゑひもせず 
+ }
+
+
+bulgarian = \lyricmode {
+  Жълтата дюля беше щастлива, че пухът, който цъфна, замръзна като гьон.
+}
+
+hebrew = \lyricmode { 
+  זה כיף סתם לשמוע איך תנצח קרפד עץ טוב בגן.
+}
+
+portuguese = \lyricmode { 
+  à vo cê uma can ção legal
+}
+
+
+\relative  { 
+  c2 d e f g f e
+}
+\addlyrics { \hebrew }
+\addlyrics { \bulgarian }
+\addlyrics { \japanese }
+\addlyrics { \portuguese }
diff --git a/input/regression/utf8.ly b/input/regression/utf8.ly
deleted file mode 100644 (file)
index 460c714..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-\version "2.5.10"
-
-%% Edit this file using a Unicode aware editor, such as GVIM, GEDIT, Emacs
-
-%{
-
-You may have to install additional fonts.
-
-Red Hat Fedora
-
-    taipeifonts fonts-xorg-truetype ttfonts-ja fonts-arabic \
-        ttfonts-zh_CN fonts-ja fonts-hebrew 
-
-Debian GNU/Linux
-
-   apt-get install emacs-intl-fonts xfonts-intl-.* \
-       ttf-kochi-gothic ttf-kochi-mincho
-
-%} 
-
-\header {
-
-  texidoc = "Various scripts may be used for texts (like titles and
-lyrics) introduced by entering them in UTF-8 encoding, and using a
-Pango based backend. Depending on the fonts installed, this fragment
-will render Japanese, Hebrew and Cyrillic.
-
-"
-  
-}
-
-japanese = \lyricmode {  
-  いろはにほへど ちりぬるを
-  わがよたれぞ  つねならむ
-  うゐのおくや  まけふこえて
-  あさきゆめみじ ゑひもせず 
- }
-
-
-bulgarian = \lyricmode {
-  Жълтата дюля беше щастлива, че пухът, който цъфна, замръзна като гьон.
-}
-
-hebrew = \lyricmode { 
-  זה כיף סתם לשמוע איך תנצח קרפד עץ טוב בגן.
-}
-
-portuguese = \lyricmode { 
-  à vo cê uma can ção legal
-}
-
-
-\relative  { 
-  c2 d e f g f e
-}
-\addlyrics { \hebrew }
-\addlyrics { \bulgarian }
-\addlyrics { \japanese }
-\addlyrics { \portuguese }
index 2c7368fa5724cb4e8d5bebc449d9d2b5cba453a7..d4f7e8a6fb04c0f64872dae83c2a05ef4c6e4263 100644 (file)
 #include "lookup.hh"
 #include "text-item.hh"
 
+
+MAKE_SCHEME_CALLBACK(Hairpin,after_line_breaking,1);
+SCM
+Hairpin::after_line_breaking (SCM smob)
+{
+  Spanner *me = dynamic_cast<Spanner *> (unsmob_grob (smob));
+  
+  Drul_array<bool> broken;
+  Drul_array<Item *> bounds;
+  Direction d = LEFT;
+  do
+    {
+      bounds[d] = me->get_bound (d);
+      broken[d] = bounds[d]->break_status_dir () != CENTER;
+    }
+  while (flip (&d) != LEFT);
+
+  if (broken[LEFT]
+      && ly_c_equal_p (bounds[RIGHT]->get_column ()->get_property ("when"),
+                      bounds[LEFT]->get_property ("when")))
+    {
+      me->suicide ();
+    }
+  return SCM_UNSPECIFIED;
+}
+
+
 MAKE_SCHEME_CALLBACK (Hairpin, print, 1);
 
 SCM
 Hairpin::print (SCM smob)
 {
-  Grob *me = unsmob_grob (smob);
-  Spanner *spanner = dynamic_cast<Spanner *> (me);
+  Spanner *me = dynamic_cast<Spanner *> (unsmob_grob (smob));
 
   SCM s = me->get_property ("grow-direction");
   if (!is_direction (s))
@@ -42,14 +68,14 @@ Hairpin::print (SCM smob)
   Direction d = LEFT;
   do
     {
-      bounds[d] = spanner->get_bound (d);
+      bounds[d] = me->get_bound (d);
       broken[d] = bounds[d]->break_status_dir () != CENTER;
     }
   while (flip (&d) != LEFT);
 
   Grob *common = bounds[LEFT]->common_refpoint (bounds[RIGHT], X_AXIS);
   Drul_array<Real> x_points;
-
+  
   do
     {
       Item *b = bounds[d];
index 66c41193e31e13e78bbe12cc7007eeff8e5c526d..31e40f762955c029918cc6d73c82ac7da04db76e 100644 (file)
@@ -18,6 +18,7 @@ struct Hairpin
 {
 public:
   DECLARE_SCHEME_CALLBACK (print, (SCM));
+  DECLARE_SCHEME_CALLBACK (after_line_breaking, (SCM));
   static bool has_interface (Grob *);
 };
 
index faf8e5c66ba2479837b31994804b8e9d28879373..90ec4dd710d8d305fd96043077ee0e1a1d189f04 100644 (file)
@@ -53,7 +53,7 @@ public:
   Slice line_slice (char const *pos_str0) const;
   String line_string (char const *pos_str0) const;
   int get_column (char const *pos_str0) const;
-  int get_char (char const *pos_str0) const;
+  int get_char_of_line (char const *pos_str0) const;
 
   /*
     JUNKME.
index ba61d770bde679c23fe062987b77606c4a0a4b5d..c90483812486203b91bc1d1a1c6f6857ab3b7b47 100644 (file)
 
 #include "config.hh"
 
+#if HAVE_UTF8_WCHAR_H
+#include <utf8/wchar.h>  /* wcrtomb */
+#else
+#include <wchar.h> /* wcrtomb */
+#endif
+
 #include <cstdio>
+
 #if HAVE_SSTREAM
 #include <sstream>
 #else
@@ -110,7 +117,7 @@ Source_file::init_port ()
 int
 Source_file::tell () const
 {
-  return pos_str0_  - contents_str0_; 
+  return pos_str0_ - contents_str0_; 
 }
 
 std::istream*
@@ -137,7 +144,7 @@ Source_file::file_line_column_string (char const *context_str0) const
     return " (" + _ ("position unknown") + ")";
   else
     return name_string () + ":" + to_string (get_line (context_str0))
-      + ":" + to_string (get_char (context_str0));
+      + ":" + to_string (get_column (context_str0));
 }
 
 String
@@ -195,7 +202,7 @@ Source_file::line_string (char const* pos_str0) const
 }
 
 int
-Source_file::get_char (char const *pos_str0) const
+Source_file::get_char_of_line (char const *pos_str0) const
 {
   if (!contains (pos_str0))
     return 0;
@@ -210,17 +217,46 @@ Source_file::get_column (char const *pos_str0) const
   if (!contains (pos_str0))
     return 0;
 
-  int ch_i = get_char (pos_str0);
-  String line = line_string (pos_str0);
+  Slice line = line_slice (pos_str0);
+  char const *data = to_str0 ();
+  Byte const *line_start = (Byte const *)data + line[LEFT];
+
+  int left = (Byte const*) pos_str0 -  line_start;
+  String line_begin (line_start, left);
+  char const *line_chars = line_begin.to_str0();
+  
+  int column = 0;
+  mbstate_t state;
+
+  /* Initialize the state.  */
+  memset (&state, '\0', sizeof (state));
 
-  int col_i = 0;
-  for (int i = 0; i < ch_i; i++)
-    if (line[i] == '\t')
-      col_i = (col_i / 8 + 1) * 8;
-    else
-      col_i++;
+  while (left > 0)
+    {
+      wchar_t multibyte[2];
+      size_t thislen = mbrtowc (multibyte, line_chars, left, &state);
+      
+      /* Stop converting at invalid character;
+        this can mean we have read just the first part
+        of a valid character.  */
+      if (thislen == (size_t) -1)
+       break;
+      /* We want to handle embedded NUL bytes
+        but the return value is 0.  Correct this.  */
+      if (thislen == 0)
+       thislen = 1;
+
+      if (thislen == 1 && line_chars[0] == '\t')
+       column = (column / 8 + 1) * 8;  
+      else
+       column ++;
+      
+      /* Advance past this character. */
+      line_chars += thislen;
+      left -= thislen;
+    }
 
-  return col_i;
+  return column;
 }
 
 String
@@ -229,7 +265,7 @@ Source_file::error_string (char const* pos_str0) const
   if (!contains (pos_str0))
     return " (" + _ ("position unknown") + ")";
 
-  int ch_i = get_char (pos_str0);
+  int ch_i = get_char_of_line (pos_str0);
   String line = line_string (pos_str0);
   String context = line.left_string (ch_i)
     + to_string ('\n')
index 9c0abfa400c9284bd5f06149358c67f24c01ef3d..b1b5f2c723ce199a390e4f39c9d812ae4c40297d 100644 (file)
     \consists "Melisma_translator"
 }
 
+\context {
+  \Voice
+  \name CueVoice
+  \alias Voice
+}
 
 \context {
     \Voice
index 3bcfa3a45f2bf8746448c5e67730024be06c7ea5..8627ea5e11a982e3e33090b6a1f28aaabb3f106b 100644 (file)
@@ -8,7 +8,30 @@
 /pdfmark where
 {pop} {userdict /pdfmark /cleartomark load put} ifelse
 
+% from adobe tech note 5002. 
+/BeginEPSF { %def
+    /b4_Inc_state save def % Save state for cleanup
+    /dict_count countdictstack def % Count objects on dict stack
+    /op_count count 1 sub def % Count objects on operand stack
+    userdict begin % Push userdict on dict stack
+    /showpage { } def % Redefine showpage, { } = null proc
+    0 setgray 0 setlinecap % Prepare graphics state
+    1 setlinewidth 0 setlinejoin
+    10 setmiterlimit [ ] 0 setdash newpath
+    /languagelevel where % If level not equal to 1 then
+    {pop languagelevel % set strokeadjust and
+    1 ne % overprint to their defaults.
+      {false setstrokeadjust false setoverprint
+      } if
+    } if
+} bind def
+
 
+/EndEPSF { %def
+  count op_count sub {pop} repeat % Clean up stacks
+  countdictstack dict_count sub {end} repeat
+  b4_Inc_state restore
+} bind def 
 
 % llx lly urx ury URI
 /mark_URI
index bc401414e967b7371a53692a773aede8c89972f7..f6a82e8ea35b98c53892f41a22b85532b5032956 100644 (file)
     (Hairpin
      . (
        (print-function . ,Hairpin::print)
+       (after-line-breaking-callback . ,Hairpin::after_line_breaking)
        (thickness . 1.0)
        (height . 0.6666)
        (spacing-procedure . ,Spanner::set_spacing_rods)
index 4758c6603c43e58557133459b5a60f1d3d5d8064..14de51a7ad6b6471fa6bc48cfa3a1276ee340b50 100644 (file)
@@ -5,6 +5,7 @@
 ;;;; (c) 2000--2005  Han-Wen Nienhuys <hanwen@cs.uu.nl>
 ;;;;                  Jan Nieuwenhuizen <janneke@gnu.org>
 
+
 ;;; markup commands
 ;;;  * each markup function should have a doc string with
 ;;     syntax, description and example. 
@@ -45,6 +46,60 @@ the PDF backend."
         (url-expr (list 'url-link url `(quote ,xextent) `(quote ,yextent))))
     (ly:stencil-add (ly:make-stencil url-expr xextent yextent) stil)))
 
+
+(define bbox-regexp
+  (make-regexp "%%BoundingBox: ([0-9-]+) ([0-9-]+) ([0-9-]+) ([0-9-]+)"))
+
+(define (get-postscript-bbox string)
+  "Extract the bbox from STRING, or return #f if not present."
+  (let*
+      ((match (regexp-exec bbox-regexp string)))
+    
+    (if match
+       (map (lambda (x)
+              (string->number (match:substring match x)))
+            (cdr (iota 5)))
+            
+       #f)))
+
+(def-markup-command (epsfile layout props file-name) (string?)
+  "Inline an EPS image. The image is scaled such that 10 PS units is
+one staff-space."
+
+  (if (ly:get-option 'safe)
+      (interpret-markup layout props "not allowed in safe") 
+      (let*
+         ((contents (ly:gulp-file file-name))
+          (bbox (get-postscript-bbox contents))
+          (scaled-bbox
+           (if bbox
+               (map (lambda (x) (/ x 10)) bbox)
+               (begin
+                 (ly:warn (_ "Could not find bounding box of `~a'")
+                          file-name)
+                 '()))))
+       
+
+       (if bbox
+           
+           (ly:make-stencil
+            (list
+             'embedded-ps
+             (string-append
+
+              ; adobe 5002.
+              "BeginEPSF "
+              "0.1 0.1 scale "
+              (format "\n%%BeginDocument: ~a\n" file-name)
+              contents
+              "%%EndDocument\n"
+              "EndEPSF\n"
+              ))
+            (cons (list-ref scaled-bbox 0) (list-ref scaled-bbox 2))
+            (cons (list-ref scaled-bbox 1) (list-ref scaled-bbox 3)))
+           
+           (ly:make-stencil "" '(0 . 0) '(0 . 0))))))  
+
 (def-markup-command (score layout props score) (ly:score?)
   "Inline an image of music."
   (let* ((systems (ly:score-embedded-format score layout)))
index 34a90897fd4d1d46f11e258b9d6430e37e390fd6..167ca939901cc9df68e67080d3e7ce63f864bd11 100644 (file)
    "%%BeginSetup\n"
    (define-fonts paper)
    (output-variables paper)
-   "init-lilypond-parameters\n"
    "%%EndSetup\n"))
 
 (define-public (munge-lily-font-name name)
                  (filter string? font-names))))
           pfas))
 
-  (display (procset "music-drawing-routines.ps") port)
-  (display (procset "lilyponddefs.ps") port)
   (if load-fonts?
       (for-each (lambda (f) (display f port)) (load-fonts paper)))
-  (display (setup paper) port))
+  (display (setup paper) port)
+
+  ; adobe note 5002: should initialize variables before loading routines.
+  (display (procset "music-drawing-routines.ps") port)
+  (display (procset "lilyponddefs.ps") port)
+  (display "init-lilypond-parameters\n" port)
+
+  )
 
 (define-public (output-framework basename book scopes fields)
   (let* ((filename (format "~a.ps" basename))
index 33dbdbc9fd92475a82585324c08ec61860f5a23c..ceaf44306b2f31461e09af3496eb79dd55866177 100644 (file)
 
            (if (and (= 0.0 x)
                     (= 0.0 y))
-               (format #f " /~a glyphshow " g)
-               (format #f " ~a ~a rmoveto /~a glyphshow "
+               (format #f " /~a glyphshow\n" g)
+               (format #f " ~a ~a rmoveto /~a glyphshow\n"
                        x y g))))
        x-y-named-glyphs))
   ))