Text measurement and SVG

In my spare time I’m working on long-needed program for engraving Gregorian chant. (“Engraving” is to music what “typesetting” is for text.) Below are the requirements I’ve been designing around:

My current plan is to write the app in JS, provide output in SVG, and deploy over the web. I have a mockup/prototype of the SVG I’d like to produce:

Gregorian chant in SVG. Your browser doesn’t support SVG; please Get Firefox!

There is one major hurdle I haven’t figured out yet: I don’t know how to position the text. The positioning of Gregorian chant is very precise: the first neume (note) of each syllable is placed over the center of the vowel of the syllable. In addition, the spacing of neumes is arranged so that there are precise amounts of whitespace between each element and syllable, and hyphens between syllables are lengthened or shortened as necessary to fit. What is the best way to give a web application precise text measurement of individual letters within a syllable (including any kerning and ligatures)?

Ideally I’d like a way to do this with the user’s own fonts, but if I need to preprocess a font file to get metrics out of it, I guess that’s ok too.

Dear lazyweb, can somebody verify that Adobe InDesign/Quark/your favorite DTP program imports my sample SVG file correctly and usably? I don’t have a copy at the moment, and it’s rather expensive just for an import test…

Atom Feed for Comments 11 Responses to “Text measurement and SVG”

  1. Albert Says:

    I can verify that your SVG loads correctly in Illustrator CS3 – I don’t have InDesign, but it’s a good guess that it would use the same lib.

  2. Robert O'Callahan Says:

    Does this help?


  3. Anonymous Says:

    Have you tried lilypond? It outputs svg and supports gregorian chant.

  4. Benjamin Smedberg Says:

    roc, yes, that might help indeed.

    Anonymous, lilypond chant lyrics are not aligned correctly and the markup is tedious to author. I could probably jump into lilypond and try to fix it, but I think it would be simpler to write a domain-specific program (and you wouldn’t have to install anything)!

  5. Toe Says:

    I can verify that your sample image does *not* display correctly when this posting is viewed through Planet Mozilla. :)

  6. Matthew Zimmerman Says:

    Hey Ben! It looks good in Inkscape 0.45.1. I guess I should say that it looks the same as it does in Firefox 2.
    We have InDesign CS3 on another computer in the lab– I can check it later if you want. However, the version
    in the syndication feed got screwed up for me too. I’m using Google Reader in Firefox.

    So I’m guessing the choir you’re directing is going to be doing some chanting?

    (Say hi to Suz, Micah and the girls for me!)

  7. Fr Chris Says:

    I have used OpusTeX in the past and found it decent and workable, although I’ve had some folks complain about the ugliness of the fonts. (I think they meant Computer Modern Roman for the text, not the neumes themselves.)

    Anyhow, just wanted to say I’m glad someone is working on this. OpusTeX is not quite ideal, especially for those who don’t know TeX, and sadly Lilypond doesn’t do chant well at all.

  8. Rick Says:

    I’m one of the authors of SVG.

    What you want for precise text placement is SVG fonts. In fact you probably want to use them for the symbols as well.

    Problem is that none of the free-browser SVG viewers support that feature yet.

    Batik supports SVG fonts, as does Adobes IE plugin. Expect browsers to support it soon enough, I mean, when you have paths, and you have text semantics, you have all the code you need to support SVG fonts.

  9. Benjamin Smedberg Says:

    How do SVG fonts help? I mostly know what fonts (type 1) I want… what I didn’t know is the precise kerning information for that font… but the SVG text measurement API does what I need… I’ll have some prototype code up shortly.

  10. Bro. Matthew Spencer, OSJ Says:

    I’ve been working on a desktop app for notating chant for some time now. After developing a font (Caeciliae) for quality chant notation, I just found that the actually layout gets really tedious with fonts. Changing margins or texts sizes alone requires re-layout of a whole piece. I explored lilypond for some time, but it’s architecture is just not ideal for chant notation.

    The position of neumes relative to their texts is certainly one of the trickier problems: accurate text measurements are essential, but then there is automatic joining of syllables (dropping the hyphenations when text elements allow), checking for dipthongs (luckily syllabification of Latin is pretty easy), etc. Throw in the fact that chant can have multiple text tracks per neume (for example, for hymns), and layout just gets even more complex.

    A web solution would be great, so I hope you continue. I’m currently writing in C# and hoping to target multi-platforms through the Mono project.

  11. Richard Chonak Says:

    Here’s a bump to an old thread! I like your idea of generating SVG.

    The TeX-based software ‘Gregorio’ (http://home.gna.org/gregorio) does the alignment of neumes to vowels pretty well, so you may be able to find some solutions to that issue by examining their code.

    For what it’s worth, I recently launched a web interface so that users can produce simple gregorio output without installing the software (or LaTeX) locally: see http://gregorio.gabrielmass.com .

Leave a Reply