Hello Philip,

That is a generous offer. The issue here is that the font is irregular because it uses elements that are not available in ordinary Arabic fonts, which are peculiar to the Warsh variant reading of the Qur’an. 

Otherwise, for aesthetic reasons I would prefer to do what you suggest. My font of choice at the moment is Amiri, and I have corresponded with the designer, who also has a variant adapted for the more common Qur’anic reading. He has shown himself interested and willing to adapt his font for our needs, but on a rather longer timescale than we had hoped for.

I will let you know how that proceeds. Thank you again for your generous help.

Regards,


Abdassamad

On 29 Jul 2016, at 11:25, spaelti <[log in to unmask]> wrote:

Hello Abdassamad,
I’m glad to hear that my macro worked. (For those wondering what the problem was: the text was apparently written not in proper Arabic encoded text, but rather using a non-standard font which uses characters in the Private Use Area [0F20-0FFF])

However I am wondering, why don’t you convert your text to proper Arabic and use a proper Arabic font instead? If you are interested in doing this—this could be done with a macro fairly easily--and are not clear how to do this, let me know.

best
Philip


On Jul 29, 2016, at 19:05 , Abdassamad Clarke <[log in to unmask]> wrote:

Dear all,

Thank you to everyone who helped with this issue, particularly Philip Spaelti whose last macro brought an almost complete resolution, except that the text, which displays correctly from right to left, now starts from the bottom of the page. However, I then encountered a further obstacle, which may prove insurmountable: the font, which is a hugely modified one with large numbers of extra characters in it, does not display in InDesign at all. 

I will endeavour to see if there are any InDesign aficionados who are as generous with their time and advice as you have been.

Again, thank you for your time and effort.

Warm regards,


Abdassamad Clarke 

On 27 Jul 2016, at 19:36, spaelti <[log in to unmask]> wrote:

Hello Abdassamad
that is of course not a helpful result, because it may simply mean that the find expression didn’t find anything, and therefore that it did nothing. I’ll send you a second version of the macro, which will end with a report. The new macro should end with a report like this:

Statistics:
Total Stretches found: xxx
Total words reversed: yyy

If the xxx and yyy are ‘0’ then you will know that the macro doesn’t find anything. This will probably mean (as Knut suggests) that either the spaces are not “spaces” or that there are intervening gremlins everywhere.

Philip



On Jul 27, 2016, at 22:07 , Abdassamad Clarke <[log in to unmask]> wrote:

Dear Philip,

Thank you so much. I ran it but nothing happened at all.

A friend opened the file on his PC Windows machine with MS Word, and it opened perfectly. He sent me a screen shot.

The puzzle deepens.

Abdassamad

On 27 Jul 2016, at 03:40, spaelti <[log in to unmask]> wrote:

What I meant by “not difficult” is that it’s not a problem to create a macro which will reverse the words. The question is whether that will solve the problem. The macro will be a solution if the words are indeed physically reversed. Just as others pointed out, I would have suspected that this is somehow the result of some special characters which cause the words to appear reversed.

But now taking the cue from Bob’s suggestion, I’m providing here a macro which looks for stretches of words separated by spaces. For each stretch, it will reverse the words in that stretch. It *will* modify the file, so use it on a copy. (But running it twice, should restore the file, knock on wood). Here’s the macro. I’ll send a macro file to Abdassamad directly.

[Caveat: I’m assuming that the ‘\w’ wildcard works for the relevant script(s). Same for the space. Otherwise the find expression will need to be adjusted. Arabists feel free to let me know whether this works or not.]

/* Macro Reverse Words in Sentence
written for Abdassamad Clarke from the Nisus List
p. spaelti, 2016.7.27
*/
$doc = Document.active
# Extract the stretches of words separated by spaces
# The stretch should start and end with a word and have at least two words
$sels = $doc.text.find '\w+ [\w ]*\w', 'Ea'
$stretches = $sels.arrayByMakingValuesDoCommand 'subtext'
# Reverse all the stretches
$results = Array.new
foreach $stretch in $stretches
$words = $stretch.split(' ')
$revWords = Array.new
while $words.count
$revWords.push $words.pop
end
$results.push $revWords.join(' ')
end
# Replace each stretch with the reversed stretch
foreach $i, $sel in $sels
$sel.text.replaceInRange $sel.range, $results[$i]
end
/* End of macro */




On 2016 Jul 27, at 08:18, Bob Stern <[log in to unmask]> wrote:

On Jul 21, 2016, at 7:36 PM, Philip Spaelti <[log in to unmask]> wrote:

it is not difficult to write a macro to reverse the order of words on a line, but one really wonders how such a file came about.


Philip:  If you're feeling more ambitious than me and want to tackle this for Abdassamad, his and Erik Richard's subsequent posts state that the delimiter is an "end of sentence character".   One approach would be to use the Find command to step through the document one sentence at a time; use the split command, with a space as delimiter, to create an array; then output the array in reverse order.

Abdassamad:  I expect Martin could write such a macro much faster than any of us if you post your question on the Nisus Macros web forum.  Be sure to clarify what "end of sentence" characters may occur in the document.

http://www.nisus.com/forum/viewforum.php?f=17

Bob

Philip Spaelti







Philip Spaelti







Philip Spaelti