nicklockwood / FXLabel

[DEPRECATED]
http://charcoaldesign.co.uk/source/cocoa#fxlabel
Other
816 stars 125 forks source link

Is it possible to add CGContextSetCharacterSpacing(context, n) to FXLabel? #1

Closed kyleplattner closed 11 years ago

kyleplattner commented 13 years ago

Is it possible to add CGContextSetCharacterSpacing(context, n) to FXLabel? If so, how?

nicklockwood commented 13 years ago

I didn't know that method existed. Seems like it would make a handy addition to the library.

The biggest problem seems to be working out the size of the text because you can't use the simple NSString size functions if you're using a non-standard letter spacing.

I'll look at adding it to the core library myself, but in the meantime, here's a stackoverflow thread with some possible solutions (I notice you commented on another stackoverflow thread):

http://stackoverflow.com/questions/2544905/how-to-change-an-uilabel-uifonts-letter-spacing

Nick

On 14 Nov 2011, at 16:25, kyleplattner wrote:

Is it possible to add CGContextSetCharacterSpacing(context, n) to FXLabel? If so, how?


Reply to this email directly or view it on GitHub: https://github.com/nicklockwood/FXLabel/issues/1

kyleplattner commented 13 years ago

I tried adding in the line and couldn't get any of my FXLabels to respond to it (it is very possible I was adding it in the wrong spot). Please let me know as soon as you get something, I am very interested in adding this in. Thanks,

Kyle

On Nov 14, 2011, at 10:47 AM, Nick Lockwood wrote:

I didn't know that method existed. Seems like it would make a handy addition to the library.

The biggest problem seems to be working out the size of the text because you can't use the simple NSString size functions if you're using a non-standard letter spacing.

I'll look at adding it to the core library myself, but in the meantime, here's a stackoverflow thread with some possible solutions (I notice you commented on another stackoverflow thread):

http://stackoverflow.com/questions/2544905/how-to-change-an-uilabel-uifonts-letter-spacing

Nick

On 14 Nov 2011, at 16:25, kyleplattner wrote:

Is it possible to add CGContextSetCharacterSpacing(context, n) to FXLabel? If so, how?


Reply to this email directly or view it on GitHub: https://github.com/nicklockwood/FXLabel/issues/1


Reply to this email directly or view it on GitHub: https://github.com/nicklockwood/FXLabel/issues/1#issuecomment-2732805

nicklockwood commented 13 years ago

I've managed to get it working. The problem is that you have to use CGContextShowTextAtPoint to display the text instead of the NSString drawInRect methods, and that seems to be much more primitive. In addition to not giving you the final size before drawing, it also doesn't provide any options for wrapping or text alignment.

I'll keep looking into it, but it seems that the only way to take advantage of this feature without losing existing functionality is to write my own text layout engine.

kyleplattner commented 13 years ago

Would you be willing to share the code you used to get it working?

Kyle

On Nov 15, 2011, at 8:20 PM, Nick Lockwood wrote:

I've managed to get it working. The problem is that you have to use CGContextShowTextAtPoint to display the text instead of the NSString drawInRect methods, and that seems to be much more primitive. In addition to not giving the final size before drawing, it also doesn't provide any options for wrapping or text alinement.

I'll keep looking into it, but it seems that the only way to take advantage of this feature without losing existing functionality is to write my own text layout engine.


Reply to this email directly or view it on GitHub: https://github.com/nicklockwood/FXLabel/issues/1#issuecomment-2754730

nicklockwood commented 13 years ago

Here you go - it's buggy though, I need to tie the adjusted text size calculation in earlier in the process so that the effects are applied over the whole width of the string:

http://charcoaldesign.com/resources/FXLabel_1.2.1b.zip

kyleplattner commented 13 years ago

Thanks, it appears to work fine for me. Let me know when you get ironed out completely though if you would.

Kyle

On Nov 16, 2011, at 2:08 PM, Nick Lockwood wrote:

Here you go - it's buggy though, I need to tie the adjusted text size calculation in earlier in the process so that the effects are applied over the whole width of the string:

http://charcoaldesign.com/resources/FXLabel_1.2.1b.zip


Reply to this email directly or view it on GitHub: https://github.com/nicklockwood/FXLabel/issues/1#issuecomment-2767126

kyleplattner commented 12 years ago

Nick, Do you know if it is possible to use FXLabel inside of a UITextField?

Kyle

On Nov 16, 2011, at 2:08 PM, Nick Lockwood wrote:

