Why does Graphics.StringDirection not work?

I am trying to detect when a String contains right-to-left script text, e.g. Arabic.

Yet, when I invoke

dim p as new Picture (8,8) dim g as Graphics = p.Graphics dim n as Integer = g.StringDirection ("?????")

Then n is always -1, which means that “this function is not supported on the user’s system”, according to the rather brief LR on this topic.

Does this mean that this function NEVER works on OSX? If so, why doesn’t the doc say so instead of suggesting that it might work?

And how to I solve this? Only needed for OS X.

Doesn’t seem to work here either. Maybe you can use that:

[code]Declare Function CFStringTokenizerCopyBestStringLanguage Lib “CoreFoundation”
(aString As CFStringRef, range As CFRange) As CFStringRef
Declare Function CFLocaleGetLanguageCharacterDirection Lib “CoreFoundation”
(isoLangCode As CFStringRef) As Integer

Const kCFLocaleLanguageDirectionUnknown = 0
Const kCFLocaleLanguageDirectionLeftToRight = 1
Const kCFLocaleLanguageDirectionRightToLeft = 2
Const kCFLocaleLanguageDirectionTopToBottom = 3
Const kCFLocaleLanguageDirectionBottomToTop = 4

Dim stringToTest As String = “???”

Dim range As CFRange
range.location = 0
range.length = stringToTest.Len

Dim isoLangCode As String = CFStringTokenizerCopyBestStringLanguage(stringToTest, range)

Select Case CFLocaleGetLanguageCharacterDirection(isoLangCode)
Case kCFLocaleLanguageDirectionUnknown
Case kCFLocaleLanguageDirectionLeftToRight
MsgBox(“Left to right”)
Case kCFLocaleLanguageDirectionRightToLeft
MsgBox(“Right to left”)
Case kCFLocaleLanguageDirectionTopToBottom
MsgBox(“Top to bottom”)
Case kCFLocaleLanguageDirectionBottomToTop
MsgBox(“Bottom to top”)

Works (only had to add a Structure for CFRange with two fields: location as Integer, length as Integer).

Thanks for the quick help, saves me some time while working out how to wrap multi-line text like the Finder does it in Icon view.