how to retrieve a writing direction?

I'd like to be able to retrieve a writing direction from an arbitrary string... but how?

I have tried getGlyphsInRange:glyphs:properties:characterIndexes:bidiLevels:

   NSLayoutManager* layoutManager = [[NSLayoutManager alloc] init];
  NSTextStorage* textStorage = [[NSTextStorage alloc] initWithString:@"abc"];
  [textStorage addLayoutManager:layoutManager];
  NSRange stringRange=NSMakeRange(0,[@"abc" length]);
  NSMutableData* glyphData=[NSMutableData dataWithLength:sizeof(CGGlyph)*stringRange.length+1];
  CGGlyph* glyphs=(CGGlyph*)[glyphData mutableBytes];
   
  unsigned char *bidiLevelBuffer = calloc([@"abc" length], sizeof(unsigned char));
  int glyphCount = (int)[layoutManager getGlyphsInRange:stringRange
                          glyphs:glyphs properties:NULL
                     characterIndexes:NULL
                        bidiLevels:bidiLevelBuffer];
   
  NSLog(@"--- %i, \"%s\"", glyphCount, bidiLevelBuffer);

with the result:

2021-12-29 10:39:54.694104+0300 aTypeTrainer4Mac[61412:3479843] --- 3, ""

...

any ideas?

I have done it, but using another approach...

to view the complete solution, follow the link:

https://osxentwicklerforum.de/index.php/Thread/33193-wie-kann-man-writing-direction-bei-einer-beliebigen-Textzeile-abfragen/

how to retrieve a writing direction?
 
 
Q