Background: I develop software for viewing specialized academic content with complex layout requirements (complex footnotes, tables, images, non-standard character sets, etc.) In the desktop version this is accomplished with WPF's low-level TextFormatter and in the web app this is accomplished with Flash's FTE (not TLF, but the underlying engine). Both of these are low-level engines that produce text lines of a specified width and formatting, which can then be arranged to form pages.
We would like to port the application to the iPad and Android tablets. At the moment we are leaning towards using AIR for Android/Packager for iPhone to reuse much of our existing as3 codebase. However, we want to explore the option of going native on each platform.
My question is: Do iOS and Android offer a comparable low-level text engine capable of:
Assuming that this is not offered by the native APIs (and at least from looking over the Android SDK this seems to be the case), are there any third party frameworks available for these platforms that do all of the above?
In iOS, there is CoreText framework. (offered in C language) I think this is perfectly suitable for you.
Here is reference documentation.
http://developer.apple.com/library/ios/#documentation/StringsTextFonts/Conceptual/CoreText_Programming/Introduction/Introduction.html
Apple has one of the strongest typographic technology as like Adobe. As far as I know, their technologies are not compatible. (except font and PDF) CoreText has most features similar with Adobe's one, but behaves slightly differently. So you have to tweak all layout values again.
I'm not sure all of features you listed are supported.
was supported in initial release of CoreText framework for iOS. I can't sure about other features like ligature, bidirectional flow. (because I didn't tested) And about selection, I checked the related feature is offered in other framework but I have not used it.
There was some issues in initial release of CoreText. I described some here: (1) Aligning multiple sized text vertical center instead of baseline with Core Text in iOS (2) Core Text: Render to an Odd Shape
The CoreText is originally a Mac OS X framework. And it is gradually being ported to iOS. I have not used CoreText on Mac, but when I checked the doc, it has many more features. I expect most features will be ported. Apple is currently porting many Mac features aggressively.
I have used Flash (not in-depth level in fonts) and I'm satisfying on Apple's framework. I believe you will not disappointed with it. As you know, Apple is the one of the opener of computer typographic era. (the other one is Adobe :)
The framework looks a little bit hardcore, but it's very easy to use than it looks. It can draw NSAttributedString (rich-text object) as it is, and all you have to do is just making an NSAttributedString instance and draw it with CoreText.
For example, if you have properly configured NSAttributedString, this code will draw every rich-text in specific rectangle area.
// In an UIView subclass.
- (void)drawRect:(CGRect)rect
{
NSAttributedString* AS = [self text]; // Assumes this property exist.
CGContextRef CTX = UIGraphicsGetCurrentContext();
CGMutablePathRef P = CGPathCreateMutable();
CGRect R = rect;
CGPathAddRect(P, NULL, R);
CTFramesetterRef FS = CTFramesetterCreateWithAttributedString((CFAttributedStringRef)AS);
CTFrameRef F = CTFramesetterCreateFrame(FS, CFRangeMake(0, 0), P, NULL);
CTFrameDraw(F, CTX);
CFRelease(FS);
CGPathRelease(P);
Of course drawn graphics will be flipped unless you call this code at somewhere.
[[self layer] setGeometryFlipped:YES];
And if you're finding alternative of native typographic/layout framework, there is two options.
HTML with UIWebView can be one. Look at CSS3 and later. There are pretty many features than people generally expect. However, HTML and UIWebView is a lot heavier and slower than CoreText. I could used CoreText drawing in UITableViewCell without any struggling on scrolling animation.
freetype library is extremely low level font library. It offers lowest level of direct access to font data and rendering facility with anti-aliasing. Because it's low level, you should implement layout logic yourself. I don't know about this library well.
I don't know about Android.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With