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

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.

Related

JSPDF how to use variable fonts

I can happily use jspdf to add fonts to a pdf. For that so far I add a font for regular, one for italic, one for bold and one for bolditalic in my case.
Now I have some fonts that do not provide these different fonts but variable ttf-fonts and I struggle to use those with JSPDF.
So far my solution goes like this:
pdf.addFileToVFS(`${fontFamily}-bold.ttf`, fontBase64Data);
pdf.addFont(`${fontFamily.ttf}-bold.ttf, fontFamily, 'bold', 700);
where I read fontBase64 data from file (which works nicely for regaulr, italic etc) and do the same with the regular and italic fonts...
For variable fonts I tried to add a font with variable font weight with above code just use the fontBase64Data as I read it from the ttf file of variable font.
However that just leaves the font regular.
To my understanding that alos makes sense as the API of addFonts seems to associate a loaded font with a font weight it represents, but does not seem to apply a font weight to the font.
Since I want to use variable fonts however I seem to need to either
set a font as variable font, so weight would be automatically applied
apply a weight to the variable font via api and then define that as bold
So far I couldn't find any of that. Am I missing sth or are variable font weights currently not supported yet by jspdf?
Cheers
Tom

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.

Force UIFont to Render as Monospaced

Is it possible to force a UIFont to be monospaced?
Specifically I'm using a font which does not contain monospaced numbers (tabular numerals). Creating a modified font object which is monospaced and adding that font to the numeric segments of attributed strings would work great.
Another solution may be to add custom attributes to an attributed string and modify what is handling the layout of the text to use a fixed size for glyphs in particular ranges.
Things that Haven't Worked:
There are a number of questions that propose solving similar problems by overriding -drawRect: or -drawTextInRect: on a UILabel (see: Is it possible to alter the letter-spacing/kerning of a font with Cocoa Touch?). This seems like an insane solution and would be prohibitively complex if a string mixes monospaced and not-monospaced fonts.
There are also number of questions which suggest, specifically in regards to numerals, creating a font with a font descriptor with certain font features enabled. (see Displaying proportionally spaced numbers (instead of monospace / tabular) on iOS). This seems only to work in fonts which include these features. The font I'm using does not include these features and they have no effect. The font features can be checked by using something like NSLog(#"%#", CTFontCopyFeatures ( ( __bridge CTFontRef ) myFont ));

Chinese font rendering in 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.

sifr3 multiple font faces in one .swf? for fonts that don't have bold or italic weights?

I have a font which only has a regular weight… I’d like to use another font as the bold weight and another as the italic weight… and have sifr use the extra fonts as a replacement based on strong and or b tags
I’ve tried embedding the multiple fonts in the .swf but only the regular weight get’s applied when sifr is activated. If I have two separate .swf font files I can the text to generate in either font but can't seem to apply the bold version to the bold text in the sentence.
Is their a smarter way to do this? using sifr3 - r436 with CS3 Flash Professional to create the font files
Okay after an hour os do googling various terms I found this
http://discuss.joyent.com/viewtopic.php?id=24567
which answers my question - I now have the whole family embedded as I need
Thanks
R

Resources