Skip to main content
Topic: XText.hmm (0.92) (Read 11981 times) previous topic - next topic

XText.hmm (0.92)

This is the plugin everyone has needed for a long time! ;)  Seriously, I wonder how I survived without this simple object that simply concatenates texts of different fonts. Here is a real world example:

<Image Link>

The plugin allows the concatenation of up to six texts. Additionally, the justification of the text can be selected. With justifications 'Left' and 'Right', there is a corresponding 'preserve width' option which is triggered by selecting 'Left and wide' or 'Right and wide'. For the non-wide justifications, there are boxed variants which draw a box around the text (if the box is too high, try to set a pinch value on StaffSymbols texts to reduce its height).

Multiline texts are supported: Just insert %br% or | (a vertical bar) in a text to indicate a line break. For some fonts, the line sizes get too large - try to increase the "pinch" value to reduce the size of such lines.

With the StaffSymbols or StaffCueSymbols fonts, a number of abbreviations are useful - they are replaced with the corresponding staff character:
  • dynamics: %ppp%, %pp%, %p%, %mp%, %mf%, %f%, %ff%, %fff%
  • notes: %1/2%, %1/4%, %1/8%, %breve%
  • clefs: %gclef%, %fclef%, %cclef%
  • accidentals: %sharp% or %#%, %natural% or %=%, %flat% or %b%, %##% or %x%, %bb%
  • rests: %rbreve%, %r/1%, %r/2%, %r/4%, %r/8%, %r/16%, %r/32%, %r/64%
  • others: %turn%, %tr%, %coda%, %segno%, %|% or %bar%

It is also possible to specify characters via decimal or hexadecimal codes:
  • decimal codes: e.g. %177%
  • hexadecimal codes: e.g. %0xf123%

Then, one can specify an arbitrary font installed in Windows for each segment by putting it between % and :% at the very beginning (in that case, the selected font class is ignored). This is helpful e.g. to use symbols like arrows from the WingDings fonts - and it does not use up one of the six NWC User font classes. See XTextExamples.nwctxt for examples (they need WingDings and WingDings 3 to be installed).

For "negative kerning" (moving the following text to the left), use %---...%. Each minus sign represents a little more than a quarter of a "left-moving" blank. This is useful to create e.g. an "fp" symbol, which can be done with the StaffSymbols text segment %f%%--%%p% (see XText_fp_sffffz_Examples.nwctxt).

Lst, it is possible to "jump back" to the start of a previous text with %-1%, %-2%, ..., or %-6%. This is useful to place text pieces above each other, e.g. for the numbers needed for figured bass or for piano fingering.

The name of the plugin, XText, allows quick selection via keyboard by pressing J X <down> <enter>. The X can be read as "extended" or simply as a reference (and reverence) to NWC's native texts, which are created from the keyboard with a simple X.

As special examples, I have added a score of two measures from Rachmaninov's Prelude in C sharp which is used in the German Wikipedia as a comparison example for score editors (however, the NWC output could not be added there, as only native features may be used, which excludes the "sffff" XText); and an excerpt from Diether de la Motte's "Harmonielehre", which explains the harmonic functions of the final six measures of Bach's famous Air in D. Of course, one can also write degree symbols using similar parameters.

H.M.

Re: XText.hmm (0.1)

Reply #1
0.2 has the link to the forum corrected.

H.M.

Re: XText.hmm (0.2)

Reply #2
Ooh, nice.  Thank you  8)

If I may suggest a variant, or perhaps an extention:  I often find myself needing to create a (Centre, Left or Right) justified, multi-line block of text, that can also need different fonts, sometimes within a line.

This plugin allows for the different fonts within a line, can you also add multi-line functionality?  Or should that be a separate plugin?
I plays 'Bones, crumpets, coronets, floosgals, youfonymums 'n tubies.

Re: XText.hmm (0.2)

