opentype math illuminated

Upload: terminatory808

Post on 06-Apr-2018

214 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/3/2019 OpenType Math Illuminated

    1/10

    12 MAPS 38 Ulrik Vieth

    OpenType Math Illuminated

    AbstractIn recent years, we have seen the development of newTEX engines, X ETEX and LuaTEX, adopting OpenTypefont technology for providing Unicode typesettingsupport. While there are already plenty of OpenTypetext fonts available for use, both from the TEXcommunity and from commercial font suppliers, thereis little support for OpenType math fonts so far.Ironically, it was left to Microsoft to develop a de factostandard for OpenType math font information and toprovide the first reference implementation of afull-featured OpenType math font.

    In order to develop the much-needed math support forLatin Modern and TEX Gyre fonts, it will be cruciallyimportant to develop a good understanding of theinternals of OpenType math tables, much as it isnecessary to develop a good understanding ofAppendix G and TEXs \fontdimen parameters todevelop math support for traditional TEX fonts. In thispaper, we try to help improve the understanding ofOpenType math internals, summarizing the parametersof OpenType math fonts as well as illustrating thesimilarities and differences between traditional TEXmath fonts and OpenType math fonts.

    Background on OpenType mathIn recent years, the TE X community has been go-ing through a phase of very significant developments.

    Among the most important achievements, we haveseen the development of new TEX engines, X ETEX andLuaTEX, providing support for Unicode and OpenTypefont technology. At about the same time we havealso seen the development of new font distributions,Latin Modern and TEX Gyre, provided simultaneouslyin Type 1 format as a set of 8-bit font encodings as wellas in OpenType format.

    Together these developments have enabled TEXusers to keep up with current trends in the publish-

    ing industry, providing users of the new TE X engineswith a comprehensive set of free OpenType fonts andenabling them to take advantage of the many offeringsby commercial font suppliers.

    As far as text typesetting is concerned, support forOpenType font technology in the new TEX engines is al-ready very advanced, supporting not only traditionaltypographic features of Latin alphabets, but also ad-

    dressing the very complex and challenging require-ments of Arabic typography.

    However, when it comes to math typesetting, oneof the traditional strongholds of TEX, support for Uni-code and OpenType math is only just beginning to takeshape.

    Ironically, it was left to Microsoft to develop the firstsystem to offer support for Unicode math. When Mi-crosoft introduced support for math typesetting in Of-fice 2007 [1, 2], they extended the OpenType font for-mat and commissioned the design of Cambria Math [3]as a reference implementation of a full-featured Open-

    Type math font.Fortunately for us, Microsoft was smart enough to

    borrow from the best examples of math typesettingtechnology, thus many concepts of OpenType math arenot only derived from the model of TEX, but also go be-

    yond TEX and introduce extensions or generalizationsof familiar concepts.

    While OpenType math is officially still consideredexperimental, it is quickly becoming a de facto stan-dard, as it has already been widely deployed to mil-lions of installations of Microsoft Office 2007 and it isalso being been adopted by other projects such as theFontForge [4] font editor or independent font designs

    such as Asana Math [5].Most importantly, support for OpenType math hasalready been implemented or is currently being imple-mented in the new TEX engines, thus adopting Open-Type math for the development of the much-neededUnicode math support for Latin Modern and TEX Gyreobviously seems to be most promising choice of tech-nology.

    Design and quality of math fonts

    When it comes to developing math fonts, designingthe glyph shapes is only part of the job. Another part,

    which is equally important, is to adjust the glyph met-rics of individual glyphs and to set up the global pa-rameters affecting various aspects of glyph positioningin math typesetting.

    As we have discussed at previous conferences, thequality of math typesetting crucially depends on thefine-tuning of these parameters. Developing a goodunderstanding of these parameters will therefore be-

  • 8/3/2019 OpenType Math Illuminated

    2/10

    OpenType Math Illuminated VOORJAAR 2009 1

    come an important prerequisite to support the devel-opment of new math fonts.

    In the case of traditional TEX math fonts, we haveto deal with the many\fontdimen parameters whichhave been analyzed in Bogusaw Jackowskis paper

    Appendix G Illuminated and a follow-up paper by the

    present author [6, 7].In the case of OpenType math fonts, we need to de-velop a similar understanding of the various tables andparameters and how the concepts of OpenType mathrelate to the concepts of TEX.

    Overview of the OpenType font format

    The OpenType font format [8] was developed jointlyby Adobe and Microsoft, based on elements of the ear-lier PostScript and TrueType font formats by the same

    vendors. The overall structure of OpenType fonts con-sists of a number of tables, some of which are required

    while others are optional [9].

    In the case of OpenType math, the extension of thefont format essentially consists of adding another op-tional table, the so-called MATH table, containing allthe information related to math typesetting. Since itis an optional table, it would be interpreted only bysoftware which knows about it (such as the new TEXengines or Microsoft Office 2007), while it would beignored by other software.

    Unlike a database table, which has a very rigid for-mat, an OpenType font table can have a fairly com-plex structure, combining a variety of different kindsof information in the same table. In the case of theOpenType MATH table, we have the following kinds of

    information:

    a number of global parameters specific to mathtypesetting (similar to TE Xs many\fontdimenparameters of Appendix G)

    instructions for vertical and horizontal variantsand/or constructions (similar to TEXs charlists andextensible recipes)

    additional glyph metric information specific tomath mode (such as italic corrections, accentplacement, or kerning)

    In the following sections, we will discuss some ofthese parameters in more detail, illustrating the simi-

    larities and differences between traditional TEX mathfonts and OpenType math fonts.

    Parameters of OpenType math fonts

    The parameters of the OpenType MATH table play asimilar role as TEXs \fontdimen parameters, control-ling various aspects of math typesetting, such as the

    placement of limits on big operators, the placementof numerators and denominators in fractions, or theplacement of superscripts and subscripts.

    While a number of parameters are specified in TEXthrough the \fontdimen parameters of math fonts,there are other parameters which are defined by built-

    inrules ofTEXs math typesetting engine. In many suchcases, additional parameters have been introduced inthe OpenType MATH table, making it possible to specifyall the relevant parameters in the math font withoutrelying on built-in rules of any particular typesettingengine.

    In view of the conference motto, it is interestingto note that the two new TE X engines, X ETE X andLuaTEX, have taken a very different approach how tosupport the additional parameters of OpenType mathfonts: While X ETE X has retained TEXs original mathtypesetting engine and uses an internal mapping toset up \fontdimen parameters from OpenType para-meters [10], LuaTE X has introduced an extension of

    TEXs math typesetting engine [11], which will allowto take full advantage of most of the additional Open-Type parameters. (More precisely, while X ETE X onlyprovides access to the OpenType parameters as ad-ditional \fontdimens, LuaTE X uses an internal datastructure based on the combined set of OpenType andTEX parameters, making it possible to supply missing values which are not supported in either OpenTypemath fonts or traditional TEX math fonts.)

    For font designers developing OpenType math fonts,it may be best to supply all of the additional OpenTypeparameters in order to make their fonts as widely us-able as possible with any typesetting engine, not nec-

    essarily limited to any specific one of the new TEX en-gines.In the following sections, we will take a closer look

    at the various groups of OpenType parameters, orga-nized in a similar way as they are presented to fontdesigners in the FontForge font editor, but not neces-sarily in the same order.

    We will use the figures from [6, 7] as a visual clueto illustrate how the various parameters are definedin TE X, while summarizing the similarities and differ-ences between OpenType parameters and TEX parame-ters in tabular form.

    Limits on big operators

    In TEX math fonts, there are five parameters controllingthe placement of limits on big operators (see figure 1),

    which are denoted as 9 to 13 using the notation ofAppendix G.

    Two of them control the default position of the limits(10 and 12), two of them control the inside gap (9and 11), while the final one controls the outside gapabove and below the limits (13).

  • 8/3/2019 OpenType Math Illuminated

    3/10

    14 MAPS 38 Ulrik Vieth

    Q

    M=1

    /2

    /2

    13

    911

    10

    12

    13

    Figure 1. TEX font metric parameters affecting theplacement of limits above or below big operators.

    In OpenType math fonts, the MATH table containsonly four parameters controlling the placement of lim-its on big operators. Those four parameters have adirect correspondence to TE Xs parameters (as shownin table 1), while the remaining one has no corre-spondence and is effectively set to zero. (Consider-ing the approach taken in other circumstances, it is

    very likely that if there were any such correspondence,there might actually be two parameters in OpenTypeinstead of only one, such as UpperLimitExtraAscender andLowerLimitExtraDescender . In LuaTEXs internal data struc-tures, there are actually two parameters for this pur-pose, which are either initialized from TEXs parameter13 when using TEX math fonts or set to zero when us-ing OpenType math fonts.)

    OpenType parameter TEX parameter

    UpperLimitBaselineRiseMin 11UpperLimitGapMin 9

    LowerLimitGapMin 10LowerLimitBaselineDropMin 12

    (no correspondence) 13

    Table 1. Correspondence of font metric parametersbetween OpenType and TEX affecting the placement oflimits above or below big operators.

    OpenType parameter TEX parameter

    StretchStackTopShiftUp 11StretchStackGapAboveMin 9StretchStackGapBelowMin 10StretchStackBottomShiftDown 12

    Table 2. Correspondence of font metric parametersbetween OpenType and TEX related to stretch stacks.

    Stretch StacksStretch stacks are a new feature in OpenType mathfonts, which do not have a direct correspondence inTE X. They can be understood in terms of materialstacked above or below stretchable elements such asoverbraces, underbraces or long arrows.

    In TEX, such elements were typically handled at themacro level and effectively treated in the same way aslimits on big operators.

    In LuaTEX, such elements will be implemented bynew primitives using either the new OpenType para-meters for stretch stacks (as shown in table 2) or theparameters for limits on big operators when using tra-ditional TEX math fonts.

    Overbars and UnderbarsIn TEX math fonts, there are no specific parameters re-lated to the placement of overlines and underlines. In-stead, there is only one parameter controlling the de-fault rule thickness (8), which is used in a numberof different situations where other parameters are ex-pressed in multiples of the rule thickness.

    In OpenType math fonts, a different approach wastaken, introducing extra parameters for each purpose,even supporting different sets of parameters for over-lines and underlines. Thus the MATH table contains thefollowing parameters related to overlines and under-lines (as shown in table 3), which only have an indirectcorrespondence in TEX.

    OpenType parameter TEX parameter

    OverbarExtraAscender (= 8)OverbarRuleThickness (= 8)OverbarVerticalGap (= 3 8)

    UnderbarVerticalGap (= 3 8)UnderbarRuleThickness (= 8)UnderbarExtraDescender (= 8)

    Table 3. Correspondence of font metric parametersbetween OpenType and TEX affecting the placement ofoverlines and underlines.

  • 8/3/2019 OpenType Math Illuminated

    4/10

    OpenType Math Illuminated VOORJAAR 2009 1

    8 styles D,D

    9 other styles

    11 styles D,D

    12 other styles

    8 styles D,D

    10 other styles

    11 styles D,D

    12 other styles

    Figure 2. TEX font metric parameters affecting theplacement of numerators and denominators in regular andgeneralized fractions.

    It is interesting to note that the introduction of ad-ditional parameters in OpenType math fonts providesfor greater flexibility of the font designer to adjust the

    values for best results.While TEXs built-in rules always use a fixed multi-

    plier of the rule thickness regardless of its size, Open-Type math fonts can compensate for a larger rule thick-

    ness by using a smaller multiplier.An example can be found when inspecting the pa-rameter values of Cambria Math: In relative terms theinside gap is only about 2.5 times rather than 3 timesthe rule thickness, while the latter (at about 0.65 ptcompared to 0.4 pt) is quite a bit larger than in typicalTEX fonts.

    Obviously, making use of the individual OpenTypeparameters (as in LuaTEX) instead of relying on TEXsbuilt-in rules (as in X ETEX) would more closely reflectthe intention of the font designer.

    Fractions and Stacks

    In TEX math fonts, there are five parameters controllingthe placement of numerators and denominators (seefigure 2), which are denoted as 8 to 12 using thenotation of Appendix G.

    Four of them apply to regular fractions, either in dis-play style (8 and 11) or in text style and below (9and 12), while the remaining one applies to the spe-cial case of generalized fractions when the fraction baris absent (10).

    Besides those specific parameters, there are alsoa number of parameters which are based on built-inrules of TE Xs math typesetting engine, expressed inmultiples of the rule thickness (8), such as the thick-

    ness of the fraction rule or the inside gap above andbelow the fraction rule (see figure 3).In OpenType math fonts, a different approach was

    once again taken, introducing a considerable numberof additional parameters for each purpose. Thus theMATH table contains 9 parameters related to regularfractions and 6 more parameters related to generalizedfractions (also known as stacks).

    38 styles D,D

    8 other styles 78 styles D,D

    38 other styles

    Figure 3. TEXs b oundary conditions affecting theplacement of numerators and denominators in regular andgeneralized fractions.

    As shown in table 4, there is a correspondence forall TE X parameters, but this correspondence isnt neces-sarily unique when the same TEX parameter is used formultiple purposes in fractions and stacks. Obviously,font designers of OpenType math fonts should be care-ful about choosing the values of OpenType parametersin a consistent way.

    Analyzing the font parameters of Cambria Mathonce again shows how the introduction of additionalparameters increases the flexibility of the designerto adjust the parameters for best results: In relativeterms, FractionDisplayStyleGapMin is only about 2 timesrather than 3 times the rule thickness. Similarly,StackDisplayStyleGapMinis only about 4.5 times rather than7 times the rule thickness. In absolute terms, however,both parameters are about the same order of magni-tude as in typical TEX fonts.

    OpenType parameter TEX parameter

    FractionNumeratorDisplayStyleShiftUp 8FractionNumeratorShiftUp 9FractionNumeratorDisplayStyleGapMin (= 3 8)FractionNumeratorGapMin (= 8)FractionRuleThickness (= 8)FractionDenominatorDisplayStyleGapMin (= 3 8)FractionDenominatorGapMin (= 8)FractionDenominatorDisplayStyleShiftDown 11FractionDenominatorShiftDown 12

    StackTopDisplayStyleShiftUp 8StackTopShiftUp 10

    StackDisplayStyleGapMin (= 7 8)StackGapMin (= 3 8)StackBottomDisplayStyleShiftDown 11StackBottomShiftDown 12

    Table 4. Correspondence of font metric parametersbetween OpenType and TEX affecting the placement ofnumerators and denominators.

  • 8/3/2019 OpenType Math Illuminated

    5/10

    16 MAPS 38 Ulrik Vieth

    131415

    1617

    18

    19

    Figure 4. TEX font metric parameters affecting theplacement of superscripts and subscripts on a simplecharacter or a boxed subformula.

    Superscripts and SubscriptsIn TEX math fonts, there are seven parameters control-ling the placement of superscripts and subscripts (seefigure 4), which are denoted as 13 to 19 using thenotation of Appendix G.

    Three of them apply to superscripts, either in dis-play style (13), in text style and below (14), or incramped style (15), while the other two apply to theplacement of subscripts, either with or without a su-perscript (16 and 17).

    Finally, there are two more parameters which applyto superscripts and subscripts on a boxed subformula

    (

    18 and

    19), which also apply to limits attached tobig operators with \nolimits.Besides those specific parameters, there are also a

    number of parameters which are based on TEXs built-in rules, expressed in multiples of the x-height (5) orthe rule thickness (8), most of them related to resolv-ing collisions between superscripts and subscripts oradjusting the position when a superscript or subscriptbecomes too big (see figure 5).

    In OpenType math fonts, we once again find a num-ber of additional parameters for each specific purpose,as shown in table 5.

    It is interesting to note that some of the usual dis-tinctions made in TEX were apparently omitted in the

    OpenType MATH table, as there is no specific value forthe superscript position in display style, nor are thereany differences in subscript position in the presence orabsence of superscripts.

    While it is not clear why there is no correspondencefor these parameters, it is quite possible that there wasa conscious design decision to omit them, perhaps toavoid inconsistencies in alignment.

    1

    45

    4

    55

    48 484

    55

    Figure 5. TEX font metric parameters affecting the

    placement of superscripts and subscripts in cases ofresolving collisions.

    Op enType parameter TEX parameter

    SuperscriptShiftUp 13, 14SuperscriptShiftUpCramped 15SubscriptShiftDown 16, 17

    SuperscriptBaselineDropMax 18SubscriptBaselineDropMin 19

    SuperscriptBottomMin (= 145)

    SubscriptTopMax (= 455)SubSuperscriptGapMin (= 4 8)SuperscriptBottomMaxWithSubscript (= 4

    55)

    SpaceAfterScript \scriptspace

    Table 5. Correspondence of font metric parametersbetween OpenType and TEX affecting the placement ofsuperscripts and subscripts.

    RadicalsIn TE X math fonts, there are no specific parametersrelated to typesetting radicals. Instead, the relevant

    parameters are based on built-in rules of TEXs mathtypesetting engine, expressed in multiples of the rulethickness (8) or the x-height (5).

    To be precise, there are even more complications in-volved [6], as the height of the fraction rule is actuallytaken from the height of the fraction glyph rather thanthe default rule thickness to account for effects of pixelrounding in bitmap fonts.

  • 8/3/2019 OpenType Math Illuminated

    6/10

    OpenType Math Illuminated VOORJAAR 2009 1

    OpenType parameter TEX parameter

    RadicalExtraAscender (= 8)RadicalRuleThickness (= 8)RadicalDisplayStyleVerticalGap (= 8 +

    145)

    RadicalVerticalGap (= 8+

    1

    4

    8)

    RadicalKernBeforeDegree e.g. 518

    em

    RadicalKernAfterDegree e.g. 1018

    em

    RadicalDegreeBottomRaisePercent e.g. 60 %

    Table 6. Correspondence of font metric parametersbetween OpenType and TEX affecting the placement ofradicals.

    In OpenType math fonts, we once again find anumber of additional parameters for each purpose, asshown in table 6.

    While there is a correspondence for all of the pa-rameters built into TEXs typesetting algorithms, it is

    interesting to note that OpenType math has also intro-duced some additional parameters related to the place-ment of the degree of an n th root ( n

    x ), which is

    usually handled at the macro level in TEXs format filesplain.tex or latex.ltx:

    \newbox\rootbox

    \def\root#1\of{%

    \setbox\rootbox

    \hbox{$\m@th\scriptscriptstyle{#1}$}%

    \mathpalette\r@@t}

    \def\r@@t#1#2{%

    \setbox\z@\hbox{$\m@th#1\sqrtsign{#2}$}%

    \dimen@=\ht\z@ \advance\dimen@-\dp\z@

    \mkern5mu\raise.6\dimen@\copy\rootbox\mkern-10mu\box\z@}

    As shown in the listing, the definition of the \rootmacro contains a number of hard-coded parameters,such as a positive kern before the box containing thedegree and negative kern thereafter, expressed in mul-tiples of the font-specific math unit. In addition, thereis also a raise factor expressed relative to the size ofthe box containing the radical sign.

    Obviously, the extra OpenType parameters relatedto the degree of radicals correspond directly to the pa-rameters used internally in the\rootmacro, making itpossible to supply a set of font-specific values instead

    of using hard-coded values expressed in multiples offont-specific units.In LuaTE X, this approach has been taken one step

    further, introducing a new \Uroot primitive as an ex-tension of the \Uradical primitive, making it possibleto replace the processing at the macro level by process-ing at the algorithmic level in LuaTEXs extended mathtypesetting engine [11].

    OpenType parameter TEX parameter

    ScriptPercentScaleDown e.g. 7080 %

    ScriptScriptPercentScaleDown e.g. 5060 %

    DisplayOperatorMinHeight ?? (e. g. 1215 pt)

    (no correspondence) 20 (e. g. 2024 pt)DelimitedSubFormulaMinHeight 21 (e. g. 1012 pt)

    AxisHeight 22 (axis height)

    AccentBaseHeight 5 (x-height)

    FlattenedAccentBaseHeight ?? (capital height)

    Table 7. Correspondence of font metric parametersbetween OpenType and TEX affecting some generalaspects of math typesetting.

    General parametersThe final group of OpenType parameters combines amixed bag of parameters for various purposes. Someof them have a straight-forward correspondence in TEX(such as the math axis position), while others do nothave any correspondence at all. As shown in table 7,there are some very noteworthy parameters in thisgroup, which deserve some further explanations in thefollowing paragraphs.

    (Script)ScriptPercentScaleDown.These OpenType parameters represent the font sizesof the first and second level script fonts relative to thebase font. In TEX math fonts, these parameters do nothave a correspondence in the font metrics. Insteadthey are usually specified at the macro level when a

    family of math fonts is loaded.If a font family provides multiple design sizes (as in

    Computer Modern), font loading of math fonts in TEXmight look like the following, using different designsizes, each at their natural size:

    \newfam\symbols

    \textfont\symbols=cmsy10

    \scriptfont\symbols=cmsy7

    \scriptscriptfont\symbols=cmsy5

    If a font family does not provide multiple designsizes (as in MathTime), font loading of math fonts willuse scaled-down versions of the base font:

    \newfam\symbols

    \textfont\symbols=mtsy10 at 10pt\scriptfont\symbols=mtsy10 at 7.6pt

    \scriptscriptfont\symbols=mtsy10 at 6pt

    The appropriate scaling factors depend on the fontdesign, but are usually defined in macro packagesor in format files using higher-level macros such as\DeclareMathSizes in LaTEX.

  • 8/3/2019 OpenType Math Illuminated

    7/10

    18 MAPS 38 Ulrik Vieth

    In OpenType math fonts, it will be possible to pack-age optical design variants for script sizes into a singlefont by using OpenType feature selectors to address thedesign variants and using scaling factors as specified inthe MATH table. (As discussed in [12], there are manyissues to consider regarding the development of Open-

    Type math fonts besides setting up the font parameters.One such issue is the question of font organization re-garding the inclusion of optical design variants into thebase font.)

    The corresponding code for font loading of full-featured OpenType math fonts in new TE X enginesmight look like the following:

    \newfam\symbols

    \textfont\symbols="CambriaMath"

    \scriptfont\symbols="CambriaMath:+ssty0"

    scaled

    \scriptscriptfont\symbols="CambriaMath:+ssty1"

    scaled

    If the font provides optical design variants for someletters and symbols, they will be substituted using the+ssty0 or +ssty1 feature selectors, but the scalingfactor of (Script)ScriptPercentScaleDown will be applied inany case regardless of substitutions.

    DisplayOperatorMinHeight.This OpenType parameter represents the minimumsize of big operators in display style. While TEX onlysupports two sizes of operators, which are used in textstyle and display style, OpenType can support multiplesizes of big operators and it needs an additional para-meter to determine the smallest size to use in displaystyle.

    For font designers, it should be easy to set this pa-rameter based on the design size of big operators, e. g.using 14 pt for display style operators combined with10 pt for text style operators.

    DelimitedSubFormulaMinHeight.This OpenType parameter represents the minimumsize of delimited subformulas and it might also be ap-plied to the special case of delimited fractions.

    To illustrate the significance, some explanationsmay be necessary to point out the difference betweenthe usual case of fractions with delimiters and the spe-cial case of delimited fractions.

    If a generalized fraction with delimiters is coded likethe following

    $ \left( {n \atop k} \right) $

    the contents will be treated as a standard case of ageneralized fraction, and the size of delimiters willbe determined by taking into account the effects of\delimiterfactor and \delimitershortfall as

    set up in the format file.As a result, we will typically get 10 pt or 12 pt de-

    limiters in text style and 18 pt or 24 pt delimiters indisplay style. For typical settings, the delimiters onlyhave to cover 90 % of the required size and they mayfall short by at most 5 pt.

    If a generalized fraction with delimiters is coded likethe following

    $ {n \atopwithdelims() k} $

    the contents will be treated as a delimited fraction, andin this case the size of delimiters will depend on the\fontdimen parameters 20 and 21 applicable in ei-ther display style or text style.

    As a result, regardless of the contents, we will al-ways get 10 pt delimiters in text style and 24 pt delim-iters in display style, even if 18 pt delimiters would bebig enough in the standard case.

    While DelimitedSubFormulaMinHeight may be the bestchoice of OpenType parameters to supply a value

    for TEXs \fontdimen parameters related to delimitedfractions, it will be insufficient by itself to represent adistinction between display style and text style valuesneeded in TE X. (Unless we simply assume a factor, suchas 20 = 221.)

    In the absence of a better solution, it may be best tosimply avoid using \atopwithdelimswith OpenTypemath fonts in the new TEX engines and to redefine user-level macros (such as \choose) in terms of\left and\right delimiters.

    (Flattened)AccentBaseHeight.These OpenType parameters affect the placement ofmath accents and are closely related to design para-

    meters of the font design.While TEX assumes that accents are designed to fit

    on top of base glyphs which do not exceed the x-height(5) and adjusts the vertical position of accents accord-ingly, OpenType provides a separate parameter for thispurpose, which doesnt have to match the x-height ofthe font, but plays a similar role with respect to accentplacement.

    In addition to that, OpenType has introduced an-other mechanism to replace accents by flattened ac-cents if the size of the base glyph exceeds a certainsize, which is most likely related to the height of cap-ital letters. At the time of writing, support for flat-

    tened accents has not yet been implemented in the newTEX engines, but it is being considered for LuaTEX ver-sion 0.40 [11].

    In view of these developments, font designers arewell advised to supply a complete set of values for allthe OpenType math parameters since new TEX engines

    working on implementing full support for OpenTypemath may start using them sooner rather than later.

  • 8/3/2019 OpenType Math Illuminated

    8/10

    OpenType Math Illuminated VOORJAAR 2009 1

    So far, we have discussed only one aspect of the in-formation contained in the OpenType MATH table, fo-cusing on the global parameters which correspond toTEXs \fontdimen parameters or to built-in rules ofTEXs math typesetting algorithms.

    Besides those global parameters, there are other

    data structures in the OpenType MATH table, which arealso important to consider, as we will discuss in the fol-lowing sections.

    Instructions for vertical and horizontalvariants and constructions

    The concepts of vertical and horizontal variants andconstructions in OpenType math are obviously verysimilar to TE Xs concepts of charlists and extensiblerecipes. However, there are some subtle differencesregarding when and how these concepts are appliedin the math typesetting algorithms.

    In TEX, charlists and extensible recipes are only used

    in certain situations when typesetting elements suchas big operators, big delimiters, big radicals or wideaccents. In OpenType math fonts, these concepts havebeen extended and generalized, allowing them to beused also for other stretchable elements such as longarrows or over- and underbraces.

    Vertical variants and constructions Big delimiters. When typesetting big delimiters orradicals TEX uses charlists to switch to the next-larger

    vertical variants, optionally followed by extensiblerecipes for vertical constructions. In OpenType math,these concepts apply in the same way.

    It is customary to provide at least four fixed-sizevariants, using a progression of sizes such as 12 pt,18 pt, 24 pt, 30 pt, before switching to an extensible version, but there is no requirement for that other thancompatibility and user expectations. (At the macrolevel these sizes can be accessed by using \big (12 pt),\Big (18 pt), \bigg (24 pt), \Bigg (30 pt).)

    Font designers are free to provide any number of ad-ditional or intermediate sizes, but in TEX they used tobe limited by constraints such as 256 glyphs per 8-bitfont table and no more than 16 different heights anddepths in TF M files. In OpenType math fonts, they areno longer subject to such restrictions, and in the ex-ample of Cambria Math big delimiters are indeed pro-

    vided in seven sizes.

    Big operators. When typesetting big operators TEXuses the charlist mechanism to switch from text styleto display style operators, but only once. There is nosupport for multiple sizes of display operators, nor arethere extensible versions.

    In OpenType math, these concepts have been ex-tended, so it would be possible to have multiple sizesof display style operators as well as extensible versionsof operators, if desired.

    While LuaTEX has already implemented most of thenew features of OpenType math, it has not yet ad-

    dressed additional sizes of big operators, and it is notclear how that would be done.Most likely, this would require some changes to the

    semantics of math markup at the user level, so that op-erators would be defined to apply to a scope of a sub-formula, which could then be measured to determinethe required size of operators.

    In addition, such a change might also requireadding new parameters to decide when an opera-tor is big enough, similar to the role of the parame-ters \delimiterfactor and \delimitershortfallin the case of big delimiters.

    Horizontal variants and constructions

    Wide accents. When typesetting wide math accentsTEX uses charlists to switch to the next-larger horizon-tal variants, but it doesnt support extensible recipesfor horizontal constructions.

    As a result, math accents in traditional TE X fontscannot grow beyond a certain maximum size, andstretchable horizontal elements of arbitrary size haveto be implemented using other mechanisms, such asalignments at the macro level.

    In OpenType math, these concepts have been ex-tended, making it possible to introduce extensible ver-sions of wide math accents (or similar elements), ifdesired. In addition, new mechanisms for bottom ac-

    cents have also been added, complementing the exist-ing mechanisms for top accents.

    Over- and underbraces. When typesetting somestretchable elements such as over- and underbraces,TEX uses an alignment construction at the macro levelto get an extensible brace of the required size, whichis then typeset as a math operator with upper or lowerlimits attached.

    While it would be possible to define extensible over-and underbraces in OpenType math fonts as extensible

    versions of math accents, the semantics of math ac-cents arent well suited to handle upper or lower limitsattached to those elements.

    In LuaTEX, new primitives \Uoverdelimiter and\Uunderdelimiter have been added as a new con-cept to represent stretchable horizontal elements

    which may have upper or lower limits attached. Theplacement of these limits is handled similar to limitson big operators in terms of so-called stretch stacksas discussed earlier in section .

  • 8/3/2019 OpenType Math Illuminated

    9/10

    20 MAPS 38 Ulrik Vieth

    Long arrows. In TEX math fonts, long horizontal ar-rows are constructed at the macro level by overlappingthe glyphs of short arrows and suitable extension mod-ules (such as or=). Similarly, arrows with hooks ortails are constructed by overlapping the glyphs of reg-ular arrows and suitable glyphs for the hooks or tails.

    In OpenType math fonts, all such constructions canbe defined at the font level in terms of horizontal con-structions rather than relying on the macro level. How-ever, in most cases such constructions will also containan extensible part, making the resulting long arrowsstrechable as well.

    In LuaTEX, stretchable long arrows can also be de-fined using the new primitives \Uoverdelimiter asdiscussed in the case of over- and underbraces. Theplacement of limits on such elements more or less cor-responds to using macros such as \stackrel to stacktext on top of a relation symbol.

    Encoding of variants and constructionsIn traditional TEX math fonts, glyphs are addressed bya slot number in a font-specific output encoding. Each

    variant glyph in a charlist and each building block inan extensible recipe needs to have a slot of its own inthe font table. However, only the entry points to thecharlists need to be encoded at the macro level andthese entry points in a font-specific input encoding donot even have to coincide with the slot numbers in theoutput encoding.

    In OpenType math fonts, the situation is somewhatdifferent. The underlying input encoding is assumed toconsist of Unicode characters. However these Unicodecodes are internally mapped to font programs usingglyph names, which can be either symbolic (such assummation or integral) or purely technical (such asuni2345 or glyph3456).

    With few exceptions, most of the variant glyphs andbuilding blocks cannot be allocated in standard Uni-code slots, so these glyphs have to be mapped to theprivate use area with font-specific glyph names. InCambria Math, variant glyphs use suffix names (suchas glyph.vsize or glyph.hsize), while otherfonts such as Asana Math use different names (suchas glyphbig or glyphwide).

    For font designers developing OpenType math fonts,setting up vertical or horizontal variants is pretty

    straight-forward, such assummation: summation.vsize1 summation.vsize2 ...

    integral : integral.vsize1 integral.vsize2 ...

    or

    tildecomb: tildecomb.hsize1 tildecomb.hsize2

    provided that the variant glyphs use suffix names.Setting up vertical or horizontal constructions is

    slightly more complicated, as it also requires some ad-ditional information which pieces are of fixed size and

    which are extensible, such as

    integral : integralbt:0 uni23AE:1 integraltp:0

    or

    arrowboth :

    arrowleft.left:0 uni23AF:1 arrowright.right:0

    It is interesting to note that some of the buildingblocks (such as uni23AE or uni23AF) have Unicodeslots by themselves, while others have to placed in theprivate use area, using private glyph names such asglyph.left, glyph.mid, or glyph.right.

    Moreover, vertical or horizontal constructions mayalso contain multiple extensible parts, such as in theexample of over- and underbraces, where the left, mid-dle, and right parts are of fixed size while the extensi-ble part appears twice on either side.

    Additional glyph metric informationBesides the global parameters and the instructionsfor vertical and horizontal variants and constructions,there is yet another kind of information stored in theOpenType MATH table, containing additions to the fontmetrics of individual glyphs.

    In traditional TEX math fonts, the file format of TF Mfonts only provides a limited number of fields to storefont metric information. As a workaround, certainfields which are needed in math mode only are storedin rather non-intuitive way by overloading fields forother purposes [13].

    For example, the nominal width of a glyph is used tostore the subscript position, while the italic correctionis used to indicate the horizontal offset between thesubscript and superscript position.

    As a result, the nominal width doesnt represent theactual width of the glyph and the accent position mayturn out incorrect. As a secondary correction, fakekern pairs with a so-called skewchar are used to storean offset to the accent position.

    In OpenType math fonts, all such non-intuitive waysof storing information can be avoided by using addi-tional data fields for glyph-specific font metric infor-mation in the MATH table.

    For example, the horizontal offset of the optical cen-ter of a glyph is stored in a top_accent table, so any

    adjustments to the placement of math accents can beexpressed in a straight-forward way instead of relyingon kern pairs with a skewchar.

    Similarly, the italic correction is no longer used forthe offset between superscripts and subscripts. In-stead, the position of indices can be expressed morespecifically in a math_kern array, representing cut-insat each corner of the glyphs.

  • 8/3/2019 OpenType Math Illuminated

    10/10

    OpenType Math Illuminated VOORJAAR 2009 2

    Summary and conclusions

    In this paper, we have tried to help improve the un-derstanding of the internals of OpenType math fonts.We have done this in order to contribute to the much-needed development of math support for Latin Modernand TEX Gyre fonts.

    In the previous sections, we have discussed the pa-rameters of the OpenType MATH table in great detail,illustrating the similarities and differences betweentraditional TEX math fonts and OpenType math fonts.However, we have covered other aspects of OpenTypemath fonts only superficially, as it is impossible to covereverything in one paper.

    For a more extensive overview of the features andfunctionality of OpenType math fonts as well as a dis-cussion of the resulting challenges to font developers,readers are also referred to [12].

    In view of the conference motto, it is interestingto note that recent versions of LuaTEX have started to

    provide a full-featured implementation of OpenTypemath support in LuaTEX and Context [14, 15], whichdiffers significantly from the implementation of Open-Type math support in X ETE X [10]. In this paper, wehave pointed out some of these differences, but fur-ther discussions of this topic are beyond of the scopeof this paper.

    Acknowledgments

    The author once again wishes to thank Bogusaw Jack-owski for permission to reproduce and adapt the fig-ures from his paper Appendix G Illuminated [6]. Inaddition, the author also wishes to acknowledge feed-

    back and suggestions from Taco Hoekwater and HansHagen regarding the state of OpenType math supportin LuaTEX.

    References

    [ 1 ] Murray Sargent II I: Math in Office Blog.http://blogs.msdn.com/murrays/default.

    aspx

    [ 2 ] Murray Sargent II I: High-quality editing anddisplay of mathematical text in Office 2007.http://blogs.msdn.com/murrays/archive/

    2006/09/13/752206.aspx

    [ 3 ] John Hudson, Ross Mills: Mathematical Type-setting: Mathematical and scientific typesettingsolutions from Microsoft. Promotional Booklet,Microsoft, 2006.http://www.tiro.com/projects/

    [ 4 ] George Williams: FontForge. Math typesettinginformation.

    http://fontforge.sourceforge.net/math.

    html

    [ 5 ] Apostolos Syropoulos: Asana Math.www.ctan.org/tex-archive/fonts/

    Asana-Math/

    [ 6 ] Bogusaw Jackowski: Appendix G Illuminated.

    Proceedings of the 16th EuroTEX Conference2006, Debrecen, Hungary.http://www.gust.org.pl/projects/

    e-foundry/math-support/tb87jackowski.pdf

    [ 7 ] Ulrik Vieth: Understanding the sthetics ofmath typesetting. Biuletyn GUST, 512, 2008.Proceedings of the 16th BachoTEX Conference2008, Bachotek, Poland.http://www.gust.org.pl/projects/

    e-foundry/math-support/vieth2008.pdf

    [ 8 ] Microsoft Typography: OpenType specification.Version 1.5, May 2008.http://www.microsoft.com/typography/

    otspec/

    [ 9 ] Yannis Haralambous: Fonts and Encodings.OReilly Media, 2007. ISBN 0-596-10242-9http://oreilly.com/catalog/9780596102425/

    [ 10 ] Will Robertson: The unicode-math package.Version 0.3b, August 2008.http://github.com/wspr/unicode-math/tree/

    master

    [ 11 ] Taco Hoekwater: LuaTEX Reference Manual.Version 0.37, 31 March 2009.http://www.luatex.org/svn/trunk/manual/

    luatexref-t.pdf

    [ 12 ] Ulrik Vieth: Do we need a Cork math fontencoding? TU Gboat, 29(3), 426434, 2008.

    Proceedings of the TU G 2008 Annual Meeting,Cork, Ireland. Reprinted in this MAPS,311.https://www.tug.org/members/TUGboat/

    tb29-3/tb93vieth.pdf

    [ 13 ] Ulrik Vieth: Math Typesetting: The Good, TheBad, The Ugly. MAPS, 26, 207216, 2001.Proceedings of the 12th EuroTEX Conference2001, Kerkrade, Netherlands.http://www.ntg.nl/maps/26/27.pdf

    [ 14 ] Taco Hoekwater: Math extensions in LuaTEX.Published elsewhere in this MAPS issue.

    [ 15 ] Hans Hagen: Unicode math in Context Mk IV.Published elsewhere in this MAPS issue.

    Ulrik ViethVaihinger Strae 6970567 StuttgartGermanyulrik dot vieth (at) arcor dot de