Here you go - it's buggy though, I need to tie the adjusted text size calculation in earlier in the process so that the effects are applied over the whole width of the string:

http://charcoaldesign.com/resources/FXLabel_1.2.1b.zip


Reply to this email directly or view it on GitHub: https://github.com/nicklockwood/FXLabel/issues/1#issuecomment-2767126

nicklockwood commented 12 years ago

Hi Kyle,

That's tricky. I've not tried it, but you might be able to use a subclass or category on UITextField to replace some of the internal UILabels with FXLabels, but looking at the header for UITextField it looks like a lot of the heavy listing is done with a private class called UITextFieldLabel, which you can't replace with an FXLabel, and attempting to do so would probably require you to make private API calls.

So the short answer is no.

kyleplattner commented 12 years ago

Thanks for the reply. Also while I am at it: is there anyway to clean up aliasing seen when using FXLabel?

Kyle

On Jan 23, 2012, at 3:23 PM, Nick Lockwood wrote:

Hi Kyle,

That's tricky. I've not tried it, but you might be able to use a subclass or category on UITextField to replace some of the internal UILabels with FXLabels, but looking at the header for UITextField it looks like a lot of the heavy listing is done with a private class called UITextFieldLabel, which you can't replace with an FXLabel, and attempting to do so would probably require you to make private API calls.

So the short answer is no.


Reply to this email directly or view it on GitHub: https://github.com/nicklockwood/FXLabel/issues/1#issuecomment-3622131

nicklockwood commented 12 years ago

Have you tried increasing the oversampling value?

kyleplattner commented 12 years ago

I have not, how do I determine what to set it at?

On Jan 23, 2012, at 3:57 PM, Nick Lockwood wrote:

Have you tried increasing the oversampling value?


Reply to this email directly or view it on GitHub: https://github.com/nicklockwood/FXLabel/issues/1#issuecomment-3622699

nicklockwood commented 12 years ago

Erm... by reading the documentation?

"For best results, set oversampling to a power of two, i.e. 1, 2, 4, 8, 16, etc. For performance reasons, you should use the lowest value that yields acceptable results."

Basically, try a value of 2 and see if your aliasing goes away. If it doesn't, try 4, and so on.

kyleplattner commented 12 years ago

Nick, With the code you gave us from the link below to accommodate character spacing right justified doesn't seem to behave correctly with applied effects. Do you have any ideas on how to fix this?

Kyle

On Nov 16, 2011, at 2:08 PM, Nick Lockwood wrote:

Here you go:

http://charcoaldesign.com/resources/FXLabel_1.2.1b.zip


Reply to this email directly or view it on GitHub: https://github.com/nicklockwood/FXLabel/issues/1#issuecomment-2767126

nicklockwood commented 12 years ago

The version I forked to add character spacing predates the edge insets feature that allows the effects to work properly with right justification. I'll update it at some point when I have some spare time.

Nick

(Sent from my iPhone)

On 10 Feb 2012, at 18:55, kyleplattner reply@reply.github.com wrote:

Nick, With the code you gave us from the link below to accommodate character spacing right justified doesn't seem to behave correctly with applied effects. Do you have any ideas on how to fix this?

Kyle

On Nov 16, 2011, at 2:08 PM, Nick Lockwood wrote:

Here you go:

http://charcoaldesign.com/resources/FXLabel_1.2.1b.zip


Reply to this email directly or view it on GitHub: https://github.com/nicklockwood/FXLabel/issues/1#issuecomment-2767126


Reply to this email directly or view it on GitHub: https://github.com/nicklockwood/FXLabel/issues/1#issuecomment-3912146

kyleplattner commented 12 years ago

Just noticed that you posted an update to FXLabel. Do you anticipate being able to add character spacing officially in the near future? I am still using an old version you had put together to include this and I would love to update.

On Feb 10, 2012, at 3:02 PM, Nick Lockwood reply@reply.github.com wrote:

The version I forked to add character spacing predates the edge insets feature that allows the effects to work properly with right justification. I'll update it at some point when I have some spare time.

Nick

(Sent from my iPhone)

On 10 Feb 2012, at 18:55, kyleplattner reply@reply.github.com wrote:

Nick, With the code you gave us from the link below to accommodate character spacing right justified doesn't seem to behave correctly with applied effects. Do you have any ideas on how to fix this?

Kyle

On Nov 16, 2011, at 2:08 PM, Nick Lockwood wrote:

