# Text engine: Shaping

#### <a class="anchor" id="bkmrk-"></a>Shaping

Stored texts are ordered by the reading flow. This means that every text is placed from left to right within the memory. It does not matter which language it is. There is also no other information stored besides the text itself. Therefore, the memory representation of text has only logical information but no visual representation information.

The goal of shaping is to find the correct representation of the given text. For example Arabic letters differ in their visual representation depending on their position. Therefore, characters usually have four different forms: Isolated, Final, Medial and Initial. Additionally, there are many more tasks for a shaper to handle: Diacritics, ligatures, kerning...

All different languages have their own characteristics when it comes to shaping. Even Latin has some shaping cases.

For more detailed information about shaping:   
WT-Shaper, HarfBuzz as well as different sources, e.g. Unicode.org and w3.org provides abundant information.

##### <a class="anchor" id="bkmrk--0"></a>Supported shaper

Candera supports different shaper:

<div class="contents" id="bkmrk-no-shaping-complex-s"><div class="contents"><div class="contents"><div class="textblock">- No shaping
- Complex Script
- HarfBuzz (in combination with FreeType)
- WorldType Shaper WorldType-Shaper (in combination with iType)

</div></div></div></div><p class="callout info">To see, which versions of shapers are currently supported, please have a look at the <span style="color: rgb(230, 126, 35);">[\[3rd Party Software section\]](https://doc316en.candera.eu/books/getting-started/page/cgi-studio-components#bkmrk-cgi-studio-3psw)</span>.  
</p>

#### <a class="anchor" id="bkmrk--1"></a>WorldType Shaper

##### <a class="anchor" id="bkmrk--2"></a>Integration of WT-Shaper

The integration is based on the same approach iType uses. (Reference to iType)

##### <a class="anchor" id="bkmrk--3"></a>CMake Integration

In CMake WT-Shaper can only be selected when Monotype is set as CANDERA\_FONTENGINE.

To switch to the shaper the following CMake flag has to be set:

<div class="contents" id="bkmrk-flag-value-candera_f"><div class="contents"><div class="textblock"><table class="doxtable" style="width: 53.7037%;"><tbody><tr><th style="width: 50.704%;">**Flag**</th><th style="width: 49.296%;">**Value**</th></tr><tr><td style="width: 50.704%;">CANDERA\_FONTENGINE</td><td style="width: 49.296%;">Monotype</td></tr><tr><td style="width: 50.704%;">CANDERA\_TEXTSHAPER</td><td style="width: 49.296%;">WorldType-Shaper</td></tr></tbody></table>

</div></div></div>If Freetype + HarfBuzz is slected, the flag CANDERA\_TEXTSHAPER will automatically change to WorldType-Shaper.

Using prebuilt binaries or not is bound to the same CMake flag as <span style="color: rgb(230, 126, 35);">[The font engine: iType](https://doc316en.candera.eu/link/294#bkmrk-the-font-engine%3A-ity)</span> iType.

The flag MONOTYPE\_USE\_BINARIES can be used to switch between the different building modes.

##### <a class="anchor" id="bkmrk--4"></a>Build process: WT-Shaper as source code

For this mode, MONOTYPE\_USE\_BINARIES has to be disabled.

<div class="contents" id="bkmrk-monotype_wtshaper_sr"><div class="contents"><div class="textblock">- MONOTYPE\_WTSHAPER\_SRC\_PATH - This path defines the location where to find the source code for WT-Shaper. By default this will be cgi\_studio\_3psw/src/Monotype/WTShaper and the folder structure may look like the following:  
    <div drawio-diagram="1424"><img src="https://doc316en.candera.eu/uploads/images/drawio/2023-02/drawing-4-1676532572.png" alt=""/></div>
    
      
      
    The FileList.txt which defines all the files should contain the following three Lists: 
    - WTSHAPER\_ALL\_HEADERS
    - WTSHAPER\_ALL\_SOURCES
    - WTSHAPER\_INCLUDE\_PATHS
    
    
    <dl class="note"><dd><p class="callout info">It does not matter how the source code is distributed on the first two lists. Only the names should be in use. The third list shall include the directories of WT-Shaper to add them to the linking system.</p>
    
    </dd></dl>
- MONOTYPE\_FEATSTD\_PORT\_ENABLED - This flag toggles the port API implementation between a CGIStudio version and the default win32\_lib including the settings which are required for [Candera](http://dev.doc.cgistudio.at/APILINK/namespace_candera.html "[DataBinding_RefTypeSample]"). The win32\_lib represents a default implementation of the framework, separated from any [Candera](http://dev.doc.cgistudio.at/APILINK/namespace_candera.html "[DataBinding_RefTypeSample]") relations. This enables an easy possibility to build WT-Shaper in a separated environment and link it to [Candera](http://dev.doc.cgistudio.at/APILINK/namespace_candera.html "[DataBinding_RefTypeSample]"). This flag is shared between iType and WT-Shaper.
- MONOTYPE\_WTSHAPER\_PORT\_PATH - This path is directly links to the port API which shall be used for the build. By default it links to the default location of the default CGIStudio implementation: cgi\_studio\_3psw/src/Monotype/WTShaper/source/port/CGIStudio However, this can be changed to different implementations, too. If MONOTYPE\_FEATSTD\_PORT\_ENABLED is false, this will link to the win32\_lib definition.

</div></div></div>##### <a class="anchor" id="bkmrk--6"></a>Build process WT-Shaper as prebuilt library

For this mode, MONOTYPE\_USE\_BINARIES has to be enabled.

In general using the prebuilt library is similar to the source code version.

The flags MONOTYPE\_FEATSTD\_PORT\_ENABLED, MONOTYPE\_WTSHAPER\_PORT\_PATH and MONOTYPE\_WTSHAPER\_SRC\_PATH are equal in usage as in the source code version. The only difference is, that the prebuilt library only requires header files.

The port files and header have to match with the build settings of the prebuilt library.

MONOTYPE\_WTSHAPER\_LIBRARY\_FILEPATH is the path to the prebuilt library. And has to be defined by the user.