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

Major optimization #7

Closed
EranBoudjnah opened this issue Dec 30, 2012 · 6 comments
Closed

Major optimization #7

EranBoudjnah opened this issue Dec 30, 2012 · 6 comments

Comments

@EranBoudjnah
Copy link

Hi,

Is there are reason for using drawAtPoint: withFont: instead of just sizeWithFont: in FXLabel_sizeWithFont: ?

Because the latter saves the need to use a context, prevents pointless drawing and a lot of warnings I got during run time prior to changing it. Am I missing anything?

Cheers,
-Eran

@nicklockwood
Copy link
Owner

Yes. It turns out that sizeWithFont rounds up to the nearest whole point, which makes the calculations totally wrong when I'm drawing everything character-by-character (it wasn't an issue previously when I was drawing a whole line of text at a time).

If you aren't using the characterSpacing feature you'd be better off using the previous stable version of FXLabel instead of the current beta version, but I'd be interested to know what warnings you are seeing?

@EranBoudjnah
Copy link
Author

Super fast response! I was getting countless warnings because context was not yet initialized (sorry, now that I modified the class I'm no longer getting them so can't quote them). Keep in mind you are actually drawing the text twice, which also affects quality around the edges, I'd imagine.

@nicklockwood
Copy link
Owner

I'm not drawing it twice because the text drawing mode is set to kCGTextInvisible prior to drawing, but yes it is certainly non-optimal, hence the beta status.

@EranBoudjnah
Copy link
Author

Cool, hope I pointed out something worth considering. Maybe even consider using a font ten times larger to achieve the precision you require? Just from the top of my head. Would require benchmarking etc...

@nicklockwood
Copy link
Owner

I've just updated with a fix that works by creating a new context specifically for doing the sizing logic. Can you check if the new version fixes the errors you were seeing?

@EranBoudjnah
Copy link
Author

Wonderful. No warnings now :) Thanks!

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