10

In iOS 15 soft hyphens (\u{00AD}) are not considered when setting text on UILabel. for example: The following code does render the text with the soft hyphen correctly in iOS 13 & 14, but not in iOS 15.

import UIKit

class ViewController: UIViewController {

@IBOutlet weak var label: UILabel!

override func viewDidLoad() {
    super.viewDidLoad()
    label.text = "Very\u{00AD}VeryVeryVeryVeryVeryLongWordWithASoftHyphenTo"
  }
}

Result: enter image description here

How can i make UILabel consider the soft hyphen (\u{00AD}) in iOS 15?

Renato Stauffer
  • 738
  • 2
  • 14
  • 30
  • This should not be different between prior versions of iOS and iOS 15. Just out of curiosity, though, what is the lineBreakMode on your UILabel? (and does the behavior change if you set it to "byWordWrapping") – Scott Thompson Sep 24 '21 at 13:55
  • Seems you do have an hyphen on iOS 15, but it's in another location, between "Soft" and "HyphenTo". As others have said, can this be a configuration issue? – Cristik Sep 25 '21 at 18:16
  • @ScottThompson I have the default set: byTruncatingTail. I just tried with byWordWrapping, but the same result. – Renato Stauffer Sep 27 '21 at 06:36
  • @Cristik Yes, it has a hyphen, but the line break is in the wrong location. As you can see on the the image. – Renato Stauffer Sep 27 '21 at 06:44
  • I know Apple switched text engines with iOS 15 (see TextKit 2 https://developer.apple.com/videos/play/wwdc2021/10061/). This could very well be a bug you should report to them! – Scott Thompson Sep 27 '21 at 12:54
  • Yeah, I also get the impression it is a bug. I will report this. bu thx for the video, I have not watched this yet :) – Renato Stauffer Sep 28 '21 at 09:36
  • 6
    I have opened a Technical Support Incident (TSI) at Apple. They told me to open a bug report in the feedback assistant. I will update the answer as soon as I get a response / have more information. – Renato Stauffer Nov 01 '21 at 07:52
  • Hi! Did you received any answer from Apple? I've experience same bug in my app, it's multilanguage and can have few different language texts on one screen, but on iOS 15 if inside string there is soft hyphen unicode symbol it also adds automatically hyphens using systems preferred language rules and obviously if word is German and system language English those hyphenation are wrong. Placed TSI ticket too, but maybe you have news regarding it? Because in iOS 15 there is seems no chanсe making correct hyphenation for other than systems first preferred language. – Ivan Barabanshchykov Dec 23 '21 at 12:03
  • @RenatoStauffer any updates? – Claus Jørgensen Mar 01 '22 at 10:31
  • The only comment I got from them was: This is expected. Soft hyphen does not guarantee you break at that point, it is merely suggesting a *possible* line break point. So seems like this behaviour really changed and is now "default". – Renato Stauffer Jan 24 '23 at 09:29

1 Answers1

1

Got response from Apple for this one:

Before iOS 15, we strictly followed soft hyphen, while in iOS 15 we now only consider those as hyphenation opportunities.

That is the design, and there are no plans to change it. The app should be able to use languageIdentifier attribute to influence the hyphenation with the attributed string so that it should follow German hyphenation even when system language is English.

https://developer.apple.com/documentation/foundation/attributescopes/foundationattributes/3802173-languageidentifier

So basically now we should use languageIdentifier attribute, lesser opportunities for our own custom hyphenation rules (like remove ugly, one side short, hyphenation break), but works grammatically correctly.

Soft hyphens still working but just as an addition.