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

Text Clipping #18

Closed
superprat opened this issue Sep 8, 2014 · 19 comments
Closed

Text Clipping #18

superprat opened this issue Sep 8, 2014 · 19 comments

Comments

@superprat
Copy link
Contributor

Hi,

I'm getting some clipping around the text with the font I'm using
ios simulator screen shot 08-sep-2014 3 29 16 pm

I updated the sizetofit method on THLabel but it removes the clipping only on the right hand side

-(void)sizeToFit
{
    [super sizeToFit];
    CGRect frame = self.frame;
    CGRect expandedFrame = CGRectInset(frame, -self.strokeSize * 2, -self.strokeSize *2);
    [self setFrame:expandedFrame];
    [self setNeedsDisplay];
}

ios simulator screen shot 08-sep-2014 3 34 07 pm

The issue is only visible when using sizeToFit. I have faar to many labels to manually set the frames for them. Any suggestions?

@superprat
Copy link
Contributor Author

whoops, Got it, nvm setTextInsets did the job

@tobihagemann tobihagemann reopened this Sep 8, 2014
@tobihagemann
Copy link
Owner

I've worked upon your last pull request and came up with a logic for sizeThatFits (because you shouldn't override sizeToFit) that conforms to the available Core Text frame. Could you please test my newest commit if this works for you? There's also a new property called automaticallyAdjustTextInsets which defaults to YES.

@superprat
Copy link
Contributor Author

I tried it out, It works in some places, but in others it sets the frame too small. The text gets shortened at the end with ...

These same labels were sized properly earlier

@tobihagemann
Copy link
Owner

Alright thanks for testing. I guess I'll have to do more testing myself. But in your case you're "only" using outside stroke, is that right?

@superprat
Copy link
Contributor Author

Yup, just strokeColor and strokeSize.

@tobihagemann
Copy link
Owner

Is there any way you could tell me which (probably custom) font you're using at which font size? I'm not able to reproduce the issue. :/

@superprat
Copy link
Contributor Author

I'm using the font Damn Noisy kids, available at http://www.dafont.com/damn-noisy-kids.font
I don't think it's fontsize dependent. Seeing the issue for all sizes. Strokesize is 2.0

@tobihagemann
Copy link
Owner

I've commited a fix, but it wasn't even font-related. If it's still producing truncated strings, I'm not sure what the issue is.

@superprat
Copy link
Contributor Author

Nope, Still producing truncated strings, in more places than before.

@tobihagemann
Copy link
Owner

I'm so confused. If you could provide a minimal example project and send it to tobias.hagemann@gmail.com, that would be great. It's okay if you don't have the time, but I don't know how/what to test anymore, because I can't reproduce the issue.

@superprat
Copy link
Contributor Author

The current code is actually crashing on line 435 now
EXC_BAD_ACCESS(code=1,address=0x0)

I'll send you a sample project on your email to reproduce the issue

@superprat
Copy link
Contributor Author

Hey did a little trial and error and I think the string is getting truncated while using AutoLayout. Wasn't able to reproduce the issue in a separate project without it

@tobihagemann
Copy link
Owner

I've commited a fix for intrinsicContentSize, I guess the sizing behavior is different with Auto Layout. Now I'm rounding up the numbers. But I'm not sure about that crash.

@superprat
Copy link
Contributor Author

Yup that did it! Everything looks perfect now.

Not sure what that crash is either, not consistently reproducible.

@tobihagemann
Copy link
Owner

My guess is that I'm using CFRelease too soon on some things, but I thought it's common practice to use CFRelease after using CFCreate. Just went through the code again and couldn't find anything specific. Crashing is bad though, it worries me a bit.

@superprat
Copy link
Contributor Author

So from what I have observed, the crash is occurring when layoutIfNeeded is being called and the label is being redrawn and the text is nil on line 438. The same issue is not observed on regular UILabels even if the text string is nil.

@tobihagemann
Copy link
Owner

Whoops! Fixed that with version 1.4.1! Thanks for helping me out! I guess that's it? :D

@superprat
Copy link
Contributor Author

Yup, looks solid! Thanks for the awesome Label !! :)

@tobihagemann
Copy link
Owner

Thanks again for testing and giving feedback!

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

No branches or pull requests

2 participants