Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attributed string attributes not preserved #67

Open
andreaslindahl opened this issue Oct 6, 2020 · 8 comments · May be fixed by #71
Open

Attributed string attributes not preserved #67

andreaslindahl opened this issue Oct 6, 2020 · 8 comments · May be fixed by #71

Comments

@andreaslindahl
Copy link

When setting the attributedText property to an NSAttributedString, NantesLabel sets the text property of the label to attributedText.string instead of actually setting the attributedText property, which means that any formatting, and other attributes, set on the NSAttributedString aren't used.

Is it possible to use an NSAttributedString without losing all of the formatting and attributes?

override open var attributedText: NSAttributedString? {
    get {
        return _attributedText
    } set {
        guard newValue != _attributedText else {
            return
        }

        _attributedText = newValue
        setNeedsFramesetter()
        _accessibilityElements = nil
        linkModels = []

        checkText()

        setNeedsDisplay()
        invalidateIntrinsicContentSize()

        super.text = attributedText?.string
    }
}
@andreaslindahl
Copy link
Author

Investigating this further, it seems most of the attributes, such as bold etc are preserved, but that some already existing paragraph styling is removed, such as headIndent.

@bvirlet
Copy link

bvirlet commented Oct 28, 2020

Have you tried using:

    public func setAttributedText(_ attributedString: NSAttributedString, afterInheritingLabelAttributesAndConfiguringWithBlock block: ((NSMutableAttributedString) -> NSMutableAttributedString)?) ```

@andreaslindahl
Copy link
Author

Yes, I tried that as well, with the same result.

@frndev
Copy link

frndev commented Dec 10, 2020

Same here, it seems centered paragraph is not preserved.

@bghenriques
Copy link

bghenriques commented Jan 17, 2021

Hi Andreas, I am using NantesLabel library on an iOS app and I have the exact same issue; the following settings are ignored:

paragraphStyle.firstLineHeadIndent
paragraphStyle.headIndent
paragraphStyle.paragraphSpacingBefore

It would be very important to have this corrected in the Library by the Nantes team.

@andreaslindahl
Copy link
Author

Is anyone maintaining this library anymore?

@ngoleo
Copy link
Contributor

ngoleo commented Feb 10, 2021

@andreaslindahl sorry for the delay. i'm exploring whether we could preserve those attributes. will keep you updated.

@darko55s
Copy link

@ngocholo check the PR above, this should fix the head ident for attributed strings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants