]> git.donarmstrong.com Git - lilypond.git/commitdiff
MusicXML: Convert some more text markup attributes
authorReinhold Kainhofer <reinhold@kainhofer.com>
Sun, 21 Oct 2007 21:08:47 +0000 (23:08 +0200)
committerReinhold Kainhofer <reinhold@kainhofer.com>
Sun, 21 Oct 2007 21:08:47 +0000 (23:08 +0200)
Convert italics, better font sizes. Unfortunately, I don't know
how to convert RGB colors to x-colors used by lilypond, so colors
are not converted. Similarly, font families are not converted, mainly
because I don'tknow the correct lilypond expression for this.
Underline, overline and strike-through don't seem to be supported
by lilypond at all :-(

scripts/musicxml2ly.py

index b97e1565244ea53687caeb0b1d2ab85629afba24..47501b1766bd0192cb80b924015718761ad38c27 100644 (file)
@@ -625,6 +625,7 @@ def musicxml_words_to_lily_event (words):
     text = words.get_text ()
     text = re.sub ('^ *\n? *', '', text)
     text = re.sub (' *\n? *$', '', text)
+    event.text = text
 
     if hasattr (words, 'default-y'):
         if getattr (words, 'default-y') > 0:
@@ -637,13 +638,36 @@ def musicxml_words_to_lily_event (words):
         if font_weight:
             event.markup += font_weight
     if hasattr (words, 'font-size'):
-        font_size = { "xx-small": '\\smaller\\smaller\\smaller', "x-small": '\\smaller\\smaller', "small": '\\smaller', "medium": '', "large": '\\large', "x-large": '\\large\\large', "xx-large": '\\large\\large\\large' }.get (getattr (words, 'font-size'), '')
+        size = getattr (words, 'font-size')
+        font_size = {
+            "xx-small": '\\teeny',
+            "x-small": '\\tiny',
+            "small": '\\small',
+            "medium": '',
+            "large": '\\large',
+            "x-large": '\\huge',
+            "xx-large": '\\bigger\\huge'
+        }.get (size, '')
         if font_size:
             event.markup += font_size
-    #TODO: Convert the other attributes defined in %text-formatting in common.mod:
-    # color, font-family
+    #if hasattr (words, 'color'):
+    #    color = getattr (words, 'color')
+    #    # TODO: In MusicXML, colors are represented as ARGB colors, in lilypond
+    #    #       as x-color. How can I convert from RGB to x-color???
+    #    font_color = {
+    #      #
+    #    }
+    if hasattr (words, 'font-style'):
+        font_style = { "italic": '\\italic' }.get (getattr (words, 'font-style'),'')
+        if font_style:
+            event.markup += font_style
+
+    # TODO: How should I best convert the font-family attribute?
+
+    # TODO: How can I represent the underline, overline and line-through
+    #       attributes in Lilypond? Values of these attributes indicate
+    #       the number of lines
 
-    event.text = text #re.replace (text, "^ *\n? *(.*) *\n? *", "\1")
     return event