Main Page
From Gsocicu
Contents |
Status
<a href="http://web.archive.org/web/20040209045054/oss.software.ibm.com/icu/userguide/layoutEngine.html">Missing code from manual located</a> <a href="Also here">Also here</a>
Currently I have a xcode project (several really) which contains basic code for rendering to a graphics context, and the beginnings of a working Mac specific font instance.
- It uses c++/obj. c, as much of the required data must be accessed through the CoreText framework. Many of the basic data types are interchangable with their Cocoa counterparts (<a href="http://developer.apple.com/documentation/Cocoa/Conceptual/CarbonCocoaDoc/Articles/InterchangeableDataTypes.html#//apple_ref/doc/uid/20002401">Interchangable Data Types</a>) so can likely be made more Cocoa-ish without much trouble.
- It has a graphics context view (currently called TestView) prepared to draw on - this will be the area to draw the glyphs once I am done with the data side of it. This renders a couple of test bits of text - not derived from the LE.
- It currently accesses font data through a <a href="CTFont">CTFont</a>. BUT - should this be a <a href="CGFont">CGFont</a> - <a href="CGFontCopyTableForTag">CGFontCopyTableForTag</a>??? Check this as a CGFont seems to return the data I want (which may make it easier to access the font metrics).
What needs to be done:
- The character to unicode mapper is a bit of an issue (I think). I need to access data in the cmap table, and it is structured so you initally can find out how many subtables there are, then you search <a href="http://ibsdietplan.org">ibs</a> for the one you want by platformID (Mac/Windows/Unicode/Other), then by specific platform ID's. At this point you have the glyph indices, and <a href="http://developer.apple.com/textfonts/TTRefMan/RM06/Chap6cmap.html">other relvant information</a>. The example code shows how to use a font on Windows and Linux (platformID 3, SpecificID 1 or 10 - unicode). These are Windows specific Unicode tables.
I am now concentrating on the microsoft font table only.
- It needs the character code mapping, and some way to draw to the graphics context. This should be possible with CGContext/CGFont.
- It needs bits and pieces ported from the sample - file loading, processing (bidi, finding runs, etc). Most of this code was created to be portable so it should not be difficult.
<a href="Program outputs">program outputs</a>
Various Notes
Fonts
Opentype and truetype, have the minimum required tables for font information. The cmaps.h/cpp class looks *only* for the Windows encoding (3), and the platform specific ID of 1, or 10 (both Unicode related). See the following tables:
<a href="http://developer.apple.com/textfonts/TTRefMan/RM06/Chap6name.html#ID">Table 39: Macintosh platform-specific encoding identifiers</a>
<a href="http://developer.apple.com/textfonts/TTRefMan/RM06/Chap6name.html#ID">Table 38: Name records</a>
<a href="http://www.microsoft.com/OpenType/OTSpec/name.htm">Microsoft Opentype platform specific identifiers</a>
TODO: Fonts with tables (3, 1) is only supported by cmaps.cpp. Not all the fonts have this particular cmap subtable.
Misc
Mac OS X is built to allow internationalisation to be easily built into an application. At the lowest level Apple Type Services for Unicode Imaging (ATSUI) exists to allow developers to manipulate and convert unicode strings. ATSUI is reasonably old now, and the Cocoa API's are the most supported so using Cocoa and various other libraries is preferred in most situations. In Leopard, a new framework called Coretext became available (it was a private framework in 10.4). Coretext is for handling fonts, and text layout.
The LayoutEngine requires the following system dependent classes:
- LEFontInstance. This is the interface between the LE and the platform font system. It will either be a single font at a particular size or a composite font. If it is a composite font - there are some things to consider (i.e that a char to glyph mapping only makes sense if it is a single font) It needs to:
- access font tables (<a href="http://developer.apple.com/textfonts/TTRefMan/RM06/Chap6.html">eg truetype tables</a>). This is possible using CTFontCopyTable, and the FontTable constants available in <a href="http://developer.apple.com/documentation/Carbon/Reference/CTFontRef/Reference/reference.html#//apple_ref/c/func/CTFontCopyTable">CTFont</a>
- do character to glyph mapping (logical storage order to visible order of glyphs).
- font metrics (font advances, ascent, descent, etc)
To do these the following methods must be implemented
- virtual const void *getFontTable(LETag tableTag)
- one of the mapCharToGlyph methods
- getAscent, getDescent, getAdvance. All available through <a href="http://developer.apple.com/documentation/Carbon/Reference/CTFontRef/Reference/reference.html#//apple_ref/c/func/CTFontCopyTable">CTFont</a> BUT only as scaled floats. We need to get point sizes - so actually must use the font tables ([hhea table])
There must also be some way to render the glyphs to the screen.
- Using Quartz, and CGContext can render glyphs. <a href="http://developer.apple.com/documentation/GraphicsImaging/Reference/CGContext/Reference/reference.html#//apple_ref/c/func/CGContextShowGlyphs">CGContextShowGlyphs</a>
- <a href="http://developer.apple.com/documentation/GraphicsImaging/Reference/CGFont/Reference/reference.html#//apple_ref/doc/c_ref/CGGlyph">CGGlyph</a> (typedef unsigned short CGGlyph)
Fonts
Much of the data requested must be accessed through font tables. In particular (for truetype):
- head table tag - for ascent, descent, linegap (leading)
- variety of other information available (will document as required)
Links
<a href="ICU Reference">ICU Reference</a>
Fonts
<a href="http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&item_id=IWS-Chapter08">Overview of Truetype</a>
ICU
- <a href="http://www.icu-project.org/userguide">ICU Userguide</a>
- <a href="http://www.icu-project.org/userguide/layoutEngine.html">Layout engine (missing code example)</a>
- <a href="http://www.icu-project.org/apiref/icu4c">ICU C API Reference</a>
- <a href="http://www.microsoft.com/typography/SpecificationsOverview.mspx">Opentype specification</a>
- <a href="http://developer.apple.com/textfonts/TTRefMan/RM06/Chap6.html">Truetype Specification</a>
Apple
- <a href="http://developer.apple.com/gettingstarted/index.html">Getting started - links to every topic</a>
- <a href="http://developer.apple.com/textfonts/TTRefMan/RM06/Chap6cmap.html">Character to Glyph mappings</a>
- <a href="http://developer.apple.com/referencelibrary/GettingStarted/GS_TextAndFonts/index.html">Getting started with text and fonts (Cocoa / Carbon)</a>
- <a href="http://developer.apple.com/documentation/CoreFoundation/Conceptual/CFStrings/Articles/about.html">Core Foundation - Strings</a>
- <a href="http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Introduction/chapter_1_section_1.html#//apple_ref/doc/uid/TP30001163-CH1-SW2">Objective C overview</a>
- Core Text
- <a href="http://developer.apple.com/documentation/Carbon/Conceptual/CoreText_Programming/index.html">Core text programming guide</a>
- <a href="http://en.wikipedia.org/wiki/Core_Text">Wikipedia entry on Core text</a>
- <a href="http://developer.apple.com/documentation/Carbon/Conceptual/CoreText_Programming/Overview/chapter_2_section_1.html">Core Text overview</a>
- <a href="http://developer.apple.com/documentation/CoreFoundation/Reference/CFStringRef/Reference/reference.html">CFString Reference</a>
- Cocoa
- <a href="http://developer.apple.com/documentation/Cocoa/Conceptual/FontHandling/FontHandling.html">Font handling - includes font creation, font metrics, glyph / character relationships for display.</a>
- <a href="http://developer.apple.com/documentation/Cocoa/Conceptual/TextArchitecture/TextArchitecture.html">Cocoa Text Architecture</a>
- <a href="http://developer.apple.com/documentation/Cocoa/Conceptual/TextLayout/TextLayout.html">Text layout overview</a>
- <a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/ObjC_classic/Intro/IntroAppKit.html">Application kit overview - (Cocoa fundamentals - NS prefixed classes)</a>
- <a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSFont_Class/Reference/Reference.html#//apple_ref/occ/instm/NSFont/coveredCharacterSet">NSFont docs</a>
- <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSCharacterSet_Class/Reference/Reference.html#//apple_ref/doc/c_ref/NSCharacterSet">NSCharacterSet Docs</a>
- <a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSTypesetter_Class/Reference/Reference.html">NSTypesetter Docs</a>
- <a href="http://www.cocoabuilder.com/archive/message/cocoa/2006/12/4/175429">Example NSTypeSetter</a>
- <a href="http://developer.apple.com/documentation/Cocoa/Conceptual/TextLayout/Concepts/Typesetters.html">TypeSetter general docs</a>
- <a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSLayoutManager_Class/Reference/Reference.html#//apple_ref/occ/cl/NSLayoutManager">NSLayoutManager docs</a>
- <a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSATSTypesetter_Class/Reference/Reference.html#//apple_ref/occ/cl/NSATSTypesetter">Concrete class of NSTypeSetter</a>
- <a href="http://developer.apple.com/documentation/Cocoa/Conceptual/TextStorageLayer/Concepts/StorageLayer.html">Cocoa Text Storage layer</a>
Consult the <a href="http://meta.wikimedia.org/wiki/Help:Contents">User's Guide</a> for information on using the wiki software.
Getting started
- <a href="http://www.mediawiki.org/wiki/Manual:Configuration_settings">Configuration settings list</a>
- <a href="http://www.mediawiki.org/wiki/Manual:FAQ">MediaWiki FAQ</a>
- <a href="http://lists.wikimedia.org/mailman/listinfo/mediawiki-announce">MediaWiki release mailing list</a>

