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

Implement UILabel-like autoshrinking #5

Open
DesmanLead opened this issue Mar 30, 2017 · 1 comment
Open

Implement UILabel-like autoshrinking #5

DesmanLead opened this issue Mar 30, 2017 · 1 comment

Comments

@DesmanLead
Copy link

The ideal interface looks like:

@interface MTMathUILabel : UIView
<...>
@property (nonatomic) BOOL adjustsFontSizeToFit;
<...>
@end

Do you have any ideas about the clear way to implement it?

Currently I see the following solutions:

  1. Use binary search or similar approach to find an optimal size over a few iterations.
  2. Calculate ratio of a desired size to an actual size and use it to calculate the font size. This is fast, but in terms of math rendering the font size does not have a constant correlation with an output size.
  3. (not the clearest one, but robust) Just resize the rendered image to fit label.
@kostub
Copy link
Owner

kostub commented Mar 30, 2017

I already have code that does auto-font adjust in the MathEditor example:

https://github.com/kostub/MathEditor/blob/master/MathEditorExample/MTViewController.m#L40

But that only works as you are editing. Doing it for the MathUILabel is a bit more complex and we have to take one of the approaches you've described. Though I'm not sure I understand the approach used by 3.

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