10 Replies Latest reply on Nov 6, 2012 2:55 AM by [Jongware]

    [CS4] !!text Hebrew with problem unexpected

    [Jongware] Most Valuable Participant

      This is driving me !sreknob

       

      I have a couple of Hebrew phrases in an otherwise English text, so I assigned the World Ready Composer to the styles in question using Peter Kahrel's "Arabic" set of scripts, and created a 'Hebrew' character style. No problem: the Hebrew text comes out perfect. What's Not So Nice is that some other text also follows an RTL direction!

       

      hebrew.PNG

       

      In the above screenshot, you can see the volume number and page range "2:663-676" appear correctly in the Story Editor below. The Story Editor does not know anything about Hebrew, so it reverses the Hebrew text. That's not a problem, because the World Ready Composer fixes that in the formatted text (above).

       

      But what is going on with the numbers!? No amount of copying & pasting seems to fix this. The paragraph direction is set to Left To Right; the Hebrew text has a character style that only applies another font.

       

      [Edit] Oh, and of course the square bracket at the right of the numbers isn't corerct either. ]It seems more than a bit [random to me.]

        • 1. Re: [CS4] !!text Hebrew with problem unexpected
          Sami Artur Level 1

          Hi Jongware,

          this is because the keynoard is RTL, try this script:

           

           

           

          main ();

           

           

          function main ()

                    {

                    try

                              {

                              if (app.selection[0].keyboardDirection == CharacterDirectionOptions.rightToLeftDirection)

                                        app.selection[0].keyboardDirection == CharacterDirectionOptions.leftToRightDirection

                              else

                                        app.selection[0].keyboardDirection = CharacterDirectionOptions.rightToLeftDirection

                              }

                    catch (_){}

                    }

          I hope it helps.

           

          Sami A. Mandelbaum

          1 person found this helpful
          • 2. Re: [CS4] !!text Hebrew with problem unexpected
            TᴀW Adobe Community Professional & MVP

            Could be that what Sami suggests will work.

             

            On the other hand, characterDirection overrides keyboardDirection.

             

            The problem here is the neutral characters. The only way to tell exactly

            what's happening with them is to select the characters one at a time

            from left to right. That way you can see the logical order of the

            characters.

             

            At any rate, I would simply select everything after the two Hebrew words

            and apply a left-to-right character direction

            (app.selection[0].characterDirection =

            CharacterDirectionOptions.leftToRightDirection)

             

            Then also select the other square bracket and apply the same to it.

             

            Finally, you may find you have an issue with the space before and after

            the Hebrew, so you may have to apply the same to both spaces.

             

            Let us know how you get on!

             

            Ariel

            1 person found this helpful
            • 3. Re: [CS4] !!text Hebrew with problem unexpected
              Sami Artur Level 1

              There is a error in my script, it is only 1 "=" in the second line:

              main ();

               

               

              function main ()

                        {

                        try

                                  {

                                  if (app.selection[0].keyboardDirection == CharacterDirectionOptions.rightToLeftDirection)

                                           app.selection[0].keyboardDirection = CharacterDirectionOptions.leftToRightDirection

                                  else

                                            app.selection[0].keyboardDirection = CharacterDirectionOptions.rightToLeftDirection

                                  }

                        catch (_){}

                        }

              Jongware, if You need more RTL scripts let me know.

              Sami

              • 4. Re: [CS4] !!text Hebrew with problem unexpected
                [Jongware] Most Valuable Participant

                It has definitely to do something with CharacterDirection, in conjunction with the WRC. Copying the text to Word shows the correct phrase.

                 

                The default CharacterDirection, without any messing around, is "Default", and this seems to cause the problem. Peter Kahrel's script to create a specific Arabic or Hebrew paragraph style explicitly sets "CharacterDirectionOptions.rightToLeftDirection".

                 

                So I tried the following:

                 

                1. Assign Left-to-Right Character direction to the paragraph style.

                2. Assign Right-to-Left to the character style, for Hebrew only.

                 

                This seems to work ... Now all I have to do is repeat the trick for Arabic -- in the same article

                 

                What I do not understand is what causes this erratic behavior. I spent more than an hour trying to figure out if there were any LTR/RTL Unicode toggle codes somewhere in these lines -- there are none. So InDesign's "heuristic" seems to be to automatically set Hebrew text right-to-left; and it gets it wrong when, oh my, suddenly some numbers appear! The numbers snap back into correct order when I insert a hard return right before them, so it has to be the Hebrew text on the same line.

                You could argue that ID infers the RTL order from the number because it is preceded by Hebrew, but in that case the heuristics still get it wrong, as it sees "2:663-676" as two parts "2:663" and "676". If I insert a space after the colon, I get this

                 

                hebrew2.PNG

                 

                which is only slightly better. The numbers are in the wrong order (because they are preceded by Hebrew, they are in the correct order for Hebrew), but the square brackets are way off. What's clearly missing is being able to insert explicit LTR and RTL codes.

                • 5. Re: [CS4] !!text Hebrew with problem unexpected
                  [Jongware] Most Valuable Participant

                  Just for follow-ups, the scripts I wrote. I could not use Peter Kahrel's 'r2l-paragraph_style_Hebrew' script because I needed to adjust pre-existing styles.

                   

                  1. Assign Left-to-Right to the current paragraph style:

                   

                  app.selection[0].appliedParagraphStyle.characterDirection = CharacterDirectionOptions.leftToRightDirection;

                   

                  2. Assign Right-to-Left to the current character style:

                   

                  app.selection[0].appliedCharacterStyle.characterDirection = CharacterDirectionOptions.leftToRightDirection;

                  • 6. Re: [CS4] !!text Hebrew with problem unexpected
                    TᴀW Adobe Community Professional & MVP

                    This is from a PDF called "Middle Eastern Specific Features" that comes with CS4 (helpfully, copying text from that PDF has been password disabled by the friendly folk at Winsoft, so here's a screenshot):

                     

                    Capture.PNG

                     

                    So not very helpful, but it does confirm that InDesign uses the context to decide the direction of neutral characters.

                     

                    What you get in InDesign does depend on how "they" typed it in Word. Especially the space between the English and Hebrew can be misleading and irritating to fix. E.g: This space שלום

                     

                    The "operator" may have typed "<English Keyboard>T-h-i-s- -s-p-a-c-e- -ש-etc. which would be correct. Or they may have type:

                    ...s-p-a-c-e-ם-ו-ל-ש- - which is wrong, but that last space gets placed between the English and Hebrew and looks like a correct space even though logically it's in the wrong place.

                     

                    The same issue occurs with brackets and parentheses, because most software will switch around open and close brackets depending on the keyboard selected. So a careless "operator" will type whatever happens to work, without trying to be consistent about when they switch keyboard. This can cause a real mess. It's probably what happened in your case.

                     

                    Sometimes it's easiest just to retype the whole thing....

                     

                    Ariel

                    • 7. Re: [CS4] !!text Hebrew with problem unexpected
                      [Jongware] Most Valuable Participant

                      A-ha! I was right, it's an automatic system going wild. Thanks for confirming it!

                       

                      > Sometimes it's easiest just to retype the whole thing....

                       

                      I must have used at least half a dozen different methods in the past. Fortunately, each one more advanced than the previous! Let me think, I have:

                       

                      * printed from Word to PDF and painstakingly imported/placed/scaled each separate phrase. Pro: anyone can do this. Con: Loads of extra work. Loads of fun with line-spanning text, and the occasional last minute correction. Cannot adjust font.

                       

                      * copied from PDF into Illustrator, saved as .ai, the rest as above. Pro: you can tinker with the text (a bit). Con: even more work.

                       

                      * reversed the characters in ID. Pro: fast, efficient, can use fonts. Con: it qorked nicely in CS3 and older, but CS4 tries to override accent placing and ligatures, which is troublesome for Hebrew. Also, Arabic needs to have Each Bloody Separate Character checked for correct initial/medial/final form. Another con: line-wrapping needs to be done manually. Only just feasible with short phrases; longer stories -- think of a full paragraph -- needs to be broken manually into lines, because otherwise right-to-left text also appears bottom-to-top.

                       

                      * cut phrases out of running text, pasted into separate text box, so I could finally use proper RTL character and paragraph formatting. Text boxes were then re-inserted into the text on the original position. Pro: finally! Automatic ligatures, wonky text cursor, real fonts -- the Real Thing. Con: still no good solution for line-wrapping text. Also, the text boxes themselves caused spacing problems.

                       

                      With all said and done, the following worked out nicely at the end:

                       

                      1. Add WRC to the correct styles. (I am *neurotic* about getting my style inheritance right. Since in this article both Hebrew and Arabic text appeared in different situations, I could set the WRC to only one style, and the rest also got it from there.)

                      2.  Select all text and blindly set its character direction to Left-to-Right.

                      3. Search for continuous spans of Hebrew and Arabic (which may include spaces and the occasional punctuation) and apply the right character set for the script to this. At this point I could either include or exclude spaces, periods at end, etc. by manually verifying if the GREP search matched the correct phrase.

                       

                      At a couple of positions I encountered the "Operator Error", where a single space was *not* included inside a long RTL phrase -- but only because in a case like this I do not trust my senses nor InDesign, and verify Each Seperate Phrase against the original copy ...

                      • 8. Re: [CS4] !!text Hebrew with problem unexpected
                        Joel Cherney Adobe Community Professional & MVP

                        The same issue occurs with brackets and parentheses, because most software will switch around open and close brackets depending on the keyboard selected. So a careless "operator" will type whatever happens to work, without trying to be consistent about when they switch keyboard. This can cause a real mess. It's probably what happened in your case.

                         

                        Sometimes it's easiest just to retype the whole thing....

                         

                        My Arabic keying skills top out at about three words per minute, so rekeying text is really not an option. So, whenever I start a new Arabic job, I have a template doc that has a few handy bits on the pasteboard. In project that require a bunch of nested brackets or other troublesome bidi characters, the most useful bits are the single space with the charstyle "Overt LTR Space" and the single space with the charstyle "Overt RTL Space."

                         

                        If someone is looking over my shoulder, what they'll see is a terribly confused sentence with nested parentheses and swaps between LTR and RTL text; I'll paste in one or two of the above spaces, and all of a sudden the paragraph will snap into the correct order. If asked "Hey Joel, how did you know to paste an "Overt LTR Space" there? How did you know that doing so would fix this segment?" and my answer will be to look blankly at whoever asked me the question, pause for three beats, and then say "I have no idea whatsoever."

                        • 9. Re: [CS4] !!text Hebrew with problem unexpected
                          Sami Artur Level 1

                          Jongware, Is your text a RTL text with LTF words or is a LTF text with RTL words?

                          You are using only 1  font Adobe Hebrew.

                          Did try to use 2 fonts 1 for English and 1 for Hebrew.

                          You can try these open source free hebrew fonts: http://culmus.sourceforge.net/

                          Sami

                          • 10. Re: [CS4] !!text Hebrew with problem unexpected
                            [Jongware] Most Valuable Participant

                            Sami, it's English with phrases in Hebrew and Arabic.

                             

                            I'm not using a single font for all text. I used a special character style for the RTL languages and set the font in there (Adobe Hebrew, Adobe Arabic).