Open garrettmoon opened 7 years ago
From @hannahmbanana on January 10, 2017 22:48
@iwheelbuy - could you check if this matches the behavior of UILabel?
From @iwheelbuy on January 11, 2017 16:15
UILabel is fine
if (route?.title ?? "").contains("ый» (Площадка отстоя)-Дом учен") {
let label = UILabel.init(frame: UIScreen.main.bounds)
label.backgroundColor = .white
label.numberOfLines = 0
label.text = route?.title
UIApplication.shared.keyWindow?.addSubview(label)
}
From @iwheelbuy on January 11, 2017 16:49
That is the page I parse information from: http://mu-kgt.ru/informing/wapold/marsh/?t=1
I use String.Encoding.windowsCP1251
to convert from data to string
From @hannahmbanana on January 12, 2017 19:47
@iwheelbuy - would you be willing to create an example project (or modify examples/layoutSpecExamples-Swift/LayoutExampleNode.swift - class HeaderWithRightAndLeftItems) to show this bug? I'm guessing it has something to do with the string encoding which I'm not too familiar with.
From @iwheelbuy on January 15, 2017 13:38
Sample project is a bit complex, but it shows the issue. pod install -> run -> tap on "Автобус"
From @Jonhory on March 17, 2017 9:45
Demo show the issue.
From @iwheelbuy on March 17, 2017 9:48
Jonhory, there is a broken link in your demo readme
From @Jonhory on March 18, 2017 4:56
My Demo update.
ASTextNode
, Red backgroundColor is UILabel
/
, ;
,maybe include more symbols.loadASTextNode
func loadTextNode(y: CGFloat, with text: String) {
let textNode = ASTextNode()
textNode.attributedText = NSAttributedString(string: text,
attributes: [NSFontAttributeName: UIFont.systemFont(ofSize: 16),
NSForegroundColorAttributeName: UIColor.red])
textNode.frame = CGRect(x: 100, y: y, width: 200, height: 20)
textNode.backgroundColor = UIColor.blue
view.addSubnode(textNode)
}
loadUILabel
func loadUILabel(y: CGFloat, with text: String) {
let label = UILabel()
label.text = text
label.textColor = UIColor.blue
label.backgroundColor = UIColor.red
label.frame = CGRect(x: 100, y: y, width: 200, height: 20)
view.addSubview(label)
}
I know this issue is originally pretty old but I thought it was interesting and maybe someone runs into this in the future.
The difference in behavior between ASTextNode
and UILabel
observed in the Demo app is caused by the fact that the default truncation settings are different. UILabel
has NSLineBreakByTruncatingTail
as default and ASTextNode
has NSLineBreakByWordWrapping
as default. If you set truncationMode
to NSLineBreakByTruncatingTail
it will behave in the same manner as UILabel
.
I did note that ASTextNode
and UILabel
behave differently when NSLineBreakByWordWrapping
is used. In the case of ASTextNode
a default character set (https://github.com/TextureGroup/Texture/blob/master/Source/TextKit/ASTextKitRenderer.mm#L76) is being used to determine a truncation point other than the end of the visible character range.
In the comments it's assumed this is a whitespace or a newline (https://github.com/TextureGroup/Texture/blob/master/Source/TextKit/ASTextKitTailTruncater.mm#L134) but ASTextKitRenderer
provides a default character set for finding a 'correct' truncation point in a string (). This default set contains the characters .,!?:;
next to whitespaces in newlines. This would cause a string like test.string
or test:string
to be truncated differently.
@Adlai-Holler I think you're the persion to talk to about everything textkit related right? Do you know if the difference in behavior for NSLineBreakByWordWrapping
is intentional?
@smeis This is related: https://github.com/TextureGroup/Texture/issues/227
From @iwheelbuy on January 10, 2017 17:53
I have some strings to be presented in
ASTextNode
I don't expect a new line right after the
/
symbol, but the result is:Is there a way not to get new line after the
/
?The cell code:
Copied from original issue: facebookarchive/AsyncDisplayKit#2885