Reply #3
I'll work on it - it's a pure algorithmic problem, i.e., what I like most about programming!

But it will take a day or two, as I have to play organ at three occasions this weekend (a wedding and two confirmations at our church), and that Bach does not yet really work = I need some more practice time today ...; oh, and I have to transpose three scores one  or two semitones up or down for our choir - NWC does it in a snap, but at one place this requires rewriting a recitative, as our solo tenor cannot go even higher ...

H.M.

Re: XText.hmm (0.3)

Reply #4
Version 0.3 now has multiline support.

It also has a properties dialog that looks like the control panel for a medium-sized nuclear reactor. I hope that people aren't put off by it, but I did not see any other way to get the necessary information.

And, it may be that the size computations are too simplistic - I did not try to learn what "descent" means, and how it should be used in computing the text layout.

Still, happy texting - and feel free to comment on my attempt (but I'd rather go back to the Envelope plugin, which is, as I see it, more satisfying from a musical perspective).

H.M.

P.S. And yes, the Bach is ok now (I'll see whether the couple likes it tomorrow), and the scores are transposed, and the recitative rewritten ... :)

Re: XText.hmm (0.3)

Reply #5
0.4 has separators between the properties - the nuclear reactor looks a little tamer now ...

H.M.

Re: XText.hmm (0.4)

Reply #6
Awesome, thank you good sir :)
I plays 'Bones, crumpets, coronets, floosgals, youfonymums 'n tubies.

Re: XText.hmm (0.5)

Reply #7
You're welcome.

In 0.5, I have added a justification 'Left and wide' to get left-justification and "preserve width" behavior. However, this shows that with multiline support, there is now an overlapping, or unclear, or muddled semantics for justifications: The "left" and "right" are used for both "justification relative to left side of text block" and "justification relative to plugin position". Therefore, the "left and wide" justification is actually a "right" justification with respect to the plugin's loction. But I'm not going to "correct" this (by introducing two independent "justifications"), mainly because the plugin right now needs all 32 possible properties; but also as there are already enough possibilities to format the text, I think - the workaround for other layouts is, as before, to use standard texts and placing them as needed.

H.M.

Re: XText.hmm (0.5)

Reply #8
Thanks for this wonderful Plugin!

If I may, I have a suggestion for a little extension: I often have had some trouble to place "commented" dynamics in a score, like for example "p dolce" or "sempre f". I could imagine to have the option to choose "Dynamic" instead of text in your object. This would be very helpful to insert special dynamics like the ones I mentioned above...

What do you think?  :) 

 

Re: XText.hmm (0.5)

Reply #9
Hi jfb,
you could pretty much do that now with the plugin in its current form.  Just change the font selection between the text and the dynamic so that you use the dynamic marking from the notation font (NWC2STDA or alternative).

For the real dynamic, just make it hidden.
I plays 'Bones, crumpets, coronets, floosgals, youfonymums 'n tubies.

Re: XText.hmm (0.5)

Reply #10
As Lawrie points out, the dynamic signs are in the StaffSymbols font, so you could just find them there ...

... however, in version 0.6 I have added a number of abbreviations for quite a few characters from that font: Just select font StaffSymbols, and then use e.g. %ppp% or %f% or %cclef% or %#% etc. For all symbols, look into the help text. If you want some more symbols added, just tell me (including the abbreviation name you think is helpful).

XTextExamples.nwctxt (attached to the primary posting) contains some examples for this, e.g. the "sempre pp" xtext.


A technical remark and question: The code simply replaces the abbreviations with single letters, as defined in a table with entries like
Code: [Select · Download]
  ['%1/8%']     = 'H',
  ['%ppp%']     = 'P',
Thus, for %ppp%, the character P is substituted, which has hex code 0x50. However, when I look into the CharMap of the standard StaffSymbols font NWC2STDA, the ppp symbol has character code 0xf050. Yet, my code works ... but I am not really sure why; and whether there might be circumstances when it does not work. Could someone tell me what's going on here? - thanks!

