]> git.donarmstrong.com Git - lilypond.git/commitdiff
(ChordNamesContext): minimumverticalExtent
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Fri, 16 Aug 2002 20:09:03 +0000 (20:09 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Fri, 16 Aug 2002 20:09:03 +0000 (20:09 +0000)
-> minimumVerticalExtent

ChangeLog
Documentation/user/refman.itely
ly/engraver-init.ly
scm/pdf.scm
scm/pdftex.scm
scripts/ly2dvi.py
tex/lily-pdf-defs.tex

index 7abe88c42c8d758e6893e8115ab3059c357a4511..83e615be18f8fdc4aafc152b8a4e58795c09235c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2002-08-16  Han-Wen Nienhuys  <hanwen@cs.uu.nl>
+
+       * ly/engraver-init.ly (ChordNamesContext): minimumverticalExtent
+       -> minimumVerticalExtent
+
+2002-08-16  Stephen Peters <portnoy@portnoy.org>
+
+       * scm/pdf.scm, pdftex.scm: pdftex updates
+
+       * scripts/ly2dvi.py: pdflatex support
+       
 2002-08-16  Jan Nieuwenhuizen  <janneke@gnu.org>
 
        * Documentation/windows/installing.texi: Include info from Wiki. 
index 40939ff3c74626bd2d330145b8daf48407c34e9c..2befc77fcfb7b378af37f56403882dcc5f10f8cc 100644 (file)
@@ -4121,7 +4121,7 @@ abbrev: @code{columns lines roman music bold italic named super sub}
 The markup is broken down and converted into a list of grob properties,
 which are prepended to the property list.  The @var{key}-@var{value}
 pair is a grob property. A list of properties available is included in
-the generated documentation for @rint{Text_interface}.
+the generated documentation for @internalsref{text-interface}.
 
 The following abbreviations are defined:
 @table @code
index 3a869f7e39ec6bed81d3b73c7a10ec884c998eee..61f79362afc015dcc6fc4d371d0ab4b981bedac2 100644 (file)
@@ -34,7 +34,7 @@ StaffContext=\translator {
        \consists "Forbid_line_break_engraver"
        \consistsend "Axis_group_engraver"
 
-       minimumverticalExtent = #'(-6 . 6)
+       minimumVerticalExtent = #'(-6 . 6)
        extraverticalExtent = ##f
        verticalExtent = ##f 
        localKeySignature = #'()
@@ -53,7 +53,7 @@ StaffContext=\translator {
 StaffContainerContext = \translator {
        \type Engraver_group_engraver
        \consists "Axis_group_engraver"
-       minimumverticalExtent = ##f
+       minimumVerticalExtent = ##f
        extraverticalExtent = ##f
        verticalExtent = ##f 
        localKeySignature = #'()
@@ -91,7 +91,7 @@ RhythmicStaffContext=\translator{
        \consists "Output_property_engraver"    
 
 
-       minimumverticalExtent = ##f
+       minimumVerticalExtent = ##f
        extraverticalExtent = ##f
        verticalExtent = ##f 
        localKeySignature = #'()
@@ -248,7 +248,7 @@ StaffGroupContext = \translator {
 LyricsVoiceContext= \translator{
        \type "Engraver_group_engraver"
        \consistsend "Axis_group_engraver"
-       minimumverticalExtent = #(cons -1.2 1.2)
+       minimumVerticalExtent = #(cons -1.2 1.2)
        extraverticalExtent = ##f
        verticalExtent = ##f 
        \name LyricsVoice 
@@ -266,7 +266,7 @@ NoteNamesContext = \translator {
        \name NoteNames
        \consistsend "Axis_group_engraver"
 
-       minimumverticalExtent = ##f
+       minimumVerticalExtent = ##f
        extraverticalExtent = ##f
        verticalExtent = ##f 
 
@@ -282,7 +282,7 @@ LyricsContext = \translator {
 
 
        \consistsend "Axis_group_engraver"
-       minimumverticalExtent = ##f
+       minimumVerticalExtent = ##f
        extraverticalExtent = ##f
        verticalExtent = ##f 
        
@@ -302,7 +302,7 @@ ChordNamesContext = \translator {
        \consists "Chord_name_engraver"
        \consists "Skip_req_swallow_translator"
        \consistsend "Axis_group_engraver"
-       minimumverticalExtent = ##f
+       minimumVerticalExtent = ##f
        extraverticalExtent = ##f
        verticalExtent = ##f 
 }
index 8c2f1722f7b439c8cc499342aa1713e814224714..62ee967d7a9eef91516097d776ad1219cdc42bbe 100644 (file)
 
 
 
-                                       ; simple commands to store and update currentpoint.  This makes the
-                                       ; other procedures simple rewrites of the PostScript code.
+; simple commands to store and update currentpoint.  This makes the
+; other procedures simple rewrites of the PostScript code.
+
 (define currentpoint (cons 0 0))
 (define (showcp) 
-  (string-append (ly-number->string (car currentpoint)) " " 
-                (ly-number->string (cdr currentpoint)) " "))
+  (string-append (control->string currentpoint) " "))
 (define (moveto x y)
   (set! currentpoint (cons x y))
   (string-append (showcp) "m "))
                 (ly-number->string (+ depth height))
                 " re f "))
 
-;; TODO:
-;;
-;;(define (dot x y diam)
-;;  (let (radius (/ diam 2))
-;;    (string-append (ly-number->string (x))
-;;                  (ly-number->string (y))
-;;                  (ly-number->string (radius))
-;;                  " ??? "))) ;; how to draw a circle in PDF?
-;;
-;;(define (roundfilledbox x y width height blotdiam)
-;;  (string-append " "
-;;    (dot x y blotdiam)
-;;    (dot (+ x width) y blotdiam)
-;;    (dot (+ x width) (+ y height) blotdiam)
-;;    (dot x (+ y height) blotdiam)
-;;    (filledbox (+ x (/ blotdiam 2)) (+ width (/ blotdiam 2)) y height)
-;;    (filledbox x width (+ y (/ blotdiam 2)) (+ height (/ blotdiam 2)))))
-;;
-;;
-;; WORKAROUND:
-;;
+(define (roundfilledbox breadth width depth height blotdiam)
+  (let* ((rad (/ blotdiam 2))
+        (h (- height rad))
+        (d (- depth rad))
+        (w (- width rad))
+        (b (- breadth rad)))
+    (string-append " 0 J "
+                  (setlinewidth blotdiam)
+                  "1 j "
+                  (moveto (- b) (- d))
+                  (rlineto (+ b w) 0)
+                  (rlineto 0 (+ d h))
+                  (rlineto (- (+ b w)) 0)
+                  (rlineto 0 (- (+ d h)))
+                  "b ")))
+
+;; PDF doesn't have the nifty arc operator.  This uses a fast
+;; approximation with two curves.  It bulges out a bit more than a
+;; true circle should along the 45 degree axes, but most users won't
+;; notice.
+(define (dot x y radius)
+  (string-append (moveto (- x radius) y)
+                (curveto (- x radius) (+ y (* 1.3333 radius))
+                         (+ x radius) (+ y (* 1.3333 radius))
+                         (+ x radius) y)
+                (curveto (+ x radius) (- y (* 1.3333 radius))
+                         (- x radius) (- y (* 1.3333 radius))
+                         (- x radius) y)
+                "f "))
+
+
 (define (roundfilledbox breadth width depth height blot) 
   (filledbox breadth width depth height))
-;;
 
 (define (font-def i s) "")
 
 
 (define (placebox x y s) "")
 
-;; TODO: bezier-ending, see ps.scm
 (define (bezier-bow l thick)
   (bezier-sandwich l thick))
 
                 (curveto-pairs (list-ref l 0)
                                (list-ref l 1)
                                (list-ref l 2))
-                "B "))
+                "B "
+                (bezier-ending (list-ref l 3) (list-ref l 0) (list-ref l 5))
+                (bezier-ending (list-ref l 7) (list-ref l 0) (list-ref l 5))))
+
+(define (bezier-ending z0 z1 z2)
+  (let ((x0 (car z0))
+       (y0 (cdr z0))
+       (x1 (car z1))
+       (y1 (cdr z1))
+       (x2 (car z2))
+       (y2 (cdr z2)))
+    (dot x0 y0 
+        (/ (sqrt (+ (* (- x1 x2) (- x1 x2)) 
+                    (* (- y1 y2) (- y1 y2)))) 2))))
+
 
 (define (start-system height) "")
 
 
 (define (text s) "")
 
+(define (draw-line thick fx fy tx ty)
+  (string-append (setlineparams)
+                (setlinewidth thick)
+                (moveto fx fy)
+                (lineto tx ty)
+                "S "))
 
 (define (unknown) "\n unknown\n")
 
-                                       ; Problem here -- we're using /F18 for the font, but we don't know
-                                       ; for sure that that will exist.
+; Problem here -- we're using /F18 for the font, but we don't know 
+; for sure that that will exist.
+
 (define (ez-ball ch letter-col ball-col)
   (let ((origin (cons 0.45 0)))
     (string-append (setgray 0)
index 3d38d7a45e215d387ec05dcd7a9e809c0d3cf7e5..a3bd441da5878a6ed5eb835e20c117609dcda358 100644 (file)
 (define (ez-ball c l b)
   (embedded-pdf (list 'ez-ball  c  l b)))
 
-
+(define (header-to-file fn key val)
+  (set! key (symbol->string key))
+  (if (not (equal? "-" fn))
+      (set! fn (string-append fn "." key))
+      )
+  (display
+   (format "writing header field `~a' to `~a'..."
+          key
+          (if (equal? "-" fn) "<stdout>" fn)
+          )
+   (current-error-port))
+  (if (equal? fn "-")
+      (display val)
+      (display val (open-file fn "w"))
+      )
+  (display "\n" (current-error-port))
+  ""
+  )
 
 (if (or (equal? (minor-version) "4.1")
        (equal? (minor-version) "4")
 
 (define (header-end)
   (string-append
-   "\\input lilyponddefs\\newdimen\\outputscale \\outputscale=\\lilypondpaperoutputscale pt"
+   "\\def\\lilyoutputscalefactor{"
+   (number->string (cond
+                   ((equal? (ly-unit) "mm") (/ 72.0  25.4))
+                   ((equal? (ly-unit) "pt") (/ 72.0  72.27))
+                   (else (error "unknown unit" (ly-unit)))
+                   ))
+   "}\n"
+   "\\input lilyponddefs \\outputscale=\\lilypondpaperoutputscale \\lilypondpaperunit"
    "\\turnOnPostScript"
    "\\pdfcompresslevel=0"))
 
 (define (placebox x y s) 
   (string-append 
    "\\placebox{"
-   (number->dim y) "}{" (number->dim x) "}{" s "}\n"))
+   (number->dim y) "}{" (number->dim x) "}{" s "}%\n"))
 
 (define (bezier-bow l thick)
   (embedded-pdf (list 'bezier-bow  `(quote ,l) thick)))
 (define (text s)
   (string-append "\\hbox{" (output-tex-string s) "}"))
 
+(define (draw-line thick fx fy tx ty)
+  (embedded-pdf (list 'draw-line thick fx fy tx ty)))
 
 (define (define-origin file line col)
   (if (procedure? point-and-click)
index d6858579cc0688128f72597fd241436177716e55..5b016b2d5ef4f303c18fb2531027c834fb30f947 100644 (file)
@@ -323,6 +323,9 @@ verbose_p = 0
 preview_p = 0
 preview_resolution = 90
 pseudo_filter_p = 0
+latex_cmd = 'latex'
+tex_extension = '.tex'
+pdftex_p = 0
 
 help_summary = _ ("Generate .dvi with LaTeX for LilyPond")
 
@@ -344,6 +347,7 @@ option_definitions = [
        ('', 'V', 'verbose', _ ("verbose")),
        ('', 'v', 'version', _ ("print version number")),
        ('', 'w', 'warranty', _ ("show warranty and copyright")),
+       ('', '', 'pdftex', _("Use pdflatex to generate a PDF output")),
        ]
 
 layout_fields = ['dedication', 'title', 'subtitle', 'subsubtitle',
@@ -468,7 +472,10 @@ def run_lilypond (files, dep_prefix):
                                                      fields))
        else:
                opts = opts + ' --no-paper'
-               
+
+       if pdftex_p:
+               opts = opts + ' -f pdftex'              
+
        if track_dependencies_p:
                opts = opts + " --dependencies"
                if dep_prefix:
@@ -506,7 +513,7 @@ def analyse_lilypond_output (filename, extra):
        # urg
        '''Grep FILENAME for interesting stuff, and
        put relevant info into EXTRA.'''
-       filename = filename+'.tex'
+       filename = filename+tex_extension
        progress (_ ("Analyzing %s...") % filename)
        s = open (filename).read ()
 
@@ -535,7 +542,7 @@ def find_tex_files_for_base (base, extra):
                if os.path.exists (base + '.' + f):
                        extra[f].append (open (base + '.' + f).read ())
        
-       return (base  +'.tex',headerfiles)
+       return (base+tex_extension,headerfiles)
         
 
 def find_tex_files (files, extra):
@@ -554,7 +561,7 @@ def find_tex_files (files, extra):
                        if x:
                                fname = fname + '-%d' % x
 
-                       if os.path.exists (fname + '.tex'):
+                       if os.path.exists (fname + tex_extension):
                                tfiles.append (find_tex_files_for_base (fname, extra))
                                analyse_lilypond_output (fname, extra)
                        else:
@@ -697,7 +704,7 @@ None
        f.write (s)
        f.close ()
 
-       cmd = 'latex \\\\nonstopmode \\\\input %s' % latex_fn
+       cmd = latex_cmd + ' \\\\nonstopmode \\\\input %s' % latex_fn
        status = quiet_system (cmd, 'LaTeX', ignore_error = 1)
 
        signal = 0xf & status
@@ -729,8 +736,8 @@ The error log is as follows:
 ''' % (global_latex_preamble (extra), outbase))
 
                f.close()
-               cmd = 'latex \\\\nonstopmode \\\\input %s' % preview_fn
-               quiet_system (cmd, "LaTeX for preview")
+               cmd = '%s \\\\nonstopmode \\\\input %s' % (latex_cmd, preview_fn)
+               quiet_system (cmd, '%s for preview' % latex_cmd)
        
 
 def run_dvips (outbase, extra):
@@ -902,6 +909,12 @@ for opt in options:
        elif o == '--version' or o == '-v':
                identify ()
                sys.exit (0)
+       elif o == '--pdftex':
+               latex_cmd = 'pdflatex'
+               targets.remove('DVI')
+               targets.append('PDFTEX')
+               pdftex_p = 1
+               tex_extension = '.pdftex'
        elif o == '--warranty' or o == '-w':
                status = system ('lilypond -w', ignore_error = 1)
                if status:
@@ -953,7 +966,7 @@ if files:
        else:
                (outdir, outbase) = os.path.split (abspath (output_name))
 
-       for i in ('.dvi', '.latex', '.ly', '.ps', '.tex'):
+       for i in ('.dvi', '.latex', '.ly', '.ps', '.tex', '.pdftex'):
                output_name = strip_extension (output_name, i)
                outbase = strip_extension (outbase, i)
 
@@ -1028,7 +1041,28 @@ if files:
 
        if 'PNG' in  targets:
                make_preview (outbase, extra_init)
-               
+
+       if 'PDFTEX' in targets:
+               try:
+                       run_latex (files, outbase, extra_init)
+                       # unless: add --tex, or --latex?
+                       targets.remove ('TEX')
+                       targets.remove ('LATEX')
+                       targets.remove ('PDFTEX')
+                       if 'PDF' not in targets:
+                               targets.append('PDF')
+               except:
+                       # TODO: friendly message about TeX/LaTeX setup,
+                       # trying to run tex/latex by hand
+                       if 'PDFTEX' in targets:
+                               targets.remove ('PDFTEX')
+                       if 'PDF' in targets:
+                               targets.remove ('PDF')
+                       if 'PS' in targets:
+                               targets.remove ('PS')
+                       traceback.print_exc ()
+                       sys.exit(1)
+
        # add DEP to targets?
        if track_dependencies_p:
                depfile = os.path.join (outdir, outbase + '.dep')
index 67c8a88f1d0d8961bda1185f0fee82570503f0bf..69cacb71a6cd259b53cc1855720e9e704b4db198 100644 (file)
@@ -6,7 +6,9 @@
         % by executing a 0 0 moveto
         \def\embeddedpdf##1{%
                 \pdfliteral{q \lilypondpaperoutputscale\lilySpace 0 0 %
-                        \lilypondpaperoutputscale\lilySpace 0 0 cm%
+                        \lilypondpaperoutputscale\lilySpace 0 0 cm %
+                       \lilyoutputscalefactor\lilySpace 0 0 %
+                       \lilyoutputscalefactor\lilySpace 0 0 cm %
                         ##1 Q}%
         }
 }