-
Notifications
You must be signed in to change notification settings - Fork 556
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#391 add direction for text attributes
- Loading branch information
Daniil Manin
committed
Jun 13, 2019
1 parent
60b145c
commit 6314726
Showing
6 changed files
with
96 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import UIKit | ||
|
||
public enum Direction { | ||
case lre | ||
case rle | ||
case lro | ||
case rlo | ||
} | ||
|
||
extension Direction { | ||
|
||
var attributedStringValue: NSArray { | ||
switch self { | ||
case .lre: | ||
return [NSNumber(integerLiteral: 0)] | ||
case .rle: | ||
return [NSNumber(integerLiteral: 1)] | ||
case .lro: | ||
return [NSNumber(integerLiteral: 2)] | ||
case .rlo: | ||
return [NSNumber(integerLiteral: 3)] | ||
} | ||
} | ||
|
||
static func from(direction: String?, unicodebidi: String?) -> Direction { | ||
let direction = direction ?? "ltr" | ||
let unicodebidi = unicodebidi ?? "normal" | ||
|
||
switch (direction, unicodebidi) { | ||
case ("ltr", "bidi-override"): | ||
return .lro | ||
case ("rtl", "bidi-override"): | ||
return .rlo | ||
case ("rtl", "normal"): | ||
return .rle | ||
default: | ||
return .lre | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters