Re: language based scaning
what I'm trying to do is sort of Twitter client, in which the tweets can be English or Arabic so in case of Arabic the alignment should be from right to left, i hope I made it clear this time cheers On Oct 13, 2009, at 2:26 PM, Ricky Sharp rsh...@mac.com wrote: You probably do not want to approach things this way. Arabic is bidirectional and you may have situations where you have a mixture of languages. What you should look at instead is to just localize your app to Arabic. In the Arabic version of your nibs, make the necessary adjustments. Sent from my iPhone On Oct 13, 2009, at 6:16 AM, Nz Gmail nassers...@gmail.com wrote: Hi, Is there is a way to figure out the occurance of Arabic chars so the label's alignment would be set accordingly (right to left)? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/rsharp%40mac.com This email sent to rsh...@mac.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: language based scaning
On Oct 15, 2009, at 1:11 PM, Nz Gmail wrote: what I'm trying to do is sort of Twitter client, in which the tweets can be English or Arabic so in case of Arabic the alignment should be from right to left, i hope I made it clear this time cheers In that case, you can probably scan the text for a Unicode code point within the ranges 0x0600 to 0x06FF and 0x750 to 0x77F. Hopefully that should cover it. However, should the Arabic text also contain presentation forms, code points can also fall within 0xFB50 to 0xFDFF and 0xFE70 to 0xFEFF. Now, I'm not sure about your exact content, but you may have blocks of text that are primarily English with Arabic content and visa versa. So, maybe just scan the first character and drive the layout based on that? e.g. [English block of text with arabic phrase here.whitespace] [whitespace.english phrase here with text of block Arabic] An exception arises if an Arabic block of text begins with Western Arabic digits; you may have to continue scanning until you reach the first alphabetic character. ___ Ricky A. Sharp mailto:rsh...@instantinteractive.com Instant Interactive(tm) http://www.instantinteractive.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: language based scaning,
thanks Ricky, so what classes should i be looking at ? ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: language based scaning,
On Oct 15, 2009, at 12:33 PM, Nasser Al Zahrani wrote: so what classes should i be looking at ? NSString, mostly. Call -characters and loop over the UniChar[] array it returns. It's possible there are APIs for language/script detection at a lower level, like CoreText, but this may be the wrong list to find experts on that. Another possibility that just occurred to me — assuming you're loading the text into an NSTextView already, you can look at the layout information which should tell you the directionality of each run. This is probably somewhere in NSLayoutManager, but I'm not an expert on that class. —Jens___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: language based scaning,
On Oct 15, 2009, at 1:02 PM, Jens Alfke wrote: NSString, mostly. Call -characters and loop over the UniChar[] array it returns. It's possible there are APIs for language/script detection at a lower level, like CoreText, but this may be the wrong list to find experts on that. Another possibility that just occurred to me — assuming you're loading the text into an NSTextView already, you can look at the layout information which should tell you the directionality of each run. This is probably somewhere in NSLayoutManager, but I'm not an expert on that class. Yes, there are better ways to do this. What they are depends a bit on exactly what is wanted. The easiest case is one where you do no work, and just let the system handle things--for example, if you set the paragraph alignment to natural, then the text system automatically aligns to the left or right depending on whether the text is LTR or RTL. If you need to detect the language of a piece of text, CFStringTokenizer can do that; in Snow Leopard there is also a higher- level language detection feature, as part of text checking, which is available via NSTextView. If you want to find pieces of text that are in a given script, you can use NSCharacterSet--that's better than getting an array of characters and looping over it manually. And yes, if you want the resolved layout directionality of a bit of text as it is laid out, you can ask for the NSGlyphAttributeBidiLevel in NSLayoutManager, but that's probably more detailed than you really want. Douglas Davidson ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com