freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Git][freetype/freetype][master] More documentation on handling OT-SVG.


From: Werner Lemberg (@wl)
Subject: [Git][freetype/freetype][master] More documentation on handling OT-SVG.
Date: Sun, 23 Jan 2022 11:24:36 +0000

Werner Lemberg pushed to branch master at FreeType / FreeType

Commits:

4 changed files:

Changes:

  • docs/CHANGES
    1
    +CHANGES BETWEEN 2.11.1 and 2.12.0
    
    2
    +
    
    3
    +  I. IMPORTANT CHANGES
    
    4
    +
    
    5
    +  - FreeType  now   handles  OT-SVG  fonts,  to   be  controlled  with
    
    6
    +    `FT_CONFIG_OPTION_SVG`  configuration macro.   By default,  it can
    
    7
    +    only load the 'SVG ' table of an OpenType font.  However, by using
    
    8
    +    the `svg-hooks` property of the new 'ot-svg' module it is possible
    
    9
    +    to register an  external SVG rendering engine.   The FreeType demo
    
    10
    +    programs  have been  set  up  to use  'librsvg'  as the  rendering
    
    11
    +    library.
    
    12
    +
    
    13
    +    This work was Moazin Kathri's GSoC 2019 project.
    
    14
    +
    
    15
    +
    
    16
    +======================================================================
    
    17
    +
    
    1 18
     CHANGES BETWEEN 2.11.0 and 2.11.1
    
    2 19
     
    
    3 20
       I. IMPORTANT CHANGES
    

  • include/freetype/ftchapters.h
    ... ... @@ -62,6 +62,7 @@
    62 62
        *   cid_fonts
    
    63 63
        *   pfr_fonts
    
    64 64
        *   winfnt_fonts
    
    65
    +   *   svg_fonts
    
    65 66
        *   font_formats
    
    66 67
        *   gasp_table
    
    67 68
        *
    
    ... ... @@ -82,6 +83,7 @@
    82 83
        *   t1_cid_driver
    
    83 84
        *   tt_driver
    
    84 85
        *   pcf_driver
    
    86
    +   *   ot_svg_driver
    
    85 87
        *   properties
    
    86 88
        *   parameter_tags
    
    87 89
        *   lcd_rendering
    

  • include/freetype/ftdriver.h
    ... ... @@ -212,16 +212,14 @@ FT_BEGIN_HEADER
    212 212
        * @description:
    
    213 213
        *   While FreeType's TrueType driver doesn't expose API functions by
    
    214 214
        *   itself, it is possible to control its behaviour with @FT_Property_Set
    
    215
    -   *   and @FT_Property_Get.  The following lists the available properties
    
    216
    -   *   together with the necessary macros and structures.
    
    217
    -   *
    
    218
    -   *   The TrueType driver's module name is 'truetype'.
    
    215
    +   *   and @FT_Property_Get.
    
    219 216
        *
    
    220
    -   *   A single property @interpreter-version is available, as documented in
    
    221
    -   *   the @properties section.
    
    217
    +   *   The TrueType driver's module name is 'truetype'; a single property
    
    218
    +   *   @interpreter-version is available, as documented in the @properties
    
    219
    +   *   section.
    
    222 220
        *
    
    223
    -   *   We start with a list of definitions, kindly provided by Greg
    
    224
    -   *   Hitchcock.
    
    221
    +   *   To help understand the differences between interpreter versions, we
    
    222
    +   *   introduce a list of definitions, kindly provided by Greg Hitchcock.
    
    225 223
        *
    
    226 224
        *   _Bi-Level Rendering_
    
    227 225
        *
    
    ... ... @@ -300,6 +298,31 @@ FT_BEGIN_HEADER
    300 298
        */
    
    301 299
     
    
    302 300
     
    
    301
    +  /**************************************************************************
    
    302
    +   *
    
    303
    +   * @section:
    
    304
    +   *   ot_svg_driver
    
    305
    +   *
    
    306
    +   * @title:
    
    307
    +   *   The SVG driver
    
    308
    +   *
    
    309
    +   * @abstract:
    
    310
    +   *   Controlling the external rendering of OT-SVG glyphs.
    
    311
    +   *
    
    312
    +   * @description:
    
    313
    +   *   By default, FreeType can only load the 'SVG~' table of OpenType fonts
    
    314
    +   *   if configuration macro `FT_CONFIG_OPTION_SVG` is defined.  To make it
    
    315
    +   *   render SVG glyphs, an external SVG rendering library is needed.  All
    
    316
    +   *   details on the interface between FreeType and the external library
    
    317
    +   *   via function hooks can be found in section @svg_fonts.
    
    318
    +   *
    
    319
    +   *   The OT-SVG driver's module name is 'ot-svg'; it supports a single
    
    320
    +   *   property called @svg-hooks, documented below in the @properties
    
    321
    +   *   section.
    
    322
    +   *
    
    323
    +   */
    
    324
    +
    
    325
    +
    
    303 326
       /**************************************************************************
    
    304 327
        *
    
    305 328
        * @section:
    
    ... ... @@ -798,6 +821,40 @@ FT_BEGIN_HEADER
    798 821
        */
    
    799 822
     
    
    800 823
     
    
    824
    +  /**************************************************************************
    
    825
    +   *
    
    826
    +   * @property:
    
    827
    +   *   svg-hooks
    
    828
    +   *
    
    829
    +   * @description:
    
    830
    +   *   Set up the interface between FreeType and an extern SVG rendering
    
    831
    +   *   library like 'librsvg'.  All details on the function hooks can be
    
    832
    +   *   found in section @svg_fonts.
    
    833
    +   *
    
    834
    +   * @example:
    
    835
    +   *   The following example code expects that the four hook functions
    
    836
    +   *   `svg_*` are defined elsewhere.  Error handling is omitted, too.
    
    837
    +   *
    
    838
    +   *   ```
    
    839
    +   *     FT_Library  library;
    
    840
    +   *     SVG_RendererHooks  hooks = {
    
    841
    +   *                          (SVG_Lib_Init_Func)svg_init,
    
    842
    +   *                          (SVG_Lib_Free_Func)svg_free,
    
    843
    +   *                          (SVG_Lib_Render_Func)svg_render,
    
    844
    +   *                          (SVG_Lib_Preset_Slot_Func)svg_preset_slot };
    
    845
    +   *
    
    846
    +   *
    
    847
    +   *     FT_Init_FreeType( &library );
    
    848
    +   *
    
    849
    +   *     FT_Property_Set( library, "ot-svg",
    
    850
    +   *                               "svg-hooks", &hooks );
    
    851
    +   *   ```
    
    852
    +   *
    
    853
    +   * @since:
    
    854
    +   *   2.12
    
    855
    +   */
    
    856
    +
    
    857
    +
    
    801 858
       /**************************************************************************
    
    802 859
        *
    
    803 860
        * @property:
    

  • include/freetype/otsvg.h
    ... ... @@ -31,6 +31,29 @@
    31 31
     FT_BEGIN_HEADER
    
    32 32
     
    
    33 33
     
    
    34
    +  /**************************************************************************
    
    35
    +   *
    
    36
    +   * @section:
    
    37
    +   *   svg_fonts
    
    38
    +   *
    
    39
    +   * @title:
    
    40
    +   *   OpenType SVG Fonts
    
    41
    +   *
    
    42
    +   * @abstract:
    
    43
    +   *   OT-SVG API between FreeType and an external SVG rendering library.
    
    44
    +   *
    
    45
    +   * @description:
    
    46
    +   *   This section describes the four hooks necessary to render SVG
    
    47
    +   *   'documents' that are contained in an OpenType font's 'SVG~' table.
    
    48
    +   *
    
    49
    +   *   For more information on the implementation, see our standard hooks
    
    50
    +   *   based on 'librsvg' in the [FreeType Demo
    
    51
    +   *   Programs](https://gitlab.freedesktop.org/freetype/freetype-demos)
    
    52
    +   *   repository.
    
    53
    +   *
    
    54
    +   */
    
    55
    +
    
    56
    +
    
    34 57
       /**************************************************************************
    
    35 58
        *
    
    36 59
        * @functype:
    
    ... ... @@ -42,9 +65,6 @@ FT_BEGIN_HEADER
    42 65
        *   one would want to allocate a structure and point the `data_pointer`
    
    43 66
        *   to it and perform any library initializations that might be needed.
    
    44 67
        *
    
    45
    -   *   For more information on the implementation, see our standard hooks
    
    46
    -   *   based on Librsvg in the 'FreeType Demo Programs' repository.
    
    47
    -   *
    
    48 68
        * @inout:
    
    49 69
        *   data_pointer ::
    
    50 70
        *     The SVG rendering module stores a pointer variable that can be used
    
    ... ... @@ -77,9 +97,6 @@ FT_BEGIN_HEADER
    77 97
        *   structure that was allocated in the init hook and perform any
    
    78 98
        *   library-related closure that might be needed.
    
    79 99
        *
    
    80
    -   *   For more information on the implementation, see our standard hooks
    
    81
    -   *   based on Librsvg in the 'FreeType Demo Programs' repository.
    
    82
    -   *
    
    83 100
        * @inout:
    
    84 101
        *   data_pointer ::
    
    85 102
        *     The SVG rendering module stores a pointer variable that can be used
    
    ... ... @@ -101,7 +118,7 @@ FT_BEGIN_HEADER
    101 118
        *
    
    102 119
        * @description:
    
    103 120
        *   A callback that is called to render an OT-SVG glyph.  This callback
    
    104
    -   *   hook is called right after the preset hook @SVG_Lib_Preset_SlotFunc
    
    121
    +   *   hook is called right after the preset hook @SVG_Lib_Preset_Slot_Func
    
    105 122
        *   has been called with `cache` set to `TRUE`.  The data necessary to
    
    106 123
        *   render is available through the handle @FT_SVG_Document, which is set
    
    107 124
        *   in the `other` field of @FT_GlyphSlotRec.
    
    ... ... @@ -110,9 +127,6 @@ FT_BEGIN_HEADER
    110 127
        *   buffer that is allocated already at `slot->bitmap.buffer`.  It also
    
    111 128
        *   sets the `num_grays` value as well as `slot->format`.
    
    112 129
        *
    
    113
    -   *   For more information on the implementation, see our standard hooks
    
    114
    -   *   based on Librsvg in the 'FreeType Demo Programs' repository.
    
    115
    -   *
    
    116 130
        * @input:
    
    117 131
        *   slot ::
    
    118 132
        *     The slot to render.
    
    ... ... @@ -145,6 +159,7 @@ FT_BEGIN_HEADER
    145 159
        *   two places.
    
    146 160
        *
    
    147 161
        *   1. When `FT_Load_Glyph` needs to preset the glyph slot.
    
    162
    +   *
    
    148 163
        *   2. Right before the `svg` module calls the render callback hook.
    
    149 164
        *
    
    150 165
        *   When it is the former, the argument `cache` is set to `FALSE`.  When
    
    ... ... @@ -165,9 +180,6 @@ FT_BEGIN_HEADER
    165 180
        *   matrices into the SVG coordinate system, as the original matrix is
    
    166 181
        *   intended for the TTF/CFF coordinate system.
    
    167 182
        *
    
    168
    -   *   For more information on the implementation, see our standard hooks
    
    169
    -   *   based on Librsvg in the 'FreeType Demo Programs' repository.
    
    170
    -   *
    
    171 183
        * @input:
    
    172 184
        *   slot ::
    
    173 185
        *     The glyph slot that has the SVG document loaded.
    
    ... ... @@ -201,8 +213,8 @@ FT_BEGIN_HEADER
    201 213
        *
    
    202 214
        * @description:
    
    203 215
        *   A structure that stores the four hooks needed to render OT-SVG glyphs
    
    204
    -   *   properly.  The structure is publicly used to set the hooks via driver
    
    205
    -   *   properties.
    
    216
    +   *   properly.  The structure is publicly used to set the hooks via the
    
    217
    +   *   @svg-hooks driver property.
    
    206 218
        *
    
    207 219
        *   The behavior of each hook is described in its documentation.  One
    
    208 220
        *   thing to note is that the preset hook and the render hook often need
    
    ... ... @@ -211,9 +223,6 @@ FT_BEGIN_HEADER
    211 223
        *   For example, in the preset hook one can draw the glyph on a recorder
    
    212 224
        *   surface and later create a bitmap surface from it in the render hook.
    
    213 225
        *
    
    214
    -   *   For more information on the implementation, see our standard hooks
    
    215
    -   *   based on Librsvg in the 'FreeType Demo Programs' repository.
    
    216
    -   *
    
    217 226
        * @fields:
    
    218 227
        *   init_svg ::
    
    219 228
        *     The initialization hook.
    
    ... ... @@ -244,7 +253,7 @@ FT_BEGIN_HEADER
    244 253
       /**************************************************************************
    
    245 254
        *
    
    246 255
        * @struct:
    
    247
    -   *   FT_SVG_DocumentRec_
    
    256
    +   *   FT_SVG_DocumentRec
    
    248 257
        *
    
    249 258
        * @description:
    
    250 259
        *   A structure that models one SVG document.
    
    ... ... @@ -276,12 +285,12 @@ FT_BEGIN_HEADER
    276 285
        *     The translation to apply to the glyph while rendering.
    
    277 286
        *
    
    278 287
        * @note:
    
    279
    -   *   When the slot is passed down to a renderer, the renderer can only
    
    280
    -   *   access the `metrics` and `units_per_EM` fields via `slot->face`.
    
    281
    -   *   However, when `FT_Glyph_To_Bitmap` sets up a dummy object, it has no
    
    282
    -   *   way to set a `face` object.  Thus, metrics information and
    
    283
    -   *   `units_per_EM` (which is necessary for OT-SVG) has to be stored
    
    284
    -   *   separately.
    
    288
    +   *   When an @FT_GlyphSlot object `slot` is passed down to a renderer, the
    
    289
    +   *   renderer can only access the `metrics` and `units_per_EM` fields via
    
    290
    +   *   `slot->face`.  However, when @FT_Glyph_To_Bitmap sets up a dummy
    
    291
    +   *   object, it has no way to set a `face` object.  Thus, metrics
    
    292
    +   *   information and `units_per_EM` (which is necessary for OT-SVG) has to
    
    293
    +   *   be stored separately.
    
    285 294
        *
    
    286 295
        * @since:
    
    287 296
        *   2.12
    


  • reply via email to

    [Prev in Thread] Current Thread [Next in Thread]