mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 13:40:49 +00:00
(+defaultWritingDirectionForLanguage:): Implement.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@19291 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
cfe33cfa9e
commit
476a373bf8
3 changed files with 41 additions and 4 deletions
|
@ -1,7 +1,12 @@
|
||||||
|
2004-05-12 16:50 Alexander Malmberg <alexander@malmberg.org>
|
||||||
|
|
||||||
|
* Source/NSParagraphStyle.m (+defaultWritingDirectionForLanguage:):
|
||||||
|
Implement. Patch from Christopher Culver.
|
||||||
|
|
||||||
2004-05-12 15:52 Alexander Malmberg <alexander@malmberg.org>
|
2004-05-12 15:52 Alexander Malmberg <alexander@malmberg.org>
|
||||||
|
|
||||||
* (-_generateGlyphsForRun:at:): Use a properly typed function
|
* Source/GSLayoutManager.m (-_generateGlyphsForRun:at:): Use a
|
||||||
pointer for characterIsMember.
|
properly typed function pointer for characterIsMember.
|
||||||
|
|
||||||
2004-05-08 Fred Kiefer <FredKiefer@gmx.de>
|
2004-05-08 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
|
|
|
@ -134,6 +134,11 @@ typedef enum _NSWritingDirection {
|
||||||
- (NSLineBreakMode) lineBreakMode;
|
- (NSLineBreakMode) lineBreakMode;
|
||||||
|
|
||||||
#ifndef STRICT_OPENSTEP
|
#ifndef STRICT_OPENSTEP
|
||||||
|
/*
|
||||||
|
* Returns the writing direction of "language", which is an ISO 639
|
||||||
|
* two- or three letter code, e.g. "en", or an ISO language-region
|
||||||
|
* format, e.g. "en_GB"
|
||||||
|
*/
|
||||||
+ (NSWritingDirection) defaultWritingDirectionForLanguage: (NSString*) language;
|
+ (NSWritingDirection) defaultWritingDirectionForLanguage: (NSString*) language;
|
||||||
- (NSWritingDirection) baseWritingDirection;
|
- (NSWritingDirection) baseWritingDirection;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -139,8 +139,35 @@ static NSParagraphStyle *defaultStyle = nil;
|
||||||
|
|
||||||
+ (NSWritingDirection) defaultWritingDirectionForLanguage: (NSString*) language
|
+ (NSWritingDirection) defaultWritingDirectionForLanguage: (NSString*) language
|
||||||
{
|
{
|
||||||
// FIXME
|
static NSArray *rightToLeft;
|
||||||
return NSWritingDirectionNaturalDirection;
|
NSWritingDirection writingDirection;
|
||||||
|
NSString *langCode = nil;
|
||||||
|
|
||||||
|
/* If language is 5/6 characters long with underscore in the middle,
|
||||||
|
treat it as ISO language-region format. */
|
||||||
|
if ([language length] == 5 && [language characterAtIndex: 2] == '_')
|
||||||
|
langCode = [language substringToIndex: 2];
|
||||||
|
else if ([language length] == 6 && [language characterAtIndex: 3] == '_')
|
||||||
|
langCode = [language substringToIndex: 3];
|
||||||
|
/* Else if it's just two or three chars long, treat as ISO 639 code. */
|
||||||
|
else if ([language length] == 2 || [language length] == 3)
|
||||||
|
langCode = language;
|
||||||
|
|
||||||
|
if (!rightToLeft)
|
||||||
|
// Holds languages whose current scripts are written right to left.
|
||||||
|
rightToLeft = [[NSArray alloc] initWithObjects: @"ar", @"ara", @"arc",
|
||||||
|
@"chi", @"fa", @"fas", @"he", @"heb", @"iw",
|
||||||
|
@"ji", @"kas", @"ks", @"ku", @"kur", @"pa",
|
||||||
|
@"pan", @"per" @"ps", @"pus", @"sd", @"snd",
|
||||||
|
@"syr", @"tk", @"tmh", @"tuk", @"ug",
|
||||||
|
@"uig", @"ur," @"urd", @"yi", @"yid", @"zh",
|
||||||
|
@"zho", nil];
|
||||||
|
if ([rightToLeft containsObject: langCode] == YES)
|
||||||
|
writingDirection = NSWritingDirectionRightToLeft;
|
||||||
|
else // If it's not RTL, assume LTR.
|
||||||
|
writingDirection = NSWritingDirectionLeftToRight;
|
||||||
|
|
||||||
|
return writingDirection;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) dealloc
|
- (void) dealloc
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue