patch for properly scaled fractions

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

patch for properly scaled fractions

Werner LEMBERG

I suggest the patch at the end of this email to get properly scaled
fractions.  The two images demonstrate this, using the input below.
Note that the correct command to position the plus sign is
\translate-scaled; this is something which should probably be added to
the documentation.

However, it's still not perfect yet: For smaller sizes, the whitespace
surrounding the plus sign is too large since it isn't scaled.  I
consider this as, well, a bad feature, and I suggest to change it too.


    Werner


======================================================================


\version "2.11.0"

\header { texidoc = "
" }

meter =
  #(define-music-function (parser location size) (number?) #{
    R1^\markup { \fontsize #$size { \fraction \number "1" \number "4"
                                    \lower #.5 \number "+"
                                    \fraction \number "10" \number "8" } } #})

meterscaled =
  #(define-music-function (parser location size) (number?) #{
    R1^\markup { \fontsize #$size { \fraction \number "1" \number "4"
                                    \translate-scaled #'(0 . -.5) \number "+"
                                    \fraction \number "10" \number "8" } } #})


{
  \meter #-8.0 | \meter #-6.0 | \meter #-4.0 |
    \meter #-2.0 | \meter #0.0 |
  \break
  \meterscaled #-8.0 | \meterscaled #-6.0 | \meterscaled #-4.0 |
    \meterscaled #-2.0 | \meterscaled #0.0 |
}

\paper {
  ragged-right = ##t
}

% EOF


======================================================================


--- define-markup-commands.scm.old 2006-11-27 22:15:07.000000000 +0100
+++ define-markup-commands.scm 2006-11-28 15:28:17.000000000 +0100
@@ -1339,21 +1339,26 @@
 (define-markup-command (fraction layout props arg1 arg2) (markup? markup?)
   "Make a fraction of two markups."
   (let* ((m1 (interpret-markup layout props arg1))
-         (m2 (interpret-markup layout props arg2)))
+         (m2 (interpret-markup layout props arg2))
+         (factor (magstep (chain-assoc-get 'font-size props 0)))
+         (boxdimen (cons (* factor -0.05) (* factor 0.05)))
+         (padding (* factor 0.2))
+         (baseline (* factor 0.6))
+         (offset (* factor 0.75)))
     (set! m1 (ly:stencil-aligned-to m1 X CENTER))
     (set! m2 (ly:stencil-aligned-to m2 X CENTER))
     (let* ((x1 (ly:stencil-extent m1 X))
            (x2 (ly:stencil-extent m2 X))
-           (line (ly:round-filled-box (interval-union x1 x2) '(-0.05 . 0.05) 0.0))
+           (line (ly:round-filled-box (interval-union x1 x2) boxdimen 0.0))
            ;; should stack mols separately, to maintain LINE on baseline
-           (stack (stack-lines -1 0.2 0.6 (list m1 line m2))))
+           (stack (stack-lines DOWN padding baseline (list m1 line m2))))
       (set! stack
     (ly:stencil-aligned-to stack Y CENTER))
       (set! stack
     (ly:stencil-aligned-to stack X LEFT))
       ;; should have EX dimension
       ;; empirical anyway
-      (ly:stencil-translate-axis stack 0.75 Y))))
+      (ly:stencil-translate-axis stack offset Y))))

_______________________________________________
lilypond-devel mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/lilypond-devel

script-scaling.old.png (16K) Download Attachment
script-scaling.new.png (16K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: patch for properly scaled fractions

Werner LEMBERG
> Note that the correct command to position the plus sign is
> \translate-scaled; this is something which should probably be added
> to the documentation.
>
> However, it's still not perfect yet: For smaller sizes, the
> whitespace surrounding the plus sign is too large since it isn't
> scaled.  I consider this as, well, a bad feature, and I suggest to
> change it too.

After some thinking I wonder whether *all* commands which move objects
should obey the font size.  For example, consider a small \score
within a \markup -- in such cases it would be natural to use the
small score's size values.


    Werner


_______________________________________________
lilypond-devel mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|

Re: patch for properly scaled fractions

Han-Wen Nienhuys-2
Werner LEMBERG escreveu:

>> Note that the correct command to position the plus sign is
>> \translate-scaled; this is something which should probably be added
>> to the documentation.
>>
>> However, it's still not perfect yet: For smaller sizes, the
>> whitespace surrounding the plus sign is too large since it isn't
>> scaled.  I consider this as, well, a bad feature, and I suggest to
>> change it too.
>
> After some thinking I wonder whether *all* commands which move objects
> should obey the font size.  For example, consider a small \score
> within a \markup -- in such cases it would be natural to use the
> small score's size values.

If you want to create a smaller score, you should tone the staff size
down from the \layout block. This will scale down everything, including markups.
(at least, so it should)

--

Han-Wen Nienhuys - [hidden email] - http://www.xs4all.nl/~hanwen

LilyPond Software Design
 -- Code for Music Notation
http://www.lilypond-design.com



_______________________________________________
lilypond-devel mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|

Re: patch for properly scaled fractions

Han-Wen Nienhuys-2
In reply to this post by Werner LEMBERG
Werner LEMBERG escreveu:
> I suggest the patch at the end of this email to get properly scaled
> fractions.  The two images demonstrate this, using the input below.
> Note that the correct command to position the plus sign is
> \translate-scaled; this is something which should probably be added to
> the documentation.

Please apply.


> However, it's still not perfect yet: For smaller sizes, the whitespace
> surrounding the plus sign is too large since it isn't scaled.  I
> consider this as, well, a bad feature, and I suggest to change it too.

Yes, the word-space in line and justified paragraph composition should be
scaled by the font-size.


--

Han-Wen Nienhuys - [hidden email] - http://www.xs4all.nl/~hanwen

LilyPond Software Design
 -- Code for Music Notation
http://www.lilypond-design.com



_______________________________________________
lilypond-devel mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|

Re: patch for properly scaled fractions

Werner LEMBERG

> > I suggest the patch at the end of this email to get properly
> > scaled fractions.  The two images demonstrate this, using the
> > input below.  Note that the correct command to position the plus
> > sign is \translate-scaled; this is something which should probably
> > be added to the documentation.
>
> Please apply.

Done.


    Werner


_______________________________________________
lilypond-devel mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/lilypond-devel