FRHyperLabel
FRHyperLabel copied to clipboard
font is not considered (added also solution in comments)
Hi.
Currently the font of label is not considered.
Instead of this //textStorage to calculate the position NSTextStorage *textStorage = [[NSTextStorage alloc] initWithAttributedString:self.attributedText]; [textStorage addLayoutManager:layoutManager];
should be this //textStorage to calculate the position NSTextStorage *textStorage = [[NSTextStorage alloc] initWithAttributedString:self.attributedText]; [textStorage addAttribute:NSFontAttributeName value:self.font range:NSMakeRange(0, self.text.length)]; [textStorage addLayoutManager:layoutManager];
Hi, thanks for the contribution. However, isn't the font attribute included in the attributes of attributedText? An attributed string could have different fonts for different parts of texts, I'm afraid is not appropriate to set one single font for the full range.
Hi again.
NSMutableAttributedString * str = [[NSMutableAttributedString alloc] initWithString:@"this is a test string"];
self.testLabel.attributedText = str;
This is initialization of my label attributed string. As you see i do not provide any font for attributed text. My label was created on interface builder and has custom font. So in this current case NSTextStorage needs a font attribute of the label.
I am not sure how current solution will behave when attributed text will have font attributes for different parts. But at the same time without this line of code calculations are wrong when no font attributes provided.
[textStorage addAttribute:NSFontAttributeName value:self.font range:NSMakeRange(0, self.text.length)];
Conclusion
- Issue is valid
- Solution should be retested (may be for covering both cases another solution will be needed ).
Custom font is not working properly: with custom font its working for few font sizes . Eg - if i use Proxima nova regular then it work with font size less then 15 pixel (for 2 line label) after that tappable area is not working.