Chinese font rendering in iOS - ios

The results when rendering Chinese text in UITableViewCell look pretty bad:
I think this is because of the fallback font rendering behaviour: the locale is English, but I'm rendering Simplified Chinese text.
I think this behaviour is because the system Helvetica only has glyphs for certain of the characters in the text.
Is there any way I can set the fallback Chinese font so that it renders English text in Helvetica, but Chinese text in a given font that has all of the Simplified glyphs?

It’s because of the wrong language precedence. If you set your preferred language order as English, 简体中文, the issue would not be exist.
For example, “允” is a shared character between Chinese and Japanese. If the system doesn’t know the correct language order, it might choose the wrong font for that character, in this case, a Japanese font.

Related

How to replace all native emojis with beautiful ones like apple's in the Electronic app?

In a regular web browser there are such naive emojis as in the photo:
My app runs on Electron and the emojis look exactly like this there. How can this be changed in favor of apple emoji? I can't use emojione and search everywhere for these emojis because there are hundreds of places in my application where users write these emojis themselves and I can't physically search everywhere for these emojis
The "right" solution is to use a font that provides Emojis you think fit your app best, but doesn't include any text so you can use your default font for text. Mind that you cannot just "use" Apple's Emojis because that would bring copyright implications for platforms that don't ship with them (i.e., Windows and Linux).
Thus, I recommend to search for an Emoji font you can redistribute with your application (with proper credit if needed by the font's licence).
If your current font chain is, for example:
* { font-family: "Roboto", "Arial", sans-serif; }
You could just go ahead, load your Emoji font (by using #font-face, for example) and prepend it to your font chain. If that font is loaded using the alias "my-emoji-font", then this would look like:
* { font-family: "my-emoji-font", "Roboto", "Arial", sans-serif; }
However, you will have to make sure that the Emoji font does not include any non-Emoji symbols, as these would then also be taken from the Emoji font. Also, this will replace Emojis for any text in your application (thus the * as the CSS selector; you could of course write a CSS rule for specific elements as usual, but bear in mind that you'll have to copy the font chain).
If your Emoji font should lack any Emoji that is used by your application, Electron will display the corresponding Emoji from Roboto, Arial (in this example) or the system's sans-serif font if it's available there.

[TextKit]Why some special characters could make Chinese characters thinner and smaller

That happens on TextKit. But everything is all right when I use CoreText.
The rich text in the debug window of Xcode also has the same issue.
So, is it a bug of TextKit? Is there any solution in addition to replace TextKit by CoreText?
I tried it and the difference really exists between CoreText and TextKit. I guess it caused by the font fallback functions.
For example, we have a string "啦☜啦", and set a font. In case the given font don't have all characters, there usually a list of fallback fonts like:
English font
CJK font
Emoji font
Unicode font (support almost all the unicode character)
There are two ways to find a fallback font.
Find from beginning
Find '啦' in given font.
Not found, find in fallback fonts in order, found in CJK font.
Find '☜' in given font.
Not found, find in fallback fonts in order, found in Unicode font.
Find '啦' in given font.
Not found, find in fallback fonts in order, found in CJK font.
Find from previous
Find '啦' in given font.
Not found, find in fallback fonts in order, found in CJK font.
Find '☜' in CJK font.
Not found, find in fallback fonts in order, found in Unicode font.
Find '啦' in Unicode font
Found.
So if TextKit use the second way, two '啦's may use different fonts because of the character '☜'.
To solve this, you can use attributed string and give '☜' a different font size to break the fallback loop, then the second '啦' use CJK font.

Arabic font breaks on iOS app

We are working in iOS app and we are using "Adobe Arabic" and "Tahoma" font.
Both fonts in some area break. For example
Tahoma breaks by adding space between in a single word as shown in image below
Not sure why this is happening for some works. We have similar issue for Adobe Arabic for some Arabic text
Mostly font breaks when using verses from quran "بِسْمِ اللَّـهِ الرَّحْمَنِ الرَّحِيمِ" otherwise it is fine... That is when ever we add tajweed font break by adding space.
What could be the possible reason for this
As I see, its failing to render diacritics. Diacritics should be merged to their previous letters in Arabic. In your example, it breaks with the Shada diacritic ّ :
It happens mostly in Quranic verses because they are fully vocalized compared to normal texts.
A solution is to normalize your texts and strip diacritics. The list of diacritcs is:
// Diacritics
'0x64b' // FatHatan
'0x64c' // Dammatan
'0x64d' // Kasratan
'0x64e' // FatHa
'0x64f' // Damma
'0x650' // Kasra
'0x652' // Sukun
'0x651' // Shadda
The normalization is recommended for normal text but not Quran verses since its considered as a holy text and recommended to be written as fully vocalized Uthmani script. You may use pre-rendered images.
A deep solution is to use a rendering engine like harfbuzz. It renders Arabic perfectly.
Try this line in css:
.element {
letter-spacing: -1px;
}
It works with me.
Try these in your css
font-family: "Traditional Arabic", "Montserrat","sans-serif","Times New Roman";

Porting Arabic font to iOS System

I am just looking to get a better look for my iPad using custom font.
The default Arabic font for iOS8 devices is GeezaPro. and it's in .ttc format.
I am trying to replace it with my custom font.
I use DOSBOX to break system font ttc file into ttf files to make them editable.
Then i use FontLab Studio to replace system font glyphs with my custom font glyphs.
I just copy the glyph from custom font and paste them in the system font (using special paste option FontLab provide).
Then i use DOSBOX again to join these ttf files into ttc file.
That's worked for custom English fonts i used. but using it with arabic fonts show some issues.
The text letters appear separated in iOS apps and everywhere.(as you already know that Arabic language use joined letters and sometimes separated letters depending on the context. if the letter is the first letter it will use specific glyph, the same goes if the letter is in the middle or in the end using different glyph. while in English all letters are always remain separated no matter what. except for handwritten scripts.)
any idea how to fix?
some links:
tutorial I followed to port my fonts
the arabic font I am trying to accomplish (it's free and legit)
P.S: some may say use Bytafont library of fonts but i want to use this specific font. and arabic fonts also limited in the library (20 font only available).
Fonts are complex programs that run on embedded hardware interpreters and font engines (the same way game ROMs run on game hardware or in emulators), and don't just contain the pictures for each letter, but also all the instructions on how to position, combine, and substitute those letters based on what sequence of input it's being told to process.
For almost every font, just copying the glyph outlines is not enough, you also need to make sure that:
the original font's glyph ordering is preserved,
the GPOS table gets copied over (which determines mark positioning, kerning, etc), and
the GSUB table gets copied over (which handles glyph substitution, without which you can't even write Arabic. As an example, you need ـب, ـبـ, بـ or ب depending on context for the same "letter" bā’)
So you generally want to unpack the TTC (which as of OpenType 1.7 can be either truetype or postscript/type2, so that's a thing to remember for the future), then perform the replacements of glyphs (with order-preservation), as well as replacing the GPOS and GSUB tables (using FontForge or TTX) and then pack it back up into the TTC.

iOS: How do I find out what "fallback font" is used when I try to display Japanese characters with my western font?

I'm displaying strings with a combination of Japanese and western characters. I know what font I'm using for the western characters...but how do I find out what font is used for the Japanese characters?
(And can I change it?)
The default Japanese system font in iOS is Hiragino Kaku Gothic ProN W3. It's also the default fallback for displaying Japanese text when using a Latin font. In my own experience, it doesn't matter whether a Latin serif or sans serif font is in use—Hiragino Kaku Gothic ProN W3 is still used for the Japanese text.
(The more interesting question is how you'd go about changing it.)

Resources