Skip to content
/****************************************************************************
*
* svttglyf.h
*
* The FreeType TrueType glyph service.
*
* Copyright (C) 2007-2024 by
* David Turner.
*
* 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 SVTTGLYF_H_
#define SVTTGLYF_H_
#include <freetype/internal/ftserv.h>
#include <freetype/tttables.h>
FT_BEGIN_HEADER
#define FT_SERVICE_ID_TT_GLYF "tt-glyf"
typedef FT_ULong
(*TT_Glyf_GetLocationFunc)( FT_Face face,
FT_UInt gindex,
FT_ULong *psize );
FT_DEFINE_SERVICE( TTGlyf )
{
TT_Glyf_GetLocationFunc get_location;
};
#define FT_DEFINE_SERVICE_TTGLYFREC( class_, get_location_ ) \
static const FT_Service_TTGlyfRec class_ = \
{ \
get_location_ \
};
/* */
FT_END_HEADER
#endif /* SVTTGLYF_H_ */
/* END */
/****************************************************************************
*
* svwinfnt.h
*
* The FreeType Windows FNT/FONT service (specification).
*
* Copyright (C) 2003-2024 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* 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 SVWINFNT_H_
#define SVWINFNT_H_
#include <freetype/internal/ftserv.h>
#include <freetype/ftwinfnt.h>
FT_BEGIN_HEADER
#define FT_SERVICE_ID_WINFNT "winfonts"
typedef FT_Error
(*FT_WinFnt_GetHeaderFunc)( FT_Face face,
FT_WinFNT_HeaderRec *aheader );
FT_DEFINE_SERVICE( WinFnt )
{
FT_WinFnt_GetHeaderFunc get_header;
};
/* */
FT_END_HEADER
#endif /* SVWINFNT_H_ */
/* END */
/****************************************************************************
*
* sfnt.h
*
* High-level 'sfnt' driver interface (specification).
*
* Copyright (C) 1996-2024 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* 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 SFNT_H_
#define SFNT_H_
#include <freetype/internal/ftdrv.h>
#include <freetype/internal/tttypes.h>
#include <freetype/internal/wofftypes.h>
FT_BEGIN_HEADER
/**************************************************************************
*
* @functype:
* TT_Init_Face_Func
*
* @description:
* First part of the SFNT face object initialization. This finds the
* face in a SFNT file or collection, and load its format tag in
* face->format_tag.
*
* @input:
* stream ::
* The input stream.
*
* face ::
* A handle to the target face object.
*
* face_index ::
* The index of the TrueType font, if we are opening a collection, in
* bits 0-15. The numbered instance index~+~1 of a GX (sub)font, if
* applicable, in bits 16-30.
*
* num_params ::
* The number of additional parameters.
*
* params ::
* Optional additional parameters.
*
* @return:
* FreeType error code. 0 means success.
*
* @note:
* The stream cursor must be at the font file's origin.
*
* This function recognizes fonts embedded in a 'TrueType collection'.
*
* Once the format tag has been validated by the font driver, it should
* then call the TT_Load_Face_Func() callback to read the rest of the
* SFNT tables in the object.
*/
typedef FT_Error
(*TT_Init_Face_Func)( FT_Stream stream,
TT_Face face,
FT_Int face_index,
FT_Int num_params,
FT_Parameter* params );
/**************************************************************************
*
* @functype:
* TT_Load_Face_Func
*
* @description:
* Second part of the SFNT face object initialization. This loads the
* common SFNT tables (head, OS/2, maxp, metrics, etc.) in the face
* object.
*
* @input:
* stream ::
* The input stream.
*
* face ::
* A handle to the target face object.
*
* face_index ::
* The index of the TrueType font, if we are opening a collection, in
* bits 0-15. The numbered instance index~+~1 of a GX (sub)font, if
* applicable, in bits 16-30.
*
* num_params ::
* The number of additional parameters.
*
* params ::
* Optional additional parameters.
*
* @return:
* FreeType error code. 0 means success.
*
* @note:
* This function must be called after TT_Init_Face_Func().
*/
typedef FT_Error
(*TT_Load_Face_Func)( FT_Stream stream,
TT_Face face,
FT_Int face_index,
FT_Int num_params,
FT_Parameter* params );
/**************************************************************************
*
* @functype:
* TT_Done_Face_Func
*
* @description:
* A callback used to delete the common SFNT data from a face.
*
* @input:
* face ::
* A handle to the target face object.
*
* @note:
* This function does NOT destroy the face object.
*/
typedef void
(*TT_Done_Face_Func)( TT_Face face );
/**************************************************************************
*
* @functype:
* TT_Load_Any_Func
*
* @description:
* Load any font table into client memory.
*
* @input:
* face ::
* The face object to look for.
*
* tag ::
* The tag of table to load. Use the value 0 if you want to access the
* whole font file, else set this parameter to a valid TrueType table
* tag that you can forge with the MAKE_TT_TAG macro.
*
* offset ::
* The starting offset in the table (or the file if tag == 0).
*
* length ::
* The address of the decision variable:
*
* If `length == NULL`: Loads the whole table. Returns an error if
* 'offset' == 0!
*
* If `*length == 0`: Exits immediately; returning the length of the
* given table or of the font file, depending on the value of 'tag'.
*
* If `*length != 0`: Loads the next 'length' bytes of table or font,
* starting at offset 'offset' (in table or font too).
*
* @output:
* buffer ::
* The address of target buffer.
*
* @return:
* TrueType error code. 0 means success.
*/
typedef FT_Error
(*TT_Load_Any_Func)( TT_Face face,
FT_ULong tag,
FT_Long offset,
FT_Byte *buffer,
FT_ULong* length );
/**************************************************************************
*
* @functype:
* TT_Find_SBit_Image_Func
*
* @description:
* Check whether an embedded bitmap (an 'sbit') exists for a given glyph,
* at a given strike.
*
* @input:
* face ::
* The target face object.
*
* glyph_index ::
* The glyph index.
*
* strike_index ::
* The current strike index.
*
* @output:
* arange ::
* The SBit range containing the glyph index.
*
* astrike ::
* The SBit strike containing the glyph index.
*
* aglyph_offset ::
* The offset of the glyph data in 'EBDT' table.
*
* @return:
* FreeType error code. 0 means success. Returns
* SFNT_Err_Invalid_Argument if no sbit exists for the requested glyph.
*/
typedef FT_Error
(*TT_Find_SBit_Image_Func)( TT_Face face,
FT_UInt glyph_index,
FT_ULong strike_index,
TT_SBit_Range *arange,
TT_SBit_Strike *astrike,
FT_ULong *aglyph_offset );
/**************************************************************************
*
* @functype:
* TT_Load_SBit_Metrics_Func
*
* @description:
* Get the big metrics for a given embedded bitmap.
*
* @input:
* stream ::
* The input stream.
*
* range ::
* The SBit range containing the glyph.
*
* @output:
* big_metrics ::
* A big SBit metrics structure for the glyph.
*
* @return:
* FreeType error code. 0 means success.
*
* @note:
* The stream cursor must be positioned at the glyph's offset within the
* 'EBDT' table before the call.
*
* If the image format uses variable metrics, the stream cursor is
* positioned just after the metrics header in the 'EBDT' table on
* function exit.
*/
typedef FT_Error
(*TT_Load_SBit_Metrics_Func)( FT_Stream stream,
TT_SBit_Range range,
TT_SBit_Metrics metrics );
/**************************************************************************
*
* @functype:
* TT_Load_SBit_Image_Func
*
* @description:
* Load a given glyph sbit image from the font resource. This also
* returns its metrics.
*
* @input:
* face ::
* The target face object.
*
* strike_index ::
* The strike index.
*
* glyph_index ::
* The current glyph index.
*
* load_flags ::
* The current load flags.
*
* stream ::
* The input stream.
*
* @output:
* amap ::
* The target pixmap.
*
* ametrics ::
* A big sbit metrics structure for the glyph image.
*
* @return:
* FreeType error code. 0 means success. Returns an error if no glyph
* sbit exists for the index.
*
* @note:
* The `map.buffer` field is always freed before the glyph is loaded.
*/
typedef FT_Error
(*TT_Load_SBit_Image_Func)( TT_Face face,
FT_ULong strike_index,
FT_UInt glyph_index,
FT_UInt load_flags,
FT_Stream stream,
FT_Bitmap *amap,
TT_SBit_MetricsRec *ametrics );
/**************************************************************************
*
* @functype:
* TT_Load_Svg_Doc_Func
*
* @description:
* Scan the SVG document list to find the document containing the glyph
* that has the ID 'glyph*XXX*', where *XXX* is the value of
* `glyph_index` as a decimal integer.
*
* @inout:
* glyph ::
* The glyph slot from which pointers to the SVG document list is to be
* grabbed. The results are stored back in the slot.
*
* @input:
* glyph_index ::
* The index of the glyph that is to be looked up.
*
* @return:
* FreeType error code. 0 means success.
*/
typedef FT_Error
(*TT_Load_Svg_Doc_Func)( FT_GlyphSlot glyph,
FT_UInt glyph_index );
/**************************************************************************
*
* @functype:
* TT_Set_SBit_Strike_Func
*
* @description:
* Select an sbit strike for a given size request.
*
* @input:
* face ::
* The target face object.
*
* req ::
* The size request.
*
* @output:
* astrike_index ::
* The index of the sbit strike.
*
* @return:
* FreeType error code. 0 means success. Returns an error if no sbit
* strike exists for the selected ppem values.
*/
typedef FT_Error
(*TT_Set_SBit_Strike_Func)( TT_Face face,
FT_Size_Request req,
FT_ULong* astrike_index );
/**************************************************************************
*
* @functype:
* TT_Load_Strike_Metrics_Func
*
* @description:
* Load the metrics of a given strike.
*
* @input:
* face ::
* The target face object.
*
* strike_index ::
* The strike index.
*
* @output:
* metrics ::
* the metrics of the strike.
*
* @return:
* FreeType error code. 0 means success. Returns an error if no such
* sbit strike exists.
*/
typedef FT_Error
(*TT_Load_Strike_Metrics_Func)( TT_Face face,
FT_ULong strike_index,
FT_Size_Metrics* metrics );
/**************************************************************************
*
* @functype:
* TT_Get_PS_Name_Func
*
* @description:
* Get the PostScript glyph name of a glyph.
*
* @input:
* idx ::
* The glyph index.
*
* PSname ::
* The address of a string pointer. Will be `NULL` in case of error,
* otherwise it is a pointer to the glyph name.
*
* You must not modify the returned string!
*
* @output:
* FreeType error code. 0 means success.
*/
typedef FT_Error
(*TT_Get_PS_Name_Func)( TT_Face face,
FT_UInt idx,
FT_String** PSname );
/**************************************************************************
*
* @functype:
* TT_Load_Metrics_Func
*
* @description:
* Load a metrics table, which is a table with a horizontal and a
* vertical version.
*
* @input:
* face ::
* A handle to the target face object.
*
* stream ::
* The input stream.
*
* vertical ::
* A boolean flag. If set, load the vertical one.
*
* @return:
* FreeType error code. 0 means success.
*/
typedef FT_Error
(*TT_Load_Metrics_Func)( TT_Face face,
FT_Stream stream,
FT_Bool vertical );
/**************************************************************************
*
* @functype:
* TT_Get_Metrics_Func
*
* @description:
* Load the horizontal or vertical header in a face object.
*
* @input:
* face ::
* A handle to the target face object.
*
* vertical ::
* A boolean flag. If set, load vertical metrics.
*
* gindex ::
* The glyph index.
*
* @output:
* abearing ::
* The horizontal (or vertical) bearing. Set to zero in case of error.
*
* aadvance ::
* The horizontal (or vertical) advance. Set to zero in case of error.
*/
typedef void
(*TT_Get_Metrics_Func)( TT_Face face,
FT_Bool vertical,
FT_UInt gindex,
FT_Short* abearing,
FT_UShort* aadvance );
/**************************************************************************
*
* @functype:
* TT_Set_Palette_Func
*
* @description:
* Load the colors into `face->palette` for a given palette index.
*
* @input:
* face ::
* The target face object.
*
* idx ::
* The palette index.
*
* @return:
* FreeType error code. 0 means success.
*/
typedef FT_Error
(*TT_Set_Palette_Func)( TT_Face face,
FT_UInt idx );
/**************************************************************************
*
* @functype:
* TT_Get_Colr_Layer_Func
*
* @description:
* Iteratively get the color layer data of a given glyph index.
*
* @input:
* face ::
* The target face object.
*
* base_glyph ::
* The glyph index the colored glyph layers are associated with.
*
* @inout:
* iterator ::
* An @FT_LayerIterator object. For the first call you should set
* `iterator->p` to `NULL`. For all following calls, simply use the
* same object again.
*
* @output:
* aglyph_index ::
* The glyph index of the current layer.
*
* acolor_index ::
* The color index into the font face's color palette of the current
* layer. The value 0xFFFF is special; it doesn't reference a palette
* entry but indicates that the text foreground color should be used
* instead (to be set up by the application outside of FreeType).
*
* @return:
* Value~1 if everything is OK. If there are no more layers (or if there
* are no layers at all), value~0 gets returned. In case of an error,
* value~0 is returned also.
*/
typedef FT_Bool
(*TT_Get_Colr_Layer_Func)( TT_Face face,
FT_UInt base_glyph,
FT_UInt *aglyph_index,
FT_UInt *acolor_index,
FT_LayerIterator* iterator );
/**************************************************************************
*
* @functype:
* TT_Get_Color_Glyph_Paint_Func
*
* @description:
* Find the root @FT_OpaquePaint object for a given glyph ID.
*
* @input:
* face ::
* The target face object.
*
* base_glyph ::
* The glyph index the colored glyph layers are associated with.
*
* @output:
* paint ::
* The root @FT_OpaquePaint object.
*
* @return:
* Value~1 if everything is OK. If no color glyph is found, or the root
* paint could not be retrieved, value~0 gets returned. In case of an
* error, value~0 is returned also.
*/
typedef FT_Bool
( *TT_Get_Color_Glyph_Paint_Func )( TT_Face face,
FT_UInt base_glyph,
FT_Color_Root_Transform root_transform,
FT_OpaquePaint *paint );
/**************************************************************************
*
* @functype:
* TT_Get_Color_Glyph_ClipBox_Func
*
* @description:
* Search for a 'COLR' v1 clip box for the specified `base_glyph` and
* fill the `clip_box` parameter with the 'COLR' v1 'ClipBox' information
* if one is found.
*
* @input:
* face ::
* A handle to the parent face object.
*
* base_glyph ::
* The glyph index for which to retrieve the clip box.
*
* @output:
* clip_box ::
* The clip box for the requested `base_glyph` if one is found. The
* clip box is computed taking scale and transformations configured on
* the @FT_Face into account. @FT_ClipBox contains @FT_Vector values
* in 26.6 format.
*
* @note:
* To retrieve the clip box in font units, reset scale to units-per-em
* and remove transforms configured using @FT_Set_Transform.
*
* @return:
* Value~1 if a ClipBox is found. If no clip box is found or an
* error occured, value~0 is returned.
*/
typedef FT_Bool
( *TT_Get_Color_Glyph_ClipBox_Func )( TT_Face face,
FT_UInt base_glyph,
FT_ClipBox* clip_box );
/**************************************************************************
*
* @functype:
* TT_Get_Paint_Layers_Func
*
* @description:
* Access the layers of a `PaintColrLayers` table.
*
* @input:
* face ::
* The target face object.
*
* @inout:
* iterator ::
* The @FT_LayerIterator from an @FT_PaintColrLayers object, for which
* the layers are to be retrieved. The internal state of the iterator
* is incremented after one call to this function for retrieving one
* layer.
*
* @output:
* paint ::
* The root @FT_OpaquePaint object referencing the actual paint table.
*
* @return:
* Value~1 if everything is OK. Value~0 gets returned when the paint
* object can not be retrieved or any other error occurs.
*/
typedef FT_Bool
( *TT_Get_Paint_Layers_Func )( TT_Face face,
FT_LayerIterator* iterator,
FT_OpaquePaint *paint );
/**************************************************************************
*
* @functype:
* TT_Get_Colorline_Stops_Func
*
* @description:
* Get the gradient and solid fill information for a given glyph.
*
* @input:
* face ::
* The target face object.
*
* @inout:
* iterator ::
* An @FT_ColorStopIterator object. For the first call you should set
* `iterator->p` to `NULL`. For all following calls, simply use the
* same object again.
*
* @output:
* color_stop ::
* Color index and alpha value for the retrieved color stop.
*
* @return:
* Value~1 if everything is OK. If there are no more color stops,
* value~0 gets returned. In case of an error, value~0 is returned
* also.
*/
typedef FT_Bool
( *TT_Get_Colorline_Stops_Func )( TT_Face face,
FT_ColorStop *color_stop,
FT_ColorStopIterator* iterator );
/**************************************************************************
*
* @functype:
* TT_Get_Paint_Func
*
* @description:
* Get the paint details for a given @FT_OpaquePaint object.
*
* @input:
* face ::
* The target face object.
*
* opaque_paint ::
* The @FT_OpaquePaint object.
*
* @output:
* paint ::
* An @FT_COLR_Paint object holding the details on `opaque_paint`.
*
* @return:
* Value~1 if everything is OK. Value~0 if no details can be found for
* this paint or any other error occured.
*/
typedef FT_Bool
( *TT_Get_Paint_Func )( TT_Face face,
FT_OpaquePaint opaque_paint,
FT_COLR_Paint *paint );
/**************************************************************************
*
* @functype:
* TT_Blend_Colr_Func
*
* @description:
* Blend the bitmap in `new_glyph` into `base_glyph` using the color
* specified by `color_index`. If `color_index` is 0xFFFF, use
* `face->foreground_color` if `face->have_foreground_color` is set.
* Otherwise check `face->palette_data.palette_flags`: If present and
* @FT_PALETTE_FOR_DARK_BACKGROUND is set, use BGRA value 0xFFFFFFFF
* (white opaque). Otherwise use BGRA value 0x000000FF (black opaque).
*
* @input:
* face ::
* The target face object.
*
* color_index ::
* Color index from the COLR table.
*
* base_glyph ::
* Slot for bitmap to be merged into. The underlying bitmap may get
* reallocated.
*
* new_glyph ::
* Slot to be incooperated into `base_glyph`.
*
* @return:
* FreeType error code. 0 means success. Returns an error if
* color_index is invalid or reallocation fails.
*/
typedef FT_Error
(*TT_Blend_Colr_Func)( TT_Face face,
FT_UInt color_index,
FT_GlyphSlot base_glyph,
FT_GlyphSlot new_glyph );
/**************************************************************************
*
* @functype:
* TT_Get_Name_Func
*
* @description:
* From the 'name' table, return a given ENGLISH name record in ASCII.
*
* @input:
* face ::
* A handle to the source face object.
*
* nameid ::
* The name id of the name record to return.
*
* @inout:
* name ::
* The address of an allocated string pointer. `NULL` if no name is
* present.
*
* @return:
* FreeType error code. 0 means success.
*/
typedef FT_Error
(*TT_Get_Name_Func)( TT_Face face,
FT_UShort nameid,
FT_String** name );
/**************************************************************************
*
* @functype:
* TT_Get_Name_ID_Func
*
* @description:
* Search whether an ENGLISH version for a given name ID is in the 'name'
* table.
*
* @input:
* face ::
* A handle to the source face object.
*
* nameid ::
* The name id of the name record to return.
*
* @output:
* win ::
* If non-negative, an index into the 'name' table with the
* corresponding (3,1) or (3,0) Windows entry.
*
* apple ::
* If non-negative, an index into the 'name' table with the
* corresponding (1,0) Apple entry.
*
* @return:
* 1 if there is either a win or apple entry (or both), 0 otheriwse.
*/
typedef FT_Bool
(*TT_Get_Name_ID_Func)( TT_Face face,
FT_UShort nameid,
FT_Int *win,
FT_Int *apple );
/**************************************************************************
*
* @functype:
* TT_Load_Table_Func
*
* @description:
* Load a given TrueType table.
*
* @input:
* face ::
* A handle to the target face object.
*
* stream ::
* The input stream.
*
* @return:
* FreeType error code. 0 means success.
*
* @note:
* The function uses `face->goto_table` to seek the stream to the start
* of the table, except while loading the font directory.
*/
typedef FT_Error
(*TT_Load_Table_Func)( TT_Face face,
FT_Stream stream );
/**************************************************************************
*
* @functype:
* TT_Free_Table_Func
*
* @description:
* Free a given TrueType table.
*
* @input:
* face ::
* A handle to the target face object.
*/
typedef void
(*TT_Free_Table_Func)( TT_Face face );
/*
* @functype:
* TT_Face_GetKerningFunc
*
* @description:
* Return the horizontal kerning value between two glyphs.
*
* @input:
* face ::
* A handle to the source face object.
*
* left_glyph ::
* The left glyph index.
*
* right_glyph ::
* The right glyph index.
*
* @return:
* The kerning value in font units.
*/
typedef FT_Int
(*TT_Face_GetKerningFunc)( TT_Face face,
FT_UInt left_glyph,
FT_UInt right_glyph );
/**************************************************************************
*
* @struct:
* SFNT_Interface
*
* @description:
* This structure holds pointers to the functions used to load and free
* the basic tables that are required in a 'sfnt' font file.
*
* @fields:
* Check the various xxx_Func() descriptions for details.
*/
typedef struct SFNT_Interface_
{
TT_Loader_GotoTableFunc goto_table;
TT_Init_Face_Func init_face;
TT_Load_Face_Func load_face;
TT_Done_Face_Func done_face;
FT_Module_Requester get_interface;
TT_Load_Any_Func load_any;
/* these functions are called by `load_face' but they can also */
/* be called from external modules, if there is a need to do so */
TT_Load_Table_Func load_head;
TT_Load_Metrics_Func load_hhea;
TT_Load_Table_Func load_cmap;
TT_Load_Table_Func load_maxp;
TT_Load_Table_Func load_os2;
TT_Load_Table_Func load_post;
TT_Load_Table_Func load_name;
TT_Free_Table_Func free_name;
/* this field was called `load_kerning' up to version 2.1.10 */
TT_Load_Table_Func load_kern;
TT_Load_Table_Func load_gpos;
TT_Load_Table_Func load_gasp;
TT_Load_Table_Func load_pclt;
/* see `ttload.h'; this field was called `load_bitmap_header' up to */
/* version 2.1.10 */
TT_Load_Table_Func load_bhed;
TT_Load_SBit_Image_Func load_sbit_image;
/* see `ttpost.h' */
TT_Get_PS_Name_Func get_psname;
TT_Free_Table_Func free_psnames;
/* starting here, the structure differs from version 2.1.7 */
/* this field was introduced in version 2.1.8, named `get_psname' */
TT_Face_GetKerningFunc get_kerning;
/* new elements introduced after version 2.1.10 */
TT_Face_GetKerningFunc get_gpos_kerning;
/* load the font directory, i.e., the offset table and */
/* the table directory */
TT_Load_Table_Func load_font_dir;
TT_Load_Metrics_Func load_hmtx;
TT_Load_Table_Func load_eblc;
TT_Free_Table_Func free_eblc;
TT_Set_SBit_Strike_Func set_sbit_strike;
TT_Load_Strike_Metrics_Func load_strike_metrics;
TT_Load_Table_Func load_cpal;
TT_Load_Table_Func load_colr;
TT_Free_Table_Func free_cpal;
TT_Free_Table_Func free_colr;
TT_Set_Palette_Func set_palette;
TT_Get_Colr_Layer_Func get_colr_layer;
TT_Get_Color_Glyph_Paint_Func get_colr_glyph_paint;
TT_Get_Color_Glyph_ClipBox_Func get_color_glyph_clipbox;
TT_Get_Paint_Layers_Func get_paint_layers;
TT_Get_Colorline_Stops_Func get_colorline_stops;
TT_Get_Paint_Func get_paint;
TT_Blend_Colr_Func colr_blend;
TT_Get_Metrics_Func get_metrics;
TT_Get_Name_Func get_name;
TT_Get_Name_ID_Func get_name_id;
/* OpenType SVG Support */
TT_Load_Table_Func load_svg;
TT_Free_Table_Func free_svg;
TT_Load_Svg_Doc_Func load_svg_doc;
} SFNT_Interface;
/* transitional */
typedef SFNT_Interface* SFNT_Service;
#define FT_DEFINE_SFNT_INTERFACE( \
class_, \
goto_table_, \
init_face_, \
load_face_, \
done_face_, \
get_interface_, \
load_any_, \
load_head_, \
load_hhea_, \
load_cmap_, \
load_maxp_, \
load_os2_, \
load_post_, \
load_name_, \
free_name_, \
load_kern_, \
load_gpos_, \
load_gasp_, \
load_pclt_, \
load_bhed_, \
load_sbit_image_, \
get_psname_, \
free_psnames_, \
get_kerning_, \
get_gpos_kerning_, \
load_font_dir_, \
load_hmtx_, \
load_eblc_, \
free_eblc_, \
set_sbit_strike_, \
load_strike_metrics_, \
load_cpal_, \
load_colr_, \
free_cpal_, \
free_colr_, \
set_palette_, \
get_colr_layer_, \
get_colr_glyph_paint_, \
get_color_glyph_clipbox, \
get_paint_layers_, \
get_colorline_stops_, \
get_paint_, \
colr_blend_, \
get_metrics_, \
get_name_, \
get_name_id_, \
load_svg_, \
free_svg_, \
load_svg_doc_ ) \
static const SFNT_Interface class_ = \
{ \
goto_table_, \
init_face_, \
load_face_, \
done_face_, \
get_interface_, \
load_any_, \
load_head_, \
load_hhea_, \
load_cmap_, \
load_maxp_, \
load_os2_, \
load_post_, \
load_name_, \
free_name_, \
load_kern_, \
load_gpos_, \
load_gasp_, \
load_pclt_, \
load_bhed_, \
load_sbit_image_, \
get_psname_, \
free_psnames_, \
get_kerning_, \
get_gpos_kerning_, \
load_font_dir_, \
load_hmtx_, \
load_eblc_, \
free_eblc_, \
set_sbit_strike_, \
load_strike_metrics_, \
load_cpal_, \
load_colr_, \
free_cpal_, \
free_colr_, \
set_palette_, \
get_colr_layer_, \
get_colr_glyph_paint_, \
get_color_glyph_clipbox, \
get_paint_layers_, \
get_colorline_stops_, \
get_paint_, \
colr_blend_, \
get_metrics_, \
get_name_, \
get_name_id_, \
load_svg_, \
free_svg_, \
load_svg_doc_ \
};
FT_END_HEADER
#endif /* SFNT_H_ */
/* END */
/****************************************************************************
*
* svginterface.h
*
* Interface of ot-svg module (specification only).
*
* Copyright (C) 2022-2024 by
* David Turner, Robert Wilhelm, Werner Lemberg, and Moazin Khatti.
*
* 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 SVGINTERFACE_H_
#define SVGINTERFACE_H_
#include <ft2build.h>
#include <freetype/otsvg.h>
FT_BEGIN_HEADER
typedef FT_Error
(*Preset_Bitmap_Func)( FT_Module module,
FT_GlyphSlot slot,
FT_Bool cache );
typedef struct SVG_Interface_
{
Preset_Bitmap_Func preset_slot;
} SVG_Interface;
typedef SVG_Interface* SVG_Service;
FT_END_HEADER
#endif /* SVGINTERFACE_H_ */
/* END */
/****************************************************************************
*
* t1types.h
*
* Basic Type1/Type2 type definitions and interface (specification
* only).
*
* Copyright (C) 1996-2024 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* 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 T1TYPES_H_
#define T1TYPES_H_
#include <freetype/ftmm.h>
#include <freetype/internal/pshints.h>
#include <freetype/internal/ftserv.h>
#include <freetype/internal/fthash.h>
#include <freetype/internal/services/svpscmap.h>
FT_BEGIN_HEADER
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/*** ***/
/*** ***/
/*** REQUIRED TYPE1/TYPE2 TABLES DEFINITIONS ***/
/*** ***/
/*** ***/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/**************************************************************************
*
* @struct:
* T1_EncodingRec
*
* @description:
* A structure modeling a custom encoding.
*
* @fields:
* num_chars ::
* The number of character codes in the encoding. Usually 256.
*
* code_first ::
* The lowest valid character code in the encoding.
*
* code_last ::
* The highest valid character code in the encoding + 1. When equal to
* code_first there are no valid character codes.
*
* char_index ::
* An array of corresponding glyph indices.
*
* char_name ::
* An array of corresponding glyph names.
*/
typedef struct T1_EncodingRecRec_
{
FT_Int num_chars;
FT_Int code_first;
FT_Int code_last;
FT_UShort* char_index;
const FT_String** char_name;
} T1_EncodingRec, *T1_Encoding;
/* used to hold extra data of PS_FontInfoRec that
* cannot be stored in the publicly defined structure.
*
* Note these can't be blended with multiple-masters.
*/
typedef struct PS_FontExtraRec_
{
FT_UShort fs_type;
} PS_FontExtraRec;
typedef struct T1_FontRec_
{
PS_FontInfoRec font_info; /* font info dictionary */
PS_FontExtraRec font_extra; /* font info extra fields */
PS_PrivateRec private_dict; /* private dictionary */
FT_String* font_name; /* top-level dictionary */
T1_EncodingType encoding_type;
T1_EncodingRec encoding;
FT_Byte* subrs_block;
FT_Byte* charstrings_block;
FT_Byte* glyph_names_block;
FT_Int num_subrs;
FT_Byte** subrs;
FT_UInt* subrs_len;
FT_Hash subrs_hash;
FT_Int num_glyphs;
FT_String** glyph_names; /* array of glyph names */
FT_Byte** charstrings; /* array of glyph charstrings */
FT_UInt* charstrings_len;
FT_Byte paint_type;
FT_Byte font_type;
FT_Matrix font_matrix;
FT_Vector font_offset;
FT_BBox font_bbox;
FT_Long font_id;
FT_Fixed stroke_width;
} T1_FontRec, *T1_Font;
typedef struct CID_SubrsRec_
{
FT_Int num_subrs;
FT_Byte** code;
} CID_SubrsRec, *CID_Subrs;
/* this structure is used to store the BlendDesignMap entry for an axis */
typedef struct PS_DesignMap_
{
FT_Byte num_points;
FT_Long* design_points;
FT_Fixed* blend_points;
} PS_DesignMapRec, *PS_DesignMap;
/* backward compatible definition */
typedef PS_DesignMapRec T1_DesignMap;
typedef struct PS_BlendRec_
{
FT_UInt num_designs;
FT_UInt num_axis;
FT_String* axis_names[T1_MAX_MM_AXIS];
FT_Fixed* design_pos[T1_MAX_MM_DESIGNS];
PS_DesignMapRec design_map[T1_MAX_MM_AXIS];
FT_Fixed* weight_vector;
FT_Fixed* default_weight_vector;
PS_FontInfo font_infos[T1_MAX_MM_DESIGNS + 1];
PS_Private privates [T1_MAX_MM_DESIGNS + 1];
FT_ULong blend_bitflags;
FT_BBox* bboxes [T1_MAX_MM_DESIGNS + 1];
/* since 2.3.0 */
/* undocumented, optional: the default design instance; */
/* corresponds to default_weight_vector -- */
/* num_default_design_vector == 0 means it is not present */
/* in the font and associated metrics files */
FT_UInt default_design_vector[T1_MAX_MM_DESIGNS];
FT_UInt num_default_design_vector;
} PS_BlendRec, *PS_Blend;
/* backward compatible definition */
typedef PS_BlendRec T1_Blend;
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/*** ***/
/*** ***/
/*** AFM FONT INFORMATION STRUCTURES ***/
/*** ***/
/*** ***/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
typedef struct AFM_TrackKernRec_
{
FT_Int degree;
FT_Fixed min_ptsize;
FT_Fixed min_kern;
FT_Fixed max_ptsize;
FT_Fixed max_kern;
} AFM_TrackKernRec, *AFM_TrackKern;
typedef struct AFM_KernPairRec_
{
FT_UInt index1;
FT_UInt index2;
FT_Int x;
FT_Int y;
} AFM_KernPairRec, *AFM_KernPair;
typedef struct AFM_FontInfoRec_
{
FT_Bool IsCIDFont;
FT_BBox FontBBox;
FT_Fixed Ascender; /* optional, mind the zero */
FT_Fixed Descender; /* optional, mind the zero */
AFM_TrackKern TrackKerns; /* free if non-NULL */
FT_UInt NumTrackKern;
AFM_KernPair KernPairs; /* free if non-NULL */
FT_UInt NumKernPair;
} AFM_FontInfoRec, *AFM_FontInfo;
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/*** ***/
/*** ***/
/*** ORIGINAL T1_FACE CLASS DEFINITION ***/
/*** ***/
/*** ***/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
typedef struct T1_FaceRec_* T1_Face;
typedef struct CID_FaceRec_* CID_Face;
typedef struct T1_FaceRec_
{
FT_FaceRec root;
T1_FontRec type1;
const void* psnames;
const void* psaux;
const void* afm_data;
FT_CharMapRec charmaprecs[2];
FT_CharMap charmaps[2];
/* support for Multiple Masters fonts */
PS_Blend blend;
/* undocumented, optional: indices of subroutines that express */
/* the NormalizeDesignVector and the ConvertDesignVector procedure, */
/* respectively, as Type 2 charstrings; -1 if keywords not present */
FT_Int ndv_idx;
FT_Int cdv_idx;
/* undocumented, optional: has the same meaning as len_buildchar */
/* for Type 2 fonts; manipulated by othersubrs 19, 24, and 25 */
FT_UInt len_buildchar;
FT_Long* buildchar;
/* since version 2.1 - interface to PostScript hinter */
const void* pshinter;
} T1_FaceRec;
typedef struct CID_FaceRec_
{
FT_FaceRec root;
void* psnames;
void* psaux;
CID_FaceInfoRec cid;
PS_FontExtraRec font_extra;
#if 0
void* afm_data;
#endif
CID_Subrs subrs;
/* since version 2.1 - interface to PostScript hinter */
void* pshinter;
/* since version 2.1.8, but was originally positioned after `afm_data' */
FT_Byte* binary_data; /* used if hex data has been converted */
FT_Stream cid_stream;
} CID_FaceRec;
FT_END_HEADER
#endif /* T1TYPES_H_ */
/* END */
/****************************************************************************
*
* tttypes.h
*
* Basic SFNT/TrueType type definitions and interface (specification
* only).
*
* Copyright (C) 1996-2024 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* 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 TTTYPES_H_
#define TTTYPES_H_
#include <freetype/tttables.h>
#include <freetype/internal/ftobjs.h>
#include <freetype/ftcolor.h>
#include "freetype/fttypes.h"
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
#include <freetype/ftmm.h>
#endif
FT_BEGIN_HEADER
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/*** ***/
/*** ***/
/*** REQUIRED TRUETYPE/OPENTYPE TABLES DEFINITIONS ***/
/*** ***/
/*** ***/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/**************************************************************************
*
* @struct:
* TTC_HeaderRec
*
* @description:
* TrueType collection header. This table contains the offsets of the
* font headers of each distinct TrueType face in the file.
*
* @fields:
* tag ::
* Must be 'ttc~' to indicate a TrueType collection.
*
* version ::
* The version number.
*
* count ::
* The number of faces in the collection. The specification says this
* should be an unsigned long, but we use a signed long since we need
* the value -1 for specific purposes.
*
* offsets ::
* The offsets of the font headers, one per face.
*/
typedef struct TTC_HeaderRec_
{
FT_ULong tag;
FT_Fixed version;
FT_Long count;
FT_ULong* offsets;
} TTC_HeaderRec;
/**************************************************************************
*
* @struct:
* SFNT_HeaderRec
*
* @description:
* SFNT file format header.
*
* @fields:
* format_tag ::
* The font format tag.
*
* num_tables ::
* The number of tables in file.
*
* search_range ::
* Must be '16 * (max power of 2 <= num_tables)'.
*
* entry_selector ::
* Must be log2 of 'search_range / 16'.
*
* range_shift ::
* Must be 'num_tables * 16 - search_range'.
*/
typedef struct SFNT_HeaderRec_
{
FT_ULong format_tag;
FT_UShort num_tables;
FT_UShort search_range;
FT_UShort entry_selector;
FT_UShort range_shift;
FT_ULong offset; /* not in file */
} SFNT_HeaderRec, *SFNT_Header;
/**************************************************************************
*
* @struct:
* TT_TableRec
*
* @description:
* This structure describes a given table of a TrueType font.
*
* @fields:
* Tag ::
* A four-bytes tag describing the table.
*
* CheckSum ::
* The table checksum. This value can be ignored.
*
* Offset ::
* The offset of the table from the start of the TrueType font in its
* resource.
*
* Length ::
* The table length (in bytes).
*/
typedef struct TT_TableRec_
{
FT_ULong Tag; /* table type */
FT_ULong CheckSum; /* table checksum */
FT_ULong Offset; /* table file offset */
FT_ULong Length; /* table length */
} TT_TableRec, *TT_Table;
/**************************************************************************
*
* @struct:
* TT_LongMetricsRec
*
* @description:
* A structure modeling the long metrics of the 'hmtx' and 'vmtx'
* TrueType tables. The values are expressed in font units.
*
* @fields:
* advance ::
* The advance width or height for the glyph.
*
* bearing ::
* The left-side or top-side bearing for the glyph.
*/
typedef struct TT_LongMetricsRec_
{
FT_UShort advance;
FT_Short bearing;
} TT_LongMetricsRec, *TT_LongMetrics;
/**************************************************************************
*
* @type:
* TT_ShortMetrics
*
* @description:
* A simple type to model the short metrics of the 'hmtx' and 'vmtx'
* tables.
*/
typedef FT_Short TT_ShortMetrics;
/**************************************************************************
*
* @struct:
* TT_NameRec
*
* @description:
* A structure modeling TrueType name records. Name records are used to
* store important strings like family name, style name, copyright,
* etc. in _localized_ versions (i.e., language, encoding, etc).
*
* @fields:
* platformID ::
* The ID of the name's encoding platform.
*
* encodingID ::
* The platform-specific ID for the name's encoding.
*
* languageID ::
* The platform-specific ID for the name's language.
*
* nameID ::
* The ID specifying what kind of name this is.
*
* stringLength ::
* The length of the string in bytes.
*
* stringOffset ::
* The offset to the string in the 'name' table.
*
* string ::
* A pointer to the string's bytes. Note that these are usually UTF-16
* encoded characters.
*/
typedef struct TT_NameRec_
{
FT_UShort platformID;
FT_UShort encodingID;
FT_UShort languageID;
FT_UShort nameID;
FT_UShort stringLength;
FT_ULong stringOffset;
/* this last field is not defined in the spec */
/* but used by the FreeType engine */
FT_Byte* string;
} TT_NameRec, *TT_Name;
/**************************************************************************
*
* @struct:
* TT_LangTagRec
*
* @description:
* A structure modeling language tag records in SFNT 'name' tables,
* introduced in OpenType version 1.6.
*
* @fields:
* stringLength ::
* The length of the string in bytes.
*
* stringOffset ::
* The offset to the string in the 'name' table.
*
* string ::
* A pointer to the string's bytes. Note that these are UTF-16BE
* encoded characters.
*/
typedef struct TT_LangTagRec_
{
FT_UShort stringLength;
FT_ULong stringOffset;
/* this last field is not defined in the spec */
/* but used by the FreeType engine */
FT_Byte* string;
} TT_LangTagRec, *TT_LangTag;
/**************************************************************************
*
* @struct:
* TT_NameTableRec
*
* @description:
* A structure modeling the TrueType name table.
*
* @fields:
* format ::
* The format of the name table.
*
* numNameRecords ::
* The number of names in table.
*
* storageOffset ::
* The offset of the name table in the 'name' TrueType table.
*
* names ::
* An array of name records.
*
* numLangTagRecords ::
* The number of language tags in table.
*
* langTags ::
* An array of language tag records.
*
* stream ::
* The file's input stream.
*/
typedef struct TT_NameTableRec_
{
FT_UShort format;
FT_UInt numNameRecords;
FT_UInt storageOffset;
TT_NameRec* names;
FT_UInt numLangTagRecords;
TT_LangTagRec* langTags;
FT_Stream stream;
} TT_NameTableRec, *TT_NameTable;
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/*** ***/
/*** ***/
/*** OPTIONAL TRUETYPE/OPENTYPE TABLES DEFINITIONS ***/
/*** ***/
/*** ***/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/**************************************************************************
*
* @struct:
* TT_GaspRangeRec
*
* @description:
* A tiny structure used to model a gasp range according to the TrueType
* specification.
*
* @fields:
* maxPPEM ::
* The maximum ppem value to which `gaspFlag` applies.
*
* gaspFlag ::
* A flag describing the grid-fitting and anti-aliasing modes to be
* used.
*/
typedef struct TT_GaspRangeRec_
{
FT_UShort maxPPEM;
FT_UShort gaspFlag;
} TT_GaspRangeRec, *TT_GaspRange;
#define TT_GASP_GRIDFIT 0x01
#define TT_GASP_DOGRAY 0x02
/**************************************************************************
*
* @struct:
* TT_GaspRec
*
* @description:
* A structure modeling the TrueType 'gasp' table used to specify
* grid-fitting and anti-aliasing behaviour.
*
* @fields:
* version ::
* The version number.
*
* numRanges ::
* The number of gasp ranges in table.
*
* gaspRanges ::
* An array of gasp ranges.
*/
typedef struct TT_Gasp_
{
FT_UShort version;
FT_UShort numRanges;
TT_GaspRange gaspRanges;
} TT_GaspRec;
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/*** ***/
/*** ***/
/*** EMBEDDED BITMAPS SUPPORT ***/
/*** ***/
/*** ***/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/**************************************************************************
*
* @struct:
* TT_SBit_MetricsRec
*
* @description:
* A structure used to hold the big metrics of a given glyph bitmap in a
* TrueType or OpenType font. These are usually found in the 'EBDT'
* (Microsoft) or 'bloc' (Apple) table.
*
* @fields:
* height ::
* The glyph height in pixels.
*
* width ::
* The glyph width in pixels.
*
* horiBearingX ::
* The horizontal left bearing.
*
* horiBearingY ::
* The horizontal top bearing.
*
* horiAdvance ::
* The horizontal advance.
*
* vertBearingX ::
* The vertical left bearing.
*
* vertBearingY ::
* The vertical top bearing.
*
* vertAdvance ::
* The vertical advance.
*/
typedef struct TT_SBit_MetricsRec_
{
FT_UShort height;
FT_UShort width;
FT_Short horiBearingX;
FT_Short horiBearingY;
FT_UShort horiAdvance;
FT_Short vertBearingX;
FT_Short vertBearingY;
FT_UShort vertAdvance;
} TT_SBit_MetricsRec, *TT_SBit_Metrics;
/**************************************************************************
*
* @struct:
* TT_SBit_SmallMetricsRec
*
* @description:
* A structure used to hold the small metrics of a given glyph bitmap in
* a TrueType or OpenType font. These are usually found in the 'EBDT'
* (Microsoft) or the 'bdat' (Apple) table.
*
* @fields:
* height ::
* The glyph height in pixels.
*
* width ::
* The glyph width in pixels.
*
* bearingX ::
* The left-side bearing.
*
* bearingY ::
* The top-side bearing.
*
* advance ::
* The advance width or height.
*/
typedef struct TT_SBit_Small_Metrics_
{
FT_Byte height;
FT_Byte width;
FT_Char bearingX;
FT_Char bearingY;
FT_Byte advance;
} TT_SBit_SmallMetricsRec, *TT_SBit_SmallMetrics;
/**************************************************************************
*
* @struct:
* TT_SBit_LineMetricsRec
*
* @description:
* A structure used to describe the text line metrics of a given bitmap
* strike, for either a horizontal or vertical layout.
*
* @fields:
* ascender ::
* The ascender in pixels.
*
* descender ::
* The descender in pixels.
*
* max_width ::
* The maximum glyph width in pixels.
*
* caret_slope_enumerator ::
* Rise of the caret slope, typically set to 1 for non-italic fonts.
*
* caret_slope_denominator ::
* Rise of the caret slope, typically set to 0 for non-italic fonts.
*
* caret_offset ::
* Offset in pixels to move the caret for proper positioning.
*
* min_origin_SB ::
* Minimum of horiBearingX (resp. vertBearingY).
* min_advance_SB ::
* Minimum of
*
* horizontal advance - ( horiBearingX + width )
*
* resp.
*
* vertical advance - ( vertBearingY + height )
*
* max_before_BL ::
* Maximum of horiBearingY (resp. vertBearingY).
*
* min_after_BL ::
* Minimum of
*
* horiBearingY - height
*
* resp.
*
* vertBearingX - width
*
* pads ::
* Unused (to make the size of the record a multiple of 32 bits.
*/
typedef struct TT_SBit_LineMetricsRec_
{
FT_Char ascender;
FT_Char descender;
FT_Byte max_width;
FT_Char caret_slope_numerator;
FT_Char caret_slope_denominator;
FT_Char caret_offset;
FT_Char min_origin_SB;
FT_Char min_advance_SB;
FT_Char max_before_BL;
FT_Char min_after_BL;
FT_Char pads[2];
} TT_SBit_LineMetricsRec, *TT_SBit_LineMetrics;
/**************************************************************************
*
* @struct:
* TT_SBit_RangeRec
*
* @description:
* A TrueType/OpenType subIndexTable as defined in the 'EBLC' (Microsoft)
* or 'bloc' (Apple) tables.
*
* @fields:
* first_glyph ::
* The first glyph index in the range.
*
* last_glyph ::
* The last glyph index in the range.
*
* index_format ::
* The format of index table. Valid values are 1 to 5.
*
* image_format ::
* The format of 'EBDT' image data.
*
* image_offset ::
* The offset to image data in 'EBDT'.
*
* image_size ::
* For index formats 2 and 5. This is the size in bytes of each glyph
* bitmap.
*
* big_metrics ::
* For index formats 2 and 5. This is the big metrics for each glyph
* bitmap.
*
* num_glyphs ::
* For index formats 4 and 5. This is the number of glyphs in the code
* array.
*
* glyph_offsets ::
* For index formats 1 and 3.
*
* glyph_codes ::
* For index formats 4 and 5.
*
* table_offset ::
* The offset of the index table in the 'EBLC' table. Only used during
* strike loading.
*/
typedef struct TT_SBit_RangeRec_
{
FT_UShort first_glyph;
FT_UShort last_glyph;
FT_UShort index_format;
FT_UShort image_format;
FT_ULong image_offset;
FT_ULong image_size;
TT_SBit_MetricsRec metrics;
FT_ULong num_glyphs;
FT_ULong* glyph_offsets;
FT_UShort* glyph_codes;
FT_ULong table_offset;
} TT_SBit_RangeRec, *TT_SBit_Range;
/**************************************************************************
*
* @struct:
* TT_SBit_StrikeRec
*
* @description:
* A structure used describe a given bitmap strike in the 'EBLC'
* (Microsoft) or 'bloc' (Apple) tables.
*
* @fields:
* num_index_ranges ::
* The number of index ranges.
*
* index_ranges ::
* An array of glyph index ranges.
*
* color_ref ::
* Unused. `color_ref` is put in for future enhancements, but these
* fields are already in use by other platforms (e.g. Newton). For
* details, please see
*
* https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6bloc.html
*
* hori ::
* The line metrics for horizontal layouts.
*
* vert ::
* The line metrics for vertical layouts.
*
* start_glyph ::
* The lowest glyph index for this strike.
*
* end_glyph ::
* The highest glyph index for this strike.
*
* x_ppem ::
* The number of horizontal pixels per EM.
*
* y_ppem ::
* The number of vertical pixels per EM.
*
* bit_depth ::
* The bit depth. Valid values are 1, 2, 4, and 8.
*
* flags ::
* Is this a vertical or horizontal strike? For details, please see
*
* https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6bloc.html
*/
typedef struct TT_SBit_StrikeRec_
{
FT_Int num_ranges;
TT_SBit_Range sbit_ranges;
FT_ULong ranges_offset;
FT_ULong color_ref;
TT_SBit_LineMetricsRec hori;
TT_SBit_LineMetricsRec vert;
FT_UShort start_glyph;
FT_UShort end_glyph;
FT_Byte x_ppem;
FT_Byte y_ppem;
FT_Byte bit_depth;
FT_Char flags;
} TT_SBit_StrikeRec, *TT_SBit_Strike;
/**************************************************************************
*
* @struct:
* TT_SBit_ComponentRec
*
* @description:
* A simple structure to describe a compound sbit element.
*
* @fields:
* glyph_code ::
* The element's glyph index.
*
* x_offset ::
* The element's left bearing.
*
* y_offset ::
* The element's top bearing.
*/
typedef struct TT_SBit_ComponentRec_
{
FT_UShort glyph_code;
FT_Char x_offset;
FT_Char y_offset;
} TT_SBit_ComponentRec, *TT_SBit_Component;
/**************************************************************************
*
* @struct:
* TT_SBit_ScaleRec
*
* @description:
* A structure used describe a given bitmap scaling table, as defined in
* the 'EBSC' table.
*
* @fields:
* hori ::
* The horizontal line metrics.
*
* vert ::
* The vertical line metrics.
*
* x_ppem ::
* The number of horizontal pixels per EM.
*
* y_ppem ::
* The number of vertical pixels per EM.
*
* x_ppem_substitute ::
* Substitution x_ppem value.
*
* y_ppem_substitute ::
* Substitution y_ppem value.
*/
typedef struct TT_SBit_ScaleRec_
{
TT_SBit_LineMetricsRec hori;
TT_SBit_LineMetricsRec vert;
FT_Byte x_ppem;
FT_Byte y_ppem;
FT_Byte x_ppem_substitute;
FT_Byte y_ppem_substitute;
} TT_SBit_ScaleRec, *TT_SBit_Scale;
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/*** ***/
/*** ***/
/*** POSTSCRIPT GLYPH NAMES SUPPORT ***/
/*** ***/
/*** ***/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/**************************************************************************
*
* @struct:
* TT_Post_NamesRec
*
* @description:
* Postscript names table, either format 2.0 or 2.5.
*
* @fields:
* loaded ::
* A flag to indicate whether the PS names are loaded.
*
* num_glyphs ::
* The number of named glyphs in the table.
*
* num_names ::
* The number of PS names stored in the table.
*
* glyph_indices ::
* The indices of the glyphs in the names arrays.
*
* glyph_names ::
* The PS names not in Mac Encoding.
*/
typedef struct TT_Post_NamesRec_
{
FT_Bool loaded;
FT_UShort num_glyphs;
FT_UShort num_names;
FT_UShort* glyph_indices;
FT_Byte** glyph_names;
} TT_Post_NamesRec, *TT_Post_Names;
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/*** ***/
/*** ***/
/*** GX VARIATION TABLE SUPPORT ***/
/*** ***/
/*** ***/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
typedef struct GX_BlendRec_ *GX_Blend;
#endif
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/*** ***/
/*** ***/
/*** EMBEDDED BDF PROPERTIES TABLE SUPPORT ***/
/*** ***/
/*** ***/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/*
* These types are used to support a `BDF ' table that isn't part of the
* official TrueType specification. It is mainly used in SFNT-based bitmap
* fonts that were generated from a set of BDF fonts.
*
* The format of the table is as follows.
*
* USHORT version `BDF ' table version number, should be 0x0001. USHORT
* strikeCount Number of strikes (bitmap sizes) in this table. ULONG
* stringTable Offset (from start of BDF table) to string
* table.
*
* This is followed by an array of `strikeCount' descriptors, having the
* following format.
*
* USHORT ppem Vertical pixels per EM for this strike. USHORT numItems
* Number of items for this strike (properties and
* atoms). Maximum is 255.
*
* This array in turn is followed by `strikeCount' value sets. Each `value
* set' is an array of `numItems' items with the following format.
*
* ULONG item_name Offset in string table to item name.
* USHORT item_type The item type. Possible values are
* 0 => string (e.g., COMMENT)
* 1 => atom (e.g., FONT or even SIZE)
* 2 => int32
* 3 => uint32
* 0x10 => A flag to indicate a properties. This
* is ORed with the above values.
* ULONG item_value For strings => Offset into string table without
* the corresponding double quotes.
* For atoms => Offset into string table.
* For integers => Direct value.
*
* All strings in the string table consist of bytes and are
* zero-terminated.
*
*/
#ifdef TT_CONFIG_OPTION_BDF
typedef struct TT_BDFRec_
{
FT_Byte* table;
FT_Byte* table_end;
FT_Byte* strings;
FT_ULong strings_size;
FT_UInt num_strikes;
FT_Bool loaded;
} TT_BDFRec, *TT_BDF;
#endif /* TT_CONFIG_OPTION_BDF */
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/*** ***/
/*** ***/
/*** ORIGINAL TT_FACE CLASS DEFINITION ***/
/*** ***/
/*** ***/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/**************************************************************************
*
* This structure/class is defined here because it is common to the
* following formats: TTF, OpenType-TT, and OpenType-CFF.
*
* Note, however, that the classes TT_Size and TT_GlyphSlot are not shared
* between font drivers, and are thus defined in `ttobjs.h`.
*
*/
/**************************************************************************
*
* @type:
* TT_Face
*
* @description:
* A handle to a TrueType face/font object. A TT_Face encapsulates the
* resolution and scaling independent parts of a TrueType font resource.
*
* @note:
* The TT_Face structure is also used as a 'parent class' for the
* OpenType-CFF class (T2_Face).
*/
typedef struct TT_FaceRec_* TT_Face;
/* a function type used for the truetype bytecode interpreter hooks */
typedef FT_Error
(*TT_Interpreter)( void* exec_context );
/* forward declaration */
typedef struct TT_LoaderRec_* TT_Loader;
/**************************************************************************
*
* @functype:
* TT_Loader_GotoTableFunc
*
* @description:
* Seeks a stream to the start of a given TrueType table.
*
* @input:
* face ::
* A handle to the target face object.
*
* tag ::
* A 4-byte tag used to name the table.
*
* stream ::
* The input stream.
*
* @output:
* length ::
* The length of the table in bytes. Set to 0 if not needed.
*
* @return:
* FreeType error code. 0 means success.
*
* @note:
* The stream cursor must be at the font file's origin.
*/
typedef FT_Error
(*TT_Loader_GotoTableFunc)( TT_Face face,
FT_ULong tag,
FT_Stream stream,
FT_ULong* length );
/**************************************************************************
*
* @functype:
* TT_Loader_StartGlyphFunc
*
* @description:
* Seeks a stream to the start of a given glyph element, and opens a
* frame for it.
*
* @input:
* loader ::
* The current TrueType glyph loader object.
*
* glyph index :: The index of the glyph to access.
*
* offset ::
* The offset of the glyph according to the 'locations' table.
*
* byte_count ::
* The size of the frame in bytes.
*
* @return:
* FreeType error code. 0 means success.
*
* @note:
* This function is normally equivalent to FT_STREAM_SEEK(offset)
* followed by FT_FRAME_ENTER(byte_count) with the loader's stream, but
* alternative formats (e.g. compressed ones) might use something
* different.
*/
typedef FT_Error
(*TT_Loader_StartGlyphFunc)( TT_Loader loader,
FT_UInt glyph_index,
FT_ULong offset,
FT_UInt byte_count );
/**************************************************************************
*
* @functype:
* TT_Loader_ReadGlyphFunc
*
* @description:
* Reads one glyph element (its header, a simple glyph, or a composite)
* from the loader's current stream frame.
*
* @input:
* loader ::
* The current TrueType glyph loader object.
*
* @return:
* FreeType error code. 0 means success.
*/
typedef FT_Error
(*TT_Loader_ReadGlyphFunc)( TT_Loader loader );
/**************************************************************************
*
* @functype:
* TT_Loader_EndGlyphFunc
*
* @description:
* Closes the current loader stream frame for the glyph.
*
* @input:
* loader ::
* The current TrueType glyph loader object.
*/
typedef void
(*TT_Loader_EndGlyphFunc)( TT_Loader loader );
typedef enum TT_SbitTableType_
{
TT_SBIT_TABLE_TYPE_NONE = 0,
TT_SBIT_TABLE_TYPE_EBLC, /* `EBLC' (Microsoft), */
/* `bloc' (Apple) */
TT_SBIT_TABLE_TYPE_CBLC, /* `CBLC' (Google) */
TT_SBIT_TABLE_TYPE_SBIX, /* `sbix' (Apple) */
/* do not remove */
TT_SBIT_TABLE_TYPE_MAX
} TT_SbitTableType;
/* OpenType 1.8 brings new tables for variation font support; */
/* to make the old MM and GX fonts still work we need to check */
/* the presence (and validity) of the functionality provided */
/* by those tables. The following flag macros are for the */
/* field `variation_support'. */
/* */
/* Note that `fvar' gets checked immediately at font loading, */
/* while the other features are only loaded if MM support is */
/* actually requested. */
/* FVAR */
#define TT_FACE_FLAG_VAR_FVAR ( 1 << 0 )
/* HVAR */
#define TT_FACE_FLAG_VAR_HADVANCE ( 1 << 1 )
#define TT_FACE_FLAG_VAR_LSB ( 1 << 2 )
#define TT_FACE_FLAG_VAR_RSB ( 1 << 3 )
/* VVAR */
#define TT_FACE_FLAG_VAR_VADVANCE ( 1 << 4 )
#define TT_FACE_FLAG_VAR_TSB ( 1 << 5 )
#define TT_FACE_FLAG_VAR_BSB ( 1 << 6 )
#define TT_FACE_FLAG_VAR_VORG ( 1 << 7 )
/* MVAR */
#define TT_FACE_FLAG_VAR_MVAR ( 1 << 8 )
/**************************************************************************
*
* TrueType Face Type
*
* @struct:
* TT_Face
*
* @description:
* The TrueType face class. These objects model the resolution and
* point-size independent data found in a TrueType font file.
*
* @fields:
* root ::
* The base FT_Face structure, managed by the base layer.
*
* ttc_header ::
* The TrueType collection header, used when the file is a 'ttc' rather
* than a 'ttf'. For ordinary font files, the field `ttc_header.count`
* is set to 0.
*
* format_tag ::
* The font format tag.
*
* num_tables ::
* The number of TrueType tables in this font file.
*
* dir_tables ::
* The directory of TrueType tables for this font file.
*
* header ::
* The font's font header ('head' table). Read on font opening.
*
* horizontal ::
* The font's horizontal header ('hhea' table). This field also
* contains the associated horizontal metrics table ('hmtx').
*
* max_profile ::
* The font's maximum profile table. Read on font opening. Note that
* some maximum values cannot be taken directly from this table. We
* thus define additional fields below to hold the computed maxima.
*
* vertical_info ::
* A boolean which is set when the font file contains vertical metrics.
* If not, the value of the 'vertical' field is undefined.
*
* vertical ::
* The font's vertical header ('vhea' table). This field also contains
* the associated vertical metrics table ('vmtx'), if found.
* IMPORTANT: The contents of this field is undefined if the
* `vertical_info` field is unset.
*
* num_names ::
* The number of name records within this TrueType font.
*
* name_table ::
* The table of name records ('name').
*
* os2 ::
* The font's OS/2 table ('OS/2').
*
* postscript ::
* The font's PostScript table ('post' table). The PostScript glyph
* names are not loaded by the driver on face opening. See the
* 'ttpost' module for more details.
*
* cmap_table ::
* Address of the face's 'cmap' SFNT table in memory (it's an extracted
* frame).
*
* cmap_size ::
* The size in bytes of the `cmap_table` described above.
*
* goto_table ::
* A function called by each TrueType table loader to position a
* stream's cursor to the start of a given table according to its tag.
* It defaults to TT_Goto_Face but can be different for strange formats
* (e.g. Type 42).
*
* access_glyph_frame ::
* A function used to access the frame of a given glyph within the
* face's font file.
*
* forget_glyph_frame ::
* A function used to forget the frame of a given glyph when all data
* has been loaded.
*
* read_glyph_header ::
* A function used to read a glyph header. It must be called between
* an 'access' and 'forget'.
*
* read_simple_glyph ::
* A function used to read a simple glyph. It must be called after the
* header was read, and before the 'forget'.
*
* read_composite_glyph ::
* A function used to read a composite glyph. It must be called after
* the header was read, and before the 'forget'.
*
* sfnt ::
* A pointer to the SFNT service.
*
* psnames ::
* A pointer to the PostScript names service.
*
* mm ::
* A pointer to the Multiple Masters service.
*
* tt_var ::
* A pointer to the Metrics Variations service for the "truetype"
* driver.
*
* face_var ::
* A pointer to the Metrics Variations service for this `TT_Face`'s
* driver.
*
* psaux ::
* A pointer to the PostScript Auxiliary service.
*
* gasp ::
* The grid-fitting and scaling properties table ('gasp'). This table
* is optional in TrueType/OpenType fonts.
*
* pclt ::
* The 'pclt' SFNT table.
*
* num_sbit_scales ::
* The number of sbit scales for this font.
*
* sbit_scales ::
* Array of sbit scales embedded in this font. This table is optional
* in a TrueType/OpenType font.
*
* postscript_names ::
* A table used to store the Postscript names of the glyphs for this
* font. See the file `ttconfig.h` for comments on the
* TT_CONFIG_OPTION_POSTSCRIPT_NAMES option.
*
* palette_data ::
* Some fields from the 'CPAL' table that are directly indexed.
*
* palette_index ::
* The current palette index, as set by @FT_Palette_Select.
*
* palette ::
* An array containing the current palette's colors.
*
* have_foreground_color ::
* There was a call to @FT_Palette_Set_Foreground_Color.
*
* foreground_color ::
* The current foreground color corresponding to 'CPAL' color index
* 0xFFFF. Only valid if `have_foreground_color` is set.
*
* font_program_size ::
* Size in bytecodes of the face's font program. 0 if none defined.
* Ignored for Type 2 fonts.
*
* font_program ::
* The face's font program (bytecode stream) executed at load time,
* also used during glyph rendering. Comes from the 'fpgm' table.
* Ignored for Type 2 font fonts.
*
* cvt_program_size ::
* The size in bytecodes of the face's cvt program. Ignored for Type 2
* fonts.
*
* cvt_program ::
* The face's cvt program (bytecode stream) executed each time an
* instance/size is changed/reset. Comes from the 'prep' table.
* Ignored for Type 2 fonts.
*
* cvt_size ::
* Size of the control value table (in entries). Ignored for Type 2
* fonts.
*
* cvt ::
* The face's original control value table. Coordinates are expressed
* in unscaled font units (in 26.6 format). Comes from the 'cvt~'
* table. Ignored for Type 2 fonts.
*
* If varied by the `CVAR' table, non-integer values are possible.
*
* interpreter ::
* A pointer to the TrueType bytecode interpreters field is also used
* to hook the debugger in 'ttdebug'.
*
* extra ::
* Reserved for third-party font drivers.
*
* postscript_name ::
* The PS name of the font. Used by the postscript name service.
*
* glyf_len ::
* The length of the 'glyf' table. Needed for malformed 'loca' tables.
*
* glyf_offset ::
* The file offset of the 'glyf' table.
*
* is_cff2 ::
* Set if the font format is CFF2.
*
* doblend ::
* A boolean which is set if the font should be blended (this is for GX
* var).
*
* blend ::
* Contains the data needed to control GX variation tables (rather like
* Multiple Master data).
*
* variation_support ::
* Flags that indicate which OpenType functionality related to font
* variation support is present, valid, and usable. For example,
* TT_FACE_FLAG_VAR_FVAR is only set if we have at least one design
* axis.
*
* var_postscript_prefix ::
* The PostScript name prefix needed for constructing a variation font
* instance's PS name .
*
* var_postscript_prefix_len ::
* The length of the `var_postscript_prefix` string.
*
* var_default_named_instance ::
* The index of the default named instance.
*
* non_var_style_name ::
* The non-variation style name, used as a backup.
*
* horz_metrics_size ::
* The size of the 'hmtx' table.
*
* vert_metrics_size ::
* The size of the 'vmtx' table.
*
* num_locations ::
* The number of glyph locations in this TrueType file. This should be
* one more than the number of glyphs. Ignored for Type 2 fonts.
*
* glyph_locations ::
* An array of longs. These are offsets to glyph data within the
* 'glyf' table. Ignored for Type 2 font faces.
*
* hdmx_table ::
* A pointer to the 'hdmx' table.
*
* hdmx_table_size ::
* The size of the 'hdmx' table.
*
* hdmx_record_count ::
* The number of hdmx records.
*
* hdmx_record_size ::
* The size of a single hdmx record.
*
* hdmx_records ::
* A array of pointers to the 'hdmx' table records sorted by ppem.
*
* sbit_table ::
* A pointer to the font's embedded bitmap location table.
*
* sbit_table_size ::
* The size of `sbit_table`.
*
* sbit_table_type ::
* The sbit table type (CBLC, sbix, etc.).
*
* sbit_num_strikes ::
* The number of sbit strikes exposed by FreeType's API, omitting
* invalid strikes.
*
* sbit_strike_map ::
* A mapping between the strike indices exposed by the API and the
* indices used in the font's sbit table.
*
* kern_table ::
* A pointer to the 'kern' table.
*
* kern_table_size ::
* The size of the 'kern' table.
*
* num_kern_tables ::
* The number of supported kern subtables (up to 32; FreeType
* recognizes only horizontal ones with format 0).
*
* kern_avail_bits ::
* The availability status of kern subtables; if bit n is set, table n
* is available.
*
* kern_order_bits ::
* The sortedness status of kern subtables; if bit n is set, table n is
* sorted.
*
* bdf ::
* Data related to an SFNT font's 'bdf' table; see `tttypes.h`.
*
* horz_metrics_offset ::
* The file offset of the 'hmtx' table.
*
* vert_metrics_offset ::
* The file offset of the 'vmtx' table.
*
* ebdt_start ::
* The file offset of the sbit data table (CBDT, bdat, etc.).
*
* ebdt_size ::
* The size of the sbit data table.
*
* cpal ::
* A pointer to data related to the 'CPAL' table. `NULL` if the table
* is not available.
*
* colr ::
* A pointer to data related to the 'COLR' table. `NULL` if the table
* is not available.
*
* svg ::
* A pointer to data related to the 'SVG' table. `NULL` if the table
* is not available.
*/
typedef struct TT_FaceRec_
{
FT_FaceRec root;
TTC_HeaderRec ttc_header;
FT_ULong format_tag;
FT_UShort num_tables;
TT_Table dir_tables;
TT_Header header; /* TrueType header table */
TT_HoriHeader horizontal; /* TrueType horizontal header */
TT_MaxProfile max_profile;
FT_Bool vertical_info;
TT_VertHeader vertical; /* TT Vertical header, if present */
FT_UShort num_names; /* number of name records */
TT_NameTableRec name_table; /* name table */
TT_OS2 os2; /* TrueType OS/2 table */
TT_Postscript postscript; /* TrueType Postscript table */
FT_Byte* cmap_table; /* extracted `cmap' table */
FT_ULong cmap_size;
TT_Loader_GotoTableFunc goto_table;
TT_Loader_StartGlyphFunc access_glyph_frame;
TT_Loader_EndGlyphFunc forget_glyph_frame;
TT_Loader_ReadGlyphFunc read_glyph_header;
TT_Loader_ReadGlyphFunc read_simple_glyph;
TT_Loader_ReadGlyphFunc read_composite_glyph;
/* a typeless pointer to the SFNT_Interface table used to load */
/* the basic TrueType tables in the face object */
void* sfnt;
/* a typeless pointer to the FT_Service_PsCMapsRec table used to */
/* handle glyph names <-> unicode & Mac values */
void* psnames;
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
/* a typeless pointer to the FT_Service_MultiMasters table used to */
/* handle variation fonts */
void* mm;
/* a typeless pointer to the FT_Service_MetricsVariationsRec table */
/* used to handle the HVAR, VVAR, and MVAR OpenType tables by the */
/* "truetype" driver */
void* tt_var;
/* a typeless pointer to the FT_Service_MetricsVariationsRec table */
/* used to handle the HVAR, VVAR, and MVAR OpenType tables by this */
/* TT_Face's driver */
void* face_var; /* since 2.13.1 */
#endif
/* a typeless pointer to the PostScript Aux service */
void* psaux;
/************************************************************************
*
* Optional TrueType/OpenType tables
*
*/
/* grid-fitting and scaling table */
TT_GaspRec gasp; /* the `gasp' table */
/* PCL 5 table */
TT_PCLT pclt;
/* embedded bitmaps support */
FT_ULong num_sbit_scales;
TT_SBit_Scale sbit_scales;
/* postscript names table */
TT_Post_NamesRec postscript_names;
/* glyph colors */
FT_Palette_Data palette_data; /* since 2.10 */
FT_UShort palette_index;
FT_Color* palette;
FT_Bool have_foreground_color;
FT_Color foreground_color;
/************************************************************************
*
* TrueType-specific fields (ignored by the CFF driver)
*
*/
/* the font program, if any */
FT_ULong font_program_size;
FT_Byte* font_program;
/* the cvt program, if any */
FT_ULong cvt_program_size;
FT_Byte* cvt_program;
/* the original, unscaled, control value table */
FT_ULong cvt_size;
FT_Int32* cvt;
/* A pointer to the bytecode interpreter to use. This is also */
/* used to hook the debugger for the `ttdebug' utility. */
TT_Interpreter interpreter;
/************************************************************************
*
* Other tables or fields. This is used by derivative formats like
* OpenType.
*
*/
FT_Generic extra;
const char* postscript_name;
FT_ULong glyf_len;
FT_ULong glyf_offset; /* since 2.7.1 */
FT_Bool is_cff2; /* since 2.7.1 */
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
FT_Bool doblend;
GX_Blend blend;
FT_UInt32 variation_support; /* since 2.7.1 */
const char* var_postscript_prefix; /* since 2.7.2 */
FT_UInt var_postscript_prefix_len; /* since 2.7.2 */
FT_UInt var_default_named_instance; /* since 2.13.1 */
const char* non_var_style_name; /* since 2.13.1 */
#endif
/* since version 2.2 */
FT_ULong horz_metrics_size;
FT_ULong vert_metrics_size;
FT_ULong num_locations; /* up to 0xFFFF + 1 */
FT_Byte* glyph_locations;
FT_Byte* hdmx_table;
FT_ULong hdmx_table_size;
FT_UInt hdmx_record_count;
FT_ULong hdmx_record_size;
FT_Byte** hdmx_records;
FT_Byte* sbit_table;
FT_ULong sbit_table_size;
TT_SbitTableType sbit_table_type;
FT_UInt sbit_num_strikes;
FT_UInt* sbit_strike_map;
FT_Byte* kern_table;
FT_ULong kern_table_size;
FT_UInt num_kern_tables;
FT_UInt32 kern_avail_bits;
FT_UInt32 kern_order_bits;
#ifdef TT_CONFIG_OPTION_GPOS_KERNING
FT_Byte* gpos_table;
FT_Bool gpos_kerning_available;
#endif
#ifdef TT_CONFIG_OPTION_BDF
TT_BDFRec bdf;
#endif /* TT_CONFIG_OPTION_BDF */
/* since 2.3.0 */
FT_ULong horz_metrics_offset;
FT_ULong vert_metrics_offset;
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
/* since 2.7 */
FT_ULong ebdt_start; /* either `CBDT', `EBDT', or `bdat' */
FT_ULong ebdt_size;
#endif
/* since 2.10 */
void* cpal;
void* colr;
/* since 2.12 */
void* svg;
} TT_FaceRec;
/**************************************************************************
*
* @struct:
* TT_GlyphZoneRec
*
* @description:
* A glyph zone is used to load, scale and hint glyph outline
* coordinates.
*
* @fields:
* memory ::
* A handle to the memory manager.
*
* max_points ::
* The maximum size in points of the zone.
*
* max_contours ::
* Max size in links contours of the zone.
*
* n_points ::
* The current number of points in the zone.
*
* n_contours ::
* The current number of contours in the zone.
*
* org ::
* The original glyph coordinates (font units/scaled).
*
* cur ::
* The current glyph coordinates (scaled/hinted).
*
* tags ::
* The point control tags.
*
* contours ::
* The contours end points.
*
* first_point ::
* Offset of the current subglyph's first point.
*/
typedef struct TT_GlyphZoneRec_
{
FT_Memory memory;
FT_UShort max_points;
FT_UShort max_contours;
FT_UShort n_points; /* number of points in zone */
FT_UShort n_contours; /* number of contours */
FT_Vector* org; /* original point coordinates */
FT_Vector* cur; /* current point coordinates */
FT_Vector* orus; /* original (unscaled) point coordinates */
FT_Byte* tags; /* current touch flags */
FT_UShort* contours; /* contour end points */
FT_UShort first_point; /* offset of first (#0) point */
} TT_GlyphZoneRec, *TT_GlyphZone;
/* handle to execution context */
typedef struct TT_ExecContextRec_* TT_ExecContext;
/**************************************************************************
*
* @type:
* TT_Size
*
* @description:
* A handle to a TrueType size object.
*/
typedef struct TT_SizeRec_* TT_Size;
/* glyph loader structure */
typedef struct TT_LoaderRec_
{
TT_Face face;
TT_Size size;
FT_GlyphSlot glyph;
FT_GlyphLoader gloader;
FT_ULong load_flags;
FT_UInt glyph_index;
FT_Stream stream;
FT_UInt byte_len;
FT_Short n_contours;
FT_BBox bbox;
FT_Int left_bearing;
FT_Int advance;
FT_Int linear;
FT_Bool linear_def;
FT_Vector pp1;
FT_Vector pp2;
/* the zone where we load our glyphs */
TT_GlyphZoneRec base;
TT_GlyphZoneRec zone;
TT_ExecContext exec;
FT_Byte* instructions;
FT_ULong ins_pos;
/* for possible extensibility in other formats */
void* other;
/* since version 2.1.8 */
FT_Int top_bearing;
FT_Int vadvance;
FT_Vector pp3;
FT_Vector pp4;
/* since version 2.2.1 */
FT_Byte* cursor;
FT_Byte* limit;
/* since version 2.6.2 */
FT_ListRec composites;
/* since version 2.11.2 */
FT_Byte* widthp;
} TT_LoaderRec;
FT_END_HEADER
#endif /* TTTYPES_H_ */
/* END */
/****************************************************************************
*
* wofftypes.h
*
* Basic WOFF/WOFF2 type definitions and interface (specification
* only).
*
* Copyright (C) 1996-2024 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* 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 WOFFTYPES_H_
#define WOFFTYPES_H_
#include <freetype/tttables.h>
#include <freetype/internal/ftobjs.h>
FT_BEGIN_HEADER
/**************************************************************************
*
* @struct:
* WOFF_HeaderRec
*
* @description:
* WOFF file format header.
*
* @fields:
* See
*
* https://www.w3.org/TR/WOFF/#WOFFHeader
*/
typedef struct WOFF_HeaderRec_
{
FT_ULong signature;
FT_ULong flavor;
FT_ULong length;
FT_UShort num_tables;
FT_UShort reserved;
FT_ULong totalSfntSize;
FT_UShort majorVersion;
FT_UShort minorVersion;
FT_ULong metaOffset;
FT_ULong metaLength;
FT_ULong metaOrigLength;
FT_ULong privOffset;
FT_ULong privLength;
} WOFF_HeaderRec, *WOFF_Header;
/**************************************************************************
*
* @struct:
* WOFF_TableRec
*
* @description:
* This structure describes a given table of a WOFF font.
*
* @fields:
* Tag ::
* A four-bytes tag describing the table.
*
* Offset ::
* The offset of the table from the start of the WOFF font in its
* resource.
*
* CompLength ::
* Compressed table length (in bytes).
*
* OrigLength ::
* Uncompressed table length (in bytes).
*
* CheckSum ::
* The table checksum. This value can be ignored.
*
* OrigOffset ::
* The uncompressed table file offset. This value gets computed while
* constructing the (uncompressed) SFNT header. It is not contained in
* the WOFF file.
*/
typedef struct WOFF_TableRec_
{
FT_Tag Tag; /* table ID */
FT_ULong Offset; /* table file offset */
FT_ULong CompLength; /* compressed table length */
FT_ULong OrigLength; /* uncompressed table length */
FT_ULong CheckSum; /* uncompressed checksum */
FT_ULong OrigOffset; /* uncompressed table file offset */
/* (not in the WOFF file) */
} WOFF_TableRec, *WOFF_Table;
/**************************************************************************
*
* @struct:
* WOFF2_TtcFontRec
*
* @description:
* Metadata for a TTC font entry in WOFF2.
*
* @fields:
* flavor ::
* TTC font flavor.
*
* num_tables ::
* Number of tables in TTC, indicating number of elements in
* `table_indices`.
*
* table_indices ::
* Array of table indices for each TTC font.
*/
typedef struct WOFF2_TtcFontRec_
{
FT_ULong flavor;
FT_UShort num_tables;
FT_UShort* table_indices;
} WOFF2_TtcFontRec, *WOFF2_TtcFont;
/**************************************************************************
*
* @struct:
* WOFF2_HeaderRec
*
* @description:
* WOFF2 file format header.
*
* @fields:
* See
*
* https://www.w3.org/TR/WOFF2/#woff20Header
*
* @note:
* We don't care about the fields `reserved`, `majorVersion` and
* `minorVersion`, so they are not included. The `totalSfntSize` field
* does not necessarily represent the actual size of the uncompressed
* SFNT font stream, so that is used as a reference value instead.
*/
typedef struct WOFF2_HeaderRec_
{
FT_ULong signature;
FT_ULong flavor;
FT_ULong length;
FT_UShort num_tables;
FT_ULong totalSfntSize;
FT_ULong totalCompressedSize;
FT_ULong metaOffset;
FT_ULong metaLength;
FT_ULong metaOrigLength;
FT_ULong privOffset;
FT_ULong privLength;
FT_ULong uncompressed_size; /* uncompressed brotli stream size */
FT_ULong compressed_offset; /* compressed stream offset */
FT_ULong header_version; /* version of original TTC Header */
FT_UShort num_fonts; /* number of fonts in TTC */
FT_ULong actual_sfnt_size; /* actual size of sfnt stream */
WOFF2_TtcFont ttc_fonts; /* metadata for fonts in a TTC */
} WOFF2_HeaderRec, *WOFF2_Header;
/**************************************************************************
*
* @struct:
* WOFF2_TableRec
*
* @description:
* This structure describes a given table of a WOFF2 font.
*
* @fields:
* See
*
* https://www.w3.org/TR/WOFF2/#table_dir_format
*/
typedef struct WOFF2_TableRec_
{
FT_Byte FlagByte; /* table type and flags */
FT_Tag Tag; /* table file offset */
FT_ULong dst_length; /* uncompressed table length */
FT_ULong TransformLength; /* transformed length */
FT_ULong flags; /* calculated flags */
FT_ULong src_offset; /* compressed table offset */
FT_ULong src_length; /* compressed table length */
FT_ULong dst_offset; /* uncompressed table offset */
} WOFF2_TableRec, *WOFF2_Table;
/**************************************************************************
*
* @struct:
* WOFF2_InfoRec
*
* @description:
* Metadata for WOFF2 font that may be required for reconstruction of
* sfnt tables.
*
* @fields:
* header_checksum ::
* Checksum of SFNT offset table.
*
* num_glyphs ::
* Number of glyphs in the font.
*
* num_hmetrics ::
* `numberOfHMetrics` field in the 'hhea' table.
*
* x_mins ::
* `xMin` values of glyph bounding box.
*
* glyf_table ::
* A pointer to the `glyf' table record.
*
* loca_table ::
* A pointer to the `loca' table record.
*
* head_table ::
* A pointer to the `head' table record.
*/
typedef struct WOFF2_InfoRec_
{
FT_ULong header_checksum;
FT_UShort num_glyphs;
FT_UShort num_hmetrics;
FT_Short* x_mins;
WOFF2_Table glyf_table;
WOFF2_Table loca_table;
WOFF2_Table head_table;
} WOFF2_InfoRec, *WOFF2_Info;
/**************************************************************************
*
* @struct:
* WOFF2_SubstreamRec
*
* @description:
* This structure stores information about a substream in the transformed
* 'glyf' table in a WOFF2 stream.
*
* @fields:
* start ::
* Beginning of the substream relative to uncompressed table stream.
*
* offset ::
* Offset of the substream relative to uncompressed table stream.
*
* size ::
* Size of the substream.
*/
typedef struct WOFF2_SubstreamRec_
{
FT_ULong start;
FT_ULong offset;
FT_ULong size;
} WOFF2_SubstreamRec, *WOFF2_Substream;
/**************************************************************************
*
* @struct:
* WOFF2_PointRec
*
* @description:
* This structure stores information about a point in the transformed
* 'glyf' table in a WOFF2 stream.
*
* @fields:
* x ::
* x-coordinate of point.
*
* y ::
* y-coordinate of point.
*
* on_curve ::
* Set if point is on-curve.
*/
typedef struct WOFF2_PointRec_
{
FT_Int x;
FT_Int y;
FT_Bool on_curve;
} WOFF2_PointRec, *WOFF2_Point;
FT_END_HEADER
#endif /* WOFFTYPES_H_ */
/* END */
/****************************************************************************
*
* otsvg.h
*
* Interface for OT-SVG support related things (specification).
*
* Copyright (C) 2022-2024 by
* David Turner, Robert Wilhelm, Werner Lemberg, and Moazin Khatti.
*
* 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 OTSVG_H_
#define OTSVG_H_
#include <freetype/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
/**************************************************************************
*
* @section:
* svg_fonts
*
* @title:
* OpenType SVG Fonts
*
* @abstract:
* OT-SVG API between FreeType and an external SVG rendering library.
*
* @description:
* This section describes the four hooks necessary to render SVG
* 'documents' that are contained in an OpenType font's 'SVG~' table.
*
* For more information on the implementation, see our standard hooks
* based on 'librsvg' in the [FreeType Demo
* Programs](https://gitlab.freedesktop.org/freetype/freetype-demos)
* repository.
*
*/
/**************************************************************************
*
* @functype:
* SVG_Lib_Init_Func
*
* @description:
* A callback that is called when the first OT-SVG glyph is rendered in
* the lifetime of an @FT_Library object. In a typical implementation,
* one would want to allocate a structure and point the `data_pointer`
* to it and perform any library initializations that might be needed.
*
* @inout:
* data_pointer ::
* The SVG rendering module stores a pointer variable that can be used
* by clients to store any data that needs to be shared across
* different hooks. `data_pointer` is essentially a pointer to that
* pointer such that it can be written to as well as read from.
*
* @return:
* FreeType error code. 0 means success.
*
* @since:
* 2.12
*/
typedef FT_Error
(*SVG_Lib_Init_Func)( FT_Pointer *data_pointer );
/**************************************************************************
*
* @functype:
* SVG_Lib_Free_Func
*
* @description:
* A callback that is called when the `ot-svg` module is being freed.
* It is only called if the init hook was called earlier. This means
* that neither the init nor the free hook is called if no OT-SVG glyph
* is rendered.
*
* In a typical implementation, one would want to free any state
* structure that was allocated in the init hook and perform any
* library-related closure that might be needed.
*
* @inout:
* data_pointer ::
* The SVG rendering module stores a pointer variable that can be used
* by clients to store any data that needs to be shared across
* different hooks. `data_pointer` is essentially a pointer to that
* pointer such that it can be written to as well as read from.
*
* @since:
* 2.12
*/
typedef void
(*SVG_Lib_Free_Func)( FT_Pointer *data_pointer );
/**************************************************************************
*
* @functype:
* SVG_Lib_Render_Func
*
* @description:
* A callback that is called to render an OT-SVG glyph. This callback
* hook is called right after the preset hook @SVG_Lib_Preset_Slot_Func
* 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 the `other` field of @FT_GlyphSlotRec.
*
* The render hook is expected to render the SVG glyph to the bitmap
* buffer that is allocated already at `slot->bitmap.buffer`. It also
* sets the `num_grays` value as well as `slot->format`.
*
* @input:
* slot ::
* The slot to render.
*
* @inout:
* data_pointer ::
* The SVG rendering module stores a pointer variable that can be used
* by clients to store any data that needs to be shared across
* different hooks. `data_pointer` is essentially a pointer to that
* pointer such that it can be written to as well as read from.
*
* @return:
* FreeType error code. 0 means success.
*
* @since:
* 2.12
*/
typedef FT_Error
(*SVG_Lib_Render_Func)( FT_GlyphSlot slot,
FT_Pointer *data_pointer );
/**************************************************************************
*
* @functype:
* SVG_Lib_Preset_Slot_Func
*
* @description:
* A callback that is called to preset the glyph slot. It is called from
* two places.
*
* 1. When `FT_Load_Glyph` needs to preset the glyph slot.
*
* 2. Right before the `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 many calculations that are necessary
* for presetting a glyph slot are the same needed later for the render
* callback hook. Thus, if `cache` is `TRUE`, the hook can _cache_ those
* calculations in a memory block referenced by the state pointer.
*
* This hook is expected to preset the slot by setting parameters such as
* `bitmap_left`, `bitmap_top`, `width`, `rows`, `pitch`, and
* `pixel_mode`. It is also expected to set all the metrics for the slot
* including the vertical advance if it is not already set. Typically,
* fonts have horizontal advances but not vertical ones. If those are
* available, they had already been set, otherwise they have to be
* estimated and set manually. The hook must take into account the
* transformations that have been set, and translate the transformation
* matrices into the SVG coordinate system, as the original matrix is
* intended for the TTF/CFF coordinate system.
*
* @input:
* slot ::
* The glyph slot that has the SVG document loaded.
*
* cache ::
* See description.
*
* @inout:
* data_pointer ::
* The SVG rendering module stores a pointer variable that can be used
* by clients to store any data that needs to be shared across
* different hooks. `data_pointer` is essentially a pointer to that
* pointer such that it can be written to as well as read from.
*
* @return:
* FreeType error code. 0 means success.
*
* @since:
* 2.12
*/
typedef FT_Error
(*SVG_Lib_Preset_Slot_Func)( FT_GlyphSlot slot,
FT_Bool cache,
FT_Pointer *state );
/**************************************************************************
*
* @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 the
* @svg-hooks driver property.
*
* The behavior of each hook is described in its documentation. One
* thing to note is that the preset hook and the render hook often need
* to do the same operations; therefore, it's better to cache the
* intermediate data in a state structure to avoid calculating it twice.
* For example, in the preset hook one can draw the glyph on a recorder
* surface and later create a bitmap surface from it in the render hook.
*
* All four hooks must be non-NULL.
*
* @fields:
* init_svg ::
* The initialization hook.
*
* free_svg ::
* The cleanup hook.
*
* render_hook ::
* The render hook.
*
* preset_slot ::
* The preset hook.
*
* @since:
* 2.12
*/
typedef struct SVG_RendererHooks_
{
SVG_Lib_Init_Func init_svg;
SVG_Lib_Free_Func free_svg;
SVG_Lib_Render_Func render_svg;
SVG_Lib_Preset_Slot_Func preset_slot;
} SVG_RendererHooks;
/**************************************************************************
*
* @struct:
* FT_SVG_DocumentRec
*
* @description:
* A structure that models one SVG document.
*
* @fields:
* svg_document ::
* A pointer to the SVG document.
*
* svg_document_length ::
* The length of `svg_document`.
*
* metrics ::
* A metrics object storing the size information.
*
* units_per_EM ::
* The size of the EM square.
*
* start_glyph_id ::
* The first glyph ID in the glyph range covered by this document.
*
* end_glyph_id ::
* The last glyph ID in the glyph range covered by this document.
*
* transform ::
* A 2x2 transformation matrix to apply to the glyph while rendering
* it.
*
* delta ::
* The translation to apply to the glyph while rendering.
*
* @note:
* When an @FT_GlyphSlot object `slot` is passed down to a renderer, the
* renderer can only access the `metrics` and `units_per_EM` fields via
* `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.
*
* @since:
* 2.12
*/
typedef struct FT_SVG_DocumentRec_
{
FT_Byte* svg_document;
FT_ULong svg_document_length;
FT_Size_Metrics metrics;
FT_UShort units_per_EM;
FT_UShort start_glyph_id;
FT_UShort end_glyph_id;
FT_Matrix transform;
FT_Vector delta;
} FT_SVG_DocumentRec;
/**************************************************************************
*
* @type:
* FT_SVG_Document
*
* @description:
* A handle to an @FT_SVG_DocumentRec object.
*
* @since:
* 2.12
*/
typedef struct FT_SVG_DocumentRec_* FT_SVG_Document;
FT_END_HEADER
#endif /* OTSVG_H_ */
/* END */
/****************************************************************************
*
* t1tables.h
*
* Basic Type 1/Type 2 tables definitions and interface (specification
* only).
*
* Copyright (C) 1996-2024 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* 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 T1TABLES_H_
#define T1TABLES_H_
#include <freetype/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
/**************************************************************************
*
* @section:
* type1_tables
*
* @title:
* Type 1 Tables
*
* @abstract:
* Type~1-specific font tables.
*
* @description:
* This section contains the definition of Type~1-specific tables,
* including structures related to other PostScript font formats.
*
* @order:
* PS_FontInfoRec
* PS_FontInfo
* PS_PrivateRec
* PS_Private
*
* CID_FaceDictRec
* CID_FaceDict
* CID_FaceInfoRec
* CID_FaceInfo
*
* FT_Has_PS_Glyph_Names
* FT_Get_PS_Font_Info
* FT_Get_PS_Font_Private
* FT_Get_PS_Font_Value
*
* T1_Blend_Flags
* T1_EncodingType
* PS_Dict_Keys
*
*/
/* Note that we separate font data in PS_FontInfoRec and PS_PrivateRec */
/* structures in order to support Multiple Master fonts. */
/**************************************************************************
*
* @struct:
* PS_FontInfoRec
*
* @description:
* A structure used to model a Type~1 or Type~2 FontInfo dictionary.
* Note that for Multiple Master fonts, each instance has its own
* FontInfo dictionary.
*/
typedef struct PS_FontInfoRec_
{
FT_String* version;
FT_String* notice;
FT_String* full_name;
FT_String* family_name;
FT_String* weight;
FT_Long italic_angle;
FT_Bool is_fixed_pitch;
FT_Short underline_position;
FT_UShort underline_thickness;
} PS_FontInfoRec;
/**************************************************************************
*
* @struct:
* PS_FontInfo
*
* @description:
* A handle to a @PS_FontInfoRec structure.
*/
typedef struct PS_FontInfoRec_* PS_FontInfo;
/**************************************************************************
*
* @struct:
* T1_FontInfo
*
* @description:
* This type is equivalent to @PS_FontInfoRec. It is deprecated but kept
* to maintain source compatibility between various versions of FreeType.
*/
typedef PS_FontInfoRec T1_FontInfo;
/**************************************************************************
*
* @struct:
* PS_PrivateRec
*
* @description:
* A structure used to model a Type~1 or Type~2 private dictionary. Note
* that for Multiple Master fonts, each instance has its own Private
* dictionary.
*/
typedef struct PS_PrivateRec_
{
FT_Int unique_id;
FT_Int lenIV;
FT_Byte num_blue_values;
FT_Byte num_other_blues;
FT_Byte num_family_blues;
FT_Byte num_family_other_blues;
FT_Short blue_values[14];
FT_Short other_blues[10];
FT_Short family_blues [14];
FT_Short family_other_blues[10];
FT_Fixed blue_scale;
FT_Int blue_shift;
FT_Int blue_fuzz;
FT_UShort standard_width[1];
FT_UShort standard_height[1];
FT_Byte num_snap_widths;
FT_Byte num_snap_heights;
FT_Bool force_bold;
FT_Bool round_stem_up;
FT_Short snap_widths [13]; /* including std width */
FT_Short snap_heights[13]; /* including std height */
FT_Fixed expansion_factor;
FT_Long language_group;
FT_Long password;
FT_Short min_feature[2];
} PS_PrivateRec;
/**************************************************************************
*
* @struct:
* PS_Private
*
* @description:
* A handle to a @PS_PrivateRec structure.
*/
typedef struct PS_PrivateRec_* PS_Private;
/**************************************************************************
*
* @struct:
* T1_Private
*
* @description:
* This type is equivalent to @PS_PrivateRec. It is deprecated but kept
* to maintain source compatibility between various versions of FreeType.
*/
typedef PS_PrivateRec T1_Private;
/**************************************************************************
*
* @enum:
* T1_Blend_Flags
*
* @description:
* A set of flags used to indicate which fields are present in a given
* blend dictionary (font info or private). Used to support Multiple
* Masters fonts.
*
* @values:
* T1_BLEND_UNDERLINE_POSITION ::
* T1_BLEND_UNDERLINE_THICKNESS ::
* T1_BLEND_ITALIC_ANGLE ::
* T1_BLEND_BLUE_VALUES ::
* T1_BLEND_OTHER_BLUES ::
* T1_BLEND_STANDARD_WIDTH ::
* T1_BLEND_STANDARD_HEIGHT ::
* T1_BLEND_STEM_SNAP_WIDTHS ::
* T1_BLEND_STEM_SNAP_HEIGHTS ::
* T1_BLEND_BLUE_SCALE ::
* T1_BLEND_BLUE_SHIFT ::
* T1_BLEND_FAMILY_BLUES ::
* T1_BLEND_FAMILY_OTHER_BLUES ::
* T1_BLEND_FORCE_BOLD ::
*/
typedef enum T1_Blend_Flags_
{
/* required fields in a FontInfo blend dictionary */
T1_BLEND_UNDERLINE_POSITION = 0,
T1_BLEND_UNDERLINE_THICKNESS,
T1_BLEND_ITALIC_ANGLE,
/* required fields in a Private blend dictionary */
T1_BLEND_BLUE_VALUES,
T1_BLEND_OTHER_BLUES,
T1_BLEND_STANDARD_WIDTH,
T1_BLEND_STANDARD_HEIGHT,
T1_BLEND_STEM_SNAP_WIDTHS,
T1_BLEND_STEM_SNAP_HEIGHTS,
T1_BLEND_BLUE_SCALE,
T1_BLEND_BLUE_SHIFT,
T1_BLEND_FAMILY_BLUES,
T1_BLEND_FAMILY_OTHER_BLUES,
T1_BLEND_FORCE_BOLD,
T1_BLEND_MAX /* do not remove */
} T1_Blend_Flags;
/* these constants are deprecated; use the corresponding */
/* `T1_Blend_Flags` values instead */
#define t1_blend_underline_position T1_BLEND_UNDERLINE_POSITION
#define t1_blend_underline_thickness T1_BLEND_UNDERLINE_THICKNESS
#define t1_blend_italic_angle T1_BLEND_ITALIC_ANGLE
#define t1_blend_blue_values T1_BLEND_BLUE_VALUES
#define t1_blend_other_blues T1_BLEND_OTHER_BLUES
#define t1_blend_standard_widths T1_BLEND_STANDARD_WIDTH
#define t1_blend_standard_height T1_BLEND_STANDARD_HEIGHT
#define t1_blend_stem_snap_widths T1_BLEND_STEM_SNAP_WIDTHS
#define t1_blend_stem_snap_heights T1_BLEND_STEM_SNAP_HEIGHTS
#define t1_blend_blue_scale T1_BLEND_BLUE_SCALE
#define t1_blend_blue_shift T1_BLEND_BLUE_SHIFT
#define t1_blend_family_blues T1_BLEND_FAMILY_BLUES
#define t1_blend_family_other_blues T1_BLEND_FAMILY_OTHER_BLUES
#define t1_blend_force_bold T1_BLEND_FORCE_BOLD
#define t1_blend_max T1_BLEND_MAX
/* */
/**************************************************************************
*
* @struct:
* CID_FaceDictRec
*
* @description:
* A structure used to represent data in a CID top-level dictionary. In
* most cases, they are part of the font's '/FDArray' array. Within a
* CID font file, such (internal) subfont dictionaries are enclosed by
* '%ADOBeginFontDict' and '%ADOEndFontDict' comments.
*
* Note that `CID_FaceDictRec` misses a field for the '/FontName'
* keyword, specifying the subfont's name (the top-level font name is
* given by the '/CIDFontName' keyword). This is an oversight, but it
* doesn't limit the 'cid' font module's functionality because FreeType
* neither needs this entry nor gives access to CID subfonts.
*/
typedef struct CID_FaceDictRec_
{
PS_PrivateRec private_dict;
FT_UInt len_buildchar;
FT_Fixed forcebold_threshold;
FT_Pos stroke_width;
FT_Fixed expansion_factor; /* this is a duplicate of */
/* `private_dict->expansion_factor' */
FT_Byte paint_type;
FT_Byte font_type;
FT_Matrix font_matrix;
FT_Vector font_offset;
FT_UInt num_subrs;
FT_ULong subrmap_offset;
FT_UInt sd_bytes;
} CID_FaceDictRec;
/**************************************************************************
*
* @struct:
* CID_FaceDict
*
* @description:
* A handle to a @CID_FaceDictRec structure.
*/
typedef struct CID_FaceDictRec_* CID_FaceDict;
/**************************************************************************
*
* @struct:
* CID_FontDict
*
* @description:
* This type is equivalent to @CID_FaceDictRec. It is deprecated but
* kept to maintain source compatibility between various versions of
* FreeType.
*/
typedef CID_FaceDictRec CID_FontDict;
/**************************************************************************
*
* @struct:
* CID_FaceInfoRec
*
* @description:
* A structure used to represent CID Face information.
*/
typedef struct CID_FaceInfoRec_
{
FT_String* cid_font_name;
FT_Fixed cid_version;
FT_Int cid_font_type;
FT_String* registry;
FT_String* ordering;
FT_Int supplement;
PS_FontInfoRec font_info;
FT_BBox font_bbox;
FT_ULong uid_base;
FT_Int num_xuid;
FT_ULong xuid[16];
FT_ULong cidmap_offset;
FT_UInt fd_bytes;
FT_UInt gd_bytes;
FT_ULong cid_count;
FT_UInt num_dicts;
CID_FaceDict font_dicts;
FT_ULong data_offset;
} CID_FaceInfoRec;
/**************************************************************************
*
* @struct:
* CID_FaceInfo
*
* @description:
* A handle to a @CID_FaceInfoRec structure.
*/
typedef struct CID_FaceInfoRec_* CID_FaceInfo;
/**************************************************************************
*
* @struct:
* CID_Info
*
* @description:
* This type is equivalent to @CID_FaceInfoRec. It is deprecated but kept
* to maintain source compatibility between various versions of FreeType.
*/
typedef CID_FaceInfoRec CID_Info;
/**************************************************************************
*
* @function:
* FT_Has_PS_Glyph_Names
*
* @description:
* Return true if a given face provides reliable PostScript glyph names.
* This is similar to using the @FT_HAS_GLYPH_NAMES macro, except that
* certain fonts (mostly TrueType) contain incorrect glyph name tables.
*
* When this function returns true, the caller is sure that the glyph
* names returned by @FT_Get_Glyph_Name are reliable.
*
* @input:
* face ::
* face handle
*
* @return:
* Boolean. True if glyph names are reliable.
*
*/
FT_EXPORT( FT_Int )
FT_Has_PS_Glyph_Names( FT_Face face );
/**************************************************************************
*
* @function:
* FT_Get_PS_Font_Info
*
* @description:
* Retrieve the @PS_FontInfoRec structure corresponding to a given
* PostScript font.
*
* @input:
* face ::
* PostScript face handle.
*
* @output:
* afont_info ::
* A pointer to a @PS_FontInfoRec object.
*
* @return:
* FreeType error code. 0~means success.
*
* @note:
* String pointers within the @PS_FontInfoRec structure are owned by the
* face and don't need to be freed by the caller. Missing entries in the
* font's FontInfo dictionary are represented by `NULL` pointers.
*
* The following font formats support this feature: 'Type~1', 'Type~42',
* 'CFF', 'CID~Type~1'. For other font formats this function returns the
* `FT_Err_Invalid_Argument` error code.
*
* @example:
* ```
* PS_FontInfoRec font_info;
*
*
* error = FT_Get_PS_Font_Info( face, &font_info );
* ...
* ```
*
*/
FT_EXPORT( FT_Error )
FT_Get_PS_Font_Info( FT_Face face,
PS_FontInfo afont_info );
/**************************************************************************
*
* @function:
* FT_Get_PS_Font_Private
*
* @description:
* Retrieve the @PS_PrivateRec structure corresponding to a given
* PostScript font.
*
* @input:
* face ::
* PostScript face handle.
*
* @output:
* afont_private ::
* A pointer to a @PS_PrivateRec object.
*
* @return:
* FreeType error code. 0~means success.
*
* @note:
* The string pointers within the @PS_PrivateRec structure are owned by
* the face and don't need to be freed by the caller.
*
* Only the 'Type~1' font format supports this feature. For other font
* formats this function returns the `FT_Err_Invalid_Argument` error
* code.
*
* @example:
* ```
* PS_PrivateRec font_private;
*
*
* error = FT_Get_PS_Font_Private( face, &font_private );
* ...
* ```
*
*/
FT_EXPORT( FT_Error )
FT_Get_PS_Font_Private( FT_Face face,
PS_Private afont_private );
/**************************************************************************
*
* @enum:
* T1_EncodingType
*
* @description:
* An enumeration describing the 'Encoding' entry in a Type 1 dictionary.
*
* @values:
* T1_ENCODING_TYPE_NONE ::
* T1_ENCODING_TYPE_ARRAY ::
* T1_ENCODING_TYPE_STANDARD ::
* T1_ENCODING_TYPE_ISOLATIN1 ::
* T1_ENCODING_TYPE_EXPERT ::
*
* @since:
* 2.4.8
*/
typedef enum T1_EncodingType_
{
T1_ENCODING_TYPE_NONE = 0,
T1_ENCODING_TYPE_ARRAY,
T1_ENCODING_TYPE_STANDARD,
T1_ENCODING_TYPE_ISOLATIN1,
T1_ENCODING_TYPE_EXPERT
} T1_EncodingType;
/**************************************************************************
*
* @enum:
* PS_Dict_Keys
*
* @description:
* An enumeration used in calls to @FT_Get_PS_Font_Value to identify the
* Type~1 dictionary entry to retrieve.
*
* @values:
* PS_DICT_FONT_TYPE ::
* PS_DICT_FONT_MATRIX ::
* PS_DICT_FONT_BBOX ::
* PS_DICT_PAINT_TYPE ::
* PS_DICT_FONT_NAME ::
* PS_DICT_UNIQUE_ID ::
* PS_DICT_NUM_CHAR_STRINGS ::
* PS_DICT_CHAR_STRING_KEY ::
* PS_DICT_CHAR_STRING ::
* PS_DICT_ENCODING_TYPE ::
* PS_DICT_ENCODING_ENTRY ::
* PS_DICT_NUM_SUBRS ::
* PS_DICT_SUBR ::
* PS_DICT_STD_HW ::
* PS_DICT_STD_VW ::
* PS_DICT_NUM_BLUE_VALUES ::
* PS_DICT_BLUE_VALUE ::
* PS_DICT_BLUE_FUZZ ::
* PS_DICT_NUM_OTHER_BLUES ::
* PS_DICT_OTHER_BLUE ::
* PS_DICT_NUM_FAMILY_BLUES ::
* PS_DICT_FAMILY_BLUE ::
* PS_DICT_NUM_FAMILY_OTHER_BLUES ::
* PS_DICT_FAMILY_OTHER_BLUE ::
* PS_DICT_BLUE_SCALE ::
* PS_DICT_BLUE_SHIFT ::
* PS_DICT_NUM_STEM_SNAP_H ::
* PS_DICT_STEM_SNAP_H ::
* PS_DICT_NUM_STEM_SNAP_V ::
* PS_DICT_STEM_SNAP_V ::
* PS_DICT_FORCE_BOLD ::
* PS_DICT_RND_STEM_UP ::
* PS_DICT_MIN_FEATURE ::
* PS_DICT_LEN_IV ::
* PS_DICT_PASSWORD ::
* PS_DICT_LANGUAGE_GROUP ::
* PS_DICT_VERSION ::
* PS_DICT_NOTICE ::
* PS_DICT_FULL_NAME ::
* PS_DICT_FAMILY_NAME ::
* PS_DICT_WEIGHT ::
* PS_DICT_IS_FIXED_PITCH ::
* PS_DICT_UNDERLINE_POSITION ::
* PS_DICT_UNDERLINE_THICKNESS ::
* PS_DICT_FS_TYPE ::
* PS_DICT_ITALIC_ANGLE ::
*
* @since:
* 2.4.8
*/
typedef enum PS_Dict_Keys_
{
/* conventionally in the font dictionary */
PS_DICT_FONT_TYPE, /* FT_Byte */
PS_DICT_FONT_MATRIX, /* FT_Fixed */
PS_DICT_FONT_BBOX, /* FT_Fixed */
PS_DICT_PAINT_TYPE, /* FT_Byte */
PS_DICT_FONT_NAME, /* FT_String* */
PS_DICT_UNIQUE_ID, /* FT_Int */
PS_DICT_NUM_CHAR_STRINGS, /* FT_Int */
PS_DICT_CHAR_STRING_KEY, /* FT_String* */
PS_DICT_CHAR_STRING, /* FT_String* */
PS_DICT_ENCODING_TYPE, /* T1_EncodingType */
PS_DICT_ENCODING_ENTRY, /* FT_String* */
/* conventionally in the font Private dictionary */
PS_DICT_NUM_SUBRS, /* FT_Int */
PS_DICT_SUBR, /* FT_String* */
PS_DICT_STD_HW, /* FT_UShort */
PS_DICT_STD_VW, /* FT_UShort */
PS_DICT_NUM_BLUE_VALUES, /* FT_Byte */
PS_DICT_BLUE_VALUE, /* FT_Short */
PS_DICT_BLUE_FUZZ, /* FT_Int */
PS_DICT_NUM_OTHER_BLUES, /* FT_Byte */
PS_DICT_OTHER_BLUE, /* FT_Short */
PS_DICT_NUM_FAMILY_BLUES, /* FT_Byte */
PS_DICT_FAMILY_BLUE, /* FT_Short */
PS_DICT_NUM_FAMILY_OTHER_BLUES, /* FT_Byte */
PS_DICT_FAMILY_OTHER_BLUE, /* FT_Short */
PS_DICT_BLUE_SCALE, /* FT_Fixed */
PS_DICT_BLUE_SHIFT, /* FT_Int */
PS_DICT_NUM_STEM_SNAP_H, /* FT_Byte */
PS_DICT_STEM_SNAP_H, /* FT_Short */
PS_DICT_NUM_STEM_SNAP_V, /* FT_Byte */
PS_DICT_STEM_SNAP_V, /* FT_Short */
PS_DICT_FORCE_BOLD, /* FT_Bool */
PS_DICT_RND_STEM_UP, /* FT_Bool */
PS_DICT_MIN_FEATURE, /* FT_Short */
PS_DICT_LEN_IV, /* FT_Int */
PS_DICT_PASSWORD, /* FT_Long */
PS_DICT_LANGUAGE_GROUP, /* FT_Long */
/* conventionally in the font FontInfo dictionary */
PS_DICT_VERSION, /* FT_String* */
PS_DICT_NOTICE, /* FT_String* */
PS_DICT_FULL_NAME, /* FT_String* */
PS_DICT_FAMILY_NAME, /* FT_String* */
PS_DICT_WEIGHT, /* FT_String* */
PS_DICT_IS_FIXED_PITCH, /* FT_Bool */
PS_DICT_UNDERLINE_POSITION, /* FT_Short */
PS_DICT_UNDERLINE_THICKNESS, /* FT_UShort */
PS_DICT_FS_TYPE, /* FT_UShort */
PS_DICT_ITALIC_ANGLE, /* FT_Long */
PS_DICT_MAX = PS_DICT_ITALIC_ANGLE
} PS_Dict_Keys;
/**************************************************************************
*
* @function:
* FT_Get_PS_Font_Value
*
* @description:
* Retrieve the value for the supplied key from a PostScript font.
*
* @input:
* face ::
* PostScript face handle.
*
* key ::
* An enumeration value representing the dictionary key to retrieve.
*
* idx ::
* For array values, this specifies the index to be returned.
*
* value ::
* A pointer to memory into which to write the value.
*
* valen_len ::
* The size, in bytes, of the memory supplied for the value.
*
* @output:
* value ::
* The value matching the above key, if it exists.
*
* @return:
* The amount of memory (in bytes) required to hold the requested value
* (if it exists, -1 otherwise).
*
* @note:
* The values returned are not pointers into the internal structures of
* the face, but are 'fresh' copies, so that the memory containing them
* belongs to the calling application. This also enforces the
* 'read-only' nature of these values, i.e., this function cannot be
* used to manipulate the face.
*
* `value` is a void pointer because the values returned can be of
* various types.
*
* If either `value` is `NULL` or `value_len` is too small, just the
* required memory size for the requested entry is returned.
*
* The `idx` parameter is used, not only to retrieve elements of, for
* example, the FontMatrix or FontBBox, but also to retrieve name keys
* from the CharStrings dictionary, and the charstrings themselves. It
* is ignored for atomic values.
*
* `PS_DICT_BLUE_SCALE` returns a value that is scaled up by 1000. To
* get the value as in the font stream, you need to divide by 65536000.0
* (to remove the FT_Fixed scale, and the x1000 scale).
*
* IMPORTANT: Only key/value pairs read by the FreeType interpreter can
* be retrieved. So, for example, PostScript procedures such as NP, ND,
* and RD are not available. Arbitrary keys are, obviously, not be
* available either.
*
* If the font's format is not PostScript-based, this function returns
* the `FT_Err_Invalid_Argument` error code.
*
* @since:
* 2.4.8
*
*/
FT_EXPORT( FT_Long )
FT_Get_PS_Font_Value( FT_Face face,
PS_Dict_Keys key,
FT_UInt idx,
void *value,
FT_Long value_len );
/* */
FT_END_HEADER
#endif /* T1TABLES_H_ */
/* END */
/****************************************************************************
*
* ttnameid.h
*
* TrueType name ID definitions (specification only).
*
* Copyright (C) 1996-2024 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* 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 TTNAMEID_H_
#define TTNAMEID_H_
FT_BEGIN_HEADER
/**************************************************************************
*
* @section:
* truetype_tables
*/
/**************************************************************************
*
* Possible values for the 'platform' identifier code in the name records
* of an SFNT 'name' table.
*
*/
/**************************************************************************
*
* @enum:
* TT_PLATFORM_XXX
*
* @description:
* A list of valid values for the `platform_id` identifier code in
* @FT_CharMapRec and @FT_SfntName structures.
*
* @values:
* TT_PLATFORM_APPLE_UNICODE ::
* Used by Apple to indicate a Unicode character map and/or name entry.
* See @TT_APPLE_ID_XXX for corresponding `encoding_id` values. Note
* that name entries in this format are coded as big-endian UCS-2
* character codes _only_.
*
* TT_PLATFORM_MACINTOSH ::
* Used by Apple to indicate a MacOS-specific charmap and/or name
* entry. See @TT_MAC_ID_XXX for corresponding `encoding_id` values.
* Note that most TrueType fonts contain an Apple roman charmap to be
* usable on MacOS systems (even if they contain a Microsoft charmap as
* well).
*
* TT_PLATFORM_ISO ::
* This value was used to specify ISO/IEC 10646 charmaps. It is
* however now deprecated. See @TT_ISO_ID_XXX for a list of
* corresponding `encoding_id` values.
*
* TT_PLATFORM_MICROSOFT ::
* Used by Microsoft to indicate Windows-specific charmaps. See
* @TT_MS_ID_XXX for a list of corresponding `encoding_id` values.
* Note that most fonts contain a Unicode charmap using
* (`TT_PLATFORM_MICROSOFT`, @TT_MS_ID_UNICODE_CS).
*
* TT_PLATFORM_CUSTOM ::
* Used to indicate application-specific charmaps.
*
* TT_PLATFORM_ADOBE ::
* This value isn't part of any font format specification, but is used
* by FreeType to report Adobe-specific charmaps in an @FT_CharMapRec
* structure. See @TT_ADOBE_ID_XXX.
*/
#define TT_PLATFORM_APPLE_UNICODE 0
#define TT_PLATFORM_MACINTOSH 1
#define TT_PLATFORM_ISO 2 /* deprecated */
#define TT_PLATFORM_MICROSOFT 3
#define TT_PLATFORM_CUSTOM 4
#define TT_PLATFORM_ADOBE 7 /* artificial */
/**************************************************************************
*
* @enum:
* TT_APPLE_ID_XXX
*
* @description:
* A list of valid values for the `encoding_id` for
* @TT_PLATFORM_APPLE_UNICODE charmaps and name entries.
*
* @values:
* TT_APPLE_ID_DEFAULT ::
* Unicode version 1.0.
*
* TT_APPLE_ID_UNICODE_1_1 ::
* Unicode 1.1; specifies Hangul characters starting at U+34xx.
*
* TT_APPLE_ID_ISO_10646 ::
* Deprecated (identical to preceding).
*
* TT_APPLE_ID_UNICODE_2_0 ::
* Unicode 2.0 and beyond (UTF-16 BMP only).
*
* TT_APPLE_ID_UNICODE_32 ::
* Unicode 3.1 and beyond, using UTF-32.
*
* TT_APPLE_ID_VARIANT_SELECTOR ::
* From Adobe, not Apple. Not a normal cmap. Specifies variations on
* a real cmap.
*
* TT_APPLE_ID_FULL_UNICODE ::
* Used for fallback fonts that provide complete Unicode coverage with
* a type~13 cmap.
*/
#define TT_APPLE_ID_DEFAULT 0 /* Unicode 1.0 */
#define TT_APPLE_ID_UNICODE_1_1 1 /* specify Hangul at U+34xx */
#define TT_APPLE_ID_ISO_10646 2 /* deprecated */
#define TT_APPLE_ID_UNICODE_2_0 3 /* or later */
#define TT_APPLE_ID_UNICODE_32 4 /* 2.0 or later, full repertoire */
#define TT_APPLE_ID_VARIANT_SELECTOR 5 /* variation selector data */
#define TT_APPLE_ID_FULL_UNICODE 6 /* used with type 13 cmaps */
/**************************************************************************
*
* @enum:
* TT_MAC_ID_XXX
*
* @description:
* A list of valid values for the `encoding_id` for
* @TT_PLATFORM_MACINTOSH charmaps and name entries.
*/
#define TT_MAC_ID_ROMAN 0
#define TT_MAC_ID_JAPANESE 1
#define TT_MAC_ID_TRADITIONAL_CHINESE 2
#define TT_MAC_ID_KOREAN 3
#define TT_MAC_ID_ARABIC 4
#define TT_MAC_ID_HEBREW 5
#define TT_MAC_ID_GREEK 6
#define TT_MAC_ID_RUSSIAN 7
#define TT_MAC_ID_RSYMBOL 8
#define TT_MAC_ID_DEVANAGARI 9
#define TT_MAC_ID_GURMUKHI 10
#define TT_MAC_ID_GUJARATI 11
#define TT_MAC_ID_ORIYA 12
#define TT_MAC_ID_BENGALI 13
#define TT_MAC_ID_TAMIL 14
#define TT_MAC_ID_TELUGU 15
#define TT_MAC_ID_KANNADA 16
#define TT_MAC_ID_MALAYALAM 17
#define TT_MAC_ID_SINHALESE 18
#define TT_MAC_ID_BURMESE 19
#define TT_MAC_ID_KHMER 20
#define TT_MAC_ID_THAI 21
#define TT_MAC_ID_LAOTIAN 22
#define TT_MAC_ID_GEORGIAN 23
#define TT_MAC_ID_ARMENIAN 24
#define TT_MAC_ID_MALDIVIAN 25
#define TT_MAC_ID_SIMPLIFIED_CHINESE 25
#define TT_MAC_ID_TIBETAN 26
#define TT_MAC_ID_MONGOLIAN 27
#define TT_MAC_ID_GEEZ 28
#define TT_MAC_ID_SLAVIC 29
#define TT_MAC_ID_VIETNAMESE 30
#define TT_MAC_ID_SINDHI 31
#define TT_MAC_ID_UNINTERP 32
/**************************************************************************
*
* @enum:
* TT_ISO_ID_XXX
*
* @description:
* A list of valid values for the `encoding_id` for @TT_PLATFORM_ISO
* charmaps and name entries.
*
* Their use is now deprecated.
*
* @values:
* TT_ISO_ID_7BIT_ASCII ::
* ASCII.
* TT_ISO_ID_10646 ::
* ISO/10646.
* TT_ISO_ID_8859_1 ::
* Also known as Latin-1.
*/
#define TT_ISO_ID_7BIT_ASCII 0
#define TT_ISO_ID_10646 1
#define TT_ISO_ID_8859_1 2
/**************************************************************************
*
* @enum:
* TT_MS_ID_XXX
*
* @description:
* A list of valid values for the `encoding_id` for
* @TT_PLATFORM_MICROSOFT charmaps and name entries.
*
* @values:
* TT_MS_ID_SYMBOL_CS ::
* Microsoft symbol encoding. See @FT_ENCODING_MS_SYMBOL.
*
* TT_MS_ID_UNICODE_CS ::
* Microsoft WGL4 charmap, matching Unicode. See @FT_ENCODING_UNICODE.
*
* TT_MS_ID_SJIS ::
* Shift JIS Japanese encoding. See @FT_ENCODING_SJIS.
*
* TT_MS_ID_PRC ::
* Chinese encodings as used in the People's Republic of China (PRC).
* This means the encodings GB~2312 and its supersets GBK and GB~18030.
* See @FT_ENCODING_PRC.
*
* TT_MS_ID_BIG_5 ::
* Traditional Chinese as used in Taiwan and Hong Kong. See
* @FT_ENCODING_BIG5.
*
* TT_MS_ID_WANSUNG ::
* Korean Extended Wansung encoding. See @FT_ENCODING_WANSUNG.
*
* TT_MS_ID_JOHAB ::
* Korean Johab encoding. See @FT_ENCODING_JOHAB.
*
* TT_MS_ID_UCS_4 ::
* UCS-4 or UTF-32 charmaps. This has been added to the OpenType
* specification version 1.4 (mid-2001).
*/
#define TT_MS_ID_SYMBOL_CS 0
#define TT_MS_ID_UNICODE_CS 1
#define TT_MS_ID_SJIS 2
#define TT_MS_ID_PRC 3
#define TT_MS_ID_BIG_5 4
#define TT_MS_ID_WANSUNG 5
#define TT_MS_ID_JOHAB 6
#define TT_MS_ID_UCS_4 10
/* this value is deprecated */
#define TT_MS_ID_GB2312 TT_MS_ID_PRC
/**************************************************************************
*
* @enum:
* TT_ADOBE_ID_XXX
*
* @description:
* A list of valid values for the `encoding_id` for @TT_PLATFORM_ADOBE
* charmaps. This is a FreeType-specific extension!
*
* @values:
* TT_ADOBE_ID_STANDARD ::
* Adobe standard encoding.
* TT_ADOBE_ID_EXPERT ::
* Adobe expert encoding.
* TT_ADOBE_ID_CUSTOM ::
* Adobe custom encoding.
* TT_ADOBE_ID_LATIN_1 ::
* Adobe Latin~1 encoding.
*/
#define TT_ADOBE_ID_STANDARD 0
#define TT_ADOBE_ID_EXPERT 1
#define TT_ADOBE_ID_CUSTOM 2
#define TT_ADOBE_ID_LATIN_1 3
/**************************************************************************
*
* @enum:
* TT_MAC_LANGID_XXX
*
* @description:
* Possible values of the language identifier field in the name records
* of the SFNT 'name' table if the 'platform' identifier code is
* @TT_PLATFORM_MACINTOSH. These values are also used as return values
* for function @FT_Get_CMap_Language_ID.
*
* The canonical source for Apple's IDs is
*
* https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6name.html
*/
#define TT_MAC_LANGID_ENGLISH 0
#define TT_MAC_LANGID_FRENCH 1
#define TT_MAC_LANGID_GERMAN 2
#define TT_MAC_LANGID_ITALIAN 3
#define TT_MAC_LANGID_DUTCH 4
#define TT_MAC_LANGID_SWEDISH 5
#define TT_MAC_LANGID_SPANISH 6
#define TT_MAC_LANGID_DANISH 7
#define TT_MAC_LANGID_PORTUGUESE 8
#define TT_MAC_LANGID_NORWEGIAN 9
#define TT_MAC_LANGID_HEBREW 10
#define TT_MAC_LANGID_JAPANESE 11
#define TT_MAC_LANGID_ARABIC 12
#define TT_MAC_LANGID_FINNISH 13
#define TT_MAC_LANGID_GREEK 14
#define TT_MAC_LANGID_ICELANDIC 15
#define TT_MAC_LANGID_MALTESE 16
#define TT_MAC_LANGID_TURKISH 17
#define TT_MAC_LANGID_CROATIAN 18
#define TT_MAC_LANGID_CHINESE_TRADITIONAL 19
#define TT_MAC_LANGID_URDU 20
#define TT_MAC_LANGID_HINDI 21
#define TT_MAC_LANGID_THAI 22
#define TT_MAC_LANGID_KOREAN 23
#define TT_MAC_LANGID_LITHUANIAN 24
#define TT_MAC_LANGID_POLISH 25
#define TT_MAC_LANGID_HUNGARIAN 26
#define TT_MAC_LANGID_ESTONIAN 27
#define TT_MAC_LANGID_LETTISH 28
#define TT_MAC_LANGID_SAAMISK 29
#define TT_MAC_LANGID_FAEROESE 30
#define TT_MAC_LANGID_FARSI 31
#define TT_MAC_LANGID_RUSSIAN 32
#define TT_MAC_LANGID_CHINESE_SIMPLIFIED 33
#define TT_MAC_LANGID_FLEMISH 34
#define TT_MAC_LANGID_IRISH 35
#define TT_MAC_LANGID_ALBANIAN 36
#define TT_MAC_LANGID_ROMANIAN 37
#define TT_MAC_LANGID_CZECH 38
#define TT_MAC_LANGID_SLOVAK 39
#define TT_MAC_LANGID_SLOVENIAN 40
#define TT_MAC_LANGID_YIDDISH 41
#define TT_MAC_LANGID_SERBIAN 42
#define TT_MAC_LANGID_MACEDONIAN 43
#define TT_MAC_LANGID_BULGARIAN 44
#define TT_MAC_LANGID_UKRAINIAN 45
#define TT_MAC_LANGID_BYELORUSSIAN 46
#define TT_MAC_LANGID_UZBEK 47
#define TT_MAC_LANGID_KAZAKH 48
#define TT_MAC_LANGID_AZERBAIJANI 49
#define TT_MAC_LANGID_AZERBAIJANI_CYRILLIC_SCRIPT 49
#define TT_MAC_LANGID_AZERBAIJANI_ARABIC_SCRIPT 50
#define TT_MAC_LANGID_ARMENIAN 51
#define TT_MAC_LANGID_GEORGIAN 52
#define TT_MAC_LANGID_MOLDAVIAN 53
#define TT_MAC_LANGID_KIRGHIZ 54
#define TT_MAC_LANGID_TAJIKI 55
#define TT_MAC_LANGID_TURKMEN 56
#define TT_MAC_LANGID_MONGOLIAN 57
#define TT_MAC_LANGID_MONGOLIAN_MONGOLIAN_SCRIPT 57
#define TT_MAC_LANGID_MONGOLIAN_CYRILLIC_SCRIPT 58
#define TT_MAC_LANGID_PASHTO 59
#define TT_MAC_LANGID_KURDISH 60
#define TT_MAC_LANGID_KASHMIRI 61
#define TT_MAC_LANGID_SINDHI 62
#define TT_MAC_LANGID_TIBETAN 63
#define TT_MAC_LANGID_NEPALI 64
#define TT_MAC_LANGID_SANSKRIT 65
#define TT_MAC_LANGID_MARATHI 66
#define TT_MAC_LANGID_BENGALI 67
#define TT_MAC_LANGID_ASSAMESE 68
#define TT_MAC_LANGID_GUJARATI 69
#define TT_MAC_LANGID_PUNJABI 70
#define TT_MAC_LANGID_ORIYA 71
#define TT_MAC_LANGID_MALAYALAM 72
#define TT_MAC_LANGID_KANNADA 73
#define TT_MAC_LANGID_TAMIL 74
#define TT_MAC_LANGID_TELUGU 75
#define TT_MAC_LANGID_SINHALESE 76
#define TT_MAC_LANGID_BURMESE 77
#define TT_MAC_LANGID_KHMER 78
#define TT_MAC_LANGID_LAO 79
#define TT_MAC_LANGID_VIETNAMESE 80
#define TT_MAC_LANGID_INDONESIAN 81
#define TT_MAC_LANGID_TAGALOG 82
#define TT_MAC_LANGID_MALAY_ROMAN_SCRIPT 83
#define TT_MAC_LANGID_MALAY_ARABIC_SCRIPT 84
#define TT_MAC_LANGID_AMHARIC 85
#define TT_MAC_LANGID_TIGRINYA 86
#define TT_MAC_LANGID_GALLA 87
#define TT_MAC_LANGID_SOMALI 88
#define TT_MAC_LANGID_SWAHILI 89
#define TT_MAC_LANGID_RUANDA 90
#define TT_MAC_LANGID_RUNDI 91
#define TT_MAC_LANGID_CHEWA 92
#define TT_MAC_LANGID_MALAGASY 93
#define TT_MAC_LANGID_ESPERANTO 94
#define TT_MAC_LANGID_WELSH 128
#define TT_MAC_LANGID_BASQUE 129
#define TT_MAC_LANGID_CATALAN 130
#define TT_MAC_LANGID_LATIN 131
#define TT_MAC_LANGID_QUECHUA 132
#define TT_MAC_LANGID_GUARANI 133
#define TT_MAC_LANGID_AYMARA 134
#define TT_MAC_LANGID_TATAR 135
#define TT_MAC_LANGID_UIGHUR 136
#define TT_MAC_LANGID_DZONGKHA 137
#define TT_MAC_LANGID_JAVANESE 138
#define TT_MAC_LANGID_SUNDANESE 139
/* The following codes are new as of 2000-03-10 */
#define TT_MAC_LANGID_GALICIAN 140
#define TT_MAC_LANGID_AFRIKAANS 141
#define TT_MAC_LANGID_BRETON 142
#define TT_MAC_LANGID_INUKTITUT 143
#define TT_MAC_LANGID_SCOTTISH_GAELIC 144
#define TT_MAC_LANGID_MANX_GAELIC 145
#define TT_MAC_LANGID_IRISH_GAELIC 146
#define TT_MAC_LANGID_TONGAN 147
#define TT_MAC_LANGID_GREEK_POLYTONIC 148
#define TT_MAC_LANGID_GREELANDIC 149
#define TT_MAC_LANGID_AZERBAIJANI_ROMAN_SCRIPT 150
/**************************************************************************
*
* @enum:
* TT_MS_LANGID_XXX
*
* @description:
* Possible values of the language identifier field in the name records
* of the SFNT 'name' table if the 'platform' identifier code is
* @TT_PLATFORM_MICROSOFT. These values are also used as return values
* for function @FT_Get_CMap_Language_ID.
*
* The canonical source for Microsoft's IDs is
*
* https://docs.microsoft.com/en-us/windows/desktop/Intl/language-identifier-constants-and-strings ,
*
* however, we only provide macros for language identifiers present in
* the OpenType specification: Microsoft has abandoned the concept of
* LCIDs (language code identifiers), and format~1 of the 'name' table
* provides a better mechanism for languages not covered here.
*
* More legacy values not listed in the reference can be found in the
* @FT_TRUETYPE_IDS_H header file.
*/
#define TT_MS_LANGID_ARABIC_SAUDI_ARABIA 0x0401
#define TT_MS_LANGID_ARABIC_IRAQ 0x0801
#define TT_MS_LANGID_ARABIC_EGYPT 0x0C01
#define TT_MS_LANGID_ARABIC_LIBYA 0x1001
#define TT_MS_LANGID_ARABIC_ALGERIA 0x1401
#define TT_MS_LANGID_ARABIC_MOROCCO 0x1801
#define TT_MS_LANGID_ARABIC_TUNISIA 0x1C01
#define TT_MS_LANGID_ARABIC_OMAN 0x2001
#define TT_MS_LANGID_ARABIC_YEMEN 0x2401
#define TT_MS_LANGID_ARABIC_SYRIA 0x2801
#define TT_MS_LANGID_ARABIC_JORDAN 0x2C01
#define TT_MS_LANGID_ARABIC_LEBANON 0x3001
#define TT_MS_LANGID_ARABIC_KUWAIT 0x3401
#define TT_MS_LANGID_ARABIC_UAE 0x3801
#define TT_MS_LANGID_ARABIC_BAHRAIN 0x3C01
#define TT_MS_LANGID_ARABIC_QATAR 0x4001
#define TT_MS_LANGID_BULGARIAN_BULGARIA 0x0402
#define TT_MS_LANGID_CATALAN_CATALAN 0x0403
#define TT_MS_LANGID_CHINESE_TAIWAN 0x0404
#define TT_MS_LANGID_CHINESE_PRC 0x0804
#define TT_MS_LANGID_CHINESE_HONG_KONG 0x0C04
#define TT_MS_LANGID_CHINESE_SINGAPORE 0x1004
#define TT_MS_LANGID_CHINESE_MACAO 0x1404
#define TT_MS_LANGID_CZECH_CZECH_REPUBLIC 0x0405
#define TT_MS_LANGID_DANISH_DENMARK 0x0406
#define TT_MS_LANGID_GERMAN_GERMANY 0x0407
#define TT_MS_LANGID_GERMAN_SWITZERLAND 0x0807
#define TT_MS_LANGID_GERMAN_AUSTRIA 0x0C07
#define TT_MS_LANGID_GERMAN_LUXEMBOURG 0x1007
#define TT_MS_LANGID_GERMAN_LIECHTENSTEIN 0x1407
#define TT_MS_LANGID_GREEK_GREECE 0x0408
#define TT_MS_LANGID_ENGLISH_UNITED_STATES 0x0409
#define TT_MS_LANGID_ENGLISH_UNITED_KINGDOM 0x0809
#define TT_MS_LANGID_ENGLISH_AUSTRALIA 0x0C09
#define TT_MS_LANGID_ENGLISH_CANADA 0x1009
#define TT_MS_LANGID_ENGLISH_NEW_ZEALAND 0x1409
#define TT_MS_LANGID_ENGLISH_IRELAND 0x1809
#define TT_MS_LANGID_ENGLISH_SOUTH_AFRICA 0x1C09
#define TT_MS_LANGID_ENGLISH_JAMAICA 0x2009
#define TT_MS_LANGID_ENGLISH_CARIBBEAN 0x2409
#define TT_MS_LANGID_ENGLISH_BELIZE 0x2809
#define TT_MS_LANGID_ENGLISH_TRINIDAD 0x2C09
#define TT_MS_LANGID_ENGLISH_ZIMBABWE 0x3009
#define TT_MS_LANGID_ENGLISH_PHILIPPINES 0x3409
#define TT_MS_LANGID_ENGLISH_INDIA 0x4009
#define TT_MS_LANGID_ENGLISH_MALAYSIA 0x4409
#define TT_MS_LANGID_ENGLISH_SINGAPORE 0x4809
#define TT_MS_LANGID_SPANISH_SPAIN_TRADITIONAL_SORT 0x040A
#define TT_MS_LANGID_SPANISH_MEXICO 0x080A
#define TT_MS_LANGID_SPANISH_SPAIN_MODERN_SORT 0x0C0A
#define TT_MS_LANGID_SPANISH_GUATEMALA 0x100A
#define TT_MS_LANGID_SPANISH_COSTA_RICA 0x140A
#define TT_MS_LANGID_SPANISH_PANAMA 0x180A
#define TT_MS_LANGID_SPANISH_DOMINICAN_REPUBLIC 0x1C0A
#define TT_MS_LANGID_SPANISH_VENEZUELA 0x200A
#define TT_MS_LANGID_SPANISH_COLOMBIA 0x240A
#define TT_MS_LANGID_SPANISH_PERU 0x280A
#define TT_MS_LANGID_SPANISH_ARGENTINA 0x2C0A
#define TT_MS_LANGID_SPANISH_ECUADOR 0x300A
#define TT_MS_LANGID_SPANISH_CHILE 0x340A
#define TT_MS_LANGID_SPANISH_URUGUAY 0x380A
#define TT_MS_LANGID_SPANISH_PARAGUAY 0x3C0A
#define TT_MS_LANGID_SPANISH_BOLIVIA 0x400A
#define TT_MS_LANGID_SPANISH_EL_SALVADOR 0x440A
#define TT_MS_LANGID_SPANISH_HONDURAS 0x480A
#define TT_MS_LANGID_SPANISH_NICARAGUA 0x4C0A
#define TT_MS_LANGID_SPANISH_PUERTO_RICO 0x500A
#define TT_MS_LANGID_SPANISH_UNITED_STATES 0x540A
#define TT_MS_LANGID_FINNISH_FINLAND 0x040B
#define TT_MS_LANGID_FRENCH_FRANCE 0x040C
#define TT_MS_LANGID_FRENCH_BELGIUM 0x080C
#define TT_MS_LANGID_FRENCH_CANADA 0x0C0C
#define TT_MS_LANGID_FRENCH_SWITZERLAND 0x100C
#define TT_MS_LANGID_FRENCH_LUXEMBOURG 0x140C
#define TT_MS_LANGID_FRENCH_MONACO 0x180C
#define TT_MS_LANGID_HEBREW_ISRAEL 0x040D
#define TT_MS_LANGID_HUNGARIAN_HUNGARY 0x040E
#define TT_MS_LANGID_ICELANDIC_ICELAND 0x040F
#define TT_MS_LANGID_ITALIAN_ITALY 0x0410
#define TT_MS_LANGID_ITALIAN_SWITZERLAND 0x0810
#define TT_MS_LANGID_JAPANESE_JAPAN 0x0411
#define TT_MS_LANGID_KOREAN_KOREA 0x0412
#define TT_MS_LANGID_DUTCH_NETHERLANDS 0x0413
#define TT_MS_LANGID_DUTCH_BELGIUM 0x0813
#define TT_MS_LANGID_NORWEGIAN_NORWAY_BOKMAL 0x0414
#define TT_MS_LANGID_NORWEGIAN_NORWAY_NYNORSK 0x0814
#define TT_MS_LANGID_POLISH_POLAND 0x0415
#define TT_MS_LANGID_PORTUGUESE_BRAZIL 0x0416
#define TT_MS_LANGID_PORTUGUESE_PORTUGAL 0x0816
#define TT_MS_LANGID_ROMANSH_SWITZERLAND 0x0417
#define TT_MS_LANGID_ROMANIAN_ROMANIA 0x0418
#define TT_MS_LANGID_RUSSIAN_RUSSIA 0x0419
#define TT_MS_LANGID_CROATIAN_CROATIA 0x041A
#define TT_MS_LANGID_SERBIAN_SERBIA_LATIN 0x081A
#define TT_MS_LANGID_SERBIAN_SERBIA_CYRILLIC 0x0C1A
#define TT_MS_LANGID_CROATIAN_BOSNIA_HERZEGOVINA 0x101A
#define TT_MS_LANGID_BOSNIAN_BOSNIA_HERZEGOVINA 0x141A
#define TT_MS_LANGID_SERBIAN_BOSNIA_HERZ_LATIN 0x181A
#define TT_MS_LANGID_SERBIAN_BOSNIA_HERZ_CYRILLIC 0x1C1A
#define TT_MS_LANGID_BOSNIAN_BOSNIA_HERZ_CYRILLIC 0x201A
#define TT_MS_LANGID_SLOVAK_SLOVAKIA 0x041B
#define TT_MS_LANGID_ALBANIAN_ALBANIA 0x041C
#define TT_MS_LANGID_SWEDISH_SWEDEN 0x041D
#define TT_MS_LANGID_SWEDISH_FINLAND 0x081D
#define TT_MS_LANGID_THAI_THAILAND 0x041E
#define TT_MS_LANGID_TURKISH_TURKEY 0x041F
#define TT_MS_LANGID_URDU_PAKISTAN 0x0420
#define TT_MS_LANGID_INDONESIAN_INDONESIA 0x0421
#define TT_MS_LANGID_UKRAINIAN_UKRAINE 0x0422
#define TT_MS_LANGID_BELARUSIAN_BELARUS 0x0423
#define TT_MS_LANGID_SLOVENIAN_SLOVENIA 0x0424
#define TT_MS_LANGID_ESTONIAN_ESTONIA 0x0425
#define TT_MS_LANGID_LATVIAN_LATVIA 0x0426
#define TT_MS_LANGID_LITHUANIAN_LITHUANIA 0x0427
#define TT_MS_LANGID_TAJIK_TAJIKISTAN 0x0428
#define TT_MS_LANGID_VIETNAMESE_VIET_NAM 0x042A
#define TT_MS_LANGID_ARMENIAN_ARMENIA 0x042B
#define TT_MS_LANGID_AZERI_AZERBAIJAN_LATIN 0x042C
#define TT_MS_LANGID_AZERI_AZERBAIJAN_CYRILLIC 0x082C
#define TT_MS_LANGID_BASQUE_BASQUE 0x042D
#define TT_MS_LANGID_UPPER_SORBIAN_GERMANY 0x042E
#define TT_MS_LANGID_LOWER_SORBIAN_GERMANY 0x082E
#define TT_MS_LANGID_MACEDONIAN_MACEDONIA 0x042F
#define TT_MS_LANGID_SETSWANA_SOUTH_AFRICA 0x0432
#define TT_MS_LANGID_ISIXHOSA_SOUTH_AFRICA 0x0434
#define TT_MS_LANGID_ISIZULU_SOUTH_AFRICA 0x0435
#define TT_MS_LANGID_AFRIKAANS_SOUTH_AFRICA 0x0436
#define TT_MS_LANGID_GEORGIAN_GEORGIA 0x0437
#define TT_MS_LANGID_FAEROESE_FAEROE_ISLANDS 0x0438
#define TT_MS_LANGID_HINDI_INDIA 0x0439
#define TT_MS_LANGID_MALTESE_MALTA 0x043A
#define TT_MS_LANGID_SAMI_NORTHERN_NORWAY 0x043B
#define TT_MS_LANGID_SAMI_NORTHERN_SWEDEN 0x083B
#define TT_MS_LANGID_SAMI_NORTHERN_FINLAND 0x0C3B
#define TT_MS_LANGID_SAMI_LULE_NORWAY 0x103B
#define TT_MS_LANGID_SAMI_LULE_SWEDEN 0x143B
#define TT_MS_LANGID_SAMI_SOUTHERN_NORWAY 0x183B
#define TT_MS_LANGID_SAMI_SOUTHERN_SWEDEN 0x1C3B
#define TT_MS_LANGID_SAMI_SKOLT_FINLAND 0x203B
#define TT_MS_LANGID_SAMI_INARI_FINLAND 0x243B
#define TT_MS_LANGID_IRISH_IRELAND 0x083C
#define TT_MS_LANGID_MALAY_MALAYSIA 0x043E
#define TT_MS_LANGID_MALAY_BRUNEI_DARUSSALAM 0x083E
#define TT_MS_LANGID_KAZAKH_KAZAKHSTAN 0x043F
#define TT_MS_LANGID_KYRGYZ_KYRGYZSTAN /* Cyrillic */ 0x0440
#define TT_MS_LANGID_KISWAHILI_KENYA 0x0441
#define TT_MS_LANGID_TURKMEN_TURKMENISTAN 0x0442
#define TT_MS_LANGID_UZBEK_UZBEKISTAN_LATIN 0x0443
#define TT_MS_LANGID_UZBEK_UZBEKISTAN_CYRILLIC 0x0843
#define TT_MS_LANGID_TATAR_RUSSIA 0x0444
#define TT_MS_LANGID_BENGALI_INDIA 0x0445
#define TT_MS_LANGID_BENGALI_BANGLADESH 0x0845
#define TT_MS_LANGID_PUNJABI_INDIA 0x0446
#define TT_MS_LANGID_GUJARATI_INDIA 0x0447
#define TT_MS_LANGID_ODIA_INDIA 0x0448
#define TT_MS_LANGID_TAMIL_INDIA 0x0449
#define TT_MS_LANGID_TELUGU_INDIA 0x044A
#define TT_MS_LANGID_KANNADA_INDIA 0x044B
#define TT_MS_LANGID_MALAYALAM_INDIA 0x044C
#define TT_MS_LANGID_ASSAMESE_INDIA 0x044D
#define TT_MS_LANGID_MARATHI_INDIA 0x044E
#define TT_MS_LANGID_SANSKRIT_INDIA 0x044F
#define TT_MS_LANGID_MONGOLIAN_MONGOLIA /* Cyrillic */ 0x0450
#define TT_MS_LANGID_MONGOLIAN_PRC 0x0850
#define TT_MS_LANGID_TIBETAN_PRC 0x0451
#define TT_MS_LANGID_WELSH_UNITED_KINGDOM 0x0452
#define TT_MS_LANGID_KHMER_CAMBODIA 0x0453
#define TT_MS_LANGID_LAO_LAOS 0x0454
#define TT_MS_LANGID_GALICIAN_GALICIAN 0x0456
#define TT_MS_LANGID_KONKANI_INDIA 0x0457
#define TT_MS_LANGID_SYRIAC_SYRIA 0x045A
#define TT_MS_LANGID_SINHALA_SRI_LANKA 0x045B
#define TT_MS_LANGID_INUKTITUT_CANADA 0x045D
#define TT_MS_LANGID_INUKTITUT_CANADA_LATIN 0x085D
#define TT_MS_LANGID_AMHARIC_ETHIOPIA 0x045E
#define TT_MS_LANGID_TAMAZIGHT_ALGERIA 0x085F
#define TT_MS_LANGID_NEPALI_NEPAL 0x0461
#define TT_MS_LANGID_FRISIAN_NETHERLANDS 0x0462
#define TT_MS_LANGID_PASHTO_AFGHANISTAN 0x0463
#define TT_MS_LANGID_FILIPINO_PHILIPPINES 0x0464
#define TT_MS_LANGID_DHIVEHI_MALDIVES 0x0465
#define TT_MS_LANGID_HAUSA_NIGERIA 0x0468
#define TT_MS_LANGID_YORUBA_NIGERIA 0x046A
#define TT_MS_LANGID_QUECHUA_BOLIVIA 0x046B
#define TT_MS_LANGID_QUECHUA_ECUADOR 0x086B
#define TT_MS_LANGID_QUECHUA_PERU 0x0C6B
#define TT_MS_LANGID_SESOTHO_SA_LEBOA_SOUTH_AFRICA 0x046C
#define TT_MS_LANGID_BASHKIR_RUSSIA 0x046D
#define TT_MS_LANGID_LUXEMBOURGISH_LUXEMBOURG 0x046E
#define TT_MS_LANGID_GREENLANDIC_GREENLAND 0x046F
#define TT_MS_LANGID_IGBO_NIGERIA 0x0470
#define TT_MS_LANGID_YI_PRC 0x0478
#define TT_MS_LANGID_MAPUDUNGUN_CHILE 0x047A
#define TT_MS_LANGID_MOHAWK_MOHAWK 0x047C
#define TT_MS_LANGID_BRETON_FRANCE 0x047E
#define TT_MS_LANGID_UIGHUR_PRC 0x0480
#define TT_MS_LANGID_MAORI_NEW_ZEALAND 0x0481
#define TT_MS_LANGID_OCCITAN_FRANCE 0x0482
#define TT_MS_LANGID_CORSICAN_FRANCE 0x0483
#define TT_MS_LANGID_ALSATIAN_FRANCE 0x0484
#define TT_MS_LANGID_YAKUT_RUSSIA 0x0485
#define TT_MS_LANGID_KICHE_GUATEMALA 0x0486
#define TT_MS_LANGID_KINYARWANDA_RWANDA 0x0487
#define TT_MS_LANGID_WOLOF_SENEGAL 0x0488
#define TT_MS_LANGID_DARI_AFGHANISTAN 0x048C
/* */
/* legacy macro definitions not present in OpenType 1.8.1 */
#define TT_MS_LANGID_ARABIC_GENERAL 0x0001
#define TT_MS_LANGID_CATALAN_SPAIN \
TT_MS_LANGID_CATALAN_CATALAN
#define TT_MS_LANGID_CHINESE_GENERAL 0x0004
#define TT_MS_LANGID_CHINESE_MACAU \
TT_MS_LANGID_CHINESE_MACAO
#define TT_MS_LANGID_GERMAN_LIECHTENSTEI \
TT_MS_LANGID_GERMAN_LIECHTENSTEIN
#define TT_MS_LANGID_ENGLISH_GENERAL 0x0009
#define TT_MS_LANGID_ENGLISH_INDONESIA 0x3809
#define TT_MS_LANGID_ENGLISH_HONG_KONG 0x3C09
#define TT_MS_LANGID_SPANISH_SPAIN_INTERNATIONAL_SORT \
TT_MS_LANGID_SPANISH_SPAIN_MODERN_SORT
#define TT_MS_LANGID_SPANISH_LATIN_AMERICA 0xE40AU
#define TT_MS_LANGID_FRENCH_WEST_INDIES 0x1C0C
#define TT_MS_LANGID_FRENCH_REUNION 0x200C
#define TT_MS_LANGID_FRENCH_CONGO 0x240C
/* which was formerly: */
#define TT_MS_LANGID_FRENCH_ZAIRE \
TT_MS_LANGID_FRENCH_CONGO
#define TT_MS_LANGID_FRENCH_SENEGAL 0x280C
#define TT_MS_LANGID_FRENCH_CAMEROON 0x2C0C
#define TT_MS_LANGID_FRENCH_COTE_D_IVOIRE 0x300C
#define TT_MS_LANGID_FRENCH_MALI 0x340C
#define TT_MS_LANGID_FRENCH_MOROCCO 0x380C
#define TT_MS_LANGID_FRENCH_HAITI 0x3C0C
#define TT_MS_LANGID_FRENCH_NORTH_AFRICA 0xE40CU
#define TT_MS_LANGID_KOREAN_EXTENDED_WANSUNG_KOREA \
TT_MS_LANGID_KOREAN_KOREA
#define TT_MS_LANGID_KOREAN_JOHAB_KOREA 0x0812
#define TT_MS_LANGID_RHAETO_ROMANIC_SWITZERLAND \
TT_MS_LANGID_ROMANSH_SWITZERLAND
#define TT_MS_LANGID_MOLDAVIAN_MOLDAVIA 0x0818
#define TT_MS_LANGID_RUSSIAN_MOLDAVIA 0x0819
#define TT_MS_LANGID_URDU_INDIA 0x0820
#define TT_MS_LANGID_CLASSIC_LITHUANIAN_LITHUANIA 0x0827
#define TT_MS_LANGID_SLOVENE_SLOVENIA \
TT_MS_LANGID_SLOVENIAN_SLOVENIA
#define TT_MS_LANGID_FARSI_IRAN 0x0429
#define TT_MS_LANGID_BASQUE_SPAIN \
TT_MS_LANGID_BASQUE_BASQUE
#define TT_MS_LANGID_SORBIAN_GERMANY \
TT_MS_LANGID_UPPER_SORBIAN_GERMANY
#define TT_MS_LANGID_SUTU_SOUTH_AFRICA 0x0430
#define TT_MS_LANGID_TSONGA_SOUTH_AFRICA 0x0431
#define TT_MS_LANGID_TSWANA_SOUTH_AFRICA \
TT_MS_LANGID_SETSWANA_SOUTH_AFRICA
#define TT_MS_LANGID_VENDA_SOUTH_AFRICA 0x0433
#define TT_MS_LANGID_XHOSA_SOUTH_AFRICA \
TT_MS_LANGID_ISIXHOSA_SOUTH_AFRICA
#define TT_MS_LANGID_ZULU_SOUTH_AFRICA \
TT_MS_LANGID_ISIZULU_SOUTH_AFRICA
#define TT_MS_LANGID_SAAMI_LAPONIA 0x043B
/* the next two values are incorrectly inverted */
#define TT_MS_LANGID_IRISH_GAELIC_IRELAND 0x043C
#define TT_MS_LANGID_SCOTTISH_GAELIC_UNITED_KINGDOM 0x083C
#define TT_MS_LANGID_YIDDISH_GERMANY 0x043D
#define TT_MS_LANGID_KAZAK_KAZAKSTAN \
TT_MS_LANGID_KAZAKH_KAZAKHSTAN
#define TT_MS_LANGID_KIRGHIZ_KIRGHIZ_REPUBLIC \
TT_MS_LANGID_KYRGYZ_KYRGYZSTAN
#define TT_MS_LANGID_KIRGHIZ_KIRGHIZSTAN \
TT_MS_LANGID_KYRGYZ_KYRGYZSTAN
#define TT_MS_LANGID_SWAHILI_KENYA \
TT_MS_LANGID_KISWAHILI_KENYA
#define TT_MS_LANGID_TATAR_TATARSTAN \
TT_MS_LANGID_TATAR_RUSSIA
#define TT_MS_LANGID_PUNJABI_ARABIC_PAKISTAN 0x0846
#define TT_MS_LANGID_ORIYA_INDIA \
TT_MS_LANGID_ODIA_INDIA
#define TT_MS_LANGID_MONGOLIAN_MONGOLIA_MONGOLIAN \
TT_MS_LANGID_MONGOLIAN_PRC
#define TT_MS_LANGID_TIBETAN_CHINA \
TT_MS_LANGID_TIBETAN_PRC
#define TT_MS_LANGID_DZONGHKA_BHUTAN 0x0851
#define TT_MS_LANGID_TIBETAN_BHUTAN \
TT_MS_LANGID_DZONGHKA_BHUTAN
#define TT_MS_LANGID_WELSH_WALES \
TT_MS_LANGID_WELSH_UNITED_KINGDOM
#define TT_MS_LANGID_BURMESE_MYANMAR 0x0455
#define TT_MS_LANGID_GALICIAN_SPAIN \
TT_MS_LANGID_GALICIAN_GALICIAN
#define TT_MS_LANGID_MANIPURI_INDIA /* Bengali */ 0x0458
#define TT_MS_LANGID_SINDHI_INDIA /* Arabic */ 0x0459
#define TT_MS_LANGID_SINDHI_PAKISTAN 0x0859
#define TT_MS_LANGID_SINHALESE_SRI_LANKA \
TT_MS_LANGID_SINHALA_SRI_LANKA
#define TT_MS_LANGID_CHEROKEE_UNITED_STATES 0x045C
#define TT_MS_LANGID_TAMAZIGHT_MOROCCO /* Arabic */ 0x045F
#define TT_MS_LANGID_TAMAZIGHT_MOROCCO_LATIN \
TT_MS_LANGID_TAMAZIGHT_ALGERIA
#define TT_MS_LANGID_KASHMIRI_PAKISTAN /* Arabic */ 0x0460
#define TT_MS_LANGID_KASHMIRI_SASIA 0x0860
#define TT_MS_LANGID_KASHMIRI_INDIA \
TT_MS_LANGID_KASHMIRI_SASIA
#define TT_MS_LANGID_NEPALI_INDIA 0x0861
#define TT_MS_LANGID_DIVEHI_MALDIVES \
TT_MS_LANGID_DHIVEHI_MALDIVES
#define TT_MS_LANGID_EDO_NIGERIA 0x0466
#define TT_MS_LANGID_FULFULDE_NIGERIA 0x0467
#define TT_MS_LANGID_IBIBIO_NIGERIA 0x0469
#define TT_MS_LANGID_SEPEDI_SOUTH_AFRICA \
TT_MS_LANGID_SESOTHO_SA_LEBOA_SOUTH_AFRICA
#define TT_MS_LANGID_SOTHO_SOUTHERN_SOUTH_AFRICA \
TT_MS_LANGID_SESOTHO_SA_LEBOA_SOUTH_AFRICA
#define TT_MS_LANGID_KANURI_NIGERIA 0x0471
#define TT_MS_LANGID_OROMO_ETHIOPIA 0x0472
#define TT_MS_LANGID_TIGRIGNA_ETHIOPIA 0x0473
#define TT_MS_LANGID_TIGRIGNA_ERYTHREA 0x0873
#define TT_MS_LANGID_TIGRIGNA_ERYTREA \
TT_MS_LANGID_TIGRIGNA_ERYTHREA
#define TT_MS_LANGID_GUARANI_PARAGUAY 0x0474
#define TT_MS_LANGID_HAWAIIAN_UNITED_STATES 0x0475
#define TT_MS_LANGID_LATIN 0x0476
#define TT_MS_LANGID_SOMALI_SOMALIA 0x0477
#define TT_MS_LANGID_YI_CHINA \
TT_MS_LANGID_YI_PRC
#define TT_MS_LANGID_PAPIAMENTU_NETHERLANDS_ANTILLES 0x0479
#define TT_MS_LANGID_UIGHUR_CHINA \
TT_MS_LANGID_UIGHUR_PRC
/**************************************************************************
*
* @enum:
* TT_NAME_ID_XXX
*
* @description:
* Possible values of the 'name' identifier field in the name records of
* an SFNT 'name' table. These values are platform independent.
*/
#define TT_NAME_ID_COPYRIGHT 0
#define TT_NAME_ID_FONT_FAMILY 1
#define TT_NAME_ID_FONT_SUBFAMILY 2
#define TT_NAME_ID_UNIQUE_ID 3
#define TT_NAME_ID_FULL_NAME 4
#define TT_NAME_ID_VERSION_STRING 5
#define TT_NAME_ID_PS_NAME 6
#define TT_NAME_ID_TRADEMARK 7
/* the following values are from the OpenType spec */
#define TT_NAME_ID_MANUFACTURER 8
#define TT_NAME_ID_DESIGNER 9
#define TT_NAME_ID_DESCRIPTION 10
#define TT_NAME_ID_VENDOR_URL 11
#define TT_NAME_ID_DESIGNER_URL 12
#define TT_NAME_ID_LICENSE 13
#define TT_NAME_ID_LICENSE_URL 14
/* number 15 is reserved */
#define TT_NAME_ID_TYPOGRAPHIC_FAMILY 16
#define TT_NAME_ID_TYPOGRAPHIC_SUBFAMILY 17
#define TT_NAME_ID_MAC_FULL_NAME 18
/* The following code is new as of 2000-01-21 */
#define TT_NAME_ID_SAMPLE_TEXT 19
/* This is new in OpenType 1.3 */
#define TT_NAME_ID_CID_FINDFONT_NAME 20
/* This is new in OpenType 1.5 */
#define TT_NAME_ID_WWS_FAMILY 21
#define TT_NAME_ID_WWS_SUBFAMILY 22
/* This is new in OpenType 1.7 */
#define TT_NAME_ID_LIGHT_BACKGROUND 23
#define TT_NAME_ID_DARK_BACKGROUND 24
/* This is new in OpenType 1.8 */
#define TT_NAME_ID_VARIATIONS_PREFIX 25
/* these two values are deprecated */
#define TT_NAME_ID_PREFERRED_FAMILY TT_NAME_ID_TYPOGRAPHIC_FAMILY
#define TT_NAME_ID_PREFERRED_SUBFAMILY TT_NAME_ID_TYPOGRAPHIC_SUBFAMILY
/**************************************************************************
*
* @enum:
* TT_UCR_XXX
*
* @description:
* Possible bit mask values for the `ulUnicodeRangeX` fields in an SFNT
* 'OS/2' table.
*/
/* ulUnicodeRange1 */
/* --------------- */
/* Bit 0 Basic Latin */
#define TT_UCR_BASIC_LATIN (1L << 0) /* U+0020-U+007E */
/* Bit 1 C1 Controls and Latin-1 Supplement */
#define TT_UCR_LATIN1_SUPPLEMENT (1L << 1) /* U+0080-U+00FF */
/* Bit 2 Latin Extended-A */
#define TT_UCR_LATIN_EXTENDED_A (1L << 2) /* U+0100-U+017F */
/* Bit 3 Latin Extended-B */
#define TT_UCR_LATIN_EXTENDED_B (1L << 3) /* U+0180-U+024F */
/* Bit 4 IPA Extensions */
/* Phonetic Extensions */
/* Phonetic Extensions Supplement */
#define TT_UCR_IPA_EXTENSIONS (1L << 4) /* U+0250-U+02AF */
/* U+1D00-U+1D7F */
/* U+1D80-U+1DBF */
/* Bit 5 Spacing Modifier Letters */
/* Modifier Tone Letters */
#define TT_UCR_SPACING_MODIFIER (1L << 5) /* U+02B0-U+02FF */
/* U+A700-U+A71F */
/* Bit 6 Combining Diacritical Marks */
/* Combining Diacritical Marks Supplement */
#define TT_UCR_COMBINING_DIACRITICAL_MARKS (1L << 6) /* U+0300-U+036F */
/* U+1DC0-U+1DFF */
/* Bit 7 Greek and Coptic */
#define TT_UCR_GREEK (1L << 7) /* U+0370-U+03FF */
/* Bit 8 Coptic */
#define TT_UCR_COPTIC (1L << 8) /* U+2C80-U+2CFF */
/* Bit 9 Cyrillic */
/* Cyrillic Supplement */
/* Cyrillic Extended-A */
/* Cyrillic Extended-B */
#define TT_UCR_CYRILLIC (1L << 9) /* U+0400-U+04FF */
/* U+0500-U+052F */
/* U+2DE0-U+2DFF */
/* U+A640-U+A69F */
/* Bit 10 Armenian */
#define TT_UCR_ARMENIAN (1L << 10) /* U+0530-U+058F */
/* Bit 11 Hebrew */
#define TT_UCR_HEBREW (1L << 11) /* U+0590-U+05FF */
/* Bit 12 Vai */
#define TT_UCR_VAI (1L << 12) /* U+A500-U+A63F */
/* Bit 13 Arabic */
/* Arabic Supplement */
#define TT_UCR_ARABIC (1L << 13) /* U+0600-U+06FF */
/* U+0750-U+077F */
/* Bit 14 NKo */
#define TT_UCR_NKO (1L << 14) /* U+07C0-U+07FF */
/* Bit 15 Devanagari */
#define TT_UCR_DEVANAGARI (1L << 15) /* U+0900-U+097F */
/* Bit 16 Bengali */
#define TT_UCR_BENGALI (1L << 16) /* U+0980-U+09FF */
/* Bit 17 Gurmukhi */
#define TT_UCR_GURMUKHI (1L << 17) /* U+0A00-U+0A7F */
/* Bit 18 Gujarati */
#define TT_UCR_GUJARATI (1L << 18) /* U+0A80-U+0AFF */
/* Bit 19 Oriya */
#define TT_UCR_ORIYA (1L << 19) /* U+0B00-U+0B7F */
/* Bit 20 Tamil */
#define TT_UCR_TAMIL (1L << 20) /* U+0B80-U+0BFF */
/* Bit 21 Telugu */
#define TT_UCR_TELUGU (1L << 21) /* U+0C00-U+0C7F */
/* Bit 22 Kannada */
#define TT_UCR_KANNADA (1L << 22) /* U+0C80-U+0CFF */
/* Bit 23 Malayalam */
#define TT_UCR_MALAYALAM (1L << 23) /* U+0D00-U+0D7F */
/* Bit 24 Thai */
#define TT_UCR_THAI (1L << 24) /* U+0E00-U+0E7F */
/* Bit 25 Lao */
#define TT_UCR_LAO (1L << 25) /* U+0E80-U+0EFF */
/* Bit 26 Georgian */
/* Georgian Supplement */
#define TT_UCR_GEORGIAN (1L << 26) /* U+10A0-U+10FF */
/* U+2D00-U+2D2F */
/* Bit 27 Balinese */
#define TT_UCR_BALINESE (1L << 27) /* U+1B00-U+1B7F */
/* Bit 28 Hangul Jamo */
#define TT_UCR_HANGUL_JAMO (1L << 28) /* U+1100-U+11FF */
/* Bit 29 Latin Extended Additional */
/* Latin Extended-C */
/* Latin Extended-D */
#define TT_UCR_LATIN_EXTENDED_ADDITIONAL (1L << 29) /* U+1E00-U+1EFF */
/* U+2C60-U+2C7F */
/* U+A720-U+A7FF */
/* Bit 30 Greek Extended */
#define TT_UCR_GREEK_EXTENDED (1L << 30) /* U+1F00-U+1FFF */
/* Bit 31 General Punctuation */
/* Supplemental Punctuation */
#define TT_UCR_GENERAL_PUNCTUATION (1L << 31) /* U+2000-U+206F */
/* U+2E00-U+2E7F */
/* ulUnicodeRange2 */
/* --------------- */
/* Bit 32 Superscripts And Subscripts */
#define TT_UCR_SUPERSCRIPTS_SUBSCRIPTS (1L << 0) /* U+2070-U+209F */
/* Bit 33 Currency Symbols */
#define TT_UCR_CURRENCY_SYMBOLS (1L << 1) /* U+20A0-U+20CF */
/* Bit 34 Combining Diacritical Marks For Symbols */
#define TT_UCR_COMBINING_DIACRITICAL_MARKS_SYMB \
(1L << 2) /* U+20D0-U+20FF */
/* Bit 35 Letterlike Symbols */
#define TT_UCR_LETTERLIKE_SYMBOLS (1L << 3) /* U+2100-U+214F */
/* Bit 36 Number Forms */
#define TT_UCR_NUMBER_FORMS (1L << 4) /* U+2150-U+218F */
/* Bit 37 Arrows */
/* Supplemental Arrows-A */
/* Supplemental Arrows-B */
/* Miscellaneous Symbols and Arrows */
#define TT_UCR_ARROWS (1L << 5) /* U+2190-U+21FF */
/* U+27F0-U+27FF */
/* U+2900-U+297F */
/* U+2B00-U+2BFF */
/* Bit 38 Mathematical Operators */
/* Supplemental Mathematical Operators */
/* Miscellaneous Mathematical Symbols-A */
/* Miscellaneous Mathematical Symbols-B */
#define TT_UCR_MATHEMATICAL_OPERATORS (1L << 6) /* U+2200-U+22FF */
/* U+2A00-U+2AFF */
/* U+27C0-U+27EF */
/* U+2980-U+29FF */
/* Bit 39 Miscellaneous Technical */
#define TT_UCR_MISCELLANEOUS_TECHNICAL (1L << 7) /* U+2300-U+23FF */
/* Bit 40 Control Pictures */
#define TT_UCR_CONTROL_PICTURES (1L << 8) /* U+2400-U+243F */
/* Bit 41 Optical Character Recognition */
#define TT_UCR_OCR (1L << 9) /* U+2440-U+245F */
/* Bit 42 Enclosed Alphanumerics */
#define TT_UCR_ENCLOSED_ALPHANUMERICS (1L << 10) /* U+2460-U+24FF */
/* Bit 43 Box Drawing */
#define TT_UCR_BOX_DRAWING (1L << 11) /* U+2500-U+257F */
/* Bit 44 Block Elements */
#define TT_UCR_BLOCK_ELEMENTS (1L << 12) /* U+2580-U+259F */
/* Bit 45 Geometric Shapes */
#define TT_UCR_GEOMETRIC_SHAPES (1L << 13) /* U+25A0-U+25FF */
/* Bit 46 Miscellaneous Symbols */
#define TT_UCR_MISCELLANEOUS_SYMBOLS (1L << 14) /* U+2600-U+26FF */
/* Bit 47 Dingbats */
#define TT_UCR_DINGBATS (1L << 15) /* U+2700-U+27BF */
/* Bit 48 CJK Symbols and Punctuation */
#define TT_UCR_CJK_SYMBOLS (1L << 16) /* U+3000-U+303F */
/* Bit 49 Hiragana */
#define TT_UCR_HIRAGANA (1L << 17) /* U+3040-U+309F */
/* Bit 50 Katakana */
/* Katakana Phonetic Extensions */
#define TT_UCR_KATAKANA (1L << 18) /* U+30A0-U+30FF */
/* U+31F0-U+31FF */
/* Bit 51 Bopomofo */
/* Bopomofo Extended */
#define TT_UCR_BOPOMOFO (1L << 19) /* U+3100-U+312F */
/* U+31A0-U+31BF */
/* Bit 52 Hangul Compatibility Jamo */
#define TT_UCR_HANGUL_COMPATIBILITY_JAMO (1L << 20) /* U+3130-U+318F */
/* Bit 53 Phags-Pa */
#define TT_UCR_CJK_MISC (1L << 21) /* U+A840-U+A87F */
#define TT_UCR_KANBUN TT_UCR_CJK_MISC /* deprecated */
#define TT_UCR_PHAGSPA
/* Bit 54 Enclosed CJK Letters and Months */
#define TT_UCR_ENCLOSED_CJK_LETTERS_MONTHS (1L << 22) /* U+3200-U+32FF */
/* Bit 55 CJK Compatibility */
#define TT_UCR_CJK_COMPATIBILITY (1L << 23) /* U+3300-U+33FF */
/* Bit 56 Hangul Syllables */
#define TT_UCR_HANGUL (1L << 24) /* U+AC00-U+D7A3 */
/* Bit 57 High Surrogates */
/* High Private Use Surrogates */
/* Low Surrogates */
/* According to OpenType specs v.1.3+, */
/* setting bit 57 implies that there is */
/* at least one codepoint beyond the */
/* Basic Multilingual Plane that is */
/* supported by this font. So it really */
/* means >= U+10000. */
#define TT_UCR_SURROGATES (1L << 25) /* U+D800-U+DB7F */
/* U+DB80-U+DBFF */
/* U+DC00-U+DFFF */
#define TT_UCR_NON_PLANE_0 TT_UCR_SURROGATES
/* Bit 58 Phoenician */
#define TT_UCR_PHOENICIAN (1L << 26) /*U+10900-U+1091F*/
/* Bit 59 CJK Unified Ideographs */
/* CJK Radicals Supplement */
/* Kangxi Radicals */
/* Ideographic Description Characters */
/* CJK Unified Ideographs Extension A */
/* CJK Unified Ideographs Extension B */
/* Kanbun */
#define TT_UCR_CJK_UNIFIED_IDEOGRAPHS (1L << 27) /* U+4E00-U+9FFF */
/* U+2E80-U+2EFF */
/* U+2F00-U+2FDF */
/* U+2FF0-U+2FFF */
/* U+3400-U+4DB5 */
/*U+20000-U+2A6DF*/
/* U+3190-U+319F */
/* Bit 60 Private Use */
#define TT_UCR_PRIVATE_USE (1L << 28) /* U+E000-U+F8FF */
/* Bit 61 CJK Strokes */
/* CJK Compatibility Ideographs */
/* CJK Compatibility Ideographs Supplement */
#define TT_UCR_CJK_COMPATIBILITY_IDEOGRAPHS (1L << 29) /* U+31C0-U+31EF */
/* U+F900-U+FAFF */
/*U+2F800-U+2FA1F*/
/* Bit 62 Alphabetic Presentation Forms */
#define TT_UCR_ALPHABETIC_PRESENTATION_FORMS (1L << 30) /* U+FB00-U+FB4F */
/* Bit 63 Arabic Presentation Forms-A */
#define TT_UCR_ARABIC_PRESENTATION_FORMS_A (1L << 31) /* U+FB50-U+FDFF */
/* ulUnicodeRange3 */
/* --------------- */
/* Bit 64 Combining Half Marks */
#define TT_UCR_COMBINING_HALF_MARKS (1L << 0) /* U+FE20-U+FE2F */
/* Bit 65 Vertical forms */
/* CJK Compatibility Forms */
#define TT_UCR_CJK_COMPATIBILITY_FORMS (1L << 1) /* U+FE10-U+FE1F */
/* U+FE30-U+FE4F */
/* Bit 66 Small Form Variants */
#define TT_UCR_SMALL_FORM_VARIANTS (1L << 2) /* U+FE50-U+FE6F */
/* Bit 67 Arabic Presentation Forms-B */
#define TT_UCR_ARABIC_PRESENTATION_FORMS_B (1L << 3) /* U+FE70-U+FEFE */
/* Bit 68 Halfwidth and Fullwidth Forms */
#define TT_UCR_HALFWIDTH_FULLWIDTH_FORMS (1L << 4) /* U+FF00-U+FFEF */
/* Bit 69 Specials */
#define TT_UCR_SPECIALS (1L << 5) /* U+FFF0-U+FFFD */
/* Bit 70 Tibetan */
#define TT_UCR_TIBETAN (1L << 6) /* U+0F00-U+0FFF */
/* Bit 71 Syriac */
#define TT_UCR_SYRIAC (1L << 7) /* U+0700-U+074F */
/* Bit 72 Thaana */
#define TT_UCR_THAANA (1L << 8) /* U+0780-U+07BF */
/* Bit 73 Sinhala */
#define TT_UCR_SINHALA (1L << 9) /* U+0D80-U+0DFF */
/* Bit 74 Myanmar */
#define TT_UCR_MYANMAR (1L << 10) /* U+1000-U+109F */
/* Bit 75 Ethiopic */
/* Ethiopic Supplement */
/* Ethiopic Extended */
#define TT_UCR_ETHIOPIC (1L << 11) /* U+1200-U+137F */
/* U+1380-U+139F */
/* U+2D80-U+2DDF */
/* Bit 76 Cherokee */
#define TT_UCR_CHEROKEE (1L << 12) /* U+13A0-U+13FF */
/* Bit 77 Unified Canadian Aboriginal Syllabics */
#define TT_UCR_CANADIAN_ABORIGINAL_SYLLABICS (1L << 13) /* U+1400-U+167F */
/* Bit 78 Ogham */
#define TT_UCR_OGHAM (1L << 14) /* U+1680-U+169F */
/* Bit 79 Runic */
#define TT_UCR_RUNIC (1L << 15) /* U+16A0-U+16FF */
/* Bit 80 Khmer */
/* Khmer Symbols */
#define TT_UCR_KHMER (1L << 16) /* U+1780-U+17FF */
/* U+19E0-U+19FF */
/* Bit 81 Mongolian */
#define TT_UCR_MONGOLIAN (1L << 17) /* U+1800-U+18AF */
/* Bit 82 Braille Patterns */
#define TT_UCR_BRAILLE (1L << 18) /* U+2800-U+28FF */
/* Bit 83 Yi Syllables */
/* Yi Radicals */
#define TT_UCR_YI (1L << 19) /* U+A000-U+A48F */
/* U+A490-U+A4CF */
/* Bit 84 Tagalog */
/* Hanunoo */
/* Buhid */
/* Tagbanwa */
#define TT_UCR_PHILIPPINE (1L << 20) /* U+1700-U+171F */
/* U+1720-U+173F */
/* U+1740-U+175F */
/* U+1760-U+177F */
/* Bit 85 Old Italic */
#define TT_UCR_OLD_ITALIC (1L << 21) /*U+10300-U+1032F*/
/* Bit 86 Gothic */
#define TT_UCR_GOTHIC (1L << 22) /*U+10330-U+1034F*/
/* Bit 87 Deseret */
#define TT_UCR_DESERET (1L << 23) /*U+10400-U+1044F*/
/* Bit 88 Byzantine Musical Symbols */
/* Musical Symbols */
/* Ancient Greek Musical Notation */
#define TT_UCR_MUSICAL_SYMBOLS (1L << 24) /*U+1D000-U+1D0FF*/
/*U+1D100-U+1D1FF*/
/*U+1D200-U+1D24F*/
/* Bit 89 Mathematical Alphanumeric Symbols */
#define TT_UCR_MATH_ALPHANUMERIC_SYMBOLS (1L << 25) /*U+1D400-U+1D7FF*/
/* Bit 90 Private Use (plane 15) */
/* Private Use (plane 16) */
#define TT_UCR_PRIVATE_USE_SUPPLEMENTARY (1L << 26) /*U+F0000-U+FFFFD*/
/*U+100000-U+10FFFD*/
/* Bit 91 Variation Selectors */
/* Variation Selectors Supplement */
#define TT_UCR_VARIATION_SELECTORS (1L << 27) /* U+FE00-U+FE0F */
/*U+E0100-U+E01EF*/
/* Bit 92 Tags */
#define TT_UCR_TAGS (1L << 28) /*U+E0000-U+E007F*/
/* Bit 93 Limbu */
#define TT_UCR_LIMBU (1L << 29) /* U+1900-U+194F */
/* Bit 94 Tai Le */
#define TT_UCR_TAI_LE (1L << 30) /* U+1950-U+197F */
/* Bit 95 New Tai Lue */
#define TT_UCR_NEW_TAI_LUE (1L << 31) /* U+1980-U+19DF */
/* ulUnicodeRange4 */
/* --------------- */
/* Bit 96 Buginese */
#define TT_UCR_BUGINESE (1L << 0) /* U+1A00-U+1A1F */
/* Bit 97 Glagolitic */
#define TT_UCR_GLAGOLITIC (1L << 1) /* U+2C00-U+2C5F */
/* Bit 98 Tifinagh */
#define TT_UCR_TIFINAGH (1L << 2) /* U+2D30-U+2D7F */
/* Bit 99 Yijing Hexagram Symbols */
#define TT_UCR_YIJING (1L << 3) /* U+4DC0-U+4DFF */
/* Bit 100 Syloti Nagri */
#define TT_UCR_SYLOTI_NAGRI (1L << 4) /* U+A800-U+A82F */
/* Bit 101 Linear B Syllabary */
/* Linear B Ideograms */
/* Aegean Numbers */
#define TT_UCR_LINEAR_B (1L << 5) /*U+10000-U+1007F*/
/*U+10080-U+100FF*/
/*U+10100-U+1013F*/
/* Bit 102 Ancient Greek Numbers */
#define TT_UCR_ANCIENT_GREEK_NUMBERS (1L << 6) /*U+10140-U+1018F*/
/* Bit 103 Ugaritic */
#define TT_UCR_UGARITIC (1L << 7) /*U+10380-U+1039F*/
/* Bit 104 Old Persian */
#define TT_UCR_OLD_PERSIAN (1L << 8) /*U+103A0-U+103DF*/
/* Bit 105 Shavian */
#define TT_UCR_SHAVIAN (1L << 9) /*U+10450-U+1047F*/
/* Bit 106 Osmanya */
#define TT_UCR_OSMANYA (1L << 10) /*U+10480-U+104AF*/
/* Bit 107 Cypriot Syllabary */
#define TT_UCR_CYPRIOT_SYLLABARY (1L << 11) /*U+10800-U+1083F*/
/* Bit 108 Kharoshthi */
#define TT_UCR_KHAROSHTHI (1L << 12) /*U+10A00-U+10A5F*/
/* Bit 109 Tai Xuan Jing Symbols */
#define TT_UCR_TAI_XUAN_JING (1L << 13) /*U+1D300-U+1D35F*/
/* Bit 110 Cuneiform */
/* Cuneiform Numbers and Punctuation */
#define TT_UCR_CUNEIFORM (1L << 14) /*U+12000-U+123FF*/
/*U+12400-U+1247F*/
/* Bit 111 Counting Rod Numerals */
#define TT_UCR_COUNTING_ROD_NUMERALS (1L << 15) /*U+1D360-U+1D37F*/
/* Bit 112 Sundanese */
#define TT_UCR_SUNDANESE (1L << 16) /* U+1B80-U+1BBF */
/* Bit 113 Lepcha */
#define TT_UCR_LEPCHA (1L << 17) /* U+1C00-U+1C4F */
/* Bit 114 Ol Chiki */
#define TT_UCR_OL_CHIKI (1L << 18) /* U+1C50-U+1C7F */
/* Bit 115 Saurashtra */
#define TT_UCR_SAURASHTRA (1L << 19) /* U+A880-U+A8DF */
/* Bit 116 Kayah Li */
#define TT_UCR_KAYAH_LI (1L << 20) /* U+A900-U+A92F */
/* Bit 117 Rejang */
#define TT_UCR_REJANG (1L << 21) /* U+A930-U+A95F */
/* Bit 118 Cham */
#define TT_UCR_CHAM (1L << 22) /* U+AA00-U+AA5F */
/* Bit 119 Ancient Symbols */
#define TT_UCR_ANCIENT_SYMBOLS (1L << 23) /*U+10190-U+101CF*/
/* Bit 120 Phaistos Disc */
#define TT_UCR_PHAISTOS_DISC (1L << 24) /*U+101D0-U+101FF*/
/* Bit 121 Carian */
/* Lycian */
/* Lydian */
#define TT_UCR_OLD_ANATOLIAN (1L << 25) /*U+102A0-U+102DF*/
/*U+10280-U+1029F*/
/*U+10920-U+1093F*/
/* Bit 122 Domino Tiles */
/* Mahjong Tiles */
#define TT_UCR_GAME_TILES (1L << 26) /*U+1F030-U+1F09F*/
/*U+1F000-U+1F02F*/
/* Bit 123-127 Reserved for process-internal usage */
/* */
/* for backward compatibility with older FreeType versions */
#define TT_UCR_ARABIC_PRESENTATION_A \
TT_UCR_ARABIC_PRESENTATION_FORMS_A
#define TT_UCR_ARABIC_PRESENTATION_B \
TT_UCR_ARABIC_PRESENTATION_FORMS_B
#define TT_UCR_COMBINING_DIACRITICS \
TT_UCR_COMBINING_DIACRITICAL_MARKS
#define TT_UCR_COMBINING_DIACRITICS_SYMB \
TT_UCR_COMBINING_DIACRITICAL_MARKS_SYMB
FT_END_HEADER
#endif /* TTNAMEID_H_ */
/* END */
/****************************************************************************
*
* tttables.h
*
* Basic SFNT/TrueType tables definitions and interface
* (specification only).
*
* Copyright (C) 1996-2024 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* 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 TTTABLES_H_
#define TTTABLES_H_
#include <freetype/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
/**************************************************************************
*
* @section:
* truetype_tables
*
* @title:
* TrueType Tables
*
* @abstract:
* TrueType-specific table types and functions.
*
* @description:
* This section contains definitions of some basic tables specific to
* TrueType and OpenType as well as some routines used to access and
* process them.
*
* @order:
* TT_Header
* TT_HoriHeader
* TT_VertHeader
* TT_OS2
* TT_Postscript
* TT_PCLT
* TT_MaxProfile
*
* FT_Sfnt_Tag
* FT_Get_Sfnt_Table
* FT_Load_Sfnt_Table
* FT_Sfnt_Table_Info
*
* FT_Get_CMap_Language_ID
* FT_Get_CMap_Format
*
* FT_PARAM_TAG_UNPATENTED_HINTING
*
*/
/**************************************************************************
*
* @struct:
* TT_Header
*
* @description:
* A structure to model a TrueType font header table. All fields follow
* the OpenType specification. The 64-bit timestamps are stored in
* two-element arrays `Created` and `Modified`, first the upper then
* the lower 32~bits.
*/
typedef struct TT_Header_
{
FT_Fixed Table_Version;
FT_Fixed Font_Revision;
FT_Long CheckSum_Adjust;
FT_Long Magic_Number;
FT_UShort Flags;
FT_UShort Units_Per_EM;
FT_ULong Created [2];
FT_ULong Modified[2];
FT_Short xMin;
FT_Short yMin;
FT_Short xMax;
FT_Short yMax;
FT_UShort Mac_Style;
FT_UShort Lowest_Rec_PPEM;
FT_Short Font_Direction;
FT_Short Index_To_Loc_Format;
FT_Short Glyph_Data_Format;
} TT_Header;
/**************************************************************************
*
* @struct:
* TT_HoriHeader
*
* @description:
* A structure to model a TrueType horizontal header, the 'hhea' table,
* as well as the corresponding horizontal metrics table, 'hmtx'.
*
* @fields:
* Version ::
* The table version.
*
* Ascender ::
* The font's ascender, i.e., the distance from the baseline to the
* top-most of all glyph points found in the font.
*
* This value is invalid in many fonts, as it is usually set by the
* font designer, and often reflects only a portion of the glyphs found
* in the font (maybe ASCII).
*
* You should use the `sTypoAscender` field of the 'OS/2' table instead
* if you want the correct one.
*
* Descender ::
* The font's descender, i.e., the distance from the baseline to the
* bottom-most of all glyph points found in the font. It is negative.
*
* This value is invalid in many fonts, as it is usually set by the
* font designer, and often reflects only a portion of the glyphs found
* in the font (maybe ASCII).
*
* You should use the `sTypoDescender` field of the 'OS/2' table
* instead if you want the correct one.
*
* Line_Gap ::
* The font's line gap, i.e., the distance to add to the ascender and
* descender to get the BTB, i.e., the baseline-to-baseline distance
* for the font.
*
* advance_Width_Max ::
* This field is the maximum of all advance widths found in the font.
* It can be used to compute the maximum width of an arbitrary string
* of text.
*
* min_Left_Side_Bearing ::
* The minimum left side bearing of all glyphs within the font.
*
* min_Right_Side_Bearing ::
* The minimum right side bearing of all glyphs within the font.
*
* xMax_Extent ::
* The maximum horizontal extent (i.e., the 'width' of a glyph's
* bounding box) for all glyphs in the font.
*
* caret_Slope_Rise ::
* The rise coefficient of the cursor's slope of the cursor
* (slope=rise/run).
*
* caret_Slope_Run ::
* The run coefficient of the cursor's slope.
*
* caret_Offset ::
* The cursor's offset for slanted fonts.
*
* Reserved ::
* 8~reserved bytes.
*
* metric_Data_Format ::
* Always~0.
*
* number_Of_HMetrics ::
* Number of HMetrics entries in the 'hmtx' table -- this value can be
* smaller than the total number of glyphs in the font.
*
* long_metrics ::
* A pointer into the 'hmtx' table.
*
* short_metrics ::
* A pointer into the 'hmtx' table.
*
* @note:
* For an OpenType variation font, the values of the following fields can
* change after a call to @FT_Set_Var_Design_Coordinates (and friends) if
* the font contains an 'MVAR' table: `caret_Slope_Rise`,
* `caret_Slope_Run`, and `caret_Offset`.
*/
typedef struct TT_HoriHeader_
{
FT_Fixed Version;
FT_Short Ascender;
FT_Short Descender;
FT_Short Line_Gap;
FT_UShort advance_Width_Max; /* advance width maximum */
FT_Short min_Left_Side_Bearing; /* minimum left-sb */
FT_Short min_Right_Side_Bearing; /* minimum right-sb */
FT_Short xMax_Extent; /* xmax extents */
FT_Short caret_Slope_Rise;
FT_Short caret_Slope_Run;
FT_Short caret_Offset;
FT_Short Reserved[4];
FT_Short metric_Data_Format;
FT_UShort number_Of_HMetrics;
/* The following fields are not defined by the OpenType specification */
/* but they are used to connect the metrics header to the relevant */
/* 'hmtx' table. */
void* long_metrics;
void* short_metrics;
} TT_HoriHeader;
/**************************************************************************
*
* @struct:
* TT_VertHeader
*
* @description:
* A structure used to model a TrueType vertical header, the 'vhea'
* table, as well as the corresponding vertical metrics table, 'vmtx'.
*
* @fields:
* Version ::
* The table version.
*
* Ascender ::
* The font's ascender, i.e., the distance from the baseline to the
* top-most of all glyph points found in the font.
*
* This value is invalid in many fonts, as it is usually set by the
* font designer, and often reflects only a portion of the glyphs found
* in the font (maybe ASCII).
*
* You should use the `sTypoAscender` field of the 'OS/2' table instead
* if you want the correct one.
*
* Descender ::
* The font's descender, i.e., the distance from the baseline to the
* bottom-most of all glyph points found in the font. It is negative.
*
* This value is invalid in many fonts, as it is usually set by the
* font designer, and often reflects only a portion of the glyphs found
* in the font (maybe ASCII).
*
* You should use the `sTypoDescender` field of the 'OS/2' table
* instead if you want the correct one.
*
* Line_Gap ::
* The font's line gap, i.e., the distance to add to the ascender and
* descender to get the BTB, i.e., the baseline-to-baseline distance
* for the font.
*
* advance_Height_Max ::
* This field is the maximum of all advance heights found in the font.
* It can be used to compute the maximum height of an arbitrary string
* of text.
*
* min_Top_Side_Bearing ::
* The minimum top side bearing of all glyphs within the font.
*
* min_Bottom_Side_Bearing ::
* The minimum bottom side bearing of all glyphs within the font.
*
* yMax_Extent ::
* The maximum vertical extent (i.e., the 'height' of a glyph's
* bounding box) for all glyphs in the font.
*
* caret_Slope_Rise ::
* The rise coefficient of the cursor's slope of the cursor
* (slope=rise/run).
*
* caret_Slope_Run ::
* The run coefficient of the cursor's slope.
*
* caret_Offset ::
* The cursor's offset for slanted fonts.
*
* Reserved ::
* 8~reserved bytes.
*
* metric_Data_Format ::
* Always~0.
*
* number_Of_VMetrics ::
* Number of VMetrics entries in the 'vmtx' table -- this value can be
* smaller than the total number of glyphs in the font.
*
* long_metrics ::
* A pointer into the 'vmtx' table.
*
* short_metrics ::
* A pointer into the 'vmtx' table.
*
* @note:
* For an OpenType variation font, the values of the following fields can
* change after a call to @FT_Set_Var_Design_Coordinates (and friends) if
* the font contains an 'MVAR' table: `Ascender`, `Descender`,
* `Line_Gap`, `caret_Slope_Rise`, `caret_Slope_Run`, and `caret_Offset`.
*/
typedef struct TT_VertHeader_
{
FT_Fixed Version;
FT_Short Ascender;
FT_Short Descender;
FT_Short Line_Gap;
FT_UShort advance_Height_Max; /* advance height maximum */
FT_Short min_Top_Side_Bearing; /* minimum top-sb */
FT_Short min_Bottom_Side_Bearing; /* minimum bottom-sb */
FT_Short yMax_Extent; /* ymax extents */
FT_Short caret_Slope_Rise;
FT_Short caret_Slope_Run;
FT_Short caret_Offset;
FT_Short Reserved[4];
FT_Short metric_Data_Format;
FT_UShort number_Of_VMetrics;
/* The following fields are not defined by the OpenType specification */
/* but they are used to connect the metrics header to the relevant */
/* 'vmtx' table. */
void* long_metrics;
void* short_metrics;
} TT_VertHeader;
/**************************************************************************
*
* @struct:
* TT_OS2
*
* @description:
* A structure to model a TrueType 'OS/2' table. All fields comply to
* the OpenType specification.
*
* Note that we now support old Mac fonts that do not include an 'OS/2'
* table. In this case, the `version` field is always set to 0xFFFF.
*
* @note:
* For an OpenType variation font, the values of the following fields can
* change after a call to @FT_Set_Var_Design_Coordinates (and friends) if
* the font contains an 'MVAR' table: `sCapHeight`, `sTypoAscender`,
* `sTypoDescender`, `sTypoLineGap`, `sxHeight`, `usWinAscent`,
* `usWinDescent`, `yStrikeoutPosition`, `yStrikeoutSize`,
* `ySubscriptXOffset`, `ySubScriptXSize`, `ySubscriptYOffset`,
* `ySubscriptYSize`, `ySuperscriptXOffset`, `ySuperscriptXSize`,
* `ySuperscriptYOffset`, and `ySuperscriptYSize`.
*
* Possible values for bits in the `ulUnicodeRangeX` fields are given by
* the @TT_UCR_XXX macros.
*/
typedef struct TT_OS2_
{
FT_UShort version; /* 0x0001 - more or 0xFFFF */
FT_Short xAvgCharWidth;
FT_UShort usWeightClass;
FT_UShort usWidthClass;
FT_UShort fsType;
FT_Short ySubscriptXSize;
FT_Short ySubscriptYSize;
FT_Short ySubscriptXOffset;
FT_Short ySubscriptYOffset;
FT_Short ySuperscriptXSize;
FT_Short ySuperscriptYSize;
FT_Short ySuperscriptXOffset;
FT_Short ySuperscriptYOffset;
FT_Short yStrikeoutSize;
FT_Short yStrikeoutPosition;
FT_Short sFamilyClass;
FT_Byte panose[10];
FT_ULong ulUnicodeRange1; /* Bits 0-31 */
FT_ULong ulUnicodeRange2; /* Bits 32-63 */
FT_ULong ulUnicodeRange3; /* Bits 64-95 */
FT_ULong ulUnicodeRange4; /* Bits 96-127 */
FT_Char achVendID[4];
FT_UShort fsSelection;
FT_UShort usFirstCharIndex;
FT_UShort usLastCharIndex;
FT_Short sTypoAscender;
FT_Short sTypoDescender;
FT_Short sTypoLineGap;
FT_UShort usWinAscent;
FT_UShort usWinDescent;
/* only version 1 and higher: */
FT_ULong ulCodePageRange1; /* Bits 0-31 */
FT_ULong ulCodePageRange2; /* Bits 32-63 */
/* only version 2 and higher: */
FT_Short sxHeight;
FT_Short sCapHeight;
FT_UShort usDefaultChar;
FT_UShort usBreakChar;
FT_UShort usMaxContext;
/* only version 5 and higher: */
FT_UShort usLowerOpticalPointSize; /* in twips (1/20 points) */
FT_UShort usUpperOpticalPointSize; /* in twips (1/20 points) */
} TT_OS2;
/**************************************************************************
*
* @struct:
* TT_Postscript
*
* @description:
* A structure to model a TrueType 'post' table. All fields comply to
* the OpenType specification. This structure does not reference a
* font's PostScript glyph names; use @FT_Get_Glyph_Name to retrieve
* them.
*
* @note:
* For an OpenType variation font, the values of the following fields can
* change after a call to @FT_Set_Var_Design_Coordinates (and friends) if
* the font contains an 'MVAR' table: `underlinePosition` and
* `underlineThickness`.
*/
typedef struct TT_Postscript_
{
FT_Fixed FormatType;
FT_Fixed italicAngle;
FT_Short underlinePosition;
FT_Short underlineThickness;
FT_ULong isFixedPitch;
FT_ULong minMemType42;
FT_ULong maxMemType42;
FT_ULong minMemType1;
FT_ULong maxMemType1;
/* Glyph names follow in the 'post' table, but we don't */
/* load them by default. */
} TT_Postscript;
/**************************************************************************
*
* @struct:
* TT_PCLT
*
* @description:
* A structure to model a TrueType 'PCLT' table. All fields comply to
* the OpenType specification.
*/
typedef struct TT_PCLT_
{
FT_Fixed Version;
FT_ULong FontNumber;
FT_UShort Pitch;
FT_UShort xHeight;
FT_UShort Style;
FT_UShort TypeFamily;
FT_UShort CapHeight;
FT_UShort SymbolSet;
FT_Char TypeFace[16];
FT_Char CharacterComplement[8];
FT_Char FileName[6];
FT_Char StrokeWeight;
FT_Char WidthType;
FT_Byte SerifStyle;
FT_Byte Reserved;
} TT_PCLT;
/**************************************************************************
*
* @struct:
* TT_MaxProfile
*
* @description:
* The maximum profile ('maxp') table contains many max values, which can
* be used to pre-allocate arrays for speeding up glyph loading and
* hinting.
*
* @fields:
* version ::
* The version number.
*
* numGlyphs ::
* The number of glyphs in this TrueType font.
*
* maxPoints ::
* The maximum number of points in a non-composite TrueType glyph. See
* also `maxCompositePoints`.
*
* maxContours ::
* The maximum number of contours in a non-composite TrueType glyph.
* See also `maxCompositeContours`.
*
* maxCompositePoints ::
* The maximum number of points in a composite TrueType glyph. See
* also `maxPoints`.
*
* maxCompositeContours ::
* The maximum number of contours in a composite TrueType glyph. See
* also `maxContours`.
*
* maxZones ::
* The maximum number of zones used for glyph hinting.
*
* maxTwilightPoints ::
* The maximum number of points in the twilight zone used for glyph
* hinting.
*
* maxStorage ::
* The maximum number of elements in the storage area used for glyph
* hinting.
*
* maxFunctionDefs ::
* The maximum number of function definitions in the TrueType bytecode
* for this font.
*
* maxInstructionDefs ::
* The maximum number of instruction definitions in the TrueType
* bytecode for this font.
*
* maxStackElements ::
* The maximum number of stack elements used during bytecode
* interpretation.
*
* maxSizeOfInstructions ::
* The maximum number of TrueType opcodes used for glyph hinting.
*
* maxComponentElements ::
* The maximum number of simple (i.e., non-composite) glyphs in a
* composite glyph.
*
* maxComponentDepth ::
* The maximum nesting depth of composite glyphs.
*
* @note:
* This structure is only used during font loading.
*/
typedef struct TT_MaxProfile_
{
FT_Fixed version;
FT_UShort numGlyphs;
FT_UShort maxPoints;
FT_UShort maxContours;
FT_UShort maxCompositePoints;
FT_UShort maxCompositeContours;
FT_UShort maxZones;
FT_UShort maxTwilightPoints;
FT_UShort maxStorage;
FT_UShort maxFunctionDefs;
FT_UShort maxInstructionDefs;
FT_UShort maxStackElements;
FT_UShort maxSizeOfInstructions;
FT_UShort maxComponentElements;
FT_UShort maxComponentDepth;
} TT_MaxProfile;
/**************************************************************************
*
* @enum:
* FT_Sfnt_Tag
*
* @description:
* An enumeration to specify indices of SFNT tables loaded and parsed by
* FreeType during initialization of an SFNT font. Used in the
* @FT_Get_Sfnt_Table API function.
*
* @values:
* FT_SFNT_HEAD ::
* To access the font's @TT_Header structure.
*
* FT_SFNT_MAXP ::
* To access the font's @TT_MaxProfile structure.
*
* FT_SFNT_OS2 ::
* To access the font's @TT_OS2 structure.
*
* FT_SFNT_HHEA ::
* To access the font's @TT_HoriHeader structure.
*
* FT_SFNT_VHEA ::
* To access the font's @TT_VertHeader structure.
*
* FT_SFNT_POST ::
* To access the font's @TT_Postscript structure.
*
* FT_SFNT_PCLT ::
* To access the font's @TT_PCLT structure.
*/
typedef enum FT_Sfnt_Tag_
{
FT_SFNT_HEAD,
FT_SFNT_MAXP,
FT_SFNT_OS2,
FT_SFNT_HHEA,
FT_SFNT_VHEA,
FT_SFNT_POST,
FT_SFNT_PCLT,
FT_SFNT_MAX
} FT_Sfnt_Tag;
/* these constants are deprecated; use the corresponding `FT_Sfnt_Tag` */
/* values instead */
#define ft_sfnt_head FT_SFNT_HEAD
#define ft_sfnt_maxp FT_SFNT_MAXP
#define ft_sfnt_os2 FT_SFNT_OS2
#define ft_sfnt_hhea FT_SFNT_HHEA
#define ft_sfnt_vhea FT_SFNT_VHEA
#define ft_sfnt_post FT_SFNT_POST
#define ft_sfnt_pclt FT_SFNT_PCLT
/**************************************************************************
*
* @function:
* FT_Get_Sfnt_Table
*
* @description:
* Return a pointer to a given SFNT table stored within a face.
*
* @input:
* face ::
* A handle to the source.
*
* tag ::
* The index of the SFNT table.
*
* @return:
* A type-less pointer to the table. This will be `NULL` in case of
* error, or if the corresponding table was not found **OR** loaded from
* the file.
*
* Use a typecast according to `tag` to access the structure elements.
*
* @note:
* The table is owned by the face object and disappears with it.
*
* This function is only useful to access SFNT tables that are loaded by
* the sfnt, truetype, and opentype drivers. See @FT_Sfnt_Tag for a
* list.
*
* @example:
* Here is an example demonstrating access to the 'vhea' table.
*
* ```
* TT_VertHeader* vert_header;
*
*
* vert_header =
* (TT_VertHeader*)FT_Get_Sfnt_Table( face, FT_SFNT_VHEA );
* ```
*/
FT_EXPORT( void* )
FT_Get_Sfnt_Table( FT_Face face,
FT_Sfnt_Tag tag );
/**************************************************************************
*
* @function:
* FT_Load_Sfnt_Table
*
* @description:
* Load any SFNT font table into client memory.
*
* @input:
* face ::
* A handle to the source face.
*
* tag ::
* The four-byte tag of the table to load. Use value~0 if you want to
* access the whole font file. Otherwise, you can use one of the
* definitions found in the @FT_TRUETYPE_TAGS_H file, or forge a new
* one with @FT_MAKE_TAG.
*
* offset ::
* The starting offset in the table (or file if tag~==~0).
*
* @output:
* buffer ::
* The target buffer address. The client must ensure that the memory
* array is big enough to hold the data.
*
* @inout:
* length ::
* If the `length` parameter is `NULL`, try to load the whole table.
* Return an error code if it fails.
*
* Else, if `*length` is~0, exit immediately while returning the
* table's (or file) full size in it.
*
* Else the number of bytes to read from the table or file, from the
* starting offset.
*
* @return:
* FreeType error code. 0~means success.
*
* @note:
* If you need to determine the table's length you should first call this
* function with `*length` set to~0, as in the following example:
*
* ```
* FT_ULong length = 0;
*
*
* error = FT_Load_Sfnt_Table( face, tag, 0, NULL, &length );
* if ( error ) { ... table does not exist ... }
*
* buffer = malloc( length );
* if ( buffer == NULL ) { ... not enough memory ... }
*
* error = FT_Load_Sfnt_Table( face, tag, 0, buffer, &length );
* if ( error ) { ... could not load table ... }
* ```
*
* Note that structures like @TT_Header or @TT_OS2 can't be used with
* this function; they are limited to @FT_Get_Sfnt_Table. Reason is that
* those structures depend on the processor architecture, with varying
* size (e.g. 32bit vs. 64bit) or order (big endian vs. little endian).
*
*/
FT_EXPORT( FT_Error )
FT_Load_Sfnt_Table( FT_Face face,
FT_ULong tag,
FT_Long offset,
FT_Byte* buffer,
FT_ULong* length );
/**************************************************************************
*
* @function:
* FT_Sfnt_Table_Info
*
* @description:
* Return information on an SFNT table.
*
* @input:
* face ::
* A handle to the source face.
*
* table_index ::
* The index of an SFNT table. The function returns
* FT_Err_Table_Missing for an invalid value.
*
* @inout:
* tag ::
* The name tag of the SFNT table. If the value is `NULL`,
* `table_index` is ignored, and `length` returns the number of SFNT
* tables in the font.
*
* @output:
* length ::
* The length of the SFNT table (or the number of SFNT tables,
* depending on `tag`).
*
* @return:
* FreeType error code. 0~means success.
*
* @note:
* While parsing fonts, FreeType handles SFNT tables with length zero as
* missing.
*
*/
FT_EXPORT( FT_Error )
FT_Sfnt_Table_Info( FT_Face face,
FT_UInt table_index,
FT_ULong *tag,
FT_ULong *length );
/**************************************************************************
*
* @function:
* FT_Get_CMap_Language_ID
*
* @description:
* Return cmap language ID as specified in the OpenType standard.
* Definitions of language ID values are in file @FT_TRUETYPE_IDS_H.
*
* @input:
* charmap ::
* The target charmap.
*
* @return:
* The language ID of `charmap`. If `charmap` doesn't belong to an SFNT
* face, just return~0 as the default value.
*
* For a format~14 cmap (to access Unicode IVS), the return value is
* 0xFFFFFFFF.
*/
FT_EXPORT( FT_ULong )
FT_Get_CMap_Language_ID( FT_CharMap charmap );
/**************************************************************************
*
* @function:
* FT_Get_CMap_Format
*
* @description:
* Return the format of an SFNT 'cmap' table.
*
* @input:
* charmap ::
* The target charmap.
*
* @return:
* The format of `charmap`. If `charmap` doesn't belong to an SFNT face
* (including the synthetic Unicode charmap sometimes created by
* FreeType), return -1.
*/
FT_EXPORT( FT_Long )
FT_Get_CMap_Format( FT_CharMap charmap );
/* */
FT_END_HEADER
#endif /* TTTABLES_H_ */
/* END */
/****************************************************************************
*
* tttags.h
*
* Tags for TrueType and OpenType tables (specification only).
*
* Copyright (C) 1996-2024 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* 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 TTAGS_H_
#define TTAGS_H_
#include <freetype/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
#define TTAG_avar FT_MAKE_TAG( 'a', 'v', 'a', 'r' )
#define TTAG_BASE FT_MAKE_TAG( 'B', 'A', 'S', 'E' )
#define TTAG_bdat FT_MAKE_TAG( 'b', 'd', 'a', 't' )
#define TTAG_BDF FT_MAKE_TAG( 'B', 'D', 'F', ' ' )
#define TTAG_bhed FT_MAKE_TAG( 'b', 'h', 'e', 'd' )
#define TTAG_bloc FT_MAKE_TAG( 'b', 'l', 'o', 'c' )
#define TTAG_bsln FT_MAKE_TAG( 'b', 's', 'l', 'n' )
#define TTAG_CBDT FT_MAKE_TAG( 'C', 'B', 'D', 'T' )
#define TTAG_CBLC FT_MAKE_TAG( 'C', 'B', 'L', 'C' )
#define TTAG_CFF FT_MAKE_TAG( 'C', 'F', 'F', ' ' )
#define TTAG_CFF2 FT_MAKE_TAG( 'C', 'F', 'F', '2' )
#define TTAG_CID FT_MAKE_TAG( 'C', 'I', 'D', ' ' )
#define TTAG_cmap FT_MAKE_TAG( 'c', 'm', 'a', 'p' )
#define TTAG_COLR FT_MAKE_TAG( 'C', 'O', 'L', 'R' )
#define TTAG_CPAL FT_MAKE_TAG( 'C', 'P', 'A', 'L' )
#define TTAG_cvar FT_MAKE_TAG( 'c', 'v', 'a', 'r' )
#define TTAG_cvt FT_MAKE_TAG( 'c', 'v', 't', ' ' )
#define TTAG_DSIG FT_MAKE_TAG( 'D', 'S', 'I', 'G' )
#define TTAG_EBDT FT_MAKE_TAG( 'E', 'B', 'D', 'T' )
#define TTAG_EBLC FT_MAKE_TAG( 'E', 'B', 'L', 'C' )
#define TTAG_EBSC FT_MAKE_TAG( 'E', 'B', 'S', 'C' )
#define TTAG_feat FT_MAKE_TAG( 'f', 'e', 'a', 't' )
#define TTAG_FOND FT_MAKE_TAG( 'F', 'O', 'N', 'D' )
#define TTAG_fpgm FT_MAKE_TAG( 'f', 'p', 'g', 'm' )
#define TTAG_fvar FT_MAKE_TAG( 'f', 'v', 'a', 'r' )
#define TTAG_gasp FT_MAKE_TAG( 'g', 'a', 's', 'p' )
#define TTAG_GDEF FT_MAKE_TAG( 'G', 'D', 'E', 'F' )
#define TTAG_glyf FT_MAKE_TAG( 'g', 'l', 'y', 'f' )
#define TTAG_GPOS FT_MAKE_TAG( 'G', 'P', 'O', 'S' )
#define TTAG_GSUB FT_MAKE_TAG( 'G', 'S', 'U', 'B' )
#define TTAG_gvar FT_MAKE_TAG( 'g', 'v', 'a', 'r' )
#define TTAG_HVAR FT_MAKE_TAG( 'H', 'V', 'A', 'R' )
#define TTAG_hdmx FT_MAKE_TAG( 'h', 'd', 'm', 'x' )
#define TTAG_head FT_MAKE_TAG( 'h', 'e', 'a', 'd' )
#define TTAG_hhea FT_MAKE_TAG( 'h', 'h', 'e', 'a' )
#define TTAG_hmtx FT_MAKE_TAG( 'h', 'm', 't', 'x' )
#define TTAG_JSTF FT_MAKE_TAG( 'J', 'S', 'T', 'F' )
#define TTAG_just FT_MAKE_TAG( 'j', 'u', 's', 't' )
#define TTAG_kern FT_MAKE_TAG( 'k', 'e', 'r', 'n' )
#define TTAG_lcar FT_MAKE_TAG( 'l', 'c', 'a', 'r' )
#define TTAG_loca FT_MAKE_TAG( 'l', 'o', 'c', 'a' )
#define TTAG_LTSH FT_MAKE_TAG( 'L', 'T', 'S', 'H' )
#define TTAG_LWFN FT_MAKE_TAG( 'L', 'W', 'F', 'N' )
#define TTAG_MATH FT_MAKE_TAG( 'M', 'A', 'T', 'H' )
#define TTAG_maxp FT_MAKE_TAG( 'm', 'a', 'x', 'p' )
#define TTAG_META FT_MAKE_TAG( 'M', 'E', 'T', 'A' )
#define TTAG_MMFX FT_MAKE_TAG( 'M', 'M', 'F', 'X' )
#define TTAG_MMSD FT_MAKE_TAG( 'M', 'M', 'S', 'D' )
#define TTAG_mort FT_MAKE_TAG( 'm', 'o', 'r', 't' )
#define TTAG_morx FT_MAKE_TAG( 'm', 'o', 'r', 'x' )
#define TTAG_MVAR FT_MAKE_TAG( 'M', 'V', 'A', 'R' )
#define TTAG_name FT_MAKE_TAG( 'n', 'a', 'm', 'e' )
#define TTAG_opbd FT_MAKE_TAG( 'o', 'p', 'b', 'd' )
#define TTAG_OS2 FT_MAKE_TAG( 'O', 'S', '/', '2' )
#define TTAG_OTTO FT_MAKE_TAG( 'O', 'T', 'T', 'O' )
#define TTAG_PCLT FT_MAKE_TAG( 'P', 'C', 'L', 'T' )
#define TTAG_POST FT_MAKE_TAG( 'P', 'O', 'S', 'T' )
#define TTAG_post FT_MAKE_TAG( 'p', 'o', 's', 't' )
#define TTAG_prep FT_MAKE_TAG( 'p', 'r', 'e', 'p' )
#define TTAG_prop FT_MAKE_TAG( 'p', 'r', 'o', 'p' )
#define TTAG_sbix FT_MAKE_TAG( 's', 'b', 'i', 'x' )
#define TTAG_sfnt FT_MAKE_TAG( 's', 'f', 'n', 't' )
#define TTAG_SING FT_MAKE_TAG( 'S', 'I', 'N', 'G' )
#define TTAG_SVG FT_MAKE_TAG( 'S', 'V', 'G', ' ' )
#define TTAG_trak FT_MAKE_TAG( 't', 'r', 'a', 'k' )
#define TTAG_true FT_MAKE_TAG( 't', 'r', 'u', 'e' )
#define TTAG_ttc FT_MAKE_TAG( 't', 't', 'c', ' ' )
#define TTAG_ttcf FT_MAKE_TAG( 't', 't', 'c', 'f' )
#define TTAG_TYP1 FT_MAKE_TAG( 'T', 'Y', 'P', '1' )
#define TTAG_typ1 FT_MAKE_TAG( 't', 'y', 'p', '1' )
#define TTAG_VDMX FT_MAKE_TAG( 'V', 'D', 'M', 'X' )
#define TTAG_vhea FT_MAKE_TAG( 'v', 'h', 'e', 'a' )
#define TTAG_vmtx FT_MAKE_TAG( 'v', 'm', 't', 'x' )
#define TTAG_VVAR FT_MAKE_TAG( 'V', 'V', 'A', 'R' )
#define TTAG_wOFF FT_MAKE_TAG( 'w', 'O', 'F', 'F' )
#define TTAG_wOF2 FT_MAKE_TAG( 'w', 'O', 'F', '2' )
/* used by "Keyboard.dfont" on legacy Mac OS X */
#define TTAG_0xA5kbd FT_MAKE_TAG( 0xA5, 'k', 'b', 'd' )
/* used by "LastResort.dfont" on legacy Mac OS X */
#define TTAG_0xA5lst FT_MAKE_TAG( 0xA5, 'l', 's', 't' )
FT_END_HEADER
#endif /* TTAGS_H_ */
/* END */
/****************************************************************************
*
* ft2build.h
*
* FreeType 2 build and setup macros.
*
* Copyright (C) 1996-2024 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* 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.
*
*/
/**************************************************************************
*
* This is the 'entry point' for FreeType header file inclusions, to be
* loaded before all other header files.
*
* A typical example is
*
* ```
* #include <ft2build.h>
* #include <freetype/freetype.h>
* ```
*
*/
#ifndef FT2BUILD_H_
#define FT2BUILD_H_
#include <freetype/config/ftheader.h>
#endif /* FT2BUILD_H_ */
/* END */
// Copyright 2006 Nemanja Trifunovic
/*
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#ifndef UTF8_FOR_CPP_2675DCD0_9480_4c0c_B92A_CC14C027B731
#define UTF8_FOR_CPP_2675DCD0_9480_4c0c_B92A_CC14C027B731
#include "utf8/checked.h"
#include "utf8/unchecked.h"
#endif // header guard
// Copyright 2006-2016 Nemanja Trifunovic
/*
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#ifndef UTF8_FOR_CPP_CHECKED_H_2675DCD0_9480_4c0c_B92A_CC14C027B731
#define UTF8_FOR_CPP_CHECKED_H_2675DCD0_9480_4c0c_B92A_CC14C027B731
#include "core.h"
#include <stdexcept>
namespace utf8
{
// Base for the exceptions that may be thrown from the library
class exception : public ::std::exception {
};
// Exceptions that may be thrown from the library functions.
class invalid_code_point : public exception {
uint32_t cp;
public:
invalid_code_point(uint32_t codepoint) : cp(codepoint) {}
virtual const char* what() const UTF_CPP_NOEXCEPT UTF_CPP_OVERRIDE { return "Invalid code point"; }
uint32_t code_point() const {return cp;}
};
class invalid_utf8 : public exception {
uint8_t u8;
public:
invalid_utf8 (uint8_t u) : u8(u) {}
virtual const char* what() const UTF_CPP_NOEXCEPT UTF_CPP_OVERRIDE { return "Invalid UTF-8"; }
uint8_t utf8_octet() const {return u8;}
};
class invalid_utf16 : public exception {
uint16_t u16;
public:
invalid_utf16 (uint16_t u) : u16(u) {}
virtual const char* what() const UTF_CPP_NOEXCEPT UTF_CPP_OVERRIDE { return "Invalid UTF-16"; }
uint16_t utf16_word() const {return u16;}
};
class not_enough_room : public exception {
public:
virtual const char* what() const UTF_CPP_NOEXCEPT UTF_CPP_OVERRIDE { return "Not enough space"; }
};
/// The library API - functions intended to be called by the users
template <typename octet_iterator>
octet_iterator append(uint32_t cp, octet_iterator result)
{
if (!utf8::internal::is_code_point_valid(cp))
throw invalid_code_point(cp);
if (cp < 0x80) // one octet
*(result++) = static_cast<uint8_t>(cp);
else if (cp < 0x800) { // two octets
*(result++) = static_cast<uint8_t>((cp >> 6) | 0xc0);
*(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80);
}
else if (cp < 0x10000) { // three octets
*(result++) = static_cast<uint8_t>((cp >> 12) | 0xe0);
*(result++) = static_cast<uint8_t>(((cp >> 6) & 0x3f) | 0x80);
*(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80);
}
else { // four octets
*(result++) = static_cast<uint8_t>((cp >> 18) | 0xf0);
*(result++) = static_cast<uint8_t>(((cp >> 12) & 0x3f) | 0x80);
*(result++) = static_cast<uint8_t>(((cp >> 6) & 0x3f) | 0x80);
*(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80);
}
return result;
}
template <typename octet_iterator, typename output_iterator>
output_iterator replace_invalid(octet_iterator start, octet_iterator end, output_iterator out, uint32_t replacement)
{
while (start != end) {
octet_iterator sequence_start = start;
internal::utf_error err_code = utf8::internal::validate_next(start, end);
switch (err_code) {
case internal::UTF8_OK :
for (octet_iterator it = sequence_start; it != start; ++it)
*out++ = *it;
break;
case internal::NOT_ENOUGH_ROOM:
out = utf8::append (replacement, out);
start = end;
break;
case internal::INVALID_LEAD:
out = utf8::append (replacement, out);
++start;
break;
case internal::INCOMPLETE_SEQUENCE:
case internal::OVERLONG_SEQUENCE:
case internal::INVALID_CODE_POINT:
out = utf8::append (replacement, out);
++start;
// just one replacement mark for the sequence
while (start != end && utf8::internal::is_trail(*start))
++start;
break;
}
}
return out;
}
template <typename octet_iterator, typename output_iterator>
inline output_iterator replace_invalid(octet_iterator start, octet_iterator end, output_iterator out)
{
static const uint32_t replacement_marker = utf8::internal::mask16(0xfffd);
return utf8::replace_invalid(start, end, out, replacement_marker);
}
template <typename octet_iterator>
uint32_t next(octet_iterator& it, octet_iterator end)
{
uint32_t cp = 0;
internal::utf_error err_code = utf8::internal::validate_next(it, end, cp);
switch (err_code) {
case internal::UTF8_OK :
break;
case internal::NOT_ENOUGH_ROOM :
throw not_enough_room();
case internal::INVALID_LEAD :
case internal::INCOMPLETE_SEQUENCE :
case internal::OVERLONG_SEQUENCE :
throw invalid_utf8(static_cast<uint8_t>(*it));
case internal::INVALID_CODE_POINT :
throw invalid_code_point(cp);
}
return cp;
}
template <typename octet_iterator>
uint32_t peek_next(octet_iterator it, octet_iterator end)
{
return utf8::next(it, end);
}
template <typename octet_iterator>
uint32_t prior(octet_iterator& it, octet_iterator start)
{
// can't do much if it == start
if (it == start)
throw not_enough_room();
octet_iterator end = it;
// Go back until we hit either a lead octet or start
while (utf8::internal::is_trail(*(--it)))
if (it == start)
throw invalid_utf8(*it); // error - no lead byte in the sequence
return utf8::peek_next(it, end);
}
template <typename octet_iterator, typename distance_type>
void advance (octet_iterator& it, distance_type n, octet_iterator end)
{
const distance_type zero(0);
if (n < zero) {
// backward
for (distance_type i = n; i < zero; ++i)
utf8::prior(it, end);
} else {
// forward
for (distance_type i = zero; i < n; ++i)
utf8::next(it, end);
}
}
template <typename octet_iterator>
typename std::iterator_traits<octet_iterator>::difference_type
distance (octet_iterator first, octet_iterator last)
{
typename std::iterator_traits<octet_iterator>::difference_type dist;
for (dist = 0; first < last; ++dist)
utf8::next(first, last);
return dist;
}
template <typename u16bit_iterator, typename octet_iterator>
octet_iterator utf16to8 (u16bit_iterator start, u16bit_iterator end, octet_iterator result)
{
while (start != end) {
uint32_t cp = utf8::internal::mask16(*start++);
// Take care of surrogate pairs first
if (utf8::internal::is_lead_surrogate(cp)) {
if (start != end) {
uint32_t trail_surrogate = utf8::internal::mask16(*start++);
if (utf8::internal::is_trail_surrogate(trail_surrogate))
cp = (cp << 10) + trail_surrogate + internal::SURROGATE_OFFSET;
else
throw invalid_utf16(static_cast<uint16_t>(trail_surrogate));
}
else
throw invalid_utf16(static_cast<uint16_t>(cp));
}
// Lone trail surrogate
else if (utf8::internal::is_trail_surrogate(cp))
throw invalid_utf16(static_cast<uint16_t>(cp));
result = utf8::append(cp, result);
}
return result;
}
template <typename u16bit_iterator, typename octet_iterator>
u16bit_iterator utf8to16 (octet_iterator start, octet_iterator end, u16bit_iterator result)
{
while (start < end) {
uint32_t cp = utf8::next(start, end);
if (cp > 0xffff) { //make a surrogate pair
*result++ = static_cast<uint16_t>((cp >> 10) + internal::LEAD_OFFSET);
*result++ = static_cast<uint16_t>((cp & 0x3ff) + internal::TRAIL_SURROGATE_MIN);
}
else
*result++ = static_cast<uint16_t>(cp);
}
return result;
}
template <typename octet_iterator, typename u32bit_iterator>
octet_iterator utf32to8 (u32bit_iterator start, u32bit_iterator end, octet_iterator result)
{
while (start != end)
result = utf8::append(*(start++), result);
return result;
}
template <typename octet_iterator, typename u32bit_iterator>
u32bit_iterator utf8to32 (octet_iterator start, octet_iterator end, u32bit_iterator result)
{
while (start < end)
(*result++) = utf8::next(start, end);
return result;
}
// The iterator class
template <typename octet_iterator>
class iterator {
octet_iterator it;
octet_iterator range_start;
octet_iterator range_end;
public:
typedef uint32_t value_type;
typedef uint32_t* pointer;
typedef uint32_t& reference;
typedef std::ptrdiff_t difference_type;
typedef std::bidirectional_iterator_tag iterator_category;
iterator () {}
explicit iterator (const octet_iterator& octet_it,
const octet_iterator& rangestart,
const octet_iterator& rangeend) :
it(octet_it), range_start(rangestart), range_end(rangeend)
{
if (it < range_start || it > range_end)
throw std::out_of_range("Invalid utf-8 iterator position");
}
// the default "big three" are OK
octet_iterator base () const { return it; }
uint32_t operator * () const
{
octet_iterator temp = it;
return utf8::next(temp, range_end);
}
bool operator == (const iterator& rhs) const
{
if (range_start != rhs.range_start || range_end != rhs.range_end)
throw std::logic_error("Comparing utf-8 iterators defined with different ranges");
return (it == rhs.it);
}
bool operator != (const iterator& rhs) const
{
return !(operator == (rhs));
}
iterator& operator ++ ()
{
utf8::next(it, range_end);
return *this;
}
iterator operator ++ (int)
{
iterator temp = *this;
utf8::next(it, range_end);
return temp;
}
iterator& operator -- ()
{
utf8::prior(it, range_start);
return *this;
}
iterator operator -- (int)
{
iterator temp = *this;
utf8::prior(it, range_start);
return temp;
}
}; // class iterator
} // namespace utf8
#if UTF_CPP_CPLUSPLUS >= 201703L // C++ 17 or later
#include "cpp17.h"
#elif UTF_CPP_CPLUSPLUS >= 201103L // C++ 11 or later
#include "cpp11.h"
#endif // C++ 11 or later
#endif //header guard
// Copyright 2006 Nemanja Trifunovic
/*
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#ifndef UTF8_FOR_CPP_CORE_H_2675DCD0_9480_4c0c_B92A_CC14C027B731
#define UTF8_FOR_CPP_CORE_H_2675DCD0_9480_4c0c_B92A_CC14C027B731
#include <iterator>
// Determine the C++ standard version.
// If the user defines UTF_CPP_CPLUSPLUS, use that.
// Otherwise, trust the unreliable predefined macro __cplusplus
#if !defined UTF_CPP_CPLUSPLUS
#define UTF_CPP_CPLUSPLUS __cplusplus
#endif
#if UTF_CPP_CPLUSPLUS >= 201103L // C++ 11 or later
#define UTF_CPP_OVERRIDE override
#define UTF_CPP_NOEXCEPT noexcept
#else // C++ 98/03
#define UTF_CPP_OVERRIDE
#define UTF_CPP_NOEXCEPT throw()
#endif // C++ 11 or later
namespace utf8
{
// The typedefs for 8-bit, 16-bit and 32-bit unsigned integers
// You may need to change them to match your system.
// These typedefs have the same names as ones from cstdint, or boost/cstdint
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
// Helper code - not intended to be directly called by the library users. May be changed at any time
namespace internal
{
// Unicode constants
// Leading (high) surrogates: 0xd800 - 0xdbff
// Trailing (low) surrogates: 0xdc00 - 0xdfff
const uint16_t LEAD_SURROGATE_MIN = 0xd800u;
const uint16_t LEAD_SURROGATE_MAX = 0xdbffu;
const uint16_t TRAIL_SURROGATE_MIN = 0xdc00u;
const uint16_t TRAIL_SURROGATE_MAX = 0xdfffu;
const uint16_t LEAD_OFFSET = 0xd7c0u; // LEAD_SURROGATE_MIN - (0x10000 >> 10)
const uint32_t SURROGATE_OFFSET = 0xfca02400u; // 0x10000u - (LEAD_SURROGATE_MIN << 10) - TRAIL_SURROGATE_MIN
// Maximum valid value for a Unicode code point
const uint32_t CODE_POINT_MAX = 0x0010ffffu;
template<typename octet_type>
inline uint8_t mask8(octet_type oc)
{
return static_cast<uint8_t>(0xff & oc);
}
template<typename u16_type>
inline uint16_t mask16(u16_type oc)
{
return static_cast<uint16_t>(0xffff & oc);
}
template<typename octet_type>
inline bool is_trail(octet_type oc)
{
return ((utf8::internal::mask8(oc) >> 6) == 0x2);
}
template <typename u16>
inline bool is_lead_surrogate(u16 cp)
{
return (cp >= LEAD_SURROGATE_MIN && cp <= LEAD_SURROGATE_MAX);
}
template <typename u16>
inline bool is_trail_surrogate(u16 cp)
{
return (cp >= TRAIL_SURROGATE_MIN && cp <= TRAIL_SURROGATE_MAX);
}
template <typename u16>
inline bool is_surrogate(u16 cp)
{
return (cp >= LEAD_SURROGATE_MIN && cp <= TRAIL_SURROGATE_MAX);
}
template <typename u32>
inline bool is_code_point_valid(u32 cp)
{
return (cp <= CODE_POINT_MAX && !utf8::internal::is_surrogate(cp));
}
template <typename octet_iterator>
inline typename std::iterator_traits<octet_iterator>::difference_type
sequence_length(octet_iterator lead_it)
{
uint8_t lead = utf8::internal::mask8(*lead_it);
if (lead < 0x80)
return 1;
else if ((lead >> 5) == 0x6)
return 2;
else if ((lead >> 4) == 0xe)
return 3;
else if ((lead >> 3) == 0x1e)
return 4;
else
return 0;
}
template <typename octet_difference_type>
inline bool is_overlong_sequence(uint32_t cp, octet_difference_type length)
{
if (cp < 0x80) {
if (length != 1)
return true;
}
else if (cp < 0x800) {
if (length != 2)
return true;
}
else if (cp < 0x10000) {
if (length != 3)
return true;
}
return false;
}
enum utf_error {UTF8_OK, NOT_ENOUGH_ROOM, INVALID_LEAD, INCOMPLETE_SEQUENCE, OVERLONG_SEQUENCE, INVALID_CODE_POINT};
/// Helper for get_sequence_x
template <typename octet_iterator>
utf_error increase_safely(octet_iterator& it, octet_iterator end)
{
if (++it == end)
return NOT_ENOUGH_ROOM;
if (!utf8::internal::is_trail(*it))
return INCOMPLETE_SEQUENCE;
return UTF8_OK;
}
#define UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR(IT, END) {utf_error ret = increase_safely(IT, END); if (ret != UTF8_OK) return ret;}
/// get_sequence_x functions decode utf-8 sequences of the length x
template <typename octet_iterator>
utf_error get_sequence_1(octet_iterator& it, octet_iterator end, uint32_t& code_point)
{
if (it == end)
return NOT_ENOUGH_ROOM;
code_point = utf8::internal::mask8(*it);
return UTF8_OK;
}
template <typename octet_iterator>
utf_error get_sequence_2(octet_iterator& it, octet_iterator end, uint32_t& code_point)
{
if (it == end)
return NOT_ENOUGH_ROOM;
code_point = utf8::internal::mask8(*it);
UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR(it, end)
code_point = ((code_point << 6) & 0x7ff) + ((*it) & 0x3f);
return UTF8_OK;
}
template <typename octet_iterator>
utf_error get_sequence_3(octet_iterator& it, octet_iterator end, uint32_t& code_point)
{
if (it == end)
return NOT_ENOUGH_ROOM;
code_point = utf8::internal::mask8(*it);
UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR(it, end)
code_point = ((code_point << 12) & 0xffff) + ((utf8::internal::mask8(*it) << 6) & 0xfff);
UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR(it, end)
code_point += (*it) & 0x3f;
return UTF8_OK;
}
template <typename octet_iterator>
utf_error get_sequence_4(octet_iterator& it, octet_iterator end, uint32_t& code_point)
{
if (it == end)
return NOT_ENOUGH_ROOM;
code_point = utf8::internal::mask8(*it);
UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR(it, end)
code_point = ((code_point << 18) & 0x1fffff) + ((utf8::internal::mask8(*it) << 12) & 0x3ffff);
UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR(it, end)
code_point += (utf8::internal::mask8(*it) << 6) & 0xfff;
UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR(it, end)
code_point += (*it) & 0x3f;
return UTF8_OK;
}
#undef UTF8_CPP_INCREASE_AND_RETURN_ON_ERROR
template <typename octet_iterator>
utf_error validate_next(octet_iterator& it, octet_iterator end, uint32_t& code_point)
{
if (it == end)
return NOT_ENOUGH_ROOM;
// Save the original value of it so we can go back in case of failure
// Of course, it does not make much sense with i.e. stream iterators
octet_iterator original_it = it;
uint32_t cp = 0;
// Determine the sequence length based on the lead octet
typedef typename std::iterator_traits<octet_iterator>::difference_type octet_difference_type;
const octet_difference_type length = utf8::internal::sequence_length(it);
// Get trail octets and calculate the code point
utf_error err = UTF8_OK;
switch (length) {
case 0:
return INVALID_LEAD;
case 1:
err = utf8::internal::get_sequence_1(it, end, cp);
break;
case 2:
err = utf8::internal::get_sequence_2(it, end, cp);
break;
case 3:
err = utf8::internal::get_sequence_3(it, end, cp);
break;
case 4:
err = utf8::internal::get_sequence_4(it, end, cp);
break;
}
if (err == UTF8_OK) {
// Decoding succeeded. Now, security checks...
if (utf8::internal::is_code_point_valid(cp)) {
if (!utf8::internal::is_overlong_sequence(cp, length)){
// Passed! Return here.
code_point = cp;
++it;
return UTF8_OK;
}
else
err = OVERLONG_SEQUENCE;
}
else
err = INVALID_CODE_POINT;
}
// Failure branch - restore the original value of the iterator
it = original_it;
return err;
}
template <typename octet_iterator>
inline utf_error validate_next(octet_iterator& it, octet_iterator end) {
uint32_t ignored;
return utf8::internal::validate_next(it, end, ignored);
}
} // namespace internal
/// The library API - functions intended to be called by the users
// Byte order mark
const uint8_t bom[] = {0xef, 0xbb, 0xbf};
template <typename octet_iterator>
octet_iterator find_invalid(octet_iterator start, octet_iterator end)
{
octet_iterator result = start;
while (result != end) {
utf8::internal::utf_error err_code = utf8::internal::validate_next(result, end);
if (err_code != internal::UTF8_OK)
return result;
}
return result;
}
template <typename octet_iterator>
inline bool is_valid(octet_iterator start, octet_iterator end)
{
return (utf8::find_invalid(start, end) == end);
}
template <typename octet_iterator>
inline bool starts_with_bom (octet_iterator it, octet_iterator end)
{
return (
((it != end) && (utf8::internal::mask8(*it++)) == bom[0]) &&
((it != end) && (utf8::internal::mask8(*it++)) == bom[1]) &&
((it != end) && (utf8::internal::mask8(*it)) == bom[2])
);
}
} // namespace utf8
#endif // header guard
// Copyright 2018 Nemanja Trifunovic
/*
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#ifndef UTF8_FOR_CPP_a184c22c_d012_11e8_a8d5_f2801f1b9fd1
#define UTF8_FOR_CPP_a184c22c_d012_11e8_a8d5_f2801f1b9fd1
#include "checked.h"
#include <string>
namespace utf8
{
inline void append(char32_t cp, std::string& s)
{
append(uint32_t(cp), std::back_inserter(s));
}
inline std::string utf16to8(const std::u16string& s)
{
std::string result;
utf16to8(s.begin(), s.end(), std::back_inserter(result));
return result;
}
inline std::u16string utf8to16(const std::string& s)
{
std::u16string result;
utf8to16(s.begin(), s.end(), std::back_inserter(result));
return result;
}
inline std::string utf32to8(const std::u32string& s)
{
std::string result;
utf32to8(s.begin(), s.end(), std::back_inserter(result));
return result;
}
inline std::u32string utf8to32(const std::string& s)
{
std::u32string result;
utf8to32(s.begin(), s.end(), std::back_inserter(result));
return result;
}
inline std::size_t find_invalid(const std::string& s)
{
std::string::const_iterator invalid = find_invalid(s.begin(), s.end());
return (invalid == s.end()) ? std::string::npos : static_cast<std::size_t>(invalid - s.begin());
}
inline bool is_valid(const std::string& s)
{
return is_valid(s.begin(), s.end());
}
inline std::string replace_invalid(const std::string& s, char32_t replacement)
{
std::string result;
replace_invalid(s.begin(), s.end(), std::back_inserter(result), replacement);
return result;
}
inline std::string replace_invalid(const std::string& s)
{
std::string result;
replace_invalid(s.begin(), s.end(), std::back_inserter(result));
return result;
}
inline bool starts_with_bom(const std::string& s)
{
return starts_with_bom(s.begin(), s.end());
}
} // namespace utf8
#endif // header guard
// Copyright 2018 Nemanja Trifunovic
/*
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#ifndef UTF8_FOR_CPP_7e906c01_03a3_4daf_b420_ea7ea952b3c9
#define UTF8_FOR_CPP_7e906c01_03a3_4daf_b420_ea7ea952b3c9
#include "checked.h"
#include <string>
namespace utf8
{
inline void append(char32_t cp, std::string& s)
{
append(uint32_t(cp), std::back_inserter(s));
}
inline std::string utf16to8(std::u16string_view s)
{
std::string result;
utf16to8(s.begin(), s.end(), std::back_inserter(result));
return result;
}
inline std::u16string utf8to16(std::string_view s)
{
std::u16string result;
utf8to16(s.begin(), s.end(), std::back_inserter(result));
return result;
}
inline std::string utf32to8(std::u32string_view s)
{
std::string result;
utf32to8(s.begin(), s.end(), std::back_inserter(result));
return result;
}
inline std::u32string utf8to32(std::string_view s)
{
std::u32string result;
utf8to32(s.begin(), s.end(), std::back_inserter(result));
return result;
}
inline std::size_t find_invalid(std::string_view s)
{
std::string_view::const_iterator invalid = find_invalid(s.begin(), s.end());
return (invalid == s.end()) ? std::string_view::npos : static_cast<std::size_t>(invalid - s.begin());
}
inline bool is_valid(std::string_view s)
{
return is_valid(s.begin(), s.end());
}
inline std::string replace_invalid(std::string_view s, char32_t replacement)
{
std::string result;
replace_invalid(s.begin(), s.end(), std::back_inserter(result), replacement);
return result;
}
inline std::string replace_invalid(std::string_view s)
{
std::string result;
replace_invalid(s.begin(), s.end(), std::back_inserter(result));
return result;
}
inline bool starts_with_bom(std::string_view s)
{
return starts_with_bom(s.begin(), s.end());
}
} // namespace utf8
#endif // header guard
// Copyright 2006 Nemanja Trifunovic
/*
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#ifndef UTF8_FOR_CPP_UNCHECKED_H_2675DCD0_9480_4c0c_B92A_CC14C027B731
#define UTF8_FOR_CPP_UNCHECKED_H_2675DCD0_9480_4c0c_B92A_CC14C027B731
#include "core.h"
namespace utf8
{
namespace unchecked
{
template <typename octet_iterator>
octet_iterator append(uint32_t cp, octet_iterator result)
{
if (cp < 0x80) // one octet
*(result++) = static_cast<uint8_t>(cp);
else if (cp < 0x800) { // two octets
*(result++) = static_cast<uint8_t>((cp >> 6) | 0xc0);
*(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80);
}
else if (cp < 0x10000) { // three octets
*(result++) = static_cast<uint8_t>((cp >> 12) | 0xe0);
*(result++) = static_cast<uint8_t>(((cp >> 6) & 0x3f) | 0x80);
*(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80);
}
else { // four octets
*(result++) = static_cast<uint8_t>((cp >> 18) | 0xf0);
*(result++) = static_cast<uint8_t>(((cp >> 12) & 0x3f)| 0x80);
*(result++) = static_cast<uint8_t>(((cp >> 6) & 0x3f) | 0x80);
*(result++) = static_cast<uint8_t>((cp & 0x3f) | 0x80);
}
return result;
}
template <typename octet_iterator, typename output_iterator>
output_iterator replace_invalid(octet_iterator start, octet_iterator end, output_iterator out, uint32_t replacement)
{
while (start != end) {
octet_iterator sequence_start = start;
internal::utf_error err_code = utf8::internal::validate_next(start, end);
switch (err_code) {
case internal::UTF8_OK :
for (octet_iterator it = sequence_start; it != start; ++it)
*out++ = *it;
break;
case internal::NOT_ENOUGH_ROOM:
out = utf8::unchecked::append (replacement, out);
start = end;
break;
case internal::INVALID_LEAD:
out = utf8::unchecked::append (replacement, out);
++start;
break;
case internal::INCOMPLETE_SEQUENCE:
case internal::OVERLONG_SEQUENCE:
case internal::INVALID_CODE_POINT:
out = utf8::unchecked::append (replacement, out);
++start;
// just one replacement mark for the sequence
while (start != end && utf8::internal::is_trail(*start))
++start;
break;
}
}
return out;
}
template <typename octet_iterator, typename output_iterator>
inline output_iterator replace_invalid(octet_iterator start, octet_iterator end, output_iterator out)
{
static const uint32_t replacement_marker = utf8::internal::mask16(0xfffd);
return utf8::unchecked::replace_invalid(start, end, out, replacement_marker);
}
template <typename octet_iterator>
uint32_t next(octet_iterator& it)
{
uint32_t cp = utf8::internal::mask8(*it);
typename std::iterator_traits<octet_iterator>::difference_type length = utf8::internal::sequence_length(it);
switch (length) {
case 1:
break;
case 2:
it++;
cp = ((cp << 6) & 0x7ff) + ((*it) & 0x3f);
break;
case 3:
++it;
cp = ((cp << 12) & 0xffff) + ((utf8::internal::mask8(*it) << 6) & 0xfff);
++it;
cp += (*it) & 0x3f;
break;
case 4:
++it;
cp = ((cp << 18) & 0x1fffff) + ((utf8::internal::mask8(*it) << 12) & 0x3ffff);
++it;
cp += (utf8::internal::mask8(*it) << 6) & 0xfff;
++it;
cp += (*it) & 0x3f;
break;
}
++it;
return cp;
}
template <typename octet_iterator>
uint32_t peek_next(octet_iterator it)
{
return utf8::unchecked::next(it);
}
template <typename octet_iterator>
uint32_t prior(octet_iterator& it)
{
while (utf8::internal::is_trail(*(--it))) ;
octet_iterator temp = it;
return utf8::unchecked::next(temp);
}
template <typename octet_iterator, typename distance_type>
void advance (octet_iterator& it, distance_type n)
{
const distance_type zero(0);
if (n < zero) {
// backward
for (distance_type i = n; i < zero; ++i)
utf8::unchecked::prior(it);
} else {
// forward
for (distance_type i = zero; i < n; ++i)
utf8::unchecked::next(it);
}
}
template <typename octet_iterator>
typename std::iterator_traits<octet_iterator>::difference_type
distance (octet_iterator first, octet_iterator last)
{
typename std::iterator_traits<octet_iterator>::difference_type dist;
for (dist = 0; first < last; ++dist)
utf8::unchecked::next(first);
return dist;
}
template <typename u16bit_iterator, typename octet_iterator>
octet_iterator utf16to8 (u16bit_iterator start, u16bit_iterator end, octet_iterator result)
{
while (start != end) {
uint32_t cp = utf8::internal::mask16(*start++);
// Take care of surrogate pairs first
if (utf8::internal::is_lead_surrogate(cp)) {
uint32_t trail_surrogate = utf8::internal::mask16(*start++);
cp = (cp << 10) + trail_surrogate + internal::SURROGATE_OFFSET;
}
result = utf8::unchecked::append(cp, result);
}
return result;
}
template <typename u16bit_iterator, typename octet_iterator>
u16bit_iterator utf8to16 (octet_iterator start, octet_iterator end, u16bit_iterator result)
{
while (start < end) {
uint32_t cp = utf8::unchecked::next(start);
if (cp > 0xffff) { //make a surrogate pair
*result++ = static_cast<uint16_t>((cp >> 10) + internal::LEAD_OFFSET);
*result++ = static_cast<uint16_t>((cp & 0x3ff) + internal::TRAIL_SURROGATE_MIN);
}
else
*result++ = static_cast<uint16_t>(cp);
}
return result;
}
template <typename octet_iterator, typename u32bit_iterator>
octet_iterator utf32to8 (u32bit_iterator start, u32bit_iterator end, octet_iterator result)
{
while (start != end)
result = utf8::unchecked::append(*(start++), result);
return result;
}
template <typename octet_iterator, typename u32bit_iterator>
u32bit_iterator utf8to32 (octet_iterator start, octet_iterator end, u32bit_iterator result)
{
while (start < end)
(*result++) = utf8::unchecked::next(start);
return result;
}
// The iterator class
template <typename octet_iterator>
class iterator {
octet_iterator it;
public:
typedef uint32_t value_type;
typedef uint32_t* pointer;
typedef uint32_t& reference;
typedef std::ptrdiff_t difference_type;
typedef std::bidirectional_iterator_tag iterator_category;
iterator () {}
explicit iterator (const octet_iterator& octet_it): it(octet_it) {}
// the default "big three" are OK
octet_iterator base () const { return it; }
uint32_t operator * () const
{
octet_iterator temp = it;
return utf8::unchecked::next(temp);
}
bool operator == (const iterator& rhs) const
{
return (it == rhs.it);
}
bool operator != (const iterator& rhs) const
{
return !(operator == (rhs));
}
iterator& operator ++ ()
{
::std::advance(it, utf8::internal::sequence_length(it));
return *this;
}
iterator operator ++ (int)
{
iterator temp = *this;
::std::advance(it, utf8::internal::sequence_length(it));
return temp;
}
iterator& operator -- ()
{
utf8::unchecked::prior(it);
return *this;
}
iterator operator -- (int)
{
iterator temp = *this;
utf8::unchecked::prior(it);
return temp;
}
}; // class iterator
} // namespace utf8::unchecked
} // namespace utf8
#endif // header guard