Poor font quality in CCLabelBMFont - ios

Scaled screenshot on iPhone 5S:
CCLabelBMFont is on top and CCLabelTTF is at the bottom.
Both strings use Helvetica Neue Light 17pt.
As you can see there is some kind of a stroke in the first string, but all symbols in font image are white on transparent background. Is it possible to get rid of this effect and make CCLabelBMFont look just as good as CCLabelTTF?
I used bmGlyph and other free analogs for Bitmap font creation, results were always the same.

First, don't change the node's scale property or it will be blurry.
You need to make a HD version of the font, where the font's png filename has the -hd suffix and the font size is double that for non-Retina devices. For example:
Non-Retina font with 32pt size (if you support non-retina devices):
font.fnt
font.png
Then create a font with 64pt size and save it as:
font-hd.fnt
font-hd.png

What a relief!
Turned out it's because of Blend src property.
I changed this property on my label from default in SpriteBuilder 'One' to 'Dst Alpha' and now it's impossible to see any difference between CCLabelTTF and CCLabelBMFont!

Related

How to set UILabel font size in iOS in terms of dp's (Not in points) just like android with only autolayout

In my iOS program, I want to set UILabel size in dp's. So that when the iOS device changes, according to scale factor (#1x, #2x, or #3x) my UILabel size will also changes proportionally.
Lets say for eg. #1x scale factor, I have UILabel size = 15pt, then It will automatically become 30pt #2x and 45pt #3x
I am not sure whether you can set UILabel size in dp's but instead what you can do is set "Autoshink" to "Minimum Font Size" and provide minimum desire font.

Use a UIImage with text or UILabel for automatically scaled text

I have text that needs to be scaled for each iOS device depending on the screen size. Apparently, you can't scale UILabel font size automatically except manually code wise (unless I am missing something). Instead of having to code for a lot of scenarios, would it be better to use an UIImage that has all the text? This way I can make the text scale automatically depending on device size?
You can make a UILabel's text scale automatically by (1) setting auto layout constraints for that UILabel such that its height and width are relative to the screen size, (2) setting the label's base font to at least the size which it would be on the largest screen, then (3) setting its "auto shrink" property such that its minimum font scale or minimum font size would be at least as small as the font on the smallest screen.
I do not recommend using an UIImage instead because you wouldn't be able to edit or localize it as easily.

What is appropriate size of icon for 3D Touch shortcut item on home screen?

I couldn't find it on Icon and Image Sizes.
But I mean, what is the size of following icons?
Below mentioned article, there is a note:
Once you download this, you will see that there is a recommended size:
104x104 for 3x
70x70 for 2x
Since Apple will automatically size and re-colour the icons, it's better to use a PDF, which has the added benefit of looking sharper and a reduced risk of causing clipped edges if margins aren't used.
Here's a comparison of PDF vs PNG (exact same icon, originally and SVG exported from Sketch):
The size is also the same.

UIFont and Retina displays. Double the size?

I think I might already know the answer, but here is the situation:
I have a spec sheet that requires the font size to be: 11pt.
When I do: UIFont *font = [UIFont fontWithName:#"Gotham" size:11.0];
Then font is tiny on my retina iPad 4.
When I double the point count with: UIFont *font = [UIFont fontWithName:#"Gotham" size:22.0];
The size looks right. Am I right to assume that I should double the font point count for #2x devices? Just as one would for a png.
Edit:
Thanks for clearing that up. I get that: UIFont *font = [UIFont fontWithName:#"Gotham" size:11.0]; Will produce the same size on Retina/Non-retina.
Now for possibly more dumb follow up:
When I open up the photoshop file (scaled at #2x) the font reads 11pt. When I export the file (converted to png and labeled #2x) and I drop the png into the project, why does the image's text still appear significantly bigger than the text I created programmatically at 11pt? (Both the image and programatic text are being viewed within the iPad)
I'm probably having a brain fart, but any help finding the solution would be appreciated.
No, you don't need to scale font sizes. Font sizes are in points, not pixels. The reason why 11.0 seems tiny to you is because it really is ;-)
But the size should be the same regardless wether it's a retina device or not.
If you are doing this right, you should be able to ignore pixels and think entirely in terms of points, the native measurement unit:
If you have a built-in interface widget, such as a UILabel, then [UIFont fontWithName:#"Gotham" size:11.0] will look the same size on Retina and non-Retina devices (but sharper on Retina).
If you are constructing an image in real time (in code), and you are using this font to draw into the image, then if this is to be a 2x image for double-resolution screen, then you should be using a double-resolution graphics context (e.g. you set this up with UIGraphicsBeginImageContext(size,NO,0)) and once again [UIFont fontWithName:#"Gotham" size:11.0] will look the same size on Retina and non-Retina devices (but sharper on Retina).
On the other hand, let's say you are preparing an image in Photoshop, to be used later in your iOS app (e.g. for an icon), and this image has some font drawing within it. Then of course for a 2x version of the image you must double the font size, just as you are doubling the size of everything in the drawing.

UIFont: Font size differs

I am setting a custom font to all subviews (such as UILabels) inside my view by a custom function. However, if I try to correct the font size for specific UILabels only via
[lbl_EXAM_Statistics setFont:[UIFont fontWithName:#"PTSans-Regular" size:13]];
The 13point seems to be a little "too small" from what was given me from the Screendesign.
In the psd file however its 13pt to be exact.
Why does the 13pt font size differ from the 13pt font size in my app?
In the screenshot the above text is from the psd file, the bottom one from the iphone simulator.
If I want to get near the text size from the Screendesign to my app I'd have to use somewhat of 18pt - but I cant waste time playing around how to get the exact pt, thats a huge timewaste with all the font size I have to specify directly. So there must be a better way.
Totally depends on your psd.
Best is to set your metrics in Photoshop in pixels. So you can see the size of your font in pixels.
Then if your PSD is at retina size (640 px width), you just have to devide by 2 the px size of your font and you will have the good result on your app.
In the end, don't use pt but px in your PSD and it will be allright (just have to think that 1point in iOS is 2px on retina screen and 1px on non-retina)
Photoshop's font size and the iPhone's should match assuming the PSD file is set to 72dpi (or 144 for retina images).
You can check this in Photoshop using Image->Image Size... and then set the resolution to 72 pixels/inch (keeping the pixels untouched by unchecking "Resample Image:"). If the image is for retina resolution, use 144 pixels/inch.
This will not change the image in any way but make all pt measurements in Photoshop match the iPhone's coordinate system, retina or not.

Resources