1

I've been trying to add and remove certain pieces of text based on their font and whenever I need to add a certain piece of text back into it's original place again I need to insert a superscript 2 after this text.

This is the piece of code in which I add the text back in again:

 if (textGroupItem.textRange.characterAttributes.textFont.toString().toLowerCase().match(regPattern)){

            textGroupItem.textRange.characters.removeAll()

            textGroupItem.textRange.characters.add(un + " - " + sm + "m" + "²")

}

This doens't give a superscript 2 but some kind of broken token as text.

So far i've also tried:

  • translatePlaceholderText("c2b2")

  • "2".sup()

  • <sup> 2</sup>

  • textGroupItem.textRange.characterAttributes.baselineShift = height; <-- height = 2 but this shifts the whole text item

How can you succesfully add a supercript 2 to a group of characters?

  • With "some kind of broken token" you must mean `²`, the [UTF8 representation of `²`](http://www.fileformat.info/info/unicode/char/b2/index.htm), right? There are some unresolved variables in your script snippet – can you rewrite it so we have a standalone version that is able to run for testing? – Jongware Mar 26 '18 at 08:44
  • Stupid question: is there a superscript 2 in the original text? If yes, is it actually `²` or a regular `2` with superscript applied to it? Could you use such a `2` or must you have the `²` – cybernetic.nomad Mar 28 '18 at 00:20

0 Answers0