About BhashaIndia | Contribute | SiteMap | Register | Sign in to Windows Live ID
  Developers Patrons
Hindi Tamil Kannada Gujarati Marathi Telugu Bengali Malayalam Punjabi Konkani Oriya Sanskrit Nepali
Home > Developers > KnowHow > Glyph > OpenType Layout Services Welcome Guest!

OpenType Layout Services (OTLS)

The OTLS library is a set of helper functions that serve a text processing client by retrieving information from fonts and guiding the operating system in rendering text. The client and OTLS work together to layout text, using some, all or none of the OpenType Layout features defined within a font, as decided by the application developer. The client can use OTLS functions to query a font about what layout feature it supports and with what script and language systems they are associated.

Using this information, the client can implement required features for specific scripts and present other features to users. An application may tightly integrate specific features into its UI, associating one or more OpenType features with formatting options or may present the features dynamically as they are returned from individual fonts.

Many of the OTLS functions need to be applied to 'runs' of text, and one of the basic responsibilities of a client using OTLS is the ability to parse and tag runs. A run is normally a maximum of one line in length and consists of a text string formatted in a single font at a particular size, in a single direction, in a particular script and a particular language system. Obviously, in many documents, the majority of consecutive runs of text will simply equate to individual lines.

In multilingual documents, however, a client may need to be able to identify and tag a number of runs within a single line of text. In the example below, two lines of bilingual text need to be separated into eight runs. At the top of the illustration, the two lines appear with formatting; the same lines appear as Unicode plain text, with the formatting runs indicated in red. Lastly, the Unicode codepoints stored by the application are shown, also with runs marked in red, which makes clear exactly where one run ends and another begins (punctuation characters are dark grey, and space characters are light grey).

In this example, there are three types of run boundary, indicated by the small red letters:

  • Change of font (bold to roman, roman to italic, italic to roman).
  • Change of script, language system and direction. Any one of these changes is sufficient to require the start of a new run. In many multilingual texts, a change of script might also occasion a change in font, but for this example we will presume that this is a multiscript font with both Latin and Arabic support.
  • End of line (the end of the first line is also a change in script, language system and direction, because the second line starts with an Arabic character).

When runs have been identified and tagged, OTLS text layout functions can be used to implement glyph substitution and glyph positioning in individual runs. OpenType features are never applied across run boundaries; the run is the basic element to which glyph processing is applied, although, for complex scripts, it is necessary to further divide the run into smaller segments.

OTLS is designed to expose the full functionality of OpenType fonts to an application, so it is a powerful assistant in implementing support for even the most complicated aspects of Windows glyph processing: for instance, GSUB layout features that are designed to present the user with a choice of variant glyphs. OTLS supports these features by enabling clients to specify features with parameters to enumerate possible substitutions. In response to, for example, a user's application of the 'Stylistic Alternates' feature (using GSUB lookup type 3, replacing one glyph with one of many), the application would call OTLS repeatedly until the possible parameters for that feature— i.e. the number of possible glyphs to be substituted—were exhausted. The application would record the resulting glyph alternates and present them to the user. In the image below, a user wants to replace a particular occurrence of the letter e with a stylistic variant. The application has called OTLS to query the font, and has found that there are eight variant glyphs available (including the normative glyph); these variants are presented to the user in a simple pop-up menu.

In addition to parsing and tagging runs, an OTLS client remains responsible for line breaking, layout direction and justification, and for memory allocation.

Partner Profile | Privacy Statement | Why Passport | Testimonials
This site uses Unicode for non-English characters and uses Open Type fonts.
©2003-2007 Microsoft Corporation. All rights reserved.