Hello,
I am writing a macro which finds texts in certain fonts, and replace
them with certain character, or insert just after each of the found
text some string (depending on the found text), in both case in some
defined font.
I could write the first part of the macro, that is: find the texts in
certain fonts, and prepare the replace texts. I have an array
variable of text ranges objects of the found texts, and an array
variable with the texts that will replace (or to be inserted just
after...) the found texts.
Now, I have to write the last part of the macro, and I don't know how
to do that.
I think I have to use some "foreach" loop:
ForEach $range in reversed $ranges
...
and
text.replaceInRange $range, $prepared_text
or
text.insertAtIndex $range.bound, $prepared_text
But how should I apply the wanted font to the replacing text or text
to be inserted?
Perhaps should I first select the range of the text to be replaced
(or the $range.bound where the new text will be inserted), apply the
font by the menu command, and replace the text or insert the text?
In that case, will something like the following be necessary?
$selection = TextSelection.new ($doc.text, $range)
$doc.setSelection ($selection)
Set Font Name 'Hiragino Mincho Pro'
But isn't it very slow...?
Or is there any other way? I wonder if it is not possible to use the
style object ".apply" command, but I don't understand how to use it...
I think this question is to Kino...
Thank you very much in advance for your answer.
Best regard,
Nobumi Iyanaga
Tokyo,
Japan
|