2019-06-15 07:17:47 +02:00
|
|
|
/****************************************************************************
|
|
|
|
*
|
2019-08-10 11:27:59 +02:00
|
|
|
* otsvg.h
|
2019-06-15 07:17:47 +02:00
|
|
|
*
|
2019-08-10 11:27:59 +02:00
|
|
|
* Interface for OT-SVG support related things (specification).
|
2019-06-15 07:17:47 +02:00
|
|
|
*
|
|
|
|
* Copyright (C) 2004-2019 by
|
2019-07-01 21:15:50 +02:00
|
|
|
* David Turner, Robert Wilhelm, Werner Lemberg and Moazin Khatti.
|
2019-06-15 07:17:47 +02:00
|
|
|
*
|
|
|
|
* This file is part of the FreeType project, and may only be used,
|
|
|
|
* modified, and distributed under the terms of the FreeType project
|
|
|
|
* license, LICENSE.TXT. By continuing to use, modify, or distribute
|
|
|
|
* this file you indicate that you have read the license and
|
|
|
|
* understand and accept it fully.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef FTSVG_RENDERER_H_
|
|
|
|
#define FTSVG_RENDERER_H_
|
|
|
|
|
|
|
|
#include <ft2build.h>
|
|
|
|
#include FT_FREETYPE_H
|
|
|
|
|
|
|
|
#ifdef FREETYPE_H
|
|
|
|
#error "freetype.h of FreeType 1 has been loaded!"
|
|
|
|
#error "Please fix the directory search order for header files"
|
|
|
|
#error "so that freetype.h of FreeType 2 is found first."
|
|
|
|
#endif
|
|
|
|
|
|
|
|
FT_BEGIN_HEADER
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
*
|
|
|
|
* @functype:
|
2019-07-10 13:28:39 +02:00
|
|
|
* SVG_Lib_Init_Func
|
2019-06-15 07:17:47 +02:00
|
|
|
*
|
|
|
|
* @description:
|
2019-08-24 15:24:28 +02:00
|
|
|
* A callback which is called when the first OT-SVG glyph is rendered in
|
|
|
|
* the lifetime of an @FT_Library object. The callback should perform all
|
|
|
|
* sorts of initializations that the SVG rendering library needs such as
|
|
|
|
* allocating memory for `svg_renderer_state` of @FT_LibraryRec.
|
2019-06-15 07:17:47 +02:00
|
|
|
*
|
2019-07-05 18:02:17 +02:00
|
|
|
* @input:
|
2019-07-10 10:58:59 +02:00
|
|
|
* library ::
|
2019-08-24 15:24:28 +02:00
|
|
|
* An instance of @FT_Library. It's passed to give the callbacks access
|
|
|
|
* to `svg_renderer_state` of @FT_LibraryRec.
|
2019-07-05 18:02:17 +02:00
|
|
|
*
|
2019-06-15 07:17:47 +02:00
|
|
|
* @return:
|
|
|
|
* FreeType error code. 0 means success.
|
|
|
|
*/
|
|
|
|
typedef FT_Error
|
2019-07-10 13:28:39 +02:00
|
|
|
(*SVG_Lib_Init_Func)( FT_Library library );
|
2019-06-15 07:17:47 +02:00
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
*
|
|
|
|
* @functype:
|
2019-07-10 13:28:39 +02:00
|
|
|
* SVG_Lib_Free_Func
|
2019-06-15 07:17:47 +02:00
|
|
|
*
|
|
|
|
* @description:
|
2019-08-24 15:24:28 +02:00
|
|
|
* A callback which is called when the `ot-svg` module is being freed.
|
|
|
|
* It is only called only if the init hook was called earlier. So, if no
|
|
|
|
* OT-SVG glyph is rendered, neither the init hook is called nor the free
|
|
|
|
* hook.
|
2019-06-15 07:17:47 +02:00
|
|
|
*
|
2019-07-05 18:02:17 +02:00
|
|
|
* @input:
|
2019-07-10 10:58:59 +02:00
|
|
|
* library ::
|
2019-08-24 15:24:28 +02:00
|
|
|
* An instance of @FT_Library. It's passed to give the callbacks access
|
|
|
|
* to `svg_renderer_state` of @FT_LibraryRec.
|
2019-06-15 07:17:47 +02:00
|
|
|
*/
|
2019-07-05 18:02:17 +02:00
|
|
|
typedef void
|
2019-07-10 13:28:39 +02:00
|
|
|
(*SVG_Lib_Free_Func)( FT_Library library );
|
2019-06-15 07:17:47 +02:00
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
*
|
|
|
|
* @functype:
|
2019-07-10 13:28:39 +02:00
|
|
|
* SVG_Lib_Render_Func
|
2019-06-15 07:17:47 +02:00
|
|
|
*
|
|
|
|
* @description:
|
2019-08-24 15:24:28 +02:00
|
|
|
* A callback which is called to render an OT-SVG glyph. This callback
|
|
|
|
* hook is called right after the preset hook has been called with
|
|
|
|
* `cache` set to `TRUE`. The data necessary to render is available
|
|
|
|
* through the handle @FT_SVG_Document which is set in `other` field of
|
|
|
|
* @FT_GlyphSlotRec.
|
2019-06-15 07:17:47 +02:00
|
|
|
*
|
|
|
|
* @input:
|
2019-07-06 12:38:37 +02:00
|
|
|
* slot ::
|
2019-08-24 15:24:28 +02:00
|
|
|
* The slot to render.
|
2019-07-06 12:38:37 +02:00
|
|
|
*
|
2019-06-15 07:17:47 +02:00
|
|
|
* @return:
|
|
|
|
* FreeType error code. 0 means success.
|
|
|
|
*/
|
|
|
|
typedef FT_Error
|
2019-08-06 20:32:41 +02:00
|
|
|
(*SVG_Lib_Render_Func)( FT_GlyphSlot slot );
|
2019-07-06 12:38:37 +02:00
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
*
|
|
|
|
* @functype:
|
2019-08-06 20:32:41 +02:00
|
|
|
* SVG_Lib_Preset_Slot_Func
|
2019-07-06 12:38:37 +02:00
|
|
|
*
|
|
|
|
* @description:
|
2019-08-24 15:24:28 +02:00
|
|
|
* A callback which is called to preset the glyphslot. It is called from
|
|
|
|
* two places.
|
|
|
|
*
|
|
|
|
* 1. When `FT_Load_Glyph` needs to preset the glyphslot.
|
|
|
|
* 2. Right before the `ot-svg` module calls the render callback hook.
|
|
|
|
*
|
|
|
|
* When it is the former, the argument `cache` is set to `FALSE`. When it
|
|
|
|
* is the latter, the argument `cache` is set to `TRUE`. This distinction
|
|
|
|
* has been made because while presetting a glyphslot many calculations
|
|
|
|
* are needed and later the render callback hook needs the same
|
|
|
|
* calculations, thus, if `cache` is `TRUE`, the hook might _cache_ these
|
|
|
|
* calculations in `svg_renderer_state` of @FT_LibraryRec.
|
2019-07-06 12:38:37 +02:00
|
|
|
*
|
|
|
|
* @input:
|
|
|
|
* slot ::
|
2019-08-06 20:32:41 +02:00
|
|
|
* The glyph slot which has the SVG document loaded.
|
2019-07-06 12:38:37 +02:00
|
|
|
*
|
2019-08-24 15:24:28 +02:00
|
|
|
* cache ::
|
|
|
|
* See description.
|
|
|
|
*
|
2019-07-06 12:38:37 +02:00
|
|
|
* @return:
|
2019-08-06 20:32:41 +02:00
|
|
|
* FreeType error code. 0 means success.
|
2019-07-06 12:38:37 +02:00
|
|
|
*/
|
2019-08-06 20:32:41 +02:00
|
|
|
typedef FT_Error
|
|
|
|
(*SVG_Lib_Preset_Slot_Func)( FT_GlyphSlot slot, FT_Bool cache);
|
|
|
|
|
2019-06-15 07:17:47 +02:00
|
|
|
|
2019-08-24 11:58:31 +02:00
|
|
|
/**************************************************************************
|
|
|
|
*
|
|
|
|
* @struct:
|
|
|
|
* SVG_RendererHooks
|
|
|
|
*
|
|
|
|
* @description:
|
|
|
|
* A structure that stores the four hooks needed to render OT-SVG glyphs
|
|
|
|
* properly. The structure is publicly used to set the hooks via driver
|
|
|
|
* properties.
|
|
|
|
*
|
|
|
|
* @fields:
|
|
|
|
* init_svg ::
|
|
|
|
* The initialization hook.
|
|
|
|
*
|
|
|
|
* free_svg ::
|
|
|
|
* The cleanup hook.
|
|
|
|
*
|
|
|
|
* render_hook ::
|
|
|
|
* The render hook.
|
|
|
|
*
|
|
|
|
* preset_slot ::
|
|
|
|
* The preset hook.
|
|
|
|
*/
|
2019-07-17 21:05:49 +02:00
|
|
|
typedef struct SVG_RendererHooks_
|
|
|
|
{
|
|
|
|
SVG_Lib_Init_Func init_svg;
|
|
|
|
SVG_Lib_Free_Func free_svg;
|
|
|
|
SVG_Lib_Render_Func render_svg;
|
|
|
|
|
2019-08-06 20:32:41 +02:00
|
|
|
SVG_Lib_Preset_Slot_Func preset_slot;
|
2019-08-24 11:58:31 +02:00
|
|
|
|
2019-07-17 21:05:49 +02:00
|
|
|
} SVG_RendererHooks;
|
|
|
|
|
2019-08-06 20:32:41 +02:00
|
|
|
|
2019-06-20 21:18:24 +02:00
|
|
|
/**************************************************************************
|
|
|
|
*
|
|
|
|
* @struct:
|
|
|
|
* FT_SVG_DocumentRec_
|
|
|
|
*
|
|
|
|
* @description:
|
|
|
|
* A structure that models one SVG document.
|
|
|
|
*
|
|
|
|
* @fields:
|
|
|
|
* svg_document ::
|
2019-08-24 11:58:31 +02:00
|
|
|
* A pointer to the SVG document.
|
2019-06-20 21:18:24 +02:00
|
|
|
*
|
|
|
|
* svg_document_length ::
|
2019-08-24 11:58:31 +02:00
|
|
|
* The length of `svg_document`.
|
2019-06-23 15:02:55 +02:00
|
|
|
*
|
|
|
|
* metrics ::
|
|
|
|
* A metrics object storing the size information.
|
2019-06-23 21:33:45 +02:00
|
|
|
*
|
|
|
|
* units_per_EM ::
|
|
|
|
* The size of the EM square.
|
|
|
|
*
|
2019-06-24 16:34:37 +02:00
|
|
|
* start_glyph_id ::
|
2019-08-24 11:58:31 +02:00
|
|
|
* The first glyph ID in the glyph range is covered by this document.
|
2019-06-24 16:34:37 +02:00
|
|
|
*
|
|
|
|
* end_glyph_id ::
|
2019-08-24 11:58:31 +02:00
|
|
|
* The last glyph ID in the glyph range is covered by this document.
|
2019-06-24 16:34:37 +02:00
|
|
|
*
|
2019-08-17 09:53:50 +02:00
|
|
|
* transform ::
|
2019-08-24 11:58:31 +02:00
|
|
|
* A 2x2 transformation matrix to apply on the glyph while rendering it.
|
2019-08-17 09:53:50 +02:00
|
|
|
*
|
|
|
|
* delta ::
|
|
|
|
* Translation to apply on the glyph while rendering.
|
|
|
|
*
|
2019-06-23 21:33:45 +02:00
|
|
|
* @note:
|
2019-07-11 12:52:31 +02:00
|
|
|
* `metrics` and `units_per_EM` might look like repetitions since both
|
2019-08-10 13:20:59 +02:00
|
|
|
* fields are stored in face object, but they are not; When the slot is
|
|
|
|
* passed down to a renderer, the renderer can only access the `metrics`
|
|
|
|
* and `units_per_EM` by `slot->face`. However, when `FT_Glyph_To_Bitmap`
|
|
|
|
* sets up a dummy object, it has no way to set a `face` object. Thus,
|
|
|
|
* metrics information and units_per_EM (which is necessary for OT-SVG)
|
|
|
|
* has to be stored separately.
|
2019-06-20 21:18:24 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
typedef struct FT_SVG_DocumentRec_
|
|
|
|
{
|
2019-06-22 13:36:29 +02:00
|
|
|
FT_Byte* svg_document;
|
|
|
|
FT_ULong svg_document_length;
|
|
|
|
FT_Size_Metrics metrics;
|
2019-06-23 21:33:45 +02:00
|
|
|
FT_UShort units_per_EM;
|
2019-06-24 16:34:37 +02:00
|
|
|
FT_UShort start_glyph_id;
|
|
|
|
FT_UShort end_glyph_id;
|
2019-08-17 09:53:50 +02:00
|
|
|
FT_Matrix transform;
|
|
|
|
FT_Vector delta;
|
2019-08-24 11:58:31 +02:00
|
|
|
|
2019-06-20 21:18:24 +02:00
|
|
|
} FT_SVG_DocumentRec;
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
*
|
|
|
|
* @type:
|
|
|
|
* FT_SVG_Document
|
|
|
|
*
|
|
|
|
* @description:
|
|
|
|
* A handle to a FT_SVG_DocumentRec object.
|
|
|
|
*/
|
|
|
|
typedef struct FT_SVG_DocumentRec_* FT_SVG_Document;
|
|
|
|
|
2019-06-15 07:17:47 +02:00
|
|
|
FT_END_HEADER
|
|
|
|
#endif
|