I usually have 4 files per font. For instance
menu-ipadhd.fnt
menu-ipadhd.png
menu.fnt
menu.png
Question is, should I localize all 4 files or .fnt localization is enough? Can Cocos2D find png file from corresponding .lproj? What is the proper way to localize bitmap fonts?
Whether cocos2d finds files according to language is easy to test, put two different files one in en.lproj and the other in some other language folder, then change the device's or simulators language and see whether it picks the correct one for each language.
If you are meaning to localize the text (strings displayed with a bitmap font) you really just have to localize the strings and make sure that for all supported languages all language-specific characters (äéøß and such) are included in the bitmap font's image. At least all of those actually used by your localized strings.
If you are localizing to a completely different character set, for example from english to cyrillic, asian or arabic languages, you need to provide different bitmap fonts altogether, ie both fnt and png files and load them according to the language. This is next to localizing the text itself.
The reason is that these non-latin character sets contain hundreds if not thousands of different characters, so including them in a single bitmap font is not desirable and may not even be possible to fit them all in 4096x4096 (or less) texture space.
Some cocos2d version's bitmap font class limits the number of characters in a bitmap font to 2048 - this may apply only to v1.x I haven't checked if that limitation still exists in 2.x in general, I just can't locate it in 2.1 anymore. For character sets that exceed this number of characters you will have to increase that number in the header of CCBMFontLabel - if available.
Be careful though with large bitmap fonts as the storage per letter can add up quite significantly, an entire font can use several megabytes - not counting the texture itself!
Related
I am using the black and white circle in my project when I noticed that on ios chrome the white circle is larger than the black circle.
● - U+25CF
○ - U+25CB
In a desktop environment the circles appear to be the same size but have slightly different heights. The difference is not noticeable.
I am trying to make these circles the same size on ios chrome.
I feel like I have eliminated any variables and that the browser is responsible for the different sizes of these circles.
photo
Actually, as far as unicode is concerned, all characters are font dependant. When a certain character is not available, it is picked from a fallback font.
If you had not configured a custom font, or if these chars are not available in the font you picked then the different sized circles are in the default font used by chrome/ios.
So, you have two ways to go: either find a font that have the characters drawn in a way that suits you, and force that, or give-up using unicode characters for these glyphs and use inline images instead.
You could make use of SVG drawings which can be encoded within the HTML markup itself, that will ensure a consistent look.
I often use font data (.ttf or .otf) in Swift to change font of UILabel. But sometimes I use only show numbers in UILabel and think which is better using font data or image data of each numbers like "1_image.png", "2_image.png", "3_image.png"...
Of course if I want to show many characters like articles and messages I should import font file in project. But I'm not sure which is better to show only numbers in the specific situation like showing user game ranking and scores.
I think it is almost always better to use a font -- as long as you are allowed to distribute it. Some of the advantages of fonts are:
They scale
No need to bother about pixel resolutions
More options to align them (like baseline etc.)
Better support for accessibility (like adjusting the contrast etc.)
I've seen apps that have more characters than mine and displayed fully whereas mine starts to truncate with the "..." after its 10th char.
I know an app on my iPhone that has 14 characters, and they are all displayed without any "...". I noticed that app's app title's fonts are a little bit smaller and the char-spacing in between is much less compared to the other apps.
Unfortunately you can't. The actual size isn't measured by chars because every char has a different width.
Your app name probably has more "boldy" chars that resulting in less char count than the one you mentioned.
BTW
The OS is shrinking app names when it tries to fit it completely under the app icon, but this also has a limit of course.
The font they use for application name is not monospace (or fixed-width). Means, the length of the name depends on the characters: M & W take more space than I & T.
Yes, there is no way to choose the font. But you might come up with a workaround.
As an option you can replace a whitespace with a thinner one as explained here.
Choosing the app name is very difficult. Find a short name. You can also put a part of your app name directly in the app's icon.
I am writing an app that requires labels w/ musical accidental symbols, called sharp and flat (♯ and ♭, respectively). Specifically, I need a label that says c♯. It is irrelevant to the question what these two symbols mean within a musical context. My app's main font is Open Sans. However, because Open Sans doesn't specify a character for the sharp and flat symbols, it uses a generic sharp and flat symbol that I find unattractive. However, I know that Helvetica Neue (or the iOS system font) has some well made symbols for sharp and flat, so I decided to change the label's text to an attributed string so I could make the c Open Sans, and the ♯ Helvetica Neue (both size 24). I did this through the interface builder. Even though everything looks exactly the way I want in the storyboard, when I launch it in the iOS Simulator, the labels with attributed strings are significantly shrunken from the other labels. I should note that the label has 3 AutoLayout constraints, though these contrasts are positionally related only, not size related.
Things I have tried (unsuccessfuly):
Using only one font
Doubling the font size (was too big)
Removing autolayout constraints
I would greatly appreciate it if someone could explain how to correctly create these labels. I am happy to provide any more information that is needed.
Thank you
I discovered that the problem is that NSAttributedString does not (yet) support custom fonts through Interface builder. It looks like I will have to subclass. This question essentially boils down to be the same as this one: Attributed string with custom fonts in storyboard does not load correctly
How do I match the font pixel size given to me by my designer in PhotoShop to the correct font size in Xcode Interface builder.
For example, my designer is using Helvetica Neueu Regular 32px Font in his design.
I've used a few points to pixel translation sites, but it doesn't seem exact.
I have attempted to follow the answer from this question, but to no avail:
https://stackoverflow.com/a/6107836/1014164
You will never have perfect results when visually comparing a Photoshop comp to a real program. In fact, it's not un-common for a text layout to be different between different computers because version and operating system differences (as well as monitor layouts) cause the text to reflow every time it's edited.
Unless things are very much different in other versions of Photoshop, your designer hasn't specified 32px because Photoshop doesn't lay text out in pixels - it works in points/picas. The exact text rendering is also dependent on the document's resolution (which is different between print and screen).
The best you can do is get the text to look roughly proportional to the designer's intent. In modern iOS, most apps will use the user's customized font settings anyway.