| 1 |
####################################### |
| 2 |
tables: Access TrueType/OpenType tables |
| 3 |
####################################### |
| 4 |
|
| 5 |
.. contents:: On this page |
| 6 |
:local: |
| 7 |
|
| 8 |
|
| 9 |
.. rubric:: Overview |
| 10 |
:heading-level: 2 |
| 11 |
|
| 12 |
This folder is a subpackage of :py:mod:`fontTools.ttLib`. Each module here is a |
| 13 |
specialized TrueType/OpenType table converter: they can convert raw data |
| 14 |
to Python objects and vice versa. Usually you do not need to |
| 15 |
use these modules directly: they are imported and used |
| 16 |
automatically when needed by :py:mod:`fontTools.ttLib`. |
| 17 |
|
| 18 |
In addition to the tables defined in the official TrueType/OpenType |
| 19 |
specification documents, several specialty tables are supported that |
| 20 |
are used by specific vendors (including the Graphite shaping engine |
| 21 |
and Apple's AAT). Note that fontTools supports the tables that provide |
| 22 |
the core functionality of AAT, but does not guarantee everything. |
| 23 |
|
| 24 |
Similarly, fontTools supports some third-party tables used by external |
| 25 |
applications (such as FontForge and Microsoft's VTT), but may not |
| 26 |
support every private table employed by those applications. |
| 27 |
|
| 28 |
|
| 29 |
Accessing tables |
| 30 |
---------------- |
| 31 |
|
| 32 |
The Python modules representing the tables have pretty strange names: this is due to the |
| 33 |
fact that we need to map TT/OT table tags (which are case sensitive) |
| 34 |
to filenames (which on macOS and Windows are not case sensitive) as well |
| 35 |
as to Python identifiers. The latter means that each table identifier |
| 36 |
can only contain ``[A-Za-z0-9_]`` and cannot start with a number. |
| 37 |
|
| 38 |
The convention adopted is that capital letters in a table tag are |
| 39 |
transformed into the letter followed by an underscore (e.g., ``A_``), while lowercase |
| 40 |
letters and numbers are preceded by an underscore (e.g., ``_a``). |
| 41 |
|
| 42 |
:py:mod:`fontTools.ttLib` provides functions to expand a tag into the format used here:: |
| 43 |
|
| 44 |
>>> from fontTools import ttLib |
| 45 |
>>> ttLib.tagToIdentifier("FOO ") |
| 46 |
'F_O_O_' |
| 47 |
>>> ttLib.tagToIdentifier("cvt ") |
| 48 |
'_c_v_t' |
| 49 |
>>> ttLib.tagToIdentifier("OS/2") |
| 50 |
'O_S_2f_2' |
| 51 |
>>> ttLib.tagToIdentifier("glyf") |
| 52 |
'_g_l_y_f' |
| 53 |
>>> |
| 54 |
|
| 55 |
And vice versa:: |
| 56 |
|
| 57 |
>>> ttLib.identifierToTag("F_O_O_") |
| 58 |
'FOO ' |
| 59 |
>>> ttLib.identifierToTag("_c_v_t") |
| 60 |
'cvt ' |
| 61 |
>>> ttLib.identifierToTag("O_S_2f_2") |
| 62 |
'OS/2' |
| 63 |
>>> ttLib.identifierToTag("_g_l_y_f") |
| 64 |
'glyf' |
| 65 |
>>> |
| 66 |
|
| 67 |
Eg. the 'glyf' table converter lives in a Python file called:: |
| 68 |
|
| 69 |
_g_l_y_f.py |
| 70 |
|
| 71 |
The converter itself is a class, named ``table_`` + expandedtag. Eg:: |
| 72 |
|
| 73 |
|
| 74 |
class table__g_l_y_f: |
| 75 |
etc. |
| 76 |
|
| 77 |
Note that if you _do_ need to use such modules or classes manually, |
| 78 |
there are two convenient API functions that let you find them by tag:: |
| 79 |
|
| 80 |
>>> ttLib.getTableModule('glyf') |
| 81 |
<module 'ttLib.tables._g_l_y_f'> |
| 82 |
>>> ttLib.getTableClass('glyf') |
| 83 |
<class ttLib.tables._g_l_y_f.table__g_l_y_f at 645f400> |
| 84 |
>> |
| 85 |
|
| 86 |
|
| 87 |
Helper modules |
| 88 |
-------------- |
| 89 |
|
| 90 |
In addition to the core table-conversion implementations, a set of |
| 91 |
helper and utility modules is also found in this package. |
| 92 |
You should not normally need to access these modules directly, |
| 93 |
but consulting them might be valuable if you need to add fontTools |
| 94 |
support for a new table type. |
| 95 |
|
| 96 |
In that case, a good place to start is with the documentation for |
| 97 |
the base table classes: |
| 98 |
|
| 99 |
.. toctree:: |
| 100 |
:maxdepth: 1 |
| 101 |
|
| 102 |
tables/table_api |
| 103 |
|
| 104 |
The modules that provide lower-level helper functionality |
| 105 |
include implementations of common OpenType data structures, support |
| 106 |
for OpenType font variations, and various classes needed for |
| 107 |
tables containing bitmap data or for tables used by the Graphite engine: |
| 108 |
|
| 109 |
.. toctree:: |
| 110 |
:maxdepth: 1 |
| 111 |
|
| 112 |
tables/OpenType_related |
| 113 |
tables/TupleVariation |
| 114 |
tables/Bitmap_related |
| 115 |
tables/grUtils |
| 116 |
|
| 117 |
A module is also included for assembling and disassembling |
| 118 |
TrueType bytecode: |
| 119 |
|
| 120 |
.. toctree:: |
| 121 |
:maxdepth: 1 |
| 122 |
|
| 123 |
tables/ttProgram |
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
Tables currently supported |
| 128 |
-------------------------- |
| 129 |
|
| 130 |
.. toctree:: |
| 131 |
:maxdepth: 1 |
| 132 |
|
| 133 |
tables/_a_n_k_r |
| 134 |
tables/_a_v_a_r |
| 135 |
tables/B_A_S_E_ |
| 136 |
tables/_b_s_l_n |
| 137 |
tables/C_B_D_T_ |
| 138 |
tables/C_B_L_C_ |
| 139 |
tables/C_F_F_ |
| 140 |
tables/C_F_F__2 |
| 141 |
tables/_c_i_d_g |
| 142 |
tables/_c_m_a_p |
| 143 |
tables/C_O_L_R_ |
| 144 |
tables/C_P_A_L_ |
| 145 |
tables/_c_v_a_r |
| 146 |
tables/_c_v_t |
| 147 |
tables/D_S_I_G_ |
| 148 |
tables/E_B_D_T_ |
| 149 |
tables/E_B_L_C_ |
| 150 |
tables/F__e_a_t |
| 151 |
tables/_f_e_a_t |
| 152 |
tables/F_F_T_M_ |
| 153 |
tables/_f_p_g_m |
| 154 |
tables/_f_v_a_r |
| 155 |
tables/_g_a_s_p |
| 156 |
tables/_g_c_i_d |
| 157 |
tables/G_D_E_F_ |
| 158 |
tables/G__l_a_t |
| 159 |
tables/G__l_o_c |
| 160 |
tables/_g_l_y_f |
| 161 |
tables/G_P_O_S_ |
| 162 |
tables/G_S_U_B_ |
| 163 |
tables/_g_v_a_r |
| 164 |
tables/_h_d_m_x |
| 165 |
tables/_h_e_a_d |
| 166 |
tables/_h_h_e_a |
| 167 |
tables/_h_m_t_x |
| 168 |
tables/H_V_A_R_ |
| 169 |
tables/J_S_T_F_ |
| 170 |
tables/_k_e_r_n |
| 171 |
tables/_l_c_a_r |
| 172 |
tables/_l_o_c_a |
| 173 |
tables/_l_t_a_g |
| 174 |
tables/L_T_S_H_ |
| 175 |
tables/M_A_T_H_ |
| 176 |
tables/_m_a_x_p |
| 177 |
tables/_m_e_t_a |
| 178 |
tables/_m_o_r_t |
| 179 |
tables/_m_o_r_x |
| 180 |
tables/M_V_A_R_ |
| 181 |
tables/_n_a_m_e |
| 182 |
tables/_o_p_b_d |
| 183 |
tables/O_S_2f_2 |
| 184 |
tables/_p_o_s_t |
| 185 |
tables/_p_r_e_p |
| 186 |
tables/_p_r_o_p |
| 187 |
tables/_s_b_i_x |
| 188 |
tables/S__i_l_f |
| 189 |
tables/S__i_l_l |
| 190 |
tables/S_T_A_T_ |
| 191 |
tables/S_V_G_ |
| 192 |
tables/_t_r_a_k |
| 193 |
tables/T_T_F_A_ |
| 194 |
tables/V_D_M_X_ |
| 195 |
tables/_v_h_e_a |
| 196 |
tables/_v_m_t_x |
| 197 |
tables/V_O_R_G_ |
| 198 |
tables/VTT_related |
| 199 |
tables/V_V_A_R_ |
| 200 |
|
| 201 |
.. automodule:: fontTools.ttLib.tables |
| 202 |
:members: |
| 203 |
:undoc-members: |
| 204 |
|
| 205 |
|