H.M.

Re: XText.hmm (0.6)

Reply #11
Hello @hmmueller,

A question/suggestion for you: I notice in your code you have a function named replaceAll(text, k, v) where you are doing string.find() and string.sub() within a loop. Did you consider using the Lua string.gsub() function? I think it should work well for what you are doing.

Thanks,
Mike

Re: XText.hmm (0.6)

Reply #12
Ha - you got me! ... yes, I considered it for a second, but I have not yet "interned" (in my mind) the Lua patterns (too much experience with the "big" regexps of C# etc.), so I am a little too cautious there. But right after uploading the script, I thought that the following much simpler code should work:
Code: [Select · Download]
  ['%%1/8%%']     = 'H',
  ['%%ppp%%']     = 'P',
...
    for k, v in pairs(replacements) do
      text = string.gsub(text, k, v)
    end
If you read this - do you have any complaints? - if not, I'll simply replace 0.6 (no functional change).

... I just did it :)

H.M.

Re: XText.hmm (0.6)

Reply #13
That was pretty much the way I figured it would change. Your plugin is now shorter AND faster.

No complaints from me :)

Mike

Edit: Oops, maybe not "shorter" since you had to double up the % because of string.gsub... but still should be faster.

Re: XText.hmm (0.7)

Reply #14
Another update (I think it's the last one): I added explicit negative kerning, i.e., the possibility to move a piece of text to the left. A simple example is the composition of an "fp" dynamic signature from the existing f and p dynamics, which can be done with the StaffSymbols text segment %f%%---%%p%.

The attachments of the primary posting show some more example usages.

The addition of this feature required a complete rewrite of the internal logic, so I may have introduced new bugs - if you find any, let me know!

H.M.

Re: XText.hmm (0.8)

Reply #15
Version 0.8 allows the specification of arbitrary characters with decimal code (%...%) or hexadecimal code (%0x...%).

H.M.

Re: XText.hmm (0.9)

Reply #16
Version 0.9 allows the specification of arbitrary Windows fonts in an segment. I think this should be very useful for the small arrows sometimes needed when voices are split or come together ("Behind Bars" shows an example on p.468; I see them often in John Rutter scores).

H.M.

Re: XText.hmm (0.9)

Reply #17
I added another example (DeLaMotte_BachAirD_m13-18_Harmonielehre_p125.nwc) to the intial posting for using XText : Adding functional symbols to a score. The example is from Diether de la Motte's "Harmonielehre" and explains the harmonic functions of the final six measures of Bach's famous Air in D. Of course, one can also write degree symbols using similar parameters.

H.M.

Re: XText.hmm (0.91)

Reply #18
In a typical example of feature creep, I have uploaded version 0.91, which allows "jumping back" to the beginning of a segment. This helps with texts that should be exactly above each other, as in the 6 and 4 of chord symbols, or maybe for piano fingering. Unfortunately, the new version 0.91 is not compatible with the previous versions with respect to the %---...% negative kerning: The size of a single minus has changed a little bit - sorry to those of you who already used this feature: Please check that the location of left-shifted text pieces is still ok ...

H.M.

Re: XText.hmm (0.92)

Reply #19
Version 0.92 adds simple boxes around texts if one of the "... (boxed)" justifications is selected.

There is no way to select margins, line thickness, corner rounding or the like for the box. The reason (which I have explained somewhere else already) is that XText needs all 32 possible parameters right now: 5 parameters for each of the 6 texts, and two for justification and line spread. So I cannot introduce any new parameters.

One could implement a Box object which looks at the next object and boxes it; where the next object could be a standard text, or an XText, or maybe one of some other supported type of item: That way, one could add versatile box controls only once ...

H.M.

 

Re: XText.hmm (0.92)

Reply #20
Thanks. I’m giving it a try!