Here you go:

http://charcoaldesign.com/resources/FXLabel_1.2.1b.zip


Reply to this email directly or view it on GitHub: https://github.com/nicklockwood/FXLabel/issues/1#issuecomment-2767126


Reply to this email directly or view it on GitHub: https://github.com/nicklockwood/FXLabel/issues/1#issuecomment-3912146


Reply to this email directly or view it on GitHub: https://github.com/nicklockwood/FXLabel/issues/1#issuecomment-3914214

nicklockwood commented 12 years ago

Yes, but it will be a major change and I've been concentrating on quick wins and bug fixes for the time being.

It's on my todo-list for FXLabel 1.4, but the version I made for you was a bit of a hack and I'm not ready to merge it into the main release yet because it would break too many things.

nicklockwood commented 11 years ago

Sorry, I didn't manage to squeeze this into 1.4. I did make a number of internal enhancements to the layout code that will make it easier to add this in future however. I'll try for the next version.

kyleplattner commented 11 years ago

Do you have an estimation of when it will be done? I am still running on a really old one-off version and have a tough time keeping up to date with the latest changes. Thanks.

Kyle

On Dec 18, 2012, at 11:42 AM, Nick Lockwood notifications@github.com<mailto:notifications@github.com> wrote:

Sorry, I didn't manage to squeeze this into 1.4. I did make a number of internal enhancements to the layout code that will make it easier to add this in future however. I'll try for the next version.

— Reply to this email directly or view it on GitHubhttps://github.com/nicklockwood/FXLabel/issues/1#issuecomment-11497075.

kyleplattner commented 11 years ago

Is there a good way to hack character spacing into the current version so I can take advantage of your recent fixes?

On Dec 18, 2012, at 11:42 AM, Nick Lockwood notifications@github.com<mailto:notifications@github.com> wrote:

Sorry, I didn't manage to squeeze this into 1.4. I did make a number of internal enhancements to the layout code that will make it easier to add this in future however. I'll try for the next version.

— Reply to this email directly or view it on GitHubhttps://github.com/nicklockwood/FXLabel/issues/1#issuecomment-11497075.

nicklockwood commented 11 years ago

This is now implemented in the current 1.5 beta. I've not done any performance tuning yet, so let me know if it's noticeably slower to render than before.

kyleplattner commented 11 years ago

Thanks so much. I can't wait to try this.

On Dec 23, 2012, at 5:09 PM, Nick Lockwood notifications@github.com<mailto:notifications@github.com> wrote:

This is now implemented in the current 1.5 beta. I've not done any performance tuning yet, so let me know if it's noticeably slower to render than before.

— Reply to this email directly or view it on GitHubhttps://github.com/nicklockwood/FXLabel/issues/1#issuecomment-11651772.

kyleplattner commented 11 years ago

I am having some trouble with some labels rendering. Would you be interested in taking a look at our project?

On Dec 23, 2012, at 7:16 PM, Kyle Plattner kyle.plattner@precisionplanting.com<mailto:kyle.plattner@precisionplanting.com> wrote:

Thanks so much. I can't wait to try this.

On Dec 23, 2012, at 5:09 PM, Nick Lockwood notifications@github.com<mailto:notifications@github.com> wrote:

This is now implemented in the current 1.5 beta. I've not done any performance tuning yet, so let me know if it's noticeably slower to render than before.

— Reply to this email directly or view it on GitHubhttps://github.com/nicklockwood/FXLabel/issues/1#issuecomment-11651772.

nicklockwood commented 11 years ago

Sure. Email it to support at charcoaldesign dot co dot uk and I'll take a look.

Nick

On 2 Jan 2013, at 04:54 PM, kyleplattner notifications@github.com wrote:

I am having some trouble with some labels rendering. Would you be interested in taking a look at our project?

On Dec 23, 2012, at 7:16 PM, Kyle Plattner kyle.plattner@precisionplanting.com<mailto:kyle.plattner@precisionplanting.com> wrote:

Thanks so much. I can't wait to try this.

On Dec 23, 2012, at 5:09 PM, Nick Lockwood notifications@github.com<mailto:notifications@github.com> wrote:

This is now implemented in the current 1.5 beta. I've not done any performance tuning yet, so let me know if it's noticeably slower to render than before.

— Reply to this email directly or view it on GitHubhttps://github.com/nicklockwood/FXLabel/issues/1#issuecomment-11651772. — Reply to this email directly or view it on GitHub.