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

Small problem with some font descenders #38

Closed
daviddelmonte opened this issue Oct 18, 2013 · 13 comments
Closed

Small problem with some font descenders #38

daviddelmonte opened this issue Oct 18, 2013 · 13 comments

Comments

@daviddelmonte
Copy link

Hi, first, thanks for a terrific control.

I find that it cuts off some font descenders (Futura for example). These are not custom fonts, in that they are part of iOS.. Maybe it's a system problem. But I thought you should be advised.

I have seen this post describing a similar problem with custom fonts:

http://www.andyyardley.com/2012/04/24/custom-ios-fonts-and-how-to-fix-the-vertical-position-problem/

If there is a workaround, please let me know.

@cbpowell
Copy link
Owner

Glad you find it useful!

Well in general, MarqueeLabel doesn't mess too much with the height or Y positioning of the UILabels it wraps. It is possible to set the frame height too small for the font size you're using though, and you'll end up cutting off the bottom. If you use a regular UILabel, with the same frame size, font size, etc, do you see the same problem?

@cbpowell
Copy link
Owner

Any luck? I'd be interested in seeing a code sample of the setup that's causing your issue if you haven't found out a solution.

@cbpowell
Copy link
Owner

Going to go ahead and close this out - let me know if my above comments didn't fix it!

@simonbromberg
Copy link
Contributor

simonbromberg commented May 1, 2017

My UILabel is big enough to avoid this descender problem when I don't use MarqueeLabel, but when I do use it the letters get cut off (e.g. g) whenever the label is labelized (i.e. if it's animating the marquee the letters are not cut off). Even if I make the UILabel way bigger than necessary, after labelizing the letters get cut off.

Using FuturaStd-Medium

Note my workaround for this is typically either to make the label bigger than necessary using AutoLayout (not working here because of MarqueeLabel) or to use insets (made simple using a custom subclass like this).

@cbpowell
Copy link
Owner

cbpowell commented May 2, 2017

@simonbromberg Hmm I just tried it in the demo project, changed the font of the first label to Futura Medium in IB and (probably) oversized the label, and didn't see the issue - could you be more specific on the configuration and/or set up a test case?

Side note - what do you mean by AutoLayout and not working because of MarqueeLabel?

@cbpowell cbpowell reopened this May 2, 2017
@simonbromberg
Copy link
Contributor

simonbromberg commented May 4, 2017

I am not using the built in Futura Medium font but rather a custom one (although I have seen this kind of issue with built-in fonts before).

Re side note: As I mentioned, when the MarqueeLabel is animating, the letters are not cut-off, but when it labelizes it cuts off the letters. I suspect this is because the UILabel it uses internally is sizes using sizeToFit which can trump the constraints in IB.

@cbpowell
Copy link
Owner

cbpowell commented May 5, 2017

Well MarqueeLabel actually uses sizeThatFits, not sizeToFit, which doesn't inherently resize the view upon the call to that function. But that's probably irrelevant, because it does "manually" resize the sublabel frame to be equal to it's own bounds.size.height (here when labelized, and here when scrolling continuously).

However, I did just notice that the LeftRight type uses the height from expectedLabelSize rather than MarqueeLabel's own bounds like the other types (both in Swift and Objective-C versions).

Do you happen to be using the LeftRight type? I tried again with the demo project and a LeftRight type and didn't see the issue, but I'm still just using the regular Futura font.

@simonbromberg
Copy link
Contributor

simonbromberg commented May 5, 2017

Is LeftRight scrolling horizontally from left to right? If so, yes.

Possibly also relevant that I am using attributed strings.

@cbpowell
Copy link
Owner

cbpowell commented May 5, 2017

If you use MarqueeLabel in such a way that it's easy to modify the code quickly, you could try changing this line to:

homeLabelFrame = CGRect(x: leadingBuffer, y: 0.0, width: expectedLabelSize.width, height: bounds.size.height).integral

Or for Objective-C, this line to:

self.homeLabelFrame = CGRectIntegral(CGRectMake(self.leadingBuffer, 0.0f, expectedLabelSize.width, self.bounds.size.height));

Or alternatively/more easily, temporarily change your label's MarqueeType to a continuous type and see if the problem goes away? The leftRight type is the only one that (incorrectly) uses the expectedLabelSize height rather than it's own bounds height. I'll fix that in an update soon too.

@cbpowell
Copy link
Owner

cbpowell commented May 6, 2017

I've pushed release 3.0.5 - let me know if it fixes the issue for you!

@cbpowell
Copy link
Owner

cbpowell commented Jun 8, 2017

@simonbromberg did you get a chance to test the latest release? I'm thinking it probably corrected the issue.

@simonbromberg
Copy link
Contributor

simonbromberg commented Jun 8, 2017

I wound up modifying the descender/ascender of the font a bit. I'll have to go back into the commit history and test it from before that change when I get a chance.

@cbpowell
Copy link
Owner

I'm thinking my change may have fixed it, so I'm going to (re)close this issue, but if you do check it and find the problem is still there please post again and I'll reopen!

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

3 participants