CINXE.COM

Comparison of OpenType and Graphite shaping speeds in a Nastaliq context | Graphite

<!DOCTYPE html> <html lang="en-US"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=Edge"> <link rel="stylesheet" href="/assets/css/just-the-docs-default.css"> <script src="/assets/js/vendor/lunr.min.js"></script> <script src="/assets/js/just-the-docs.js"></script> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="icon" href="/assets/images/favicon.ico" type="image/x-icon"> <!-- Begin Jekyll SEO tag v2.8.0 --> <title>Comparison of OpenType and Graphite shaping speeds in a Nastaliq context | Graphite</title> <meta name="generator" content="Jekyll v4.3.2" /> <meta property="og:title" content="Comparison of OpenType and Graphite shaping speeds in a Nastaliq context" /> <meta property="og:locale" content="en_US" /> <meta name="description" content="Site for Graphite" /> <meta property="og:description" content="Site for Graphite" /> <link rel="canonical" href="https://silnrsi.github.io/graphite/graphite_otcompare.html" /> <meta property="og:url" content="https://silnrsi.github.io/graphite/graphite_otcompare.html" /> <meta property="og:site_name" content="Graphite" /> <meta property="og:type" content="website" /> <meta name="twitter:card" content="summary" /> <meta property="twitter:title" content="Comparison of OpenType and Graphite shaping speeds in a Nastaliq context" /> <script type="application/ld+json"> {"@context":"https://schema.org","@type":"WebPage","description":"Site for Graphite","headline":"Comparison of OpenType and Graphite shaping speeds in a Nastaliq context","url":"https://silnrsi.github.io/graphite/graphite_otcompare.html"}</script> <!-- End Jekyll SEO tag --> </head> <body> <a class="skip-to-main" href="#main-content">Skip to main content</a> <svg xmlns="http://www.w3.org/2000/svg" class="d-none"> <symbol id="svg-link" viewBox="0 0 24 24"> <title>Link</title> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"> <path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path> </svg> </symbol> <symbol id="svg-menu" viewBox="0 0 24 24"> <title>Menu</title> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-menu"> <line x1="3" y1="12" x2="21" y2="12"></line><line x1="3" y1="6" x2="21" y2="6"></line><line x1="3" y1="18" x2="21" y2="18"></line> </svg> </symbol> <symbol id="svg-arrow-right" viewBox="0 0 24 24"> <title>Expand</title> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-chevron-right"> <polyline points="9 18 15 12 9 6"></polyline> </svg> </symbol> <!-- Feather. MIT License: https://github.com/feathericons/feather/blob/master/LICENSE --> <symbol id="svg-external-link" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-external-link"> <title id="svg-external-link-title">(external link)</title> <path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path><polyline points="15 3 21 3 21 9"></polyline><line x1="10" y1="14" x2="21" y2="3"></line> </symbol> <symbol id="svg-doc" viewBox="0 0 24 24"> <title>Document</title> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-file"> <path d="M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"></path><polyline points="13 2 13 9 20 9"></polyline> </svg> </symbol> <symbol id="svg-search" viewBox="0 0 24 24"> <title>Search</title> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-search"> <circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line> </svg> </symbol> <!-- Bootstrap Icons. MIT License: https://github.com/twbs/icons/blob/main/LICENSE.md --> <symbol id="svg-copy" viewBox="0 0 16 16"> <title>Copy</title> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-clipboard" viewBox="0 0 16 16"> <path d="M4 1.5H3a2 2 0 0 0-2 2V14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V3.5a2 2 0 0 0-2-2h-1v1h1a1 1 0 0 1 1 1V14a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V3.5a1 1 0 0 1 1-1h1v-1z"/> <path d="M9.5 1a.5.5 0 0 1 .5.5v1a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5v-1a.5.5 0 0 1 .5-.5h3zm-3-1A1.5 1.5 0 0 0 5 1.5v1A1.5 1.5 0 0 0 6.5 4h3A1.5 1.5 0 0 0 11 2.5v-1A1.5 1.5 0 0 0 9.5 0h-3z"/> </svg> </symbol> <symbol id="svg-copied" viewBox="0 0 16 16"> <title>Copied</title> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-clipboard-check-fill" viewBox="0 0 16 16"> <path d="M6.5 0A1.5 1.5 0 0 0 5 1.5v1A1.5 1.5 0 0 0 6.5 4h3A1.5 1.5 0 0 0 11 2.5v-1A1.5 1.5 0 0 0 9.5 0h-3Zm3 1a.5.5 0 0 1 .5.5v1a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5v-1a.5.5 0 0 1 .5-.5h3Z"/> <path d="M4 1.5H3a2 2 0 0 0-2 2V14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V3.5a2 2 0 0 0-2-2h-1v1A2.5 2.5 0 0 1 9.5 5h-3A2.5 2.5 0 0 1 4 2.5v-1Zm6.854 7.354-3 3a.5.5 0 0 1-.708 0l-1.5-1.5a.5.5 0 0 1 .708-.708L7.5 10.793l2.646-2.647a.5.5 0 0 1 .708.708Z"/> </svg> </symbol> </svg> <div class="side-bar"> <div class="site-header" role="banner"> <a href="/" class="site-title lh-tight"> Graphite </a> <button id="menu-button" class="site-button btn-reset" aria-label="Toggle menu" aria-pressed="false"> <svg viewBox="0 0 24 24" class="icon" aria-hidden="true"><use xlink:href="#svg-menu"></use></svg> </a> </div> <nav aria-label="Main" id="site-nav" class="site-nav"> <ul class="nav-list"><li class="nav-list-item"><a href="/" class="nav-list-link">Home</a></li><li class="nav-list-item active"><button class="nav-list-expander btn-reset" aria-label="toggle items in About Graphite category" aria-pressed="true"> <svg viewBox="0 0 24 24" aria-hidden="true"><use xlink:href="#svg-arrow-right"></use></svg> </button><a href="/graphite_about.html" class="nav-list-link">About Graphite</a><ul class="nav-list"><li class="nav-list-item "><a href="/graphite_aboutWhy.html" class="nav-list-link">Why was Graphite developed?</a></li><li class="nav-list-item active"><button class="nav-list-expander btn-reset" aria-label="toggle items in Graphite and OpenType category" aria-pressed="true"> <svg viewBox="0 0 24 24" aria-hidden="true"><use xlink:href="#svg-arrow-right"></use></svg> </button><a href="/graphite_aboutOT.html" class="nav-list-link">Graphite and OpenType</a><ul class="nav-list"><li class="nav-list-item active"> <a href="/graphite_otcompare.html" class="nav-list-link active">Comparison of OpenType and Graphite shaping speeds in a Nastaliq context</a> </li></ul></li><li class="nav-list-item "><a href="/graphite_techAbout.html" class="nav-list-link">Graphite technical overview</a></li></ul></li><li class="nav-list-item"><a href="/graphite_news.html" class="nav-list-link">News</a></li><li class="nav-list-item"><button class="nav-list-expander btn-reset" aria-label="toggle items in Using Graphite category" aria-pressed="false"> <svg viewBox="0 0 24 24" aria-hidden="true"><use xlink:href="#svg-arrow-right"></use></svg> </button><a href="/graphite_appsParent.html" class="nav-list-link">Using Graphite</a><ul class="nav-list"><li class="nav-list-item "><a href="/graphite_apps.html" class="nav-list-link">Applications that support Graphite</a></li><li class="nav-list-item "><a href="/graphite_firefox.html" class="nav-list-link">Graphite and Firefox</a></li><li class="nav-list-item "><a href="/graphite_fontdemo.html" class="nav-list-link">Graphite Font Demo</a></li><li class="nav-list-item "><a href="/graphite_fonts.html" class="nav-list-link">Graphite-enabled Fonts</a></li></ul></li><li class="nav-list-item"><button class="nav-list-expander btn-reset" aria-label="toggle items in Developers category" aria-pressed="false"> <svg viewBox="0 0 24 24" aria-hidden="true"><use xlink:href="#svg-arrow-right"></use></svg> </button><a href="/graphite_dev.html" class="nav-list-link">Developers</a><ul class="nav-list"><li class="nav-list-item "><a href="/graphite_devFont.html" class="nav-list-link">Font Development</a></li><li class="nav-list-item "><a href="/graide.html" class="nav-list-link">Graide</a></li><li class="nav-list-item "><button class="nav-list-expander btn-reset" aria-label="toggle items in Graphite Tutorial category" aria-pressed="false"> <svg viewBox="0 0 24 24" aria-hidden="true"><use xlink:href="#svg-arrow-right"></use></svg> </button><a href="/graide_tutorial.html" class="nav-list-link">Graphite Tutorial</a><ul class="nav-list"><li class="nav-list-item "> <a href="/tutorial/graide_tutorial1.html" class="nav-list-link">Unit 1</a> </li><li class="nav-list-item "> <a href="/tutorial/graide_tutorial2.html" class="nav-list-link">Unit 2</a> </li><li class="nav-list-item "> <a href="/tutorial/graide_tutorial3.html" class="nav-list-link">Unit 3</a> </li><li class="nav-list-item "> <a href="/tutorial/graide_tutorial4.html" class="nav-list-link">Unit 4</a> </li><li class="nav-list-item "> <a href="/tutorial/graide_tutorial5.html" class="nav-list-link">Unit 5</a> </li><li class="nav-list-item "> <a href="/tutorial/graide_tutorial6.html" class="nav-list-link">Unit 6</a> </li><li class="nav-list-item "> <a href="/tutorial/graide_tutorial7.html" class="nav-list-link">Unit 7</a> </li><li class="nav-list-item "> <a href="/tutorial/graide_tutorial8.html" class="nav-list-link">Unit 8</a> </li><li class="nav-list-item "> <a href="/tutorial/graide_tutorial8a.html" class="nav-list-link">Intermission</a> </li><li class="nav-list-item "> <a href="/tutorial/graide_tutorial9.html" class="nav-list-link">Unit 9</a> </li><li class="nav-list-item "> <a href="/tutorial/graide_tutorial10.html" class="nav-list-link">Unit 10</a> </li><li class="nav-list-item "> <a href="/tutorial/graide_tutorial11.html" class="nav-list-link">Unit 11</a> </li><li class="nav-list-item "> <a href="/tutorial/graide_tutorial12.html" class="nav-list-link">Unit 12</a> </li><li class="nav-list-item "> <a href="/tutorial/graide_tutorial13.html" class="nav-list-link">Unit 13</a> </li><li class="nav-list-item "> <a href="/tutorial/graide_tutorial14.html" class="nav-list-link">Unit 14</a> </li><li class="nav-list-item "> <a href="/tutorial/graide_tutorial15.html" class="nav-list-link">Unit 15</a> </li><li class="nav-list-item "> <a href="/tutorial/graide_tutorial16.html" class="nav-list-link">Unit 16</a> </li><li class="nav-list-item "> <a href="/tutorial/graide_tutorial17.html" class="nav-list-link">Unit 17</a> </li><li class="nav-list-item "> <a href="/tutorial/graide_tutorial18.html" class="nav-list-link">Unit 18</a> </li><li class="nav-list-item "> <a href="/tutorial/graide_tutorial_end.html" class="nav-list-link">Conclusion</a> </li><li class="nav-list-item "> <a href="/tutorial/graphite_tut_solutions.html" class="nav-list-link">Solutions to Tutorial Exercises</a> </li></ul></li><li class="nav-list-item "><a href="/graphite_codeSnippets.html" class="nav-list-link">GDL Code Snippets</a></li><li class="nav-list-item "><a href="/graphite_devApp.html" class="nav-list-link">Adding Graphite to Your Application</a></li></ul></li><li class="nav-list-item"><a href="/graphite_download.html" class="nav-list-link">Download</a></li><li class="nav-list-item"><a href="/graphite_support.html" class="nav-list-link">Support</a></li><li class="nav-list-item"><a href="/graphite_contact.html" class="nav-list-link">Contact</a></li></ul> </nav> <footer class="site-footer"> This site uses <a href="https://github.com/just-the-docs/just-the-docs">Just the Docs</a>, a documentation theme for Jekyll. </footer> </div> <div class="main" id="top"> <div id="main-header" class="main-header"> <div class="search" role="search"> <div class="search-input-wrap"> <input type="text" id="search-input" class="search-input" tabindex="0" placeholder="Search Graphite site" aria-label="Search Graphite site" autocomplete="off"> <label for="search-input" class="search-label"><svg viewBox="0 0 24 24" class="search-icon"><use xlink:href="#svg-search"></use></svg></label> </div> <div id="search-results" class="search-results"></div> </div> <nav aria-label="Auxiliary" class="aux-nav"> <ul class="aux-nav-list"> <li class="aux-nav-list-item"> <a href="https://github.com/silnrsi/graphite" class="site-button" > Repository </a> </li> </ul> </nav> </div> <div id="main-content-wrap" class="main-content-wrap"> <nav aria-label="Breadcrumb" class="breadcrumb-nav"> <ol class="breadcrumb-nav-list"> <li class="breadcrumb-nav-list-item"><a href="/graphite_about.html">About Graphite</a></li> <li class="breadcrumb-nav-list-item"><a href="/graphite_aboutOT.html">Graphite and OpenType</a></li> <li class="breadcrumb-nav-list-item"><span>Comparison of OpenType and Graphite shaping speeds in a Nastaliq context</span></li> </ol> </nav> <div id="main-content" class="main-content"> <main> <h1 id="comparison-of-opentype-and-graphite-shaping-speeds-in-a-nastaliq-context"> <a href="#comparison-of-opentype-and-graphite-shaping-speeds-in-a-nastaliq-context" class="anchor-heading" aria-labelledby="comparison-of-opentype-and-graphite-shaping-speeds-in-a-nastaliq-context"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> Comparison of OpenType and Graphite shaping speeds in a Nastaliq context </h1> <p><em>Martin Hosken, July 2017</em></p> <h2 id="introduction"> <a href="#introduction" class="anchor-heading" aria-labelledby="introduction"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> Introduction </h2> <p>This paper examines the speed performance of OpenType and Graphite. For the most part we examine fonts that have similar processing features and have been implemented in both OpenType and Graphite. After a general discussion covering a number of fonts, the paper goes on to examine the implementation of two Arabic Nastaliq fonts.</p> <p>For the most part, users do not perceive fonts as being too slow. But even a few milliseconds added to a page render time can affect user satisfaction. Many applications speed up rendering by caching the results of text shaping at the word level.</p> <h2 id="comparing-speeds"> <a href="#comparing-speeds" class="anchor-heading" aria-labelledby="comparing-speeds"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> Comparing Speeds </h2> <p>This graph shows the relative speed of various fonts and text in various scripts. In each case the font used is one that has both Graphite and OpenType tables aiming to have identical behaviour. The only exception is for Urdu where Noto Nastaliq Urdu is used for OpenType-based tests and Awami for the Graphite test.</p> <p><img src="assets/images/otcompare_speedtest.jpeg" alt="" /></p> <p>The y-axis shows the time taken to shape the data and is expressed in cycles per character. The shorter the bar, the better. The cycles count comes from measuring the number of emulated cpu cycles, as measured by valgrind (callgrind) for the particular code used in shaping the text and dividing it by the number of characters to normalise for text length. Usp10 results are missing for TaiHeritagePro and Padauk due to failure in the test setup to load the font. Notice that the graph has been truncated slightly to enhance resolution; one result - usp10, ur (Noto) - has been cut off, for which the timing is is 83905 cycles/character.</p> <p>The usp timings are not particularly helpful except to say that in the context of complex fonts, usp10 is not particularly snappy in comparison to other engines.</p> <p>The tests are ordered left to right according to script processing complexity. The precise order is not formally defined or that important, but it does show that more complex scripts take longer to process. It also highlights the increased improvement in speed that Graphite provides as the complexity of the script processing increases. This is in contrast to the expectation that OpenType, due to handling more script complexity in code, should provide a greater benefit as the script becomes more complex. The contrast is highlighted by the fact that Padauk is doing full UTN#11 sequence checking in Graphite, which is not so strictly applied in the OpenType code. In addition, Awami is doing word kerning. Busra stands out in comparison to other Khmer fonts, as being significantly slower, because it too is doing strict sequence checking, both in OpenType and Graphite.The graph shows the time taken to shape text in various scripts using various engines. The three engines used are Uniscribe (usp10) from just before all shaping was done in DirectWrite; OpenType (ot - via harfbuzz; and Graphite (gr - via harfbuzz). Each cluster of 3 bars shows the timings for a paragraph from the Universal Declaration of Human Rights in a particular language. The language code is given along with the font used in the test. So, for example, nep (Annapurna) labels a test involving Nepali text and the Annapurna SIL font; or “ur (Noto, Awami)” labels a test involving Urdu text. The opentype engines (usp10 and harfbuzz) use the Noto Nastaliq Urdu font and the Graphite test uses Awami Nastaliq. For precise details of font versions see the appendix on testing details.</p> <p>The likely cause for the slowness of complex OpenType fonts is that such fonts include a number of contextual lookups, which are particularly slow in OpenType processing. Graphite, on the other hand, is structured around contextual matching and so works particularly well with such fonts.</p> <h2 id="testing-details"> <a href="#testing-details" class="anchor-heading" aria-labelledby="testing-details"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> Testing details </h2> <p>This section may be skipped without loss of understanding. It is included to provide extra detail on the testing procedure and full results data for those interested.</p> <p>The tests were undertaken on a 64 bit Intel i7-4712HQ with Ubuntu 16.04, running valgrind (v3.11.0) and collecting results using callgrind. The timing results were then taken by examining the overall times for the following functions:</p> <ul> <li>ot: hb_shape_plan_execute</li> <li>graphite: gr_make_seg</li> </ul> <p>For the usp10 test, harfbuzz (v1.4.5) was run under Wine (v1.8.5) using the Uniscribe shaper (usp10.dll, v1.0626.7601.17514). But since there are no debug symbols to reference functions by name, the timings were taken from an appropriate function call that shows no evidence of loading the font and then subtracting all the time taken to run GetCharABCWidthsI, which is a Wine function. Notice that within the function chosen, no other calls were made out to Wine, thus only usp10 code was executed. V1.3.10 of Graphite was used.</p> <p>The raw test results are:</p> <div class="table-wrapper"><table> <thead> <tr> <th style="text-align: left">Test</th> <th style="text-align: left">Font</th> <th style="text-align: left">usp10</th> <th style="text-align: left">ot</th> <th style="text-align: left">graphite</th> </tr> </thead> <tbody> <tr> <td style="text-align: left">en (Charis)</td> <td style="text-align: left">Charis SIL Regular v5.00</td> <td style="text-align: left">12272</td> <td style="text-align: left">2178</td> <td style="text-align: left">1310</td> </tr> <tr> <td style="text-align: left">yor (Charis)</td> <td style="text-align: left">Charis SIL Regular v.500</td> <td style="text-align: left">10298</td> <td style="text-align: left">2311</td> <td style="text-align: left">1682</td> </tr> <tr> <td style="text-align: left">ar (Scheherazade)</td> <td style="text-align: left">Scheherazade v2.100</td> <td style="text-align: left">20371</td> <td style="text-align: left">4292</td> <td style="text-align: left">3630</td> </tr> <tr> <td style="text-align: left">nep (Annapurna)</td> <td style="text-align: left">Annapurna SIL v1.202</td> <td style="text-align: left">28584</td> <td style="text-align: left">6470</td> <td style="text-align: left">3378</td> </tr> <tr> <td style="text-align: left">blt (TaiHeritagePro)</td> <td style="text-align: left">Tai Heritage Pro v2.500</td> <td style="text-align: left"> </td> <td style="text-align: left">16308</td> <td style="text-align: left">2010</td> </tr> <tr> <td style="text-align: left">kh (Busra)</td> <td style="text-align: left">Khmer Busra v7.100</td> <td style="text-align: left">21478</td> <td style="text-align: left">12491</td> <td style="text-align: left">5045</td> </tr> <tr> <td style="text-align: left">my (Padauk)</td> <td style="text-align: left">Padauk v3.004</td> <td style="text-align: left"> </td> <td style="text-align: left">16070</td> <td style="text-align: left">6863</td> </tr> <tr> <td style="text-align: left">ur (Noto, Awami)</td> <td style="text-align: left">Noto Nastaliq Urdu v1.02, Awami Nastaliq preV1 v0.920</td> <td style="text-align: left">83907</td> <td style="text-align: left">44603</td> <td style="text-align: left">21827</td> </tr> </tbody> </table></div> <p>Not all test strings are included, but the most useful example is the string used for the ur:</p> <p class="arabic-sample">چونکہ انسانی حقوق سے لاپروایٔی اور ان کی بے حرمتی اکثر ایسے وحشیانہ افعال کی شکل میں ظاہر ہویٔی ہے جن سے انسانیت کے ضمیر کو سخت صدمے پہنچے ہیں اور عام انسانوں کی بلندترین آرزو یہ رہی ہے کہ ایسی دنیا وجود میں آیٔے جس میں تمام انسانوں کو اپنی بات کہنے اور اپنے عقیدے پر قایٔم رہنے کی آزادی حاصل ہو اور خوف اور احتیاج سے محفوظ رہیں،</p> <h2 id="special-challenges-of-nastaliq"> <a href="#special-challenges-of-nastaliq" class="anchor-heading" aria-labelledby="special-challenges-of-nastaliq"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> Special Challenges of Nastaliq </h2> <p>Arabic Nastaliq is, at its heart, Arabic. So why does a Nastaliq font take so much longer to process than a Naskh one (like Scheherazade)? There are two extra actions that a Nastaliq font needs to do in addition to the standard shaping of character forms and basic diacritic/nuqta attachment.</p> <ul> <li>The first is collision avoidance. Due to the sloping of the syllable, the horizontal space for a character is compressed and this greatly increases the likelihood that nuqtas will collide either with other nuqtas or with other base characters.</li> <li>The second action is word kerning. This moves words (or more strictly, clusters) closer together so that one word may finish underneath the start of another word.</li> </ul> <p>There is another penalty that Nastaliq fonts incur as a result of word kerning. Word caches assume that the space between two words does not change based on the words involved. Word kerning adjusts the width of the space between two words based on the two words involved. This means that word caching cannot be applied to such text. Such a cache is often hit quite hard given that a piece of text will often be shaped multiple times for measuring purposes and line breaking before being rendered. The result is a slow font that cannot be cached. The need for speed in this context is paramount. The nature of the Arabic script makes it nearly impossible to find other boundaries in the text where sequences could be cached without interaction across the boundary.</p> <p>We consider two fonts for comparison:</p> <ul> <li>Noto Nastaliq Urdu is a best of class OpenType font being fast, small and with a good coverage of both characters and supported sequences.</li> <li>Awami Nastaliq is a similar font in terms of speed, size and coverage. Awami supports all the languages of Pakistan that use the Nastaliq style.</li> </ul> <p>The key functionality difference between them is that Noto Nastaliq Urdu does not do word kerning, whereas Awami Nastaliq does.</p> <p>The following graph shows how the two engines (Graphite as represented by Awami, and harfbuzz (OpenType) as represented by Noto Nastaliq Urdu) break down their processing time when shaping the test text. Shorter times are better. Note that the colours only function to show the different sub-timings. Which subtimings they correspond to are different for the two font shaping processes and are described in the following text.</p> <p><img src="assets/images/otcompare_nastaliqComponents.jpeg" alt="" /></p> <p>Noto Nastaliq Urdu takes 44604 cycles/character to do its work. Of these, 40657 cycles are in GSUB (blue) and 2567 cycles in GPOS (orange). This might seem odd given that collision avoidance is about moving diacritics and nuqtas around. But Noto does most of this work in the GSUB table through the use of extra spacing glyphs to adjust the positioning of Nuqtas.</p> <p>Awami is structured differently. It takes 22287 cycles/character to do its work. There is a data conversion overhead to convert the results from Graphite’s internal form to fit Harfbuzz’s structures. This takes 462 cycles/character (green) and is about the same for all right-to-left fonts. Collision avoidance takes 4739 cycles (red) and word kerning takes 3611 cycles (yellow). This leaves 13475 cycles (blue) for choosing the right glyphs and basic positioning. Notice this is considerably more than the 3630 cycles used in Scheherazade. So not only does a Nastaliq font have to deal with collision avoidance and word kerning, its basic shaping is far more complex than a Naskh font.</p> <h2 id="conclusion"> <a href="#conclusion" class="anchor-heading" aria-labelledby="conclusion"><svg viewBox="0 0 16 16" aria-hidden="true"><use xlink:href="#svg-link"></use></svg></a> Conclusion </h2> <p>The dramatic difference in speed between Awami Nastaliq and Noto Nastaliq Urdu demonstrates that reliance on a large number of OpenType complex contextual rules can considerably slow down shaping and rendering. Graphite’s alternate methods enable Awami Nastaliq to be much more efficient, even given its increased complexity. This speed benefit is not only applicable to extremely complex fonts, but is present through the full range of font complexity.</p> <p>Word caching, when possible, can mitigate some of the slowdowns of complex fonts, however there are situations where word caching does not help:</p> <ul> <li>Cross-space contexts such as word kerning or even collision avoidance</li> <li>Where there are no word breaks, such as for some Southeast Asian scripts (Thai, Lao, Khmer, Burmese, and others)</li> </ul> <p>The overall conclusion is that, in many situations, the value of an alternative to standard OpenType engines stands out, both in terms of functionality and performance. This value will grow as users demand fonts with increased complexity and greater support for sophisticated typography.</p> </main> <hr> <footer> <p class="text-small text-grey-dk-100 mb-0">Copyright &copy; 2012-2023 SIL International and released under the <a href="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-ShareAlike 3.0 license (CC-BY-SA)</a> unless noted otherwise.</p> </footer> </div> </div> <div class="search-overlay"></div> </div> </body> </html>

Pages: 1 2 3 4 5 6 7 8 9 10