Add a `units_per_EM' field.
A field `units_per_EM' is added to `FT_SVG_DocumentRec' and `FT_SvgGlyphRec'. This is needed because the renderer needs this info to properly scale the SVGs if the viewbox width and height differ from `face->units_per_EM'. Face object can't be accessed because of the restrictions put by `FT_Glyph_To_Bitmap' thus this has to be provided separately just like `metrics'.
This commit is contained in:
parent
c9308ac171
commit
5f2dcadbf2
|
@ -259,6 +259,20 @@ FT_BEGIN_HEADER
|
||||||
*
|
*
|
||||||
* metrics ::
|
* metrics ::
|
||||||
* A metrics object storing the size information.
|
* A metrics object storing the size information.
|
||||||
|
*
|
||||||
|
* units_per_EM ::
|
||||||
|
* The size of the EM square.
|
||||||
|
*
|
||||||
|
* @note:
|
||||||
|
* `metrics' and `units_per_EM' might look like repetitions since both
|
||||||
|
* fields are stored in face objects. However, the Glyph Management API
|
||||||
|
* requires an `FT_Glyph' to store all the information that completely
|
||||||
|
* describes a glyph. Outline glyphs are themselves scaled thus they
|
||||||
|
* don't need this information. However, SVG documents do. The field of
|
||||||
|
* `units_per_EM' is needed because the SVG is to be scaled in case its
|
||||||
|
* viewbox size differs from `units_per_EM'. For more info, refer to
|
||||||
|
* the section `Coordinate Systems and Glyph Metrics' of the OpenType
|
||||||
|
* SVG specs.
|
||||||
*/
|
*/
|
||||||
typedef struct FT_SvgGlyphRec_
|
typedef struct FT_SvgGlyphRec_
|
||||||
{
|
{
|
||||||
|
@ -267,6 +281,7 @@ FT_BEGIN_HEADER
|
||||||
FT_ULong svg_document_length;
|
FT_ULong svg_document_length;
|
||||||
FT_UInt glyph_index;
|
FT_UInt glyph_index;
|
||||||
FT_Size_Metrics metrics;
|
FT_Size_Metrics metrics;
|
||||||
|
FT_UShort units_per_EM;
|
||||||
/* TODO: (OT-SVG) Maybe put a transformation matrix here */
|
/* TODO: (OT-SVG) Maybe put a transformation matrix here */
|
||||||
} FT_SvgGlyphRec;
|
} FT_SvgGlyphRec;
|
||||||
|
|
||||||
|
|
|
@ -165,6 +165,20 @@ FT_BEGIN_HEADER
|
||||||
*
|
*
|
||||||
* metrics ::
|
* metrics ::
|
||||||
* A metrics object storing the size information.
|
* A metrics object storing the size information.
|
||||||
|
*
|
||||||
|
* units_per_EM ::
|
||||||
|
* The size of the EM square.
|
||||||
|
*
|
||||||
|
* @note:
|
||||||
|
* `metrics' and `units_per_EM' might look like repetitions since both
|
||||||
|
* fields are stored in face objects. However, the Glyph Management API
|
||||||
|
* requires an `FT_Glyph' to store all the information that completely
|
||||||
|
* describes a glyph. Outline glyphs are themselves scaled thus they
|
||||||
|
* don't need this information. However, SVG documents do. The field of
|
||||||
|
* `units_per_EM' is needed because the SVG is to be scaled in case its
|
||||||
|
* viewbox size differs from `units_per_EM'. For more info, refer to
|
||||||
|
* the section `Coordinate Systems and Glyph Metrics' of the OpenType
|
||||||
|
* SVG specs.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef struct FT_SVG_DocumentRec_
|
typedef struct FT_SVG_DocumentRec_
|
||||||
|
@ -172,6 +186,7 @@ FT_BEGIN_HEADER
|
||||||
FT_Byte* svg_document;
|
FT_Byte* svg_document;
|
||||||
FT_ULong svg_document_length;
|
FT_ULong svg_document_length;
|
||||||
FT_Size_Metrics metrics;
|
FT_Size_Metrics metrics;
|
||||||
|
FT_UShort units_per_EM;
|
||||||
} FT_SVG_DocumentRec;
|
} FT_SVG_DocumentRec;
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
|
|
|
@ -327,6 +327,7 @@
|
||||||
glyph->svg_document_length = doc_length;
|
glyph->svg_document_length = doc_length;
|
||||||
glyph->glyph_index = slot->glyph_index;
|
glyph->glyph_index = slot->glyph_index;
|
||||||
glyph->metrics = document->metrics;
|
glyph->metrics = document->metrics;
|
||||||
|
glyph->units_per_EM = document->units_per_EM;
|
||||||
|
|
||||||
/* copy the document into glyph */
|
/* copy the document into glyph */
|
||||||
FT_MEM_COPY( glyph->svg_document, document->svg_document, doc_length );
|
FT_MEM_COPY( glyph->svg_document, document->svg_document, doc_length );
|
||||||
|
@ -376,6 +377,7 @@
|
||||||
target->glyph_index = source->glyph_index;
|
target->glyph_index = source->glyph_index;
|
||||||
target->svg_document_length = source->svg_document_length;
|
target->svg_document_length = source->svg_document_length;
|
||||||
target->metrics = source->metrics;
|
target->metrics = source->metrics;
|
||||||
|
target->units_per_EM = source->units_per_EM;
|
||||||
|
|
||||||
/* allocate space for the svg document */
|
/* allocate space for the svg document */
|
||||||
target->svg_document = memory->alloc( memory,
|
target->svg_document = memory->alloc( memory,
|
||||||
|
@ -410,6 +412,7 @@
|
||||||
document->svg_document = glyph->svg_document;
|
document->svg_document = glyph->svg_document;
|
||||||
document->svg_document_length = glyph->svg_document_length;
|
document->svg_document_length = glyph->svg_document_length;
|
||||||
document->metrics = glyph->metrics;
|
document->metrics = glyph->metrics;
|
||||||
|
document->units_per_EM = glyph->units_per_EM;
|
||||||
slot->format = FT_GLYPH_FORMAT_SVG;
|
slot->format = FT_GLYPH_FORMAT_SVG;
|
||||||
|
|
||||||
slot->other = document;
|
slot->other = document;
|
||||||
|
|
|
@ -232,6 +232,7 @@
|
||||||
svg_document->svg_document = doc_list;
|
svg_document->svg_document = doc_list;
|
||||||
svg_document->svg_document_length = doc_length;
|
svg_document->svg_document_length = doc_length;
|
||||||
svg_document->metrics = glyph->face->size->metrics;
|
svg_document->metrics = glyph->face->size->metrics;
|
||||||
|
svg_document->units_per_EM = glyph->face->units_per_EM;
|
||||||
|
|
||||||
glyph->other = svg_document;
|
glyph->other = svg_document;
|
||||||
glyph->metrics.horiAdvance *= ((float)glyph->face->size->metrics.x_ppem)/((float)glyph->face->units_per_EM) * 64.0;
|
glyph->metrics.horiAdvance *= ((float)glyph->face->size->metrics.x_ppem)/((float)glyph->face->units_per_EM) * 64.0;
|
||||||
|
|
Loading…
Reference in New Issue