code
stringlengths 0
56.1M
| repo_name
stringlengths 3
57
| path
stringlengths 2
176
| language
stringclasses 672
values | license
stringclasses 8
values | size
int64 0
56.8M
|
|---|---|---|---|---|---|
/****************************************************************************
*
* svsfnt.h
*
* The FreeType SFNT table loading service (specification).
*
* Copyright (C) 2003-2022 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 SVSFNT_H_
#define SVSFNT_H_
#include <freetype/internal/ftserv.h>
#include <freetype/tttables.h>
FT_BEGIN_HEADER
/*
* SFNT table loading service.
*/
#define FT_SERVICE_ID_SFNT_TABLE "sfnt-table"
/*
* Used to implement FT_Load_Sfnt_Table().
*/
typedef FT_Error
(*FT_SFNT_TableLoadFunc)( FT_Face face,
FT_ULong tag,
FT_Long offset,
FT_Byte* buffer,
FT_ULong* length );
/*
* Used to implement FT_Get_Sfnt_Table().
*/
typedef void*
(*FT_SFNT_TableGetFunc)( FT_Face face,
FT_Sfnt_Tag tag );
/*
* Used to implement FT_Sfnt_Table_Info().
*/
typedef FT_Error
(*FT_SFNT_TableInfoFunc)( FT_Face face,
FT_UInt idx,
FT_ULong *tag,
FT_ULong *offset,
FT_ULong *length );
FT_DEFINE_SERVICE( SFNT_Table )
{
FT_SFNT_TableLoadFunc load_table;
FT_SFNT_TableGetFunc get_table;
FT_SFNT_TableInfoFunc table_info;
};
#define FT_DEFINE_SERVICE_SFNT_TABLEREC( class_, load_, get_, info_ ) \
static const FT_Service_SFNT_TableRec class_ = \
{ \
load_, get_, info_ \
};
/* */
FT_END_HEADER
#endif /* SVSFNT_H_ */
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/include/freetype/internal/services/svsfnt.h
|
C++
|
gpl-3.0
| 2,079
|
/****************************************************************************
*
* svttcmap.h
*
* The FreeType TrueType/sfnt cmap extra information service.
*
* Copyright (C) 2003-2022 by
* Masatake YAMATO, Redhat K.K.,
* 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.
*
*/
/* Development of this service is support of
Information-technology Promotion Agency, Japan. */
#ifndef SVTTCMAP_H_
#define SVTTCMAP_H_
#include <freetype/internal/ftserv.h>
#include <freetype/tttables.h>
FT_BEGIN_HEADER
#define FT_SERVICE_ID_TT_CMAP "tt-cmaps"
/**************************************************************************
*
* @struct:
* TT_CMapInfo
*
* @description:
* A structure used to store TrueType/sfnt specific cmap information
* which is not covered by the generic @FT_CharMap structure. This
* structure can be accessed with the @FT_Get_TT_CMap_Info function.
*
* @fields:
* language ::
* The language ID used in Mac fonts. Definitions of values are in
* `ttnameid.h`.
*
* format ::
* The cmap format. OpenType 1.6 defines the formats 0 (byte encoding
* table), 2~(high-byte mapping through table), 4~(segment mapping to
* delta values), 6~(trimmed table mapping), 8~(mixed 16-bit and 32-bit
* coverage), 10~(trimmed array), 12~(segmented coverage), 13~(last
* resort font), and 14 (Unicode Variation Sequences).
*/
typedef struct TT_CMapInfo_
{
FT_ULong language;
FT_Long format;
} TT_CMapInfo;
typedef FT_Error
(*TT_CMap_Info_GetFunc)( FT_CharMap charmap,
TT_CMapInfo *cmap_info );
FT_DEFINE_SERVICE( TTCMaps )
{
TT_CMap_Info_GetFunc get_cmap_info;
};
#define FT_DEFINE_SERVICE_TTCMAPSREC( class_, get_cmap_info_ ) \
static const FT_Service_TTCMapsRec class_ = \
{ \
get_cmap_info_ \
};
/* */
FT_END_HEADER
#endif /* SVTTCMAP_H_ */
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/include/freetype/internal/services/svttcmap.h
|
C++
|
gpl-3.0
| 2,397
|
/****************************************************************************
*
* svtteng.h
*
* The FreeType TrueType engine query service (specification).
*
* Copyright (C) 2006-2022 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 SVTTENG_H_
#define SVTTENG_H_
#include <freetype/internal/ftserv.h>
#include <freetype/ftmodapi.h>
FT_BEGIN_HEADER
/*
* SFNT table loading service.
*/
#define FT_SERVICE_ID_TRUETYPE_ENGINE "truetype-engine"
/*
* Used to implement FT_Get_TrueType_Engine_Type
*/
FT_DEFINE_SERVICE( TrueTypeEngine )
{
FT_TrueTypeEngineType engine_type;
};
/* */
FT_END_HEADER
#endif /* SVTTENG_H_ */
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/include/freetype/internal/services/svtteng.h
|
C++
|
gpl-3.0
| 1,007
|
/****************************************************************************
*
* svttglyf.h
*
* The FreeType TrueType glyph service.
*
* Copyright (C) 2007-2022 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 */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/include/freetype/internal/services/svttglyf.h
|
C++
|
gpl-3.0
| 1,251
|
/****************************************************************************
*
* svwinfnt.h
*
* The FreeType Windows FNT/FONT service (specification).
*
* Copyright (C) 2003-2022 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 */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/include/freetype/internal/services/svwinfnt.h
|
C++
|
gpl-3.0
| 1,017
|
/****************************************************************************
*
* sfnt.h
*
* High-level 'sfnt' driver interface (specification).
*
* Copyright (C) 1996-2022 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_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 */
/* 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_gasp_, \
load_pclt_, \
load_bhed_, \
load_sbit_image_, \
get_psname_, \
free_psnames_, \
get_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_gasp_, \
load_pclt_, \
load_bhed_, \
load_sbit_image_, \
get_psname_, \
free_psnames_, \
get_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 */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/include/freetype/internal/sfnt.h
|
C++
|
gpl-3.0
| 32,444
|
/****************************************************************************
*
* svginterface.h
*
* Interface of ot-svg module (specification only).
*
* Copyright (C) 2022 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 */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/include/freetype/internal/svginterface.h
|
C++
|
gpl-3.0
| 1,036
|
/****************************************************************************
*
* t1types.h
*
* Basic Type1/Type2 type definitions and interface (specification
* only).
*
* Copyright (C) 1996-2022 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/t1tables.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;
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/*** ***/
/*** ***/
/*** 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;
FT_Fixed Descender;
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 */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/include/freetype/internal/t1types.h
|
C++
|
gpl-3.0
| 8,158
|
/****************************************************************************
*
* tttypes.h
*
* Basic SFNT/TrueType type definitions and interface (specification
* only).
*
* Copyright (C) 1996-2022 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>
#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_20Rec
*
* @description:
* Postscript names sub-table, format 2.0. Stores the PS name of each
* glyph in the font face.
*
* @fields:
* 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_20Rec_
{
FT_UShort num_glyphs;
FT_UShort num_names;
FT_UShort* glyph_indices;
FT_Char** glyph_names;
} TT_Post_20Rec, *TT_Post_20;
/**************************************************************************
*
* @struct:
* TT_Post_25Rec
*
* @description:
* Postscript names sub-table, format 2.5. Stores the PS name of each
* glyph in the font face.
*
* @fields:
* num_glyphs ::
* The number of glyphs in the table.
*
* offsets ::
* An array of signed offsets in a normal Mac Postscript name encoding.
*/
typedef struct TT_Post_25_
{
FT_UShort num_glyphs;
FT_Char* offsets;
} TT_Post_25Rec, *TT_Post_25;
/**************************************************************************
*
* @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.
*
* format_20 ::
* The sub-table used for format 2.0.
*
* format_25 ::
* The sub-table used for format 2.5.
*/
typedef struct TT_Post_NamesRec_
{
FT_Bool loaded;
union
{
TT_Post_20Rec format_20;
TT_Post_25Rec format_25;
} 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.
*
* var ::
* A pointer to the Metrics Variations service.
*
* hdmx ::
* The face's horizontal device metrics ('hdmx' table). This table is
* optional in TrueType/OpenType fonts.
*
* 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.
*
* 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.
*
* 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.
*
* 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.
*
* sph_found_func_flags ::
* Flags identifying special bytecode functions (used by the v38
* implementation of the bytecode interpreter).
*
* sph_compatibility_mode ::
* This flag is set if we are in ClearType backward compatibility mode
* (used by the v38 implementation of the bytecode interpreter).
*
* ebdt_start ::
* The file offset of the sbit data table (CBDT, bdat, etc.).
*
* ebdt_size ::
* The size of the sbit data table.
*/
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 */
void* var;
#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 */
#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_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_SUPPORT_SUBPIXEL_HINTING_INFINALITY
/* since 2.4.12 */
FT_ULong sph_found_func_flags; /* special functions found */
/* for this face */
FT_Bool sph_compatibility_mode;
#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
#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_Short max_contours;
FT_UShort n_points; /* number of points in zone */
FT_Short 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 */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/include/freetype/internal/tttypes.h
|
C++
|
gpl-3.0
| 52,924
|
/****************************************************************************
*
* wofftypes.h
*
* Basic WOFF/WOFF2 type definitions and interface (specification
* only).
*
* Copyright (C) 1996-2022 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 */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/include/freetype/internal/wofftypes.h
|
C++
|
gpl-3.0
| 8,010
|
/****************************************************************************
*
* otsvg.h
*
* Interface for OT-SVG support related things (specification).
*
* Copyright (C) 2022 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 */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/include/freetype/otsvg.h
|
C++
|
gpl-3.0
| 10,452
|
/****************************************************************************
*
* t1tables.h
*
* Basic Type 1/Type 2 tables definitions and interface (specification
* only).
*
* Copyright (C) 1996-2022 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
/* */
/* maximum number of Multiple Masters designs, as defined in the spec */
#define T1_MAX_MM_DESIGNS 16
/* maximum number of Multiple Masters axes, as defined in the spec */
#define T1_MAX_MM_AXIS 4
/* maximum number of elements in a design map */
#define T1_MAX_MM_MAP_POINTS 20
/* 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;
/**************************************************************************
*
* @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 */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/include/freetype/t1tables.h
|
C++
|
gpl-3.0
| 23,188
|
/****************************************************************************
*
* ttnameid.h
*
* TrueType name ID definitions (specification only).
*
* Copyright (C) 1996-2022 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 */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/include/freetype/ttnameid.h
|
C++
|
gpl-3.0
| 58,769
|
/****************************************************************************
*
* tttables.h
*
* Basic SFNT/TrueType tables definitions and interface
* (specification only).
*
* Copyright (C) 1996-2022 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/20th points) */
FT_UShort usUpperOpticalPointSize; /* in twips (1/20th 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,
* return -1.
*/
FT_EXPORT( FT_Long )
FT_Get_CMap_Format( FT_CharMap charmap );
/* */
FT_END_HEADER
#endif /* TTTABLES_H_ */
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/include/freetype/tttables.h
|
C++
|
gpl-3.0
| 25,231
|
/****************************************************************************
*
* tttags.h
*
* Tags for TrueType and OpenType tables (specification only).
*
* Copyright (C) 1996-2022 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 */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/include/freetype/tttags.h
|
C++
|
gpl-3.0
| 5,145
|
/****************************************************************************
*
* ft2build.h
*
* FreeType 2 build and setup macros.
*
* Copyright (C) 1996-2022 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 */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/include/ft2build.h
|
C++
|
gpl-3.0
| 990
|
#
# Meson project file for FreeType 2
#
# Copyright (C) 2020-2022 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.
#
# Say
#
# meson configure
#
# to see all configuration options and their default values. For example,
# to build only a shared version of FreeType, override the default value
# with
#
# meson setup -Ddefault_library=shared
#
project('freetype2', 'c',
meson_version: '>= 0.55.0',
default_options: ['default_library=both'],
version: run_command('builds/meson/extract_freetype_version.py',
'include/freetype/freetype.h',
check: true).stdout().strip(),
)
# Only meson >= 0.57 can read a file and assign its contents to a
# variable; we thus use an external command to have this functionality
# with older versions, too.
python_exe = find_program('python3')
ft2_so_version = run_command(python_exe,
files('builds/meson/extract_libtool_version.py'),
'--soversion',
files('builds/unix/configure.raw'),
check: true).stdout().strip()
ft2_pkgconfig_version = run_command(python_exe,
files('builds/meson/extract_libtool_version.py'),
files('builds/unix/configure.raw'),
check: true).stdout().strip()
ft2_includes = include_directories('include')
freetype_includedir = join_paths(get_option('includedir'), 'freetype2')
# Generate a custom `ftmodule.h` version based on the content of
# `modules.cfg`.
ftmodule_h = custom_target('ftmodule.h',
output: 'ftmodule.h',
input: 'modules.cfg',
command: [python_exe, files('builds/meson/parse_modules_cfg.py'),
'--format=ftmodule.h', '@INPUT@', '--output', '@OUTPUT@'],
install: true,
install_dir: join_paths(freetype_includedir, 'freetype/config'),
)
ft2_sources = [ftmodule_h]
# FreeType 2 modules.
ft_main_modules = run_command(python_exe,
files('builds/meson/parse_modules_cfg.py'),
'--format=main-modules',
files('modules.cfg'),
check: true).stdout().strip().split()
ft2_sources += files([
'src/base/ftbase.c',
'src/base/ftinit.c',
])
foreach mod: ft_main_modules
source = mod
if mod == 'winfonts'
source = 'winfnt'
elif mod == 'cid'
source = 'type1cid'
endif
ft2_sources += 'src/@0@/@1@.c'.format(mod, source)
endforeach
# NOTE: The `bzip2` aux module is handled through options.
ft_aux_modules = run_command(python_exe,
files('builds/meson/parse_modules_cfg.py'),
'--format=aux-modules',
files('modules.cfg'),
check: true).stdout().strip().split()
foreach auxmod: ft_aux_modules
source = auxmod
# Most sources are named `src/<module>/<module>.c`, but there are a few
# exceptions handled here.
if auxmod == 'cache'
source = 'ftcache'
elif auxmod == 'lzw'
source = 'ftlzw'
elif auxmod == 'gzip'
source = 'ftgzip'
elif auxmod == 'bzip2'
# Handled through options instead, see below.
continue
endif
ft2_sources += 'src/@0@/@1@.c'.format(auxmod, source)
endforeach
# FreeType 2 base extensions.
# To be configured in `modules.cfg`.
base_extensions = run_command(python_exe,
files('builds/meson/parse_modules_cfg.py'),
'--format=base-extensions-list',
files('modules.cfg'),
check: true).stdout().split()
foreach ext: base_extensions
ft2_sources += files('src/base/' + ext)
endforeach
# Header files.
ft2_public_headers = files([
'include/freetype/freetype.h',
'include/freetype/ftadvanc.h',
'include/freetype/ftbbox.h',
'include/freetype/ftbdf.h',
'include/freetype/ftbitmap.h',
'include/freetype/ftbzip2.h',
'include/freetype/ftcache.h',
'include/freetype/ftchapters.h',
'include/freetype/ftcid.h',
'include/freetype/ftcolor.h',
'include/freetype/ftdriver.h',
'include/freetype/fterrdef.h',
'include/freetype/fterrors.h',
'include/freetype/ftfntfmt.h',
'include/freetype/ftgasp.h',
'include/freetype/ftglyph.h',
'include/freetype/ftgxval.h',
'include/freetype/ftgzip.h',
'include/freetype/ftimage.h',
'include/freetype/ftincrem.h',
'include/freetype/ftlcdfil.h',
'include/freetype/ftlist.h',
'include/freetype/ftlzw.h',
'include/freetype/ftmac.h',
'include/freetype/ftmm.h',
'include/freetype/ftmodapi.h',
'include/freetype/ftmoderr.h',
'include/freetype/ftotval.h',
'include/freetype/ftoutln.h',
'include/freetype/ftparams.h',
'include/freetype/ftpfr.h',
'include/freetype/ftrender.h',
'include/freetype/ftsizes.h',
'include/freetype/ftsnames.h',
'include/freetype/ftstroke.h',
'include/freetype/ftsynth.h',
'include/freetype/ftsystem.h',
'include/freetype/fttrigon.h',
'include/freetype/fttypes.h',
'include/freetype/ftwinfnt.h',
'include/freetype/otsvg.h',
'include/freetype/t1tables.h',
'include/freetype/ttnameid.h',
'include/freetype/tttables.h',
'include/freetype/tttags.h',
])
ft2_config_headers = files([
'include/freetype/config/ftconfig.h',
'include/freetype/config/ftheader.h',
'include/freetype/config/ftstdlib.h',
'include/freetype/config/integer-types.h',
'include/freetype/config/mac-support.h',
'include/freetype/config/public-macros.h',
])
ft2_defines = ['-DFT2_BUILD_LIBRARY=1']
# System support file.
cc = meson.get_compiler('c')
# NOTE: msys2 on Windows has `unistd.h` and `fcntl.h` but not `sys/mman.h`!
has_unistd_h = cc.has_header('unistd.h')
has_fcntl_h = cc.has_header('fcntl.h')
has_sys_mman_h = cc.has_header('sys/mman.h')
mmap_option = get_option('mmap')
use_unix_ftsystem_c = false
if mmap_option.disabled()
ft2_sources += files(['src/base/ftsystem.c',])
elif host_machine.system() == 'windows'
ft2_sources += files(['builds/windows/ftsystem.c',])
else
if has_unistd_h and has_fcntl_h and has_sys_mman_h
# This version of `ftsystem.c` uses `mmap` to read input font files.
ft2_sources += files(['builds/unix/ftsystem.c',])
use_unix_ftsystem_c = true
elif mmap_option.enabled()
error('mmap was enabled via options but is not available,'
+ ' required headers were not found!')
else
ft2_sources += files(['src/base/ftsystem.c',])
endif
endif
# Debug support file
#
# NOTE: Some specialized versions exist for other platforms not supported by
# Meson. Most implementation differences are extremely minor, i.e., in the
# implementation of `FT_Message` and `FT_Panic`, and getting the `FT2_DEBUG`
# value from the environment, when this is supported. A smaller refactor
# might make these platform-specific files much smaller, and could be moved
# into `ftsystem.c` as well.
#
if host_machine.system() == 'windows'
winmod = import('windows')
ft2_sources += [
'builds/windows/ftdebug.c',
winmod.compile_resources('src/base/ftver.rc'),
]
else
ft2_sources += 'src/base/ftdebug.c'
endif
ft2_deps = []
common_ldflags = []
# Correct compatibility version for OS x.
#
# OSX sets the compatibility_version (aka libtools version) differently from
# the library name.
#
if host_machine.system() == 'darwin'
# maintain compatibility with autotools on macOS
common_ldflags = [
'-compatibility_version', ft2_pkgconfig_version.split('.')[0],
'-current_version', ft2_pkgconfig_version
]
endif
# Generate `ftoption.h` based on available dependencies.
process_header_command = [python_exe,
files('builds/meson/process_ftoption_h.py'),
'@INPUT@', '--output=@OUTPUT@']
ftoption_command = process_header_command
# external GZip support
zlib_option = get_option('zlib')
# Backwards-compatible aliases.
if zlib_option == 'disabled'
zlib_option = 'none'
elif zlib_option == 'enabled'
zlib_option = 'auto'
endif
if zlib_option == 'auto'
# First try to find a system installation, otherwise fall back to
# the subproject.
zlib_dep = dependency('zlib',
required: false)
if zlib_dep.found()
zlib_option = 'system'
else
zlib_option = 'external'
endif
endif
if zlib_option == 'none'
ftoption_command += [ '--disable=FT_CONFIG_OPTION_USE_ZLIB' ]
elif zlib_option == 'internal'
ftoption_command += [ '--enable=FT_CONFIG_OPTION_USE_ZLIB' ]
elif zlib_option == 'external'
ftoption_command += [ '--enable=FT_CONFIG_OPTION_USE_ZLIB' ]
zlib_project = subproject('zlib',
required: true,
default_options: 'default_library=static')
zlib_dep = zlib_project.get_variable('zlib_dep')
ft2_deps += [zlib_dep]
elif zlib_option == 'system'
zlib_dep = dependency('zlib',
required: true)
assert(zlib_dep.found(), 'Could not find system zlib installation!')
ftoption_command += [
'--enable=FT_CONFIG_OPTION_USE_ZLIB',
'--enable=FT_CONFIG_OPTION_SYSTEM_ZLIB',
]
ft2_deps += [zlib_dep]
else
assert(false, 'Invalid zlib option ' + zlib_option)
endif
# BZip2 support
bzip2_dep = cc.find_library('bz2',
required: get_option('bzip2'))
if bzip2_dep.found()
ftoption_command += ['--enable=FT_CONFIG_OPTION_USE_BZIP2']
ft2_sources += files(['src/bzip2/ftbzip2.c',])
ft2_deps += [bzip2_dep]
endif
# PNG support
libpng_dep = dependency('libpng',
required: get_option('png'),
fallback: 'libpng')
if libpng_dep.found()
ftoption_command += ['--enable=FT_CONFIG_OPTION_USE_PNG']
ft2_deps += [libpng_dep]
endif
# Harfbuzz support
harfbuzz_dep = dependency('harfbuzz',
version: '>= 2.0.0',
required: get_option('harfbuzz'))
if harfbuzz_dep.found()
ftoption_command += ['--enable=FT_CONFIG_OPTION_USE_HARFBUZZ']
ft2_deps += [harfbuzz_dep]
endif
# Brotli decompression support
brotli_dep = dependency('libbrotlidec',
required: get_option('brotli'))
if brotli_dep.found()
ftoption_command += ['--enable=FT_CONFIG_OPTION_USE_BROTLI']
ft2_deps += [brotli_dep]
endif
# We can now generate `ftoption.h`.
ftoption_h = custom_target('ftoption.h',
input: 'include/freetype/config/ftoption.h',
output: 'ftoption.h',
command: ftoption_command,
install: true,
install_dir: join_paths(freetype_includedir, 'freetype/config'),
)
ft2_sources += ftoption_h
ft2_defines += ['-DFT_CONFIG_OPTIONS_H=<ftoption.h>']
if host_machine.system() == 'windows'
ft2_defines += ['-DDLL_EXPORT=1']
endif
# Generate `ftconfig.h`.
ftconfig_command = process_header_command
if has_unistd_h
ftconfig_command += '--enable=HAVE_UNISTD_H'
endif
if has_fcntl_h
ftconfig_command += '--enable=HAVE_FCNTL_H'
endif
if use_unix_ftsystem_c
ftconfig_h_in = files('builds/unix/ftconfig.h.in')
ftconfig_h = custom_target('ftconfig.h',
input: ftconfig_h_in,
output: 'ftconfig.h',
command: ftconfig_command,
install: true,
install_dir: join_paths(freetype_includedir, 'freetype/config'),
)
ft2_sources += ftconfig_h
ft2_defines += ['-DFT_CONFIG_CONFIG_H=<ftconfig.h>']
endif
ft2_lib = library('freetype',
sources: ft2_sources + [ftmodule_h],
c_args: ft2_defines,
gnu_symbol_visibility: 'hidden',
include_directories: ft2_includes,
dependencies: ft2_deps,
install: true,
version: ft2_so_version,
link_args: common_ldflags,
)
# To be used by other projects including this one through `subproject`.
freetype_dep = declare_dependency(
include_directories: ft2_includes,
link_with: ft2_lib,
version: ft2_pkgconfig_version)
meson.override_dependency('freetype2', freetype_dep)
# NOTE: Using both `install_dir` and `subdir` doesn't seem to work below,
# i.e., the subdir value seems to be ignored, contrary to examples in the
# Meson documentation.
install_headers('include/ft2build.h',
install_dir: freetype_includedir)
install_headers(ft2_public_headers,
install_dir: join_paths(freetype_includedir, 'freetype'))
install_headers(ft2_config_headers,
install_dir: join_paths(freetype_includedir, 'freetype/config'))
pkgconfig = import('pkgconfig')
pkgconfig.generate(ft2_lib,
filebase: 'freetype2',
name: 'FreeType 2',
description: 'A free, high-quality, and portable font engine.',
url: 'https://freetype.org',
subdirs: 'freetype2',
version: ft2_pkgconfig_version,
)
if get_option('tests').enabled()
subdir('tests')
endif
# NOTE: Unlike the old `make refdoc` command, this generates the
# documentation under `$BUILD/docs/` since Meson doesn't support modifying
# the source root directory (which is a good thing).
gen_docs = custom_target('freetype2 reference documentation',
output: 'docs',
input: ft2_public_headers + ft2_config_headers,
command: [python_exe,
files('builds/meson/generate_reference_docs.py'),
'--version=' + meson.project_version(),
'--input-dir=' + meson.current_source_dir(),
'--output-dir=@OUTPUT@'
],
)
summary({'OS': host_machine.system(),
}, section: 'Operating System')
summary({'Zlib': zlib_option,
'Bzip2': bzip2_dep.found() ? 'yes' : 'no',
'Png': libpng_dep.found() ? 'yes' : 'no',
'Harfbuzz': harfbuzz_dep.found() ? 'yes' : 'no',
'Brotli': brotli_dep.found() ? 'yes' : 'no',
}, section: 'Used Libraries')
# EOF
|
whupdup/frame
|
real/third_party/freetype-2.12.0/meson.build
|
build
|
gpl-3.0
| 13,001
|
#
# meson_options.txt
#
# Copyright (C) 2020-2022 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.
option('brotli',
type: 'feature',
value: 'auto',
description: 'Use Brotli library to support decompressing WOFF2 fonts')
option('bzip2',
type: 'feature',
value: 'auto',
description: 'Support reading bzip2-compressed font files')
option('harfbuzz',
type: 'feature',
value: 'auto',
description: 'Use Harfbuzz library to improve auto-hinting;'
+ ' if available, many glyphs not directly addressable'
+ ' by a font\'s character map will be hinted also')
option('mmap',
type: 'feature',
value: 'auto',
description: 'Use mmap() to open font files for faster parsing')
option('png',
type: 'feature',
value: 'auto',
description: 'Support color bitmap glyph formats in the PNG format;'
+ ' requires libpng')
option('tests',
type: 'feature',
value: 'disabled',
description: 'Enable FreeType unit and regression tests')
option('zlib',
type: 'combo',
choices: [ 'auto', 'none',
'internal', 'external', 'system',
'disabled', 'enabled' ],
description: 'Support reading gzip-compressed font files')
# EOF
|
whupdup/frame
|
real/third_party/freetype-2.12.0/meson_options.txt
|
Text
|
gpl-3.0
| 1,518
|
# modules.cfg
#
# Copyright (C) 2005-2022 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.
#
#
# In case you compile the FreeType library with GNU make or makepp, this
# file controls which components are built into the library. Otherwise,
# please read this file for information on the various modules and its
# dependencies, then follow the instructions in the file `docs/INSTALL.ANY'.
#
# To deactivate a module, simply comment out the corresponding line. To
# activate a module, remove the comment character.
#
# Note that many modules and components are further controlled with macros
# in the file `include/freetype/config/ftoption.h'.
####
#### font modules -- at least one is required
####
#### The order given here (from top to down) is the order used for testing
#### font formats in the compiled library.
####
# TrueType font driver.
#
# This driver needs the `sfnt' module.
FONT_MODULES += truetype
# PostScript Type 1 font driver.
#
# This driver needs the `psaux', `pshinter', and `psnames' modules.
FONT_MODULES += type1
# CFF/OpenType font driver.
#
# This driver needs the `sfnt', `psaux', `pshinter', and `psnames' modules.
FONT_MODULES += cff
# Type 1 CID-keyed font driver.
#
# This driver needs the `psaux', `pshinter', and `psnames' modules.
FONT_MODULES += cid
# PFR/TrueDoc font driver. See optional extension ftpfr.c below also.
FONT_MODULES += pfr
# PostScript Type 42 font driver.
#
# This driver needs the `truetype' and `psaux' modules.
FONT_MODULES += type42
# Windows FONT/FNT font driver. See optional extension ftwinfnt.c below
# also.
FONT_MODULES += winfonts
# PCF font driver. If debugging and tracing is enabled, needs `ftbitmap.c'.
FONT_MODULES += pcf
# BDF font driver. See optional extension ftbdf.c below also.
FONT_MODULES += bdf
# SFNT files support. If used without `truetype' or `cff', it supports
# bitmap-only fonts within an SFNT wrapper.
#
# This driver needs the `psnames' module.
FONT_MODULES += sfnt
####
#### hinting modules
####
# FreeType's auto hinter.
HINTING_MODULES += autofit
# PostScript hinter.
HINTING_MODULES += pshinter
# The TrueType hinting engine doesn't have a module of its own but is
# controlled in file include/freetype/config/ftoption.h
# (TT_CONFIG_OPTION_BYTECODE_INTERPRETER and friends).
####
#### raster modules -- at least one is required for vector font formats
####
# Anti-aliasing rasterizer.
RASTER_MODULES += smooth
# Monochrome rasterizer.
RASTER_MODULES += raster
# OT-SVG.
RASTER_MODULES += svg
# Signed distance field rasterizer.
RASTER_MODULES += sdf
####
#### auxiliary modules
####
# FreeType's cache sub-system (quite stable but still in beta -- this means
# that its public API is subject to change if necessary). See
# include/freetype/ftcache.h. Needs `ftglyph.c'.
AUX_MODULES += cache
# TrueType GX/AAT table validation. Needs `ftgxval.c' below.
#
# AUX_MODULES += gxvalid
# Support for streams compressed with gzip (files with suffix .gz).
#
# See include/freetype/ftgzip.h for the API.
AUX_MODULES += gzip
# Support for streams compressed with LZW (files with suffix .Z).
#
# See include/freetype/ftlzw.h for the API.
AUX_MODULES += lzw
# Support for streams compressed with bzip2 (files with suffix .bz2).
#
# See include/freetype/ftbzip2.h for the API.
AUX_MODULES += bzip2
# OpenType table validation. Needs `ftotval.c' below.
#
# AUX_MODULES += otvalid
# Auxiliary PostScript driver component to share common code.
#
# This module depends on `psnames'.
AUX_MODULES += psaux
# Support for PostScript glyph names.
#
# This module can be controlled in ftconfig.h
# (FT_CONFIG_OPTION_POSTSCRIPT_NAMES).
AUX_MODULES += psnames
####
#### base module extensions
####
# Exact bounding box calculation.
#
# See include/freetype/ftbbox.h for the API.
BASE_EXTENSIONS += ftbbox.c
# Access BDF-specific strings. Needs BDF font driver.
#
# See include/freetype/ftbdf.h for the API.
BASE_EXTENSIONS += ftbdf.c
# Utility functions for converting 1bpp, 2bpp, 4bpp, and 8bpp bitmaps into
# 8bpp format, and for emboldening of bitmap glyphs.
#
# See include/freetype/ftbitmap.h for the API.
BASE_EXTENSIONS += ftbitmap.c
# Access CID font information.
#
# See include/freetype/ftcid.h for the API.
BASE_EXTENSIONS += ftcid.c
# Access FSType information. Needs `fttype1.c'.
#
# See include/freetype/freetype.h for the API.
BASE_EXTENSIONS += ftfstype.c
# Support for GASP table queries.
#
# See include/freetype/ftgasp.h for the API.
BASE_EXTENSIONS += ftgasp.c
# Convenience functions to handle glyphs. Needs `ftbitmap.c'.
#
# See include/freetype/ftglyph.h for the API.
BASE_EXTENSIONS += ftglyph.c
# Interface for gxvalid module.
#
# See include/freetype/ftgxval.h for the API.
BASE_EXTENSIONS += ftgxval.c
# Multiple Master font interface.
#
# See include/freetype/ftmm.h for the API.
BASE_EXTENSIONS += ftmm.c
# Interface for otvalid module.
#
# See include/freetype/ftotval.h for the API.
BASE_EXTENSIONS += ftotval.c
# Support for FT_Face_CheckTrueTypePatents.
#
# See include/freetype/freetype.h for the API.
BASE_EXTENSIONS += ftpatent.c
# Interface for accessing PFR-specific data. Needs PFR font driver.
#
# See include/freetype/ftpfr.h for the API.
BASE_EXTENSIONS += ftpfr.c
# Path stroker. Needs `ftglyph.c'.
#
# See include/freetype/ftstroke.h for the API.
BASE_EXTENSIONS += ftstroke.c
# Support for synthetic emboldening and slanting of fonts. Needs
# `ftbitmap.c'.
#
# See include/freetype/ftsynth.h for the API.
BASE_EXTENSIONS += ftsynth.c
# Interface to access data specific to PostScript Type 1 and Type 2 (CFF)
# fonts.
#
# See include/freetype/t1tables.h for the API.
BASE_EXTENSIONS += fttype1.c
# Interface for accessing data specific to Windows FNT files. Needs winfnt
# driver.
#
# See include/freetype/ftwinfnt.h for the API.
BASE_EXTENSIONS += ftwinfnt.c
####
#### The components `ftsystem.c' (for memory allocation and stream I/O
#### management) and `ftdebug.c' (for emitting debug messages to the user)
#### are controlled with the following variables.
####
#### ftsystem.c: $(FTSYS_SRC)
#### ftdebug.c: $(FTDEBUG_SRC)
####
#### Please refer to docs/CUSTOMIZE for details.
####
# EOF
|
whupdup/frame
|
real/third_party/freetype-2.12.0/modules.cfg
|
INI
|
gpl-3.0
| 6,490
|
This directory contains all the object files created when building the
library.
|
whupdup/frame
|
real/third_party/freetype-2.12.0/objs/README
|
none
|
gpl-3.0
| 80
|
/* This file has been generated by the Perl script `afblue.pl', */
/* using data from file `afblue.dat'. */
/****************************************************************************
*
* afblue.c
*
* Auto-fitter data for blue strings (body).
*
* Copyright (C) 2013-2022 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.
*
*/
#include "aftypes.h"
FT_LOCAL_ARRAY_DEF( char )
af_blue_strings[] =
{
/* */
'\xF0', '\x9E', '\xA4', '\x8C', ' ', '\xF0', '\x9E', '\xA4', '\x85', ' ', '\xF0', '\x9E', '\xA4', '\x88', ' ', '\xF0', '\x9E', '\xA4', '\x8F', ' ', '\xF0', '\x9E', '\xA4', '\x94', ' ', '\xF0', '\x9E', '\xA4', '\x9A', /* 𞤌 𞤅 𞤈 𞤏 𞤔 𞤚 */
'\0',
'\xF0', '\x9E', '\xA4', '\x82', ' ', '\xF0', '\x9E', '\xA4', '\x96', /* 𞤂 𞤖 */
'\0',
'\xF0', '\x9E', '\xA4', '\xAC', ' ', '\xF0', '\x9E', '\xA4', '\xAE', ' ', '\xF0', '\x9E', '\xA4', '\xBB', ' ', '\xF0', '\x9E', '\xA4', '\xBC', ' ', '\xF0', '\x9E', '\xA4', '\xBE', /* 𞤬 𞤮 𞤻 𞤼 𞤾 */
'\0',
'\xF0', '\x9E', '\xA4', '\xA4', ' ', '\xF0', '\x9E', '\xA4', '\xA8', ' ', '\xF0', '\x9E', '\xA4', '\xA9', ' ', '\xF0', '\x9E', '\xA4', '\xAD', ' ', '\xF0', '\x9E', '\xA4', '\xB4', ' ', '\xF0', '\x9E', '\xA4', '\xB8', ' ', '\xF0', '\x9E', '\xA4', '\xBA', ' ', '\xF0', '\x9E', '\xA5', '\x80', /* 𞤤 𞤨 𞤩 𞤭 𞤴 𞤸 𞤺 𞥀 */
'\0',
'\xD8', '\xA7', ' ', '\xD8', '\xA5', ' ', '\xD9', '\x84', ' ', '\xD9', '\x83', ' ', '\xD8', '\xB7', ' ', '\xD8', '\xB8', /* ا إ ل ك ط ظ */
'\0',
'\xD8', '\xAA', ' ', '\xD8', '\xAB', ' ', '\xD8', '\xB7', ' ', '\xD8', '\xB8', ' ', '\xD9', '\x83', /* ت ث ط ظ ك */
'\0',
'\xD9', '\x80', /* ـ */
'\0',
'\xD4', '\xB1', ' ', '\xD5', '\x84', ' ', '\xD5', '\x92', ' ', '\xD5', '\x8D', ' ', '\xD4', '\xB2', ' ', '\xD4', '\xB3', ' ', '\xD4', '\xB4', ' ', '\xD5', '\x95', /* Ա Մ Ւ Ս Բ Գ Դ Օ */
'\0',
'\xD5', '\x92', ' ', '\xD5', '\x88', ' ', '\xD4', '\xB4', ' ', '\xD5', '\x83', ' ', '\xD5', '\x87', ' ', '\xD5', '\x8D', ' ', '\xD5', '\x8F', ' ', '\xD5', '\x95', /* Ւ Ո Դ Ճ Շ Ս Տ Օ */
'\0',
'\xD5', '\xA5', ' ', '\xD5', '\xA7', ' ', '\xD5', '\xAB', ' ', '\xD5', '\xB4', ' ', '\xD5', '\xBE', ' ', '\xD6', '\x86', ' ', '\xD5', '\xB3', /* ե է ի մ վ ֆ ճ */
'\0',
'\xD5', '\xA1', ' ', '\xD5', '\xB5', ' ', '\xD6', '\x82', ' ', '\xD5', '\xBD', ' ', '\xD5', '\xA3', ' ', '\xD5', '\xB7', ' ', '\xD6', '\x80', ' ', '\xD6', '\x85', /* ա յ ւ ս գ շ ր օ */
'\0',
'\xD5', '\xB0', ' ', '\xD5', '\xB8', ' ', '\xD5', '\xB3', ' ', '\xD5', '\xA1', ' ', '\xD5', '\xA5', ' ', '\xD5', '\xAE', ' ', '\xD5', '\xBD', ' ', '\xD6', '\x85', /* հ ո ճ ա ե ծ ս օ */
'\0',
'\xD5', '\xA2', ' ', '\xD5', '\xA8', ' ', '\xD5', '\xAB', ' ', '\xD5', '\xAC', ' ', '\xD5', '\xB2', ' ', '\xD5', '\xBA', ' ', '\xD6', '\x83', ' ', '\xD6', '\x81', /* բ ը ի լ ղ պ փ ց */
'\0',
'\xF0', '\x90', '\xAC', '\x80', ' ', '\xF0', '\x90', '\xAC', '\x81', ' ', '\xF0', '\x90', '\xAC', '\x90', ' ', '\xF0', '\x90', '\xAC', '\x9B', /* 𐬀 𐬁 𐬐 𐬛 */
'\0',
'\xF0', '\x90', '\xAC', '\x80', ' ', '\xF0', '\x90', '\xAC', '\x81', /* 𐬀 𐬁 */
'\0',
'\xEA', '\x9A', '\xA7', ' ', '\xEA', '\x9A', '\xA8', ' ', '\xEA', '\x9B', '\x9B', ' ', '\xEA', '\x9B', '\x89', ' ', '\xEA', '\x9B', '\x81', ' ', '\xEA', '\x9B', '\x88', ' ', '\xEA', '\x9B', '\xAB', ' ', '\xEA', '\x9B', '\xAF', /* ꚧ ꚨ ꛛ ꛉ ꛁ ꛈ ꛫ ꛯ */
'\0',
'\xEA', '\x9A', '\xAD', ' ', '\xEA', '\x9A', '\xB3', ' ', '\xEA', '\x9A', '\xB6', ' ', '\xEA', '\x9B', '\xAC', ' ', '\xEA', '\x9A', '\xA2', ' ', '\xEA', '\x9A', '\xBD', ' ', '\xEA', '\x9B', '\xAF', ' ', '\xEA', '\x9B', '\xB2', /* ꚭ ꚳ ꚶ ꛬ ꚢ ꚽ ꛯ ꛲ */
'\0',
'\xE0', '\xA6', '\x85', ' ', '\xE0', '\xA6', '\xA1', ' ', '\xE0', '\xA6', '\xA4', ' ', '\xE0', '\xA6', '\xA8', ' ', '\xE0', '\xA6', '\xAC', ' ', '\xE0', '\xA6', '\xAD', ' ', '\xE0', '\xA6', '\xB2', ' ', '\xE0', '\xA6', '\x95', /* অ ড ত ন ব ভ ল ক */
'\0',
'\xE0', '\xA6', '\x87', ' ', '\xE0', '\xA6', '\x9F', ' ', '\xE0', '\xA6', '\xA0', ' ', '\xE0', '\xA6', '\xBF', ' ', '\xE0', '\xA7', '\x80', ' ', '\xE0', '\xA7', '\x88', ' ', '\xE0', '\xA7', '\x97', /* ই ট ঠ ি ী ৈ ৗ */
'\0',
'\xE0', '\xA6', '\x93', ' ', '\xE0', '\xA6', '\x8F', ' ', '\xE0', '\xA6', '\xA1', ' ', '\xE0', '\xA6', '\xA4', ' ', '\xE0', '\xA6', '\xA8', ' ', '\xE0', '\xA6', '\xAC', ' ', '\xE0', '\xA6', '\xB2', ' ', '\xE0', '\xA6', '\x95', /* ও এ ড ত ন ব ল ক */
'\0',
'\xE1', '\x9D', '\x90', ' ', '\xE1', '\x9D', '\x88', /* ᝐ ᝈ */
'\0',
'\xE1', '\x9D', '\x85', ' ', '\xE1', '\x9D', '\x8A', ' ', '\xE1', '\x9D', '\x8E', /* ᝅ ᝊ ᝎ */
'\0',
'\xE1', '\x9D', '\x82', ' ', '\xE1', '\x9D', '\x83', ' ', '\xE1', '\x9D', '\x89', ' ', '\xE1', '\x9D', '\x8C', /* ᝂ ᝃ ᝉ ᝌ */
'\0',
'\xE1', '\x9D', '\x80', ' ', '\xE1', '\x9D', '\x83', ' ', '\xE1', '\x9D', '\x86', ' ', '\xE1', '\x9D', '\x89', ' ', '\xE1', '\x9D', '\x8B', ' ', '\xE1', '\x9D', '\x8F', ' ', '\xE1', '\x9D', '\x91', /* ᝀ ᝃ ᝆ ᝉ ᝋ ᝏ ᝑ */
'\0',
'\xE1', '\x97', '\x9C', ' ', '\xE1', '\x96', '\xB4', ' ', '\xE1', '\x90', '\x81', ' ', '\xE1', '\x92', '\xA3', ' ', '\xE1', '\x91', '\xAB', ' ', '\xE1', '\x91', '\x8E', ' ', '\xE1', '\x94', '\x91', ' ', '\xE1', '\x97', '\xB0', /* ᗜ ᖴ ᐁ ᒣ ᑫ ᑎ ᔑ ᗰ */
'\0',
'\xE1', '\x97', '\xB6', ' ', '\xE1', '\x96', '\xB5', ' ', '\xE1', '\x92', '\xA7', ' ', '\xE1', '\x90', '\x83', ' ', '\xE1', '\x91', '\x8C', ' ', '\xE1', '\x92', '\x8D', ' ', '\xE1', '\x94', '\x91', ' ', '\xE1', '\x97', '\xA2', /* ᗶ ᖵ ᒧ ᐃ ᑌ ᒍ ᔑ ᗢ */
'\0',
'\xE1', '\x93', '\x93', ' ', '\xE1', '\x93', '\x95', ' ', '\xE1', '\x93', '\x80', ' ', '\xE1', '\x93', '\x82', ' ', '\xE1', '\x93', '\x84', ' ', '\xE1', '\x95', '\x84', ' ', '\xE1', '\x95', '\x86', ' ', '\xE1', '\x98', '\xA3', /* ᓓ ᓕ ᓀ ᓂ ᓄ ᕄ ᕆ ᘣ */
'\0',
'\xE1', '\x95', '\x83', ' ', '\xE1', '\x93', '\x82', ' ', '\xE1', '\x93', '\x80', ' ', '\xE1', '\x95', '\x82', ' ', '\xE1', '\x93', '\x97', ' ', '\xE1', '\x93', '\x9A', ' ', '\xE1', '\x95', '\x86', ' ', '\xE1', '\x98', '\xA3', /* ᕃ ᓂ ᓀ ᕂ ᓗ ᓚ ᕆ ᘣ */
'\0',
'\xE1', '\x90', '\xAA', ' ', '\xE1', '\x99', '\x86', ' ', '\xE1', '\xA3', '\x98', ' ', '\xE1', '\x90', '\xA2', ' ', '\xE1', '\x92', '\xBE', ' ', '\xE1', '\xA3', '\x97', ' ', '\xE1', '\x94', '\x86', /* ᐪ ᙆ ᣘ ᐢ ᒾ ᣗ ᔆ */
'\0',
'\xE1', '\x99', '\x86', ' ', '\xE1', '\x97', '\xAE', ' ', '\xE1', '\x92', '\xBB', ' ', '\xE1', '\x90', '\x9E', ' ', '\xE1', '\x94', '\x86', ' ', '\xE1', '\x92', '\xA1', ' ', '\xE1', '\x92', '\xA2', ' ', '\xE1', '\x93', '\x91', /* ᙆ ᗮ ᒻ ᐞ ᔆ ᒡ ᒢ ᓑ */
'\0',
'\xF0', '\x90', '\x8A', '\xA7', ' ', '\xF0', '\x90', '\x8A', '\xAB', ' ', '\xF0', '\x90', '\x8A', '\xAC', ' ', '\xF0', '\x90', '\x8A', '\xAD', ' ', '\xF0', '\x90', '\x8A', '\xB1', ' ', '\xF0', '\x90', '\x8A', '\xBA', ' ', '\xF0', '\x90', '\x8A', '\xBC', ' ', '\xF0', '\x90', '\x8A', '\xBF', /* 𐊧 𐊫 𐊬 𐊭 𐊱 𐊺 𐊼 𐊿 */
'\0',
'\xF0', '\x90', '\x8A', '\xA3', ' ', '\xF0', '\x90', '\x8A', '\xA7', ' ', '\xF0', '\x90', '\x8A', '\xB7', ' ', '\xF0', '\x90', '\x8B', '\x80', ' ', '\xF0', '\x90', '\x8A', '\xAB', ' ', '\xF0', '\x90', '\x8A', '\xB8', ' ', '\xF0', '\x90', '\x8B', '\x89', /* 𐊣 𐊧 𐊷 𐋀 𐊫 𐊸 𐋉 */
'\0',
'\xF0', '\x91', '\x84', '\x83', ' ', '\xF0', '\x91', '\x84', '\x85', ' ', '\xF0', '\x91', '\x84', '\x89', ' ', '\xF0', '\x91', '\x84', '\x99', ' ', '\xF0', '\x91', '\x84', '\x97', /* 𑄃 𑄅 𑄉 𑄙 𑄗 */
'\0',
'\xF0', '\x91', '\x84', '\x85', ' ', '\xF0', '\x91', '\x84', '\x9B', ' ', '\xF0', '\x91', '\x84', '\x9D', ' ', '\xF0', '\x91', '\x84', '\x97', ' ', '\xF0', '\x91', '\x84', '\x93', /* 𑄅 𑄛 𑄝 𑄗 𑄓 */
'\0',
'\xF0', '\x91', '\x84', '\x96', '\xF0', '\x91', '\x84', '\xB3', '\xF0', '\x91', '\x84', '\xA2', ' ', '\xF0', '\x91', '\x84', '\x98', '\xF0', '\x91', '\x84', '\xB3', '\xF0', '\x91', '\x84', '\xA2', ' ', '\xF0', '\x91', '\x84', '\x99', '\xF0', '\x91', '\x84', '\xB3', '\xF0', '\x91', '\x84', '\xA2', ' ', '\xF0', '\x91', '\x84', '\xA4', '\xF0', '\x91', '\x84', '\xB3', '\xF0', '\x91', '\x84', '\xA2', ' ', '\xF0', '\x91', '\x84', '\xA5', '\xF0', '\x91', '\x84', '\xB3', '\xF0', '\x91', '\x84', '\xA2', /* 𑄖𑄳𑄢 𑄘𑄳𑄢 𑄙𑄳𑄢 𑄤𑄳𑄢 𑄥𑄳𑄢 */
'\0',
'\xE1', '\x8F', '\x86', ' ', '\xE1', '\x8E', '\xBB', ' ', '\xE1', '\x8E', '\xAC', ' ', '\xE1', '\x8F', '\x83', ' ', '\xE1', '\x8E', '\xA4', ' ', '\xE1', '\x8F', '\xA3', ' ', '\xE1', '\x8E', '\xA6', ' ', '\xE1', '\x8F', '\x95', /* Ꮖ Ꮋ Ꭼ Ꮓ Ꭴ Ꮳ Ꭶ Ꮥ */
'\0',
'\xEA', '\xAE', '\x92', ' ', '\xEA', '\xAE', '\xA4', ' ', '\xEA', '\xAE', '\xB6', ' ', '\xEA', '\xAD', '\xB4', ' ', '\xEA', '\xAD', '\xBE', ' ', '\xEA', '\xAE', '\x97', ' ', '\xEA', '\xAE', '\x9D', ' ', '\xEA', '\xAE', '\xBF', /* ꮒ ꮤ ꮶ ꭴ ꭾ ꮗ ꮝ ꮿ */
'\0',
'\xEA', '\xAE', '\x96', ' ', '\xEA', '\xAD', '\xBC', ' ', '\xEA', '\xAE', '\x93', ' ', '\xEA', '\xAE', '\xA0', ' ', '\xEA', '\xAE', '\xB3', ' ', '\xEA', '\xAD', '\xB6', ' ', '\xEA', '\xAE', '\xA5', ' ', '\xEA', '\xAE', '\xBB', /* ꮖ ꭼ ꮓ ꮠ ꮳ ꭶ ꮥ ꮻ */
'\0',
'\xE1', '\x8F', '\xB8', ' ', '\xEA', '\xAE', '\x90', ' ', '\xEA', '\xAD', '\xB9', ' ', '\xEA', '\xAD', '\xBB', /* ᏸ ꮐ ꭹ ꭻ */
'\0',
'\xE2', '\xB2', '\x8C', ' ', '\xE2', '\xB2', '\x8E', ' ', '\xE2', '\xB2', '\xA0', ' ', '\xE2', '\xB3', '\x9E', ' ', '\xE2', '\xB2', '\x9E', ' ', '\xE2', '\xB2', '\x90', ' ', '\xE2', '\xB2', '\xA4', ' ', '\xE2', '\xB3', '\x8A', /* Ⲍ Ⲏ Ⲡ Ⳟ Ⲟ Ⲑ Ⲥ Ⳋ */
'\0',
'\xE2', '\xB3', '\x90', ' ', '\xE2', '\xB3', '\x98', ' ', '\xE2', '\xB3', '\x9E', ' ', '\xE2', '\xB2', '\x8E', ' ', '\xE2', '\xB2', '\x9E', ' ', '\xE2', '\xB2', '\x90', ' ', '\xE2', '\xB3', '\x9C', ' ', '\xE2', '\xB2', '\xB0', /* Ⳑ Ⳙ Ⳟ Ⲏ Ⲟ Ⲑ Ⳝ Ⲱ */
'\0',
'\xE2', '\xB2', '\x8D', ' ', '\xE2', '\xB2', '\x8F', ' ', '\xE2', '\xB2', '\xA1', ' ', '\xE2', '\xB3', '\x9F', ' ', '\xE2', '\xB2', '\x9F', ' ', '\xE2', '\xB2', '\x91', ' ', '\xE2', '\xB2', '\xA5', ' ', '\xE2', '\xB3', '\x8B', /* ⲍ ⲏ ⲡ ⳟ ⲟ ⲑ ⲥ ⳋ */
'\0',
'\xE2', '\xB3', '\x91', ' ', '\xE2', '\xB3', '\x99', ' ', '\xE2', '\xB3', '\x9F', ' ', '\xE2', '\xB2', '\x8F', ' ', '\xE2', '\xB2', '\x9F', ' ', '\xE2', '\xB2', '\x91', ' ', '\xE2', '\xB3', '\x9D', ' ', '\xE2', '\xB3', '\x92', /* ⳑ ⳙ ⳟ ⲏ ⲟ ⲑ ⳝ Ⳓ */
'\0',
'\xF0', '\x90', '\xA0', '\x8D', ' ', '\xF0', '\x90', '\xA0', '\x99', ' ', '\xF0', '\x90', '\xA0', '\xB3', ' ', '\xF0', '\x90', '\xA0', '\xB1', ' ', '\xF0', '\x90', '\xA0', '\x85', ' ', '\xF0', '\x90', '\xA0', '\x93', ' ', '\xF0', '\x90', '\xA0', '\xA3', ' ', '\xF0', '\x90', '\xA0', '\xA6', /* 𐠍 𐠙 𐠳 𐠱 𐠅 𐠓 𐠣 𐠦 */
'\0',
'\xF0', '\x90', '\xA0', '\x83', ' ', '\xF0', '\x90', '\xA0', '\x8A', ' ', '\xF0', '\x90', '\xA0', '\x9B', ' ', '\xF0', '\x90', '\xA0', '\xA3', ' ', '\xF0', '\x90', '\xA0', '\xB3', ' ', '\xF0', '\x90', '\xA0', '\xB5', ' ', '\xF0', '\x90', '\xA0', '\x90', /* 𐠃 𐠊 𐠛 𐠣 𐠳 𐠵 𐠐 */
'\0',
'\xF0', '\x90', '\xA0', '\x88', ' ', '\xF0', '\x90', '\xA0', '\x8F', ' ', '\xF0', '\x90', '\xA0', '\x96', /* 𐠈 𐠏 𐠖 */
'\0',
'\xD0', '\x91', ' ', '\xD0', '\x92', ' ', '\xD0', '\x95', ' ', '\xD0', '\x9F', ' ', '\xD0', '\x97', ' ', '\xD0', '\x9E', ' ', '\xD0', '\xA1', ' ', '\xD0', '\xAD', /* Б В Е П З О С Э */
'\0',
'\xD0', '\x91', ' ', '\xD0', '\x92', ' ', '\xD0', '\x95', ' ', '\xD0', '\xA8', ' ', '\xD0', '\x97', ' ', '\xD0', '\x9E', ' ', '\xD0', '\xA1', ' ', '\xD0', '\xAD', /* Б В Е Ш З О С Э */
'\0',
'\xD1', '\x85', ' ', '\xD0', '\xBF', ' ', '\xD0', '\xBD', ' ', '\xD1', '\x88', ' ', '\xD0', '\xB5', ' ', '\xD0', '\xB7', ' ', '\xD0', '\xBE', ' ', '\xD1', '\x81', /* х п н ш е з о с */
'\0',
'\xD1', '\x80', ' ', '\xD1', '\x83', ' ', '\xD1', '\x84', /* р у ф */
'\0',
'\xF0', '\x90', '\x90', '\x82', ' ', '\xF0', '\x90', '\x90', '\x84', ' ', '\xF0', '\x90', '\x90', '\x8B', ' ', '\xF0', '\x90', '\x90', '\x97', ' ', '\xF0', '\x90', '\x90', '\x91', /* 𐐂 𐐄 𐐋 𐐗 𐐑 */
'\0',
'\xF0', '\x90', '\x90', '\x80', ' ', '\xF0', '\x90', '\x90', '\x82', ' ', '\xF0', '\x90', '\x90', '\x84', ' ', '\xF0', '\x90', '\x90', '\x97', ' ', '\xF0', '\x90', '\x90', '\x9B', /* 𐐀 𐐂 𐐄 𐐗 𐐛 */
'\0',
'\xF0', '\x90', '\x90', '\xAA', ' ', '\xF0', '\x90', '\x90', '\xAC', ' ', '\xF0', '\x90', '\x90', '\xB3', ' ', '\xF0', '\x90', '\x90', '\xBF', ' ', '\xF0', '\x90', '\x90', '\xB9', /* 𐐪 𐐬 𐐳 𐐿 𐐹 */
'\0',
'\xF0', '\x90', '\x90', '\xA8', ' ', '\xF0', '\x90', '\x90', '\xAA', ' ', '\xF0', '\x90', '\x90', '\xAC', ' ', '\xF0', '\x90', '\x90', '\xBF', ' ', '\xF0', '\x90', '\x91', '\x83', /* 𐐨 𐐪 𐐬 𐐿 𐑃 */
'\0',
'\xE0', '\xA4', '\x95', ' ', '\xE0', '\xA4', '\xA8', ' ', '\xE0', '\xA4', '\xAE', ' ', '\xE0', '\xA4', '\x89', ' ', '\xE0', '\xA4', '\x9B', ' ', '\xE0', '\xA4', '\x9F', ' ', '\xE0', '\xA4', '\xA0', ' ', '\xE0', '\xA4', '\xA1', /* क न म उ छ ट ठ ड */
'\0',
'\xE0', '\xA4', '\x88', ' ', '\xE0', '\xA4', '\x90', ' ', '\xE0', '\xA4', '\x93', ' ', '\xE0', '\xA4', '\x94', ' ', '\xE0', '\xA4', '\xBF', ' ', '\xE0', '\xA5', '\x80', ' ', '\xE0', '\xA5', '\x8B', ' ', '\xE0', '\xA5', '\x8C', /* ई ऐ ओ औ ि ी ो ौ */
'\0',
'\xE0', '\xA4', '\x95', ' ', '\xE0', '\xA4', '\xAE', ' ', '\xE0', '\xA4', '\x85', ' ', '\xE0', '\xA4', '\x86', ' ', '\xE0', '\xA4', '\xA5', ' ', '\xE0', '\xA4', '\xA7', ' ', '\xE0', '\xA4', '\xAD', ' ', '\xE0', '\xA4', '\xB6', /* क म अ आ थ ध भ श */
'\0',
'\xE0', '\xA5', '\x81', ' ', '\xE0', '\xA5', '\x83', /* ु ृ */
'\0',
'\xE1', '\x88', '\x80', ' ', '\xE1', '\x88', '\x83', ' ', '\xE1', '\x8B', '\x98', ' ', '\xE1', '\x8D', '\x90', ' ', '\xE1', '\x88', '\x9B', ' ', '\xE1', '\x89', '\xA0', ' ', '\xE1', '\x8B', '\x8B', ' ', '\xE1', '\x8B', '\x90', /* ሀ ሃ ዘ ፐ ማ በ ዋ ዐ */
'\0',
'\xE1', '\x88', '\x88', ' ', '\xE1', '\x88', '\x90', ' ', '\xE1', '\x89', '\xA0', ' ', '\xE1', '\x8B', '\x98', ' ', '\xE1', '\x88', '\x80', ' ', '\xE1', '\x88', '\xAA', ' ', '\xE1', '\x8B', '\x90', ' ', '\xE1', '\x8C', '\xA8', /* ለ ሐ በ ዘ ሀ ሪ ዐ ጨ */
'\0',
'\xE1', '\x83', '\x92', ' ', '\xE1', '\x83', '\x93', ' ', '\xE1', '\x83', '\x94', ' ', '\xE1', '\x83', '\x95', ' ', '\xE1', '\x83', '\x97', ' ', '\xE1', '\x83', '\x98', ' ', '\xE1', '\x83', '\x9D', ' ', '\xE1', '\x83', '\xA6', /* გ დ ე ვ თ ი ო ღ */
'\0',
'\xE1', '\x83', '\x90', ' ', '\xE1', '\x83', '\x96', ' ', '\xE1', '\x83', '\x9B', ' ', '\xE1', '\x83', '\xA1', ' ', '\xE1', '\x83', '\xA8', ' ', '\xE1', '\x83', '\xAB', ' ', '\xE1', '\x83', '\xAE', ' ', '\xE1', '\x83', '\x9E', /* ა ზ მ ს შ ძ ხ პ */
'\0',
'\xE1', '\x83', '\xA1', ' ', '\xE1', '\x83', '\xAE', ' ', '\xE1', '\x83', '\xA5', ' ', '\xE1', '\x83', '\x96', ' ', '\xE1', '\x83', '\x9B', ' ', '\xE1', '\x83', '\xA8', ' ', '\xE1', '\x83', '\xA9', ' ', '\xE1', '\x83', '\xAC', /* ს ხ ქ ზ მ შ ჩ წ */
'\0',
'\xE1', '\x83', '\x94', ' ', '\xE1', '\x83', '\x95', ' ', '\xE1', '\x83', '\x9F', ' ', '\xE1', '\x83', '\xA2', ' ', '\xE1', '\x83', '\xA3', ' ', '\xE1', '\x83', '\xA4', ' ', '\xE1', '\x83', '\xA5', ' ', '\xE1', '\x83', '\xA7', /* ე ვ ჟ ტ უ ფ ქ ყ */
'\0',
'\xE1', '\x82', '\xB1', ' ', '\xE1', '\x82', '\xA7', ' ', '\xE1', '\x82', '\xB9', ' ', '\xE1', '\x82', '\xBC', ' ', '\xE1', '\x82', '\xA4', ' ', '\xE1', '\x82', '\xA5', ' ', '\xE1', '\x82', '\xB3', ' ', '\xE1', '\x82', '\xBA', /* Ⴑ Ⴇ Ⴙ Ⴜ Ⴄ Ⴅ Ⴓ Ⴚ */
'\0',
'\xE1', '\x82', '\xA4', ' ', '\xE1', '\x82', '\xA5', ' ', '\xE1', '\x82', '\xA7', ' ', '\xE1', '\x82', '\xA8', ' ', '\xE1', '\x82', '\xA6', ' ', '\xE1', '\x82', '\xB1', ' ', '\xE1', '\x82', '\xAA', ' ', '\xE1', '\x82', '\xAB', /* Ⴄ Ⴅ Ⴇ Ⴈ Ⴆ Ⴑ Ⴊ Ⴋ */
'\0',
'\xE2', '\xB4', '\x81', ' ', '\xE2', '\xB4', '\x97', ' ', '\xE2', '\xB4', '\x82', ' ', '\xE2', '\xB4', '\x84', ' ', '\xE2', '\xB4', '\x85', ' ', '\xE2', '\xB4', '\x87', ' ', '\xE2', '\xB4', '\x94', ' ', '\xE2', '\xB4', '\x96', /* ⴁ ⴗ ⴂ ⴄ ⴅ ⴇ ⴔ ⴖ */
'\0',
'\xE2', '\xB4', '\x88', ' ', '\xE2', '\xB4', '\x8C', ' ', '\xE2', '\xB4', '\x96', ' ', '\xE2', '\xB4', '\x8E', ' ', '\xE2', '\xB4', '\x83', ' ', '\xE2', '\xB4', '\x86', ' ', '\xE2', '\xB4', '\x8B', ' ', '\xE2', '\xB4', '\xA2', /* ⴈ ⴌ ⴖ ⴎ ⴃ ⴆ ⴋ ⴢ */
'\0',
'\xE2', '\xB4', '\x90', ' ', '\xE2', '\xB4', '\x91', ' ', '\xE2', '\xB4', '\x93', ' ', '\xE2', '\xB4', '\x95', ' ', '\xE2', '\xB4', '\x99', ' ', '\xE2', '\xB4', '\x9B', ' ', '\xE2', '\xB4', '\xA1', ' ', '\xE2', '\xB4', '\xA3', /* ⴐ ⴑ ⴓ ⴕ ⴙ ⴛ ⴡ ⴣ */
'\0',
'\xE2', '\xB4', '\x84', ' ', '\xE2', '\xB4', '\x85', ' ', '\xE2', '\xB4', '\x94', ' ', '\xE2', '\xB4', '\x95', ' ', '\xE2', '\xB4', '\x81', ' ', '\xE2', '\xB4', '\x82', ' ', '\xE2', '\xB4', '\x98', ' ', '\xE2', '\xB4', '\x9D', /* ⴄ ⴅ ⴔ ⴕ ⴁ ⴂ ⴘ ⴝ */
'\0',
'\xE1', '\xB2', '\x9C', ' ', '\xE1', '\xB2', '\x9F', ' ', '\xE1', '\xB2', '\xB3', ' ', '\xE1', '\xB2', '\xB8', ' ', '\xE1', '\xB2', '\x92', ' ', '\xE1', '\xB2', '\x94', ' ', '\xE1', '\xB2', '\x9D', ' ', '\xE1', '\xB2', '\xB4', /* Ნ Ჟ Ჳ Ჸ Გ Ე Ო Ჴ */
'\0',
'\xE1', '\xB2', '\x98', ' ', '\xE1', '\xB2', '\xB2', ' ', '\xE1', '\xB2', '\x9D', ' ', '\xE1', '\xB2', '\xA9', ' ', '\xE1', '\xB2', '\x9B', ' ', '\xE1', '\xB2', '\xA8', ' ', '\xE1', '\xB2', '\xAF', ' ', '\xE1', '\xB2', '\xBD', /* Ი Ჲ Ო Ჩ Მ Შ Ჯ Ჽ */
'\0',
'\xE2', '\xB0', '\x85', ' ', '\xE2', '\xB0', '\x94', ' ', '\xE2', '\xB0', '\xAA', ' ', '\xE2', '\xB0', '\x84', ' ', '\xE2', '\xB0', '\x82', ' ', '\xE2', '\xB0', '\x8A', ' ', '\xE2', '\xB0', '\xAB', ' ', '\xE2', '\xB0', '\x8B', /* Ⰵ Ⱄ Ⱚ Ⰴ Ⰲ Ⰺ Ⱛ Ⰻ */
'\0',
'\xE2', '\xB0', '\x85', ' ', '\xE2', '\xB0', '\x84', ' ', '\xE2', '\xB0', '\x82', ' ', '\xE2', '\xB0', '\xAA', ' ', '\xE2', '\xB0', '\x9E', ' ', '\xE2', '\xB0', '\xA1', ' ', '\xE2', '\xB0', '\x8A', ' ', '\xE2', '\xB0', '\x94', /* Ⰵ Ⰴ Ⰲ Ⱚ Ⱎ Ⱑ Ⰺ Ⱄ */
'\0',
'\xE2', '\xB0', '\xB5', ' ', '\xE2', '\xB1', '\x84', ' ', '\xE2', '\xB1', '\x9A', ' ', '\xE2', '\xB0', '\xB4', ' ', '\xE2', '\xB0', '\xB2', ' ', '\xE2', '\xB0', '\xBA', ' ', '\xE2', '\xB1', '\x9B', ' ', '\xE2', '\xB0', '\xBB', /* ⰵ ⱄ ⱚ ⰴ ⰲ ⰺ ⱛ ⰻ */
'\0',
'\xE2', '\xB0', '\xB5', ' ', '\xE2', '\xB0', '\xB4', ' ', '\xE2', '\xB0', '\xB2', ' ', '\xE2', '\xB1', '\x9A', ' ', '\xE2', '\xB1', '\x8E', ' ', '\xE2', '\xB1', '\x91', ' ', '\xE2', '\xB0', '\xBA', ' ', '\xE2', '\xB1', '\x84', /* ⰵ ⰴ ⰲ ⱚ ⱎ ⱑ ⰺ ⱄ */
'\0',
'\xF0', '\x90', '\x8C', '\xB2', ' ', '\xF0', '\x90', '\x8C', '\xB6', ' ', '\xF0', '\x90', '\x8D', '\x80', ' ', '\xF0', '\x90', '\x8D', '\x84', ' ', '\xF0', '\x90', '\x8C', '\xB4', ' ', '\xF0', '\x90', '\x8D', '\x83', ' ', '\xF0', '\x90', '\x8D', '\x88', ' ', '\xF0', '\x90', '\x8C', '\xBE', /* 𐌲 𐌶 𐍀 𐍄 𐌴 𐍃 𐍈 𐌾 */
'\0',
'\xF0', '\x90', '\x8C', '\xB6', ' ', '\xF0', '\x90', '\x8C', '\xB4', ' ', '\xF0', '\x90', '\x8D', '\x83', ' ', '\xF0', '\x90', '\x8D', '\x88', /* 𐌶 𐌴 𐍃 𐍈 */
'\0',
'\xCE', '\x93', ' ', '\xCE', '\x92', ' ', '\xCE', '\x95', ' ', '\xCE', '\x96', ' ', '\xCE', '\x98', ' ', '\xCE', '\x9F', ' ', '\xCE', '\xA9', /* Γ Β Ε Ζ Θ Ο Ω */
'\0',
'\xCE', '\x92', ' ', '\xCE', '\x94', ' ', '\xCE', '\x96', ' ', '\xCE', '\x9E', ' ', '\xCE', '\x98', ' ', '\xCE', '\x9F', /* Β Δ Ζ Ξ Θ Ο */
'\0',
'\xCE', '\xB2', ' ', '\xCE', '\xB8', ' ', '\xCE', '\xB4', ' ', '\xCE', '\xB6', ' ', '\xCE', '\xBB', ' ', '\xCE', '\xBE', /* β θ δ ζ λ ξ */
'\0',
'\xCE', '\xB1', ' ', '\xCE', '\xB5', ' ', '\xCE', '\xB9', ' ', '\xCE', '\xBF', ' ', '\xCF', '\x80', ' ', '\xCF', '\x83', ' ', '\xCF', '\x84', ' ', '\xCF', '\x89', /* α ε ι ο π σ τ ω */
'\0',
'\xCE', '\xB2', ' ', '\xCE', '\xB3', ' ', '\xCE', '\xB7', ' ', '\xCE', '\xBC', ' ', '\xCF', '\x81', ' ', '\xCF', '\x86', ' ', '\xCF', '\x87', ' ', '\xCF', '\x88', /* β γ η μ ρ φ χ ψ */
'\0',
'\xE0', '\xAA', '\xA4', ' ', '\xE0', '\xAA', '\xA8', ' ', '\xE0', '\xAA', '\x8B', ' ', '\xE0', '\xAA', '\x8C', ' ', '\xE0', '\xAA', '\x9B', ' ', '\xE0', '\xAA', '\x9F', ' ', '\xE0', '\xAA', '\xB0', ' ', '\xE0', '\xAB', '\xA6', /* ત ન ઋ ઌ છ ટ ર ૦ */
'\0',
'\xE0', '\xAA', '\x96', ' ', '\xE0', '\xAA', '\x97', ' ', '\xE0', '\xAA', '\x98', ' ', '\xE0', '\xAA', '\x9E', ' ', '\xE0', '\xAA', '\x87', ' ', '\xE0', '\xAA', '\x88', ' ', '\xE0', '\xAA', '\xA0', ' ', '\xE0', '\xAA', '\x9C', /* ખ ગ ઘ ઞ ઇ ઈ ઠ જ */
'\0',
'\xE0', '\xAA', '\x88', ' ', '\xE0', '\xAA', '\x8A', ' ', '\xE0', '\xAA', '\xBF', ' ', '\xE0', '\xAB', '\x80', ' ', '\xE0', '\xAA', '\xB2', '\xE0', '\xAB', '\x80', ' ', '\xE0', '\xAA', '\xB6', '\xE0', '\xAB', '\x8D', '\xE0', '\xAA', '\x9A', '\xE0', '\xAA', '\xBF', ' ', '\xE0', '\xAA', '\x9C', '\xE0', '\xAA', '\xBF', ' ', '\xE0', '\xAA', '\xB8', '\xE0', '\xAB', '\x80', /* ઈ ઊ િ ી લી શ્ચિ જિ સી */
'\0',
'\xE0', '\xAB', '\x81', ' ', '\xE0', '\xAB', '\x83', ' ', '\xE0', '\xAB', '\x84', ' ', '\xE0', '\xAA', '\x96', '\xE0', '\xAB', '\x81', ' ', '\xE0', '\xAA', '\x9B', '\xE0', '\xAB', '\x83', ' ', '\xE0', '\xAA', '\x9B', '\xE0', '\xAB', '\x84', /* ુ ૃ ૄ ખુ છૃ છૄ */
'\0',
'\xE0', '\xAB', '\xA6', ' ', '\xE0', '\xAB', '\xA7', ' ', '\xE0', '\xAB', '\xA8', ' ', '\xE0', '\xAB', '\xA9', ' ', '\xE0', '\xAB', '\xAD', /* ૦ ૧ ૨ ૩ ૭ */
'\0',
'\xE0', '\xA8', '\x95', ' ', '\xE0', '\xA8', '\x97', ' ', '\xE0', '\xA8', '\x99', ' ', '\xE0', '\xA8', '\x9A', ' ', '\xE0', '\xA8', '\x9C', ' ', '\xE0', '\xA8', '\xA4', ' ', '\xE0', '\xA8', '\xA7', ' ', '\xE0', '\xA8', '\xB8', /* ਕ ਗ ਙ ਚ ਜ ਤ ਧ ਸ */
'\0',
'\xE0', '\xA8', '\x95', ' ', '\xE0', '\xA8', '\x97', ' ', '\xE0', '\xA8', '\x99', ' ', '\xE0', '\xA8', '\x9A', ' ', '\xE0', '\xA8', '\x9C', ' ', '\xE0', '\xA8', '\xA4', ' ', '\xE0', '\xA8', '\xA7', ' ', '\xE0', '\xA8', '\xB8', /* ਕ ਗ ਙ ਚ ਜ ਤ ਧ ਸ */
'\0',
'\xE0', '\xA8', '\x87', ' ', '\xE0', '\xA8', '\x88', ' ', '\xE0', '\xA8', '\x89', ' ', '\xE0', '\xA8', '\x8F', ' ', '\xE0', '\xA8', '\x93', ' ', '\xE0', '\xA9', '\xB3', ' ', '\xE0', '\xA8', '\xBF', ' ', '\xE0', '\xA9', '\x80', /* ਇ ਈ ਉ ਏ ਓ ੳ ਿ ੀ */
'\0',
'\xE0', '\xA8', '\x85', ' ', '\xE0', '\xA8', '\x8F', ' ', '\xE0', '\xA8', '\x93', ' ', '\xE0', '\xA8', '\x97', ' ', '\xE0', '\xA8', '\x9C', ' ', '\xE0', '\xA8', '\xA0', ' ', '\xE0', '\xA8', '\xB0', ' ', '\xE0', '\xA8', '\xB8', /* ਅ ਏ ਓ ਗ ਜ ਠ ਰ ਸ */
'\0',
'\xE0', '\xA9', '\xA6', ' ', '\xE0', '\xA9', '\xA7', ' ', '\xE0', '\xA9', '\xA8', ' ', '\xE0', '\xA9', '\xA9', ' ', '\xE0', '\xA9', '\xAD', /* ੦ ੧ ੨ ੩ ੭ */
'\0',
'\xD7', '\x91', ' ', '\xD7', '\x93', ' ', '\xD7', '\x94', ' ', '\xD7', '\x97', ' ', '\xD7', '\x9A', ' ', '\xD7', '\x9B', ' ', '\xD7', '\x9D', ' ', '\xD7', '\xA1', /* ב ד ה ח ך כ ם ס */
'\0',
'\xD7', '\x91', ' ', '\xD7', '\x98', ' ', '\xD7', '\x9B', ' ', '\xD7', '\x9D', ' ', '\xD7', '\xA1', ' ', '\xD7', '\xA6', /* ב ט כ ם ס צ */
'\0',
'\xD7', '\xA7', ' ', '\xD7', '\x9A', ' ', '\xD7', '\x9F', ' ', '\xD7', '\xA3', ' ', '\xD7', '\xA5', /* ק ך ן ף ץ */
'\0',
'\xE0', '\xB2', '\x87', ' ', '\xE0', '\xB2', '\x8A', ' ', '\xE0', '\xB2', '\x90', ' ', '\xE0', '\xB2', '\xA3', ' ', '\xE0', '\xB2', '\xB8', '\xE0', '\xB2', '\xBE', ' ', '\xE0', '\xB2', '\xA8', '\xE0', '\xB2', '\xBE', ' ', '\xE0', '\xB2', '\xA6', '\xE0', '\xB2', '\xBE', ' ', '\xE0', '\xB2', '\xB0', '\xE0', '\xB2', '\xBE', /* ಇ ಊ ಐ ಣ ಸಾ ನಾ ದಾ ರಾ */
'\0',
'\xE0', '\xB2', '\x85', ' ', '\xE0', '\xB2', '\x89', ' ', '\xE0', '\xB2', '\x8E', ' ', '\xE0', '\xB2', '\xB2', ' ', '\xE0', '\xB3', '\xA6', ' ', '\xE0', '\xB3', '\xA8', ' ', '\xE0', '\xB3', '\xAC', ' ', '\xE0', '\xB3', '\xAD', /* ಅ ಉ ಎ ಲ ೦ ೨ ೬ ೭ */
'\0',
'\xEA', '\xA4', '\x85', ' ', '\xEA', '\xA4', '\x8F', ' ', '\xEA', '\xA4', '\x81', ' ', '\xEA', '\xA4', '\x8B', ' ', '\xEA', '\xA4', '\x80', ' ', '\xEA', '\xA4', '\x8D', /* ꤅ ꤏ ꤁ ꤋ ꤀ ꤍ */
'\0',
'\xEA', '\xA4', '\x88', ' ', '\xEA', '\xA4', '\x98', ' ', '\xEA', '\xA4', '\x80', ' ', '\xEA', '\xA4', '\x8D', ' ', '\xEA', '\xA4', '\xA2', /* ꤈ ꤘ ꤀ ꤍ ꤢ */
'\0',
'\xEA', '\xA4', '\x96', ' ', '\xEA', '\xA4', '\xA1', /* ꤖ ꤡ */
'\0',
'\xEA', '\xA4', '\x91', ' ', '\xEA', '\xA4', '\x9C', ' ', '\xEA', '\xA4', '\x9E', /* ꤑ ꤜ ꤞ */
'\0',
'\xEA', '\xA4', '\x91', '\xEA', '\xA4', '\xAC', ' ', '\xEA', '\xA4', '\x9C', '\xEA', '\xA4', '\xAD', ' ', '\xEA', '\xA4', '\x94', '\xEA', '\xA4', '\xAC', /* ꤑ꤬ ꤜ꤭ ꤔ꤬ */
'\0',
'\xE1', '\x9E', '\x81', ' ', '\xE1', '\x9E', '\x91', ' ', '\xE1', '\x9E', '\x93', ' ', '\xE1', '\x9E', '\xA7', ' ', '\xE1', '\x9E', '\xA9', ' ', '\xE1', '\x9E', '\xB6', /* ខ ទ ន ឧ ឩ ា */
'\0',
'\xE1', '\x9E', '\x80', '\xE1', '\x9F', '\x92', '\xE1', '\x9E', '\x80', ' ', '\xE1', '\x9E', '\x80', '\xE1', '\x9F', '\x92', '\xE1', '\x9E', '\x81', ' ', '\xE1', '\x9E', '\x80', '\xE1', '\x9F', '\x92', '\xE1', '\x9E', '\x82', ' ', '\xE1', '\x9E', '\x80', '\xE1', '\x9F', '\x92', '\xE1', '\x9E', '\x90', /* ក្ក ក្ខ ក្គ ក្ថ */
'\0',
'\xE1', '\x9E', '\x81', ' ', '\xE1', '\x9E', '\x83', ' ', '\xE1', '\x9E', '\x85', ' ', '\xE1', '\x9E', '\x8B', ' ', '\xE1', '\x9E', '\x94', ' ', '\xE1', '\x9E', '\x98', ' ', '\xE1', '\x9E', '\x99', ' ', '\xE1', '\x9E', '\xB2', /* ខ ឃ ច ឋ ប ម យ ឲ */
'\0',
'\xE1', '\x9E', '\x8F', '\xE1', '\x9F', '\x92', '\xE1', '\x9E', '\x9A', ' ', '\xE1', '\x9E', '\x9A', '\xE1', '\x9F', '\x80', ' ', '\xE1', '\x9E', '\xB2', '\xE1', '\x9F', '\x92', '\xE1', '\x9E', '\x99', ' ', '\xE1', '\x9E', '\xA2', '\xE1', '\x9E', '\xBF', /* ត្រ រៀ ឲ្យ អឿ */
'\0',
'\xE1', '\x9E', '\x93', '\xE1', '\x9F', '\x92', '\xE1', '\x9E', '\x8F', '\xE1', '\x9F', '\x92', '\xE1', '\x9E', '\x9A', '\xE1', '\x9F', '\x83', ' ', '\xE1', '\x9E', '\x84', '\xE1', '\x9F', '\x92', '\xE1', '\x9E', '\x81', '\xE1', '\x9F', '\x92', '\xE1', '\x9E', '\x99', ' ', '\xE1', '\x9E', '\x80', '\xE1', '\x9F', '\x92', '\xE1', '\x9E', '\x94', '\xE1', '\x9F', '\x80', ' ', '\xE1', '\x9E', '\x85', '\xE1', '\x9F', '\x92', '\xE1', '\x9E', '\x9A', '\xE1', '\x9F', '\x80', ' ', '\xE1', '\x9E', '\x93', '\xE1', '\x9F', '\x92', '\xE1', '\x9E', '\x8F', '\xE1', '\x9E', '\xBF', ' ', '\xE1', '\x9E', '\x9B', '\xE1', '\x9F', '\x92', '\xE1', '\x9E', '\x94', '\xE1', '\x9E', '\xBF', /* ន្ត្រៃ ង្ខ្យ ក្បៀ ច្រៀ ន្តឿ ល្បឿ */
'\0',
'\xE1', '\xA7', '\xA0', ' ', '\xE1', '\xA7', '\xA1', /* ᧠ ᧡ */
'\0',
'\xE1', '\xA7', '\xB6', ' ', '\xE1', '\xA7', '\xB9', /* ᧶ ᧹ */
'\0',
'\xE0', '\xBA', '\xB2', ' ', '\xE0', '\xBA', '\x94', ' ', '\xE0', '\xBA', '\xAD', ' ', '\xE0', '\xBA', '\xA1', ' ', '\xE0', '\xBA', '\xA5', ' ', '\xE0', '\xBA', '\xA7', ' ', '\xE0', '\xBA', '\xA3', ' ', '\xE0', '\xBA', '\x87', /* າ ດ ອ ມ ລ ວ ຣ ງ */
'\0',
'\xE0', '\xBA', '\xB2', ' ', '\xE0', '\xBA', '\xAD', ' ', '\xE0', '\xBA', '\x9A', ' ', '\xE0', '\xBA', '\x8D', ' ', '\xE0', '\xBA', '\xA3', ' ', '\xE0', '\xBA', '\xAE', ' ', '\xE0', '\xBA', '\xA7', ' ', '\xE0', '\xBA', '\xA2', /* າ ອ ບ ຍ ຣ ຮ ວ ຢ */
'\0',
'\xE0', '\xBA', '\x9B', ' ', '\xE0', '\xBA', '\xA2', ' ', '\xE0', '\xBA', '\x9F', ' ', '\xE0', '\xBA', '\x9D', /* ປ ຢ ຟ ຝ */
'\0',
'\xE0', '\xBB', '\x82', ' ', '\xE0', '\xBB', '\x84', ' ', '\xE0', '\xBB', '\x83', /* ໂ ໄ ໃ */
'\0',
'\xE0', '\xBA', '\x87', ' ', '\xE0', '\xBA', '\x8A', ' ', '\xE0', '\xBA', '\x96', ' ', '\xE0', '\xBA', '\xBD', ' ', '\xE0', '\xBB', '\x86', ' ', '\xE0', '\xBA', '\xAF', /* ງ ຊ ຖ ຽ ໆ ຯ */
'\0',
'T', ' ', 'H', ' ', 'E', ' ', 'Z', ' ', 'O', ' ', 'C', ' ', 'Q', ' ', 'S', /* T H E Z O C Q S */
'\0',
'H', ' ', 'E', ' ', 'Z', ' ', 'L', ' ', 'O', ' ', 'C', ' ', 'U', ' ', 'S', /* H E Z L O C U S */
'\0',
'f', ' ', 'i', ' ', 'j', ' ', 'k', ' ', 'd', ' ', 'b', ' ', 'h', /* f i j k d b h */
'\0',
'u', ' ', 'v', ' ', 'x', ' ', 'z', ' ', 'o', ' ', 'e', ' ', 's', ' ', 'c', /* u v x z o e s c */
'\0',
'n', ' ', 'r', ' ', 'x', ' ', 'z', ' ', 'o', ' ', 'e', ' ', 's', ' ', 'c', /* n r x z o e s c */
'\0',
'p', ' ', 'q', ' ', 'g', ' ', 'j', ' ', 'y', /* p q g j y */
'\0',
'\xE2', '\x82', '\x80', ' ', '\xE2', '\x82', '\x83', ' ', '\xE2', '\x82', '\x85', ' ', '\xE2', '\x82', '\x87', ' ', '\xE2', '\x82', '\x88', /* ₀ ₃ ₅ ₇ ₈ */
'\0',
'\xE2', '\x82', '\x80', ' ', '\xE2', '\x82', '\x81', ' ', '\xE2', '\x82', '\x82', ' ', '\xE2', '\x82', '\x83', ' ', '\xE2', '\x82', '\x88', /* ₀ ₁ ₂ ₃ ₈ */
'\0',
'\xE1', '\xB5', '\xA2', ' ', '\xE2', '\xB1', '\xBC', ' ', '\xE2', '\x82', '\x95', ' ', '\xE2', '\x82', '\x96', ' ', '\xE2', '\x82', '\x97', /* ᵢ ⱼ ₕ ₖ ₗ */
'\0',
'\xE2', '\x82', '\x90', ' ', '\xE2', '\x82', '\x91', ' ', '\xE2', '\x82', '\x92', ' ', '\xE2', '\x82', '\x93', ' ', '\xE2', '\x82', '\x99', ' ', '\xE2', '\x82', '\x9B', ' ', '\xE1', '\xB5', '\xA5', ' ', '\xE1', '\xB5', '\xA4', ' ', '\xE1', '\xB5', '\xA3', /* ₐ ₑ ₒ ₓ ₙ ₛ ᵥ ᵤ ᵣ */
'\0',
'\xE1', '\xB5', '\xA6', ' ', '\xE1', '\xB5', '\xA7', ' ', '\xE1', '\xB5', '\xA8', ' ', '\xE1', '\xB5', '\xA9', ' ', '\xE2', '\x82', '\x9A', /* ᵦ ᵧ ᵨ ᵩ ₚ */
'\0',
'\xE2', '\x81', '\xB0', ' ', '\xC2', '\xB3', ' ', '\xE2', '\x81', '\xB5', ' ', '\xE2', '\x81', '\xB7', ' ', '\xE1', '\xB5', '\x80', ' ', '\xE1', '\xB4', '\xB4', ' ', '\xE1', '\xB4', '\xB1', ' ', '\xE1', '\xB4', '\xBC', /* ⁰ ³ ⁵ ⁷ ᵀ ᴴ ᴱ ᴼ */
'\0',
'\xE2', '\x81', '\xB0', ' ', '\xC2', '\xB9', ' ', '\xC2', '\xB2', ' ', '\xC2', '\xB3', ' ', '\xE1', '\xB4', '\xB1', ' ', '\xE1', '\xB4', '\xB8', ' ', '\xE1', '\xB4', '\xBC', ' ', '\xE1', '\xB5', '\x81', /* ⁰ ¹ ² ³ ᴱ ᴸ ᴼ ᵁ */
'\0',
'\xE1', '\xB5', '\x87', ' ', '\xE1', '\xB5', '\x88', ' ', '\xE1', '\xB5', '\x8F', ' ', '\xCA', '\xB0', ' ', '\xCA', '\xB2', ' ', '\xE1', '\xB6', '\xA0', ' ', '\xE2', '\x81', '\xB1', /* ᵇ ᵈ ᵏ ʰ ʲ ᶠ ⁱ */
'\0',
'\xE1', '\xB5', '\x89', ' ', '\xE1', '\xB5', '\x92', ' ', '\xCA', '\xB3', ' ', '\xCB', '\xA2', ' ', '\xCB', '\xA3', ' ', '\xE1', '\xB6', '\x9C', ' ', '\xE1', '\xB6', '\xBB', /* ᵉ ᵒ ʳ ˢ ˣ ᶜ ᶻ */
'\0',
'\xE1', '\xB5', '\x96', ' ', '\xCA', '\xB8', ' ', '\xE1', '\xB5', '\x8D', /* ᵖ ʸ ᵍ */
'\0',
'\xEA', '\x93', '\xA1', ' ', '\xEA', '\x93', '\xA7', ' ', '\xEA', '\x93', '\xB1', ' ', '\xEA', '\x93', '\xB6', ' ', '\xEA', '\x93', '\xA9', ' ', '\xEA', '\x93', '\x9A', ' ', '\xEA', '\x93', '\xB5', ' ', '\xEA', '\x93', '\xB3', /* ꓡ ꓧ ꓱ ꓶ ꓩ ꓚ ꓵ ꓳ */
'\0',
'\xEA', '\x93', '\x95', ' ', '\xEA', '\x93', '\x9C', ' ', '\xEA', '\x93', '\x9E', ' ', '\xEA', '\x93', '\xA1', ' ', '\xEA', '\x93', '\x9B', ' ', '\xEA', '\x93', '\xA2', ' ', '\xEA', '\x93', '\xB3', ' ', '\xEA', '\x93', '\xB4', /* ꓕ ꓜ ꓞ ꓡ ꓛ ꓢ ꓳ ꓴ */
'\0',
'\xE0', '\xB4', '\x92', ' ', '\xE0', '\xB4', '\x9F', ' ', '\xE0', '\xB4', '\xA0', ' ', '\xE0', '\xB4', '\xB1', ' ', '\xE0', '\xB4', '\x9A', ' ', '\xE0', '\xB4', '\xAA', ' ', '\xE0', '\xB4', '\x9A', '\xE0', '\xB5', '\x8D', '\xE0', '\xB4', '\x9A', ' ', '\xE0', '\xB4', '\xAA', '\xE0', '\xB5', '\x8D', '\xE0', '\xB4', '\xAA', /* ഒ ട ഠ റ ച പ ച്ച പ്പ */
'\0',
'\xE0', '\xB4', '\x9F', ' ', '\xE0', '\xB4', '\xA0', ' ', '\xE0', '\xB4', '\xA7', ' ', '\xE0', '\xB4', '\xB6', ' ', '\xE0', '\xB4', '\x98', ' ', '\xE0', '\xB4', '\x9A', ' ', '\xE0', '\xB4', '\xA5', ' ', '\xE0', '\xB4', '\xB2', /* ട ഠ ധ ശ ഘ ച ഥ ല */
'\0',
'\xF0', '\x96', '\xB9', '\x80', ' ', '\xF0', '\x96', '\xB9', '\x81', ' ', '\xF0', '\x96', '\xB9', '\x82', ' ', '\xF0', '\x96', '\xB9', '\x83', ' ', '\xF0', '\x96', '\xB9', '\x8F', ' ', '\xF0', '\x96', '\xB9', '\x9A', ' ', '\xF0', '\x96', '\xB9', '\x9F', /* 𖹀 𖹁 𖹂 𖹃 𖹏 𖹚 𖹟 */
'\0',
'\xF0', '\x96', '\xB9', '\x80', ' ', '\xF0', '\x96', '\xB9', '\x81', ' ', '\xF0', '\x96', '\xB9', '\x82', ' ', '\xF0', '\x96', '\xB9', '\x83', ' ', '\xF0', '\x96', '\xB9', '\x8F', ' ', '\xF0', '\x96', '\xB9', '\x9A', ' ', '\xF0', '\x96', '\xB9', '\x92', ' ', '\xF0', '\x96', '\xB9', '\x93', /* 𖹀 𖹁 𖹂 𖹃 𖹏 𖹚 𖹒 𖹓 */
'\0',
'\xF0', '\x96', '\xB9', '\xA4', ' ', '\xF0', '\x96', '\xB9', '\xAC', ' ', '\xF0', '\x96', '\xB9', '\xA7', ' ', '\xF0', '\x96', '\xB9', '\xB4', ' ', '\xF0', '\x96', '\xB9', '\xB6', ' ', '\xF0', '\x96', '\xB9', '\xBE', /* 𖹤 𖹬 𖹧 𖹴 𖹶 𖹾 */
'\0',
'\xF0', '\x96', '\xB9', '\xA0', ' ', '\xF0', '\x96', '\xB9', '\xA1', ' ', '\xF0', '\x96', '\xB9', '\xA2', ' ', '\xF0', '\x96', '\xB9', '\xB9', ' ', '\xF0', '\x96', '\xB9', '\xB3', ' ', '\xF0', '\x96', '\xB9', '\xAE', /* 𖹠 𖹡 𖹢 𖹹 𖹳 𖹮 */
'\0',
'\xF0', '\x96', '\xB9', '\xA0', ' ', '\xF0', '\x96', '\xB9', '\xA1', ' ', '\xF0', '\x96', '\xB9', '\xA2', ' ', '\xF0', '\x96', '\xB9', '\xB3', ' ', '\xF0', '\x96', '\xB9', '\xAD', ' ', '\xF0', '\x96', '\xB9', '\xBD', /* 𖹠 𖹡 𖹢 𖹳 𖹭 𖹽 */
'\0',
'\xF0', '\x96', '\xB9', '\xA5', ' ', '\xF0', '\x96', '\xB9', '\xA8', ' ', '\xF0', '\x96', '\xB9', '\xA9', /* 𖹥 𖹨 𖹩 */
'\0',
'\xF0', '\x96', '\xBA', '\x80', ' ', '\xF0', '\x96', '\xBA', '\x85', ' ', '\xF0', '\x96', '\xBA', '\x88', ' ', '\xF0', '\x96', '\xBA', '\x84', ' ', '\xF0', '\x96', '\xBA', '\x8D', /* 𖺀 𖺅 𖺈 𖺄 𖺍 */
'\0',
'\xE1', '\xA0', '\xB3', ' ', '\xE1', '\xA0', '\xB4', ' ', '\xE1', '\xA0', '\xB6', ' ', '\xE1', '\xA0', '\xBD', ' ', '\xE1', '\xA1', '\x82', ' ', '\xE1', '\xA1', '\x8A', ' ', '\xE2', '\x80', '\x8D', '\xE1', '\xA1', '\xA1', '\xE2', '\x80', '\x8D', ' ', '\xE2', '\x80', '\x8D', '\xE1', '\xA1', '\xB3', '\xE2', '\x80', '\x8D', /* ᠳ ᠴ ᠶ ᠽ ᡂ ᡊ ᡡ ᡳ */
'\0',
'\xE1', '\xA1', '\x83', /* ᡃ */
'\0',
'\xE1', '\x80', '\x81', ' ', '\xE1', '\x80', '\x82', ' ', '\xE1', '\x80', '\x84', ' ', '\xE1', '\x80', '\x92', ' ', '\xE1', '\x80', '\x9D', ' ', '\xE1', '\x81', '\xA5', ' ', '\xE1', '\x81', '\x8A', ' ', '\xE1', '\x81', '\x8B', /* ခ ဂ င ဒ ဝ ၥ ၊ ။ */
'\0',
'\xE1', '\x80', '\x84', ' ', '\xE1', '\x80', '\x8E', ' ', '\xE1', '\x80', '\x92', ' ', '\xE1', '\x80', '\x95', ' ', '\xE1', '\x80', '\x97', ' ', '\xE1', '\x80', '\x9D', ' ', '\xE1', '\x81', '\x8A', ' ', '\xE1', '\x81', '\x8B', /* င ဎ ဒ ပ ဗ ဝ ၊ ။ */
'\0',
'\xE1', '\x80', '\xA9', ' ', '\xE1', '\x80', '\xBC', ' ', '\xE1', '\x81', '\x8D', ' ', '\xE1', '\x81', '\x8F', ' ', '\xE1', '\x81', '\x86', ' ', '\xE1', '\x80', '\xAB', ' ', '\xE1', '\x80', '\xAD', /* ဩ ြ ၍ ၏ ၆ ါ ိ */
'\0',
'\xE1', '\x80', '\x89', ' ', '\xE1', '\x80', '\x8A', ' ', '\xE1', '\x80', '\xA5', ' ', '\xE1', '\x80', '\xA9', ' ', '\xE1', '\x80', '\xA8', ' ', '\xE1', '\x81', '\x82', ' ', '\xE1', '\x81', '\x85', ' ', '\xE1', '\x81', '\x89', /* ဉ ည ဥ ဩ ဨ ၂ ၅ ၉ */
'\0',
'\xDF', '\x90', ' ', '\xDF', '\x89', ' ', '\xDF', '\x92', ' ', '\xDF', '\x9F', ' ', '\xDF', '\x96', ' ', '\xDF', '\x9C', ' ', '\xDF', '\xA0', ' ', '\xDF', '\xA5', /* ߐ ߉ ߒ ߟ ߖ ߜ ߠ ߥ */
'\0',
'\xDF', '\x80', ' ', '\xDF', '\x98', ' ', '\xDF', '\xA1', ' ', '\xDF', '\xA0', ' ', '\xDF', '\xA5', /* ߀ ߘ ߡ ߠ ߥ */
'\0',
'\xDF', '\x8F', ' ', '\xDF', '\x9B', ' ', '\xDF', '\x8B', /* ߏ ߛ ߋ */
'\0',
'\xDF', '\x8E', ' ', '\xDF', '\x8F', ' ', '\xDF', '\x9B', ' ', '\xDF', '\x8B', /* ߎ ߏ ߛ ߋ */
'\0',
'\xE1', '\xB1', '\x9B', ' ', '\xE1', '\xB1', '\x9C', ' ', '\xE1', '\xB1', '\x9D', ' ', '\xE1', '\xB1', '\xA1', ' ', '\xE1', '\xB1', '\xA2', ' ', '\xE1', '\xB1', '\xA5', /* ᱛ ᱜ ᱝ ᱡ ᱢ ᱥ */
'\0',
'\xF0', '\x90', '\xB0', '\x97', ' ', '\xF0', '\x90', '\xB0', '\x98', ' ', '\xF0', '\x90', '\xB0', '\xA7', /* 𐰗 𐰘 𐰧 */
'\0',
'\xF0', '\x90', '\xB0', '\x89', ' ', '\xF0', '\x90', '\xB0', '\x97', ' ', '\xF0', '\x90', '\xB0', '\xA6', ' ', '\xF0', '\x90', '\xB0', '\xA7', /* 𐰉 𐰗 𐰦 𐰧 */
'\0',
'\xF0', '\x90', '\x92', '\xBE', ' ', '\xF0', '\x90', '\x93', '\x8D', ' ', '\xF0', '\x90', '\x93', '\x92', ' ', '\xF0', '\x90', '\x93', '\x93', ' ', '\xF0', '\x90', '\x92', '\xBB', ' ', '\xF0', '\x90', '\x93', '\x82', ' ', '\xF0', '\x90', '\x92', '\xB5', ' ', '\xF0', '\x90', '\x93', '\x86', /* 𐒾 𐓍 𐓒 𐓓 𐒻 𐓂 𐒵 𐓆 */
'\0',
'\xF0', '\x90', '\x92', '\xB0', ' ', '\xF0', '\x90', '\x93', '\x8D', ' ', '\xF0', '\x90', '\x93', '\x82', ' ', '\xF0', '\x90', '\x92', '\xBF', ' ', '\xF0', '\x90', '\x93', '\x8E', ' ', '\xF0', '\x90', '\x92', '\xB9', /* 𐒰 𐓍 𐓂 𐒿 𐓎 𐒹 */
'\0',
'\xF0', '\x90', '\x92', '\xBC', ' ', '\xF0', '\x90', '\x92', '\xBD', ' ', '\xF0', '\x90', '\x92', '\xBE', /* 𐒼 𐒽 𐒾 */
'\0',
'\xF0', '\x90', '\x93', '\xB5', ' ', '\xF0', '\x90', '\x93', '\xB6', ' ', '\xF0', '\x90', '\x93', '\xBA', ' ', '\xF0', '\x90', '\x93', '\xBB', ' ', '\xF0', '\x90', '\x93', '\x9D', ' ', '\xF0', '\x90', '\x93', '\xA3', ' ', '\xF0', '\x90', '\x93', '\xAA', ' ', '\xF0', '\x90', '\x93', '\xAE', /* 𐓵 𐓶 𐓺 𐓻 𐓝 𐓣 𐓪 𐓮 */
'\0',
'\xF0', '\x90', '\x93', '\x98', ' ', '\xF0', '\x90', '\x93', '\x9A', ' ', '\xF0', '\x90', '\x93', '\xA3', ' ', '\xF0', '\x90', '\x93', '\xB5', ' ', '\xF0', '\x90', '\x93', '\xA1', ' ', '\xF0', '\x90', '\x93', '\xA7', ' ', '\xF0', '\x90', '\x93', '\xAA', ' ', '\xF0', '\x90', '\x93', '\xB6', /* 𐓘 𐓚 𐓣 𐓵 𐓡 𐓧 𐓪 𐓶 */
'\0',
'\xF0', '\x90', '\x93', '\xA4', ' ', '\xF0', '\x90', '\x93', '\xA6', ' ', '\xF0', '\x90', '\x93', '\xB8', ' ', '\xF0', '\x90', '\x93', '\xB9', ' ', '\xF0', '\x90', '\x93', '\x9B', /* 𐓤 𐓦 𐓸 𐓹 𐓛 */
'\0',
'\xF0', '\x90', '\x93', '\xA4', ' ', '\xF0', '\x90', '\x93', '\xA5', ' ', '\xF0', '\x90', '\x93', '\xA6', /* 𐓤 𐓥 𐓦 */
'\0',
'\xF0', '\x90', '\x92', '\x86', ' ', '\xF0', '\x90', '\x92', '\x89', ' ', '\xF0', '\x90', '\x92', '\x90', ' ', '\xF0', '\x90', '\x92', '\x92', ' ', '\xF0', '\x90', '\x92', '\x98', ' ', '\xF0', '\x90', '\x92', '\x9B', ' ', '\xF0', '\x90', '\x92', '\xA0', ' ', '\xF0', '\x90', '\x92', '\xA3', /* 𐒆 𐒉 𐒐 𐒒 𐒘 𐒛 𐒠 𐒣 */
'\0',
'\xF0', '\x90', '\x92', '\x80', ' ', '\xF0', '\x90', '\x92', '\x82', ' ', '\xF0', '\x90', '\x92', '\x86', ' ', '\xF0', '\x90', '\x92', '\x88', ' ', '\xF0', '\x90', '\x92', '\x8A', ' ', '\xF0', '\x90', '\x92', '\x92', ' ', '\xF0', '\x90', '\x92', '\xA0', ' ', '\xF0', '\x90', '\x92', '\xA9', /* 𐒀 𐒂 𐒆 𐒈 𐒊 𐒒 𐒠 𐒩 */
'\0',
'\xF0', '\x90', '\xB4', '\x83', ' ', '\xF0', '\x90', '\xB4', '\x80', ' ', '\xF0', '\x90', '\xB4', '\x86', ' ', '\xF0', '\x90', '\xB4', '\x96', ' ', '\xF0', '\x90', '\xB4', '\x95', /* 𐴃 𐴀 𐴆 𐴖 𐴕 */
'\0',
'\xF0', '\x90', '\xB4', '\x94', ' ', '\xF0', '\x90', '\xB4', '\x96', ' ', '\xF0', '\x90', '\xB4', '\x95', ' ', '\xF0', '\x90', '\xB4', '\x91', ' ', '\xF0', '\x90', '\xB4', '\x90', /* 𐴔 𐴖 𐴕 𐴑 𐴐 */
'\0',
'\xD9', '\x80', /* ـ */
'\0',
'\xEA', '\xA2', '\x9C', ' ', '\xEA', '\xA2', '\x9E', ' ', '\xEA', '\xA2', '\xB3', ' ', '\xEA', '\xA2', '\x82', ' ', '\xEA', '\xA2', '\x96', ' ', '\xEA', '\xA2', '\x92', ' ', '\xEA', '\xA2', '\x9D', ' ', '\xEA', '\xA2', '\x9B', /* ꢜ ꢞ ꢳ ꢂ ꢖ ꢒ ꢝ ꢛ */
'\0',
'\xEA', '\xA2', '\x82', ' ', '\xEA', '\xA2', '\xA8', ' ', '\xEA', '\xA2', '\xBA', ' ', '\xEA', '\xA2', '\xA4', ' ', '\xEA', '\xA2', '\x8E', /* ꢂ ꢨ ꢺ ꢤ ꢎ */
'\0',
'\xF0', '\x90', '\x91', '\x95', ' ', '\xF0', '\x90', '\x91', '\x99', /* 𐑕 𐑙 */
'\0',
'\xF0', '\x90', '\x91', '\x94', ' ', '\xF0', '\x90', '\x91', '\x96', ' ', '\xF0', '\x90', '\x91', '\x97', ' ', '\xF0', '\x90', '\x91', '\xB9', ' ', '\xF0', '\x90', '\x91', '\xBB', /* 𐑔 𐑖 𐑗 𐑹 𐑻 */
'\0',
'\xF0', '\x90', '\x91', '\x9F', ' ', '\xF0', '\x90', '\x91', '\xA3', /* 𐑟 𐑣 */
'\0',
'\xF0', '\x90', '\x91', '\xB1', ' ', '\xF0', '\x90', '\x91', '\xB2', ' ', '\xF0', '\x90', '\x91', '\xB3', ' ', '\xF0', '\x90', '\x91', '\xB4', ' ', '\xF0', '\x90', '\x91', '\xB8', ' ', '\xF0', '\x90', '\x91', '\xBA', ' ', '\xF0', '\x90', '\x91', '\xBC', /* 𐑱 𐑲 𐑳 𐑴 𐑸 𐑺 𐑼 */
'\0',
'\xF0', '\x90', '\x91', '\xB4', ' ', '\xF0', '\x90', '\x91', '\xBB', ' ', '\xF0', '\x90', '\x91', '\xB9', /* 𐑴 𐑻 𐑹 */
'\0',
'\xE0', '\xB6', '\x89', ' ', '\xE0', '\xB6', '\x9A', ' ', '\xE0', '\xB6', '\x9D', ' ', '\xE0', '\xB6', '\xB3', ' ', '\xE0', '\xB6', '\xB4', ' ', '\xE0', '\xB6', '\xBA', ' ', '\xE0', '\xB6', '\xBD', ' ', '\xE0', '\xB7', '\x86', /* ඉ ක ඝ ඳ ප ය ල ෆ */
'\0',
'\xE0', '\xB6', '\x91', ' ', '\xE0', '\xB6', '\x94', ' ', '\xE0', '\xB6', '\x9D', ' ', '\xE0', '\xB6', '\xA2', ' ', '\xE0', '\xB6', '\xA7', ' ', '\xE0', '\xB6', '\xAE', ' ', '\xE0', '\xB6', '\xB0', ' ', '\xE0', '\xB6', '\xBB', /* එ ඔ ඝ ජ ට ථ ධ ර */
'\0',
'\xE0', '\xB6', '\xAF', ' ', '\xE0', '\xB6', '\xB3', ' ', '\xE0', '\xB6', '\x8B', ' ', '\xE0', '\xB6', '\xBD', ' ', '\xE0', '\xB6', '\xAD', '\xE0', '\xB7', '\x96', ' ', '\xE0', '\xB6', '\xAD', '\xE0', '\xB7', '\x94', ' ', '\xE0', '\xB6', '\xB6', '\xE0', '\xB7', '\x94', ' ', '\xE0', '\xB6', '\xAF', '\xE0', '\xB7', '\x94', /* ද ඳ උ ල තූ තු බු දු */
'\0',
'\xE1', '\xAE', '\x8B', ' ', '\xE1', '\xAE', '\x9E', ' ', '\xE1', '\xAE', '\xAE', ' ', '\xE1', '\xAE', '\xBD', ' ', '\xE1', '\xAE', '\xB0', ' ', '\xE1', '\xAE', '\x88', /* ᮋ ᮞ ᮮ ᮽ ᮰ ᮈ */
'\0',
'\xE1', '\xAE', '\x84', ' ', '\xE1', '\xAE', '\x94', ' ', '\xE1', '\xAE', '\x95', ' ', '\xE1', '\xAE', '\x97', ' ', '\xE1', '\xAE', '\xB0', ' ', '\xE1', '\xAE', '\x86', ' ', '\xE1', '\xAE', '\x88', ' ', '\xE1', '\xAE', '\x89', /* ᮄ ᮔ ᮕ ᮗ ᮰ ᮆ ᮈ ᮉ */
'\0',
'\xE1', '\xAE', '\xBC', ' ', '\xE1', '\xB3', '\x84', /* ᮼ ᳄ */
'\0',
'\xEA', '\xAA', '\x86', ' ', '\xEA', '\xAA', '\x94', ' ', '\xEA', '\xAA', '\x92', ' ', '\xEA', '\xAA', '\x96', ' ', '\xEA', '\xAA', '\xAB', /* ꪆ ꪔ ꪒ ꪖ ꪫ */
'\0',
'\xEA', '\xAA', '\x89', ' ', '\xEA', '\xAA', '\xAB', ' ', '\xEA', '\xAA', '\xAE', /* ꪉ ꪫ ꪮ */
'\0',
'\xE0', '\xAE', '\x89', ' ', '\xE0', '\xAE', '\x92', ' ', '\xE0', '\xAE', '\x93', ' ', '\xE0', '\xAE', '\xB1', ' ', '\xE0', '\xAE', '\x88', ' ', '\xE0', '\xAE', '\x95', ' ', '\xE0', '\xAE', '\x99', ' ', '\xE0', '\xAE', '\x9A', /* உ ஒ ஓ ற ஈ க ங ச */
'\0',
'\xE0', '\xAE', '\x95', ' ', '\xE0', '\xAE', '\x9A', ' ', '\xE0', '\xAE', '\xB2', ' ', '\xE0', '\xAE', '\xB6', ' ', '\xE0', '\xAE', '\x89', ' ', '\xE0', '\xAE', '\x99', ' ', '\xE0', '\xAE', '\x9F', ' ', '\xE0', '\xAE', '\xAA', /* க ச ல ஶ உ ங ட ப */
'\0',
'\xE0', '\xB0', '\x87', ' ', '\xE0', '\xB0', '\x8C', ' ', '\xE0', '\xB0', '\x99', ' ', '\xE0', '\xB0', '\x9E', ' ', '\xE0', '\xB0', '\xA3', ' ', '\xE0', '\xB0', '\xB1', ' ', '\xE0', '\xB1', '\xAF', /* ఇ ఌ ఙ ఞ ణ ఱ ౯ */
'\0',
'\xE0', '\xB0', '\x85', ' ', '\xE0', '\xB0', '\x95', ' ', '\xE0', '\xB0', '\x9A', ' ', '\xE0', '\xB0', '\xB0', ' ', '\xE0', '\xB0', '\xBD', ' ', '\xE0', '\xB1', '\xA8', ' ', '\xE0', '\xB1', '\xAC', /* అ క చ ర ఽ ౨ ౬ */
'\0',
'\xE0', '\xB8', '\x9A', ' ', '\xE0', '\xB9', '\x80', ' ', '\xE0', '\xB9', '\x81', ' ', '\xE0', '\xB8', '\xAD', ' ', '\xE0', '\xB8', '\x81', ' ', '\xE0', '\xB8', '\xB2', /* บ เ แ อ ก า */
'\0',
'\xE0', '\xB8', '\x9A', ' ', '\xE0', '\xB8', '\x9B', ' ', '\xE0', '\xB8', '\xA9', ' ', '\xE0', '\xB8', '\xAF', ' ', '\xE0', '\xB8', '\xAD', ' ', '\xE0', '\xB8', '\xA2', ' ', '\xE0', '\xB8', '\xAE', /* บ ป ษ ฯ อ ย ฮ */
'\0',
'\xE0', '\xB8', '\x9B', ' ', '\xE0', '\xB8', '\x9D', ' ', '\xE0', '\xB8', '\x9F', /* ป ฝ ฟ */
'\0',
'\xE0', '\xB9', '\x82', ' ', '\xE0', '\xB9', '\x83', ' ', '\xE0', '\xB9', '\x84', /* โ ใ ไ */
'\0',
'\xE0', '\xB8', '\x8E', ' ', '\xE0', '\xB8', '\x8F', ' ', '\xE0', '\xB8', '\xA4', ' ', '\xE0', '\xB8', '\xA6', /* ฎ ฏ ฤ ฦ */
'\0',
'\xE0', '\xB8', '\x8D', ' ', '\xE0', '\xB8', '\x90', /* ญ ฐ */
'\0',
'\xE0', '\xB9', '\x90', ' ', '\xE0', '\xB9', '\x91', ' ', '\xE0', '\xB9', '\x93', /* ๐ ๑ ๓ */
'\0',
'\xE2', '\xB5', '\x94', ' ', '\xE2', '\xB5', '\x99', ' ', '\xE2', '\xB5', '\x9B', ' ', '\xE2', '\xB5', '\x9E', ' ', '\xE2', '\xB4', '\xB5', ' ', '\xE2', '\xB4', '\xBC', ' ', '\xE2', '\xB4', '\xB9', ' ', '\xE2', '\xB5', '\x8E', /* ⵔ ⵙ ⵛ ⵞ ⴵ ⴼ ⴹ ⵎ */
'\0',
'\xEA', '\x97', '\x8D', ' ', '\xEA', '\x98', '\x96', ' ', '\xEA', '\x98', '\x99', ' ', '\xEA', '\x98', '\x9C', ' ', '\xEA', '\x96', '\x9C', ' ', '\xEA', '\x96', '\x9D', ' ', '\xEA', '\x94', '\x85', ' ', '\xEA', '\x95', '\xA2', /* ꗍ ꘖ ꘙ ꘜ ꖜ ꖝ ꔅ ꕢ */
'\0',
'\xEA', '\x97', '\x8D', ' ', '\xEA', '\x98', '\x96', ' ', '\xEA', '\x98', '\x99', ' ', '\xEA', '\x97', '\x9E', ' ', '\xEA', '\x94', '\x85', ' ', '\xEA', '\x95', '\xA2', ' ', '\xEA', '\x96', '\x9C', ' ', '\xEA', '\x94', '\x86', /* ꗍ ꘖ ꘙ ꗞ ꔅ ꕢ ꖜ ꔆ */
#ifdef AF_CONFIG_OPTION_CJK
'\0',
'\xE4', '\xBB', '\x96', ' ', '\xE4', '\xBB', '\xAC', ' ', '\xE4', '\xBD', '\xA0', ' ', '\xE4', '\xBE', '\x86', ' ', '\xE5', '\x80', '\x91', ' ', '\xE5', '\x88', '\xB0', ' ', '\xE5', '\x92', '\x8C', ' ', '\xE5', '\x9C', '\xB0', /* 他 们 你 來 們 到 和 地 */
' ', '\xE5', '\xAF', '\xB9', ' ', '\xE5', '\xB0', '\x8D', ' ', '\xE5', '\xB0', '\xB1', ' ', '\xE5', '\xB8', '\xAD', ' ', '\xE6', '\x88', '\x91', ' ', '\xE6', '\x97', '\xB6', ' ', '\xE6', '\x99', '\x82', ' ', '\xE6', '\x9C', '\x83', /* 对 對 就 席 我 时 時 會 */
' ', '\xE6', '\x9D', '\xA5', ' ', '\xE7', '\x82', '\xBA', ' ', '\xE8', '\x83', '\xBD', ' ', '\xE8', '\x88', '\xB0', ' ', '\xE8', '\xAA', '\xAA', ' ', '\xE8', '\xAF', '\xB4', ' ', '\xE8', '\xBF', '\x99', ' ', '\xE9', '\x80', '\x99', /* 来 為 能 舰 說 说 这 這 */
' ', '\xE9', '\xBD', '\x8A', ' ', '|', /* 齊 | */
' ', '\xE5', '\x86', '\x9B', ' ', '\xE5', '\x90', '\x8C', ' ', '\xE5', '\xB7', '\xB2', ' ', '\xE6', '\x84', '\xBF', ' ', '\xE6', '\x97', '\xA2', ' ', '\xE6', '\x98', '\x9F', ' ', '\xE6', '\x98', '\xAF', ' ', '\xE6', '\x99', '\xAF', /* 军 同 已 愿 既 星 是 景 */
' ', '\xE6', '\xB0', '\x91', ' ', '\xE7', '\x85', '\xA7', ' ', '\xE7', '\x8E', '\xB0', ' ', '\xE7', '\x8F', '\xBE', ' ', '\xE7', '\x90', '\x86', ' ', '\xE7', '\x94', '\xA8', ' ', '\xE7', '\xBD', '\xAE', ' ', '\xE8', '\xA6', '\x81', /* 民 照 现 現 理 用 置 要 */
' ', '\xE8', '\xBB', '\x8D', ' ', '\xE9', '\x82', '\xA3', ' ', '\xE9', '\x85', '\x8D', ' ', '\xE9', '\x87', '\x8C', ' ', '\xE9', '\x96', '\x8B', ' ', '\xE9', '\x9B', '\xB7', ' ', '\xE9', '\x9C', '\xB2', ' ', '\xE9', '\x9D', '\xA2', /* 軍 那 配 里 開 雷 露 面 */
' ', '\xE9', '\xA1', '\xBE', /* 顾 */
'\0',
'\xE4', '\xB8', '\xAA', ' ', '\xE4', '\xB8', '\xBA', ' ', '\xE4', '\xBA', '\xBA', ' ', '\xE4', '\xBB', '\x96', ' ', '\xE4', '\xBB', '\xA5', ' ', '\xE4', '\xBB', '\xAC', ' ', '\xE4', '\xBD', '\xA0', ' ', '\xE4', '\xBE', '\x86', /* 个 为 人 他 以 们 你 來 */
' ', '\xE5', '\x80', '\x8B', ' ', '\xE5', '\x80', '\x91', ' ', '\xE5', '\x88', '\xB0', ' ', '\xE5', '\x92', '\x8C', ' ', '\xE5', '\xA4', '\xA7', ' ', '\xE5', '\xAF', '\xB9', ' ', '\xE5', '\xB0', '\x8D', ' ', '\xE5', '\xB0', '\xB1', /* 個 們 到 和 大 对 對 就 */
' ', '\xE6', '\x88', '\x91', ' ', '\xE6', '\x97', '\xB6', ' ', '\xE6', '\x99', '\x82', ' ', '\xE6', '\x9C', '\x89', ' ', '\xE6', '\x9D', '\xA5', ' ', '\xE7', '\x82', '\xBA', ' ', '\xE8', '\xA6', '\x81', ' ', '\xE8', '\xAA', '\xAA', /* 我 时 時 有 来 為 要 說 */
' ', '\xE8', '\xAF', '\xB4', ' ', '|', /* 说 | */
' ', '\xE4', '\xB8', '\xBB', ' ', '\xE4', '\xBA', '\x9B', ' ', '\xE5', '\x9B', '\xA0', ' ', '\xE5', '\xAE', '\x83', ' ', '\xE6', '\x83', '\xB3', ' ', '\xE6', '\x84', '\x8F', ' ', '\xE7', '\x90', '\x86', ' ', '\xE7', '\x94', '\x9F', /* 主 些 因 它 想 意 理 生 */
' ', '\xE7', '\x95', '\xB6', ' ', '\xE7', '\x9C', '\x8B', ' ', '\xE7', '\x9D', '\x80', ' ', '\xE7', '\xBD', '\xAE', ' ', '\xE8', '\x80', '\x85', ' ', '\xE8', '\x87', '\xAA', ' ', '\xE8', '\x91', '\x97', ' ', '\xE8', '\xA3', '\xA1', /* 當 看 着 置 者 自 著 裡 */
' ', '\xE8', '\xBF', '\x87', ' ', '\xE8', '\xBF', '\x98', ' ', '\xE8', '\xBF', '\x9B', ' ', '\xE9', '\x80', '\xB2', ' ', '\xE9', '\x81', '\x8E', ' ', '\xE9', '\x81', '\x93', ' ', '\xE9', '\x82', '\x84', ' ', '\xE9', '\x87', '\x8C', /* 过 还 进 進 過 道 還 里 */
' ', '\xE9', '\x9D', '\xA2', /* 面 */
#ifdef AF_CONFIG_OPTION_CJK_BLUE_HANI_VERT
'\0',
' ', '\xE4', '\xBA', '\x9B', ' ', '\xE4', '\xBB', '\xAC', ' ', '\xE4', '\xBD', '\xA0', ' ', '\xE4', '\xBE', '\x86', ' ', '\xE5', '\x80', '\x91', ' ', '\xE5', '\x88', '\xB0', ' ', '\xE5', '\x92', '\x8C', ' ', '\xE5', '\x9C', '\xB0', /* 些 们 你 來 們 到 和 地 */
' ', '\xE5', '\xA5', '\xB9', ' ', '\xE5', '\xB0', '\x86', ' ', '\xE5', '\xB0', '\x87', ' ', '\xE5', '\xB0', '\xB1', ' ', '\xE5', '\xB9', '\xB4', ' ', '\xE5', '\xBE', '\x97', ' ', '\xE6', '\x83', '\x85', ' ', '\xE6', '\x9C', '\x80', /* 她 将 將 就 年 得 情 最 */
' ', '\xE6', '\xA0', '\xB7', ' ', '\xE6', '\xA8', '\xA3', ' ', '\xE7', '\x90', '\x86', ' ', '\xE8', '\x83', '\xBD', ' ', '\xE8', '\xAA', '\xAA', ' ', '\xE8', '\xAF', '\xB4', ' ', '\xE8', '\xBF', '\x99', ' ', '\xE9', '\x80', '\x99', /* 样 樣 理 能 說 说 这 這 */
' ', '\xE9', '\x80', '\x9A', ' ', '|', /* 通 | */
' ', '\xE5', '\x8D', '\xB3', ' ', '\xE5', '\x90', '\x97', ' ', '\xE5', '\x90', '\xA7', ' ', '\xE5', '\x90', '\xAC', ' ', '\xE5', '\x91', '\xA2', ' ', '\xE5', '\x93', '\x81', ' ', '\xE5', '\x93', '\x8D', ' ', '\xE5', '\x97', '\x8E', /* 即 吗 吧 听 呢 品 响 嗎 */
' ', '\xE5', '\xB8', '\x88', ' ', '\xE5', '\xB8', '\xAB', ' ', '\xE6', '\x94', '\xB6', ' ', '\xE6', '\x96', '\xAD', ' ', '\xE6', '\x96', '\xB7', ' ', '\xE6', '\x98', '\x8E', ' ', '\xE7', '\x9C', '\xBC', ' ', '\xE9', '\x96', '\x93', /* 师 師 收 断 斷 明 眼 間 */
' ', '\xE9', '\x97', '\xB4', ' ', '\xE9', '\x99', '\x85', ' ', '\xE9', '\x99', '\x88', ' ', '\xE9', '\x99', '\x90', ' ', '\xE9', '\x99', '\xA4', ' ', '\xE9', '\x99', '\xB3', ' ', '\xE9', '\x9A', '\x8F', ' ', '\xE9', '\x9A', '\x9B', /* 间 际 陈 限 除 陳 随 際 */
' ', '\xE9', '\x9A', '\xA8', /* 隨 */
'\0',
'\xE4', '\xBA', '\x8B', ' ', '\xE5', '\x89', '\x8D', ' ', '\xE5', '\xAD', '\xB8', ' ', '\xE5', '\xB0', '\x86', ' ', '\xE5', '\xB0', '\x87', ' ', '\xE6', '\x83', '\x85', ' ', '\xE6', '\x83', '\xB3', ' ', '\xE6', '\x88', '\x96', /* 事 前 學 将 將 情 想 或 */
' ', '\xE6', '\x94', '\xBF', ' ', '\xE6', '\x96', '\xAF', ' ', '\xE6', '\x96', '\xB0', ' ', '\xE6', '\xA0', '\xB7', ' ', '\xE6', '\xA8', '\xA3', ' ', '\xE6', '\xB0', '\x91', ' ', '\xE6', '\xB2', '\x92', ' ', '\xE6', '\xB2', '\xA1', /* 政 斯 新 样 樣 民 沒 没 */
' ', '\xE7', '\x84', '\xB6', ' ', '\xE7', '\x89', '\xB9', ' ', '\xE7', '\x8E', '\xB0', ' ', '\xE7', '\x8F', '\xBE', ' ', '\xE7', '\x90', '\x83', ' ', '\xE7', '\xAC', '\xAC', ' ', '\xE7', '\xB6', '\x93', ' ', '\xE8', '\xB0', '\x81', /* 然 特 现 現 球 第 經 谁 */
' ', '\xE8', '\xB5', '\xB7', ' ', '|', /* 起 | */
' ', '\xE4', '\xBE', '\x8B', ' ', '\xE5', '\x88', '\xA5', ' ', '\xE5', '\x88', '\xAB', ' ', '\xE5', '\x88', '\xB6', ' ', '\xE5', '\x8A', '\xA8', ' ', '\xE5', '\x8B', '\x95', ' ', '\xE5', '\x90', '\x97', ' ', '\xE5', '\x97', '\x8E', /* 例 別 别 制 动 動 吗 嗎 */
' ', '\xE5', '\xA2', '\x9E', ' ', '\xE6', '\x8C', '\x87', ' ', '\xE6', '\x98', '\x8E', ' ', '\xE6', '\x9C', '\x9D', ' ', '\xE6', '\x9C', '\x9F', ' ', '\xE6', '\x9E', '\x84', ' ', '\xE7', '\x89', '\xA9', ' ', '\xE7', '\xA1', '\xAE', /* 增 指 明 朝 期 构 物 确 */
' ', '\xE7', '\xA7', '\x8D', ' ', '\xE8', '\xAA', '\xBF', ' ', '\xE8', '\xB0', '\x83', ' ', '\xE8', '\xB2', '\xBB', ' ', '\xE8', '\xB4', '\xB9', ' ', '\xE9', '\x82', '\xA3', ' ', '\xE9', '\x83', '\xBD', ' ', '\xE9', '\x96', '\x93', /* 种 調 调 費 费 那 都 間 */
' ', '\xE9', '\x97', '\xB4', /* 间 */
#endif /* AF_CONFIG_OPTION_CJK_BLUE_HANI_VERT */
#endif /* AF_CONFIG_OPTION_CJK */
'\0',
};
/* stringsets are specific to styles */
FT_LOCAL_ARRAY_DEF( AF_Blue_StringRec )
af_blue_stringsets[] =
{
/* */
{ AF_BLUE_STRING_ADLAM_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_ADLAM_CAPITAL_BOTTOM, 0 },
{ AF_BLUE_STRING_ADLAM_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
{ AF_BLUE_STRING_ADLAM_SMALL_BOTTOM, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_ARABIC_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_ARABIC_BOTTOM, 0 },
{ AF_BLUE_STRING_ARABIC_JOIN, AF_BLUE_PROPERTY_LATIN_NEUTRAL },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_ARMENIAN_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_ARMENIAN_CAPITAL_BOTTOM, 0 },
{ AF_BLUE_STRING_ARMENIAN_SMALL_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_ARMENIAN_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
{ AF_BLUE_STRING_ARMENIAN_SMALL_BOTTOM, 0 },
{ AF_BLUE_STRING_ARMENIAN_SMALL_DESCENDER, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_AVESTAN_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_AVESTAN_BOTTOM, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_BAMUM_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_BAMUM_BOTTOM, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_BENGALI_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_BENGALI_HEAD, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_BENGALI_BASE, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_NEUTRAL |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
{ AF_BLUE_STRING_BENGALI_BASE, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_BUHID_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_BUHID_LARGE, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_BUHID_SMALL, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
{ AF_BLUE_STRING_BUHID_BOTTOM, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_CHAKMA_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_CHAKMA_BOTTOM, 0 },
{ AF_BLUE_STRING_CHAKMA_DESCENDER, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_CANADIAN_SYLLABICS_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_CANADIAN_SYLLABICS_BOTTOM, 0 },
{ AF_BLUE_STRING_CANADIAN_SYLLABICS_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
{ AF_BLUE_STRING_CANADIAN_SYLLABICS_SMALL_BOTTOM, 0 },
{ AF_BLUE_STRING_CANADIAN_SYLLABICS_SUPS_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_CANADIAN_SYLLABICS_SUPS_BOTTOM, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_CARIAN_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_CARIAN_BOTTOM, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_CHEROKEE_CAPITAL, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_CHEROKEE_CAPITAL, 0 },
{ AF_BLUE_STRING_CHEROKEE_SMALL_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_CHEROKEE_SMALL, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
{ AF_BLUE_STRING_CHEROKEE_SMALL, 0 },
{ AF_BLUE_STRING_CHEROKEE_SMALL_DESCENDER, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_COPTIC_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_COPTIC_CAPITAL_BOTTOM, 0 },
{ AF_BLUE_STRING_COPTIC_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
{ AF_BLUE_STRING_COPTIC_SMALL_BOTTOM, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_CYPRIOT_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_CYPRIOT_BOTTOM, 0 },
{ AF_BLUE_STRING_CYPRIOT_SMALL, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_CYPRIOT_SMALL, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_CYRILLIC_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_CYRILLIC_CAPITAL_BOTTOM, 0 },
{ AF_BLUE_STRING_CYRILLIC_SMALL, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
{ AF_BLUE_STRING_CYRILLIC_SMALL, 0 },
{ AF_BLUE_STRING_CYRILLIC_SMALL_DESCENDER, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_DEVANAGARI_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_DEVANAGARI_HEAD, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_DEVANAGARI_BASE, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_NEUTRAL |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
{ AF_BLUE_STRING_DEVANAGARI_BASE, 0 },
{ AF_BLUE_STRING_DEVANAGARI_BOTTOM, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_DESERET_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_DESERET_CAPITAL_BOTTOM, 0 },
{ AF_BLUE_STRING_DESERET_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
{ AF_BLUE_STRING_DESERET_SMALL_BOTTOM, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_ETHIOPIC_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_ETHIOPIC_BOTTOM, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_GEORGIAN_MKHEDRULI_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
{ AF_BLUE_STRING_GEORGIAN_MKHEDRULI_BOTTOM, 0 },
{ AF_BLUE_STRING_GEORGIAN_MKHEDRULI_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_GEORGIAN_MKHEDRULI_DESCENDER, 0 },
{ AF_BLUE_STRING_GEORGIAN_MTAVRULI_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_GEORGIAN_MTAVRULI_BOTTOM, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_GEORGIAN_ASOMTAVRULI_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_GEORGIAN_ASOMTAVRULI_BOTTOM, 0 },
{ AF_BLUE_STRING_GEORGIAN_NUSKHURI_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
{ AF_BLUE_STRING_GEORGIAN_NUSKHURI_BOTTOM, 0 },
{ AF_BLUE_STRING_GEORGIAN_NUSKHURI_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_GEORGIAN_NUSKHURI_DESCENDER, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_GLAGOLITIC_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_GLAGOLITIC_CAPITAL_BOTTOM, 0 },
{ AF_BLUE_STRING_GLAGOLITIC_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
{ AF_BLUE_STRING_GLAGOLITIC_SMALL_BOTTOM, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_GOTHIC_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_GOTHIC_BOTTOM, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_GREEK_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_GREEK_CAPITAL_BOTTOM, 0 },
{ AF_BLUE_STRING_GREEK_SMALL_BETA_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_GREEK_SMALL, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
{ AF_BLUE_STRING_GREEK_SMALL, 0 },
{ AF_BLUE_STRING_GREEK_SMALL_DESCENDER, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_GUJARATI_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
{ AF_BLUE_STRING_GUJARATI_BOTTOM, 0 },
{ AF_BLUE_STRING_GUJARATI_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_GUJARATI_DESCENDER, 0 },
{ AF_BLUE_STRING_GUJARATI_DIGIT_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_GURMUKHI_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_GURMUKHI_HEAD, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_GURMUKHI_BASE, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_NEUTRAL |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
{ AF_BLUE_STRING_GURMUKHI_BOTTOM, 0 },
{ AF_BLUE_STRING_GURMUKHI_DIGIT_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_HEBREW_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_LONG },
{ AF_BLUE_STRING_HEBREW_BOTTOM, 0 },
{ AF_BLUE_STRING_HEBREW_DESCENDER, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_KANNADA_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_KANNADA_BOTTOM, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_KAYAH_LI_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
{ AF_BLUE_STRING_KAYAH_LI_BOTTOM, 0 },
{ AF_BLUE_STRING_KAYAH_LI_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_KAYAH_LI_DESCENDER, 0 },
{ AF_BLUE_STRING_KAYAH_LI_LARGE_DESCENDER, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_KHMER_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
{ AF_BLUE_STRING_KHMER_SUBSCRIPT_TOP, AF_BLUE_PROPERTY_LATIN_SUB_TOP },
{ AF_BLUE_STRING_KHMER_BOTTOM, 0 },
{ AF_BLUE_STRING_KHMER_DESCENDER, 0 },
{ AF_BLUE_STRING_KHMER_LARGE_DESCENDER, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_KHMER_SYMBOLS_WAXING_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
{ AF_BLUE_STRING_KHMER_SYMBOLS_WANING_BOTTOM, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_LAO_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
{ AF_BLUE_STRING_LAO_BOTTOM, 0 },
{ AF_BLUE_STRING_LAO_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_LAO_LARGE_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_LAO_DESCENDER, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_LATIN_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_LATIN_CAPITAL_BOTTOM, 0 },
{ AF_BLUE_STRING_LATIN_SMALL_F_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_LATIN_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
{ AF_BLUE_STRING_LATIN_SMALL_BOTTOM, 0 },
{ AF_BLUE_STRING_LATIN_SMALL_DESCENDER, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_LATIN_SUBS_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_LATIN_SUBS_CAPITAL_BOTTOM, 0 },
{ AF_BLUE_STRING_LATIN_SUBS_SMALL_F_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_LATIN_SUBS_SMALL, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
{ AF_BLUE_STRING_LATIN_SUBS_SMALL, 0 },
{ AF_BLUE_STRING_LATIN_SUBS_SMALL_DESCENDER, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_LATIN_SUPS_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_LATIN_SUPS_CAPITAL_BOTTOM, 0 },
{ AF_BLUE_STRING_LATIN_SUPS_SMALL_F_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_LATIN_SUPS_SMALL, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
{ AF_BLUE_STRING_LATIN_SUPS_SMALL, 0 },
{ AF_BLUE_STRING_LATIN_SUPS_SMALL_DESCENDER, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_LISU_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_LISU_BOTTOM, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_MALAYALAM_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_MALAYALAM_BOTTOM, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_MEDEFAIDRIN_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_MEDEFAIDRIN_CAPITAL_BOTTOM, 0 },
{ AF_BLUE_STRING_MEDEFAIDRIN_SMALL_F_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_MEDEFAIDRIN_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
{ AF_BLUE_STRING_MEDEFAIDRIN_SMALL_BOTTOM, 0 },
{ AF_BLUE_STRING_MEDEFAIDRIN_SMALL_DESCENDER, 0 },
{ AF_BLUE_STRING_MEDEFAIDRIN_DIGIT_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_MONGOLIAN_TOP_BASE, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_MONGOLIAN_BOTTOM_BASE, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_MYANMAR_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
{ AF_BLUE_STRING_MYANMAR_BOTTOM, 0 },
{ AF_BLUE_STRING_MYANMAR_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_MYANMAR_DESCENDER, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_NKO_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_NKO_BOTTOM, 0 },
{ AF_BLUE_STRING_NKO_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
{ AF_BLUE_STRING_NKO_SMALL_BOTTOM, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_OL_CHIKI, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_OL_CHIKI, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_OLD_TURKIC_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_OLD_TURKIC_BOTTOM, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_OSAGE_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_OSAGE_CAPITAL_BOTTOM, 0 },
{ AF_BLUE_STRING_OSAGE_CAPITAL_DESCENDER, 0 },
{ AF_BLUE_STRING_OSAGE_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
{ AF_BLUE_STRING_OSAGE_SMALL_BOTTOM, 0 },
{ AF_BLUE_STRING_OSAGE_SMALL_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_OSAGE_SMALL_DESCENDER, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_OSMANYA_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_OSMANYA_BOTTOM, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_ROHINGYA_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_ROHINGYA_BOTTOM, 0 },
{ AF_BLUE_STRING_ROHINGYA_JOIN, AF_BLUE_PROPERTY_LATIN_NEUTRAL },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_SAURASHTRA_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_SAURASHTRA_BOTTOM, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_SHAVIAN_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_SHAVIAN_BOTTOM, 0 },
{ AF_BLUE_STRING_SHAVIAN_DESCENDER, 0 },
{ AF_BLUE_STRING_SHAVIAN_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
{ AF_BLUE_STRING_SHAVIAN_SMALL_BOTTOM, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_SINHALA_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_SINHALA_BOTTOM, 0 },
{ AF_BLUE_STRING_SINHALA_DESCENDER, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_SUNDANESE_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_SUNDANESE_BOTTOM, 0 },
{ AF_BLUE_STRING_SUNDANESE_DESCENDER, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_TAMIL_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_TAMIL_BOTTOM, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_TAI_VIET_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_TAI_VIET_BOTTOM, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_TELUGU_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_TELUGU_BOTTOM, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_THAI_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT },
{ AF_BLUE_STRING_THAI_BOTTOM, 0 },
{ AF_BLUE_STRING_THAI_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_THAI_LARGE_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_THAI_DESCENDER, 0 },
{ AF_BLUE_STRING_THAI_LARGE_DESCENDER, 0 },
{ AF_BLUE_STRING_THAI_DIGIT_TOP, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_TIFINAGH, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_TIFINAGH, 0 },
{ AF_BLUE_STRING_MAX, 0 },
{ AF_BLUE_STRING_VAI_TOP, AF_BLUE_PROPERTY_LATIN_TOP },
{ AF_BLUE_STRING_VAI_BOTTOM, 0 },
{ AF_BLUE_STRING_MAX, 0 },
#ifdef AF_CONFIG_OPTION_CJK
{ AF_BLUE_STRING_CJK_TOP, AF_BLUE_PROPERTY_CJK_TOP },
{ AF_BLUE_STRING_CJK_BOTTOM, 0 },
#ifdef AF_CONFIG_OPTION_CJK_BLUE_HANI_VERT
{ AF_BLUE_STRING_CJK_LEFT, AF_BLUE_PROPERTY_CJK_HORIZ },
{ AF_BLUE_STRING_CJK_RIGHT, AF_BLUE_PROPERTY_CJK_HORIZ |
AF_BLUE_PROPERTY_CJK_RIGHT },
#endif /* AF_CONFIG_OPTION_CJK_BLUE_HANI_VERT */
{ AF_BLUE_STRING_MAX, 0 },
#endif /* AF_CONFIG_OPTION_CJK */
};
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/autofit/afblue.c
|
C++
|
gpl-3.0
| 76,975
|
/****************************************************************************
*
* afblue.c
*
* Auto-fitter data for blue strings (body).
*
* Copyright (C) 2013-2022 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.
*
*/
#include "aftypes.h"
FT_LOCAL_ARRAY_DEF( char )
af_blue_strings[] =
{
/* */
@AF_BLUE_STRINGS_ARRAY@
};
/* stringsets are specific to styles */
FT_LOCAL_ARRAY_DEF( AF_Blue_StringRec )
af_blue_stringsets[] =
{
/* */
@AF_BLUE_STRINGSETS_ARRAY@
};
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/autofit/afblue.cin
|
cin
|
gpl-3.0
| 830
|
// afblue.dat
//
// Auto-fitter data for blue strings.
//
// Copyright (C) 2013-2022 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 file contains data specific to blue zones. It gets processed by
// a script to simulate `jagged arrays', with enumeration values holding
// offsets into the arrays.
//
// The format of the file is rather simple: A section starts with three
// labels separated by whitespace and followed by a colon (everything in a
// single line); the first label gives the name of the enumeration template,
// the second the name of the array template, and the third the name of the
// `maximum' template. The script then fills the corresponding templates
// (indicated by `@' characters around the name).
//
// A section contains one or more data records. Each data record consists
// of two or more lines. The first line holds the enumeration name, and the
// remaining lines the corresponding array data.
//
// There are two possible representations for array data.
//
// - A string of characters or character clusters (for example, representing
// Aksharas, Devanagari syllables) in UTF-8 encoding enclosed in double
// quotes, using C syntax, where the elements are separated by spaces.
// There can be only one string per line, thus the starting and ending
// double quote must be the first and last character in the line,
// respectively, ignoring whitespace before and after the string. If
// there are multiple strings (in multiple lines), they are concatenated
// to a single string. In the output, a string gets represented as a
// series of singles bytes, followed by a zero byte. The enumeration
// values simply hold byte offsets to the start of the corresponding
// strings.
//
// For strings, the `maximum' template holds the maximum number of
// non-space characters in all strings.
//
// - Data blocks enclosed in balanced braces, which get copied verbatim and
// which can span multiple lines. The opening brace of a block must be
// the first character of a line (ignoring whitespace), and the closing
// brace the last (ignoring whitespace also). The script appends a comma
// character after each block and counts the number of blocks to set the
// enumeration values.
//
// For data blocks, the `maximum' template holds the maximum number of
// array elements.
//
// A section can contain either strings only or data blocks only.
//
// A comment line starts with `//'; it gets removed. A preprocessor
// directive line (using the standard syntax of `cpp') starts with `#' and
// gets copied verbatim to both the enumeration and the array. Whitespace
// outside of a string is insignificant.
//
// Preprocessor directives are ignored while the script computes maximum
// values; this essentially means that the maximum values can easily be too
// large. Given that the purpose of those values is to create local
// fixed-size arrays at compile time for further processing of the blue zone
// data, this isn't a problem. Note the final zero byte of a string is not
// counted. Note also that the count holds the number of UTF-8 encoded
// characters, not bytes.
// The blue zone string data, to be used in the blue stringsets below.
AF_BLUE_STRING_ENUM AF_BLUE_STRINGS_ARRAY AF_BLUE_STRING_MAX_LEN:
AF_BLUE_STRING_ADLAM_CAPITAL_TOP
"𞤌 𞤅 𞤈 𞤏 𞤔 𞤚"
AF_BLUE_STRING_ADLAM_CAPITAL_BOTTOM
"𞤂 𞤖"
AF_BLUE_STRING_ADLAM_SMALL_TOP
"𞤬 𞤮 𞤻 𞤼 𞤾"
AF_BLUE_STRING_ADLAM_SMALL_BOTTOM
"𞤤 𞤨 𞤩 𞤭 𞤴 𞤸 𞤺 𞥀"
AF_BLUE_STRING_ARABIC_TOP
"ا إ ل ك ط ظ"
AF_BLUE_STRING_ARABIC_BOTTOM
"ت ث ط ظ ك"
// We don't necessarily have access to medial forms via Unicode in case
// Arabic presentational forms are missing. The only character that is
// guaranteed to have the same vertical position with joining (this is,
// non-isolated) forms is U+0640, ARABIC TATWEEL, which must join both
// round and flat curves.
AF_BLUE_STRING_ARABIC_JOIN
"ـ"
AF_BLUE_STRING_ARMENIAN_CAPITAL_TOP
"Ա Մ Ւ Ս Բ Գ Դ Օ"
AF_BLUE_STRING_ARMENIAN_CAPITAL_BOTTOM
"Ւ Ո Դ Ճ Շ Ս Տ Օ"
AF_BLUE_STRING_ARMENIAN_SMALL_ASCENDER
"ե է ի մ վ ֆ ճ"
AF_BLUE_STRING_ARMENIAN_SMALL_TOP
"ա յ ւ ս գ շ ր օ"
AF_BLUE_STRING_ARMENIAN_SMALL_BOTTOM
"հ ո ճ ա ե ծ ս օ"
AF_BLUE_STRING_ARMENIAN_SMALL_DESCENDER
"բ ը ի լ ղ պ փ ց"
AF_BLUE_STRING_AVESTAN_TOP
"𐬀 𐬁 𐬐 𐬛"
AF_BLUE_STRING_AVESTAN_BOTTOM
"𐬀 𐬁"
AF_BLUE_STRING_BAMUM_TOP
"ꚧ ꚨ ꛛ ꛉ ꛁ ꛈ ꛫ ꛯ"
AF_BLUE_STRING_BAMUM_BOTTOM
"ꚭ ꚳ ꚶ ꛬ ꚢ ꚽ ꛯ ꛲"
AF_BLUE_STRING_BENGALI_BASE
"অ ড ত ন ব ভ ল ক"
AF_BLUE_STRING_BENGALI_TOP
"ই ট ঠ ি ী ৈ ৗ"
AF_BLUE_STRING_BENGALI_HEAD
"ও এ ড ত ন ব ল ক"
AF_BLUE_STRING_BUHID_TOP
"ᝐ ᝈ"
AF_BLUE_STRING_BUHID_LARGE
"ᝅ ᝊ ᝎ"
AF_BLUE_STRING_BUHID_SMALL
"ᝂ ᝃ ᝉ ᝌ"
AF_BLUE_STRING_BUHID_BOTTOM
"ᝀ ᝃ ᝆ ᝉ ᝋ ᝏ ᝑ"
AF_BLUE_STRING_CANADIAN_SYLLABICS_TOP
"ᗜ ᖴ ᐁ ᒣ ᑫ ᑎ ᔑ ᗰ"
AF_BLUE_STRING_CANADIAN_SYLLABICS_BOTTOM
"ᗶ ᖵ ᒧ ᐃ ᑌ ᒍ ᔑ ᗢ"
AF_BLUE_STRING_CANADIAN_SYLLABICS_SMALL_TOP
"ᓓ ᓕ ᓀ ᓂ ᓄ ᕄ ᕆ ᘣ"
AF_BLUE_STRING_CANADIAN_SYLLABICS_SMALL_BOTTOM
"ᕃ ᓂ ᓀ ᕂ ᓗ ᓚ ᕆ ᘣ"
AF_BLUE_STRING_CANADIAN_SYLLABICS_SUPS_TOP
"ᐪ ᙆ ᣘ ᐢ ᒾ ᣗ ᔆ"
AF_BLUE_STRING_CANADIAN_SYLLABICS_SUPS_BOTTOM
"ᙆ ᗮ ᒻ ᐞ ᔆ ᒡ ᒢ ᓑ"
AF_BLUE_STRING_CARIAN_TOP
"𐊧 𐊫 𐊬 𐊭 𐊱 𐊺 𐊼 𐊿"
AF_BLUE_STRING_CARIAN_BOTTOM
"𐊣 𐊧 𐊷 𐋀 𐊫 𐊸 𐋉"
AF_BLUE_STRING_CHAKMA_TOP
"𑄃 𑄅 𑄉 𑄙 𑄗"
AF_BLUE_STRING_CHAKMA_BOTTOM
"𑄅 𑄛 𑄝 𑄗 𑄓"
AF_BLUE_STRING_CHAKMA_DESCENDER
"𑄖𑄳𑄢 𑄘𑄳𑄢 𑄙𑄳𑄢 𑄤𑄳𑄢 𑄥𑄳𑄢"
AF_BLUE_STRING_CHEROKEE_CAPITAL
"Ꮖ Ꮋ Ꭼ Ꮓ Ꭴ Ꮳ Ꭶ Ꮥ"
AF_BLUE_STRING_CHEROKEE_SMALL_ASCENDER
"ꮒ ꮤ ꮶ ꭴ ꭾ ꮗ ꮝ ꮿ"
AF_BLUE_STRING_CHEROKEE_SMALL
"ꮖ ꭼ ꮓ ꮠ ꮳ ꭶ ꮥ ꮻ"
AF_BLUE_STRING_CHEROKEE_SMALL_DESCENDER
"ᏸ ꮐ ꭹ ꭻ"
AF_BLUE_STRING_COPTIC_CAPITAL_TOP
"Ⲍ Ⲏ Ⲡ Ⳟ Ⲟ Ⲑ Ⲥ Ⳋ"
AF_BLUE_STRING_COPTIC_CAPITAL_BOTTOM
"Ⳑ Ⳙ Ⳟ Ⲏ Ⲟ Ⲑ Ⳝ Ⲱ"
AF_BLUE_STRING_COPTIC_SMALL_TOP
"ⲍ ⲏ ⲡ ⳟ ⲟ ⲑ ⲥ ⳋ"
AF_BLUE_STRING_COPTIC_SMALL_BOTTOM
"ⳑ ⳙ ⳟ ⲏ ⲟ ⲑ ⳝ Ⳓ"
AF_BLUE_STRING_CYPRIOT_TOP
"𐠍 𐠙 𐠳 𐠱 𐠅 𐠓 𐠣 𐠦"
AF_BLUE_STRING_CYPRIOT_BOTTOM
"𐠃 𐠊 𐠛 𐠣 𐠳 𐠵 𐠐"
AF_BLUE_STRING_CYPRIOT_SMALL
"𐠈 𐠏 𐠖"
AF_BLUE_STRING_CYRILLIC_CAPITAL_TOP
"Б В Е П З О С Э"
AF_BLUE_STRING_CYRILLIC_CAPITAL_BOTTOM
"Б В Е Ш З О С Э"
AF_BLUE_STRING_CYRILLIC_SMALL
"х п н ш е з о с"
AF_BLUE_STRING_CYRILLIC_SMALL_DESCENDER
"р у ф"
AF_BLUE_STRING_DESERET_CAPITAL_TOP
"𐐂 𐐄 𐐋 𐐗 𐐑"
AF_BLUE_STRING_DESERET_CAPITAL_BOTTOM
"𐐀 𐐂 𐐄 𐐗 𐐛"
AF_BLUE_STRING_DESERET_SMALL_TOP
"𐐪 𐐬 𐐳 𐐿 𐐹"
AF_BLUE_STRING_DESERET_SMALL_BOTTOM
"𐐨 𐐪 𐐬 𐐿 𐑃"
AF_BLUE_STRING_DEVANAGARI_BASE
"क न म उ छ ट ठ ड"
AF_BLUE_STRING_DEVANAGARI_TOP
"ई ऐ ओ औ ि ी ो ौ"
// note that some fonts have extreme variation in the height of the
// round head elements; for this reason we also define the `base'
// blue zone, which must be always present
AF_BLUE_STRING_DEVANAGARI_HEAD
"क म अ आ थ ध भ श"
AF_BLUE_STRING_DEVANAGARI_BOTTOM
"ु ृ"
AF_BLUE_STRING_ETHIOPIC_TOP
"ሀ ሃ ዘ ፐ ማ በ ዋ ዐ"
AF_BLUE_STRING_ETHIOPIC_BOTTOM
"ለ ሐ በ ዘ ሀ ሪ ዐ ጨ"
AF_BLUE_STRING_GEORGIAN_MKHEDRULI_TOP
"გ დ ე ვ თ ი ო ღ"
AF_BLUE_STRING_GEORGIAN_MKHEDRULI_BOTTOM
"ა ზ მ ს შ ძ ხ პ"
AF_BLUE_STRING_GEORGIAN_MKHEDRULI_ASCENDER
"ს ხ ქ ზ მ შ ჩ წ"
AF_BLUE_STRING_GEORGIAN_MKHEDRULI_DESCENDER
"ე ვ ჟ ტ უ ფ ქ ყ"
AF_BLUE_STRING_GEORGIAN_ASOMTAVRULI_TOP
"Ⴑ Ⴇ Ⴙ Ⴜ Ⴄ Ⴅ Ⴓ Ⴚ"
AF_BLUE_STRING_GEORGIAN_ASOMTAVRULI_BOTTOM
"Ⴄ Ⴅ Ⴇ Ⴈ Ⴆ Ⴑ Ⴊ Ⴋ"
AF_BLUE_STRING_GEORGIAN_NUSKHURI_TOP
"ⴁ ⴗ ⴂ ⴄ ⴅ ⴇ ⴔ ⴖ"
AF_BLUE_STRING_GEORGIAN_NUSKHURI_BOTTOM
"ⴈ ⴌ ⴖ ⴎ ⴃ ⴆ ⴋ ⴢ"
AF_BLUE_STRING_GEORGIAN_NUSKHURI_ASCENDER
"ⴐ ⴑ ⴓ ⴕ ⴙ ⴛ ⴡ ⴣ"
AF_BLUE_STRING_GEORGIAN_NUSKHURI_DESCENDER
"ⴄ ⴅ ⴔ ⴕ ⴁ ⴂ ⴘ ⴝ"
AF_BLUE_STRING_GEORGIAN_MTAVRULI_TOP
"Ნ Ჟ Ჳ Ჸ Გ Ე Ო Ჴ"
AF_BLUE_STRING_GEORGIAN_MTAVRULI_BOTTOM
"Ი Ჲ Ო Ჩ Მ Შ Ჯ Ჽ"
AF_BLUE_STRING_GLAGOLITIC_CAPITAL_TOP
"Ⰵ Ⱄ Ⱚ Ⰴ Ⰲ Ⰺ Ⱛ Ⰻ"
AF_BLUE_STRING_GLAGOLITIC_CAPITAL_BOTTOM
"Ⰵ Ⰴ Ⰲ Ⱚ Ⱎ Ⱑ Ⰺ Ⱄ"
AF_BLUE_STRING_GLAGOLITIC_SMALL_TOP
"ⰵ ⱄ ⱚ ⰴ ⰲ ⰺ ⱛ ⰻ"
AF_BLUE_STRING_GLAGOLITIC_SMALL_BOTTOM
"ⰵ ⰴ ⰲ ⱚ ⱎ ⱑ ⰺ ⱄ"
AF_BLUE_STRING_GOTHIC_TOP
"𐌲 𐌶 𐍀 𐍄 𐌴 𐍃 𐍈 𐌾"
AF_BLUE_STRING_GOTHIC_BOTTOM
"𐌶 𐌴 𐍃 𐍈"
AF_BLUE_STRING_GREEK_CAPITAL_TOP
"Γ Β Ε Ζ Θ Ο Ω"
AF_BLUE_STRING_GREEK_CAPITAL_BOTTOM
"Β Δ Ζ Ξ Θ Ο"
AF_BLUE_STRING_GREEK_SMALL_BETA_TOP
"β θ δ ζ λ ξ"
AF_BLUE_STRING_GREEK_SMALL
"α ε ι ο π σ τ ω"
AF_BLUE_STRING_GREEK_SMALL_DESCENDER
"β γ η μ ρ φ χ ψ"
AF_BLUE_STRING_GUJARATI_TOP
"ત ન ઋ ઌ છ ટ ર ૦"
AF_BLUE_STRING_GUJARATI_BOTTOM
"ખ ગ ઘ ઞ ઇ ઈ ઠ જ"
AF_BLUE_STRING_GUJARATI_ASCENDER
"ઈ ઊ િ ી લી શ્ચિ જિ સી"
AF_BLUE_STRING_GUJARATI_DESCENDER
"ુ ૃ ૄ ખુ છૃ છૄ"
AF_BLUE_STRING_GUJARATI_DIGIT_TOP
"૦ ૧ ૨ ૩ ૭"
AF_BLUE_STRING_GURMUKHI_BASE
"ਕ ਗ ਙ ਚ ਜ ਤ ਧ ਸ"
AF_BLUE_STRING_GURMUKHI_HEAD
"ਕ ਗ ਙ ਚ ਜ ਤ ਧ ਸ"
AF_BLUE_STRING_GURMUKHI_TOP
"ਇ ਈ ਉ ਏ ਓ ੳ ਿ ੀ"
AF_BLUE_STRING_GURMUKHI_BOTTOM
"ਅ ਏ ਓ ਗ ਜ ਠ ਰ ਸ"
AF_BLUE_STRING_GURMUKHI_DIGIT_TOP
"੦ ੧ ੨ ੩ ੭"
AF_BLUE_STRING_HEBREW_TOP
"ב ד ה ח ך כ ם ס"
AF_BLUE_STRING_HEBREW_BOTTOM
"ב ט כ ם ס צ"
AF_BLUE_STRING_HEBREW_DESCENDER
"ק ך ן ף ץ"
AF_BLUE_STRING_KANNADA_TOP
"ಇ ಊ ಐ ಣ ಸಾ ನಾ ದಾ ರಾ"
AF_BLUE_STRING_KANNADA_BOTTOM
"ಅ ಉ ಎ ಲ ೦ ೨ ೬ ೭"
AF_BLUE_STRING_KAYAH_LI_TOP
"꤅ ꤏ ꤁ ꤋ ꤀ ꤍ"
AF_BLUE_STRING_KAYAH_LI_BOTTOM
"꤈ ꤘ ꤀ ꤍ ꤢ"
AF_BLUE_STRING_KAYAH_LI_ASCENDER
"ꤖ ꤡ"
AF_BLUE_STRING_KAYAH_LI_DESCENDER
"ꤑ ꤜ ꤞ"
AF_BLUE_STRING_KAYAH_LI_LARGE_DESCENDER
"ꤑ꤬ ꤜ꤭ ꤔ꤬"
AF_BLUE_STRING_KHMER_TOP
"ខ ទ ន ឧ ឩ ា"
AF_BLUE_STRING_KHMER_SUBSCRIPT_TOP
"ក្ក ក្ខ ក្គ ក្ថ"
AF_BLUE_STRING_KHMER_BOTTOM
"ខ ឃ ច ឋ ប ម យ ឲ"
AF_BLUE_STRING_KHMER_DESCENDER
"ត្រ រៀ ឲ្យ អឿ"
AF_BLUE_STRING_KHMER_LARGE_DESCENDER
"ន្ត្រៃ ង្ខ្យ ក្បៀ ច្រៀ ន្តឿ ល្បឿ"
AF_BLUE_STRING_KHMER_SYMBOLS_WAXING_TOP
"᧠ ᧡"
AF_BLUE_STRING_KHMER_SYMBOLS_WANING_BOTTOM
"᧶ ᧹"
AF_BLUE_STRING_LAO_TOP
"າ ດ ອ ມ ລ ວ ຣ ງ"
AF_BLUE_STRING_LAO_BOTTOM
"າ ອ ບ ຍ ຣ ຮ ວ ຢ"
AF_BLUE_STRING_LAO_ASCENDER
"ປ ຢ ຟ ຝ"
AF_BLUE_STRING_LAO_LARGE_ASCENDER
"ໂ ໄ ໃ"
AF_BLUE_STRING_LAO_DESCENDER
"ງ ຊ ຖ ຽ ໆ ຯ"
AF_BLUE_STRING_LATIN_CAPITAL_TOP
"T H E Z O C Q S"
AF_BLUE_STRING_LATIN_CAPITAL_BOTTOM
"H E Z L O C U S"
AF_BLUE_STRING_LATIN_SMALL_F_TOP
"f i j k d b h"
AF_BLUE_STRING_LATIN_SMALL_TOP
"u v x z o e s c"
AF_BLUE_STRING_LATIN_SMALL_BOTTOM
"n r x z o e s c"
AF_BLUE_STRING_LATIN_SMALL_DESCENDER
"p q g j y"
// we assume that both the subscript and superscript ranges
// don't contain oldstyle digits (actually, most fonts probably
// have digits only in those ranges)
AF_BLUE_STRING_LATIN_SUBS_CAPITAL_TOP
"₀ ₃ ₅ ₇ ₈"
AF_BLUE_STRING_LATIN_SUBS_CAPITAL_BOTTOM
"₀ ₁ ₂ ₃ ₈"
AF_BLUE_STRING_LATIN_SUBS_SMALL_F_TOP
"ᵢ ⱼ ₕ ₖ ₗ"
AF_BLUE_STRING_LATIN_SUBS_SMALL
"ₐ ₑ ₒ ₓ ₙ ₛ ᵥ ᵤ ᵣ"
AF_BLUE_STRING_LATIN_SUBS_SMALL_DESCENDER
"ᵦ ᵧ ᵨ ᵩ ₚ"
AF_BLUE_STRING_LATIN_SUPS_CAPITAL_TOP
"⁰ ³ ⁵ ⁷ ᵀ ᴴ ᴱ ᴼ"
AF_BLUE_STRING_LATIN_SUPS_CAPITAL_BOTTOM
"⁰ ¹ ² ³ ᴱ ᴸ ᴼ ᵁ"
AF_BLUE_STRING_LATIN_SUPS_SMALL_F_TOP
"ᵇ ᵈ ᵏ ʰ ʲ ᶠ ⁱ"
AF_BLUE_STRING_LATIN_SUPS_SMALL
"ᵉ ᵒ ʳ ˢ ˣ ᶜ ᶻ"
AF_BLUE_STRING_LATIN_SUPS_SMALL_DESCENDER
"ᵖ ʸ ᵍ"
AF_BLUE_STRING_LISU_TOP
"ꓡ ꓧ ꓱ ꓶ ꓩ ꓚ ꓵ ꓳ"
AF_BLUE_STRING_LISU_BOTTOM
"ꓕ ꓜ ꓞ ꓡ ꓛ ꓢ ꓳ ꓴ"
AF_BLUE_STRING_MALAYALAM_TOP
"ഒ ട ഠ റ ച പ ച്ച പ്പ"
AF_BLUE_STRING_MALAYALAM_BOTTOM
"ട ഠ ധ ശ ഘ ച ഥ ല"
AF_BLUE_STRING_MEDEFAIDRIN_CAPITAL_TOP
"𖹀 𖹁 𖹂 𖹃 𖹏 𖹚 𖹟"
AF_BLUE_STRING_MEDEFAIDRIN_CAPITAL_BOTTOM
"𖹀 𖹁 𖹂 𖹃 𖹏 𖹚 𖹒 𖹓"
AF_BLUE_STRING_MEDEFAIDRIN_SMALL_F_TOP
"𖹤 𖹬 𖹧 𖹴 𖹶 𖹾"
AF_BLUE_STRING_MEDEFAIDRIN_SMALL_TOP
"𖹠 𖹡 𖹢 𖹹 𖹳 𖹮"
AF_BLUE_STRING_MEDEFAIDRIN_SMALL_BOTTOM
"𖹠 𖹡 𖹢 𖹳 𖹭 𖹽"
AF_BLUE_STRING_MEDEFAIDRIN_SMALL_DESCENDER
"𖹥 𖹨 𖹩"
AF_BLUE_STRING_MEDEFAIDRIN_DIGIT_TOP
"𖺀 𖺅 𖺈 𖺄 𖺍"
AF_BLUE_STRING_MONGOLIAN_TOP_BASE
"ᠳ ᠴ ᠶ ᠽ ᡂ ᡊ ᡡ ᡳ"
AF_BLUE_STRING_MONGOLIAN_BOTTOM_BASE
"ᡃ"
AF_BLUE_STRING_MYANMAR_TOP
"ခ ဂ င ဒ ဝ ၥ ၊ ။"
AF_BLUE_STRING_MYANMAR_BOTTOM
"င ဎ ဒ ပ ဗ ဝ ၊ ။"
AF_BLUE_STRING_MYANMAR_ASCENDER
"ဩ ြ ၍ ၏ ၆ ါ ိ"
AF_BLUE_STRING_MYANMAR_DESCENDER
"ဉ ည ဥ ဩ ဨ ၂ ၅ ၉"
AF_BLUE_STRING_NKO_TOP
"ߐ ߉ ߒ ߟ ߖ ߜ ߠ ߥ"
AF_BLUE_STRING_NKO_BOTTOM
"߀ ߘ ߡ ߠ ߥ"
AF_BLUE_STRING_NKO_SMALL_TOP
"ߏ ߛ ߋ"
AF_BLUE_STRING_NKO_SMALL_BOTTOM
"ߎ ߏ ߛ ߋ"
AF_BLUE_STRING_OL_CHIKI
"ᱛ ᱜ ᱝ ᱡ ᱢ ᱥ"
AF_BLUE_STRING_OLD_TURKIC_TOP
"𐰗 𐰘 𐰧"
AF_BLUE_STRING_OLD_TURKIC_BOTTOM
"𐰉 𐰗 𐰦 𐰧"
AF_BLUE_STRING_OSAGE_CAPITAL_TOP
"𐒾 𐓍 𐓒 𐓓 𐒻 𐓂 𐒵 𐓆"
AF_BLUE_STRING_OSAGE_CAPITAL_BOTTOM
"𐒰 𐓍 𐓂 𐒿 𐓎 𐒹"
AF_BLUE_STRING_OSAGE_CAPITAL_DESCENDER
"𐒼 𐒽 𐒾"
AF_BLUE_STRING_OSAGE_SMALL_TOP
"𐓵 𐓶 𐓺 𐓻 𐓝 𐓣 𐓪 𐓮"
AF_BLUE_STRING_OSAGE_SMALL_BOTTOM
"𐓘 𐓚 𐓣 𐓵 𐓡 𐓧 𐓪 𐓶"
AF_BLUE_STRING_OSAGE_SMALL_ASCENDER
"𐓤 𐓦 𐓸 𐓹 𐓛"
AF_BLUE_STRING_OSAGE_SMALL_DESCENDER
"𐓤 𐓥 𐓦"
AF_BLUE_STRING_OSMANYA_TOP
"𐒆 𐒉 𐒐 𐒒 𐒘 𐒛 𐒠 𐒣"
AF_BLUE_STRING_OSMANYA_BOTTOM
"𐒀 𐒂 𐒆 𐒈 𐒊 𐒒 𐒠 𐒩"
AF_BLUE_STRING_ROHINGYA_TOP
"𐴃 𐴀 𐴆 𐴖 𐴕"
AF_BLUE_STRING_ROHINGYA_BOTTOM
"𐴔 𐴖 𐴕 𐴑 𐴐"
AF_BLUE_STRING_ROHINGYA_JOIN
"ـ"
AF_BLUE_STRING_SAURASHTRA_TOP
"ꢜ ꢞ ꢳ ꢂ ꢖ ꢒ ꢝ ꢛ"
AF_BLUE_STRING_SAURASHTRA_BOTTOM
"ꢂ ꢨ ꢺ ꢤ ꢎ"
AF_BLUE_STRING_SHAVIAN_TOP
"𐑕 𐑙"
AF_BLUE_STRING_SHAVIAN_BOTTOM
"𐑔 𐑖 𐑗 𐑹 𐑻"
AF_BLUE_STRING_SHAVIAN_DESCENDER
"𐑟 𐑣"
AF_BLUE_STRING_SHAVIAN_SMALL_TOP
"𐑱 𐑲 𐑳 𐑴 𐑸 𐑺 𐑼"
AF_BLUE_STRING_SHAVIAN_SMALL_BOTTOM
"𐑴 𐑻 𐑹"
AF_BLUE_STRING_SINHALA_TOP
"ඉ ක ඝ ඳ ප ය ල ෆ"
AF_BLUE_STRING_SINHALA_BOTTOM
"එ ඔ ඝ ජ ට ථ ධ ර"
AF_BLUE_STRING_SINHALA_DESCENDER
"ද ඳ උ ල තූ තු බු දු"
AF_BLUE_STRING_SUNDANESE_TOP
"ᮋ ᮞ ᮮ ᮽ ᮰ ᮈ"
AF_BLUE_STRING_SUNDANESE_BOTTOM
"ᮄ ᮔ ᮕ ᮗ ᮰ ᮆ ᮈ ᮉ"
AF_BLUE_STRING_SUNDANESE_DESCENDER
"ᮼ ᳄"
AF_BLUE_STRING_TAI_VIET_TOP
"ꪆ ꪔ ꪒ ꪖ ꪫ"
AF_BLUE_STRING_TAI_VIET_BOTTOM
"ꪉ ꪫ ꪮ"
AF_BLUE_STRING_TAMIL_TOP
"உ ஒ ஓ ற ஈ க ங ச"
AF_BLUE_STRING_TAMIL_BOTTOM
"க ச ல ஶ உ ங ட ப"
AF_BLUE_STRING_TELUGU_TOP
"ఇ ఌ ఙ ఞ ణ ఱ ౯"
AF_BLUE_STRING_TELUGU_BOTTOM
"అ క చ ర ఽ ౨ ౬"
AF_BLUE_STRING_THAI_TOP
"บ เ แ อ ก า"
AF_BLUE_STRING_THAI_BOTTOM
"บ ป ษ ฯ อ ย ฮ"
AF_BLUE_STRING_THAI_ASCENDER
"ป ฝ ฟ"
AF_BLUE_STRING_THAI_LARGE_ASCENDER
"โ ใ ไ"
AF_BLUE_STRING_THAI_DESCENDER
"ฎ ฏ ฤ ฦ"
AF_BLUE_STRING_THAI_LARGE_DESCENDER
"ญ ฐ"
AF_BLUE_STRING_THAI_DIGIT_TOP
"๐ ๑ ๓"
AF_BLUE_STRING_TIFINAGH
"ⵔ ⵙ ⵛ ⵞ ⴵ ⴼ ⴹ ⵎ"
AF_BLUE_STRING_VAI_TOP
"ꗍ ꘖ ꘙ ꘜ ꖜ ꖝ ꔅ ꕢ"
AF_BLUE_STRING_VAI_BOTTOM
"ꗍ ꘖ ꘙ ꗞ ꔅ ꕢ ꖜ ꔆ"
#ifdef AF_CONFIG_OPTION_CJK
AF_BLUE_STRING_CJK_TOP
"他 们 你 來 們 到 和 地"
" 对 對 就 席 我 时 時 會"
" 来 為 能 舰 說 说 这 這"
" 齊 |"
" 军 同 已 愿 既 星 是 景"
" 民 照 现 現 理 用 置 要"
" 軍 那 配 里 開 雷 露 面"
" 顾"
AF_BLUE_STRING_CJK_BOTTOM
"个 为 人 他 以 们 你 來"
" 個 們 到 和 大 对 對 就"
" 我 时 時 有 来 為 要 說"
" 说 |"
" 主 些 因 它 想 意 理 生"
" 當 看 着 置 者 自 著 裡"
" 过 还 进 進 過 道 還 里"
" 面"
#ifdef AF_CONFIG_OPTION_CJK_BLUE_HANI_VERT
AF_BLUE_STRING_CJK_LEFT
" 些 们 你 來 們 到 和 地"
" 她 将 將 就 年 得 情 最"
" 样 樣 理 能 說 说 这 這"
" 通 |"
" 即 吗 吧 听 呢 品 响 嗎"
" 师 師 收 断 斷 明 眼 間"
" 间 际 陈 限 除 陳 随 際"
" 隨"
AF_BLUE_STRING_CJK_RIGHT
"事 前 學 将 將 情 想 或"
" 政 斯 新 样 樣 民 沒 没"
" 然 特 现 現 球 第 經 谁"
" 起 |"
" 例 別 别 制 动 動 吗 嗎"
" 增 指 明 朝 期 构 物 确"
" 种 調 调 費 费 那 都 間"
" 间"
#endif /* AF_CONFIG_OPTION_CJK_BLUE_HANI_VERT */
#endif /* AF_CONFIG_OPTION_CJK */
// The blue zone stringsets, as used in the script styles, cf. `afstyles.h'.
//
// The AF_BLUE_PROPERTY_XXX flags are defined in `afblue.h'; here some
// explanations.
//
// A blue zone in general is defined by a reference and an overshoot line.
// During the hinting process, all coordinate values between those two lines
// are set equal to the reference value, provided that the blue zone is not
// wider than 0.75 pixels (otherwise the blue zone gets ignored). All
// entries must have `AF_BLUE_STRING_MAX' as the final line.
//
// During the glyph analysis, edges are sorted from bottom to top, and then
// sequentially checked, edge by edge, against the blue zones in the order
// given below.
//
//
// latin auto-hinter
// -----------------
//
// Characters in a blue string are automatically classified as having a flat
// (reference) or a round (overshoot) extremum. The blue zone is then set
// up by the mean values of all flat extrema and all round extrema,
// respectively. Only horizontal blue zones (i.e., adjusting vertical
// coordinate values) are supported.
//
// Some scripts like Khmer need character composition to get all necessary
// blue zones, since Unicode only provides an abstract data model that
// doesn't represent all possible glyph shapes. For such character
// clusters, the HarfBuzz library is used to convert them into the
// corresponding glyphs. The largest glyph element (where `largest' can be
// either `largest ascender' or `largest descender') then defines the
// corresponding flat or round extremum.
//
// For the latin auto-hinter, the overshoot should be larger than the
// reference for top zones, and vice versa for bottom zones.
//
// LATIN_TOP
// Take the maximum flat and round coordinate values of the blue string
// characters for computing the blue zone's reference and overshoot
// values.
//
// If not set, take the minimum values.
//
// Mutually exclusive with `LATIN_SUB_TOP'.
//
// LATIN_SUB_TOP
// For all glyphs of a character cluster, compute the maximum flat
// and round coordinate values of each component, then take the
// smallest of the maximum values. The idea is to get the top of
// subscript glyphs, as used in Khmer, for example. Note that
// this mechanism doesn't work for ordinary ligatures.
//
// This flags indicates a secondary blue zone: It gets removed if
// there is a non-LATIN_SUB_TOP blue zone at the same coordinate
// value (after scaling).
//
// Mutually exclusive with `LATIN_TOP'.
//
// LATIN_NEUTRAL
// Ignore round extrema and define the blue zone with flat values only.
// Both top and bottom of contours can match. This is useful for
// scripts like Devanagari where vowel signs attach to the base
// character and are implemented as components of composite glyphs.
//
// If not set, both round and flat extrema are taken into account.
// Additionally, only the top or the bottom of a contour can match,
// depending on the LATIN_TOP flag.
//
// Neutral blue zones should always follow non-neutral blue zones.
//
// LATIN_X_HEIGHT
// Scale all glyphs vertically from the corresponding script to make the
// reference line of this blue zone align on the grid. The scaling
// takes place before all other blue zones get aligned to the grid.
// Only one blue character string of a script style can have this flag.
//
// LATIN_LONG
// Apply an additional constraint for blue zone values: Don't
// necessarily use the extremum as-is but a segment of the topmost (or
// bottommost) contour that is longer than a heuristic threshold, and
// which is not too far away vertically from the real extremum. This
// ensures that small bumps in the outline are ignored (for example, the
// `vertical serifs' found in many Hebrew glyph designs).
//
// The segment must be at least EM/25 font units long, and the distance
// to the extremum must be smaller than EM/4.
//
//
// cjk auto-hinter
// ---------------
//
// Characters in a blue string are *not* automatically classified. Instead,
// first come the characters used for the overshoot value, then the
// character `|', then the characters used for the reference value
// (everything separated by space characters). The blue zone is then set up
// by the mean values of all reference values and all overshoot values,
// respectively. Both horizontal and vertical blue zones (i.e., adjusting
// vertical and horizontal coordinate values, respectively) are supported.
//
// For the cjk auto-hinter, the overshoot should be smaller than the
// reference for top zones, and vice versa for bottom zones.
//
// CJK_TOP
// Take the maximum flat and round coordinate values of the blue string
// characters. If not set, take the minimum values.
//
// CJK_RIGHT
// A synonym for CJK_TOP. If CJK_HORIZ is set, this flag indicates the
// right blue zone, taking horizontal maximum values.
//
// CJK_HORIZ
// Define a blue zone for horizontal hinting (i.e., vertical blue
// zones). If not set, this is a blue zone for vertical hinting.
AF_BLUE_STRINGSET_ENUM AF_BLUE_STRINGSETS_ARRAY AF_BLUE_STRINGSET_MAX_LEN:
AF_BLUE_STRINGSET_ADLM
{ AF_BLUE_STRING_ADLAM_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_ADLAM_CAPITAL_BOTTOM, 0 }
{ AF_BLUE_STRING_ADLAM_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT }
{ AF_BLUE_STRING_ADLAM_SMALL_BOTTOM, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_ARAB
{ AF_BLUE_STRING_ARABIC_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_ARABIC_BOTTOM, 0 }
{ AF_BLUE_STRING_ARABIC_JOIN, AF_BLUE_PROPERTY_LATIN_NEUTRAL }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_ARMN
{ AF_BLUE_STRING_ARMENIAN_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_ARMENIAN_CAPITAL_BOTTOM, 0 }
{ AF_BLUE_STRING_ARMENIAN_SMALL_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_ARMENIAN_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT }
{ AF_BLUE_STRING_ARMENIAN_SMALL_BOTTOM, 0 }
{ AF_BLUE_STRING_ARMENIAN_SMALL_DESCENDER, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_AVST
{ AF_BLUE_STRING_AVESTAN_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_AVESTAN_BOTTOM, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_BAMU
{ AF_BLUE_STRING_BAMUM_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_BAMUM_BOTTOM, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_BENG
{ AF_BLUE_STRING_BENGALI_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_BENGALI_HEAD, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_BENGALI_BASE, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_NEUTRAL |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT }
{ AF_BLUE_STRING_BENGALI_BASE, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_BUHD
{ AF_BLUE_STRING_BUHID_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_BUHID_LARGE, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_BUHID_SMALL, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT }
{ AF_BLUE_STRING_BUHID_BOTTOM, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_CAKM
{ AF_BLUE_STRING_CHAKMA_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_CHAKMA_BOTTOM, 0 }
{ AF_BLUE_STRING_CHAKMA_DESCENDER, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_CANS
{ AF_BLUE_STRING_CANADIAN_SYLLABICS_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_CANADIAN_SYLLABICS_BOTTOM, 0 }
{ AF_BLUE_STRING_CANADIAN_SYLLABICS_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT }
{ AF_BLUE_STRING_CANADIAN_SYLLABICS_SMALL_BOTTOM, 0 }
{ AF_BLUE_STRING_CANADIAN_SYLLABICS_SUPS_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_CANADIAN_SYLLABICS_SUPS_BOTTOM, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_CARI
{ AF_BLUE_STRING_CARIAN_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_CARIAN_BOTTOM, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_CHER
{ AF_BLUE_STRING_CHEROKEE_CAPITAL, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_CHEROKEE_CAPITAL, 0 }
{ AF_BLUE_STRING_CHEROKEE_SMALL_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_CHEROKEE_SMALL, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT }
{ AF_BLUE_STRING_CHEROKEE_SMALL, 0 }
{ AF_BLUE_STRING_CHEROKEE_SMALL_DESCENDER, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_COPT
{ AF_BLUE_STRING_COPTIC_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_COPTIC_CAPITAL_BOTTOM, 0 }
{ AF_BLUE_STRING_COPTIC_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT }
{ AF_BLUE_STRING_COPTIC_SMALL_BOTTOM, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_CPRT
{ AF_BLUE_STRING_CYPRIOT_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_CYPRIOT_BOTTOM, 0 }
{ AF_BLUE_STRING_CYPRIOT_SMALL, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_CYPRIOT_SMALL, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_CYRL
{ AF_BLUE_STRING_CYRILLIC_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_CYRILLIC_CAPITAL_BOTTOM, 0 }
{ AF_BLUE_STRING_CYRILLIC_SMALL, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT }
{ AF_BLUE_STRING_CYRILLIC_SMALL, 0 }
{ AF_BLUE_STRING_CYRILLIC_SMALL_DESCENDER, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_DEVA
{ AF_BLUE_STRING_DEVANAGARI_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_DEVANAGARI_HEAD, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_DEVANAGARI_BASE, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_NEUTRAL |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT }
{ AF_BLUE_STRING_DEVANAGARI_BASE, 0 }
{ AF_BLUE_STRING_DEVANAGARI_BOTTOM, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_DSRT
{ AF_BLUE_STRING_DESERET_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_DESERET_CAPITAL_BOTTOM, 0 }
{ AF_BLUE_STRING_DESERET_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT }
{ AF_BLUE_STRING_DESERET_SMALL_BOTTOM, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_ETHI
{ AF_BLUE_STRING_ETHIOPIC_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_ETHIOPIC_BOTTOM, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_GEOR
{ AF_BLUE_STRING_GEORGIAN_MKHEDRULI_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT }
{ AF_BLUE_STRING_GEORGIAN_MKHEDRULI_BOTTOM, 0 }
{ AF_BLUE_STRING_GEORGIAN_MKHEDRULI_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_GEORGIAN_MKHEDRULI_DESCENDER, 0 }
{ AF_BLUE_STRING_GEORGIAN_MTAVRULI_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_GEORGIAN_MTAVRULI_BOTTOM, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_GEOK
{ AF_BLUE_STRING_GEORGIAN_ASOMTAVRULI_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_GEORGIAN_ASOMTAVRULI_BOTTOM, 0 }
{ AF_BLUE_STRING_GEORGIAN_NUSKHURI_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT }
{ AF_BLUE_STRING_GEORGIAN_NUSKHURI_BOTTOM, 0 }
{ AF_BLUE_STRING_GEORGIAN_NUSKHURI_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_GEORGIAN_NUSKHURI_DESCENDER, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_GLAG
{ AF_BLUE_STRING_GLAGOLITIC_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_GLAGOLITIC_CAPITAL_BOTTOM, 0 }
{ AF_BLUE_STRING_GLAGOLITIC_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT }
{ AF_BLUE_STRING_GLAGOLITIC_SMALL_BOTTOM, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_GOTH
{ AF_BLUE_STRING_GOTHIC_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_GOTHIC_BOTTOM, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_GREK
{ AF_BLUE_STRING_GREEK_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_GREEK_CAPITAL_BOTTOM, 0 }
{ AF_BLUE_STRING_GREEK_SMALL_BETA_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_GREEK_SMALL, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT }
{ AF_BLUE_STRING_GREEK_SMALL, 0 }
{ AF_BLUE_STRING_GREEK_SMALL_DESCENDER, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_GUJR
{ AF_BLUE_STRING_GUJARATI_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT }
{ AF_BLUE_STRING_GUJARATI_BOTTOM, 0 }
{ AF_BLUE_STRING_GUJARATI_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_GUJARATI_DESCENDER, 0 }
{ AF_BLUE_STRING_GUJARATI_DIGIT_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_GURU
{ AF_BLUE_STRING_GURMUKHI_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_GURMUKHI_HEAD, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_GURMUKHI_BASE, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_NEUTRAL |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT }
{ AF_BLUE_STRING_GURMUKHI_BOTTOM, 0 }
{ AF_BLUE_STRING_GURMUKHI_DIGIT_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_HEBR
{ AF_BLUE_STRING_HEBREW_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_LONG }
{ AF_BLUE_STRING_HEBREW_BOTTOM, 0 }
{ AF_BLUE_STRING_HEBREW_DESCENDER, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_KNDA
{ AF_BLUE_STRING_KANNADA_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_KANNADA_BOTTOM, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_KALI
{ AF_BLUE_STRING_KAYAH_LI_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT }
{ AF_BLUE_STRING_KAYAH_LI_BOTTOM, 0 }
{ AF_BLUE_STRING_KAYAH_LI_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_KAYAH_LI_DESCENDER, 0 }
{ AF_BLUE_STRING_KAYAH_LI_LARGE_DESCENDER, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_KHMR
{ AF_BLUE_STRING_KHMER_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT }
{ AF_BLUE_STRING_KHMER_SUBSCRIPT_TOP, AF_BLUE_PROPERTY_LATIN_SUB_TOP }
{ AF_BLUE_STRING_KHMER_BOTTOM, 0 }
{ AF_BLUE_STRING_KHMER_DESCENDER, 0 }
{ AF_BLUE_STRING_KHMER_LARGE_DESCENDER, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_KHMS
{ AF_BLUE_STRING_KHMER_SYMBOLS_WAXING_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT }
{ AF_BLUE_STRING_KHMER_SYMBOLS_WANING_BOTTOM, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_LAO
{ AF_BLUE_STRING_LAO_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT }
{ AF_BLUE_STRING_LAO_BOTTOM, 0 }
{ AF_BLUE_STRING_LAO_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_LAO_LARGE_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_LAO_DESCENDER, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_LATN
{ AF_BLUE_STRING_LATIN_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_LATIN_CAPITAL_BOTTOM, 0 }
{ AF_BLUE_STRING_LATIN_SMALL_F_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_LATIN_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT }
{ AF_BLUE_STRING_LATIN_SMALL_BOTTOM, 0 }
{ AF_BLUE_STRING_LATIN_SMALL_DESCENDER, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_LATB
{ AF_BLUE_STRING_LATIN_SUBS_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_LATIN_SUBS_CAPITAL_BOTTOM, 0 }
{ AF_BLUE_STRING_LATIN_SUBS_SMALL_F_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_LATIN_SUBS_SMALL, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT }
{ AF_BLUE_STRING_LATIN_SUBS_SMALL, 0 }
{ AF_BLUE_STRING_LATIN_SUBS_SMALL_DESCENDER, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_LATP
{ AF_BLUE_STRING_LATIN_SUPS_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_LATIN_SUPS_CAPITAL_BOTTOM, 0 }
{ AF_BLUE_STRING_LATIN_SUPS_SMALL_F_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_LATIN_SUPS_SMALL, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT }
{ AF_BLUE_STRING_LATIN_SUPS_SMALL, 0 }
{ AF_BLUE_STRING_LATIN_SUPS_SMALL_DESCENDER, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_LISU
{ AF_BLUE_STRING_LISU_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_LISU_BOTTOM, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_MLYM
{ AF_BLUE_STRING_MALAYALAM_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_MALAYALAM_BOTTOM, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_MEDF
{ AF_BLUE_STRING_MEDEFAIDRIN_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_MEDEFAIDRIN_CAPITAL_BOTTOM, 0 }
{ AF_BLUE_STRING_MEDEFAIDRIN_SMALL_F_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_MEDEFAIDRIN_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT }
{ AF_BLUE_STRING_MEDEFAIDRIN_SMALL_BOTTOM, 0 }
{ AF_BLUE_STRING_MEDEFAIDRIN_SMALL_DESCENDER, 0 }
{ AF_BLUE_STRING_MEDEFAIDRIN_DIGIT_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_MONG
{ AF_BLUE_STRING_MONGOLIAN_TOP_BASE, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_MONGOLIAN_BOTTOM_BASE, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_MYMR
{ AF_BLUE_STRING_MYANMAR_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT }
{ AF_BLUE_STRING_MYANMAR_BOTTOM, 0 }
{ AF_BLUE_STRING_MYANMAR_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_MYANMAR_DESCENDER, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_NKOO
{ AF_BLUE_STRING_NKO_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_NKO_BOTTOM, 0 }
{ AF_BLUE_STRING_NKO_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT }
{ AF_BLUE_STRING_NKO_SMALL_BOTTOM, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_NONE
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_OLCK
{ AF_BLUE_STRING_OL_CHIKI, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_OL_CHIKI, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_ORKH
{ AF_BLUE_STRING_OLD_TURKIC_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_OLD_TURKIC_BOTTOM, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_OSGE
{ AF_BLUE_STRING_OSAGE_CAPITAL_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_OSAGE_CAPITAL_BOTTOM, 0 }
{ AF_BLUE_STRING_OSAGE_CAPITAL_DESCENDER, 0 }
{ AF_BLUE_STRING_OSAGE_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT }
{ AF_BLUE_STRING_OSAGE_SMALL_BOTTOM, 0 }
{ AF_BLUE_STRING_OSAGE_SMALL_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_OSAGE_SMALL_DESCENDER, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_OSMA
{ AF_BLUE_STRING_OSMANYA_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_OSMANYA_BOTTOM, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_ROHG
{ AF_BLUE_STRING_ROHINGYA_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_ROHINGYA_BOTTOM, 0 }
{ AF_BLUE_STRING_ROHINGYA_JOIN, AF_BLUE_PROPERTY_LATIN_NEUTRAL }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_SAUR
{ AF_BLUE_STRING_SAURASHTRA_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_SAURASHTRA_BOTTOM, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_SHAW
{ AF_BLUE_STRING_SHAVIAN_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_SHAVIAN_BOTTOM, 0 }
{ AF_BLUE_STRING_SHAVIAN_DESCENDER, 0 }
{ AF_BLUE_STRING_SHAVIAN_SMALL_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT }
{ AF_BLUE_STRING_SHAVIAN_SMALL_BOTTOM, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_SINH
{ AF_BLUE_STRING_SINHALA_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_SINHALA_BOTTOM, 0 }
{ AF_BLUE_STRING_SINHALA_DESCENDER, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_SUND
{ AF_BLUE_STRING_SUNDANESE_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_SUNDANESE_BOTTOM, 0 }
{ AF_BLUE_STRING_SUNDANESE_DESCENDER, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_TAML
{ AF_BLUE_STRING_TAMIL_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_TAMIL_BOTTOM, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_TAVT
{ AF_BLUE_STRING_TAI_VIET_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_TAI_VIET_BOTTOM, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_TELU
{ AF_BLUE_STRING_TELUGU_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_TELUGU_BOTTOM, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_THAI
{ AF_BLUE_STRING_THAI_TOP, AF_BLUE_PROPERTY_LATIN_TOP |
AF_BLUE_PROPERTY_LATIN_X_HEIGHT }
{ AF_BLUE_STRING_THAI_BOTTOM, 0 }
{ AF_BLUE_STRING_THAI_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_THAI_LARGE_ASCENDER, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_THAI_DESCENDER, 0 }
{ AF_BLUE_STRING_THAI_LARGE_DESCENDER, 0 }
{ AF_BLUE_STRING_THAI_DIGIT_TOP, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_TFNG
{ AF_BLUE_STRING_TIFINAGH, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_TIFINAGH, 0 }
{ AF_BLUE_STRING_MAX, 0 }
AF_BLUE_STRINGSET_VAII
{ AF_BLUE_STRING_VAI_TOP, AF_BLUE_PROPERTY_LATIN_TOP }
{ AF_BLUE_STRING_VAI_BOTTOM, 0 }
{ AF_BLUE_STRING_MAX, 0 }
#ifdef AF_CONFIG_OPTION_CJK
AF_BLUE_STRINGSET_HANI
{ AF_BLUE_STRING_CJK_TOP, AF_BLUE_PROPERTY_CJK_TOP }
{ AF_BLUE_STRING_CJK_BOTTOM, 0 }
#ifdef AF_CONFIG_OPTION_CJK_BLUE_HANI_VERT
{ AF_BLUE_STRING_CJK_LEFT, AF_BLUE_PROPERTY_CJK_HORIZ }
{ AF_BLUE_STRING_CJK_RIGHT, AF_BLUE_PROPERTY_CJK_HORIZ |
AF_BLUE_PROPERTY_CJK_RIGHT }
#endif /* AF_CONFIG_OPTION_CJK_BLUE_HANI_VERT */
{ AF_BLUE_STRING_MAX, 0 }
#endif /* AF_CONFIG_OPTION_CJK */
// END
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/autofit/afblue.dat
|
dat
|
gpl-3.0
| 48,622
|
/* This file has been generated by the Perl script `afblue.pl', */
/* using data from file `afblue.dat'. */
/****************************************************************************
*
* afblue.h
*
* Auto-fitter data for blue strings (specification).
*
* Copyright (C) 2013-2022 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 AFBLUE_H_
#define AFBLUE_H_
FT_BEGIN_HEADER
/* an auxiliary macro to decode a UTF-8 character -- since we only use */
/* hard-coded, self-converted data, no error checking is performed */
#define GET_UTF8_CHAR( ch, p ) \
do \
{ \
ch = (unsigned char)*p++; \
if ( ch >= 0x80 ) \
{ \
FT_UInt len_; \
\
\
if ( ch < 0xE0 ) \
{ \
len_ = 1; \
ch &= 0x1F; \
} \
else if ( ch < 0xF0 ) \
{ \
len_ = 2; \
ch &= 0x0F; \
} \
else \
{ \
len_ = 3; \
ch &= 0x07; \
} \
\
for ( ; len_ > 0; len_-- ) \
ch = ( ch << 6 ) | ( *p++ & 0x3F ); \
} \
} while ( 0 )
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** B L U E S T R I N G S *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
/* At the bottommost level, we define strings for finding blue zones. */
#define AF_BLUE_STRING_MAX_LEN 51
/* The AF_Blue_String enumeration values are offsets into the */
/* `af_blue_strings' array. */
typedef enum AF_Blue_String_
{
AF_BLUE_STRING_ADLAM_CAPITAL_TOP = 0,
AF_BLUE_STRING_ADLAM_CAPITAL_BOTTOM = 30,
AF_BLUE_STRING_ADLAM_SMALL_TOP = 40,
AF_BLUE_STRING_ADLAM_SMALL_BOTTOM = 65,
AF_BLUE_STRING_ARABIC_TOP = 105,
AF_BLUE_STRING_ARABIC_BOTTOM = 123,
AF_BLUE_STRING_ARABIC_JOIN = 138,
AF_BLUE_STRING_ARMENIAN_CAPITAL_TOP = 141,
AF_BLUE_STRING_ARMENIAN_CAPITAL_BOTTOM = 165,
AF_BLUE_STRING_ARMENIAN_SMALL_ASCENDER = 189,
AF_BLUE_STRING_ARMENIAN_SMALL_TOP = 210,
AF_BLUE_STRING_ARMENIAN_SMALL_BOTTOM = 234,
AF_BLUE_STRING_ARMENIAN_SMALL_DESCENDER = 258,
AF_BLUE_STRING_AVESTAN_TOP = 282,
AF_BLUE_STRING_AVESTAN_BOTTOM = 302,
AF_BLUE_STRING_BAMUM_TOP = 312,
AF_BLUE_STRING_BAMUM_BOTTOM = 344,
AF_BLUE_STRING_BENGALI_BASE = 376,
AF_BLUE_STRING_BENGALI_TOP = 408,
AF_BLUE_STRING_BENGALI_HEAD = 436,
AF_BLUE_STRING_BUHID_TOP = 468,
AF_BLUE_STRING_BUHID_LARGE = 476,
AF_BLUE_STRING_BUHID_SMALL = 488,
AF_BLUE_STRING_BUHID_BOTTOM = 504,
AF_BLUE_STRING_CANADIAN_SYLLABICS_TOP = 532,
AF_BLUE_STRING_CANADIAN_SYLLABICS_BOTTOM = 564,
AF_BLUE_STRING_CANADIAN_SYLLABICS_SMALL_TOP = 596,
AF_BLUE_STRING_CANADIAN_SYLLABICS_SMALL_BOTTOM = 628,
AF_BLUE_STRING_CANADIAN_SYLLABICS_SUPS_TOP = 660,
AF_BLUE_STRING_CANADIAN_SYLLABICS_SUPS_BOTTOM = 688,
AF_BLUE_STRING_CARIAN_TOP = 720,
AF_BLUE_STRING_CARIAN_BOTTOM = 760,
AF_BLUE_STRING_CHAKMA_TOP = 795,
AF_BLUE_STRING_CHAKMA_BOTTOM = 820,
AF_BLUE_STRING_CHAKMA_DESCENDER = 845,
AF_BLUE_STRING_CHEROKEE_CAPITAL = 910,
AF_BLUE_STRING_CHEROKEE_SMALL_ASCENDER = 942,
AF_BLUE_STRING_CHEROKEE_SMALL = 974,
AF_BLUE_STRING_CHEROKEE_SMALL_DESCENDER = 1006,
AF_BLUE_STRING_COPTIC_CAPITAL_TOP = 1022,
AF_BLUE_STRING_COPTIC_CAPITAL_BOTTOM = 1054,
AF_BLUE_STRING_COPTIC_SMALL_TOP = 1086,
AF_BLUE_STRING_COPTIC_SMALL_BOTTOM = 1118,
AF_BLUE_STRING_CYPRIOT_TOP = 1150,
AF_BLUE_STRING_CYPRIOT_BOTTOM = 1190,
AF_BLUE_STRING_CYPRIOT_SMALL = 1225,
AF_BLUE_STRING_CYRILLIC_CAPITAL_TOP = 1240,
AF_BLUE_STRING_CYRILLIC_CAPITAL_BOTTOM = 1264,
AF_BLUE_STRING_CYRILLIC_SMALL = 1288,
AF_BLUE_STRING_CYRILLIC_SMALL_DESCENDER = 1312,
AF_BLUE_STRING_DESERET_CAPITAL_TOP = 1321,
AF_BLUE_STRING_DESERET_CAPITAL_BOTTOM = 1346,
AF_BLUE_STRING_DESERET_SMALL_TOP = 1371,
AF_BLUE_STRING_DESERET_SMALL_BOTTOM = 1396,
AF_BLUE_STRING_DEVANAGARI_BASE = 1421,
AF_BLUE_STRING_DEVANAGARI_TOP = 1453,
AF_BLUE_STRING_DEVANAGARI_HEAD = 1485,
AF_BLUE_STRING_DEVANAGARI_BOTTOM = 1517,
AF_BLUE_STRING_ETHIOPIC_TOP = 1525,
AF_BLUE_STRING_ETHIOPIC_BOTTOM = 1557,
AF_BLUE_STRING_GEORGIAN_MKHEDRULI_TOP = 1589,
AF_BLUE_STRING_GEORGIAN_MKHEDRULI_BOTTOM = 1621,
AF_BLUE_STRING_GEORGIAN_MKHEDRULI_ASCENDER = 1653,
AF_BLUE_STRING_GEORGIAN_MKHEDRULI_DESCENDER = 1685,
AF_BLUE_STRING_GEORGIAN_ASOMTAVRULI_TOP = 1717,
AF_BLUE_STRING_GEORGIAN_ASOMTAVRULI_BOTTOM = 1749,
AF_BLUE_STRING_GEORGIAN_NUSKHURI_TOP = 1781,
AF_BLUE_STRING_GEORGIAN_NUSKHURI_BOTTOM = 1813,
AF_BLUE_STRING_GEORGIAN_NUSKHURI_ASCENDER = 1845,
AF_BLUE_STRING_GEORGIAN_NUSKHURI_DESCENDER = 1877,
AF_BLUE_STRING_GEORGIAN_MTAVRULI_TOP = 1909,
AF_BLUE_STRING_GEORGIAN_MTAVRULI_BOTTOM = 1941,
AF_BLUE_STRING_GLAGOLITIC_CAPITAL_TOP = 1973,
AF_BLUE_STRING_GLAGOLITIC_CAPITAL_BOTTOM = 2005,
AF_BLUE_STRING_GLAGOLITIC_SMALL_TOP = 2037,
AF_BLUE_STRING_GLAGOLITIC_SMALL_BOTTOM = 2069,
AF_BLUE_STRING_GOTHIC_TOP = 2101,
AF_BLUE_STRING_GOTHIC_BOTTOM = 2141,
AF_BLUE_STRING_GREEK_CAPITAL_TOP = 2161,
AF_BLUE_STRING_GREEK_CAPITAL_BOTTOM = 2182,
AF_BLUE_STRING_GREEK_SMALL_BETA_TOP = 2200,
AF_BLUE_STRING_GREEK_SMALL = 2218,
AF_BLUE_STRING_GREEK_SMALL_DESCENDER = 2242,
AF_BLUE_STRING_GUJARATI_TOP = 2266,
AF_BLUE_STRING_GUJARATI_BOTTOM = 2298,
AF_BLUE_STRING_GUJARATI_ASCENDER = 2330,
AF_BLUE_STRING_GUJARATI_DESCENDER = 2380,
AF_BLUE_STRING_GUJARATI_DIGIT_TOP = 2413,
AF_BLUE_STRING_GURMUKHI_BASE = 2433,
AF_BLUE_STRING_GURMUKHI_HEAD = 2465,
AF_BLUE_STRING_GURMUKHI_TOP = 2497,
AF_BLUE_STRING_GURMUKHI_BOTTOM = 2529,
AF_BLUE_STRING_GURMUKHI_DIGIT_TOP = 2561,
AF_BLUE_STRING_HEBREW_TOP = 2581,
AF_BLUE_STRING_HEBREW_BOTTOM = 2605,
AF_BLUE_STRING_HEBREW_DESCENDER = 2623,
AF_BLUE_STRING_KANNADA_TOP = 2638,
AF_BLUE_STRING_KANNADA_BOTTOM = 2682,
AF_BLUE_STRING_KAYAH_LI_TOP = 2714,
AF_BLUE_STRING_KAYAH_LI_BOTTOM = 2738,
AF_BLUE_STRING_KAYAH_LI_ASCENDER = 2758,
AF_BLUE_STRING_KAYAH_LI_DESCENDER = 2766,
AF_BLUE_STRING_KAYAH_LI_LARGE_DESCENDER = 2778,
AF_BLUE_STRING_KHMER_TOP = 2799,
AF_BLUE_STRING_KHMER_SUBSCRIPT_TOP = 2823,
AF_BLUE_STRING_KHMER_BOTTOM = 2863,
AF_BLUE_STRING_KHMER_DESCENDER = 2895,
AF_BLUE_STRING_KHMER_LARGE_DESCENDER = 2929,
AF_BLUE_STRING_KHMER_SYMBOLS_WAXING_TOP = 3016,
AF_BLUE_STRING_KHMER_SYMBOLS_WANING_BOTTOM = 3024,
AF_BLUE_STRING_LAO_TOP = 3032,
AF_BLUE_STRING_LAO_BOTTOM = 3064,
AF_BLUE_STRING_LAO_ASCENDER = 3096,
AF_BLUE_STRING_LAO_LARGE_ASCENDER = 3112,
AF_BLUE_STRING_LAO_DESCENDER = 3124,
AF_BLUE_STRING_LATIN_CAPITAL_TOP = 3148,
AF_BLUE_STRING_LATIN_CAPITAL_BOTTOM = 3164,
AF_BLUE_STRING_LATIN_SMALL_F_TOP = 3180,
AF_BLUE_STRING_LATIN_SMALL_TOP = 3194,
AF_BLUE_STRING_LATIN_SMALL_BOTTOM = 3210,
AF_BLUE_STRING_LATIN_SMALL_DESCENDER = 3226,
AF_BLUE_STRING_LATIN_SUBS_CAPITAL_TOP = 3236,
AF_BLUE_STRING_LATIN_SUBS_CAPITAL_BOTTOM = 3256,
AF_BLUE_STRING_LATIN_SUBS_SMALL_F_TOP = 3276,
AF_BLUE_STRING_LATIN_SUBS_SMALL = 3296,
AF_BLUE_STRING_LATIN_SUBS_SMALL_DESCENDER = 3332,
AF_BLUE_STRING_LATIN_SUPS_CAPITAL_TOP = 3352,
AF_BLUE_STRING_LATIN_SUPS_CAPITAL_BOTTOM = 3383,
AF_BLUE_STRING_LATIN_SUPS_SMALL_F_TOP = 3412,
AF_BLUE_STRING_LATIN_SUPS_SMALL = 3438,
AF_BLUE_STRING_LATIN_SUPS_SMALL_DESCENDER = 3463,
AF_BLUE_STRING_LISU_TOP = 3474,
AF_BLUE_STRING_LISU_BOTTOM = 3506,
AF_BLUE_STRING_MALAYALAM_TOP = 3538,
AF_BLUE_STRING_MALAYALAM_BOTTOM = 3582,
AF_BLUE_STRING_MEDEFAIDRIN_CAPITAL_TOP = 3614,
AF_BLUE_STRING_MEDEFAIDRIN_CAPITAL_BOTTOM = 3649,
AF_BLUE_STRING_MEDEFAIDRIN_SMALL_F_TOP = 3689,
AF_BLUE_STRING_MEDEFAIDRIN_SMALL_TOP = 3719,
AF_BLUE_STRING_MEDEFAIDRIN_SMALL_BOTTOM = 3749,
AF_BLUE_STRING_MEDEFAIDRIN_SMALL_DESCENDER = 3779,
AF_BLUE_STRING_MEDEFAIDRIN_DIGIT_TOP = 3794,
AF_BLUE_STRING_MONGOLIAN_TOP_BASE = 3819,
AF_BLUE_STRING_MONGOLIAN_BOTTOM_BASE = 3863,
AF_BLUE_STRING_MYANMAR_TOP = 3867,
AF_BLUE_STRING_MYANMAR_BOTTOM = 3899,
AF_BLUE_STRING_MYANMAR_ASCENDER = 3931,
AF_BLUE_STRING_MYANMAR_DESCENDER = 3959,
AF_BLUE_STRING_NKO_TOP = 3991,
AF_BLUE_STRING_NKO_BOTTOM = 4015,
AF_BLUE_STRING_NKO_SMALL_TOP = 4030,
AF_BLUE_STRING_NKO_SMALL_BOTTOM = 4039,
AF_BLUE_STRING_OL_CHIKI = 4051,
AF_BLUE_STRING_OLD_TURKIC_TOP = 4075,
AF_BLUE_STRING_OLD_TURKIC_BOTTOM = 4090,
AF_BLUE_STRING_OSAGE_CAPITAL_TOP = 4110,
AF_BLUE_STRING_OSAGE_CAPITAL_BOTTOM = 4150,
AF_BLUE_STRING_OSAGE_CAPITAL_DESCENDER = 4180,
AF_BLUE_STRING_OSAGE_SMALL_TOP = 4195,
AF_BLUE_STRING_OSAGE_SMALL_BOTTOM = 4235,
AF_BLUE_STRING_OSAGE_SMALL_ASCENDER = 4275,
AF_BLUE_STRING_OSAGE_SMALL_DESCENDER = 4300,
AF_BLUE_STRING_OSMANYA_TOP = 4315,
AF_BLUE_STRING_OSMANYA_BOTTOM = 4355,
AF_BLUE_STRING_ROHINGYA_TOP = 4395,
AF_BLUE_STRING_ROHINGYA_BOTTOM = 4420,
AF_BLUE_STRING_ROHINGYA_JOIN = 4445,
AF_BLUE_STRING_SAURASHTRA_TOP = 4448,
AF_BLUE_STRING_SAURASHTRA_BOTTOM = 4480,
AF_BLUE_STRING_SHAVIAN_TOP = 4500,
AF_BLUE_STRING_SHAVIAN_BOTTOM = 4510,
AF_BLUE_STRING_SHAVIAN_DESCENDER = 4535,
AF_BLUE_STRING_SHAVIAN_SMALL_TOP = 4545,
AF_BLUE_STRING_SHAVIAN_SMALL_BOTTOM = 4580,
AF_BLUE_STRING_SINHALA_TOP = 4595,
AF_BLUE_STRING_SINHALA_BOTTOM = 4627,
AF_BLUE_STRING_SINHALA_DESCENDER = 4659,
AF_BLUE_STRING_SUNDANESE_TOP = 4703,
AF_BLUE_STRING_SUNDANESE_BOTTOM = 4727,
AF_BLUE_STRING_SUNDANESE_DESCENDER = 4759,
AF_BLUE_STRING_TAI_VIET_TOP = 4767,
AF_BLUE_STRING_TAI_VIET_BOTTOM = 4787,
AF_BLUE_STRING_TAMIL_TOP = 4799,
AF_BLUE_STRING_TAMIL_BOTTOM = 4831,
AF_BLUE_STRING_TELUGU_TOP = 4863,
AF_BLUE_STRING_TELUGU_BOTTOM = 4891,
AF_BLUE_STRING_THAI_TOP = 4919,
AF_BLUE_STRING_THAI_BOTTOM = 4943,
AF_BLUE_STRING_THAI_ASCENDER = 4971,
AF_BLUE_STRING_THAI_LARGE_ASCENDER = 4983,
AF_BLUE_STRING_THAI_DESCENDER = 4995,
AF_BLUE_STRING_THAI_LARGE_DESCENDER = 5011,
AF_BLUE_STRING_THAI_DIGIT_TOP = 5019,
AF_BLUE_STRING_TIFINAGH = 5031,
AF_BLUE_STRING_VAI_TOP = 5063,
AF_BLUE_STRING_VAI_BOTTOM = 5095,
af_blue_1_1 = 5126,
#ifdef AF_CONFIG_OPTION_CJK
AF_BLUE_STRING_CJK_TOP = af_blue_1_1 + 1,
AF_BLUE_STRING_CJK_BOTTOM = af_blue_1_1 + 203,
af_blue_1_1_1 = af_blue_1_1 + 404,
#ifdef AF_CONFIG_OPTION_CJK_BLUE_HANI_VERT
AF_BLUE_STRING_CJK_LEFT = af_blue_1_1_1 + 1,
AF_BLUE_STRING_CJK_RIGHT = af_blue_1_1_1 + 204,
af_blue_1_1_2 = af_blue_1_1_1 + 405,
#else
af_blue_1_1_2 = af_blue_1_1_1 + 0,
#endif /* AF_CONFIG_OPTION_CJK_BLUE_HANI_VERT */
af_blue_1_2 = af_blue_1_1_2 + 0,
#else
af_blue_1_2 = af_blue_1_1 + 0,
#endif /* AF_CONFIG_OPTION_CJK */
AF_BLUE_STRING_MAX /* do not remove */
} AF_Blue_String;
FT_LOCAL_ARRAY( char )
af_blue_strings[];
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** B L U E S T R I N G S E T S *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
/* The next level is to group blue strings into style-specific sets. */
/* Properties are specific to a writing system. We assume that a given */
/* blue string can't be used in more than a single writing system, which */
/* is a safe bet. */
#define AF_BLUE_PROPERTY_LATIN_TOP ( 1U << 0 ) /* must have value 1 */
#define AF_BLUE_PROPERTY_LATIN_SUB_TOP ( 1U << 1 )
#define AF_BLUE_PROPERTY_LATIN_NEUTRAL ( 1U << 2 )
#define AF_BLUE_PROPERTY_LATIN_X_HEIGHT ( 1U << 3 )
#define AF_BLUE_PROPERTY_LATIN_LONG ( 1U << 4 )
#define AF_BLUE_PROPERTY_CJK_TOP ( 1U << 0 ) /* must have value 1 */
#define AF_BLUE_PROPERTY_CJK_HORIZ ( 1U << 1 ) /* must have value 2 */
#define AF_BLUE_PROPERTY_CJK_RIGHT AF_BLUE_PROPERTY_CJK_TOP
#define AF_BLUE_STRINGSET_MAX_LEN 8
/* The AF_Blue_Stringset enumeration values are offsets into the */
/* `af_blue_stringsets' array. */
typedef enum AF_Blue_Stringset_
{
AF_BLUE_STRINGSET_ADLM = 0,
AF_BLUE_STRINGSET_ARAB = 5,
AF_BLUE_STRINGSET_ARMN = 9,
AF_BLUE_STRINGSET_AVST = 16,
AF_BLUE_STRINGSET_BAMU = 19,
AF_BLUE_STRINGSET_BENG = 22,
AF_BLUE_STRINGSET_BUHD = 27,
AF_BLUE_STRINGSET_CAKM = 32,
AF_BLUE_STRINGSET_CANS = 36,
AF_BLUE_STRINGSET_CARI = 43,
AF_BLUE_STRINGSET_CHER = 46,
AF_BLUE_STRINGSET_COPT = 53,
AF_BLUE_STRINGSET_CPRT = 58,
AF_BLUE_STRINGSET_CYRL = 63,
AF_BLUE_STRINGSET_DEVA = 69,
AF_BLUE_STRINGSET_DSRT = 75,
AF_BLUE_STRINGSET_ETHI = 80,
AF_BLUE_STRINGSET_GEOR = 83,
AF_BLUE_STRINGSET_GEOK = 90,
AF_BLUE_STRINGSET_GLAG = 97,
AF_BLUE_STRINGSET_GOTH = 102,
AF_BLUE_STRINGSET_GREK = 105,
AF_BLUE_STRINGSET_GUJR = 112,
AF_BLUE_STRINGSET_GURU = 118,
AF_BLUE_STRINGSET_HEBR = 124,
AF_BLUE_STRINGSET_KNDA = 128,
AF_BLUE_STRINGSET_KALI = 131,
AF_BLUE_STRINGSET_KHMR = 137,
AF_BLUE_STRINGSET_KHMS = 143,
AF_BLUE_STRINGSET_LAO = 146,
AF_BLUE_STRINGSET_LATN = 152,
AF_BLUE_STRINGSET_LATB = 159,
AF_BLUE_STRINGSET_LATP = 166,
AF_BLUE_STRINGSET_LISU = 173,
AF_BLUE_STRINGSET_MLYM = 176,
AF_BLUE_STRINGSET_MEDF = 179,
AF_BLUE_STRINGSET_MONG = 187,
AF_BLUE_STRINGSET_MYMR = 190,
AF_BLUE_STRINGSET_NKOO = 195,
AF_BLUE_STRINGSET_NONE = 200,
AF_BLUE_STRINGSET_OLCK = 201,
AF_BLUE_STRINGSET_ORKH = 204,
AF_BLUE_STRINGSET_OSGE = 207,
AF_BLUE_STRINGSET_OSMA = 215,
AF_BLUE_STRINGSET_ROHG = 218,
AF_BLUE_STRINGSET_SAUR = 222,
AF_BLUE_STRINGSET_SHAW = 225,
AF_BLUE_STRINGSET_SINH = 231,
AF_BLUE_STRINGSET_SUND = 235,
AF_BLUE_STRINGSET_TAML = 239,
AF_BLUE_STRINGSET_TAVT = 242,
AF_BLUE_STRINGSET_TELU = 245,
AF_BLUE_STRINGSET_THAI = 248,
AF_BLUE_STRINGSET_TFNG = 256,
AF_BLUE_STRINGSET_VAII = 259,
af_blue_2_1 = 262,
#ifdef AF_CONFIG_OPTION_CJK
AF_BLUE_STRINGSET_HANI = af_blue_2_1 + 0,
af_blue_2_1_1 = af_blue_2_1 + 2,
#ifdef AF_CONFIG_OPTION_CJK_BLUE_HANI_VERT
af_blue_2_1_2 = af_blue_2_1_1 + 2,
#else
af_blue_2_1_2 = af_blue_2_1_1 + 0,
#endif /* AF_CONFIG_OPTION_CJK_BLUE_HANI_VERT */
af_blue_2_2 = af_blue_2_1_2 + 1,
#else
af_blue_2_2 = af_blue_2_1 + 0,
#endif /* AF_CONFIG_OPTION_CJK */
AF_BLUE_STRINGSET_MAX /* do not remove */
} AF_Blue_Stringset;
typedef struct AF_Blue_StringRec_
{
AF_Blue_String string;
FT_UShort properties;
} AF_Blue_StringRec;
FT_LOCAL_ARRAY( AF_Blue_StringRec )
af_blue_stringsets[];
/* */
FT_END_HEADER
#endif /* AFBLUE_H_ */
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/autofit/afblue.h
|
C++
|
gpl-3.0
| 16,937
|
/****************************************************************************
*
* afblue.h
*
* Auto-fitter data for blue strings (specification).
*
* Copyright (C) 2013-2022 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 AFBLUE_H_
#define AFBLUE_H_
FT_BEGIN_HEADER
/* an auxiliary macro to decode a UTF-8 character -- since we only use */
/* hard-coded, self-converted data, no error checking is performed */
#define GET_UTF8_CHAR( ch, p ) \
do \
{ \
ch = (unsigned char)*p++; \
if ( ch >= 0x80 ) \
{ \
FT_UInt len_; \
\
\
if ( ch < 0xE0 ) \
{ \
len_ = 1; \
ch &= 0x1F; \
} \
else if ( ch < 0xF0 ) \
{ \
len_ = 2; \
ch &= 0x0F; \
} \
else \
{ \
len_ = 3; \
ch &= 0x07; \
} \
\
for ( ; len_ > 0; len_-- ) \
ch = ( ch << 6 ) | ( *p++ & 0x3F ); \
} \
} while ( 0 )
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** B L U E S T R I N G S *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
/* At the bottommost level, we define strings for finding blue zones. */
#define AF_BLUE_STRING_MAX_LEN @AF_BLUE_STRING_MAX_LEN@
/* The AF_Blue_String enumeration values are offsets into the */
/* `af_blue_strings' array. */
typedef enum AF_Blue_String_
{
@AF_BLUE_STRING_ENUM@
AF_BLUE_STRING_MAX /* do not remove */
} AF_Blue_String;
FT_LOCAL_ARRAY( char )
af_blue_strings[];
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** B L U E S T R I N G S E T S *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
/* The next level is to group blue strings into style-specific sets. */
/* Properties are specific to a writing system. We assume that a given */
/* blue string can't be used in more than a single writing system, which */
/* is a safe bet. */
#define AF_BLUE_PROPERTY_LATIN_TOP ( 1U << 0 ) /* must have value 1 */
#define AF_BLUE_PROPERTY_LATIN_SUB_TOP ( 1U << 1 )
#define AF_BLUE_PROPERTY_LATIN_NEUTRAL ( 1U << 2 )
#define AF_BLUE_PROPERTY_LATIN_X_HEIGHT ( 1U << 3 )
#define AF_BLUE_PROPERTY_LATIN_LONG ( 1U << 4 )
#define AF_BLUE_PROPERTY_CJK_TOP ( 1U << 0 ) /* must have value 1 */
#define AF_BLUE_PROPERTY_CJK_HORIZ ( 1U << 1 ) /* must have value 2 */
#define AF_BLUE_PROPERTY_CJK_RIGHT AF_BLUE_PROPERTY_CJK_TOP
#define AF_BLUE_STRINGSET_MAX_LEN @AF_BLUE_STRINGSET_MAX_LEN@
/* The AF_Blue_Stringset enumeration values are offsets into the */
/* `af_blue_stringsets' array. */
typedef enum AF_Blue_Stringset_
{
@AF_BLUE_STRINGSET_ENUM@
AF_BLUE_STRINGSET_MAX /* do not remove */
} AF_Blue_Stringset;
typedef struct AF_Blue_StringRec_
{
AF_Blue_String string;
FT_UShort properties;
} AF_Blue_StringRec;
FT_LOCAL_ARRAY( AF_Blue_StringRec )
af_blue_stringsets[];
/* */
FT_END_HEADER
#endif /* AFBLUE_H_ */
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/autofit/afblue.hin
|
hin
|
gpl-3.0
| 5,250
|
/****************************************************************************
*
* afcjk.c
*
* Auto-fitter hinting routines for CJK writing system (body).
*
* Copyright (C) 2006-2022 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.
*
*/
/*
* The algorithm is based on akito's autohint patch, archived at
*
* https://web.archive.org/web/20051219160454/http://www.kde.gr.jp:80/~akito/patch/freetype2/2.1.7/
*
*/
#include <freetype/ftadvanc.h>
#include <freetype/internal/ftdebug.h>
#include "afglobal.h"
#include "aflatin.h"
#include "afcjk.h"
#ifdef AF_CONFIG_OPTION_CJK
#undef AF_CONFIG_OPTION_CJK_BLUE_HANI_VERT
#include "aferrors.h"
/**************************************************************************
*
* The macro FT_COMPONENT is used in trace mode. It is an implicit
* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
* messages during execution.
*/
#undef FT_COMPONENT
#define FT_COMPONENT afcjk
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** C J K G L O B A L M E T R I C S *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
/* Basically the Latin version with AF_CJKMetrics */
/* to replace AF_LatinMetrics. */
FT_LOCAL_DEF( void )
af_cjk_metrics_init_widths( AF_CJKMetrics metrics,
FT_Face face )
{
/* scan the array of segments in each direction */
AF_GlyphHintsRec hints[1];
FT_TRACE5(( "\n" ));
FT_TRACE5(( "cjk standard widths computation (style `%s')\n",
af_style_names[metrics->root.style_class->style] ));
FT_TRACE5(( "===================================================\n" ));
FT_TRACE5(( "\n" ));
af_glyph_hints_init( hints, face->memory );
metrics->axis[AF_DIMENSION_HORZ].width_count = 0;
metrics->axis[AF_DIMENSION_VERT].width_count = 0;
{
FT_Error error;
FT_ULong glyph_index;
int dim;
AF_CJKMetricsRec dummy[1];
AF_Scaler scaler = &dummy->root.scaler;
AF_StyleClass style_class = metrics->root.style_class;
AF_ScriptClass script_class = af_script_classes[style_class->script];
/* If HarfBuzz is not available, we need a pointer to a single */
/* unsigned long value. */
#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
void* shaper_buf;
#else
FT_ULong shaper_buf_;
void* shaper_buf = &shaper_buf_;
#endif
const char* p;
#ifdef FT_DEBUG_LEVEL_TRACE
FT_ULong ch = 0;
#endif
p = script_class->standard_charstring;
#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
shaper_buf = af_shaper_buf_create( face );
#endif
/* We check a list of standard characters. The first match wins. */
glyph_index = 0;
while ( *p )
{
unsigned int num_idx;
#ifdef FT_DEBUG_LEVEL_TRACE
const char* p_old;
#endif
while ( *p == ' ' )
p++;
#ifdef FT_DEBUG_LEVEL_TRACE
p_old = p;
GET_UTF8_CHAR( ch, p_old );
#endif
/* reject input that maps to more than a single glyph */
p = af_shaper_get_cluster( p, &metrics->root, shaper_buf, &num_idx );
if ( num_idx > 1 )
continue;
/* otherwise exit loop if we have a result */
glyph_index = af_shaper_get_elem( &metrics->root,
shaper_buf,
0,
NULL,
NULL );
if ( glyph_index )
break;
}
af_shaper_buf_destroy( face, shaper_buf );
if ( !glyph_index )
goto Exit;
if ( !glyph_index )
goto Exit;
FT_TRACE5(( "standard character: U+%04lX (glyph index %ld)\n",
ch, glyph_index ));
error = FT_Load_Glyph( face, glyph_index, FT_LOAD_NO_SCALE );
if ( error || face->glyph->outline.n_points <= 0 )
goto Exit;
FT_ZERO( dummy );
dummy->units_per_em = metrics->units_per_em;
scaler->x_scale = 0x10000L;
scaler->y_scale = 0x10000L;
scaler->x_delta = 0;
scaler->y_delta = 0;
scaler->face = face;
scaler->render_mode = FT_RENDER_MODE_NORMAL;
scaler->flags = 0;
af_glyph_hints_rescale( hints, (AF_StyleMetrics)dummy );
error = af_glyph_hints_reload( hints, &face->glyph->outline );
if ( error )
goto Exit;
for ( dim = 0; dim < AF_DIMENSION_MAX; dim++ )
{
AF_CJKAxis axis = &metrics->axis[dim];
AF_AxisHints axhints = &hints->axis[dim];
AF_Segment seg, limit, link;
FT_UInt num_widths = 0;
error = af_latin_hints_compute_segments( hints,
(AF_Dimension)dim );
if ( error )
goto Exit;
/*
* We assume that the glyphs selected for the stem width
* computation are `featureless' enough so that the linking
* algorithm works fine without adjustments of its scoring
* function.
*/
af_latin_hints_link_segments( hints,
0,
NULL,
(AF_Dimension)dim );
seg = axhints->segments;
limit = seg + axhints->num_segments;
for ( ; seg < limit; seg++ )
{
link = seg->link;
/* we only consider stem segments there! */
if ( link && link->link == seg && link > seg )
{
FT_Pos dist;
dist = seg->pos - link->pos;
if ( dist < 0 )
dist = -dist;
if ( num_widths < AF_CJK_MAX_WIDTHS )
axis->widths[num_widths++].org = dist;
}
}
/* this also replaces multiple almost identical stem widths */
/* with a single one (the value 100 is heuristic) */
af_sort_and_quantize_widths( &num_widths, axis->widths,
dummy->units_per_em / 100 );
axis->width_count = num_widths;
}
Exit:
for ( dim = 0; dim < AF_DIMENSION_MAX; dim++ )
{
AF_CJKAxis axis = &metrics->axis[dim];
FT_Pos stdw;
stdw = ( axis->width_count > 0 ) ? axis->widths[0].org
: AF_LATIN_CONSTANT( metrics, 50 );
/* let's try 20% of the smallest width */
axis->edge_distance_threshold = stdw / 5;
axis->standard_width = stdw;
axis->extra_light = 0;
#ifdef FT_DEBUG_LEVEL_TRACE
{
FT_UInt i;
FT_TRACE5(( "%s widths:\n",
dim == AF_DIMENSION_VERT ? "horizontal"
: "vertical" ));
FT_TRACE5(( " %ld (standard)", axis->standard_width ));
for ( i = 1; i < axis->width_count; i++ )
FT_TRACE5(( " %ld", axis->widths[i].org ));
FT_TRACE5(( "\n" ));
}
#endif
}
}
FT_TRACE5(( "\n" ));
af_glyph_hints_done( hints );
}
/* Find all blue zones. */
static void
af_cjk_metrics_init_blues( AF_CJKMetrics metrics,
FT_Face face )
{
FT_Pos fills[AF_BLUE_STRING_MAX_LEN];
FT_Pos flats[AF_BLUE_STRING_MAX_LEN];
FT_UInt num_fills;
FT_UInt num_flats;
FT_Bool fill;
AF_CJKBlue blue;
FT_Error error;
AF_CJKAxis axis;
FT_Outline outline;
AF_StyleClass sc = metrics->root.style_class;
AF_Blue_Stringset bss = sc->blue_stringset;
const AF_Blue_StringRec* bs = &af_blue_stringsets[bss];
/* If HarfBuzz is not available, we need a pointer to a single */
/* unsigned long value. */
#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
void* shaper_buf;
#else
FT_ULong shaper_buf_;
void* shaper_buf = &shaper_buf_;
#endif
/* we walk over the blue character strings as specified in the */
/* style's entry in the `af_blue_stringset' array, computing its */
/* extremum points (depending on the string properties) */
FT_TRACE5(( "cjk blue zones computation\n" ));
FT_TRACE5(( "==========================\n" ));
FT_TRACE5(( "\n" ));
#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
shaper_buf = af_shaper_buf_create( face );
#endif
for ( ; bs->string != AF_BLUE_STRING_MAX; bs++ )
{
const char* p = &af_blue_strings[bs->string];
FT_Pos* blue_ref;
FT_Pos* blue_shoot;
if ( AF_CJK_IS_HORIZ_BLUE( bs ) )
axis = &metrics->axis[AF_DIMENSION_HORZ];
else
axis = &metrics->axis[AF_DIMENSION_VERT];
#ifdef FT_DEBUG_LEVEL_TRACE
{
FT_String* cjk_blue_name[4] =
{
(FT_String*)"bottom", /* -- , -- */
(FT_String*)"top", /* -- , TOP */
(FT_String*)"left", /* HORIZ, -- */
(FT_String*)"right" /* HORIZ, TOP */
};
FT_TRACE5(( "blue zone %d (%s):\n",
axis->blue_count,
cjk_blue_name[AF_CJK_IS_HORIZ_BLUE( bs ) |
AF_CJK_IS_TOP_BLUE( bs ) ] ));
}
#endif /* FT_DEBUG_LEVEL_TRACE */
num_fills = 0;
num_flats = 0;
fill = 1; /* start with characters that define fill values */
FT_TRACE5(( " [overshoot values]\n" ));
while ( *p )
{
FT_ULong glyph_index;
FT_Pos best_pos; /* same as points.y or points.x, resp. */
FT_Int best_point;
FT_Vector* points;
unsigned int num_idx;
#ifdef FT_DEBUG_LEVEL_TRACE
const char* p_old;
FT_ULong ch;
#endif
while ( *p == ' ' )
p++;
#ifdef FT_DEBUG_LEVEL_TRACE
p_old = p;
GET_UTF8_CHAR( ch, p_old );
#endif
/* switch to characters that define flat values */
if ( *p == '|' )
{
fill = 0;
FT_TRACE5(( " [reference values]\n" ));
p++;
continue;
}
/* reject input that maps to more than a single glyph */
p = af_shaper_get_cluster( p, &metrics->root, shaper_buf, &num_idx );
if ( num_idx > 1 )
continue;
/* load the character in the face -- skip unknown or empty ones */
glyph_index = af_shaper_get_elem( &metrics->root,
shaper_buf,
0,
NULL,
NULL );
if ( glyph_index == 0 )
{
FT_TRACE5(( " U+%04lX unavailable\n", ch ));
continue;
}
error = FT_Load_Glyph( face, glyph_index, FT_LOAD_NO_SCALE );
outline = face->glyph->outline;
if ( error || outline.n_points <= 2 )
{
FT_TRACE5(( " U+%04lX contains no (usable) outlines\n", ch ));
continue;
}
/* now compute min or max point indices and coordinates */
points = outline.points;
best_point = -1;
best_pos = 0; /* make compiler happy */
{
FT_Int nn;
FT_Int first = 0;
FT_Int last = -1;
for ( nn = 0; nn < outline.n_contours; first = last + 1, nn++ )
{
FT_Int pp;
last = outline.contours[nn];
/* Avoid single-point contours since they are never rasterized. */
/* In some fonts, they correspond to mark attachment points */
/* which are way outside of the glyph's real outline. */
if ( last <= first )
continue;
if ( AF_CJK_IS_HORIZ_BLUE( bs ) )
{
if ( AF_CJK_IS_RIGHT_BLUE( bs ) )
{
for ( pp = first; pp <= last; pp++ )
if ( best_point < 0 || points[pp].x > best_pos )
{
best_point = pp;
best_pos = points[pp].x;
}
}
else
{
for ( pp = first; pp <= last; pp++ )
if ( best_point < 0 || points[pp].x < best_pos )
{
best_point = pp;
best_pos = points[pp].x;
}
}
}
else
{
if ( AF_CJK_IS_TOP_BLUE( bs ) )
{
for ( pp = first; pp <= last; pp++ )
if ( best_point < 0 || points[pp].y > best_pos )
{
best_point = pp;
best_pos = points[pp].y;
}
}
else
{
for ( pp = first; pp <= last; pp++ )
if ( best_point < 0 || points[pp].y < best_pos )
{
best_point = pp;
best_pos = points[pp].y;
}
}
}
}
FT_TRACE5(( " U+%04lX: best_pos = %5ld\n", ch, best_pos ));
}
if ( fill )
fills[num_fills++] = best_pos;
else
flats[num_flats++] = best_pos;
} /* end while loop */
if ( num_flats == 0 && num_fills == 0 )
{
/*
* we couldn't find a single glyph to compute this blue zone,
* we will simply ignore it then
*/
FT_TRACE5(( " empty\n" ));
continue;
}
/* we have computed the contents of the `fill' and `flats' tables, */
/* now determine the reference and overshoot position of the blue -- */
/* we simply take the median value after a simple sort */
af_sort_pos( num_fills, fills );
af_sort_pos( num_flats, flats );
blue = &axis->blues[axis->blue_count];
blue_ref = &blue->ref.org;
blue_shoot = &blue->shoot.org;
axis->blue_count++;
if ( num_flats == 0 )
{
*blue_ref =
*blue_shoot = fills[num_fills / 2];
}
else if ( num_fills == 0 )
{
*blue_ref =
*blue_shoot = flats[num_flats / 2];
}
else
{
*blue_ref = fills[num_fills / 2];
*blue_shoot = flats[num_flats / 2];
}
/* make sure blue_ref >= blue_shoot for top/right or */
/* vice versa for bottom/left */
if ( *blue_shoot != *blue_ref )
{
FT_Pos ref = *blue_ref;
FT_Pos shoot = *blue_shoot;
FT_Bool under_ref = FT_BOOL( shoot < ref );
/* AF_CJK_IS_TOP_BLUE covers `right' and `top' */
if ( AF_CJK_IS_TOP_BLUE( bs ) ^ under_ref )
{
*blue_ref =
*blue_shoot = ( shoot + ref ) / 2;
FT_TRACE5(( " [reference smaller than overshoot,"
" taking mean value]\n" ));
}
}
blue->flags = 0;
if ( AF_CJK_IS_TOP_BLUE( bs ) )
blue->flags |= AF_CJK_BLUE_TOP;
FT_TRACE5(( " -> reference = %ld\n", *blue_ref ));
FT_TRACE5(( " overshoot = %ld\n", *blue_shoot ));
} /* end for loop */
af_shaper_buf_destroy( face, shaper_buf );
FT_TRACE5(( "\n" ));
return;
}
/* Basically the Latin version with type AF_CJKMetrics for metrics. */
FT_LOCAL_DEF( void )
af_cjk_metrics_check_digits( AF_CJKMetrics metrics,
FT_Face face )
{
FT_Bool started = 0, same_width = 1;
FT_Fixed advance = 0, old_advance = 0;
/* If HarfBuzz is not available, we need a pointer to a single */
/* unsigned long value. */
#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
void* shaper_buf;
#else
FT_ULong shaper_buf_;
void* shaper_buf = &shaper_buf_;
#endif
/* in all supported charmaps, digits have character codes 0x30-0x39 */
const char digits[] = "0 1 2 3 4 5 6 7 8 9";
const char* p;
p = digits;
#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
shaper_buf = af_shaper_buf_create( face );
#endif
while ( *p )
{
FT_ULong glyph_index;
unsigned int num_idx;
/* reject input that maps to more than a single glyph */
p = af_shaper_get_cluster( p, &metrics->root, shaper_buf, &num_idx );
if ( num_idx > 1 )
continue;
glyph_index = af_shaper_get_elem( &metrics->root,
shaper_buf,
0,
&advance,
NULL );
if ( !glyph_index )
continue;
if ( started )
{
if ( advance != old_advance )
{
same_width = 0;
break;
}
}
else
{
old_advance = advance;
started = 1;
}
}
af_shaper_buf_destroy( face, shaper_buf );
metrics->root.digits_have_same_width = same_width;
}
/* Initialize global metrics. */
FT_LOCAL_DEF( FT_Error )
af_cjk_metrics_init( AF_CJKMetrics metrics,
FT_Face face )
{
FT_CharMap oldmap = face->charmap;
metrics->units_per_em = face->units_per_EM;
if ( !FT_Select_Charmap( face, FT_ENCODING_UNICODE ) )
{
af_cjk_metrics_init_widths( metrics, face );
af_cjk_metrics_init_blues( metrics, face );
af_cjk_metrics_check_digits( metrics, face );
}
FT_Set_Charmap( face, oldmap );
return FT_Err_Ok;
}
/* Adjust scaling value, then scale and shift widths */
/* and blue zones (if applicable) for given dimension. */
static void
af_cjk_metrics_scale_dim( AF_CJKMetrics metrics,
AF_Scaler scaler,
AF_Dimension dim )
{
FT_Fixed scale;
FT_Pos delta;
AF_CJKAxis axis;
FT_UInt nn;
if ( dim == AF_DIMENSION_HORZ )
{
scale = scaler->x_scale;
delta = scaler->x_delta;
}
else
{
scale = scaler->y_scale;
delta = scaler->y_delta;
}
axis = &metrics->axis[dim];
if ( axis->org_scale == scale && axis->org_delta == delta )
return;
axis->org_scale = scale;
axis->org_delta = delta;
axis->scale = scale;
axis->delta = delta;
/* scale the blue zones */
for ( nn = 0; nn < axis->blue_count; nn++ )
{
AF_CJKBlue blue = &axis->blues[nn];
FT_Pos dist;
blue->ref.cur = FT_MulFix( blue->ref.org, scale ) + delta;
blue->ref.fit = blue->ref.cur;
blue->shoot.cur = FT_MulFix( blue->shoot.org, scale ) + delta;
blue->shoot.fit = blue->shoot.cur;
blue->flags &= ~AF_CJK_BLUE_ACTIVE;
/* a blue zone is only active if it is less than 3/4 pixels tall */
dist = FT_MulFix( blue->ref.org - blue->shoot.org, scale );
if ( dist <= 48 && dist >= -48 )
{
FT_Pos delta1, delta2;
blue->ref.fit = FT_PIX_ROUND( blue->ref.cur );
/* shoot is under shoot for cjk */
delta1 = FT_DivFix( blue->ref.fit, scale ) - blue->shoot.org;
delta2 = delta1;
if ( delta1 < 0 )
delta2 = -delta2;
delta2 = FT_MulFix( delta2, scale );
FT_TRACE5(( "delta: %ld", delta1 ));
if ( delta2 < 32 )
delta2 = 0;
#if 0
else if ( delta2 < 64 )
delta2 = 32 + ( ( ( delta2 - 32 ) + 16 ) & ~31 );
#endif
else
delta2 = FT_PIX_ROUND( delta2 );
FT_TRACE5(( "/%ld\n", delta2 ));
if ( delta1 < 0 )
delta2 = -delta2;
blue->shoot.fit = blue->ref.fit - delta2;
FT_TRACE5(( ">> active cjk blue zone %c%d[%ld/%ld]:\n",
( dim == AF_DIMENSION_HORZ ) ? 'H' : 'V',
nn, blue->ref.org, blue->shoot.org ));
FT_TRACE5(( " ref: cur=%.2f fit=%.2f\n",
blue->ref.cur / 64.0, blue->ref.fit / 64.0 ));
FT_TRACE5(( " shoot: cur=%.2f fit=%.2f\n",
blue->shoot.cur / 64.0, blue->shoot.fit / 64.0 ));
blue->flags |= AF_CJK_BLUE_ACTIVE;
}
}
}
/* Scale global values in both directions. */
FT_LOCAL_DEF( void )
af_cjk_metrics_scale( AF_CJKMetrics metrics,
AF_Scaler scaler )
{
/* we copy the whole structure since the x and y scaling values */
/* are not modified, contrary to e.g. the `latin' auto-hinter */
metrics->root.scaler = *scaler;
af_cjk_metrics_scale_dim( metrics, scaler, AF_DIMENSION_HORZ );
af_cjk_metrics_scale_dim( metrics, scaler, AF_DIMENSION_VERT );
}
/* Extract standard_width from writing system/script specific */
/* metrics class. */
FT_LOCAL_DEF( void )
af_cjk_get_standard_widths( AF_CJKMetrics metrics,
FT_Pos* stdHW,
FT_Pos* stdVW )
{
if ( stdHW )
*stdHW = metrics->axis[AF_DIMENSION_VERT].standard_width;
if ( stdVW )
*stdVW = metrics->axis[AF_DIMENSION_HORZ].standard_width;
}
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** C J K G L Y P H A N A L Y S I S *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
/* Walk over all contours and compute its segments. */
static FT_Error
af_cjk_hints_compute_segments( AF_GlyphHints hints,
AF_Dimension dim )
{
AF_AxisHints axis = &hints->axis[dim];
AF_Segment segments = axis->segments;
AF_Segment segment_limit = FT_OFFSET( segments, axis->num_segments );
FT_Error error;
AF_Segment seg;
error = af_latin_hints_compute_segments( hints, dim );
if ( error )
return error;
/* a segment is round if it doesn't have successive */
/* on-curve points. */
for ( seg = segments; seg < segment_limit; seg++ )
{
AF_Point pt = seg->first;
AF_Point last = seg->last;
FT_UInt f0 = pt->flags & AF_FLAG_CONTROL;
FT_UInt f1;
seg->flags &= ~AF_EDGE_ROUND;
for ( ; pt != last; f0 = f1 )
{
pt = pt->next;
f1 = pt->flags & AF_FLAG_CONTROL;
if ( !f0 && !f1 )
break;
if ( pt == last )
seg->flags |= AF_EDGE_ROUND;
}
}
return FT_Err_Ok;
}
static void
af_cjk_hints_link_segments( AF_GlyphHints hints,
AF_Dimension dim )
{
AF_AxisHints axis = &hints->axis[dim];
AF_Segment segments = axis->segments;
AF_Segment segment_limit = FT_OFFSET( segments, axis->num_segments );
AF_Direction major_dir = axis->major_dir;
AF_Segment seg1, seg2;
FT_Pos len_threshold;
FT_Pos dist_threshold;
len_threshold = AF_LATIN_CONSTANT( hints->metrics, 8 );
dist_threshold = ( dim == AF_DIMENSION_HORZ ) ? hints->x_scale
: hints->y_scale;
dist_threshold = FT_DivFix( 64 * 3, dist_threshold );
/* now compare each segment to the others */
for ( seg1 = segments; seg1 < segment_limit; seg1++ )
{
if ( seg1->dir != major_dir )
continue;
for ( seg2 = segments; seg2 < segment_limit; seg2++ )
if ( seg2 != seg1 && seg1->dir + seg2->dir == 0 )
{
FT_Pos dist = seg2->pos - seg1->pos;
if ( dist < 0 )
continue;
{
FT_Pos min = seg1->min_coord;
FT_Pos max = seg1->max_coord;
FT_Pos len;
if ( min < seg2->min_coord )
min = seg2->min_coord;
if ( max > seg2->max_coord )
max = seg2->max_coord;
len = max - min;
if ( len >= len_threshold )
{
if ( dist * 8 < seg1->score * 9 &&
( dist * 8 < seg1->score * 7 || seg1->len < len ) )
{
seg1->score = dist;
seg1->len = len;
seg1->link = seg2;
}
if ( dist * 8 < seg2->score * 9 &&
( dist * 8 < seg2->score * 7 || seg2->len < len ) )
{
seg2->score = dist;
seg2->len = len;
seg2->link = seg1;
}
}
}
}
}
/*
* now compute the `serif' segments
*
* In Hanzi, some strokes are wider on one or both of the ends.
* We either identify the stems on the ends as serifs or remove
* the linkage, depending on the length of the stems.
*
*/
{
AF_Segment link1, link2;
for ( seg1 = segments; seg1 < segment_limit; seg1++ )
{
link1 = seg1->link;
if ( !link1 || link1->link != seg1 || link1->pos <= seg1->pos )
continue;
if ( seg1->score >= dist_threshold )
continue;
for ( seg2 = segments; seg2 < segment_limit; seg2++ )
{
if ( seg2->pos > seg1->pos || seg1 == seg2 )
continue;
link2 = seg2->link;
if ( !link2 || link2->link != seg2 || link2->pos < link1->pos )
continue;
if ( seg1->pos == seg2->pos && link1->pos == link2->pos )
continue;
if ( seg2->score <= seg1->score || seg1->score * 4 <= seg2->score )
continue;
/* seg2 < seg1 < link1 < link2 */
if ( seg1->len >= seg2->len * 3 )
{
AF_Segment seg;
for ( seg = segments; seg < segment_limit; seg++ )
{
AF_Segment link = seg->link;
if ( link == seg2 )
{
seg->link = NULL;
seg->serif = link1;
}
else if ( link == link2 )
{
seg->link = NULL;
seg->serif = seg1;
}
}
}
else
{
seg1->link = link1->link = NULL;
break;
}
}
}
}
for ( seg1 = segments; seg1 < segment_limit; seg1++ )
{
seg2 = seg1->link;
if ( seg2 )
{
if ( seg2->link != seg1 )
{
seg1->link = NULL;
if ( seg2->score < dist_threshold || seg1->score < seg2->score * 4 )
seg1->serif = seg2->link;
}
}
}
}
static FT_Error
af_cjk_hints_compute_edges( AF_GlyphHints hints,
AF_Dimension dim )
{
AF_AxisHints axis = &hints->axis[dim];
FT_Error error = FT_Err_Ok;
FT_Memory memory = hints->memory;
AF_CJKAxis laxis = &((AF_CJKMetrics)hints->metrics)->axis[dim];
AF_Segment segments = axis->segments;
AF_Segment segment_limit = FT_OFFSET( segments, axis->num_segments );
AF_Segment seg;
FT_Fixed scale;
FT_Pos edge_distance_threshold;
axis->num_edges = 0;
scale = ( dim == AF_DIMENSION_HORZ ) ? hints->x_scale
: hints->y_scale;
/**********************************************************************
*
* We begin by generating a sorted table of edges for the current
* direction. To do so, we simply scan each segment and try to find
* an edge in our table that corresponds to its position.
*
* If no edge is found, we create and insert a new edge in the
* sorted table. Otherwise, we simply add the segment to the edge's
* list which is then processed in the second step to compute the
* edge's properties.
*
* Note that the edges table is sorted along the segment/edge
* position.
*
*/
edge_distance_threshold = FT_MulFix( laxis->edge_distance_threshold,
scale );
if ( edge_distance_threshold > 64 / 4 )
edge_distance_threshold = FT_DivFix( 64 / 4, scale );
else
edge_distance_threshold = laxis->edge_distance_threshold;
for ( seg = segments; seg < segment_limit; seg++ )
{
AF_Edge found = NULL;
FT_Pos best = 0xFFFFU;
FT_Int ee;
/* look for an edge corresponding to the segment */
for ( ee = 0; ee < axis->num_edges; ee++ )
{
AF_Edge edge = axis->edges + ee;
FT_Pos dist;
if ( edge->dir != seg->dir )
continue;
dist = seg->pos - edge->fpos;
if ( dist < 0 )
dist = -dist;
if ( dist < edge_distance_threshold && dist < best )
{
AF_Segment link = seg->link;
/* check whether all linked segments of the candidate edge */
/* can make a single edge. */
if ( link )
{
AF_Segment seg1 = edge->first;
FT_Pos dist2 = 0;
do
{
AF_Segment link1 = seg1->link;
if ( link1 )
{
dist2 = AF_SEGMENT_DIST( link, link1 );
if ( dist2 >= edge_distance_threshold )
break;
}
} while ( ( seg1 = seg1->edge_next ) != edge->first );
if ( dist2 >= edge_distance_threshold )
continue;
}
best = dist;
found = edge;
}
}
if ( !found )
{
AF_Edge edge;
/* insert a new edge in the list and */
/* sort according to the position */
error = af_axis_hints_new_edge( axis, seg->pos,
(AF_Direction)seg->dir, 0,
memory, &edge );
if ( error )
goto Exit;
/* add the segment to the new edge's list */
FT_ZERO( edge );
edge->first = seg;
edge->last = seg;
edge->dir = seg->dir;
edge->fpos = seg->pos;
edge->opos = FT_MulFix( seg->pos, scale );
edge->pos = edge->opos;
seg->edge_next = seg;
}
else
{
/* if an edge was found, simply add the segment to the edge's */
/* list */
seg->edge_next = found->first;
found->last->edge_next = seg;
found->last = seg;
}
}
/*******************************************************************
*
* Good, we now compute each edge's properties according to the
* segments found on its position. Basically, these are
*
* - the edge's main direction
* - stem edge, serif edge or both (which defaults to stem then)
* - rounded edge, straight or both (which defaults to straight)
* - link for edge
*
*/
/* first of all, set the `edge' field in each segment -- this is */
/* required in order to compute edge links */
/*
* Note that removing this loop and setting the `edge' field of each
* segment directly in the code above slows down execution speed for
* some reasons on platforms like the Sun.
*/
{
AF_Edge edges = axis->edges;
AF_Edge edge_limit = FT_OFFSET( edges, axis->num_edges );
AF_Edge edge;
for ( edge = edges; edge < edge_limit; edge++ )
{
seg = edge->first;
if ( seg )
do
{
seg->edge = edge;
seg = seg->edge_next;
} while ( seg != edge->first );
}
/* now compute each edge properties */
for ( edge = edges; edge < edge_limit; edge++ )
{
FT_Int is_round = 0; /* does it contain round segments? */
FT_Int is_straight = 0; /* does it contain straight segments? */
seg = edge->first;
if ( !seg )
goto Skip_Loop;
do
{
FT_Bool is_serif;
/* check for roundness of segment */
if ( seg->flags & AF_EDGE_ROUND )
is_round++;
else
is_straight++;
/* check for links -- if seg->serif is set, then seg->link must */
/* be ignored */
is_serif = FT_BOOL( seg->serif && seg->serif->edge != edge );
if ( seg->link || is_serif )
{
AF_Edge edge2;
AF_Segment seg2;
edge2 = edge->link;
seg2 = seg->link;
if ( is_serif )
{
seg2 = seg->serif;
edge2 = edge->serif;
}
if ( edge2 )
{
FT_Pos edge_delta;
FT_Pos seg_delta;
edge_delta = edge->fpos - edge2->fpos;
if ( edge_delta < 0 )
edge_delta = -edge_delta;
seg_delta = AF_SEGMENT_DIST( seg, seg2 );
if ( seg_delta < edge_delta )
edge2 = seg2->edge;
}
else
edge2 = seg2->edge;
if ( is_serif )
{
edge->serif = edge2;
edge2->flags |= AF_EDGE_SERIF;
}
else
edge->link = edge2;
}
seg = seg->edge_next;
} while ( seg != edge->first );
Skip_Loop:
/* set the round/straight flags */
edge->flags = AF_EDGE_NORMAL;
if ( is_round > 0 && is_round >= is_straight )
edge->flags |= AF_EDGE_ROUND;
/* get rid of serifs if link is set */
/* XXX: This gets rid of many unpleasant artefacts! */
/* Example: the `c' in cour.pfa at size 13 */
if ( edge->serif && edge->link )
edge->serif = NULL;
}
}
Exit:
return error;
}
/* Detect segments and edges for given dimension. */
static FT_Error
af_cjk_hints_detect_features( AF_GlyphHints hints,
AF_Dimension dim )
{
FT_Error error;
error = af_cjk_hints_compute_segments( hints, dim );
if ( !error )
{
af_cjk_hints_link_segments( hints, dim );
error = af_cjk_hints_compute_edges( hints, dim );
}
return error;
}
/* Compute all edges which lie within blue zones. */
static void
af_cjk_hints_compute_blue_edges( AF_GlyphHints hints,
AF_CJKMetrics metrics,
AF_Dimension dim )
{
AF_AxisHints axis = &hints->axis[dim];
AF_Edge edge = axis->edges;
AF_Edge edge_limit = FT_OFFSET( edge, axis->num_edges );
AF_CJKAxis cjk = &metrics->axis[dim];
FT_Fixed scale = cjk->scale;
FT_Pos best_dist0; /* initial threshold */
/* compute the initial threshold as a fraction of the EM size */
best_dist0 = FT_MulFix( metrics->units_per_em / 40, scale );
if ( best_dist0 > 64 / 2 ) /* maximum 1/2 pixel */
best_dist0 = 64 / 2;
/* compute which blue zones are active, i.e. have their scaled */
/* size < 3/4 pixels */
/* If the distant between an edge and a blue zone is shorter than */
/* best_dist0, set the blue zone for the edge. Then search for */
/* the blue zone with the smallest best_dist to the edge. */
for ( ; edge < edge_limit; edge++ )
{
FT_UInt bb;
AF_Width best_blue = NULL;
FT_Pos best_dist = best_dist0;
for ( bb = 0; bb < cjk->blue_count; bb++ )
{
AF_CJKBlue blue = cjk->blues + bb;
FT_Bool is_top_right_blue, is_major_dir;
/* skip inactive blue zones (i.e., those that are too small) */
if ( !( blue->flags & AF_CJK_BLUE_ACTIVE ) )
continue;
/* if it is a top zone, check for right edges -- if it is a bottom */
/* zone, check for left edges */
/* */
/* of course, that's for TrueType */
is_top_right_blue =
(FT_Byte)( ( blue->flags & AF_CJK_BLUE_TOP ) != 0 );
is_major_dir =
FT_BOOL( edge->dir == axis->major_dir );
/* if it is a top zone, the edge must be against the major */
/* direction; if it is a bottom zone, it must be in the major */
/* direction */
if ( is_top_right_blue ^ is_major_dir )
{
FT_Pos dist;
AF_Width compare;
/* Compare the edge to the closest blue zone type */
if ( FT_ABS( edge->fpos - blue->ref.org ) >
FT_ABS( edge->fpos - blue->shoot.org ) )
compare = &blue->shoot;
else
compare = &blue->ref;
dist = edge->fpos - compare->org;
if ( dist < 0 )
dist = -dist;
dist = FT_MulFix( dist, scale );
if ( dist < best_dist )
{
best_dist = dist;
best_blue = compare;
}
}
}
if ( best_blue )
edge->blue_edge = best_blue;
}
}
/* Initalize hinting engine. */
FT_LOCAL_DEF( FT_Error )
af_cjk_hints_init( AF_GlyphHints hints,
AF_CJKMetrics metrics )
{
FT_Render_Mode mode;
FT_UInt32 scaler_flags, other_flags;
af_glyph_hints_rescale( hints, (AF_StyleMetrics)metrics );
/*
* correct x_scale and y_scale when needed, since they may have
* been modified af_cjk_scale_dim above
*/
hints->x_scale = metrics->axis[AF_DIMENSION_HORZ].scale;
hints->x_delta = metrics->axis[AF_DIMENSION_HORZ].delta;
hints->y_scale = metrics->axis[AF_DIMENSION_VERT].scale;
hints->y_delta = metrics->axis[AF_DIMENSION_VERT].delta;
/* compute flags depending on render mode, etc. */
mode = metrics->root.scaler.render_mode;
scaler_flags = hints->scaler_flags;
other_flags = 0;
/*
* We snap the width of vertical stems for the monochrome and
* horizontal LCD rendering targets only.
*/
if ( mode == FT_RENDER_MODE_MONO || mode == FT_RENDER_MODE_LCD )
other_flags |= AF_LATIN_HINTS_HORZ_SNAP;
/*
* We snap the width of horizontal stems for the monochrome and
* vertical LCD rendering targets only.
*/
if ( mode == FT_RENDER_MODE_MONO || mode == FT_RENDER_MODE_LCD_V )
other_flags |= AF_LATIN_HINTS_VERT_SNAP;
/*
* We adjust stems to full pixels unless in `light' or `lcd' mode.
*/
if ( mode != FT_RENDER_MODE_LIGHT && mode != FT_RENDER_MODE_LCD )
other_flags |= AF_LATIN_HINTS_STEM_ADJUST;
if ( mode == FT_RENDER_MODE_MONO )
other_flags |= AF_LATIN_HINTS_MONO;
scaler_flags |= AF_SCALER_FLAG_NO_ADVANCE;
hints->scaler_flags = scaler_flags;
hints->other_flags = other_flags;
return FT_Err_Ok;
}
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** C J K G L Y P H G R I D - F I T T I N G *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
/* Snap a given width in scaled coordinates to one of the */
/* current standard widths. */
static FT_Pos
af_cjk_snap_width( AF_Width widths,
FT_UInt count,
FT_Pos width )
{
FT_UInt n;
FT_Pos best = 64 + 32 + 2;
FT_Pos reference = width;
FT_Pos scaled;
for ( n = 0; n < count; n++ )
{
FT_Pos w;
FT_Pos dist;
w = widths[n].cur;
dist = width - w;
if ( dist < 0 )
dist = -dist;
if ( dist < best )
{
best = dist;
reference = w;
}
}
scaled = FT_PIX_ROUND( reference );
if ( width >= reference )
{
if ( width < scaled + 48 )
width = reference;
}
else
{
if ( width > scaled - 48 )
width = reference;
}
return width;
}
/* Compute the snapped width of a given stem. */
/* There is a lot of voodoo in this function; changing the hard-coded */
/* parameters influence the whole hinting process. */
static FT_Pos
af_cjk_compute_stem_width( AF_GlyphHints hints,
AF_Dimension dim,
FT_Pos width,
FT_UInt base_flags,
FT_UInt stem_flags )
{
AF_CJKMetrics metrics = (AF_CJKMetrics)hints->metrics;
AF_CJKAxis axis = &metrics->axis[dim];
FT_Pos dist = width;
FT_Int sign = 0;
FT_Bool vertical = FT_BOOL( dim == AF_DIMENSION_VERT );
FT_UNUSED( base_flags );
FT_UNUSED( stem_flags );
if ( !AF_LATIN_HINTS_DO_STEM_ADJUST( hints ) )
return width;
if ( dist < 0 )
{
dist = -width;
sign = 1;
}
if ( ( vertical && !AF_LATIN_HINTS_DO_VERT_SNAP( hints ) ) ||
( !vertical && !AF_LATIN_HINTS_DO_HORZ_SNAP( hints ) ) )
{
/* smooth hinting process: very lightly quantize the stem width */
if ( axis->width_count > 0 )
{
if ( FT_ABS( dist - axis->widths[0].cur ) < 40 )
{
dist = axis->widths[0].cur;
if ( dist < 48 )
dist = 48;
goto Done_Width;
}
}
if ( dist < 54 )
dist += ( 54 - dist ) / 2;
else if ( dist < 3 * 64 )
{
FT_Pos delta;
delta = dist & 63;
dist &= -64;
if ( delta < 10 )
dist += delta;
else if ( delta < 22 )
dist += 10;
else if ( delta < 42 )
dist += delta;
else if ( delta < 54 )
dist += 54;
else
dist += delta;
}
}
else
{
/* strong hinting process: snap the stem width to integer pixels */
dist = af_cjk_snap_width( axis->widths, axis->width_count, dist );
if ( vertical )
{
/* in the case of vertical hinting, always round */
/* the stem heights to integer pixels */
if ( dist >= 64 )
dist = ( dist + 16 ) & ~63;
else
dist = 64;
}
else
{
if ( AF_LATIN_HINTS_DO_MONO( hints ) )
{
/* monochrome horizontal hinting: snap widths to integer pixels */
/* with a different threshold */
if ( dist < 64 )
dist = 64;
else
dist = ( dist + 32 ) & ~63;
}
else
{
/* for horizontal anti-aliased hinting, we adopt a more subtle */
/* approach: we strengthen small stems, round stems whose size */
/* is between 1 and 2 pixels to an integer, otherwise nothing */
if ( dist < 48 )
dist = ( dist + 64 ) >> 1;
else if ( dist < 128 )
dist = ( dist + 22 ) & ~63;
else
/* round otherwise to prevent color fringes in LCD mode */
dist = ( dist + 32 ) & ~63;
}
}
}
Done_Width:
if ( sign )
dist = -dist;
return dist;
}
/* Align one stem edge relative to the previous stem edge. */
static void
af_cjk_align_linked_edge( AF_GlyphHints hints,
AF_Dimension dim,
AF_Edge base_edge,
AF_Edge stem_edge )
{
FT_Pos dist = stem_edge->opos - base_edge->opos;
FT_Pos fitted_width = af_cjk_compute_stem_width( hints, dim, dist,
base_edge->flags,
stem_edge->flags );
stem_edge->pos = base_edge->pos + fitted_width;
FT_TRACE5(( " CJKLINK: edge %ld @%d (opos=%.2f) linked to %.2f,"
" dist was %.2f, now %.2f\n",
stem_edge - hints->axis[dim].edges, stem_edge->fpos,
stem_edge->opos / 64.0, stem_edge->pos / 64.0,
dist / 64.0, fitted_width / 64.0 ));
}
/* Shift the coordinates of the `serif' edge by the same amount */
/* as the corresponding `base' edge has been moved already. */
static void
af_cjk_align_serif_edge( AF_GlyphHints hints,
AF_Edge base,
AF_Edge serif )
{
FT_UNUSED( hints );
serif->pos = base->pos + ( serif->opos - base->opos );
}
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/**** ****/
/**** E D G E H I N T I N G ****/
/**** ****/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
#define AF_LIGHT_MODE_MAX_HORZ_GAP 9
#define AF_LIGHT_MODE_MAX_VERT_GAP 15
#define AF_LIGHT_MODE_MAX_DELTA_ABS 14
static FT_Pos
af_hint_normal_stem( AF_GlyphHints hints,
AF_Edge edge,
AF_Edge edge2,
FT_Pos anchor,
AF_Dimension dim )
{
FT_Pos org_len, cur_len, org_center;
FT_Pos cur_pos1, cur_pos2;
FT_Pos d_off1, u_off1, d_off2, u_off2, delta;
FT_Pos offset;
FT_Pos threshold = 64;
if ( !AF_LATIN_HINTS_DO_STEM_ADJUST( hints ) )
{
if ( ( edge->flags & AF_EDGE_ROUND ) &&
( edge2->flags & AF_EDGE_ROUND ) )
{
if ( dim == AF_DIMENSION_VERT )
threshold = 64 - AF_LIGHT_MODE_MAX_HORZ_GAP;
else
threshold = 64 - AF_LIGHT_MODE_MAX_VERT_GAP;
}
else
{
if ( dim == AF_DIMENSION_VERT )
threshold = 64 - AF_LIGHT_MODE_MAX_HORZ_GAP / 3;
else
threshold = 64 - AF_LIGHT_MODE_MAX_VERT_GAP / 3;
}
}
org_len = edge2->opos - edge->opos;
cur_len = af_cjk_compute_stem_width( hints, dim, org_len,
edge->flags,
edge2->flags );
org_center = ( edge->opos + edge2->opos ) / 2 + anchor;
cur_pos1 = org_center - cur_len / 2;
cur_pos2 = cur_pos1 + cur_len;
d_off1 = cur_pos1 - FT_PIX_FLOOR( cur_pos1 );
d_off2 = cur_pos2 - FT_PIX_FLOOR( cur_pos2 );
u_off1 = 64 - d_off1;
u_off2 = 64 - d_off2;
delta = 0;
if ( d_off1 == 0 || d_off2 == 0 )
goto Exit;
if ( cur_len <= threshold )
{
if ( d_off2 < cur_len )
{
if ( u_off1 <= d_off2 )
delta = u_off1;
else
delta = -d_off2;
}
goto Exit;
}
if ( threshold < 64 )
{
if ( d_off1 >= threshold || u_off1 >= threshold ||
d_off2 >= threshold || u_off2 >= threshold )
goto Exit;
}
offset = cur_len & 63;
if ( offset < 32 )
{
if ( u_off1 <= offset || d_off2 <= offset )
goto Exit;
}
else
offset = 64 - threshold;
d_off1 = threshold - u_off1;
u_off1 = u_off1 - offset;
u_off2 = threshold - d_off2;
d_off2 = d_off2 - offset;
if ( d_off1 <= u_off1 )
u_off1 = -d_off1;
if ( d_off2 <= u_off2 )
u_off2 = -d_off2;
if ( FT_ABS( u_off1 ) <= FT_ABS( u_off2 ) )
delta = u_off1;
else
delta = u_off2;
Exit:
#if 1
if ( !AF_LATIN_HINTS_DO_STEM_ADJUST( hints ) )
{
if ( delta > AF_LIGHT_MODE_MAX_DELTA_ABS )
delta = AF_LIGHT_MODE_MAX_DELTA_ABS;
else if ( delta < -AF_LIGHT_MODE_MAX_DELTA_ABS )
delta = -AF_LIGHT_MODE_MAX_DELTA_ABS;
}
#endif
cur_pos1 += delta;
if ( edge->opos < edge2->opos )
{
edge->pos = cur_pos1;
edge2->pos = cur_pos1 + cur_len;
}
else
{
edge->pos = cur_pos1 + cur_len;
edge2->pos = cur_pos1;
}
return delta;
}
/* The main grid-fitting routine. */
static void
af_cjk_hint_edges( AF_GlyphHints hints,
AF_Dimension dim )
{
AF_AxisHints axis = &hints->axis[dim];
AF_Edge edges = axis->edges;
AF_Edge edge_limit = FT_OFFSET( edges, axis->num_edges );
FT_PtrDist n_edges;
AF_Edge edge;
AF_Edge anchor = NULL;
FT_Pos delta = 0;
FT_Int skipped = 0;
FT_Bool has_last_stem = FALSE;
FT_Pos last_stem_pos = 0;
#ifdef FT_DEBUG_LEVEL_TRACE
FT_UInt num_actions = 0;
#endif
FT_TRACE5(( "cjk %s edge hinting (style `%s')\n",
dim == AF_DIMENSION_VERT ? "horizontal" : "vertical",
af_style_names[hints->metrics->style_class->style] ));
/* we begin by aligning all stems relative to the blue zone */
if ( AF_HINTS_DO_BLUES( hints ) )
{
for ( edge = edges; edge < edge_limit; edge++ )
{
AF_Width blue;
AF_Edge edge1, edge2;
if ( edge->flags & AF_EDGE_DONE )
continue;
blue = edge->blue_edge;
edge1 = NULL;
edge2 = edge->link;
if ( blue )
{
edge1 = edge;
}
else if ( edge2 && edge2->blue_edge )
{
blue = edge2->blue_edge;
edge1 = edge2;
edge2 = edge;
}
if ( !edge1 )
continue;
#ifdef FT_DEBUG_LEVEL_TRACE
FT_TRACE5(( " CJKBLUE: edge %ld @%d (opos=%.2f) snapped to %.2f,"
" was %.2f\n",
edge1 - edges, edge1->fpos, edge1->opos / 64.0,
blue->fit / 64.0, edge1->pos / 64.0 ));
num_actions++;
#endif
edge1->pos = blue->fit;
edge1->flags |= AF_EDGE_DONE;
if ( edge2 && !edge2->blue_edge )
{
af_cjk_align_linked_edge( hints, dim, edge1, edge2 );
edge2->flags |= AF_EDGE_DONE;
#ifdef FT_DEBUG_LEVEL_TRACE
num_actions++;
#endif
}
if ( !anchor )
anchor = edge;
}
}
/* now we align all stem edges. */
for ( edge = edges; edge < edge_limit; edge++ )
{
AF_Edge edge2;
if ( edge->flags & AF_EDGE_DONE )
continue;
/* skip all non-stem edges */
edge2 = edge->link;
if ( !edge2 )
{
skipped++;
continue;
}
/* Some CJK characters have so many stems that
* the hinter is likely to merge two adjacent ones.
* To solve this problem, if either edge of a stem
* is too close to the previous one, we avoid
* aligning the two edges, but rather interpolate
* their locations at the end of this function in
* order to preserve the space between the stems.
*/
if ( has_last_stem &&
( edge->pos < last_stem_pos + 64 ||
edge2->pos < last_stem_pos + 64 ) )
{
skipped++;
continue;
}
/* now align the stem */
/* this should not happen, but it's better to be safe */
if ( edge2->blue_edge )
{
FT_TRACE5(( "ASSERTION FAILED for edge %ld\n", edge2-edges ));
af_cjk_align_linked_edge( hints, dim, edge2, edge );
edge->flags |= AF_EDGE_DONE;
#ifdef FT_DEBUG_LEVEL_TRACE
num_actions++;
#endif
continue;
}
if ( edge2 < edge )
{
af_cjk_align_linked_edge( hints, dim, edge2, edge );
edge->flags |= AF_EDGE_DONE;
#ifdef FT_DEBUG_LEVEL_TRACE
num_actions++;
#endif
/* We rarely reaches here it seems;
* usually the two edges belonging
* to one stem are marked as DONE together
*/
has_last_stem = TRUE;
last_stem_pos = edge->pos;
continue;
}
if ( dim != AF_DIMENSION_VERT && !anchor )
{
#if 0
if ( fixedpitch )
{
AF_Edge left = edge;
AF_Edge right = edge_limit - 1;
AF_EdgeRec left1, left2, right1, right2;
FT_Pos target, center1, center2;
FT_Pos delta1, delta2, d1, d2;
while ( right > left && !right->link )
right--;
left1 = *left;
left2 = *left->link;
right1 = *right->link;
right2 = *right;
delta = ( ( ( hinter->pp2.x + 32 ) & -64 ) - hinter->pp2.x ) / 2;
target = left->opos + ( right->opos - left->opos ) / 2 + delta - 16;
delta1 = delta;
delta1 += af_hint_normal_stem( hints, left, left->link,
delta1, 0 );
if ( left->link != right )
af_hint_normal_stem( hints, right->link, right, delta1, 0 );
center1 = left->pos + ( right->pos - left->pos ) / 2;
if ( center1 >= target )
delta2 = delta - 32;
else
delta2 = delta + 32;
delta2 += af_hint_normal_stem( hints, &left1, &left2, delta2, 0 );
if ( delta1 != delta2 )
{
if ( left->link != right )
af_hint_normal_stem( hints, &right1, &right2, delta2, 0 );
center2 = left1.pos + ( right2.pos - left1.pos ) / 2;
d1 = center1 - target;
d2 = center2 - target;
if ( FT_ABS( d2 ) < FT_ABS( d1 ) )
{
left->pos = left1.pos;
left->link->pos = left2.pos;
if ( left->link != right )
{
right->link->pos = right1.pos;
right->pos = right2.pos;
}
delta1 = delta2;
}
}
delta = delta1;
right->link->flags |= AF_EDGE_DONE;
right->flags |= AF_EDGE_DONE;
}
else
#endif /* 0 */
delta = af_hint_normal_stem( hints, edge, edge2, 0,
AF_DIMENSION_HORZ );
}
else
af_hint_normal_stem( hints, edge, edge2, delta, dim );
#if 0
printf( "stem (%d,%d) adjusted (%.1f,%.1f)\n",
edge - edges, edge2 - edges,
( edge->pos - edge->opos ) / 64.0,
( edge2->pos - edge2->opos ) / 64.0 );
#endif
anchor = edge;
edge->flags |= AF_EDGE_DONE;
edge2->flags |= AF_EDGE_DONE;
has_last_stem = TRUE;
last_stem_pos = edge2->pos;
}
/* make sure that lowercase m's maintain their symmetry */
/* In general, lowercase m's have six vertical edges if they are sans */
/* serif, or twelve if they are with serifs. This implementation is */
/* based on that assumption, and seems to work very well with most */
/* faces. However, if for a certain face this assumption is not */
/* true, the m is just rendered like before. In addition, any stem */
/* correction will only be applied to symmetrical glyphs (even if the */
/* glyph is not an m), so the potential for unwanted distortion is */
/* relatively low. */
/* We don't handle horizontal edges since we can't easily assure that */
/* the third (lowest) stem aligns with the base line; it might end up */
/* one pixel higher or lower. */
n_edges = edge_limit - edges;
if ( dim == AF_DIMENSION_HORZ && ( n_edges == 6 || n_edges == 12 ) )
{
AF_Edge edge1, edge2, edge3;
FT_Pos dist1, dist2, span;
if ( n_edges == 6 )
{
edge1 = edges;
edge2 = edges + 2;
edge3 = edges + 4;
}
else
{
edge1 = edges + 1;
edge2 = edges + 5;
edge3 = edges + 9;
}
dist1 = edge2->opos - edge1->opos;
dist2 = edge3->opos - edge2->opos;
span = dist1 - dist2;
if ( span < 0 )
span = -span;
if ( edge1->link == edge1 + 1 &&
edge2->link == edge2 + 1 &&
edge3->link == edge3 + 1 && span < 8 )
{
delta = edge3->pos - ( 2 * edge2->pos - edge1->pos );
edge3->pos -= delta;
if ( edge3->link )
edge3->link->pos -= delta;
/* move the serifs along with the stem */
if ( n_edges == 12 )
{
( edges + 8 )->pos -= delta;
( edges + 11 )->pos -= delta;
}
edge3->flags |= AF_EDGE_DONE;
if ( edge3->link )
edge3->link->flags |= AF_EDGE_DONE;
}
}
if ( !skipped )
goto Exit;
/*
* now hint the remaining edges (serifs and single) in order
* to complete our processing
*/
for ( edge = edges; edge < edge_limit; edge++ )
{
if ( edge->flags & AF_EDGE_DONE )
continue;
if ( edge->serif )
{
af_cjk_align_serif_edge( hints, edge->serif, edge );
edge->flags |= AF_EDGE_DONE;
skipped--;
}
}
if ( !skipped )
goto Exit;
for ( edge = edges; edge < edge_limit; edge++ )
{
AF_Edge before, after;
if ( edge->flags & AF_EDGE_DONE )
continue;
before = after = edge;
while ( --before >= edges )
if ( before->flags & AF_EDGE_DONE )
break;
while ( ++after < edge_limit )
if ( after->flags & AF_EDGE_DONE )
break;
if ( before >= edges || after < edge_limit )
{
if ( before < edges )
af_cjk_align_serif_edge( hints, after, edge );
else if ( after >= edge_limit )
af_cjk_align_serif_edge( hints, before, edge );
else
{
if ( after->fpos == before->fpos )
edge->pos = before->pos;
else
edge->pos = before->pos +
FT_MulDiv( edge->fpos - before->fpos,
after->pos - before->pos,
after->fpos - before->fpos );
}
}
}
Exit:
#ifdef FT_DEBUG_LEVEL_TRACE
if ( !num_actions )
FT_TRACE5(( " (none)\n" ));
FT_TRACE5(( "\n" ));
#endif
return;
}
static void
af_cjk_align_edge_points( AF_GlyphHints hints,
AF_Dimension dim )
{
AF_AxisHints axis = & hints->axis[dim];
AF_Edge edges = axis->edges;
AF_Edge edge_limit = FT_OFFSET( edges, axis->num_edges );
AF_Edge edge;
FT_Bool snapping;
snapping = FT_BOOL( ( dim == AF_DIMENSION_HORZ &&
AF_LATIN_HINTS_DO_HORZ_SNAP( hints ) ) ||
( dim == AF_DIMENSION_VERT &&
AF_LATIN_HINTS_DO_VERT_SNAP( hints ) ) );
for ( edge = edges; edge < edge_limit; edge++ )
{
/* move the points of each segment */
/* in each edge to the edge's position */
AF_Segment seg = edge->first;
if ( snapping )
{
do
{
AF_Point point = seg->first;
for (;;)
{
if ( dim == AF_DIMENSION_HORZ )
{
point->x = edge->pos;
point->flags |= AF_FLAG_TOUCH_X;
}
else
{
point->y = edge->pos;
point->flags |= AF_FLAG_TOUCH_Y;
}
if ( point == seg->last )
break;
point = point->next;
}
seg = seg->edge_next;
} while ( seg != edge->first );
}
else
{
FT_Pos delta = edge->pos - edge->opos;
do
{
AF_Point point = seg->first;
for (;;)
{
if ( dim == AF_DIMENSION_HORZ )
{
point->x += delta;
point->flags |= AF_FLAG_TOUCH_X;
}
else
{
point->y += delta;
point->flags |= AF_FLAG_TOUCH_Y;
}
if ( point == seg->last )
break;
point = point->next;
}
seg = seg->edge_next;
} while ( seg != edge->first );
}
}
}
/* Apply the complete hinting algorithm to a CJK glyph. */
FT_LOCAL_DEF( FT_Error )
af_cjk_hints_apply( FT_UInt glyph_index,
AF_GlyphHints hints,
FT_Outline* outline,
AF_CJKMetrics metrics )
{
FT_Error error;
int dim;
FT_UNUSED( metrics );
FT_UNUSED( glyph_index );
error = af_glyph_hints_reload( hints, outline );
if ( error )
goto Exit;
/* analyze glyph outline */
if ( AF_HINTS_DO_HORIZONTAL( hints ) )
{
error = af_cjk_hints_detect_features( hints, AF_DIMENSION_HORZ );
if ( error )
goto Exit;
af_cjk_hints_compute_blue_edges( hints, metrics, AF_DIMENSION_HORZ );
}
if ( AF_HINTS_DO_VERTICAL( hints ) )
{
error = af_cjk_hints_detect_features( hints, AF_DIMENSION_VERT );
if ( error )
goto Exit;
af_cjk_hints_compute_blue_edges( hints, metrics, AF_DIMENSION_VERT );
}
/* grid-fit the outline */
for ( dim = 0; dim < AF_DIMENSION_MAX; dim++ )
{
if ( ( dim == AF_DIMENSION_HORZ && AF_HINTS_DO_HORIZONTAL( hints ) ) ||
( dim == AF_DIMENSION_VERT && AF_HINTS_DO_VERTICAL( hints ) ) )
{
af_cjk_hint_edges( hints, (AF_Dimension)dim );
af_cjk_align_edge_points( hints, (AF_Dimension)dim );
af_glyph_hints_align_strong_points( hints, (AF_Dimension)dim );
af_glyph_hints_align_weak_points( hints, (AF_Dimension)dim );
}
}
af_glyph_hints_save( hints, outline );
Exit:
return error;
}
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** C J K S C R I P T C L A S S *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
AF_DEFINE_WRITING_SYSTEM_CLASS(
af_cjk_writing_system_class,
AF_WRITING_SYSTEM_CJK,
sizeof ( AF_CJKMetricsRec ),
(AF_WritingSystem_InitMetricsFunc) af_cjk_metrics_init, /* style_metrics_init */
(AF_WritingSystem_ScaleMetricsFunc)af_cjk_metrics_scale, /* style_metrics_scale */
(AF_WritingSystem_DoneMetricsFunc) NULL, /* style_metrics_done */
(AF_WritingSystem_GetStdWidthsFunc)af_cjk_get_standard_widths, /* style_metrics_getstdw */
(AF_WritingSystem_InitHintsFunc) af_cjk_hints_init, /* style_hints_init */
(AF_WritingSystem_ApplyHintsFunc) af_cjk_hints_apply /* style_hints_apply */
)
#else /* !AF_CONFIG_OPTION_CJK */
AF_DEFINE_WRITING_SYSTEM_CLASS(
af_cjk_writing_system_class,
AF_WRITING_SYSTEM_CJK,
sizeof ( AF_CJKMetricsRec ),
(AF_WritingSystem_InitMetricsFunc) NULL, /* style_metrics_init */
(AF_WritingSystem_ScaleMetricsFunc)NULL, /* style_metrics_scale */
(AF_WritingSystem_DoneMetricsFunc) NULL, /* style_metrics_done */
(AF_WritingSystem_GetStdWidthsFunc)NULL, /* style_metrics_getstdw */
(AF_WritingSystem_InitHintsFunc) NULL, /* style_hints_init */
(AF_WritingSystem_ApplyHintsFunc) NULL /* style_hints_apply */
)
#endif /* !AF_CONFIG_OPTION_CJK */
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/autofit/afcjk.c
|
C++
|
gpl-3.0
| 66,119
|
/****************************************************************************
*
* afcjk.h
*
* Auto-fitter hinting routines for CJK writing system (specification).
*
* Copyright (C) 2006-2022 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 AFCJK_H_
#define AFCJK_H_
#include "afhints.h"
#include "aflatin.h"
FT_BEGIN_HEADER
/* the CJK-specific writing system */
AF_DECLARE_WRITING_SYSTEM_CLASS( af_cjk_writing_system_class )
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** C J K G L O B A L M E T R I C S *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
/*
* CJK glyphs tend to fill the square. So we have both vertical and
* horizontal blue zones. But some glyphs have flat bounding strokes that
* leave some space between neighbour glyphs.
*/
#define AF_CJK_IS_TOP_BLUE( b ) \
( (b)->properties & AF_BLUE_PROPERTY_CJK_TOP )
#define AF_CJK_IS_HORIZ_BLUE( b ) \
( (b)->properties & AF_BLUE_PROPERTY_CJK_HORIZ )
#define AF_CJK_IS_RIGHT_BLUE AF_CJK_IS_TOP_BLUE
#define AF_CJK_MAX_WIDTHS 16
#define AF_CJK_BLUE_ACTIVE ( 1U << 0 ) /* zone height is <= 3/4px */
#define AF_CJK_BLUE_TOP ( 1U << 1 ) /* result of AF_CJK_IS_TOP_BLUE */
#define AF_CJK_BLUE_ADJUSTMENT ( 1U << 2 ) /* used for scale adjustment */
/* optimization */
typedef struct AF_CJKBlueRec_
{
AF_WidthRec ref;
AF_WidthRec shoot; /* undershoot */
FT_UInt flags;
} AF_CJKBlueRec, *AF_CJKBlue;
typedef struct AF_CJKAxisRec_
{
FT_Fixed scale;
FT_Pos delta;
FT_UInt width_count; /* number of used widths */
AF_WidthRec widths[AF_CJK_MAX_WIDTHS]; /* widths array */
FT_Pos edge_distance_threshold; /* used for creating edges */
FT_Pos standard_width; /* the default stem thickness */
FT_Bool extra_light; /* is standard width very light? */
/* used for horizontal metrics too for CJK */
FT_Bool control_overshoot;
FT_UInt blue_count;
AF_CJKBlueRec blues[AF_BLUE_STRINGSET_MAX];
FT_Fixed org_scale;
FT_Pos org_delta;
} AF_CJKAxisRec, *AF_CJKAxis;
typedef struct AF_CJKMetricsRec_
{
AF_StyleMetricsRec root;
FT_UInt units_per_em;
AF_CJKAxisRec axis[AF_DIMENSION_MAX];
} AF_CJKMetricsRec, *AF_CJKMetrics;
#ifdef AF_CONFIG_OPTION_CJK
FT_LOCAL( FT_Error )
af_cjk_metrics_init( AF_CJKMetrics metrics,
FT_Face face );
FT_LOCAL( void )
af_cjk_metrics_scale( AF_CJKMetrics metrics,
AF_Scaler scaler );
FT_LOCAL( FT_Error )
af_cjk_hints_init( AF_GlyphHints hints,
AF_CJKMetrics metrics );
FT_LOCAL( FT_Error )
af_cjk_hints_apply( FT_UInt glyph_index,
AF_GlyphHints hints,
FT_Outline* outline,
AF_CJKMetrics metrics );
/* shared; called from afindic.c */
FT_LOCAL( void )
af_cjk_metrics_check_digits( AF_CJKMetrics metrics,
FT_Face face );
FT_LOCAL( void )
af_cjk_metrics_init_widths( AF_CJKMetrics metrics,
FT_Face face );
#endif /* AF_CONFIG_OPTION_CJK */
/* */
FT_END_HEADER
#endif /* AFCJK_H_ */
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/autofit/afcjk.h
|
C++
|
gpl-3.0
| 4,191
|
/****************************************************************************
*
* afcover.h
*
* Auto-fitter coverages (specification only).
*
* Copyright (C) 2013-2022 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 header file can be included multiple times. */
/* Define `COVERAGE' as needed. */
/* Add new coverages here. The first and second arguments are the */
/* coverage name in lowercase and uppercase, respectively, followed */
/* by a description string. The last four arguments are the four */
/* characters defining the corresponding OpenType feature. */
#if 0
/* XXX: It's not possible to define blue zone characters in advance. */
COVERAGE( alternative_fractions, ALTERNATIVE_FRACTIONS,
"alternative fractions",
'a', 'f', 'r', 'c' )
#endif
COVERAGE( petite_capitals_from_capitals, PETITE_CAPITALS_FROM_CAPITALS,
"petite capitals from capitals",
'c', '2', 'c', 'p' )
COVERAGE( small_capitals_from_capitals, SMALL_CAPITALS_FROM_CAPITALS,
"small capitals from capitals",
'c', '2', 's', 'c' )
#if 0
/* XXX: Only digits are in this coverage, however, both normal style */
/* and oldstyle representation forms are possible. */
COVERAGE( denominators, DENOMINATORS,
"denominators",
'd', 'n', 'o', 'm' )
#endif
#if 0
/* XXX: It's not possible to define blue zone characters in advance. */
COVERAGE( fractions, FRACTIONS,
"fractions",
'f', 'r', 'a', 'c' )
#endif
#if 0
/* XXX: Only digits are in this coverage, however, both normal style */
/* and oldstyle representation forms are possible. */
COVERAGE( numerators, NUMERATORS,
"numerators",
'n', 'u', 'm', 'r' )
#endif
COVERAGE( ordinals, ORDINALS,
"ordinals",
'o', 'r', 'd', 'n' )
COVERAGE( petite_capitals, PETITE_CAPITALS,
"petite capitals",
'p', 'c', 'a', 'p' )
COVERAGE( ruby, RUBY,
"ruby",
'r', 'u', 'b', 'y' )
COVERAGE( scientific_inferiors, SCIENTIFIC_INFERIORS,
"scientific inferiors",
's', 'i', 'n', 'f' )
COVERAGE( small_capitals, SMALL_CAPITALS,
"small capitals",
's', 'm', 'c', 'p' )
COVERAGE( subscript, SUBSCRIPT,
"subscript",
's', 'u', 'b', 's' )
COVERAGE( superscript, SUPERSCRIPT,
"superscript",
's', 'u', 'p', 's' )
COVERAGE( titling, TITLING,
"titling",
't', 'i', 't', 'l' )
#if 0
/* to be always excluded */
COVERAGE(nalt, 'n', 'a', 'l', 't'); /* Alternate Annotation Forms (?) */
COVERAGE(ornm, 'o', 'r', 'n', 'm'); /* Ornaments (?) */
#endif
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/autofit/afcover.h
|
C++
|
gpl-3.0
| 3,159
|
/****************************************************************************
*
* afdummy.c
*
* Auto-fitter dummy routines to be used if no hinting should be
* performed (body).
*
* Copyright (C) 2003-2022 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.
*
*/
#include "afdummy.h"
#include "afhints.h"
#include "aferrors.h"
static FT_Error
af_dummy_hints_init( AF_GlyphHints hints,
AF_StyleMetrics metrics )
{
af_glyph_hints_rescale( hints, metrics );
hints->x_scale = metrics->scaler.x_scale;
hints->y_scale = metrics->scaler.y_scale;
hints->x_delta = metrics->scaler.x_delta;
hints->y_delta = metrics->scaler.y_delta;
return FT_Err_Ok;
}
static FT_Error
af_dummy_hints_apply( FT_UInt glyph_index,
AF_GlyphHints hints,
FT_Outline* outline,
AF_StyleMetrics metrics )
{
FT_Error error;
FT_UNUSED( glyph_index );
FT_UNUSED( metrics );
error = af_glyph_hints_reload( hints, outline );
if ( !error )
af_glyph_hints_save( hints, outline );
return error;
}
AF_DEFINE_WRITING_SYSTEM_CLASS(
af_dummy_writing_system_class,
AF_WRITING_SYSTEM_DUMMY,
sizeof ( AF_StyleMetricsRec ),
(AF_WritingSystem_InitMetricsFunc) NULL, /* style_metrics_init */
(AF_WritingSystem_ScaleMetricsFunc)NULL, /* style_metrics_scale */
(AF_WritingSystem_DoneMetricsFunc) NULL, /* style_metrics_done */
(AF_WritingSystem_GetStdWidthsFunc)NULL, /* style_metrics_getstdw */
(AF_WritingSystem_InitHintsFunc) af_dummy_hints_init, /* style_hints_init */
(AF_WritingSystem_ApplyHintsFunc) af_dummy_hints_apply /* style_hints_apply */
)
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/autofit/afdummy.c
|
C++
|
gpl-3.0
| 2,160
|
/****************************************************************************
*
* afdummy.h
*
* Auto-fitter dummy routines to be used if no hinting should be
* performed (specification).
*
* Copyright (C) 2003-2022 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 AFDUMMY_H_
#define AFDUMMY_H_
#include "aftypes.h"
FT_BEGIN_HEADER
/* A dummy writing system used when no hinting should be performed. */
AF_DECLARE_WRITING_SYSTEM_CLASS( af_dummy_writing_system_class )
/* */
FT_END_HEADER
#endif /* AFDUMMY_H_ */
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/autofit/afdummy.h
|
C++
|
gpl-3.0
| 877
|
/****************************************************************************
*
* aferrors.h
*
* Autofitter error codes (specification only).
*
* Copyright (C) 2005-2022 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 file is used to define the Autofitter error enumeration
* constants.
*
*/
#ifndef AFERRORS_H_
#define AFERRORS_H_
#include <freetype/ftmoderr.h>
#undef FTERRORS_H_
#undef FT_ERR_PREFIX
#define FT_ERR_PREFIX AF_Err_
#define FT_ERR_BASE FT_Mod_Err_Autofit
#include <freetype/fterrors.h>
#endif /* AFERRORS_H_ */
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/autofit/aferrors.h
|
C++
|
gpl-3.0
| 984
|
/****************************************************************************
*
* afglobal.c
*
* Auto-fitter routines to compute global hinting values (body).
*
* Copyright (C) 2003-2022 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.
*
*/
#include "afglobal.h"
#include "afranges.h"
#include "afshaper.h"
#include "afws-decl.h"
#include <freetype/internal/ftdebug.h>
/**************************************************************************
*
* The macro FT_COMPONENT is used in trace mode. It is an implicit
* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
* messages during execution.
*/
#undef FT_COMPONENT
#define FT_COMPONENT afglobal
#include "aferrors.h"
#undef SCRIPT
#define SCRIPT( s, S, d, h, H, ss ) \
AF_DEFINE_SCRIPT_CLASS( \
af_ ## s ## _script_class, \
AF_SCRIPT_ ## S, \
af_ ## s ## _uniranges, \
af_ ## s ## _nonbase_uniranges, \
AF_ ## H, \
ss )
#include "afscript.h"
#undef STYLE
#define STYLE( s, S, d, ws, sc, ss, c ) \
AF_DEFINE_STYLE_CLASS( \
af_ ## s ## _style_class, \
AF_STYLE_ ## S, \
ws, \
sc, \
ss, \
c )
#include "afstyles.h"
#undef WRITING_SYSTEM
#define WRITING_SYSTEM( ws, WS ) \
&af_ ## ws ## _writing_system_class,
FT_LOCAL_ARRAY_DEF( AF_WritingSystemClass )
af_writing_system_classes[] =
{
#include "afws-iter.h"
NULL /* do not remove */
};
#undef SCRIPT
#define SCRIPT( s, S, d, h, H, ss ) \
&af_ ## s ## _script_class,
FT_LOCAL_ARRAY_DEF( AF_ScriptClass )
af_script_classes[] =
{
#include "afscript.h"
NULL /* do not remove */
};
#undef STYLE
#define STYLE( s, S, d, ws, sc, ss, c ) \
&af_ ## s ## _style_class,
FT_LOCAL_ARRAY_DEF( AF_StyleClass )
af_style_classes[] =
{
#include "afstyles.h"
NULL /* do not remove */
};
#ifdef FT_DEBUG_LEVEL_TRACE
#undef STYLE
#define STYLE( s, S, d, ws, sc, ss, c ) #s,
FT_LOCAL_ARRAY_DEF( char* )
af_style_names[] =
{
#include "afstyles.h"
};
#endif /* FT_DEBUG_LEVEL_TRACE */
/* Compute the style index of each glyph within a given face. */
static FT_Error
af_face_globals_compute_style_coverage( AF_FaceGlobals globals )
{
FT_Error error;
FT_Face face = globals->face;
FT_CharMap old_charmap = face->charmap;
FT_UShort* gstyles = globals->glyph_styles;
FT_UInt ss;
FT_UInt i;
FT_UInt dflt = ~0U; /* a non-valid value */
/* the value AF_STYLE_UNASSIGNED means `uncovered glyph' */
for ( i = 0; i < (FT_UInt)globals->glyph_count; i++ )
gstyles[i] = AF_STYLE_UNASSIGNED;
error = FT_Select_Charmap( face, FT_ENCODING_UNICODE );
if ( error )
{
/*
* Ignore this error; we simply use the fallback style.
* XXX: Shouldn't we rather disable hinting?
*/
error = FT_Err_Ok;
goto Exit;
}
/* scan each style in a Unicode charmap */
for ( ss = 0; af_style_classes[ss]; ss++ )
{
AF_StyleClass style_class =
af_style_classes[ss];
AF_ScriptClass script_class =
af_script_classes[style_class->script];
AF_Script_UniRange range;
if ( !script_class->script_uni_ranges )
continue;
/*
* Scan all Unicode points in the range and set the corresponding
* glyph style index.
*/
if ( style_class->coverage == AF_COVERAGE_DEFAULT )
{
if ( (FT_UInt)style_class->script ==
globals->module->default_script )
dflt = ss;
for ( range = script_class->script_uni_ranges;
range->first != 0;
range++ )
{
FT_ULong charcode = range->first;
FT_UInt gindex;
gindex = FT_Get_Char_Index( face, charcode );
if ( gindex != 0 &&
gindex < (FT_ULong)globals->glyph_count &&
( gstyles[gindex] & AF_STYLE_MASK ) == AF_STYLE_UNASSIGNED )
gstyles[gindex] = (FT_UShort)ss;
for (;;)
{
charcode = FT_Get_Next_Char( face, charcode, &gindex );
if ( gindex == 0 || charcode > range->last )
break;
if ( gindex < (FT_ULong)globals->glyph_count &&
( gstyles[gindex] & AF_STYLE_MASK ) == AF_STYLE_UNASSIGNED )
gstyles[gindex] = (FT_UShort)ss;
}
}
/* do the same for the script's non-base characters */
for ( range = script_class->script_uni_nonbase_ranges;
range->first != 0;
range++ )
{
FT_ULong charcode = range->first;
FT_UInt gindex;
gindex = FT_Get_Char_Index( face, charcode );
if ( gindex != 0 &&
gindex < (FT_ULong)globals->glyph_count &&
( gstyles[gindex] & AF_STYLE_MASK ) == (FT_UShort)ss )
gstyles[gindex] |= AF_NONBASE;
for (;;)
{
charcode = FT_Get_Next_Char( face, charcode, &gindex );
if ( gindex == 0 || charcode > range->last )
break;
if ( gindex < (FT_ULong)globals->glyph_count &&
( gstyles[gindex] & AF_STYLE_MASK ) == (FT_UShort)ss )
gstyles[gindex] |= AF_NONBASE;
}
}
}
else
{
/* get glyphs not directly addressable by cmap */
af_shaper_get_coverage( globals, style_class, gstyles, 0 );
}
}
/* handle the remaining default OpenType features ... */
for ( ss = 0; af_style_classes[ss]; ss++ )
{
AF_StyleClass style_class = af_style_classes[ss];
if ( style_class->coverage == AF_COVERAGE_DEFAULT )
af_shaper_get_coverage( globals, style_class, gstyles, 0 );
}
/* ... and finally the default OpenType features of the default script */
af_shaper_get_coverage( globals, af_style_classes[dflt], gstyles, 1 );
/* mark ASCII digits */
for ( i = 0x30; i <= 0x39; i++ )
{
FT_UInt gindex = FT_Get_Char_Index( face, i );
if ( gindex != 0 && gindex < (FT_ULong)globals->glyph_count )
gstyles[gindex] |= AF_DIGIT;
}
Exit:
/*
* By default, all uncovered glyphs are set to the fallback style.
* XXX: Shouldn't we disable hinting or do something similar?
*/
if ( globals->module->fallback_style != AF_STYLE_UNASSIGNED )
{
FT_Long nn;
for ( nn = 0; nn < globals->glyph_count; nn++ )
{
if ( ( gstyles[nn] & AF_STYLE_MASK ) == AF_STYLE_UNASSIGNED )
{
gstyles[nn] &= ~AF_STYLE_MASK;
gstyles[nn] |= globals->module->fallback_style;
}
}
}
#ifdef FT_DEBUG_LEVEL_TRACE
FT_TRACE4(( "\n" ));
FT_TRACE4(( "style coverage\n" ));
FT_TRACE4(( "==============\n" ));
FT_TRACE4(( "\n" ));
for ( ss = 0; af_style_classes[ss]; ss++ )
{
AF_StyleClass style_class = af_style_classes[ss];
FT_UInt count = 0;
FT_Long idx;
FT_TRACE4(( "%s:\n", af_style_names[style_class->style] ));
for ( idx = 0; idx < globals->glyph_count; idx++ )
{
if ( ( gstyles[idx] & AF_STYLE_MASK ) == style_class->style )
{
if ( !( count % 10 ) )
FT_TRACE4(( " " ));
FT_TRACE4(( " %ld", idx ));
count++;
if ( !( count % 10 ) )
FT_TRACE4(( "\n" ));
}
}
if ( !count )
FT_TRACE4(( " (none)\n" ));
if ( count % 10 )
FT_TRACE4(( "\n" ));
}
#endif /* FT_DEBUG_LEVEL_TRACE */
FT_Set_Charmap( face, old_charmap );
return error;
}
FT_LOCAL_DEF( FT_Error )
af_face_globals_new( FT_Face face,
AF_FaceGlobals *aglobals,
AF_Module module )
{
FT_Error error;
FT_Memory memory;
AF_FaceGlobals globals = NULL;
memory = face->memory;
/* we allocate an AF_FaceGlobals structure together */
/* with the glyph_styles array */
if ( FT_QALLOC( globals,
sizeof ( *globals ) +
(FT_ULong)face->num_glyphs * sizeof ( FT_UShort ) ) )
goto Exit;
FT_ZERO( &globals->metrics );
globals->face = face;
globals->glyph_count = face->num_glyphs;
/* right after the globals structure come the glyph styles */
globals->glyph_styles = (FT_UShort*)( globals + 1 );
globals->module = module;
globals->stem_darkening_for_ppem = 0;
globals->darken_x = 0;
globals->darken_y = 0;
globals->standard_vertical_width = 0;
globals->standard_horizontal_width = 0;
globals->scale_down_factor = 0;
#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
globals->hb_font = hb_ft_font_create( face, NULL );
globals->hb_buf = hb_buffer_create();
#endif
error = af_face_globals_compute_style_coverage( globals );
if ( error )
{
af_face_globals_free( globals );
globals = NULL;
}
else
globals->increase_x_height = AF_PROP_INCREASE_X_HEIGHT_MAX;
Exit:
*aglobals = globals;
return error;
}
FT_LOCAL_DEF( void )
af_face_globals_free( AF_FaceGlobals globals )
{
if ( globals )
{
FT_Memory memory = globals->face->memory;
FT_UInt nn;
for ( nn = 0; nn < AF_STYLE_MAX; nn++ )
{
if ( globals->metrics[nn] )
{
AF_StyleClass style_class =
af_style_classes[nn];
AF_WritingSystemClass writing_system_class =
af_writing_system_classes[style_class->writing_system];
if ( writing_system_class->style_metrics_done )
writing_system_class->style_metrics_done( globals->metrics[nn] );
FT_FREE( globals->metrics[nn] );
}
}
#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
hb_font_destroy( globals->hb_font );
hb_buffer_destroy( globals->hb_buf );
#endif
/* no need to free `globals->glyph_styles'; */
/* it is part of the `globals' array */
FT_FREE( globals );
}
}
FT_LOCAL_DEF( FT_Error )
af_face_globals_get_metrics( AF_FaceGlobals globals,
FT_UInt gindex,
FT_UInt options,
AF_StyleMetrics *ametrics )
{
AF_StyleMetrics metrics = NULL;
AF_Style style = (AF_Style)options;
AF_WritingSystemClass writing_system_class;
AF_StyleClass style_class;
FT_Error error = FT_Err_Ok;
if ( gindex >= (FT_ULong)globals->glyph_count )
{
error = FT_THROW( Invalid_Argument );
goto Exit;
}
/* if we have a forced style (via `options'), use it, */
/* otherwise look into `glyph_styles' array */
if ( style == AF_STYLE_NONE_DFLT || style + 1 >= AF_STYLE_MAX )
style = (AF_Style)( globals->glyph_styles[gindex] &
AF_STYLE_UNASSIGNED );
Again:
style_class = af_style_classes[style];
writing_system_class = af_writing_system_classes
[style_class->writing_system];
metrics = globals->metrics[style];
if ( !metrics )
{
/* create the global metrics object if necessary */
FT_Memory memory = globals->face->memory;
if ( FT_ALLOC( metrics, writing_system_class->style_metrics_size ) )
goto Exit;
metrics->style_class = style_class;
metrics->globals = globals;
if ( writing_system_class->style_metrics_init )
{
error = writing_system_class->style_metrics_init( metrics,
globals->face );
if ( error )
{
if ( writing_system_class->style_metrics_done )
writing_system_class->style_metrics_done( metrics );
FT_FREE( metrics );
/* internal error code -1 indicates */
/* that no blue zones have been found */
if ( error == -1 )
{
style = (AF_Style)( globals->glyph_styles[gindex] &
AF_STYLE_UNASSIGNED );
/* IMPORTANT: Clear the error code, see
* https://gitlab.freedesktop.org/freetype/freetype/-/issues/1063
*/
error = FT_Err_Ok;
goto Again;
}
goto Exit;
}
}
globals->metrics[style] = metrics;
}
Exit:
*ametrics = metrics;
return error;
}
FT_LOCAL_DEF( FT_Bool )
af_face_globals_is_digit( AF_FaceGlobals globals,
FT_UInt gindex )
{
if ( gindex < (FT_ULong)globals->glyph_count )
return FT_BOOL( globals->glyph_styles[gindex] & AF_DIGIT );
return FT_BOOL( 0 );
}
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/autofit/afglobal.c
|
C++
|
gpl-3.0
| 13,819
|
/****************************************************************************
*
* afglobal.h
*
* Auto-fitter routines to compute global hinting values
* (specification).
*
* Copyright (C) 2003-2022 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 AFGLOBAL_H_
#define AFGLOBAL_H_
#include "aftypes.h"
#include "afmodule.h"
#include "afshaper.h"
FT_BEGIN_HEADER
FT_LOCAL_ARRAY( AF_WritingSystemClass )
af_writing_system_classes[];
#undef SCRIPT
#define SCRIPT( s, S, d, h, H, ss ) \
AF_DECLARE_SCRIPT_CLASS( af_ ## s ## _script_class )
#include "afscript.h"
FT_LOCAL_ARRAY( AF_ScriptClass )
af_script_classes[];
#undef STYLE
#define STYLE( s, S, d, ws, sc, ss, c ) \
AF_DECLARE_STYLE_CLASS( af_ ## s ## _style_class )
#include "afstyles.h"
FT_LOCAL_ARRAY( AF_StyleClass )
af_style_classes[];
#ifdef FT_DEBUG_LEVEL_TRACE
FT_LOCAL_ARRAY( char* )
af_style_names[];
#endif
/*
* Default values and flags for both autofitter globals (found in
* AF_ModuleRec) and face globals (in AF_FaceGlobalsRec).
*/
/* index of fallback style in `af_style_classes' */
#ifdef AF_CONFIG_OPTION_CJK
#define AF_STYLE_FALLBACK AF_STYLE_HANI_DFLT
#else
#define AF_STYLE_FALLBACK AF_STYLE_NONE_DFLT
#endif
/* default script for OpenType; ignored if HarfBuzz isn't used */
#define AF_SCRIPT_DEFAULT AF_SCRIPT_LATN
/* a bit mask for AF_DIGIT and AF_NONBASE */
#define AF_STYLE_MASK 0x3FFF
/* an uncovered glyph */
#define AF_STYLE_UNASSIGNED AF_STYLE_MASK
/* if this flag is set, we have an ASCII digit */
#define AF_DIGIT 0x8000U
/* if this flag is set, we have a non-base character */
#define AF_NONBASE 0x4000U
/* `increase-x-height' property */
#define AF_PROP_INCREASE_X_HEIGHT_MIN 6
#define AF_PROP_INCREASE_X_HEIGHT_MAX 0
/************************************************************************/
/************************************************************************/
/***** *****/
/***** F A C E G L O B A L S *****/
/***** *****/
/************************************************************************/
/************************************************************************/
/*
* Note that glyph_styles[] maps each glyph to an index into the
* `af_style_classes' array.
*
*/
typedef struct AF_FaceGlobalsRec_
{
FT_Face face;
FT_Long glyph_count; /* same as face->num_glyphs */
FT_UShort* glyph_styles;
#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
hb_font_t* hb_font;
hb_buffer_t* hb_buf; /* for feature comparison */
#endif
/* per-face auto-hinter properties */
FT_UInt increase_x_height;
AF_StyleMetrics metrics[AF_STYLE_MAX];
/* Compute darkening amount once per size. Use this to check whether */
/* darken_{x,y} needs to be recomputed. */
FT_UShort stem_darkening_for_ppem;
/* Copy from e.g. AF_LatinMetrics.axis[AF_DIMENSION_HORZ] */
/* to compute the darkening amount. */
FT_Pos standard_vertical_width;
/* Copy from e.g. AF_LatinMetrics.axis[AF_DIMENSION_VERT] */
/* to compute the darkening amount. */
FT_Pos standard_horizontal_width;
/* The actual amount to darken a glyph along the X axis. */
FT_Pos darken_x;
/* The actual amount to darken a glyph along the Y axis. */
FT_Pos darken_y;
/* Amount to scale down by to keep emboldened points */
/* on the Y-axis in pre-computed blue zones. */
FT_Fixed scale_down_factor;
AF_Module module; /* to access global properties */
} AF_FaceGlobalsRec;
/*
* model the global hints data for a given face, decomposed into
* style-specific items
*/
FT_LOCAL( FT_Error )
af_face_globals_new( FT_Face face,
AF_FaceGlobals *aglobals,
AF_Module module );
FT_LOCAL( FT_Error )
af_face_globals_get_metrics( AF_FaceGlobals globals,
FT_UInt gindex,
FT_UInt options,
AF_StyleMetrics *ametrics );
FT_LOCAL( void )
af_face_globals_free( AF_FaceGlobals globals );
FT_LOCAL_DEF( FT_Bool )
af_face_globals_is_digit( AF_FaceGlobals globals,
FT_UInt gindex );
/* */
FT_END_HEADER
#endif /* AFGLOBAL_H_ */
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/autofit/afglobal.h
|
C++
|
gpl-3.0
| 5,122
|
/****************************************************************************
*
* afhints.c
*
* Auto-fitter hinting routines (body).
*
* Copyright (C) 2003-2022 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.
*
*/
#include "afhints.h"
#include "aferrors.h"
#include <freetype/internal/ftcalc.h>
#include <freetype/internal/ftdebug.h>
/**************************************************************************
*
* The macro FT_COMPONENT is used in trace mode. It is an implicit
* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
* messages during execution.
*/
#undef FT_COMPONENT
#define FT_COMPONENT afhints
FT_LOCAL_DEF( void )
af_sort_pos( FT_UInt count,
FT_Pos* table )
{
FT_UInt i, j;
FT_Pos swap;
for ( i = 1; i < count; i++ )
{
for ( j = i; j > 0; j-- )
{
if ( table[j] >= table[j - 1] )
break;
swap = table[j];
table[j] = table[j - 1];
table[j - 1] = swap;
}
}
}
FT_LOCAL_DEF( void )
af_sort_and_quantize_widths( FT_UInt* count,
AF_Width table,
FT_Pos threshold )
{
FT_UInt i, j;
FT_UInt cur_idx;
FT_Pos cur_val;
FT_Pos sum;
AF_WidthRec swap;
if ( *count == 1 )
return;
/* sort */
for ( i = 1; i < *count; i++ )
{
for ( j = i; j > 0; j-- )
{
if ( table[j].org >= table[j - 1].org )
break;
swap = table[j];
table[j] = table[j - 1];
table[j - 1] = swap;
}
}
cur_idx = 0;
cur_val = table[cur_idx].org;
/* compute and use mean values for clusters not larger than */
/* `threshold'; this is very primitive and might not yield */
/* the best result, but normally, using reference character */
/* `o', `*count' is 2, so the code below is fully sufficient */
for ( i = 1; i < *count; i++ )
{
if ( table[i].org - cur_val > threshold ||
i == *count - 1 )
{
sum = 0;
/* fix loop for end of array */
if ( table[i].org - cur_val <= threshold &&
i == *count - 1 )
i++;
for ( j = cur_idx; j < i; j++ )
{
sum += table[j].org;
table[j].org = 0;
}
table[cur_idx].org = sum / (FT_Pos)j;
if ( i < *count - 1 )
{
cur_idx = i + 1;
cur_val = table[cur_idx].org;
}
}
}
cur_idx = 1;
/* compress array to remove zero values */
for ( i = 1; i < *count; i++ )
{
if ( table[i].org )
table[cur_idx++] = table[i];
}
*count = cur_idx;
}
/* Get new segment for given axis. */
FT_LOCAL_DEF( FT_Error )
af_axis_hints_new_segment( AF_AxisHints axis,
FT_Memory memory,
AF_Segment *asegment )
{
FT_Error error = FT_Err_Ok;
AF_Segment segment = NULL;
if ( axis->num_segments < AF_SEGMENTS_EMBEDDED )
{
if ( !axis->segments )
{
axis->segments = axis->embedded.segments;
axis->max_segments = AF_SEGMENTS_EMBEDDED;
}
}
else if ( axis->num_segments >= axis->max_segments )
{
FT_Int old_max = axis->max_segments;
FT_Int new_max = old_max;
FT_Int big_max = (FT_Int)( FT_INT_MAX / sizeof ( *segment ) );
if ( old_max >= big_max )
{
error = FT_THROW( Out_Of_Memory );
goto Exit;
}
new_max += ( new_max >> 2 ) + 4;
if ( new_max < old_max || new_max > big_max )
new_max = big_max;
if ( axis->segments == axis->embedded.segments )
{
if ( FT_NEW_ARRAY( axis->segments, new_max ) )
goto Exit;
ft_memcpy( axis->segments, axis->embedded.segments,
sizeof ( axis->embedded.segments ) );
}
else
{
if ( FT_RENEW_ARRAY( axis->segments, old_max, new_max ) )
goto Exit;
}
axis->max_segments = new_max;
}
segment = axis->segments + axis->num_segments++;
Exit:
*asegment = segment;
return error;
}
/* Get new edge for given axis, direction, and position, */
/* without initializing the edge itself. */
FT_LOCAL( FT_Error )
af_axis_hints_new_edge( AF_AxisHints axis,
FT_Int fpos,
AF_Direction dir,
FT_Bool top_to_bottom_hinting,
FT_Memory memory,
AF_Edge *anedge )
{
FT_Error error = FT_Err_Ok;
AF_Edge edge = NULL;
AF_Edge edges;
if ( axis->num_edges < AF_EDGES_EMBEDDED )
{
if ( !axis->edges )
{
axis->edges = axis->embedded.edges;
axis->max_edges = AF_EDGES_EMBEDDED;
}
}
else if ( axis->num_edges >= axis->max_edges )
{
FT_Int old_max = axis->max_edges;
FT_Int new_max = old_max;
FT_Int big_max = (FT_Int)( FT_INT_MAX / sizeof ( *edge ) );
if ( old_max >= big_max )
{
error = FT_THROW( Out_Of_Memory );
goto Exit;
}
new_max += ( new_max >> 2 ) + 4;
if ( new_max < old_max || new_max > big_max )
new_max = big_max;
if ( axis->edges == axis->embedded.edges )
{
if ( FT_NEW_ARRAY( axis->edges, new_max ) )
goto Exit;
ft_memcpy( axis->edges, axis->embedded.edges,
sizeof ( axis->embedded.edges ) );
}
else
{
if ( FT_RENEW_ARRAY( axis->edges, old_max, new_max ) )
goto Exit;
}
axis->max_edges = new_max;
}
edges = axis->edges;
edge = edges + axis->num_edges;
while ( edge > edges )
{
if ( top_to_bottom_hinting ? ( edge[-1].fpos > fpos )
: ( edge[-1].fpos < fpos ) )
break;
/* we want the edge with same position and minor direction */
/* to appear before those in the major one in the list */
if ( edge[-1].fpos == fpos && dir == axis->major_dir )
break;
edge[0] = edge[-1];
edge--;
}
axis->num_edges++;
Exit:
*anedge = edge;
return error;
}
#ifdef FT_DEBUG_AUTOFIT
#include FT_CONFIG_STANDARD_LIBRARY_H
/* The dump functions are used in the `ftgrid' demo program, too. */
#define AF_DUMP( varformat ) \
do \
{ \
if ( to_stdout ) \
printf varformat; \
else \
FT_TRACE7( varformat ); \
} while ( 0 )
static const char*
af_dir_str( AF_Direction dir )
{
const char* result;
switch ( dir )
{
case AF_DIR_UP:
result = "up";
break;
case AF_DIR_DOWN:
result = "down";
break;
case AF_DIR_LEFT:
result = "left";
break;
case AF_DIR_RIGHT:
result = "right";
break;
default:
result = "none";
}
return result;
}
#define AF_INDEX_NUM( ptr, base ) (int)( (ptr) ? ( (ptr) - (base) ) : -1 )
static char*
af_print_idx( char* p,
int idx )
{
if ( idx == -1 )
{
p[0] = '-';
p[1] = '-';
p[2] = '\0';
}
else
ft_sprintf( p, "%d", idx );
return p;
}
static int
af_get_segment_index( AF_GlyphHints hints,
int point_idx,
int dimension )
{
AF_AxisHints axis = &hints->axis[dimension];
AF_Point point = hints->points + point_idx;
AF_Segment segments = axis->segments;
AF_Segment limit = segments + axis->num_segments;
AF_Segment segment;
for ( segment = segments; segment < limit; segment++ )
{
if ( segment->first <= segment->last )
{
if ( point >= segment->first && point <= segment->last )
break;
}
else
{
AF_Point p = segment->first;
for (;;)
{
if ( point == p )
goto Exit;
if ( p == segment->last )
break;
p = p->next;
}
}
}
Exit:
if ( segment == limit )
return -1;
return (int)( segment - segments );
}
static int
af_get_edge_index( AF_GlyphHints hints,
int segment_idx,
int dimension )
{
AF_AxisHints axis = &hints->axis[dimension];
AF_Edge edges = axis->edges;
AF_Segment segment = axis->segments + segment_idx;
return segment_idx == -1 ? -1 : AF_INDEX_NUM( segment->edge, edges );
}
static int
af_get_strong_edge_index( AF_GlyphHints hints,
AF_Edge* strong_edges,
int dimension )
{
AF_AxisHints axis = &hints->axis[dimension];
AF_Edge edges = axis->edges;
return AF_INDEX_NUM( strong_edges[dimension], edges );
}
#ifdef __cplusplus
extern "C" {
#endif
void
af_glyph_hints_dump_points( AF_GlyphHints hints,
FT_Bool to_stdout )
{
AF_Point points = hints->points;
AF_Point limit = points + hints->num_points;
AF_Point* contour = hints->contours;
AF_Point* climit = contour + hints->num_contours;
AF_Point point;
AF_DUMP(( "Table of points:\n" ));
if ( hints->num_points )
{
AF_DUMP(( " index hedge hseg vedge vseg flags "
/* " XXXXX XXXXX XXXXX XXXXX XXXXX XXXXXX" */
" xorg yorg xscale yscale xfit yfit "
/* " XXXXX XXXXX XXXX.XX XXXX.XX XXXX.XX XXXX.XX" */
" hbef haft vbef vaft" ));
/* " XXXXX XXXXX XXXXX XXXXX" */
}
else
AF_DUMP(( " (none)\n" ));
for ( point = points; point < limit; point++ )
{
int point_idx = AF_INDEX_NUM( point, points );
int segment_idx_0 = af_get_segment_index( hints, point_idx, 0 );
int segment_idx_1 = af_get_segment_index( hints, point_idx, 1 );
char buf1[16], buf2[16], buf3[16], buf4[16];
char buf5[16], buf6[16], buf7[16], buf8[16];
/* insert extra newline at the beginning of a contour */
if ( contour < climit && *contour == point )
{
AF_DUMP(( "\n" ));
contour++;
}
AF_DUMP(( " %5d %5s %5s %5s %5s %s"
" %5d %5d %7.2f %7.2f %7.2f %7.2f"
" %5s %5s %5s %5s\n",
point_idx,
af_print_idx( buf1,
af_get_edge_index( hints, segment_idx_1, 1 ) ),
af_print_idx( buf2, segment_idx_1 ),
af_print_idx( buf3,
af_get_edge_index( hints, segment_idx_0, 0 ) ),
af_print_idx( buf4, segment_idx_0 ),
( point->flags & AF_FLAG_NEAR )
? " near "
: ( point->flags & AF_FLAG_WEAK_INTERPOLATION )
? " weak "
: "strong",
point->fx,
point->fy,
point->ox / 64.0,
point->oy / 64.0,
point->x / 64.0,
point->y / 64.0,
af_print_idx( buf5, af_get_strong_edge_index( hints,
point->before,
1 ) ),
af_print_idx( buf6, af_get_strong_edge_index( hints,
point->after,
1 ) ),
af_print_idx( buf7, af_get_strong_edge_index( hints,
point->before,
0 ) ),
af_print_idx( buf8, af_get_strong_edge_index( hints,
point->after,
0 ) ) ));
}
AF_DUMP(( "\n" ));
}
#ifdef __cplusplus
}
#endif
static const char*
af_edge_flags_to_string( FT_UInt flags )
{
static char temp[32];
int pos = 0;
if ( flags & AF_EDGE_ROUND )
{
ft_memcpy( temp + pos, "round", 5 );
pos += 5;
}
if ( flags & AF_EDGE_SERIF )
{
if ( pos > 0 )
temp[pos++] = ' ';
ft_memcpy( temp + pos, "serif", 5 );
pos += 5;
}
if ( pos == 0 )
return "normal";
temp[pos] = '\0';
return temp;
}
/* Dump the array of linked segments. */
#ifdef __cplusplus
extern "C" {
#endif
void
af_glyph_hints_dump_segments( AF_GlyphHints hints,
FT_Bool to_stdout )
{
FT_Int dimension;
for ( dimension = 1; dimension >= 0; dimension-- )
{
AF_AxisHints axis = &hints->axis[dimension];
AF_Point points = hints->points;
AF_Edge edges = axis->edges;
AF_Segment segments = axis->segments;
AF_Segment limit = segments + axis->num_segments;
AF_Segment seg;
char buf1[16], buf2[16], buf3[16];
AF_DUMP(( "Table of %s segments:\n",
dimension == AF_DIMENSION_HORZ ? "vertical"
: "horizontal" ));
if ( axis->num_segments )
{
AF_DUMP(( " index pos delta dir from to "
/* " XXXXX XXXXX XXXXX XXXXX XXXX XXXX" */
" link serif edge"
/* " XXXX XXXXX XXXX" */
" height extra flags\n" ));
/* " XXXXXX XXXXX XXXXXXXXXXX" */
}
else
AF_DUMP(( " (none)\n" ));
for ( seg = segments; seg < limit; seg++ )
AF_DUMP(( " %5d %5d %5d %5s %4d %4d"
" %4s %5s %4s"
" %6d %5d %11s\n",
AF_INDEX_NUM( seg, segments ),
seg->pos,
seg->delta,
af_dir_str( (AF_Direction)seg->dir ),
AF_INDEX_NUM( seg->first, points ),
AF_INDEX_NUM( seg->last, points ),
af_print_idx( buf1, AF_INDEX_NUM( seg->link, segments ) ),
af_print_idx( buf2, AF_INDEX_NUM( seg->serif, segments ) ),
af_print_idx( buf3, AF_INDEX_NUM( seg->edge, edges ) ),
seg->height,
seg->height - ( seg->max_coord - seg->min_coord ),
af_edge_flags_to_string( seg->flags ) ));
AF_DUMP(( "\n" ));
}
}
#ifdef __cplusplus
}
#endif
/* Fetch number of segments. */
#ifdef __cplusplus
extern "C" {
#endif
FT_Error
af_glyph_hints_get_num_segments( AF_GlyphHints hints,
FT_Int dimension,
FT_Int* num_segments )
{
AF_Dimension dim;
AF_AxisHints axis;
dim = ( dimension == 0 ) ? AF_DIMENSION_HORZ : AF_DIMENSION_VERT;
axis = &hints->axis[dim];
*num_segments = axis->num_segments;
return FT_Err_Ok;
}
#ifdef __cplusplus
}
#endif
/* Fetch offset of segments into user supplied offset array. */
#ifdef __cplusplus
extern "C" {
#endif
FT_Error
af_glyph_hints_get_segment_offset( AF_GlyphHints hints,
FT_Int dimension,
FT_Int idx,
FT_Pos *offset,
FT_Bool *is_blue,
FT_Pos *blue_offset )
{
AF_Dimension dim;
AF_AxisHints axis;
AF_Segment seg;
if ( !offset )
return FT_THROW( Invalid_Argument );
dim = ( dimension == 0 ) ? AF_DIMENSION_HORZ : AF_DIMENSION_VERT;
axis = &hints->axis[dim];
if ( idx < 0 || idx >= axis->num_segments )
return FT_THROW( Invalid_Argument );
seg = &axis->segments[idx];
*offset = ( dim == AF_DIMENSION_HORZ ) ? seg->first->fx
: seg->first->fy;
if ( seg->edge )
*is_blue = FT_BOOL( seg->edge->blue_edge );
else
*is_blue = FALSE;
if ( *is_blue )
*blue_offset = seg->edge->blue_edge->org;
else
*blue_offset = 0;
return FT_Err_Ok;
}
#ifdef __cplusplus
}
#endif
/* Dump the array of linked edges. */
#ifdef __cplusplus
extern "C" {
#endif
void
af_glyph_hints_dump_edges( AF_GlyphHints hints,
FT_Bool to_stdout )
{
FT_Int dimension;
for ( dimension = 1; dimension >= 0; dimension-- )
{
AF_AxisHints axis = &hints->axis[dimension];
AF_Edge edges = axis->edges;
AF_Edge limit = edges + axis->num_edges;
AF_Edge edge;
char buf1[16], buf2[16];
/*
* note: AF_DIMENSION_HORZ corresponds to _vertical_ edges
* since they have a constant X coordinate.
*/
if ( dimension == AF_DIMENSION_HORZ )
AF_DUMP(( "Table of %s edges (1px=%.2fu, 10u=%.2fpx):\n",
"vertical",
65536.0 * 64.0 / hints->x_scale,
10.0 * hints->x_scale / 65536.0 / 64.0 ));
else
AF_DUMP(( "Table of %s edges (1px=%.2fu, 10u=%.2fpx):\n",
"horizontal",
65536.0 * 64.0 / hints->y_scale,
10.0 * hints->y_scale / 65536.0 / 64.0 ));
if ( axis->num_edges )
{
AF_DUMP(( " index pos dir link serif"
/* " XXXXX XXXX.XX XXXXX XXXX XXXXX" */
" blue opos pos flags\n" ));
/* " X XXXX.XX XXXX.XX XXXXXXXXXXX" */
}
else
AF_DUMP(( " (none)\n" ));
for ( edge = edges; edge < limit; edge++ )
AF_DUMP(( " %5d %7.2f %5s %4s %5s"
" %c %7.2f %7.2f %11s\n",
AF_INDEX_NUM( edge, edges ),
(int)edge->opos / 64.0,
af_dir_str( (AF_Direction)edge->dir ),
af_print_idx( buf1, AF_INDEX_NUM( edge->link, edges ) ),
af_print_idx( buf2, AF_INDEX_NUM( edge->serif, edges ) ),
edge->blue_edge ? 'y' : 'n',
edge->opos / 64.0,
edge->pos / 64.0,
af_edge_flags_to_string( edge->flags ) ));
AF_DUMP(( "\n" ));
}
}
#ifdef __cplusplus
}
#endif
#undef AF_DUMP
#endif /* !FT_DEBUG_AUTOFIT */
/* Compute the direction value of a given vector. */
FT_LOCAL_DEF( AF_Direction )
af_direction_compute( FT_Pos dx,
FT_Pos dy )
{
FT_Pos ll, ss; /* long and short arm lengths */
AF_Direction dir; /* candidate direction */
if ( dy >= dx )
{
if ( dy >= -dx )
{
dir = AF_DIR_UP;
ll = dy;
ss = dx;
}
else
{
dir = AF_DIR_LEFT;
ll = -dx;
ss = dy;
}
}
else /* dy < dx */
{
if ( dy >= -dx )
{
dir = AF_DIR_RIGHT;
ll = dx;
ss = dy;
}
else
{
dir = AF_DIR_DOWN;
ll = -dy;
ss = dx;
}
}
/* return no direction if arm lengths do not differ enough */
/* (value 14 is heuristic, corresponding to approx. 4.1 degrees) */
/* the long arm is never negative */
if ( ll <= 14 * FT_ABS( ss ) )
dir = AF_DIR_NONE;
return dir;
}
FT_LOCAL_DEF( void )
af_glyph_hints_init( AF_GlyphHints hints,
FT_Memory memory )
{
/* no need to initialize the embedded items */
FT_MEM_ZERO( hints, sizeof ( *hints ) - sizeof ( hints->embedded ) );
hints->memory = memory;
}
FT_LOCAL_DEF( void )
af_glyph_hints_done( AF_GlyphHints hints )
{
FT_Memory memory;
int dim;
if ( !( hints && hints->memory ) )
return;
memory = hints->memory;
/*
* note that we don't need to free the segment and edge
* buffers since they are really within the hints->points array
*/
for ( dim = 0; dim < AF_DIMENSION_MAX; dim++ )
{
AF_AxisHints axis = &hints->axis[dim];
axis->num_segments = 0;
axis->max_segments = 0;
if ( axis->segments != axis->embedded.segments )
FT_FREE( axis->segments );
axis->num_edges = 0;
axis->max_edges = 0;
if ( axis->edges != axis->embedded.edges )
FT_FREE( axis->edges );
}
if ( hints->contours != hints->embedded.contours )
FT_FREE( hints->contours );
hints->max_contours = 0;
hints->num_contours = 0;
if ( hints->points != hints->embedded.points )
FT_FREE( hints->points );
hints->max_points = 0;
hints->num_points = 0;
hints->memory = NULL;
}
/* Reset metrics. */
FT_LOCAL_DEF( void )
af_glyph_hints_rescale( AF_GlyphHints hints,
AF_StyleMetrics metrics )
{
hints->metrics = metrics;
hints->scaler_flags = metrics->scaler.flags;
}
/* Recompute all AF_Point in AF_GlyphHints from the definitions */
/* in a source outline. */
FT_LOCAL_DEF( FT_Error )
af_glyph_hints_reload( AF_GlyphHints hints,
FT_Outline* outline )
{
FT_Error error = FT_Err_Ok;
AF_Point points;
FT_Int old_max, new_max;
FT_Fixed x_scale = hints->x_scale;
FT_Fixed y_scale = hints->y_scale;
FT_Pos x_delta = hints->x_delta;
FT_Pos y_delta = hints->y_delta;
FT_Memory memory = hints->memory;
hints->num_points = 0;
hints->num_contours = 0;
hints->axis[0].num_segments = 0;
hints->axis[0].num_edges = 0;
hints->axis[1].num_segments = 0;
hints->axis[1].num_edges = 0;
/* first of all, reallocate the contours array if necessary */
new_max = outline->n_contours;
old_max = hints->max_contours;
if ( new_max <= AF_CONTOURS_EMBEDDED )
{
if ( !hints->contours )
{
hints->contours = hints->embedded.contours;
hints->max_contours = AF_CONTOURS_EMBEDDED;
}
}
else if ( new_max > old_max )
{
if ( hints->contours == hints->embedded.contours )
hints->contours = NULL;
new_max = ( new_max + 3 ) & ~3; /* round up to a multiple of 4 */
if ( FT_RENEW_ARRAY( hints->contours, old_max, new_max ) )
goto Exit;
hints->max_contours = new_max;
}
/*
* then reallocate the points arrays if necessary --
* note that we reserve two additional point positions, used to
* hint metrics appropriately
*/
new_max = outline->n_points + 2;
old_max = hints->max_points;
if ( new_max <= AF_POINTS_EMBEDDED )
{
if ( !hints->points )
{
hints->points = hints->embedded.points;
hints->max_points = AF_POINTS_EMBEDDED;
}
}
else if ( new_max > old_max )
{
if ( hints->points == hints->embedded.points )
hints->points = NULL;
new_max = ( new_max + 2 + 7 ) & ~7; /* round up to a multiple of 8 */
if ( FT_RENEW_ARRAY( hints->points, old_max, new_max ) )
goto Exit;
hints->max_points = new_max;
}
hints->num_points = outline->n_points;
hints->num_contours = outline->n_contours;
/* We can't rely on the value of `FT_Outline.flags' to know the fill */
/* direction used for a glyph, given that some fonts are broken (e.g., */
/* the Arphic ones). We thus recompute it each time we need to. */
/* */
hints->axis[AF_DIMENSION_HORZ].major_dir = AF_DIR_UP;
hints->axis[AF_DIMENSION_VERT].major_dir = AF_DIR_LEFT;
if ( FT_Outline_Get_Orientation( outline ) == FT_ORIENTATION_POSTSCRIPT )
{
hints->axis[AF_DIMENSION_HORZ].major_dir = AF_DIR_DOWN;
hints->axis[AF_DIMENSION_VERT].major_dir = AF_DIR_RIGHT;
}
hints->x_scale = x_scale;
hints->y_scale = y_scale;
hints->x_delta = x_delta;
hints->y_delta = y_delta;
points = hints->points;
if ( hints->num_points == 0 )
goto Exit;
{
AF_Point point;
AF_Point point_limit = points + hints->num_points;
/* value 20 in `near_limit' is heuristic */
FT_UInt units_per_em = hints->metrics->scaler.face->units_per_EM;
FT_Int near_limit = 20 * units_per_em / 2048;
/* compute coordinates & Bezier flags, next and prev */
{
FT_Vector* vec = outline->points;
char* tag = outline->tags;
FT_Short endpoint = outline->contours[0];
AF_Point end = points + endpoint;
AF_Point prev = end;
FT_Int contour_index = 0;
for ( point = points; point < point_limit; point++, vec++, tag++ )
{
FT_Pos out_x, out_y;
point->in_dir = (FT_Char)AF_DIR_NONE;
point->out_dir = (FT_Char)AF_DIR_NONE;
point->fx = (FT_Short)vec->x;
point->fy = (FT_Short)vec->y;
point->ox = point->x = FT_MulFix( vec->x, x_scale ) + x_delta;
point->oy = point->y = FT_MulFix( vec->y, y_scale ) + y_delta;
end->fx = (FT_Short)outline->points[endpoint].x;
end->fy = (FT_Short)outline->points[endpoint].y;
switch ( FT_CURVE_TAG( *tag ) )
{
case FT_CURVE_TAG_CONIC:
point->flags = AF_FLAG_CONIC;
break;
case FT_CURVE_TAG_CUBIC:
point->flags = AF_FLAG_CUBIC;
break;
default:
point->flags = AF_FLAG_NONE;
}
out_x = point->fx - prev->fx;
out_y = point->fy - prev->fy;
if ( FT_ABS( out_x ) + FT_ABS( out_y ) < near_limit )
prev->flags |= AF_FLAG_NEAR;
point->prev = prev;
prev->next = point;
prev = point;
if ( point == end )
{
if ( ++contour_index < outline->n_contours )
{
endpoint = outline->contours[contour_index];
end = points + endpoint;
prev = end;
}
}
#ifdef FT_DEBUG_AUTOFIT
point->before[0] = NULL;
point->before[1] = NULL;
point->after[0] = NULL;
point->after[1] = NULL;
#endif
}
}
/* set up the contours array */
{
AF_Point* contour = hints->contours;
AF_Point* contour_limit = contour + hints->num_contours;
short* end = outline->contours;
short idx = 0;
for ( ; contour < contour_limit; contour++, end++ )
{
contour[0] = points + idx;
idx = (short)( end[0] + 1 );
}
}
{
/*
* Compute directions of `in' and `out' vectors.
*
* Note that distances between points that are very near to each
* other are accumulated. In other words, the auto-hinter either
* prepends the small vectors between near points to the first
* non-near vector, or the sum of small vector lengths exceeds a
* threshold, thus `grouping' the small vectors. All intermediate
* points are tagged as weak; the directions are adjusted also to
* be equal to the accumulated one.
*/
FT_Int near_limit2 = 2 * near_limit - 1;
AF_Point* contour;
AF_Point* contour_limit = hints->contours + hints->num_contours;
for ( contour = hints->contours; contour < contour_limit; contour++ )
{
AF_Point first = *contour;
AF_Point next, prev, curr;
FT_Pos out_x, out_y;
/* since the first point of a contour could be part of a */
/* series of near points, go backwards to find the first */
/* non-near point and adjust `first' */
point = first;
prev = first->prev;
while ( prev != first )
{
out_x = point->fx - prev->fx;
out_y = point->fy - prev->fy;
/*
* We use Taxicab metrics to measure the vector length.
*
* Note that the accumulated distances so far could have the
* opposite direction of the distance measured here. For this
* reason we use `near_limit2' for the comparison to get a
* non-near point even in the worst case.
*/
if ( FT_ABS( out_x ) + FT_ABS( out_y ) >= near_limit2 )
break;
point = prev;
prev = prev->prev;
}
/* adjust first point */
first = point;
/* now loop over all points of the contour to get */
/* `in' and `out' vector directions */
curr = first;
/*
* We abuse the `u' and `v' fields to store index deltas to the
* next and previous non-near point, respectively.
*
* To avoid problems with not having non-near points, we point to
* `first' by default as the next non-near point.
*
*/
curr->u = (FT_Pos)( first - curr );
first->v = -curr->u;
out_x = 0;
out_y = 0;
next = first;
do
{
AF_Direction out_dir;
point = next;
next = point->next;
out_x += next->fx - point->fx;
out_y += next->fy - point->fy;
if ( FT_ABS( out_x ) + FT_ABS( out_y ) < near_limit )
{
next->flags |= AF_FLAG_WEAK_INTERPOLATION;
continue;
}
curr->u = (FT_Pos)( next - curr );
next->v = -curr->u;
out_dir = af_direction_compute( out_x, out_y );
/* adjust directions for all points inbetween; */
/* the loop also updates position of `curr' */
curr->out_dir = (FT_Char)out_dir;
for ( curr = curr->next; curr != next; curr = curr->next )
{
curr->in_dir = (FT_Char)out_dir;
curr->out_dir = (FT_Char)out_dir;
}
next->in_dir = (FT_Char)out_dir;
curr->u = (FT_Pos)( first - curr );
first->v = -curr->u;
out_x = 0;
out_y = 0;
} while ( next != first );
}
/*
* The next step is to `simplify' an outline's topology so that we
* can identify local extrema more reliably: A series of
* non-horizontal or non-vertical vectors pointing into the same
* quadrant are handled as a single, long vector. From a
* topological point of the view, the intermediate points are of no
* interest and thus tagged as weak.
*/
for ( point = points; point < point_limit; point++ )
{
if ( point->flags & AF_FLAG_WEAK_INTERPOLATION )
continue;
if ( point->in_dir == AF_DIR_NONE &&
point->out_dir == AF_DIR_NONE )
{
/* check whether both vectors point into the same quadrant */
FT_Pos in_x, in_y;
FT_Pos out_x, out_y;
AF_Point next_u = point + point->u;
AF_Point prev_v = point + point->v;
in_x = point->fx - prev_v->fx;
in_y = point->fy - prev_v->fy;
out_x = next_u->fx - point->fx;
out_y = next_u->fy - point->fy;
if ( ( in_x ^ out_x ) >= 0 && ( in_y ^ out_y ) >= 0 )
{
/* yes, so tag current point as weak */
/* and update index deltas */
point->flags |= AF_FLAG_WEAK_INTERPOLATION;
prev_v->u = (FT_Pos)( next_u - prev_v );
next_u->v = -prev_v->u;
}
}
}
/*
* Finally, check for remaining weak points. Everything else not
* collected in edges so far is then implicitly classified as strong
* points.
*/
for ( point = points; point < point_limit; point++ )
{
if ( point->flags & AF_FLAG_WEAK_INTERPOLATION )
continue;
if ( point->flags & AF_FLAG_CONTROL )
{
/* control points are always weak */
Is_Weak_Point:
point->flags |= AF_FLAG_WEAK_INTERPOLATION;
}
else if ( point->out_dir == point->in_dir )
{
if ( point->out_dir != AF_DIR_NONE )
{
/* current point lies on a horizontal or */
/* vertical segment (but doesn't start or end it) */
goto Is_Weak_Point;
}
{
AF_Point next_u = point + point->u;
AF_Point prev_v = point + point->v;
if ( ft_corner_is_flat( point->fx - prev_v->fx,
point->fy - prev_v->fy,
next_u->fx - point->fx,
next_u->fy - point->fy ) )
{
/* either the `in' or the `out' vector is much more */
/* dominant than the other one, so tag current point */
/* as weak and update index deltas */
prev_v->u = (FT_Pos)( next_u - prev_v );
next_u->v = -prev_v->u;
goto Is_Weak_Point;
}
}
}
else if ( point->in_dir == -point->out_dir )
{
/* current point forms a spike */
goto Is_Weak_Point;
}
}
}
}
Exit:
return error;
}
/* Store the hinted outline in an FT_Outline structure. */
FT_LOCAL_DEF( void )
af_glyph_hints_save( AF_GlyphHints hints,
FT_Outline* outline )
{
AF_Point point = hints->points;
AF_Point limit = point + hints->num_points;
FT_Vector* vec = outline->points;
char* tag = outline->tags;
for ( ; point < limit; point++, vec++, tag++ )
{
vec->x = point->x;
vec->y = point->y;
if ( point->flags & AF_FLAG_CONIC )
tag[0] = FT_CURVE_TAG_CONIC;
else if ( point->flags & AF_FLAG_CUBIC )
tag[0] = FT_CURVE_TAG_CUBIC;
else
tag[0] = FT_CURVE_TAG_ON;
}
}
/****************************************************************
*
* EDGE POINT GRID-FITTING
*
****************************************************************/
/* Align all points of an edge to the same coordinate value, */
/* either horizontally or vertically. */
FT_LOCAL_DEF( void )
af_glyph_hints_align_edge_points( AF_GlyphHints hints,
AF_Dimension dim )
{
AF_AxisHints axis = & hints->axis[dim];
AF_Segment segments = axis->segments;
AF_Segment segment_limit = FT_OFFSET( segments, axis->num_segments );
AF_Segment seg;
if ( dim == AF_DIMENSION_HORZ )
{
for ( seg = segments; seg < segment_limit; seg++ )
{
AF_Edge edge = seg->edge;
AF_Point point, first, last;
if ( !edge )
continue;
first = seg->first;
last = seg->last;
point = first;
for (;;)
{
point->x = edge->pos;
point->flags |= AF_FLAG_TOUCH_X;
if ( point == last )
break;
point = point->next;
}
}
}
else
{
for ( seg = segments; seg < segment_limit; seg++ )
{
AF_Edge edge = seg->edge;
AF_Point point, first, last;
if ( !edge )
continue;
first = seg->first;
last = seg->last;
point = first;
for (;;)
{
point->y = edge->pos;
point->flags |= AF_FLAG_TOUCH_Y;
if ( point == last )
break;
point = point->next;
}
}
}
}
/****************************************************************
*
* STRONG POINT INTERPOLATION
*
****************************************************************/
/* Hint the strong points -- this is equivalent to the TrueType `IP' */
/* hinting instruction. */
FT_LOCAL_DEF( void )
af_glyph_hints_align_strong_points( AF_GlyphHints hints,
AF_Dimension dim )
{
AF_Point points = hints->points;
AF_Point point_limit = points + hints->num_points;
AF_AxisHints axis = &hints->axis[dim];
AF_Edge edges = axis->edges;
AF_Edge edge_limit = FT_OFFSET( edges, axis->num_edges );
FT_UInt touch_flag;
if ( dim == AF_DIMENSION_HORZ )
touch_flag = AF_FLAG_TOUCH_X;
else
touch_flag = AF_FLAG_TOUCH_Y;
if ( edges < edge_limit )
{
AF_Point point;
AF_Edge edge;
for ( point = points; point < point_limit; point++ )
{
FT_Pos u, ou, fu; /* point position */
FT_Pos delta;
if ( point->flags & touch_flag )
continue;
/* if this point is candidate to weak interpolation, we */
/* interpolate it after all strong points have been processed */
if ( ( point->flags & AF_FLAG_WEAK_INTERPOLATION ) )
continue;
if ( dim == AF_DIMENSION_VERT )
{
u = point->fy;
ou = point->oy;
}
else
{
u = point->fx;
ou = point->ox;
}
fu = u;
/* is the point before the first edge? */
edge = edges;
delta = edge->fpos - u;
if ( delta >= 0 )
{
u = edge->pos - ( edge->opos - ou );
#ifdef FT_DEBUG_AUTOFIT
point->before[dim] = edge;
point->after[dim] = NULL;
#endif
goto Store_Point;
}
/* is the point after the last edge? */
edge = edge_limit - 1;
delta = u - edge->fpos;
if ( delta >= 0 )
{
u = edge->pos + ( ou - edge->opos );
#ifdef FT_DEBUG_AUTOFIT
point->before[dim] = NULL;
point->after[dim] = edge;
#endif
goto Store_Point;
}
{
FT_PtrDist min, max, mid;
FT_Pos fpos;
/* find enclosing edges */
min = 0;
max = edge_limit - edges;
#if 1
/* for a small number of edges, a linear search is better */
if ( max <= 8 )
{
FT_PtrDist nn;
for ( nn = 0; nn < max; nn++ )
if ( edges[nn].fpos >= u )
break;
if ( edges[nn].fpos == u )
{
u = edges[nn].pos;
goto Store_Point;
}
min = nn;
}
else
#endif
while ( min < max )
{
mid = ( max + min ) >> 1;
edge = edges + mid;
fpos = edge->fpos;
if ( u < fpos )
max = mid;
else if ( u > fpos )
min = mid + 1;
else
{
/* we are on the edge */
u = edge->pos;
#ifdef FT_DEBUG_AUTOFIT
point->before[dim] = NULL;
point->after[dim] = NULL;
#endif
goto Store_Point;
}
}
/* point is not on an edge */
{
AF_Edge before = edges + min - 1;
AF_Edge after = edges + min + 0;
#ifdef FT_DEBUG_AUTOFIT
point->before[dim] = before;
point->after[dim] = after;
#endif
/* assert( before && after && before != after ) */
if ( before->scale == 0 )
before->scale = FT_DivFix( after->pos - before->pos,
after->fpos - before->fpos );
u = before->pos + FT_MulFix( fu - before->fpos,
before->scale );
}
}
Store_Point:
/* save the point position */
if ( dim == AF_DIMENSION_HORZ )
point->x = u;
else
point->y = u;
point->flags |= touch_flag;
}
}
}
/****************************************************************
*
* WEAK POINT INTERPOLATION
*
****************************************************************/
/* Shift the original coordinates of all points between `p1' and */
/* `p2' to get hinted coordinates, using the same difference as */
/* given by `ref'. */
static void
af_iup_shift( AF_Point p1,
AF_Point p2,
AF_Point ref )
{
AF_Point p;
FT_Pos delta = ref->u - ref->v;
if ( delta == 0 )
return;
for ( p = p1; p < ref; p++ )
p->u = p->v + delta;
for ( p = ref + 1; p <= p2; p++ )
p->u = p->v + delta;
}
/* Interpolate the original coordinates of all points between `p1' and */
/* `p2' to get hinted coordinates, using `ref1' and `ref2' as the */
/* reference points. The `u' and `v' members are the current and */
/* original coordinate values, respectively. */
/* */
/* Details can be found in the TrueType bytecode specification. */
static void
af_iup_interp( AF_Point p1,
AF_Point p2,
AF_Point ref1,
AF_Point ref2 )
{
AF_Point p;
FT_Pos u, v1, v2, u1, u2, d1, d2;
if ( p1 > p2 )
return;
if ( ref1->v > ref2->v )
{
p = ref1;
ref1 = ref2;
ref2 = p;
}
v1 = ref1->v;
v2 = ref2->v;
u1 = ref1->u;
u2 = ref2->u;
d1 = u1 - v1;
d2 = u2 - v2;
if ( u1 == u2 || v1 == v2 )
{
for ( p = p1; p <= p2; p++ )
{
u = p->v;
if ( u <= v1 )
u += d1;
else if ( u >= v2 )
u += d2;
else
u = u1;
p->u = u;
}
}
else
{
FT_Fixed scale = FT_DivFix( u2 - u1, v2 - v1 );
for ( p = p1; p <= p2; p++ )
{
u = p->v;
if ( u <= v1 )
u += d1;
else if ( u >= v2 )
u += d2;
else
u = u1 + FT_MulFix( u - v1, scale );
p->u = u;
}
}
}
/* Hint the weak points -- this is equivalent to the TrueType `IUP' */
/* hinting instruction. */
FT_LOCAL_DEF( void )
af_glyph_hints_align_weak_points( AF_GlyphHints hints,
AF_Dimension dim )
{
AF_Point points = hints->points;
AF_Point point_limit = points + hints->num_points;
AF_Point* contour = hints->contours;
AF_Point* contour_limit = contour + hints->num_contours;
FT_UInt touch_flag;
AF_Point point;
AF_Point end_point;
AF_Point first_point;
/* PASS 1: Move segment points to edge positions */
if ( dim == AF_DIMENSION_HORZ )
{
touch_flag = AF_FLAG_TOUCH_X;
for ( point = points; point < point_limit; point++ )
{
point->u = point->x;
point->v = point->ox;
}
}
else
{
touch_flag = AF_FLAG_TOUCH_Y;
for ( point = points; point < point_limit; point++ )
{
point->u = point->y;
point->v = point->oy;
}
}
for ( ; contour < contour_limit; contour++ )
{
AF_Point first_touched, last_touched;
point = *contour;
end_point = point->prev;
first_point = point;
/* find first touched point */
for (;;)
{
if ( point > end_point ) /* no touched point in contour */
goto NextContour;
if ( point->flags & touch_flag )
break;
point++;
}
first_touched = point;
for (;;)
{
FT_ASSERT( point <= end_point &&
( point->flags & touch_flag ) != 0 );
/* skip any touched neighbours */
while ( point < end_point &&
( point[1].flags & touch_flag ) != 0 )
point++;
last_touched = point;
/* find the next touched point, if any */
point++;
for (;;)
{
if ( point > end_point )
goto EndContour;
if ( ( point->flags & touch_flag ) != 0 )
break;
point++;
}
/* interpolate between last_touched and point */
af_iup_interp( last_touched + 1, point - 1,
last_touched, point );
}
EndContour:
/* special case: only one point was touched */
if ( last_touched == first_touched )
af_iup_shift( first_point, end_point, first_touched );
else /* interpolate the last part */
{
if ( last_touched < end_point )
af_iup_interp( last_touched + 1, end_point,
last_touched, first_touched );
if ( first_touched > points )
af_iup_interp( first_point, first_touched - 1,
last_touched, first_touched );
}
NextContour:
;
}
/* now save the interpolated values back to x/y */
if ( dim == AF_DIMENSION_HORZ )
{
for ( point = points; point < point_limit; point++ )
point->x = point->u;
}
else
{
for ( point = points; point < point_limit; point++ )
point->y = point->u;
}
}
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/autofit/afhints.c
|
C++
|
gpl-3.0
| 46,934
|
/****************************************************************************
*
* afhints.h
*
* Auto-fitter hinting routines (specification).
*
* Copyright (C) 2003-2022 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 AFHINTS_H_
#define AFHINTS_H_
#include "aftypes.h"
#define xxAF_SORT_SEGMENTS
FT_BEGIN_HEADER
/*
* The definition of outline glyph hints. These are shared by all
* writing system analysis routines (until now).
*/
typedef enum AF_Dimension_
{
AF_DIMENSION_HORZ = 0, /* x coordinates, */
/* i.e., vertical segments & edges */
AF_DIMENSION_VERT = 1, /* y coordinates, */
/* i.e., horizontal segments & edges */
AF_DIMENSION_MAX /* do not remove */
} AF_Dimension;
/* hint directions -- the values are computed so that two vectors are */
/* in opposite directions iff `dir1 + dir2 == 0' */
typedef enum AF_Direction_
{
AF_DIR_NONE = 4,
AF_DIR_RIGHT = 1,
AF_DIR_LEFT = -1,
AF_DIR_UP = 2,
AF_DIR_DOWN = -2
} AF_Direction;
/*
* The following explanations are mostly taken from the article
*
* Real-Time Grid Fitting of Typographic Outlines
*
* by David Turner and Werner Lemberg
*
* https://www.tug.org/TUGboat/Articles/tb24-3/lemberg.pdf
*
* with appropriate updates.
*
*
* Segments
*
* `af_{cjk,latin,...}_hints_compute_segments' are the functions to
* find segments in an outline.
*
* A segment is a series of at least two consecutive points that are
* approximately aligned along a coordinate axis. The analysis to do
* so is specific to a writing system.
*
*
* Edges
*
* `af_{cjk,latin,...}_hints_compute_edges' are the functions to find
* edges.
*
* As soon as segments are defined, the auto-hinter groups them into
* edges. An edge corresponds to a single position on the main
* dimension that collects one or more segments (allowing for a small
* threshold).
*
* As an example, the `latin' writing system first tries to grid-fit
* edges, then to align segments on the edges unless it detects that
* they form a serif.
*
*
* A H
* | |
* | |
* | |
* | |
* C | | F
* +------<-----+ +-----<------+
* | B G |
* | |
* | |
* +--------------->------------------+
* D E
*
*
* Stems
*
* Stems are detected by `af_{cjk,latin,...}_hint_edges'.
*
* Segments need to be `linked' to other ones in order to detect stems.
* A stem is made of two segments that face each other in opposite
* directions and that are sufficiently close to each other. Using
* vocabulary from the TrueType specification, stem segments form a
* `black distance'.
*
* In the above ASCII drawing, the horizontal segments are BC, DE, and
* FG; the vertical segments are AB, CD, EF, and GH.
*
* Each segment has at most one `best' candidate to form a black
* distance, or no candidate at all. Notice that two distinct segments
* can have the same candidate, which frequently means a serif.
*
* A stem is recognized by the following condition:
*
* best segment_1 = segment_2 && best segment_2 = segment_1
*
* The best candidate is stored in field `link' in structure
* `AF_Segment'.
*
* In the above ASCII drawing, the best candidate for both AB and CD is
* GH, while the best candidate for GH is AB. Similarly, the best
* candidate for EF and GH is AB, while the best candidate for AB is
* GH.
*
* The detection and handling of stems is dependent on the writing
* system.
*
*
* Serifs
*
* Serifs are detected by `af_{cjk,latin,...}_hint_edges'.
*
* In comparison to a stem, a serif (as handled by the auto-hinter
* module that takes care of the `latin' writing system) has
*
* best segment_1 = segment_2 && best segment_2 != segment_1
*
* where segment_1 corresponds to the serif segment (CD and EF in the
* above ASCII drawing).
*
* The best candidate is stored in field `serif' in structure
* `AF_Segment' (and `link' is set to NULL).
*
*
* Touched points
*
* A point is called `touched' if it has been processed somehow by the
* auto-hinter. It basically means that it shouldn't be moved again
* (or moved only under certain constraints to preserve the already
* applied processing).
*
*
* Flat and round segments
*
* Segments are `round' or `flat', depending on the series of points
* that define them. A segment is round if the next and previous point
* of an extremum (which can be either a single point or sequence of
* points) are both conic or cubic control points. Otherwise, a
* segment with an extremum is flat.
*
*
* Strong Points
*
* Experience has shown that points not part of an edge need to be
* interpolated linearly between their two closest edges, even if these
* are not part of the contour of those particular points. Typical
* candidates for this are
*
* - angle points (i.e., points where the `in' and `out' direction
* differ greatly)
*
* - inflection points (i.e., where the `in' and `out' angles are the
* same, but the curvature changes sign) [currently, such points
* aren't handled specially in the auto-hinter]
*
* `af_glyph_hints_align_strong_points' is the function that takes
* care of such situations; it is equivalent to the TrueType `IP'
* hinting instruction.
*
*
* Weak Points
*
* Other points in the outline must be interpolated using the
* coordinates of their previous and next unfitted contour neighbours.
* These are called `weak points' and are touched by the function
* `af_glyph_hints_align_weak_points', equivalent to the TrueType `IUP'
* hinting instruction. Typical candidates are control points and
* points on the contour without a major direction.
*
* The major effect is to reduce possible distortion caused by
* alignment of edges and strong points, thus weak points are processed
* after strong points.
*/
/* point hint flags */
#define AF_FLAG_NONE 0
/* point type flags */
#define AF_FLAG_CONIC ( 1U << 0 )
#define AF_FLAG_CUBIC ( 1U << 1 )
#define AF_FLAG_CONTROL ( AF_FLAG_CONIC | AF_FLAG_CUBIC )
/* point touch flags */
#define AF_FLAG_TOUCH_X ( 1U << 2 )
#define AF_FLAG_TOUCH_Y ( 1U << 3 )
/* candidates for weak interpolation have this flag set */
#define AF_FLAG_WEAK_INTERPOLATION ( 1U << 4 )
/* the distance to the next point is very small */
#define AF_FLAG_NEAR ( 1U << 5 )
/* edge hint flags */
#define AF_EDGE_NORMAL 0
#define AF_EDGE_ROUND ( 1U << 0 )
#define AF_EDGE_SERIF ( 1U << 1 )
#define AF_EDGE_DONE ( 1U << 2 )
#define AF_EDGE_NEUTRAL ( 1U << 3 ) /* edge aligns to a neutral blue zone */
typedef struct AF_PointRec_* AF_Point;
typedef struct AF_SegmentRec_* AF_Segment;
typedef struct AF_EdgeRec_* AF_Edge;
typedef struct AF_PointRec_
{
FT_UShort flags; /* point flags used by hinter */
FT_Char in_dir; /* direction of inwards vector */
FT_Char out_dir; /* direction of outwards vector */
FT_Pos ox, oy; /* original, scaled position */
FT_Short fx, fy; /* original, unscaled position (in font units) */
FT_Pos x, y; /* current position */
FT_Pos u, v; /* current (x,y) or (y,x) depending on context */
AF_Point next; /* next point in contour */
AF_Point prev; /* previous point in contour */
#ifdef FT_DEBUG_AUTOFIT
/* track `before' and `after' edges for strong points */
AF_Edge before[2];
AF_Edge after[2];
#endif
} AF_PointRec;
typedef struct AF_SegmentRec_
{
FT_Byte flags; /* edge/segment flags for this segment */
FT_Char dir; /* segment direction */
FT_Short pos; /* position of segment */
FT_Short delta; /* deviation from segment position */
FT_Short min_coord; /* minimum coordinate of segment */
FT_Short max_coord; /* maximum coordinate of segment */
FT_Short height; /* the hinted segment height */
AF_Edge edge; /* the segment's parent edge */
AF_Segment edge_next; /* link to next segment in parent edge */
AF_Segment link; /* (stem) link segment */
AF_Segment serif; /* primary segment for serifs */
FT_Pos score; /* used during stem matching */
FT_Pos len; /* used during stem matching */
AF_Point first; /* first point in edge segment */
AF_Point last; /* last point in edge segment */
} AF_SegmentRec;
typedef struct AF_EdgeRec_
{
FT_Short fpos; /* original, unscaled position (in font units) */
FT_Pos opos; /* original, scaled position */
FT_Pos pos; /* current position */
FT_Byte flags; /* edge flags */
FT_Char dir; /* edge direction */
FT_Fixed scale; /* used to speed up interpolation between edges */
AF_Width blue_edge; /* non-NULL if this is a blue edge */
AF_Edge link; /* link edge */
AF_Edge serif; /* primary edge for serifs */
FT_Int score; /* used during stem matching */
AF_Segment first; /* first segment in edge */
AF_Segment last; /* last segment in edge */
} AF_EdgeRec;
#define AF_SEGMENTS_EMBEDDED 18 /* number of embedded segments */
#define AF_EDGES_EMBEDDED 12 /* number of embedded edges */
typedef struct AF_AxisHintsRec_
{
FT_Int num_segments; /* number of used segments */
FT_Int max_segments; /* number of allocated segments */
AF_Segment segments; /* segments array */
#ifdef AF_SORT_SEGMENTS
FT_Int mid_segments;
#endif
FT_Int num_edges; /* number of used edges */
FT_Int max_edges; /* number of allocated edges */
AF_Edge edges; /* edges array */
AF_Direction major_dir; /* either vertical or horizontal */
/* two arrays to avoid allocation penalty */
struct
{
AF_SegmentRec segments[AF_SEGMENTS_EMBEDDED];
AF_EdgeRec edges[AF_EDGES_EMBEDDED];
} embedded;
} AF_AxisHintsRec, *AF_AxisHints;
#define AF_POINTS_EMBEDDED 96 /* number of embedded points */
#define AF_CONTOURS_EMBEDDED 8 /* number of embedded contours */
typedef struct AF_GlyphHintsRec_
{
FT_Memory memory;
FT_Fixed x_scale;
FT_Pos x_delta;
FT_Fixed y_scale;
FT_Pos y_delta;
FT_Int max_points; /* number of allocated points */
FT_Int num_points; /* number of used points */
AF_Point points; /* points array */
FT_Int max_contours; /* number of allocated contours */
FT_Int num_contours; /* number of used contours */
AF_Point* contours; /* contours array */
AF_AxisHintsRec axis[AF_DIMENSION_MAX];
FT_UInt32 scaler_flags; /* copy of scaler flags */
FT_UInt32 other_flags; /* free for style-specific */
/* implementations */
AF_StyleMetrics metrics;
/* Two arrays to avoid allocation penalty. */
/* The `embedded' structure must be the last element! */
struct
{
AF_Point contours[AF_CONTOURS_EMBEDDED];
AF_PointRec points[AF_POINTS_EMBEDDED];
} embedded;
} AF_GlyphHintsRec;
#define AF_HINTS_TEST_SCALER( h, f ) ( (h)->scaler_flags & (f) )
#define AF_HINTS_TEST_OTHER( h, f ) ( (h)->other_flags & (f) )
#ifdef FT_DEBUG_AUTOFIT
#define AF_HINTS_DO_HORIZONTAL( h ) \
( !_af_debug_disable_horz_hints && \
!AF_HINTS_TEST_SCALER( h, AF_SCALER_FLAG_NO_HORIZONTAL ) )
#define AF_HINTS_DO_VERTICAL( h ) \
( !_af_debug_disable_vert_hints && \
!AF_HINTS_TEST_SCALER( h, AF_SCALER_FLAG_NO_VERTICAL ) )
#define AF_HINTS_DO_BLUES( h ) ( !_af_debug_disable_blue_hints )
#else /* !FT_DEBUG_AUTOFIT */
#define AF_HINTS_DO_HORIZONTAL( h ) \
!AF_HINTS_TEST_SCALER( h, AF_SCALER_FLAG_NO_HORIZONTAL )
#define AF_HINTS_DO_VERTICAL( h ) \
!AF_HINTS_TEST_SCALER( h, AF_SCALER_FLAG_NO_VERTICAL )
#define AF_HINTS_DO_BLUES( h ) 1
#endif /* !FT_DEBUG_AUTOFIT */
#define AF_HINTS_DO_ADVANCE( h ) \
!AF_HINTS_TEST_SCALER( h, AF_SCALER_FLAG_NO_ADVANCE )
FT_LOCAL( AF_Direction )
af_direction_compute( FT_Pos dx,
FT_Pos dy );
FT_LOCAL( FT_Error )
af_axis_hints_new_segment( AF_AxisHints axis,
FT_Memory memory,
AF_Segment *asegment );
FT_LOCAL( FT_Error)
af_axis_hints_new_edge( AF_AxisHints axis,
FT_Int fpos,
AF_Direction dir,
FT_Bool top_to_bottom_hinting,
FT_Memory memory,
AF_Edge *edge );
FT_LOCAL( void )
af_glyph_hints_init( AF_GlyphHints hints,
FT_Memory memory );
FT_LOCAL( void )
af_glyph_hints_rescale( AF_GlyphHints hints,
AF_StyleMetrics metrics );
FT_LOCAL( FT_Error )
af_glyph_hints_reload( AF_GlyphHints hints,
FT_Outline* outline );
FT_LOCAL( void )
af_glyph_hints_save( AF_GlyphHints hints,
FT_Outline* outline );
FT_LOCAL( void )
af_glyph_hints_align_edge_points( AF_GlyphHints hints,
AF_Dimension dim );
FT_LOCAL( void )
af_glyph_hints_align_strong_points( AF_GlyphHints hints,
AF_Dimension dim );
FT_LOCAL( void )
af_glyph_hints_align_weak_points( AF_GlyphHints hints,
AF_Dimension dim );
FT_LOCAL( void )
af_glyph_hints_done( AF_GlyphHints hints );
/* */
#define AF_SEGMENT_LEN( seg ) ( (seg)->max_coord - (seg)->min_coord )
#define AF_SEGMENT_DIST( seg1, seg2 ) ( ( (seg1)->pos > (seg2)->pos ) \
? (seg1)->pos - (seg2)->pos \
: (seg2)->pos - (seg1)->pos )
FT_END_HEADER
#endif /* AFHINTS_H_ */
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/autofit/afhints.h
|
C++
|
gpl-3.0
| 16,039
|
/****************************************************************************
*
* afindic.c
*
* Auto-fitter hinting routines for Indic writing system (body).
*
* Copyright (C) 2007-2022 by
* Rahul Bhalerao <rahul.bhalerao@redhat.com>, <b.rahul.pm@gmail.com>.
*
* 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.
*
*/
#include "aftypes.h"
#include "aflatin.h"
#include "afcjk.h"
#ifdef AF_CONFIG_OPTION_INDIC
#include "afindic.h"
#include "aferrors.h"
static FT_Error
af_indic_metrics_init( AF_CJKMetrics metrics,
FT_Face face )
{
/* skip blue zone init in CJK routines */
FT_CharMap oldmap = face->charmap;
metrics->units_per_em = face->units_per_EM;
if ( FT_Select_Charmap( face, FT_ENCODING_UNICODE ) )
face->charmap = NULL;
else
{
af_cjk_metrics_init_widths( metrics, face );
#if 0
/* either need indic specific blue_chars[] or just skip blue zones */
af_cjk_metrics_init_blues( metrics, face, af_cjk_blue_chars );
#endif
af_cjk_metrics_check_digits( metrics, face );
}
FT_Set_Charmap( face, oldmap );
return FT_Err_Ok;
}
static void
af_indic_metrics_scale( AF_CJKMetrics metrics,
AF_Scaler scaler )
{
/* use CJK routines */
af_cjk_metrics_scale( metrics, scaler );
}
static FT_Error
af_indic_hints_init( AF_GlyphHints hints,
AF_CJKMetrics metrics )
{
/* use CJK routines */
return af_cjk_hints_init( hints, metrics );
}
static FT_Error
af_indic_hints_apply( FT_UInt glyph_index,
AF_GlyphHints hints,
FT_Outline* outline,
AF_CJKMetrics metrics )
{
/* use CJK routines */
return af_cjk_hints_apply( glyph_index, hints, outline, metrics );
}
/* Extract standard_width from writing system/script specific */
/* metrics class. */
static void
af_indic_get_standard_widths( AF_CJKMetrics metrics,
FT_Pos* stdHW,
FT_Pos* stdVW )
{
if ( stdHW )
*stdHW = metrics->axis[AF_DIMENSION_VERT].standard_width;
if ( stdVW )
*stdVW = metrics->axis[AF_DIMENSION_HORZ].standard_width;
}
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** I N D I C S C R I P T C L A S S *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
AF_DEFINE_WRITING_SYSTEM_CLASS(
af_indic_writing_system_class,
AF_WRITING_SYSTEM_INDIC,
sizeof ( AF_CJKMetricsRec ),
(AF_WritingSystem_InitMetricsFunc) af_indic_metrics_init, /* style_metrics_init */
(AF_WritingSystem_ScaleMetricsFunc)af_indic_metrics_scale, /* style_metrics_scale */
(AF_WritingSystem_DoneMetricsFunc) NULL, /* style_metrics_done */
(AF_WritingSystem_GetStdWidthsFunc)af_indic_get_standard_widths, /* style_metrics_getstdw */
(AF_WritingSystem_InitHintsFunc) af_indic_hints_init, /* style_hints_init */
(AF_WritingSystem_ApplyHintsFunc) af_indic_hints_apply /* style_hints_apply */
)
#else /* !AF_CONFIG_OPTION_INDIC */
AF_DEFINE_WRITING_SYSTEM_CLASS(
af_indic_writing_system_class,
AF_WRITING_SYSTEM_INDIC,
sizeof ( AF_CJKMetricsRec ),
(AF_WritingSystem_InitMetricsFunc) NULL, /* style_metrics_init */
(AF_WritingSystem_ScaleMetricsFunc)NULL, /* style_metrics_scale */
(AF_WritingSystem_DoneMetricsFunc) NULL, /* style_metrics_done */
(AF_WritingSystem_GetStdWidthsFunc)NULL, /* style_metrics_getstdw */
(AF_WritingSystem_InitHintsFunc) NULL, /* style_hints_init */
(AF_WritingSystem_ApplyHintsFunc) NULL /* style_hints_apply */
)
#endif /* !AF_CONFIG_OPTION_INDIC */
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/autofit/afindic.c
|
C++
|
gpl-3.0
| 4,548
|
/****************************************************************************
*
* afindic.h
*
* Auto-fitter hinting routines for Indic writing system
* (specification).
*
* Copyright (C) 2007-2022 by
* Rahul Bhalerao <rahul.bhalerao@redhat.com>, <b.rahul.pm@gmail.com>.
*
* 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 AFINDIC_H_
#define AFINDIC_H_
#include "afhints.h"
FT_BEGIN_HEADER
/* the `indic' writing system */
AF_DECLARE_WRITING_SYSTEM_CLASS( af_indic_writing_system_class )
/* */
FT_END_HEADER
#endif /* AFINDIC_H_ */
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/autofit/afindic.h
|
C++
|
gpl-3.0
| 840
|
/****************************************************************************
*
* aflatin.c
*
* Auto-fitter hinting routines for latin writing system (body).
*
* Copyright (C) 2003-2022 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.
*
*/
#include <freetype/ftadvanc.h>
#include <freetype/internal/ftdebug.h>
#include "afglobal.h"
#include "aflatin.h"
#include "aferrors.h"
/**************************************************************************
*
* The macro FT_COMPONENT is used in trace mode. It is an implicit
* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
* messages during execution.
*/
#undef FT_COMPONENT
#define FT_COMPONENT aflatin
/* needed for computation of round vs. flat segments */
#define FLAT_THRESHOLD( x ) ( x / 14 )
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** L A T I N G L O B A L M E T R I C S *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
/* Find segments and links, compute all stem widths, and initialize */
/* standard width and height for the glyph with given charcode. */
FT_LOCAL_DEF( void )
af_latin_metrics_init_widths( AF_LatinMetrics metrics,
FT_Face face )
{
/* scan the array of segments in each direction */
AF_GlyphHintsRec hints[1];
FT_TRACE5(( "\n" ));
FT_TRACE5(( "latin standard widths computation (style `%s')\n",
af_style_names[metrics->root.style_class->style] ));
FT_TRACE5(( "=====================================================\n" ));
FT_TRACE5(( "\n" ));
af_glyph_hints_init( hints, face->memory );
metrics->axis[AF_DIMENSION_HORZ].width_count = 0;
metrics->axis[AF_DIMENSION_VERT].width_count = 0;
{
FT_Error error;
FT_ULong glyph_index;
int dim;
AF_LatinMetricsRec dummy[1];
AF_Scaler scaler = &dummy->root.scaler;
AF_StyleClass style_class = metrics->root.style_class;
AF_ScriptClass script_class = af_script_classes[style_class->script];
/* If HarfBuzz is not available, we need a pointer to a single */
/* unsigned long value. */
#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
void* shaper_buf;
#else
FT_ULong shaper_buf_;
void* shaper_buf = &shaper_buf_;
#endif
const char* p;
#ifdef FT_DEBUG_LEVEL_TRACE
FT_ULong ch = 0;
#endif
p = script_class->standard_charstring;
#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
shaper_buf = af_shaper_buf_create( face );
#endif
/*
* We check a list of standard characters to catch features like
* `c2sc' (small caps from caps) that don't contain lowercase letters
* by definition, or other features that mainly operate on numerals.
* The first match wins.
*/
glyph_index = 0;
while ( *p )
{
unsigned int num_idx;
#ifdef FT_DEBUG_LEVEL_TRACE
const char* p_old;
#endif
while ( *p == ' ' )
p++;
#ifdef FT_DEBUG_LEVEL_TRACE
p_old = p;
GET_UTF8_CHAR( ch, p_old );
#endif
/* reject input that maps to more than a single glyph */
p = af_shaper_get_cluster( p, &metrics->root, shaper_buf, &num_idx );
if ( num_idx > 1 )
continue;
/* otherwise exit loop if we have a result */
glyph_index = af_shaper_get_elem( &metrics->root,
shaper_buf,
0,
NULL,
NULL );
if ( glyph_index )
break;
}
af_shaper_buf_destroy( face, shaper_buf );
if ( !glyph_index )
{
FT_TRACE5(( "standard character missing;"
" using fallback stem widths\n" ));
goto Exit;
}
FT_TRACE5(( "standard character: U+%04lX (glyph index %ld)\n",
ch, glyph_index ));
error = FT_Load_Glyph( face, glyph_index, FT_LOAD_NO_SCALE );
if ( error || face->glyph->outline.n_points <= 0 )
goto Exit;
FT_ZERO( dummy );
dummy->units_per_em = metrics->units_per_em;
scaler->x_scale = 0x10000L;
scaler->y_scale = 0x10000L;
scaler->x_delta = 0;
scaler->y_delta = 0;
scaler->face = face;
scaler->render_mode = FT_RENDER_MODE_NORMAL;
scaler->flags = 0;
af_glyph_hints_rescale( hints, (AF_StyleMetrics)dummy );
error = af_glyph_hints_reload( hints, &face->glyph->outline );
if ( error )
goto Exit;
for ( dim = 0; dim < AF_DIMENSION_MAX; dim++ )
{
AF_LatinAxis axis = &metrics->axis[dim];
AF_AxisHints axhints = &hints->axis[dim];
AF_Segment seg, limit, link;
FT_UInt num_widths = 0;
error = af_latin_hints_compute_segments( hints,
(AF_Dimension)dim );
if ( error )
goto Exit;
/*
* We assume that the glyphs selected for the stem width
* computation are `featureless' enough so that the linking
* algorithm works fine without adjustments of its scoring
* function.
*/
af_latin_hints_link_segments( hints,
0,
NULL,
(AF_Dimension)dim );
seg = axhints->segments;
limit = FT_OFFSET( seg, axhints->num_segments );
for ( ; seg < limit; seg++ )
{
link = seg->link;
/* we only consider stem segments there! */
if ( link && link->link == seg && link > seg )
{
FT_Pos dist;
dist = seg->pos - link->pos;
if ( dist < 0 )
dist = -dist;
if ( num_widths < AF_LATIN_MAX_WIDTHS )
axis->widths[num_widths++].org = dist;
}
}
/* this also replaces multiple almost identical stem widths */
/* with a single one (the value 100 is heuristic) */
af_sort_and_quantize_widths( &num_widths, axis->widths,
dummy->units_per_em / 100 );
axis->width_count = num_widths;
}
Exit:
for ( dim = 0; dim < AF_DIMENSION_MAX; dim++ )
{
AF_LatinAxis axis = &metrics->axis[dim];
FT_Pos stdw;
stdw = ( axis->width_count > 0 ) ? axis->widths[0].org
: AF_LATIN_CONSTANT( metrics, 50 );
/* let's try 20% of the smallest width */
axis->edge_distance_threshold = stdw / 5;
axis->standard_width = stdw;
axis->extra_light = 0;
#ifdef FT_DEBUG_LEVEL_TRACE
{
FT_UInt i;
FT_TRACE5(( "%s widths:\n",
dim == AF_DIMENSION_VERT ? "horizontal"
: "vertical" ));
FT_TRACE5(( " %ld (standard)", axis->standard_width ));
for ( i = 1; i < axis->width_count; i++ )
FT_TRACE5(( " %ld", axis->widths[i].org ));
FT_TRACE5(( "\n" ));
}
#endif
}
}
FT_TRACE5(( "\n" ));
af_glyph_hints_done( hints );
}
static void
af_latin_sort_blue( FT_UInt count,
AF_LatinBlue* table )
{
FT_UInt i, j;
AF_LatinBlue swap;
/* we sort from bottom to top */
for ( i = 1; i < count; i++ )
{
for ( j = i; j > 0; j-- )
{
FT_Pos a, b;
if ( table[j - 1]->flags & ( AF_LATIN_BLUE_TOP |
AF_LATIN_BLUE_SUB_TOP ) )
a = table[j - 1]->ref.org;
else
a = table[j - 1]->shoot.org;
if ( table[j]->flags & ( AF_LATIN_BLUE_TOP |
AF_LATIN_BLUE_SUB_TOP ) )
b = table[j]->ref.org;
else
b = table[j]->shoot.org;
if ( b >= a )
break;
swap = table[j];
table[j] = table[j - 1];
table[j - 1] = swap;
}
}
}
/* Find all blue zones. Flat segments give the reference points, */
/* round segments the overshoot positions. */
static int
af_latin_metrics_init_blues( AF_LatinMetrics metrics,
FT_Face face )
{
FT_Pos flats [AF_BLUE_STRING_MAX_LEN];
FT_Pos rounds[AF_BLUE_STRING_MAX_LEN];
FT_UInt num_flats;
FT_UInt num_rounds;
AF_LatinBlue blue;
FT_Error error;
AF_LatinAxis axis = &metrics->axis[AF_DIMENSION_VERT];
FT_Outline outline;
AF_StyleClass sc = metrics->root.style_class;
AF_Blue_Stringset bss = sc->blue_stringset;
const AF_Blue_StringRec* bs = &af_blue_stringsets[bss];
FT_Pos flat_threshold = FLAT_THRESHOLD( metrics->units_per_em );
/* If HarfBuzz is not available, we need a pointer to a single */
/* unsigned long value. */
#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
void* shaper_buf;
#else
FT_ULong shaper_buf_;
void* shaper_buf = &shaper_buf_;
#endif
/* we walk over the blue character strings as specified in the */
/* style's entry in the `af_blue_stringset' array */
FT_TRACE5(( "latin blue zones computation\n" ));
FT_TRACE5(( "============================\n" ));
FT_TRACE5(( "\n" ));
#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
shaper_buf = af_shaper_buf_create( face );
#endif
for ( ; bs->string != AF_BLUE_STRING_MAX; bs++ )
{
const char* p = &af_blue_strings[bs->string];
FT_Pos* blue_ref;
FT_Pos* blue_shoot;
FT_Pos ascender;
FT_Pos descender;
#ifdef FT_DEBUG_LEVEL_TRACE
{
FT_Bool have_flag = 0;
FT_TRACE5(( "blue zone %d", axis->blue_count ));
if ( bs->properties )
{
FT_TRACE5(( " (" ));
if ( AF_LATIN_IS_TOP_BLUE( bs ) )
{
FT_TRACE5(( "top" ));
have_flag = 1;
}
else if ( AF_LATIN_IS_SUB_TOP_BLUE( bs ) )
{
FT_TRACE5(( "sub top" ));
have_flag = 1;
}
if ( AF_LATIN_IS_NEUTRAL_BLUE( bs ) )
{
if ( have_flag )
FT_TRACE5(( ", " ));
FT_TRACE5(( "neutral" ));
have_flag = 1;
}
if ( AF_LATIN_IS_X_HEIGHT_BLUE( bs ) )
{
if ( have_flag )
FT_TRACE5(( ", " ));
FT_TRACE5(( "small top" ));
have_flag = 1;
}
if ( AF_LATIN_IS_LONG_BLUE( bs ) )
{
if ( have_flag )
FT_TRACE5(( ", " ));
FT_TRACE5(( "long" ));
}
FT_TRACE5(( ")" ));
}
FT_TRACE5(( ":\n" ));
}
#endif /* FT_DEBUG_LEVEL_TRACE */
num_flats = 0;
num_rounds = 0;
ascender = 0;
descender = 0;
while ( *p )
{
FT_ULong glyph_index;
FT_Long y_offset;
FT_Int best_point, best_contour_first, best_contour_last;
FT_Vector* points;
FT_Pos best_y_extremum; /* same as points.y */
FT_Bool best_round = 0;
unsigned int i, num_idx;
#ifdef FT_DEBUG_LEVEL_TRACE
const char* p_old;
FT_ULong ch;
#endif
while ( *p == ' ' )
p++;
#ifdef FT_DEBUG_LEVEL_TRACE
p_old = p;
GET_UTF8_CHAR( ch, p_old );
#endif
p = af_shaper_get_cluster( p, &metrics->root, shaper_buf, &num_idx );
if ( !num_idx )
{
FT_TRACE5(( " U+%04lX unavailable\n", ch ));
continue;
}
if ( AF_LATIN_IS_TOP_BLUE( bs ) )
best_y_extremum = FT_INT_MIN;
else
best_y_extremum = FT_INT_MAX;
/* iterate over all glyph elements of the character cluster */
/* and get the data of the `biggest' one */
for ( i = 0; i < num_idx; i++ )
{
FT_Pos best_y;
FT_Bool round = 0;
/* load the character in the face -- skip unknown or empty ones */
glyph_index = af_shaper_get_elem( &metrics->root,
shaper_buf,
i,
NULL,
&y_offset );
if ( glyph_index == 0 )
{
FT_TRACE5(( " U+%04lX unavailable\n", ch ));
continue;
}
error = FT_Load_Glyph( face, glyph_index, FT_LOAD_NO_SCALE );
outline = face->glyph->outline;
/* reject glyphs that don't produce any rendering */
if ( error || outline.n_points <= 2 )
{
#ifdef FT_DEBUG_LEVEL_TRACE
if ( num_idx == 1 )
FT_TRACE5(( " U+%04lX contains no (usable) outlines\n", ch ));
else
FT_TRACE5(( " component %d of cluster starting with U+%04lX"
" contains no (usable) outlines\n", i, ch ));
#endif
continue;
}
/* now compute min or max point indices and coordinates */
points = outline.points;
best_point = -1;
best_y = 0; /* make compiler happy */
best_contour_first = 0; /* ditto */
best_contour_last = 0; /* ditto */
{
FT_Int nn;
FT_Int first = 0;
FT_Int last = -1;
for ( nn = 0; nn < outline.n_contours; first = last + 1, nn++ )
{
FT_Int old_best_point = best_point;
FT_Int pp;
last = outline.contours[nn];
/* Avoid single-point contours since they are never */
/* rasterized. In some fonts, they correspond to mark */
/* attachment points that are way outside of the glyph's */
/* real outline. */
if ( last <= first )
continue;
if ( AF_LATIN_IS_TOP_BLUE( bs ) ||
AF_LATIN_IS_SUB_TOP_BLUE( bs ) )
{
for ( pp = first; pp <= last; pp++ )
{
if ( best_point < 0 || points[pp].y > best_y )
{
best_point = pp;
best_y = points[pp].y;
ascender = FT_MAX( ascender, best_y + y_offset );
}
else
descender = FT_MIN( descender, points[pp].y + y_offset );
}
}
else
{
for ( pp = first; pp <= last; pp++ )
{
if ( best_point < 0 || points[pp].y < best_y )
{
best_point = pp;
best_y = points[pp].y;
descender = FT_MIN( descender, best_y + y_offset );
}
else
ascender = FT_MAX( ascender, points[pp].y + y_offset );
}
}
if ( best_point != old_best_point )
{
best_contour_first = first;
best_contour_last = last;
}
}
}
/* now check whether the point belongs to a straight or round */
/* segment; we first need to find in which contour the extremum */
/* lies, then inspect its previous and next points */
if ( best_point >= 0 )
{
FT_Pos best_x = points[best_point].x;
FT_Int prev, next;
FT_Int best_segment_first, best_segment_last;
FT_Int best_on_point_first, best_on_point_last;
FT_Pos dist;
best_segment_first = best_point;
best_segment_last = best_point;
if ( FT_CURVE_TAG( outline.tags[best_point] ) == FT_CURVE_TAG_ON )
{
best_on_point_first = best_point;
best_on_point_last = best_point;
}
else
{
best_on_point_first = -1;
best_on_point_last = -1;
}
/* look for the previous and next points on the contour */
/* that are not on the same Y coordinate, then threshold */
/* the `closeness'... */
prev = best_point;
next = prev;
do
{
if ( prev > best_contour_first )
prev--;
else
prev = best_contour_last;
dist = FT_ABS( points[prev].y - best_y );
/* accept a small distance or a small angle (both values are */
/* heuristic; value 20 corresponds to approx. 2.9 degrees) */
if ( dist > 5 )
if ( FT_ABS( points[prev].x - best_x ) <= 20 * dist )
break;
best_segment_first = prev;
if ( FT_CURVE_TAG( outline.tags[prev] ) == FT_CURVE_TAG_ON )
{
best_on_point_first = prev;
if ( best_on_point_last < 0 )
best_on_point_last = prev;
}
} while ( prev != best_point );
do
{
if ( next < best_contour_last )
next++;
else
next = best_contour_first;
dist = FT_ABS( points[next].y - best_y );
if ( dist > 5 )
if ( FT_ABS( points[next].x - best_x ) <= 20 * dist )
break;
best_segment_last = next;
if ( FT_CURVE_TAG( outline.tags[next] ) == FT_CURVE_TAG_ON )
{
best_on_point_last = next;
if ( best_on_point_first < 0 )
best_on_point_first = next;
}
} while ( next != best_point );
if ( AF_LATIN_IS_LONG_BLUE( bs ) )
{
/* If this flag is set, we have an additional constraint to */
/* get the blue zone distance: Find a segment of the topmost */
/* (or bottommost) contour that is longer than a heuristic */
/* threshold. This ensures that small bumps in the outline */
/* are ignored (for example, the `vertical serifs' found in */
/* many Hebrew glyph designs). */
/* If this segment is long enough, we are done. Otherwise, */
/* search the segment next to the extremum that is long */
/* enough, has the same direction, and a not too large */
/* vertical distance from the extremum. Note that the */
/* algorithm doesn't check whether the found segment is */
/* actually the one (vertically) nearest to the extremum. */
/* heuristic threshold value */
FT_Pos length_threshold = metrics->units_per_em / 25;
dist = FT_ABS( points[best_segment_last].x -
points[best_segment_first].x );
if ( dist < length_threshold &&
best_segment_last - best_segment_first + 2 <=
best_contour_last - best_contour_first )
{
/* heuristic threshold value */
FT_Pos height_threshold = metrics->units_per_em / 4;
FT_Int first;
FT_Int last;
FT_Bool hit;
/* we intentionally declare these two variables */
/* outside of the loop since various compilers emit */
/* incorrect warning messages otherwise, talking about */
/* `possibly uninitialized variables' */
FT_Int p_first = 0; /* make compiler happy */
FT_Int p_last = 0;
FT_Bool left2right;
/* compute direction */
prev = best_point;
do
{
if ( prev > best_contour_first )
prev--;
else
prev = best_contour_last;
if ( points[prev].x != best_x )
break;
} while ( prev != best_point );
/* skip glyph for the degenerate case */
if ( prev == best_point )
continue;
left2right = FT_BOOL( points[prev].x < points[best_point].x );
first = best_segment_last;
last = first;
hit = 0;
do
{
FT_Bool l2r;
FT_Pos d;
if ( !hit )
{
/* no hit; adjust first point */
first = last;
/* also adjust first and last on point */
if ( FT_CURVE_TAG( outline.tags[first] ) ==
FT_CURVE_TAG_ON )
{
p_first = first;
p_last = first;
}
else
{
p_first = -1;
p_last = -1;
}
hit = 1;
}
if ( last < best_contour_last )
last++;
else
last = best_contour_first;
if ( FT_ABS( best_y - points[first].y ) > height_threshold )
{
/* vertical distance too large */
hit = 0;
continue;
}
/* same test as above */
dist = FT_ABS( points[last].y - points[first].y );
if ( dist > 5 )
if ( FT_ABS( points[last].x - points[first].x ) <=
20 * dist )
{
hit = 0;
continue;
}
if ( FT_CURVE_TAG( outline.tags[last] ) == FT_CURVE_TAG_ON )
{
p_last = last;
if ( p_first < 0 )
p_first = last;
}
l2r = FT_BOOL( points[first].x < points[last].x );
d = FT_ABS( points[last].x - points[first].x );
if ( l2r == left2right &&
d >= length_threshold )
{
/* all constraints are met; update segment after */
/* finding its end */
do
{
if ( last < best_contour_last )
last++;
else
last = best_contour_first;
d = FT_ABS( points[last].y - points[first].y );
if ( d > 5 )
if ( FT_ABS( points[next].x - points[first].x ) <=
20 * dist )
{
if ( last > best_contour_first )
last--;
else
last = best_contour_last;
break;
}
p_last = last;
if ( FT_CURVE_TAG( outline.tags[last] ) ==
FT_CURVE_TAG_ON )
{
p_last = last;
if ( p_first < 0 )
p_first = last;
}
} while ( last != best_segment_first );
best_y = points[first].y;
best_segment_first = first;
best_segment_last = last;
best_on_point_first = p_first;
best_on_point_last = p_last;
break;
}
} while ( last != best_segment_first );
}
}
/* for computing blue zones, we add the y offset as returned */
/* by the currently used OpenType feature -- for example, */
/* superscript glyphs might be identical to subscript glyphs */
/* with a vertical shift */
best_y += y_offset;
#ifdef FT_DEBUG_LEVEL_TRACE
if ( num_idx == 1 )
FT_TRACE5(( " U+%04lX: best_y = %5ld", ch, best_y ));
else
FT_TRACE5(( " component %d of cluster starting with U+%04lX:"
" best_y = %5ld", i, ch, best_y ));
#endif
/* now set the `round' flag depending on the segment's kind: */
/* */
/* - if the horizontal distance between the first and last */
/* `on' point is larger than a heuristic threshold */
/* we have a flat segment */
/* - if either the first or the last point of the segment is */
/* an `off' point, the segment is round, otherwise it is */
/* flat */
if ( best_on_point_first >= 0 &&
best_on_point_last >= 0 &&
( FT_ABS( points[best_on_point_last].x -
points[best_on_point_first].x ) ) >
flat_threshold )
round = 0;
else
round = FT_BOOL(
FT_CURVE_TAG( outline.tags[best_segment_first] ) !=
FT_CURVE_TAG_ON ||
FT_CURVE_TAG( outline.tags[best_segment_last] ) !=
FT_CURVE_TAG_ON );
if ( round && AF_LATIN_IS_NEUTRAL_BLUE( bs ) )
{
/* only use flat segments for a neutral blue zone */
FT_TRACE5(( " (round, skipped)\n" ));
continue;
}
FT_TRACE5(( " (%s)\n", round ? "round" : "flat" ));
}
if ( AF_LATIN_IS_TOP_BLUE( bs ) )
{
if ( best_y > best_y_extremum )
{
best_y_extremum = best_y;
best_round = round;
}
}
else
{
if ( best_y < best_y_extremum )
{
best_y_extremum = best_y;
best_round = round;
}
}
} /* end for loop */
if ( !( best_y_extremum == FT_INT_MIN ||
best_y_extremum == FT_INT_MAX ) )
{
if ( best_round )
rounds[num_rounds++] = best_y_extremum;
else
flats[num_flats++] = best_y_extremum;
}
} /* end while loop */
if ( num_flats == 0 && num_rounds == 0 )
{
/*
* we couldn't find a single glyph to compute this blue zone,
* we will simply ignore it then
*/
FT_TRACE5(( " empty\n" ));
continue;
}
/* we have computed the contents of the `rounds' and `flats' tables, */
/* now determine the reference and overshoot position of the blue -- */
/* we simply take the median value after a simple sort */
af_sort_pos( num_rounds, rounds );
af_sort_pos( num_flats, flats );
blue = &axis->blues[axis->blue_count];
blue_ref = &blue->ref.org;
blue_shoot = &blue->shoot.org;
axis->blue_count++;
if ( num_flats == 0 )
{
*blue_ref =
*blue_shoot = rounds[num_rounds / 2];
}
else if ( num_rounds == 0 )
{
*blue_ref =
*blue_shoot = flats[num_flats / 2];
}
else
{
*blue_ref = flats [num_flats / 2];
*blue_shoot = rounds[num_rounds / 2];
}
/* there are sometimes problems: if the overshoot position of top */
/* zones is under its reference position, or the opposite for bottom */
/* zones. We must thus check everything there and correct the errors */
if ( *blue_shoot != *blue_ref )
{
FT_Pos ref = *blue_ref;
FT_Pos shoot = *blue_shoot;
FT_Bool over_ref = FT_BOOL( shoot > ref );
if ( ( AF_LATIN_IS_TOP_BLUE( bs ) ||
AF_LATIN_IS_SUB_TOP_BLUE( bs) ) ^ over_ref )
{
*blue_ref =
*blue_shoot = ( shoot + ref ) / 2;
FT_TRACE5(( " [overshoot smaller than reference,"
" taking mean value]\n" ));
}
}
blue->ascender = ascender;
blue->descender = descender;
blue->flags = 0;
if ( AF_LATIN_IS_TOP_BLUE( bs ) )
blue->flags |= AF_LATIN_BLUE_TOP;
if ( AF_LATIN_IS_SUB_TOP_BLUE( bs ) )
blue->flags |= AF_LATIN_BLUE_SUB_TOP;
if ( AF_LATIN_IS_NEUTRAL_BLUE( bs ) )
blue->flags |= AF_LATIN_BLUE_NEUTRAL;
/*
* The following flag is used later to adjust the y and x scales
* in order to optimize the pixel grid alignment of the top of small
* letters.
*/
if ( AF_LATIN_IS_X_HEIGHT_BLUE( bs ) )
blue->flags |= AF_LATIN_BLUE_ADJUSTMENT;
FT_TRACE5(( " -> reference = %ld\n", *blue_ref ));
FT_TRACE5(( " overshoot = %ld\n", *blue_shoot ));
} /* end for loop */
af_shaper_buf_destroy( face, shaper_buf );
if ( axis->blue_count )
{
/* we finally check whether blue zones are ordered; */
/* `ref' and `shoot' values of two blue zones must not overlap */
FT_UInt i;
AF_LatinBlue blue_sorted[AF_BLUE_STRINGSET_MAX_LEN + 2];
for ( i = 0; i < axis->blue_count; i++ )
blue_sorted[i] = &axis->blues[i];
/* sort bottoms of blue zones... */
af_latin_sort_blue( axis->blue_count, blue_sorted );
/* ...and adjust top values if necessary */
for ( i = 0; i < axis->blue_count - 1; i++ )
{
FT_Pos* a;
FT_Pos* b;
#ifdef FT_DEBUG_LEVEL_TRACE
FT_Bool a_is_top = 0;
#endif
if ( blue_sorted[i]->flags & ( AF_LATIN_BLUE_TOP |
AF_LATIN_BLUE_SUB_TOP ) )
{
a = &blue_sorted[i]->shoot.org;
#ifdef FT_DEBUG_LEVEL_TRACE
a_is_top = 1;
#endif
}
else
a = &blue_sorted[i]->ref.org;
if ( blue_sorted[i + 1]->flags & ( AF_LATIN_BLUE_TOP |
AF_LATIN_BLUE_SUB_TOP ) )
b = &blue_sorted[i + 1]->shoot.org;
else
b = &blue_sorted[i + 1]->ref.org;
if ( *a > *b )
{
*a = *b;
FT_TRACE5(( "blue zone overlap:"
" adjusting %s %ld to %ld\n",
a_is_top ? "overshoot" : "reference",
blue_sorted[i] - axis->blues,
*a ));
}
}
FT_TRACE5(( "\n" ));
return 0;
}
else
{
/* disable hinting for the current style if there are no blue zones */
AF_FaceGlobals globals = metrics->root.globals;
FT_UShort* gstyles = globals->glyph_styles;
FT_Long i;
FT_TRACE5(( "no blue zones found:"
" hinting disabled for this style\n" ));
for ( i = 0; i < globals->glyph_count; i++ )
{
if ( ( gstyles[i] & AF_STYLE_MASK ) == sc->style )
gstyles[i] = AF_STYLE_NONE_DFLT;
}
FT_TRACE5(( "\n" ));
return 1;
}
}
/* Check whether all ASCII digits have the same advance width. */
FT_LOCAL_DEF( void )
af_latin_metrics_check_digits( AF_LatinMetrics metrics,
FT_Face face )
{
FT_Bool started = 0, same_width = 1;
FT_Fixed advance = 0, old_advance = 0;
/* If HarfBuzz is not available, we need a pointer to a single */
/* unsigned long value. */
#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
void* shaper_buf;
#else
FT_ULong shaper_buf_;
void* shaper_buf = &shaper_buf_;
#endif
/* in all supported charmaps, digits have character codes 0x30-0x39 */
const char digits[] = "0 1 2 3 4 5 6 7 8 9";
const char* p;
p = digits;
#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
shaper_buf = af_shaper_buf_create( face );
#endif
while ( *p )
{
FT_ULong glyph_index;
unsigned int num_idx;
/* reject input that maps to more than a single glyph */
p = af_shaper_get_cluster( p, &metrics->root, shaper_buf, &num_idx );
if ( num_idx > 1 )
continue;
glyph_index = af_shaper_get_elem( &metrics->root,
shaper_buf,
0,
&advance,
NULL );
if ( !glyph_index )
continue;
if ( started )
{
if ( advance != old_advance )
{
same_width = 0;
break;
}
}
else
{
old_advance = advance;
started = 1;
}
}
af_shaper_buf_destroy( face, shaper_buf );
metrics->root.digits_have_same_width = same_width;
}
/* Initialize global metrics. */
FT_LOCAL_DEF( FT_Error )
af_latin_metrics_init( AF_LatinMetrics metrics,
FT_Face face )
{
FT_Error error = FT_Err_Ok;
FT_CharMap oldmap = face->charmap;
metrics->units_per_em = face->units_per_EM;
if ( !FT_Select_Charmap( face, FT_ENCODING_UNICODE ) )
{
af_latin_metrics_init_widths( metrics, face );
if ( af_latin_metrics_init_blues( metrics, face ) )
{
/* use internal error code to indicate missing blue zones */
error = -1;
goto Exit;
}
af_latin_metrics_check_digits( metrics, face );
}
Exit:
FT_Set_Charmap( face, oldmap );
return error;
}
/* Adjust scaling value, then scale and shift widths */
/* and blue zones (if applicable) for given dimension. */
static void
af_latin_metrics_scale_dim( AF_LatinMetrics metrics,
AF_Scaler scaler,
AF_Dimension dim )
{
FT_Fixed scale;
FT_Pos delta;
AF_LatinAxis axis;
FT_UInt nn;
if ( dim == AF_DIMENSION_HORZ )
{
scale = scaler->x_scale;
delta = scaler->x_delta;
}
else
{
scale = scaler->y_scale;
delta = scaler->y_delta;
}
axis = &metrics->axis[dim];
if ( axis->org_scale == scale && axis->org_delta == delta )
return;
axis->org_scale = scale;
axis->org_delta = delta;
/*
* correct X and Y scale to optimize the alignment of the top of small
* letters to the pixel grid
*/
{
AF_LatinAxis Axis = &metrics->axis[AF_DIMENSION_VERT];
AF_LatinBlue blue = NULL;
for ( nn = 0; nn < Axis->blue_count; nn++ )
{
if ( Axis->blues[nn].flags & AF_LATIN_BLUE_ADJUSTMENT )
{
blue = &Axis->blues[nn];
break;
}
}
if ( blue )
{
FT_Pos scaled;
FT_Pos threshold;
FT_Pos fitted;
FT_UInt limit;
FT_UInt ppem;
scaled = FT_MulFix( blue->shoot.org, scale );
ppem = metrics->root.scaler.face->size->metrics.x_ppem;
limit = metrics->root.globals->increase_x_height;
threshold = 40;
/* if the `increase-x-height' property is active, */
/* we round up much more often */
if ( limit &&
ppem <= limit &&
ppem >= AF_PROP_INCREASE_X_HEIGHT_MIN )
threshold = 52;
fitted = ( scaled + threshold ) & ~63;
if ( scaled != fitted )
{
#if 0
if ( dim == AF_DIMENSION_HORZ )
{
if ( fitted < scaled )
scale -= scale / 50; /* scale *= 0.98 */
}
else
#endif
if ( dim == AF_DIMENSION_VERT )
{
FT_Pos max_height;
FT_Pos dist;
FT_Fixed new_scale;
new_scale = FT_MulDiv( scale, fitted, scaled );
/* the scaling should not change the result by more than two pixels */
max_height = metrics->units_per_em;
for ( nn = 0; nn < Axis->blue_count; nn++ )
{
max_height = FT_MAX( max_height, Axis->blues[nn].ascender );
max_height = FT_MAX( max_height, -Axis->blues[nn].descender );
}
dist = FT_ABS( FT_MulFix( max_height, new_scale - scale ) );
dist &= ~127;
if ( dist == 0 )
{
FT_TRACE5(( "af_latin_metrics_scale_dim:"
" x height alignment (style `%s'):\n",
af_style_names[metrics->root.style_class->style] ));
FT_TRACE5(( " "
" vertical scaling changed"
" from %.5f to %.5f (by %ld%%)\n",
scale / 65536.0,
new_scale / 65536.0,
( fitted - scaled ) * 100 / scaled ));
FT_TRACE5(( "\n" ));
scale = new_scale;
}
#ifdef FT_DEBUG_LEVEL_TRACE
else
{
FT_TRACE5(( "af_latin_metrics_scale_dim:"
" x height alignment (style `%s'):\n",
af_style_names[metrics->root.style_class->style] ));
FT_TRACE5(( " "
" excessive vertical scaling abandoned\n" ));
FT_TRACE5(( "\n" ));
}
#endif
}
}
}
}
axis->scale = scale;
axis->delta = delta;
if ( dim == AF_DIMENSION_HORZ )
{
metrics->root.scaler.x_scale = scale;
metrics->root.scaler.x_delta = delta;
}
else
{
metrics->root.scaler.y_scale = scale;
metrics->root.scaler.y_delta = delta;
}
FT_TRACE5(( "%s widths (style `%s')\n",
dim == AF_DIMENSION_HORZ ? "horizontal" : "vertical",
af_style_names[metrics->root.style_class->style] ));
/* scale the widths */
for ( nn = 0; nn < axis->width_count; nn++ )
{
AF_Width width = axis->widths + nn;
width->cur = FT_MulFix( width->org, scale );
width->fit = width->cur;
FT_TRACE5(( " %ld scaled to %.2f\n",
width->org,
width->cur / 64.0 ));
}
FT_TRACE5(( "\n" ));
/* an extra-light axis corresponds to a standard width that is */
/* smaller than 5/8 pixels */
axis->extra_light =
FT_BOOL( FT_MulFix( axis->standard_width, scale ) < 32 + 8 );
#ifdef FT_DEBUG_LEVEL_TRACE
if ( axis->extra_light )
{
FT_TRACE5(( "`%s' style is extra light (at current resolution)\n",
af_style_names[metrics->root.style_class->style] ));
FT_TRACE5(( "\n" ));
}
#endif
if ( dim == AF_DIMENSION_VERT )
{
#ifdef FT_DEBUG_LEVEL_TRACE
if ( axis->blue_count )
FT_TRACE5(( "blue zones (style `%s')\n",
af_style_names[metrics->root.style_class->style] ));
#endif
/* scale the blue zones */
for ( nn = 0; nn < axis->blue_count; nn++ )
{
AF_LatinBlue blue = &axis->blues[nn];
FT_Pos dist;
blue->ref.cur = FT_MulFix( blue->ref.org, scale ) + delta;
blue->ref.fit = blue->ref.cur;
blue->shoot.cur = FT_MulFix( blue->shoot.org, scale ) + delta;
blue->shoot.fit = blue->shoot.cur;
blue->flags &= ~AF_LATIN_BLUE_ACTIVE;
/* a blue zone is only active if it is less than 3/4 pixels tall */
dist = FT_MulFix( blue->ref.org - blue->shoot.org, scale );
if ( dist <= 48 && dist >= -48 )
{
#if 0
FT_Pos delta1;
#endif
FT_Pos delta2;
/* use discrete values for blue zone widths */
#if 0
/* generic, original code */
delta1 = blue->shoot.org - blue->ref.org;
delta2 = delta1;
if ( delta1 < 0 )
delta2 = -delta2;
delta2 = FT_MulFix( delta2, scale );
if ( delta2 < 32 )
delta2 = 0;
else if ( delta2 < 64 )
delta2 = 32 + ( ( ( delta2 - 32 ) + 16 ) & ~31 );
else
delta2 = FT_PIX_ROUND( delta2 );
if ( delta1 < 0 )
delta2 = -delta2;
blue->ref.fit = FT_PIX_ROUND( blue->ref.cur );
blue->shoot.fit = blue->ref.fit + delta2;
#else
/* simplified version due to abs(dist) <= 48 */
delta2 = dist;
if ( dist < 0 )
delta2 = -delta2;
if ( delta2 < 32 )
delta2 = 0;
else if ( delta2 < 48 )
delta2 = 32;
else
delta2 = 64;
if ( dist < 0 )
delta2 = -delta2;
blue->ref.fit = FT_PIX_ROUND( blue->ref.cur );
blue->shoot.fit = blue->ref.fit - delta2;
#endif
blue->flags |= AF_LATIN_BLUE_ACTIVE;
}
}
/* use sub-top blue zone only if it doesn't overlap with */
/* another (non-sup-top) blue zone; otherwise, the */
/* effect would be similar to a neutral blue zone, which */
/* is not desired here */
for ( nn = 0; nn < axis->blue_count; nn++ )
{
AF_LatinBlue blue = &axis->blues[nn];
FT_UInt i;
if ( !( blue->flags & AF_LATIN_BLUE_SUB_TOP ) )
continue;
if ( !( blue->flags & AF_LATIN_BLUE_ACTIVE ) )
continue;
for ( i = 0; i < axis->blue_count; i++ )
{
AF_LatinBlue b = &axis->blues[i];
if ( b->flags & AF_LATIN_BLUE_SUB_TOP )
continue;
if ( !( b->flags & AF_LATIN_BLUE_ACTIVE ) )
continue;
if ( b->ref.fit <= blue->shoot.fit &&
b->shoot.fit >= blue->ref.fit )
{
blue->flags &= ~AF_LATIN_BLUE_ACTIVE;
break;
}
}
}
#ifdef FT_DEBUG_LEVEL_TRACE
for ( nn = 0; nn < axis->blue_count; nn++ )
{
AF_LatinBlue blue = &axis->blues[nn];
FT_TRACE5(( " reference %d: %ld scaled to %.2f%s\n",
nn,
blue->ref.org,
blue->ref.fit / 64.0,
( blue->flags & AF_LATIN_BLUE_ACTIVE ) ? ""
: " (inactive)" ));
FT_TRACE5(( " overshoot %d: %ld scaled to %.2f%s\n",
nn,
blue->shoot.org,
blue->shoot.fit / 64.0,
( blue->flags & AF_LATIN_BLUE_ACTIVE ) ? ""
: " (inactive)" ));
}
#endif
}
}
/* Scale global values in both directions. */
FT_LOCAL_DEF( void )
af_latin_metrics_scale( AF_LatinMetrics metrics,
AF_Scaler scaler )
{
metrics->root.scaler.render_mode = scaler->render_mode;
metrics->root.scaler.face = scaler->face;
metrics->root.scaler.flags = scaler->flags;
af_latin_metrics_scale_dim( metrics, scaler, AF_DIMENSION_HORZ );
af_latin_metrics_scale_dim( metrics, scaler, AF_DIMENSION_VERT );
}
/* Extract standard_width from writing system/script specific */
/* metrics class. */
FT_LOCAL_DEF( void )
af_latin_get_standard_widths( AF_LatinMetrics metrics,
FT_Pos* stdHW,
FT_Pos* stdVW )
{
if ( stdHW )
*stdHW = metrics->axis[AF_DIMENSION_VERT].standard_width;
if ( stdVW )
*stdVW = metrics->axis[AF_DIMENSION_HORZ].standard_width;
}
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** L A T I N G L Y P H A N A L Y S I S *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
/* Walk over all contours and compute its segments. */
FT_LOCAL_DEF( FT_Error )
af_latin_hints_compute_segments( AF_GlyphHints hints,
AF_Dimension dim )
{
AF_LatinMetrics metrics = (AF_LatinMetrics)hints->metrics;
AF_AxisHints axis = &hints->axis[dim];
FT_Memory memory = hints->memory;
FT_Error error = FT_Err_Ok;
AF_Segment segment = NULL;
AF_SegmentRec seg0;
AF_Point* contour = hints->contours;
AF_Point* contour_limit = contour + hints->num_contours;
AF_Direction major_dir, segment_dir;
FT_Pos flat_threshold = FLAT_THRESHOLD( metrics->units_per_em );
FT_ZERO( &seg0 );
seg0.score = 32000;
seg0.flags = AF_EDGE_NORMAL;
major_dir = (AF_Direction)FT_ABS( axis->major_dir );
segment_dir = major_dir;
axis->num_segments = 0;
/* set up (u,v) in each point */
if ( dim == AF_DIMENSION_HORZ )
{
AF_Point point = hints->points;
AF_Point limit = point + hints->num_points;
for ( ; point < limit; point++ )
{
point->u = point->fx;
point->v = point->fy;
}
}
else
{
AF_Point point = hints->points;
AF_Point limit = point + hints->num_points;
for ( ; point < limit; point++ )
{
point->u = point->fy;
point->v = point->fx;
}
}
/* do each contour separately */
for ( ; contour < contour_limit; contour++ )
{
AF_Point point = contour[0];
AF_Point last = point->prev;
int on_edge = 0;
/* we call values measured along a segment (point->v) */
/* `coordinates', and values orthogonal to it (point->u) */
/* `positions' */
FT_Pos min_pos = 32000;
FT_Pos max_pos = -32000;
FT_Pos min_coord = 32000;
FT_Pos max_coord = -32000;
FT_UShort min_flags = AF_FLAG_NONE;
FT_UShort max_flags = AF_FLAG_NONE;
FT_Pos min_on_coord = 32000;
FT_Pos max_on_coord = -32000;
FT_Bool passed;
AF_Segment prev_segment = NULL;
FT_Pos prev_min_pos = min_pos;
FT_Pos prev_max_pos = max_pos;
FT_Pos prev_min_coord = min_coord;
FT_Pos prev_max_coord = max_coord;
FT_UShort prev_min_flags = min_flags;
FT_UShort prev_max_flags = max_flags;
FT_Pos prev_min_on_coord = min_on_coord;
FT_Pos prev_max_on_coord = max_on_coord;
if ( FT_ABS( last->out_dir ) == major_dir &&
FT_ABS( point->out_dir ) == major_dir )
{
/* we are already on an edge, try to locate its start */
last = point;
for (;;)
{
point = point->prev;
if ( FT_ABS( point->out_dir ) != major_dir )
{
point = point->next;
break;
}
if ( point == last )
break;
}
}
last = point;
passed = 0;
for (;;)
{
FT_Pos u, v;
if ( on_edge )
{
/* get minimum and maximum position */
u = point->u;
if ( u < min_pos )
min_pos = u;
if ( u > max_pos )
max_pos = u;
/* get minimum and maximum coordinate together with flags */
v = point->v;
if ( v < min_coord )
{
min_coord = v;
min_flags = point->flags;
}
if ( v > max_coord )
{
max_coord = v;
max_flags = point->flags;
}
/* get minimum and maximum coordinate of `on' points */
if ( !( point->flags & AF_FLAG_CONTROL ) )
{
v = point->v;
if ( v < min_on_coord )
min_on_coord = v;
if ( v > max_on_coord )
max_on_coord = v;
}
if ( point->out_dir != segment_dir || point == last )
{
/* check whether the new segment's start point is identical to */
/* the previous segment's end point; for example, this might */
/* happen for spikes */
if ( !prev_segment || segment->first != prev_segment->last )
{
/* points are different: we are just leaving an edge, thus */
/* record a new segment */
segment->last = point;
segment->pos = (FT_Short)( ( min_pos + max_pos ) >> 1 );
segment->delta = (FT_Short)( ( max_pos - min_pos ) >> 1 );
/* a segment is round if either its first or last point */
/* is a control point, and the length of the on points */
/* inbetween doesn't exceed a heuristic limit */
if ( ( min_flags | max_flags ) & AF_FLAG_CONTROL &&
( max_on_coord - min_on_coord ) < flat_threshold )
segment->flags |= AF_EDGE_ROUND;
segment->min_coord = (FT_Short)min_coord;
segment->max_coord = (FT_Short)max_coord;
segment->height = segment->max_coord - segment->min_coord;
prev_segment = segment;
prev_min_pos = min_pos;
prev_max_pos = max_pos;
prev_min_coord = min_coord;
prev_max_coord = max_coord;
prev_min_flags = min_flags;
prev_max_flags = max_flags;
prev_min_on_coord = min_on_coord;
prev_max_on_coord = max_on_coord;
}
else
{
/* points are the same: we don't create a new segment but */
/* merge the current segment with the previous one */
if ( prev_segment->last->in_dir == point->in_dir )
{
/* we have identical directions (this can happen for */
/* degenerate outlines that move zig-zag along the main */
/* axis without changing the coordinate value of the other */
/* axis, and where the segments have just been merged): */
/* unify segments */
/* update constraints */
if ( prev_min_pos < min_pos )
min_pos = prev_min_pos;
if ( prev_max_pos > max_pos )
max_pos = prev_max_pos;
if ( prev_min_coord < min_coord )
{
min_coord = prev_min_coord;
min_flags = prev_min_flags;
}
if ( prev_max_coord > max_coord )
{
max_coord = prev_max_coord;
max_flags = prev_max_flags;
}
if ( prev_min_on_coord < min_on_coord )
min_on_coord = prev_min_on_coord;
if ( prev_max_on_coord > max_on_coord )
max_on_coord = prev_max_on_coord;
prev_segment->last = point;
prev_segment->pos = (FT_Short)( ( min_pos +
max_pos ) >> 1 );
prev_segment->delta = (FT_Short)( ( max_pos -
min_pos ) >> 1 );
if ( ( min_flags | max_flags ) & AF_FLAG_CONTROL &&
( max_on_coord - min_on_coord ) < flat_threshold )
prev_segment->flags |= AF_EDGE_ROUND;
else
prev_segment->flags &= ~AF_EDGE_ROUND;
prev_segment->min_coord = (FT_Short)min_coord;
prev_segment->max_coord = (FT_Short)max_coord;
prev_segment->height = prev_segment->max_coord -
prev_segment->min_coord;
}
else
{
/* we have different directions; use the properties of the */
/* longer segment and discard the other one */
if ( FT_ABS( prev_max_coord - prev_min_coord ) >
FT_ABS( max_coord - min_coord ) )
{
/* discard current segment */
if ( min_pos < prev_min_pos )
prev_min_pos = min_pos;
if ( max_pos > prev_max_pos )
prev_max_pos = max_pos;
prev_segment->last = point;
prev_segment->pos = (FT_Short)( ( prev_min_pos +
prev_max_pos ) >> 1 );
prev_segment->delta = (FT_Short)( ( prev_max_pos -
prev_min_pos ) >> 1 );
}
else
{
/* discard previous segment */
if ( prev_min_pos < min_pos )
min_pos = prev_min_pos;
if ( prev_max_pos > max_pos )
max_pos = prev_max_pos;
segment->last = point;
segment->pos = (FT_Short)( ( min_pos + max_pos ) >> 1 );
segment->delta = (FT_Short)( ( max_pos - min_pos ) >> 1 );
if ( ( min_flags | max_flags ) & AF_FLAG_CONTROL &&
( max_on_coord - min_on_coord ) < flat_threshold )
segment->flags |= AF_EDGE_ROUND;
segment->min_coord = (FT_Short)min_coord;
segment->max_coord = (FT_Short)max_coord;
segment->height = segment->max_coord -
segment->min_coord;
*prev_segment = *segment;
prev_min_pos = min_pos;
prev_max_pos = max_pos;
prev_min_coord = min_coord;
prev_max_coord = max_coord;
prev_min_flags = min_flags;
prev_max_flags = max_flags;
prev_min_on_coord = min_on_coord;
prev_max_on_coord = max_on_coord;
}
}
axis->num_segments--;
}
on_edge = 0;
segment = NULL;
/* fall through */
}
}
/* now exit if we are at the start/end point */
if ( point == last )
{
if ( passed )
break;
passed = 1;
}
/* if we are not on an edge, check whether the major direction */
/* coincides with the current point's `out' direction, or */
/* whether we have a single-point contour */
if ( !on_edge &&
( FT_ABS( point->out_dir ) == major_dir ||
point == point->prev ) )
{
/*
* For efficiency, we restrict the number of segments to 1000,
* which is a heuristic value: it is very unlikely that a glyph
* with so many segments can be hinted in a sensible way.
* Reasons:
*
* - The glyph has really 1000 segments; this implies that it has
* at least 2000 outline points. Assuming 'normal' fonts that
* have superfluous points optimized away, viewing such a glyph
* only makes sense at large magnifications where hinting
* isn't applied anyway.
*
* - We have a broken glyph. Hinting doesn't make sense in this
* case either.
*/
if ( axis->num_segments > 1000 )
{
FT_TRACE0(( "af_latin_hints_compute_segments:"
" more than 1000 segments in this glyph;\n" ));
FT_TRACE0(( " "
" hinting is suppressed\n" ));
axis->num_segments = 0;
return FT_Err_Ok;
}
/* this is the start of a new segment! */
segment_dir = (AF_Direction)point->out_dir;
error = af_axis_hints_new_segment( axis, memory, &segment );
if ( error )
goto Exit;
/* clear all segment fields */
segment[0] = seg0;
segment->dir = (FT_Char)segment_dir;
segment->first = point;
segment->last = point;
/* `af_axis_hints_new_segment' reallocates memory, */
/* thus we have to refresh the `prev_segment' pointer */
if ( prev_segment )
prev_segment = segment - 1;
min_pos = max_pos = point->u;
min_coord = max_coord = point->v;
min_flags = max_flags = point->flags;
if ( point->flags & AF_FLAG_CONTROL )
{
min_on_coord = 32000;
max_on_coord = -32000;
}
else
min_on_coord = max_on_coord = point->v;
on_edge = 1;
if ( point == point->prev )
{
/* we have a one-point segment: this is a one-point */
/* contour with `in' and `out' direction set to */
/* AF_DIR_NONE */
segment->pos = (FT_Short)min_pos;
if (point->flags & AF_FLAG_CONTROL)
segment->flags |= AF_EDGE_ROUND;
segment->min_coord = (FT_Short)point->v;
segment->max_coord = (FT_Short)point->v;
segment->height = 0;
on_edge = 0;
segment = NULL;
}
}
point = point->next;
}
} /* contours */
/* now slightly increase the height of segments if this makes */
/* sense -- this is used to better detect and ignore serifs */
{
AF_Segment segments = axis->segments;
AF_Segment segments_end = FT_OFFSET( segments, axis->num_segments );
for ( segment = segments; segment < segments_end; segment++ )
{
AF_Point first = segment->first;
AF_Point last = segment->last;
FT_Pos first_v = first->v;
FT_Pos last_v = last->v;
if ( first_v < last_v )
{
AF_Point p;
p = first->prev;
if ( p->v < first_v )
segment->height = (FT_Short)( segment->height +
( ( first_v - p->v ) >> 1 ) );
p = last->next;
if ( p->v > last_v )
segment->height = (FT_Short)( segment->height +
( ( p->v - last_v ) >> 1 ) );
}
else
{
AF_Point p;
p = first->prev;
if ( p->v > first_v )
segment->height = (FT_Short)( segment->height +
( ( p->v - first_v ) >> 1 ) );
p = last->next;
if ( p->v < last_v )
segment->height = (FT_Short)( segment->height +
( ( last_v - p->v ) >> 1 ) );
}
}
}
Exit:
return error;
}
/* Link segments to form stems and serifs. If `width_count' and */
/* `widths' are non-zero, use them to fine-tune the scoring function. */
FT_LOCAL_DEF( void )
af_latin_hints_link_segments( AF_GlyphHints hints,
FT_UInt width_count,
AF_WidthRec* widths,
AF_Dimension dim )
{
AF_AxisHints axis = &hints->axis[dim];
AF_Segment segments = axis->segments;
AF_Segment segment_limit = FT_OFFSET( segments, axis->num_segments );
FT_Pos len_threshold, len_score, dist_score, max_width;
AF_Segment seg1, seg2;
if ( width_count )
max_width = widths[width_count - 1].org;
else
max_width = 0;
/* a heuristic value to set up a minimum value for overlapping */
len_threshold = AF_LATIN_CONSTANT( hints->metrics, 8 );
if ( len_threshold == 0 )
len_threshold = 1;
/* a heuristic value to weight lengths */
len_score = AF_LATIN_CONSTANT( hints->metrics, 6000 );
/* a heuristic value to weight distances (no call to */
/* AF_LATIN_CONSTANT needed, since we work on multiples */
/* of the stem width) */
dist_score = 3000;
/* now compare each segment to the others */
for ( seg1 = segments; seg1 < segment_limit; seg1++ )
{
if ( seg1->dir != axis->major_dir )
continue;
/* search for stems having opposite directions, */
/* with seg1 to the `left' of seg2 */
for ( seg2 = segments; seg2 < segment_limit; seg2++ )
{
FT_Pos pos1 = seg1->pos;
FT_Pos pos2 = seg2->pos;
if ( seg1->dir + seg2->dir == 0 && pos2 > pos1 )
{
/* compute distance between the two segments */
FT_Pos min = seg1->min_coord;
FT_Pos max = seg1->max_coord;
FT_Pos len;
if ( min < seg2->min_coord )
min = seg2->min_coord;
if ( max > seg2->max_coord )
max = seg2->max_coord;
/* compute maximum coordinate difference of the two segments */
/* (this is, how much they overlap) */
len = max - min;
if ( len >= len_threshold )
{
/*
* The score is the sum of two demerits indicating the
* `badness' of a fit, measured along the segments' main axis
* and orthogonal to it, respectively.
*
* - The less overlapping along the main axis, the worse it
* is, causing a larger demerit.
*
* - The nearer the orthogonal distance to a stem width, the
* better it is, causing a smaller demerit. For simplicity,
* however, we only increase the demerit for values that
* exceed the largest stem width.
*/
FT_Pos dist = pos2 - pos1;
FT_Pos dist_demerit, score;
if ( max_width )
{
/* distance demerits are based on multiples of `max_width'; */
/* we scale by 1024 for getting more precision */
FT_Pos delta = ( dist << 10 ) / max_width - ( 1 << 10 );
if ( delta > 10000 )
dist_demerit = 32000;
else if ( delta > 0 )
dist_demerit = delta * delta / dist_score;
else
dist_demerit = 0;
}
else
dist_demerit = dist; /* default if no widths available */
score = dist_demerit + len_score / len;
/* and we search for the smallest score */
if ( score < seg1->score )
{
seg1->score = score;
seg1->link = seg2;
}
if ( score < seg2->score )
{
seg2->score = score;
seg2->link = seg1;
}
}
}
}
}
/* now compute the `serif' segments, cf. explanations in `afhints.h' */
for ( seg1 = segments; seg1 < segment_limit; seg1++ )
{
seg2 = seg1->link;
if ( seg2 )
{
if ( seg2->link != seg1 )
{
seg1->link = NULL;
seg1->serif = seg2->link;
}
}
}
}
/* Link segments to edges, using feature analysis for selection. */
FT_LOCAL_DEF( FT_Error )
af_latin_hints_compute_edges( AF_GlyphHints hints,
AF_Dimension dim )
{
AF_AxisHints axis = &hints->axis[dim];
FT_Error error = FT_Err_Ok;
FT_Memory memory = hints->memory;
AF_LatinAxis laxis = &((AF_LatinMetrics)hints->metrics)->axis[dim];
AF_StyleClass style_class = hints->metrics->style_class;
AF_ScriptClass script_class = af_script_classes[style_class->script];
FT_Bool top_to_bottom_hinting = 0;
AF_Segment segments = axis->segments;
AF_Segment segment_limit = FT_OFFSET( segments, axis->num_segments );
AF_Segment seg;
#if 0
AF_Direction up_dir;
#endif
FT_Fixed scale;
FT_Pos edge_distance_threshold;
FT_Pos segment_length_threshold;
FT_Pos segment_width_threshold;
axis->num_edges = 0;
scale = ( dim == AF_DIMENSION_HORZ ) ? hints->x_scale
: hints->y_scale;
#if 0
up_dir = ( dim == AF_DIMENSION_HORZ ) ? AF_DIR_UP
: AF_DIR_RIGHT;
#endif
if ( dim == AF_DIMENSION_VERT )
top_to_bottom_hinting = script_class->top_to_bottom_hinting;
/*
* We ignore all segments that are less than 1 pixel in length
* to avoid many problems with serif fonts. We compute the
* corresponding threshold in font units.
*/
if ( dim == AF_DIMENSION_HORZ )
segment_length_threshold = FT_DivFix( 64, hints->y_scale );
else
segment_length_threshold = 0;
/*
* Similarly, we ignore segments that have a width delta
* larger than 0.5px (i.e., a width larger than 1px).
*/
segment_width_threshold = FT_DivFix( 32, scale );
/**********************************************************************
*
* We begin by generating a sorted table of edges for the current
* direction. To do so, we simply scan each segment and try to find
* an edge in our table that corresponds to its position.
*
* If no edge is found, we create and insert a new edge in the
* sorted table. Otherwise, we simply add the segment to the edge's
* list which gets processed in the second step to compute the
* edge's properties.
*
* Note that the table of edges is sorted along the segment/edge
* position.
*
*/
/* assure that edge distance threshold is at most 0.25px */
edge_distance_threshold = FT_MulFix( laxis->edge_distance_threshold,
scale );
if ( edge_distance_threshold > 64 / 4 )
edge_distance_threshold = 64 / 4;
edge_distance_threshold = FT_DivFix( edge_distance_threshold,
scale );
for ( seg = segments; seg < segment_limit; seg++ )
{
AF_Edge found = NULL;
FT_Int ee;
/* ignore too short segments, too wide ones, and, in this loop, */
/* one-point segments without a direction */
if ( seg->height < segment_length_threshold ||
seg->delta > segment_width_threshold ||
seg->dir == AF_DIR_NONE )
continue;
/* A special case for serif edges: If they are smaller than */
/* 1.5 pixels we ignore them. */
if ( seg->serif &&
2 * seg->height < 3 * segment_length_threshold )
continue;
/* look for an edge corresponding to the segment */
for ( ee = 0; ee < axis->num_edges; ee++ )
{
AF_Edge edge = axis->edges + ee;
FT_Pos dist;
dist = seg->pos - edge->fpos;
if ( dist < 0 )
dist = -dist;
if ( dist < edge_distance_threshold && edge->dir == seg->dir )
{
found = edge;
break;
}
}
if ( !found )
{
AF_Edge edge;
/* insert a new edge in the list and */
/* sort according to the position */
error = af_axis_hints_new_edge( axis, seg->pos,
(AF_Direction)seg->dir,
top_to_bottom_hinting,
memory, &edge );
if ( error )
goto Exit;
/* add the segment to the new edge's list */
FT_ZERO( edge );
edge->first = seg;
edge->last = seg;
edge->dir = seg->dir;
edge->fpos = seg->pos;
edge->opos = FT_MulFix( seg->pos, scale );
edge->pos = edge->opos;
seg->edge_next = seg;
}
else
{
/* if an edge was found, simply add the segment to the edge's */
/* list */
seg->edge_next = found->first;
found->last->edge_next = seg;
found->last = seg;
}
}
/* we loop again over all segments to catch one-point segments */
/* without a direction: if possible, link them to existing edges */
for ( seg = segments; seg < segment_limit; seg++ )
{
AF_Edge found = NULL;
FT_Int ee;
if ( seg->dir != AF_DIR_NONE )
continue;
/* look for an edge corresponding to the segment */
for ( ee = 0; ee < axis->num_edges; ee++ )
{
AF_Edge edge = axis->edges + ee;
FT_Pos dist;
dist = seg->pos - edge->fpos;
if ( dist < 0 )
dist = -dist;
if ( dist < edge_distance_threshold )
{
found = edge;
break;
}
}
/* one-point segments without a match are ignored */
if ( found )
{
seg->edge_next = found->first;
found->last->edge_next = seg;
found->last = seg;
}
}
/*******************************************************************
*
* Good, we now compute each edge's properties according to the
* segments found on its position. Basically, these are
*
* - the edge's main direction
* - stem edge, serif edge or both (which defaults to stem then)
* - rounded edge, straight or both (which defaults to straight)
* - link for edge
*
*/
/* first of all, set the `edge' field in each segment -- this is */
/* required in order to compute edge links */
/*
* Note that removing this loop and setting the `edge' field of each
* segment directly in the code above slows down execution speed for
* some reasons on platforms like the Sun.
*/
{
AF_Edge edges = axis->edges;
AF_Edge edge_limit = FT_OFFSET( edges, axis->num_edges );
AF_Edge edge;
for ( edge = edges; edge < edge_limit; edge++ )
{
seg = edge->first;
if ( seg )
do
{
seg->edge = edge;
seg = seg->edge_next;
} while ( seg != edge->first );
}
/* now compute each edge properties */
for ( edge = edges; edge < edge_limit; edge++ )
{
FT_Int is_round = 0; /* does it contain round segments? */
FT_Int is_straight = 0; /* does it contain straight segments? */
#if 0
FT_Pos ups = 0; /* number of upwards segments */
FT_Pos downs = 0; /* number of downwards segments */
#endif
seg = edge->first;
do
{
FT_Bool is_serif;
/* check for roundness of segment */
if ( seg->flags & AF_EDGE_ROUND )
is_round++;
else
is_straight++;
#if 0
/* check for segment direction */
if ( seg->dir == up_dir )
ups += seg->max_coord - seg->min_coord;
else
downs += seg->max_coord - seg->min_coord;
#endif
/* check for links -- if seg->serif is set, then seg->link must */
/* be ignored */
is_serif = FT_BOOL( seg->serif &&
seg->serif->edge &&
seg->serif->edge != edge );
if ( ( seg->link && seg->link->edge ) || is_serif )
{
AF_Edge edge2;
AF_Segment seg2;
edge2 = edge->link;
seg2 = seg->link;
if ( is_serif )
{
seg2 = seg->serif;
edge2 = edge->serif;
}
if ( edge2 )
{
FT_Pos edge_delta;
FT_Pos seg_delta;
edge_delta = edge->fpos - edge2->fpos;
if ( edge_delta < 0 )
edge_delta = -edge_delta;
seg_delta = seg->pos - seg2->pos;
if ( seg_delta < 0 )
seg_delta = -seg_delta;
if ( seg_delta < edge_delta )
edge2 = seg2->edge;
}
else
edge2 = seg2->edge;
if ( is_serif )
{
edge->serif = edge2;
edge2->flags |= AF_EDGE_SERIF;
}
else
edge->link = edge2;
}
seg = seg->edge_next;
} while ( seg != edge->first );
/* set the round/straight flags */
edge->flags = AF_EDGE_NORMAL;
if ( is_round > 0 && is_round >= is_straight )
edge->flags |= AF_EDGE_ROUND;
#if 0
/* set the edge's main direction */
edge->dir = AF_DIR_NONE;
if ( ups > downs )
edge->dir = (FT_Char)up_dir;
else if ( ups < downs )
edge->dir = (FT_Char)-up_dir;
else if ( ups == downs )
edge->dir = 0; /* both up and down! */
#endif
/* get rid of serifs if link is set */
/* XXX: This gets rid of many unpleasant artefacts! */
/* Example: the `c' in cour.pfa at size 13 */
if ( edge->serif && edge->link )
edge->serif = NULL;
}
}
Exit:
return error;
}
/* Detect segments and edges for given dimension. */
FT_LOCAL_DEF( FT_Error )
af_latin_hints_detect_features( AF_GlyphHints hints,
FT_UInt width_count,
AF_WidthRec* widths,
AF_Dimension dim )
{
FT_Error error;
error = af_latin_hints_compute_segments( hints, dim );
if ( !error )
{
af_latin_hints_link_segments( hints, width_count, widths, dim );
error = af_latin_hints_compute_edges( hints, dim );
}
return error;
}
/* Compute all edges which lie within blue zones. */
static void
af_latin_hints_compute_blue_edges( AF_GlyphHints hints,
AF_LatinMetrics metrics )
{
AF_AxisHints axis = &hints->axis[AF_DIMENSION_VERT];
AF_Edge edge = axis->edges;
AF_Edge edge_limit = FT_OFFSET( edge, axis->num_edges );
AF_LatinAxis latin = &metrics->axis[AF_DIMENSION_VERT];
FT_Fixed scale = latin->scale;
/* compute which blue zones are active, i.e. have their scaled */
/* size < 3/4 pixels */
/* for each horizontal edge search the blue zone which is closest */
for ( ; edge < edge_limit; edge++ )
{
FT_UInt bb;
AF_Width best_blue = NULL;
FT_Bool best_blue_is_neutral = 0;
FT_Pos best_dist; /* initial threshold */
/* compute the initial threshold as a fraction of the EM size */
/* (the value 40 is heuristic) */
best_dist = FT_MulFix( metrics->units_per_em / 40, scale );
/* assure a minimum distance of 0.5px */
if ( best_dist > 64 / 2 )
best_dist = 64 / 2;
for ( bb = 0; bb < latin->blue_count; bb++ )
{
AF_LatinBlue blue = latin->blues + bb;
FT_Bool is_top_blue, is_neutral_blue, is_major_dir;
/* skip inactive blue zones (i.e., those that are too large) */
if ( !( blue->flags & AF_LATIN_BLUE_ACTIVE ) )
continue;
/* if it is a top zone, check for right edges (against the major */
/* direction); if it is a bottom zone, check for left edges (in */
/* the major direction) -- this assumes the TrueType convention */
/* for the orientation of contours */
is_top_blue =
(FT_Byte)( ( blue->flags & ( AF_LATIN_BLUE_TOP |
AF_LATIN_BLUE_SUB_TOP ) ) != 0 );
is_neutral_blue =
(FT_Byte)( ( blue->flags & AF_LATIN_BLUE_NEUTRAL ) != 0);
is_major_dir =
FT_BOOL( edge->dir == axis->major_dir );
/* neutral blue zones are handled for both directions */
if ( is_top_blue ^ is_major_dir || is_neutral_blue )
{
FT_Pos dist;
/* first of all, compare it to the reference position */
dist = edge->fpos - blue->ref.org;
if ( dist < 0 )
dist = -dist;
dist = FT_MulFix( dist, scale );
if ( dist < best_dist )
{
best_dist = dist;
best_blue = &blue->ref;
best_blue_is_neutral = is_neutral_blue;
}
/* now compare it to the overshoot position and check whether */
/* the edge is rounded, and whether the edge is over the */
/* reference position of a top zone, or under the reference */
/* position of a bottom zone (provided we don't have a */
/* neutral blue zone) */
if ( edge->flags & AF_EDGE_ROUND &&
dist != 0 &&
!is_neutral_blue )
{
FT_Bool is_under_ref = FT_BOOL( edge->fpos < blue->ref.org );
if ( is_top_blue ^ is_under_ref )
{
dist = edge->fpos - blue->shoot.org;
if ( dist < 0 )
dist = -dist;
dist = FT_MulFix( dist, scale );
if ( dist < best_dist )
{
best_dist = dist;
best_blue = &blue->shoot;
best_blue_is_neutral = is_neutral_blue;
}
}
}
}
}
if ( best_blue )
{
edge->blue_edge = best_blue;
if ( best_blue_is_neutral )
edge->flags |= AF_EDGE_NEUTRAL;
}
}
}
/* Initalize hinting engine. */
static FT_Error
af_latin_hints_init( AF_GlyphHints hints,
AF_LatinMetrics metrics )
{
FT_Render_Mode mode;
FT_UInt32 scaler_flags, other_flags;
FT_Face face = metrics->root.scaler.face;
af_glyph_hints_rescale( hints, (AF_StyleMetrics)metrics );
/*
* correct x_scale and y_scale if needed, since they may have
* been modified by `af_latin_metrics_scale_dim' above
*/
hints->x_scale = metrics->axis[AF_DIMENSION_HORZ].scale;
hints->x_delta = metrics->axis[AF_DIMENSION_HORZ].delta;
hints->y_scale = metrics->axis[AF_DIMENSION_VERT].scale;
hints->y_delta = metrics->axis[AF_DIMENSION_VERT].delta;
/* compute flags depending on render mode, etc. */
mode = metrics->root.scaler.render_mode;
scaler_flags = hints->scaler_flags;
other_flags = 0;
/*
* We snap the width of vertical stems for the monochrome and
* horizontal LCD rendering targets only.
*/
if ( mode == FT_RENDER_MODE_MONO || mode == FT_RENDER_MODE_LCD )
other_flags |= AF_LATIN_HINTS_HORZ_SNAP;
/*
* We snap the width of horizontal stems for the monochrome and
* vertical LCD rendering targets only.
*/
if ( mode == FT_RENDER_MODE_MONO || mode == FT_RENDER_MODE_LCD_V )
other_flags |= AF_LATIN_HINTS_VERT_SNAP;
/*
* We adjust stems to full pixels unless in `light' or `lcd' mode.
*/
if ( mode != FT_RENDER_MODE_LIGHT && mode != FT_RENDER_MODE_LCD )
other_flags |= AF_LATIN_HINTS_STEM_ADJUST;
if ( mode == FT_RENDER_MODE_MONO )
other_flags |= AF_LATIN_HINTS_MONO;
/*
* In `light' or `lcd' mode we disable horizontal hinting completely.
* We also do it if the face is italic.
*
* However, if warping is enabled (which only works in `light' hinting
* mode), advance widths get adjusted, too.
*/
if ( mode == FT_RENDER_MODE_LIGHT || mode == FT_RENDER_MODE_LCD ||
( face->style_flags & FT_STYLE_FLAG_ITALIC ) != 0 )
scaler_flags |= AF_SCALER_FLAG_NO_HORIZONTAL;
hints->scaler_flags = scaler_flags;
hints->other_flags = other_flags;
return FT_Err_Ok;
}
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** L A T I N G L Y P H G R I D - F I T T I N G *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
/* Snap a given width in scaled coordinates to one of the */
/* current standard widths. */
static FT_Pos
af_latin_snap_width( AF_Width widths,
FT_UInt count,
FT_Pos width )
{
FT_UInt n;
FT_Pos best = 64 + 32 + 2;
FT_Pos reference = width;
FT_Pos scaled;
for ( n = 0; n < count; n++ )
{
FT_Pos w;
FT_Pos dist;
w = widths[n].cur;
dist = width - w;
if ( dist < 0 )
dist = -dist;
if ( dist < best )
{
best = dist;
reference = w;
}
}
scaled = FT_PIX_ROUND( reference );
if ( width >= reference )
{
if ( width < scaled + 48 )
width = reference;
}
else
{
if ( width > scaled - 48 )
width = reference;
}
return width;
}
/* Compute the snapped width of a given stem, ignoring very thin ones. */
/* There is a lot of voodoo in this function; changing the hard-coded */
/* parameters influence the whole hinting process. */
static FT_Pos
af_latin_compute_stem_width( AF_GlyphHints hints,
AF_Dimension dim,
FT_Pos width,
FT_Pos base_delta,
FT_UInt base_flags,
FT_UInt stem_flags )
{
AF_LatinMetrics metrics = (AF_LatinMetrics)hints->metrics;
AF_LatinAxis axis = &metrics->axis[dim];
FT_Pos dist = width;
FT_Int sign = 0;
FT_Int vertical = ( dim == AF_DIMENSION_VERT );
if ( !AF_LATIN_HINTS_DO_STEM_ADJUST( hints ) ||
axis->extra_light )
return width;
if ( dist < 0 )
{
dist = -width;
sign = 1;
}
if ( ( vertical && !AF_LATIN_HINTS_DO_VERT_SNAP( hints ) ) ||
( !vertical && !AF_LATIN_HINTS_DO_HORZ_SNAP( hints ) ) )
{
/* smooth hinting process: very lightly quantize the stem width */
/* leave the widths of serifs alone */
if ( ( stem_flags & AF_EDGE_SERIF ) &&
vertical &&
( dist < 3 * 64 ) )
goto Done_Width;
else if ( base_flags & AF_EDGE_ROUND )
{
if ( dist < 80 )
dist = 64;
}
else if ( dist < 56 )
dist = 56;
if ( axis->width_count > 0 )
{
FT_Pos delta;
/* compare to standard width */
delta = dist - axis->widths[0].cur;
if ( delta < 0 )
delta = -delta;
if ( delta < 40 )
{
dist = axis->widths[0].cur;
if ( dist < 48 )
dist = 48;
goto Done_Width;
}
if ( dist < 3 * 64 )
{
delta = dist & 63;
dist &= -64;
if ( delta < 10 )
dist += delta;
else if ( delta < 32 )
dist += 10;
else if ( delta < 54 )
dist += 54;
else
dist += delta;
}
else
{
/* A stem's end position depends on two values: the start */
/* position and the stem length. The former gets usually */
/* rounded to the grid, while the latter gets rounded also if it */
/* exceeds a certain length (see below in this function). This */
/* `double rounding' can lead to a great difference to the */
/* original, unhinted position; this normally doesn't matter for */
/* large PPEM values, but for small sizes it can easily make */
/* outlines collide. For this reason, we adjust the stem length */
/* by a small amount depending on the PPEM value in case the */
/* former and latter rounding both point into the same */
/* direction. */
FT_Pos bdelta = 0;
if ( ( ( width > 0 ) && ( base_delta > 0 ) ) ||
( ( width < 0 ) && ( base_delta < 0 ) ) )
{
FT_UInt ppem = metrics->root.scaler.face->size->metrics.x_ppem;
if ( ppem < 10 )
bdelta = base_delta;
else if ( ppem < 30 )
bdelta = ( base_delta * (FT_Pos)( 30 - ppem ) ) / 20;
if ( bdelta < 0 )
bdelta = -bdelta;
}
dist = ( dist - bdelta + 32 ) & ~63;
}
}
}
else
{
/* strong hinting process: snap the stem width to integer pixels */
FT_Pos org_dist = dist;
dist = af_latin_snap_width( axis->widths, axis->width_count, dist );
if ( vertical )
{
/* in the case of vertical hinting, always round */
/* the stem heights to integer pixels */
if ( dist >= 64 )
dist = ( dist + 16 ) & ~63;
else
dist = 64;
}
else
{
if ( AF_LATIN_HINTS_DO_MONO( hints ) )
{
/* monochrome horizontal hinting: snap widths to integer pixels */
/* with a different threshold */
if ( dist < 64 )
dist = 64;
else
dist = ( dist + 32 ) & ~63;
}
else
{
/* for horizontal anti-aliased hinting, we adopt a more subtle */
/* approach: we strengthen small stems, round stems whose size */
/* is between 1 and 2 pixels to an integer, otherwise nothing */
if ( dist < 48 )
dist = ( dist + 64 ) >> 1;
else if ( dist < 128 )
{
/* We only round to an integer width if the corresponding */
/* distortion is less than 1/4 pixel. Otherwise this */
/* makes everything worse since the diagonals, which are */
/* not hinted, appear a lot bolder or thinner than the */
/* vertical stems. */
FT_Pos delta;
dist = ( dist + 22 ) & ~63;
delta = dist - org_dist;
if ( delta < 0 )
delta = -delta;
if ( delta >= 16 )
{
dist = org_dist;
if ( dist < 48 )
dist = ( dist + 64 ) >> 1;
}
}
else
/* round otherwise to prevent color fringes in LCD mode */
dist = ( dist + 32 ) & ~63;
}
}
}
Done_Width:
if ( sign )
dist = -dist;
return dist;
}
/* Align one stem edge relative to the previous stem edge. */
static void
af_latin_align_linked_edge( AF_GlyphHints hints,
AF_Dimension dim,
AF_Edge base_edge,
AF_Edge stem_edge )
{
FT_Pos dist, base_delta;
FT_Pos fitted_width;
dist = stem_edge->opos - base_edge->opos;
base_delta = base_edge->pos - base_edge->opos;
fitted_width = af_latin_compute_stem_width( hints, dim,
dist, base_delta,
base_edge->flags,
stem_edge->flags );
stem_edge->pos = base_edge->pos + fitted_width;
FT_TRACE5(( " LINK: edge %ld (opos=%.2f) linked to %.2f,"
" dist was %.2f, now %.2f\n",
stem_edge - hints->axis[dim].edges, stem_edge->opos / 64.0,
stem_edge->pos / 64.0, dist / 64.0, fitted_width / 64.0 ));
}
/* Shift the coordinates of the `serif' edge by the same amount */
/* as the corresponding `base' edge has been moved already. */
static void
af_latin_align_serif_edge( AF_GlyphHints hints,
AF_Edge base,
AF_Edge serif )
{
FT_UNUSED( hints );
serif->pos = base->pos + ( serif->opos - base->opos );
}
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/**** ****/
/**** E D G E H I N T I N G ****/
/**** ****/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/* The main grid-fitting routine. */
static void
af_latin_hint_edges( AF_GlyphHints hints,
AF_Dimension dim )
{
AF_AxisHints axis = &hints->axis[dim];
AF_Edge edges = axis->edges;
AF_Edge edge_limit = FT_OFFSET( edges, axis->num_edges );
FT_PtrDist n_edges;
AF_Edge edge;
AF_Edge anchor = NULL;
FT_Int has_serifs = 0;
AF_StyleClass style_class = hints->metrics->style_class;
AF_ScriptClass script_class = af_script_classes[style_class->script];
FT_Bool top_to_bottom_hinting = 0;
#ifdef FT_DEBUG_LEVEL_TRACE
FT_UInt num_actions = 0;
#endif
FT_TRACE5(( "latin %s edge hinting (style `%s')\n",
dim == AF_DIMENSION_VERT ? "horizontal" : "vertical",
af_style_names[hints->metrics->style_class->style] ));
if ( dim == AF_DIMENSION_VERT )
top_to_bottom_hinting = script_class->top_to_bottom_hinting;
/* we begin by aligning all stems relative to the blue zone */
/* if needed -- that's only for horizontal edges */
if ( dim == AF_DIMENSION_VERT && AF_HINTS_DO_BLUES( hints ) )
{
for ( edge = edges; edge < edge_limit; edge++ )
{
AF_Width blue;
AF_Edge edge1, edge2; /* these edges form the stem to check */
if ( edge->flags & AF_EDGE_DONE )
continue;
edge1 = NULL;
edge2 = edge->link;
/*
* If a stem contains both a neutral and a non-neutral blue zone,
* skip the neutral one. Otherwise, outlines with different
* directions might be incorrectly aligned at the same vertical
* position.
*
* If we have two neutral blue zones, skip one of them.
*
*/
if ( edge->blue_edge && edge2 && edge2->blue_edge )
{
FT_Byte neutral = edge->flags & AF_EDGE_NEUTRAL;
FT_Byte neutral2 = edge2->flags & AF_EDGE_NEUTRAL;
if ( neutral2 )
{
edge2->blue_edge = NULL;
edge2->flags &= ~AF_EDGE_NEUTRAL;
}
else if ( neutral )
{
edge->blue_edge = NULL;
edge->flags &= ~AF_EDGE_NEUTRAL;
}
}
blue = edge->blue_edge;
if ( blue )
edge1 = edge;
/* flip edges if the other edge is aligned to a blue zone */
else if ( edge2 && edge2->blue_edge )
{
blue = edge2->blue_edge;
edge1 = edge2;
edge2 = edge;
}
if ( !edge1 )
continue;
#ifdef FT_DEBUG_LEVEL_TRACE
if ( !anchor )
FT_TRACE5(( " BLUE_ANCHOR: edge %ld (opos=%.2f) snapped to %.2f,"
" was %.2f (anchor=edge %ld)\n",
edge1 - edges, edge1->opos / 64.0, blue->fit / 64.0,
edge1->pos / 64.0, edge - edges ));
else
FT_TRACE5(( " BLUE: edge %ld (opos=%.2f) snapped to %.2f,"
" was %.2f\n",
edge1 - edges, edge1->opos / 64.0, blue->fit / 64.0,
edge1->pos / 64.0 ));
num_actions++;
#endif
edge1->pos = blue->fit;
edge1->flags |= AF_EDGE_DONE;
if ( edge2 && !edge2->blue_edge )
{
af_latin_align_linked_edge( hints, dim, edge1, edge2 );
edge2->flags |= AF_EDGE_DONE;
#ifdef FT_DEBUG_LEVEL_TRACE
num_actions++;
#endif
}
if ( !anchor )
anchor = edge;
}
}
/* now we align all other stem edges, trying to maintain the */
/* relative order of stems in the glyph */
for ( edge = edges; edge < edge_limit; edge++ )
{
AF_Edge edge2;
if ( edge->flags & AF_EDGE_DONE )
continue;
/* skip all non-stem edges */
edge2 = edge->link;
if ( !edge2 )
{
has_serifs++;
continue;
}
/* now align the stem */
/* this should not happen, but it's better to be safe */
if ( edge2->blue_edge )
{
FT_TRACE5(( " ASSERTION FAILED for edge %ld\n", edge2 - edges ));
af_latin_align_linked_edge( hints, dim, edge2, edge );
edge->flags |= AF_EDGE_DONE;
#ifdef FT_DEBUG_LEVEL_TRACE
num_actions++;
#endif
continue;
}
if ( !anchor )
{
/* if we reach this if clause, no stem has been aligned yet */
FT_Pos org_len, org_center, cur_len;
FT_Pos cur_pos1, error1, error2, u_off, d_off;
org_len = edge2->opos - edge->opos;
cur_len = af_latin_compute_stem_width( hints, dim,
org_len, 0,
edge->flags,
edge2->flags );
/* some voodoo to specially round edges for small stem widths; */
/* the idea is to align the center of a stem, then shifting */
/* the stem edges to suitable positions */
if ( cur_len <= 64 )
{
/* width <= 1px */
u_off = 32;
d_off = 32;
}
else
{
/* 1px < width < 1.5px */
u_off = 38;
d_off = 26;
}
if ( cur_len < 96 )
{
org_center = edge->opos + ( org_len >> 1 );
cur_pos1 = FT_PIX_ROUND( org_center );
error1 = org_center - ( cur_pos1 - u_off );
if ( error1 < 0 )
error1 = -error1;
error2 = org_center - ( cur_pos1 + d_off );
if ( error2 < 0 )
error2 = -error2;
if ( error1 < error2 )
cur_pos1 -= u_off;
else
cur_pos1 += d_off;
edge->pos = cur_pos1 - cur_len / 2;
edge2->pos = edge->pos + cur_len;
}
else
edge->pos = FT_PIX_ROUND( edge->opos );
anchor = edge;
edge->flags |= AF_EDGE_DONE;
FT_TRACE5(( " ANCHOR: edge %ld (opos=%.2f) and %ld (opos=%.2f)"
" snapped to %.2f and %.2f\n",
edge - edges, edge->opos / 64.0,
edge2 - edges, edge2->opos / 64.0,
edge->pos / 64.0, edge2->pos / 64.0 ));
af_latin_align_linked_edge( hints, dim, edge, edge2 );
#ifdef FT_DEBUG_LEVEL_TRACE
num_actions += 2;
#endif
}
else
{
FT_Pos org_pos, org_len, org_center, cur_len;
FT_Pos cur_pos1, cur_pos2, delta1, delta2;
org_pos = anchor->pos + ( edge->opos - anchor->opos );
org_len = edge2->opos - edge->opos;
org_center = org_pos + ( org_len >> 1 );
cur_len = af_latin_compute_stem_width( hints, dim,
org_len, 0,
edge->flags,
edge2->flags );
if ( edge2->flags & AF_EDGE_DONE )
{
FT_TRACE5(( " ADJUST: edge %ld (pos=%.2f) moved to %.2f\n",
edge - edges, edge->pos / 64.0,
( edge2->pos - cur_len ) / 64.0 ));
edge->pos = edge2->pos - cur_len;
}
else if ( cur_len < 96 )
{
FT_Pos u_off, d_off;
cur_pos1 = FT_PIX_ROUND( org_center );
if ( cur_len <= 64 )
{
u_off = 32;
d_off = 32;
}
else
{
u_off = 38;
d_off = 26;
}
delta1 = org_center - ( cur_pos1 - u_off );
if ( delta1 < 0 )
delta1 = -delta1;
delta2 = org_center - ( cur_pos1 + d_off );
if ( delta2 < 0 )
delta2 = -delta2;
if ( delta1 < delta2 )
cur_pos1 -= u_off;
else
cur_pos1 += d_off;
edge->pos = cur_pos1 - cur_len / 2;
edge2->pos = cur_pos1 + cur_len / 2;
FT_TRACE5(( " STEM: edge %ld (opos=%.2f) linked to %ld (opos=%.2f)"
" snapped to %.2f and %.2f\n",
edge - edges, edge->opos / 64.0,
edge2 - edges, edge2->opos / 64.0,
edge->pos / 64.0, edge2->pos / 64.0 ));
}
else
{
org_pos = anchor->pos + ( edge->opos - anchor->opos );
org_len = edge2->opos - edge->opos;
org_center = org_pos + ( org_len >> 1 );
cur_len = af_latin_compute_stem_width( hints, dim,
org_len, 0,
edge->flags,
edge2->flags );
cur_pos1 = FT_PIX_ROUND( org_pos );
delta1 = cur_pos1 + ( cur_len >> 1 ) - org_center;
if ( delta1 < 0 )
delta1 = -delta1;
cur_pos2 = FT_PIX_ROUND( org_pos + org_len ) - cur_len;
delta2 = cur_pos2 + ( cur_len >> 1 ) - org_center;
if ( delta2 < 0 )
delta2 = -delta2;
edge->pos = ( delta1 < delta2 ) ? cur_pos1 : cur_pos2;
edge2->pos = edge->pos + cur_len;
FT_TRACE5(( " STEM: edge %ld (opos=%.2f) linked to %ld (opos=%.2f)"
" snapped to %.2f and %.2f\n",
edge - edges, edge->opos / 64.0,
edge2 - edges, edge2->opos / 64.0,
edge->pos / 64.0, edge2->pos / 64.0 ));
}
#ifdef FT_DEBUG_LEVEL_TRACE
num_actions++;
#endif
edge->flags |= AF_EDGE_DONE;
edge2->flags |= AF_EDGE_DONE;
if ( edge > edges &&
( top_to_bottom_hinting ? ( edge->pos > edge[-1].pos )
: ( edge->pos < edge[-1].pos ) ) )
{
/* don't move if stem would (almost) disappear otherwise; */
/* the ad-hoc value 16 corresponds to 1/4px */
if ( edge->link && FT_ABS( edge->link->pos - edge[-1].pos ) > 16 )
{
#ifdef FT_DEBUG_LEVEL_TRACE
FT_TRACE5(( " BOUND: edge %ld (pos=%.2f) moved to %.2f\n",
edge - edges,
edge->pos / 64.0,
edge[-1].pos / 64.0 ));
num_actions++;
#endif
edge->pos = edge[-1].pos;
}
}
}
}
/* make sure that lowercase m's maintain their symmetry */
/* In general, lowercase m's have six vertical edges if they are sans */
/* serif, or twelve if they are with serifs. This implementation is */
/* based on that assumption, and seems to work very well with most */
/* faces. However, if for a certain face this assumption is not */
/* true, the m is just rendered like before. In addition, any stem */
/* correction will only be applied to symmetrical glyphs (even if the */
/* glyph is not an m), so the potential for unwanted distortion is */
/* relatively low. */
/* We don't handle horizontal edges since we can't easily assure that */
/* the third (lowest) stem aligns with the base line; it might end up */
/* one pixel higher or lower. */
n_edges = edge_limit - edges;
if ( dim == AF_DIMENSION_HORZ && ( n_edges == 6 || n_edges == 12 ) )
{
AF_Edge edge1, edge2, edge3;
FT_Pos dist1, dist2, span, delta;
if ( n_edges == 6 )
{
edge1 = edges;
edge2 = edges + 2;
edge3 = edges + 4;
}
else
{
edge1 = edges + 1;
edge2 = edges + 5;
edge3 = edges + 9;
}
dist1 = edge2->opos - edge1->opos;
dist2 = edge3->opos - edge2->opos;
span = dist1 - dist2;
if ( span < 0 )
span = -span;
if ( span < 8 )
{
delta = edge3->pos - ( 2 * edge2->pos - edge1->pos );
edge3->pos -= delta;
if ( edge3->link )
edge3->link->pos -= delta;
/* move the serifs along with the stem */
if ( n_edges == 12 )
{
( edges + 8 )->pos -= delta;
( edges + 11 )->pos -= delta;
}
edge3->flags |= AF_EDGE_DONE;
if ( edge3->link )
edge3->link->flags |= AF_EDGE_DONE;
}
}
if ( has_serifs || !anchor )
{
/*
* now hint the remaining edges (serifs and single) in order
* to complete our processing
*/
for ( edge = edges; edge < edge_limit; edge++ )
{
FT_Pos delta;
if ( edge->flags & AF_EDGE_DONE )
continue;
delta = 1000;
if ( edge->serif )
{
delta = edge->serif->opos - edge->opos;
if ( delta < 0 )
delta = -delta;
}
if ( delta < 64 + 16 )
{
af_latin_align_serif_edge( hints, edge->serif, edge );
FT_TRACE5(( " SERIF: edge %ld (opos=%.2f) serif to %ld (opos=%.2f)"
" aligned to %.2f\n",
edge - edges, edge->opos / 64.0,
edge->serif - edges, edge->serif->opos / 64.0,
edge->pos / 64.0 ));
}
else if ( !anchor )
{
edge->pos = FT_PIX_ROUND( edge->opos );
anchor = edge;
FT_TRACE5(( " SERIF_ANCHOR: edge %ld (opos=%.2f)"
" snapped to %.2f\n",
edge-edges, edge->opos / 64.0, edge->pos / 64.0 ));
}
else
{
AF_Edge before, after;
for ( before = edge - 1; before >= edges; before-- )
if ( before->flags & AF_EDGE_DONE )
break;
for ( after = edge + 1; after < edge_limit; after++ )
if ( after->flags & AF_EDGE_DONE )
break;
if ( before >= edges && before < edge &&
after < edge_limit && after > edge )
{
if ( after->opos == before->opos )
edge->pos = before->pos;
else
edge->pos = before->pos +
FT_MulDiv( edge->opos - before->opos,
after->pos - before->pos,
after->opos - before->opos );
FT_TRACE5(( " SERIF_LINK1: edge %ld (opos=%.2f) snapped to %.2f"
" from %ld (opos=%.2f)\n",
edge - edges, edge->opos / 64.0,
edge->pos / 64.0,
before - edges, before->opos / 64.0 ));
}
else
{
edge->pos = anchor->pos +
( ( edge->opos - anchor->opos + 16 ) & ~31 );
FT_TRACE5(( " SERIF_LINK2: edge %ld (opos=%.2f)"
" snapped to %.2f\n",
edge - edges, edge->opos / 64.0, edge->pos / 64.0 ));
}
}
#ifdef FT_DEBUG_LEVEL_TRACE
num_actions++;
#endif
edge->flags |= AF_EDGE_DONE;
if ( edge > edges &&
( top_to_bottom_hinting ? ( edge->pos > edge[-1].pos )
: ( edge->pos < edge[-1].pos ) ) )
{
/* don't move if stem would (almost) disappear otherwise; */
/* the ad-hoc value 16 corresponds to 1/4px */
if ( edge->link && FT_ABS( edge->link->pos - edge[-1].pos ) > 16 )
{
#ifdef FT_DEBUG_LEVEL_TRACE
FT_TRACE5(( " BOUND: edge %ld (pos=%.2f) moved to %.2f\n",
edge - edges,
edge->pos / 64.0,
edge[-1].pos / 64.0 ));
num_actions++;
#endif
edge->pos = edge[-1].pos;
}
}
if ( edge + 1 < edge_limit &&
edge[1].flags & AF_EDGE_DONE &&
( top_to_bottom_hinting ? ( edge->pos < edge[1].pos )
: ( edge->pos > edge[1].pos ) ) )
{
/* don't move if stem would (almost) disappear otherwise; */
/* the ad-hoc value 16 corresponds to 1/4px */
if ( edge->link && FT_ABS( edge->link->pos - edge[-1].pos ) > 16 )
{
#ifdef FT_DEBUG_LEVEL_TRACE
FT_TRACE5(( " BOUND: edge %ld (pos=%.2f) moved to %.2f\n",
edge - edges,
edge->pos / 64.0,
edge[1].pos / 64.0 ));
num_actions++;
#endif
edge->pos = edge[1].pos;
}
}
}
}
#ifdef FT_DEBUG_LEVEL_TRACE
if ( !num_actions )
FT_TRACE5(( " (none)\n" ));
FT_TRACE5(( "\n" ));
#endif
}
/* Apply the complete hinting algorithm to a latin glyph. */
static FT_Error
af_latin_hints_apply( FT_UInt glyph_index,
AF_GlyphHints hints,
FT_Outline* outline,
AF_LatinMetrics metrics )
{
FT_Error error;
int dim;
AF_LatinAxis axis;
error = af_glyph_hints_reload( hints, outline );
if ( error )
goto Exit;
/* analyze glyph outline */
if ( AF_HINTS_DO_HORIZONTAL( hints ) )
{
axis = &metrics->axis[AF_DIMENSION_HORZ];
error = af_latin_hints_detect_features( hints,
axis->width_count,
axis->widths,
AF_DIMENSION_HORZ );
if ( error )
goto Exit;
}
if ( AF_HINTS_DO_VERTICAL( hints ) )
{
axis = &metrics->axis[AF_DIMENSION_VERT];
error = af_latin_hints_detect_features( hints,
axis->width_count,
axis->widths,
AF_DIMENSION_VERT );
if ( error )
goto Exit;
/* apply blue zones to base characters only */
if ( !( metrics->root.globals->glyph_styles[glyph_index] & AF_NONBASE ) )
af_latin_hints_compute_blue_edges( hints, metrics );
}
/* grid-fit the outline */
for ( dim = 0; dim < AF_DIMENSION_MAX; dim++ )
{
if ( ( dim == AF_DIMENSION_HORZ && AF_HINTS_DO_HORIZONTAL( hints ) ) ||
( dim == AF_DIMENSION_VERT && AF_HINTS_DO_VERTICAL( hints ) ) )
{
af_latin_hint_edges( hints, (AF_Dimension)dim );
af_glyph_hints_align_edge_points( hints, (AF_Dimension)dim );
af_glyph_hints_align_strong_points( hints, (AF_Dimension)dim );
af_glyph_hints_align_weak_points( hints, (AF_Dimension)dim );
}
}
af_glyph_hints_save( hints, outline );
Exit:
return error;
}
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** L A T I N S C R I P T C L A S S *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
AF_DEFINE_WRITING_SYSTEM_CLASS(
af_latin_writing_system_class,
AF_WRITING_SYSTEM_LATIN,
sizeof ( AF_LatinMetricsRec ),
(AF_WritingSystem_InitMetricsFunc) af_latin_metrics_init, /* style_metrics_init */
(AF_WritingSystem_ScaleMetricsFunc)af_latin_metrics_scale, /* style_metrics_scale */
(AF_WritingSystem_DoneMetricsFunc) NULL, /* style_metrics_done */
(AF_WritingSystem_GetStdWidthsFunc)af_latin_get_standard_widths, /* style_metrics_getstdw */
(AF_WritingSystem_InitHintsFunc) af_latin_hints_init, /* style_hints_init */
(AF_WritingSystem_ApplyHintsFunc) af_latin_hints_apply /* style_hints_apply */
)
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/autofit/aflatin.c
|
C++
|
gpl-3.0
| 113,147
|
/****************************************************************************
*
* aflatin.h
*
* Auto-fitter hinting routines for latin writing system
* (specification).
*
* Copyright (C) 2003-2022 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 AFLATIN_H_
#define AFLATIN_H_
#include "afhints.h"
FT_BEGIN_HEADER
/* the `latin' writing system */
AF_DECLARE_WRITING_SYSTEM_CLASS( af_latin_writing_system_class )
/* constants are given with units_per_em == 2048 in mind */
#define AF_LATIN_CONSTANT( metrics, c ) \
( ( (c) * (FT_Long)( (AF_LatinMetrics)(metrics) )->units_per_em ) / 2048 )
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** L A T I N G L O B A L M E T R I C S *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
/*
* The following declarations could be embedded in the file `aflatin.c';
* they have been made semi-public to allow alternate writing system
* hinters to re-use some of them.
*/
#define AF_LATIN_IS_TOP_BLUE( b ) \
( (b)->properties & AF_BLUE_PROPERTY_LATIN_TOP )
#define AF_LATIN_IS_SUB_TOP_BLUE( b ) \
( (b)->properties & AF_BLUE_PROPERTY_LATIN_SUB_TOP )
#define AF_LATIN_IS_NEUTRAL_BLUE( b ) \
( (b)->properties & AF_BLUE_PROPERTY_LATIN_NEUTRAL )
#define AF_LATIN_IS_X_HEIGHT_BLUE( b ) \
( (b)->properties & AF_BLUE_PROPERTY_LATIN_X_HEIGHT )
#define AF_LATIN_IS_LONG_BLUE( b ) \
( (b)->properties & AF_BLUE_PROPERTY_LATIN_LONG )
#define AF_LATIN_MAX_WIDTHS 16
#define AF_LATIN_BLUE_ACTIVE ( 1U << 0 ) /* zone height is <= 3/4px */
#define AF_LATIN_BLUE_TOP ( 1U << 1 ) /* we have a top blue zone */
#define AF_LATIN_BLUE_SUB_TOP ( 1U << 2 ) /* we have a subscript top */
/* blue zone */
#define AF_LATIN_BLUE_NEUTRAL ( 1U << 3 ) /* we have neutral blue zone */
#define AF_LATIN_BLUE_ADJUSTMENT ( 1U << 4 ) /* used for scale adjustment */
/* optimization */
typedef struct AF_LatinBlueRec_
{
AF_WidthRec ref;
AF_WidthRec shoot;
FT_Pos ascender;
FT_Pos descender;
FT_UInt flags;
} AF_LatinBlueRec, *AF_LatinBlue;
typedef struct AF_LatinAxisRec_
{
FT_Fixed scale;
FT_Pos delta;
FT_UInt width_count; /* number of used widths */
AF_WidthRec widths[AF_LATIN_MAX_WIDTHS]; /* widths array */
FT_Pos edge_distance_threshold; /* used for creating edges */
FT_Pos standard_width; /* the default stem thickness */
FT_Bool extra_light; /* is standard width very light? */
/* ignored for horizontal metrics */
FT_UInt blue_count;
AF_LatinBlueRec blues[AF_BLUE_STRINGSET_MAX];
FT_Fixed org_scale;
FT_Pos org_delta;
} AF_LatinAxisRec, *AF_LatinAxis;
typedef struct AF_LatinMetricsRec_
{
AF_StyleMetricsRec root;
FT_UInt units_per_em;
AF_LatinAxisRec axis[AF_DIMENSION_MAX];
} AF_LatinMetricsRec, *AF_LatinMetrics;
FT_LOCAL( FT_Error )
af_latin_metrics_init( AF_LatinMetrics metrics,
FT_Face face );
FT_LOCAL( void )
af_latin_metrics_scale( AF_LatinMetrics metrics,
AF_Scaler scaler );
FT_LOCAL( void )
af_latin_metrics_init_widths( AF_LatinMetrics metrics,
FT_Face face );
FT_LOCAL( void )
af_latin_metrics_check_digits( AF_LatinMetrics metrics,
FT_Face face );
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** L A T I N G L Y P H A N A L Y S I S *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
#define AF_LATIN_HINTS_HORZ_SNAP ( 1U << 0 ) /* stem width snapping */
#define AF_LATIN_HINTS_VERT_SNAP ( 1U << 1 ) /* stem height snapping */
#define AF_LATIN_HINTS_STEM_ADJUST ( 1U << 2 ) /* stem width/height */
/* adjustment */
#define AF_LATIN_HINTS_MONO ( 1U << 3 ) /* monochrome rendering */
#define AF_LATIN_HINTS_DO_HORZ_SNAP( h ) \
AF_HINTS_TEST_OTHER( h, AF_LATIN_HINTS_HORZ_SNAP )
#define AF_LATIN_HINTS_DO_VERT_SNAP( h ) \
AF_HINTS_TEST_OTHER( h, AF_LATIN_HINTS_VERT_SNAP )
#define AF_LATIN_HINTS_DO_STEM_ADJUST( h ) \
AF_HINTS_TEST_OTHER( h, AF_LATIN_HINTS_STEM_ADJUST )
#define AF_LATIN_HINTS_DO_MONO( h ) \
AF_HINTS_TEST_OTHER( h, AF_LATIN_HINTS_MONO )
/*
* The next functions shouldn't normally be exported. However, other
* writing systems might like to use these functions as-is.
*/
FT_LOCAL( FT_Error )
af_latin_hints_compute_segments( AF_GlyphHints hints,
AF_Dimension dim );
FT_LOCAL( void )
af_latin_hints_link_segments( AF_GlyphHints hints,
FT_UInt width_count,
AF_WidthRec* widths,
AF_Dimension dim );
FT_LOCAL( FT_Error )
af_latin_hints_compute_edges( AF_GlyphHints hints,
AF_Dimension dim );
FT_LOCAL( FT_Error )
af_latin_hints_detect_features( AF_GlyphHints hints,
FT_UInt width_count,
AF_WidthRec* widths,
AF_Dimension dim );
/* */
FT_END_HEADER
#endif /* AFLATIN_H_ */
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/autofit/aflatin.h
|
C++
|
gpl-3.0
| 6,784
|
/****************************************************************************
*
* afloader.c
*
* Auto-fitter glyph loading routines (body).
*
* Copyright (C) 2003-2022 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.
*
*/
#include "afglobal.h"
#include "afloader.h"
#include "afhints.h"
#include "aferrors.h"
#include "afmodule.h"
#include <freetype/internal/ftcalc.h>
/* Initialize glyph loader. */
FT_LOCAL_DEF( void )
af_loader_init( AF_Loader loader,
AF_GlyphHints hints )
{
FT_ZERO( loader );
loader->hints = hints;
}
/* Reset glyph loader and compute globals if necessary. */
FT_LOCAL_DEF( FT_Error )
af_loader_reset( AF_Loader loader,
AF_Module module,
FT_Face face )
{
FT_Error error = FT_Err_Ok;
loader->face = face;
loader->globals = (AF_FaceGlobals)face->autohint.data;
if ( !loader->globals )
{
error = af_face_globals_new( face, &loader->globals, module );
if ( !error )
{
face->autohint.data =
(FT_Pointer)loader->globals;
face->autohint.finalizer =
(FT_Generic_Finalizer)af_face_globals_free;
}
}
return error;
}
/* Finalize glyph loader. */
FT_LOCAL_DEF( void )
af_loader_done( AF_Loader loader )
{
loader->face = NULL;
loader->globals = NULL;
loader->hints = NULL;
}
#define af_intToFixed( i ) \
( (FT_Fixed)( (FT_UInt32)(i) << 16 ) )
#define af_fixedToInt( x ) \
( (FT_Short)( ( (FT_UInt32)(x) + 0x8000U ) >> 16 ) )
#define af_floatToFixed( f ) \
( (FT_Fixed)( (f) * 65536.0 + 0.5 ) )
static FT_Error
af_loader_embolden_glyph_in_slot( AF_Loader loader,
FT_Face face,
AF_StyleMetrics style_metrics )
{
FT_Error error = FT_Err_Ok;
FT_GlyphSlot slot = face->glyph;
AF_FaceGlobals globals = loader->globals;
AF_WritingSystemClass writing_system_class;
FT_Size_Metrics* size_metrics = &face->size->internal->autohint_metrics;
FT_Pos stdVW = 0;
FT_Pos stdHW = 0;
FT_Bool size_changed = size_metrics->x_ppem !=
globals->stem_darkening_for_ppem;
FT_Fixed em_size = af_intToFixed( face->units_per_EM );
FT_Matrix scale_down_matrix = { 0x10000L, 0, 0, 0x10000L };
/* Skip stem darkening for broken fonts. */
if ( !face->units_per_EM )
{
error = FT_ERR( Corrupted_Font_Header );
goto Exit;
}
/*
* We depend on the writing system (script analyzers) to supply
* standard widths for the script of the glyph we are looking at. If
* it can't deliver, stem darkening is disabled.
*/
writing_system_class =
af_writing_system_classes[style_metrics->style_class->writing_system];
if ( writing_system_class->style_metrics_getstdw )
writing_system_class->style_metrics_getstdw( style_metrics,
&stdHW,
&stdVW );
else
{
error = FT_ERR( Unimplemented_Feature );
goto Exit;
}
if ( size_changed ||
( stdVW > 0 && stdVW != globals->standard_vertical_width ) )
{
FT_Fixed darken_by_font_units_x, darken_x;
darken_by_font_units_x =
af_loader_compute_darkening( loader,
face,
stdVW ) ;
darken_x = FT_MulFix( darken_by_font_units_x,
size_metrics->x_scale );
globals->standard_vertical_width = stdVW;
globals->stem_darkening_for_ppem = size_metrics->x_ppem;
globals->darken_x = af_fixedToInt( darken_x );
}
if ( size_changed ||
( stdHW > 0 && stdHW != globals->standard_horizontal_width ) )
{
FT_Fixed darken_by_font_units_y, darken_y;
darken_by_font_units_y =
af_loader_compute_darkening( loader,
face,
stdHW ) ;
darken_y = FT_MulFix( darken_by_font_units_y,
size_metrics->y_scale );
globals->standard_horizontal_width = stdHW;
globals->stem_darkening_for_ppem = size_metrics->x_ppem;
globals->darken_y = af_fixedToInt( darken_y );
/*
* Scale outlines down on the Y-axis to keep them inside their blue
* zones. The stronger the emboldening, the stronger the downscaling
* (plus heuristical padding to prevent outlines still falling out
* their zones due to rounding).
*
* Reason: `FT_Outline_Embolden' works by shifting the rightmost
* points of stems farther to the right, and topmost points farther
* up. This positions points on the Y-axis outside their
* pre-computed blue zones and leads to distortion when applying the
* hints in the code further below. Code outside this emboldening
* block doesn't know we are presenting it with modified outlines the
* analyzer didn't see!
*
* An unfortunate side effect of downscaling is that the emboldening
* effect is slightly decreased. The loss becomes more pronounced
* versus the CFF driver at smaller sizes, e.g., at 9ppem and below.
*/
globals->scale_down_factor =
FT_DivFix( em_size - ( darken_by_font_units_y + af_intToFixed( 8 ) ),
em_size );
}
FT_Outline_EmboldenXY( &slot->outline,
globals->darken_x,
globals->darken_y );
scale_down_matrix.yy = globals->scale_down_factor;
FT_Outline_Transform( &slot->outline, &scale_down_matrix );
Exit:
return error;
}
/* Load the glyph at index into the current slot of a face and hint it. */
FT_LOCAL_DEF( FT_Error )
af_loader_load_glyph( AF_Loader loader,
AF_Module module,
FT_Face face,
FT_UInt glyph_index,
FT_Int32 load_flags )
{
FT_Error error;
FT_Size size = face->size;
FT_Size_Internal size_internal = size->internal;
FT_GlyphSlot slot = face->glyph;
FT_Slot_Internal slot_internal = slot->internal;
FT_GlyphLoader gloader = slot_internal->loader;
AF_GlyphHints hints = loader->hints;
AF_ScalerRec scaler;
AF_StyleMetrics style_metrics;
FT_UInt style_options = AF_STYLE_NONE_DFLT;
AF_StyleClass style_class;
AF_WritingSystemClass writing_system_class;
if ( !size )
return FT_THROW( Invalid_Size_Handle );
FT_ZERO( &scaler );
if ( !size_internal->autohint_metrics.x_scale ||
size_internal->autohint_mode != FT_LOAD_TARGET_MODE( load_flags ) )
{
/* switching between hinting modes usually means different scaling */
/* values; this later on enforces recomputation of everything */
/* related to the current size */
size_internal->autohint_mode = FT_LOAD_TARGET_MODE( load_flags );
size_internal->autohint_metrics = size->metrics;
#ifdef AF_CONFIG_OPTION_TT_SIZE_METRICS
{
FT_Size_Metrics* size_metrics = &size_internal->autohint_metrics;
/* set metrics to integer values and adjust scaling accordingly; */
/* this is the same setup as with TrueType fonts, cf. function */
/* `tt_size_reset' in file `ttobjs.c' */
size_metrics->ascender = FT_PIX_ROUND(
FT_MulFix( face->ascender,
size_metrics->y_scale ) );
size_metrics->descender = FT_PIX_ROUND(
FT_MulFix( face->descender,
size_metrics->y_scale ) );
size_metrics->height = FT_PIX_ROUND(
FT_MulFix( face->height,
size_metrics->y_scale ) );
size_metrics->x_scale = FT_DivFix( size_metrics->x_ppem << 6,
face->units_per_EM );
size_metrics->y_scale = FT_DivFix( size_metrics->y_ppem << 6,
face->units_per_EM );
size_metrics->max_advance = FT_PIX_ROUND(
FT_MulFix( face->max_advance_width,
size_metrics->x_scale ) );
}
#endif /* AF_CONFIG_OPTION_TT_SIZE_METRICS */
}
/*
* TODO: This code currently doesn't support fractional advance widths,
* i.e., placing hinted glyphs at anything other than integer
* x-positions. This is only relevant for the warper code, which
* scales and shifts glyphs to optimize blackness of stems (hinting on
* the x-axis by nature places things on pixel integers, hinting on the
* y-axis only, i.e., LIGHT mode, doesn't touch the x-axis). The delta
* values of the scaler would need to be adjusted.
*/
scaler.face = face;
scaler.x_scale = size_internal->autohint_metrics.x_scale;
scaler.x_delta = 0;
scaler.y_scale = size_internal->autohint_metrics.y_scale;
scaler.y_delta = 0;
scaler.render_mode = FT_LOAD_TARGET_MODE( load_flags );
scaler.flags = 0;
/* note that the fallback style can't be changed anymore */
/* after the first call of `af_loader_load_glyph' */
error = af_loader_reset( loader, module, face );
if ( error )
goto Exit;
/*
* Glyphs (really code points) are assigned to scripts. Script
* analysis is done lazily: For each glyph that passes through here,
* the corresponding script analyzer is called, but returns immediately
* if it has been run already.
*/
error = af_face_globals_get_metrics( loader->globals, glyph_index,
style_options, &style_metrics );
if ( error )
goto Exit;
style_class = style_metrics->style_class;
writing_system_class =
af_writing_system_classes[style_class->writing_system];
loader->metrics = style_metrics;
if ( writing_system_class->style_metrics_scale )
writing_system_class->style_metrics_scale( style_metrics, &scaler );
else
style_metrics->scaler = scaler;
if ( writing_system_class->style_hints_init )
{
error = writing_system_class->style_hints_init( hints,
style_metrics );
if ( error )
goto Exit;
}
/*
* Do the main work of `af_loader_load_glyph'. Note that we never have
* to deal with composite glyphs as those get loaded into
* FT_GLYPH_FORMAT_OUTLINE by the recursed `FT_Load_Glyph' function.
* In the rare cases where FT_LOAD_NO_RECURSE is set, it implies
* FT_LOAD_NO_SCALE and as such the auto-hinter is never called.
*/
load_flags |= FT_LOAD_NO_SCALE |
FT_LOAD_IGNORE_TRANSFORM |
FT_LOAD_LINEAR_DESIGN;
load_flags &= ~FT_LOAD_RENDER;
error = FT_Load_Glyph( face, glyph_index, load_flags );
if ( error )
goto Exit;
/*
* Apply stem darkening (emboldening) here before hints are applied to
* the outline. Glyphs are scaled down proportionally to the
* emboldening so that curve points don't fall outside their
* precomputed blue zones.
*
* Any emboldening done by the font driver (e.g., the CFF driver)
* doesn't reach here because the autohinter loads the unprocessed
* glyphs in font units for analysis (functions `af_*_metrics_init_*')
* and then above to prepare it for the rasterizers by itself,
* independently of the font driver. So emboldening must be done here,
* within the autohinter.
*
* All glyphs to be autohinted pass through here one by one. The
* standard widths can therefore change from one glyph to the next,
* depending on what script a glyph is assigned to (each script has its
* own set of standard widths and other metrics). The darkening amount
* must therefore be recomputed for each size and
* `standard_{vertical,horizontal}_width' change.
*
* Ignore errors and carry on without emboldening.
*
*/
/* stem darkening only works well in `light' mode */
if ( scaler.render_mode == FT_RENDER_MODE_LIGHT &&
( !face->internal->no_stem_darkening ||
( face->internal->no_stem_darkening < 0 &&
!module->no_stem_darkening ) ) )
af_loader_embolden_glyph_in_slot( loader, face, style_metrics );
loader->transformed = slot_internal->glyph_transformed;
if ( loader->transformed )
{
FT_Matrix inverse;
loader->trans_matrix = slot_internal->glyph_matrix;
loader->trans_delta = slot_internal->glyph_delta;
inverse = loader->trans_matrix;
if ( !FT_Matrix_Invert( &inverse ) )
FT_Vector_Transform( &loader->trans_delta, &inverse );
}
switch ( slot->format )
{
case FT_GLYPH_FORMAT_OUTLINE:
/* translate the loaded glyph when an internal transform is needed */
if ( loader->transformed )
FT_Outline_Translate( &slot->outline,
loader->trans_delta.x,
loader->trans_delta.y );
/* compute original horizontal phantom points */
/* (and ignore vertical ones) */
loader->pp1.x = hints->x_delta;
loader->pp1.y = hints->y_delta;
loader->pp2.x = FT_MulFix( slot->metrics.horiAdvance,
hints->x_scale ) + hints->x_delta;
loader->pp2.y = hints->y_delta;
/* be sure to check for spacing glyphs */
if ( slot->outline.n_points == 0 )
goto Hint_Metrics;
/* now load the slot image into the auto-outline */
/* and run the automatic hinting process */
if ( writing_system_class->style_hints_apply )
{
error = writing_system_class->style_hints_apply(
glyph_index,
hints,
&gloader->base.outline,
style_metrics );
if ( error )
goto Exit;
}
/* we now need to adjust the metrics according to the change in */
/* width/positioning that occurred during the hinting process */
if ( scaler.render_mode != FT_RENDER_MODE_LIGHT )
{
AF_AxisHints axis = &hints->axis[AF_DIMENSION_HORZ];
if ( axis->num_edges > 1 && AF_HINTS_DO_ADVANCE( hints ) )
{
AF_Edge edge1 = axis->edges; /* leftmost edge */
AF_Edge edge2 = edge1 +
axis->num_edges - 1; /* rightmost edge */
FT_Pos old_rsb = loader->pp2.x - edge2->opos;
/* loader->pp1.x is always zero at this point of time */
FT_Pos old_lsb = edge1->opos; /* - loader->pp1.x */
FT_Pos new_lsb = edge1->pos;
/* remember unhinted values to later account */
/* for rounding errors */
FT_Pos pp1x_uh = new_lsb - old_lsb;
FT_Pos pp2x_uh = edge2->pos + old_rsb;
/* prefer too much space over too little space */
/* for very small sizes */
if ( old_lsb < 24 )
pp1x_uh -= 8;
if ( old_rsb < 24 )
pp2x_uh += 8;
loader->pp1.x = FT_PIX_ROUND( pp1x_uh );
loader->pp2.x = FT_PIX_ROUND( pp2x_uh );
if ( loader->pp1.x >= new_lsb && old_lsb > 0 )
loader->pp1.x -= 64;
if ( loader->pp2.x <= edge2->pos && old_rsb > 0 )
loader->pp2.x += 64;
slot->lsb_delta = loader->pp1.x - pp1x_uh;
slot->rsb_delta = loader->pp2.x - pp2x_uh;
}
else
{
FT_Pos pp1x = loader->pp1.x;
FT_Pos pp2x = loader->pp2.x;
loader->pp1.x = FT_PIX_ROUND( pp1x );
loader->pp2.x = FT_PIX_ROUND( pp2x );
slot->lsb_delta = loader->pp1.x - pp1x;
slot->rsb_delta = loader->pp2.x - pp2x;
}
}
/* `light' mode uses integer advance widths */
/* but sets `lsb_delta' and `rsb_delta' */
else
{
FT_Pos pp1x = loader->pp1.x;
FT_Pos pp2x = loader->pp2.x;
loader->pp1.x = FT_PIX_ROUND( pp1x );
loader->pp2.x = FT_PIX_ROUND( pp2x );
slot->lsb_delta = loader->pp1.x - pp1x;
slot->rsb_delta = loader->pp2.x - pp2x;
}
break;
default:
/* we don't support other formats (yet?) */
error = FT_THROW( Unimplemented_Feature );
}
Hint_Metrics:
{
FT_BBox bbox;
FT_Vector vvector;
vvector.x = slot->metrics.vertBearingX - slot->metrics.horiBearingX;
vvector.y = slot->metrics.vertBearingY - slot->metrics.horiBearingY;
vvector.x = FT_MulFix( vvector.x, style_metrics->scaler.x_scale );
vvector.y = FT_MulFix( vvector.y, style_metrics->scaler.y_scale );
/* transform the hinted outline if needed */
if ( loader->transformed )
{
FT_Outline_Transform( &gloader->base.outline, &loader->trans_matrix );
FT_Vector_Transform( &vvector, &loader->trans_matrix );
}
/* we must translate our final outline by -pp1.x and compute */
/* the new metrics */
if ( loader->pp1.x )
FT_Outline_Translate( &gloader->base.outline, -loader->pp1.x, 0 );
FT_Outline_Get_CBox( &gloader->base.outline, &bbox );
bbox.xMin = FT_PIX_FLOOR( bbox.xMin );
bbox.yMin = FT_PIX_FLOOR( bbox.yMin );
bbox.xMax = FT_PIX_CEIL( bbox.xMax );
bbox.yMax = FT_PIX_CEIL( bbox.yMax );
slot->metrics.width = bbox.xMax - bbox.xMin;
slot->metrics.height = bbox.yMax - bbox.yMin;
slot->metrics.horiBearingX = bbox.xMin;
slot->metrics.horiBearingY = bbox.yMax;
slot->metrics.vertBearingX = FT_PIX_FLOOR( bbox.xMin + vvector.x );
slot->metrics.vertBearingY = FT_PIX_FLOOR( bbox.yMax + vvector.y );
/* for mono-width fonts (like Andale, Courier, etc.) we need */
/* to keep the original rounded advance width; ditto for */
/* digits if all have the same advance width */
if ( scaler.render_mode != FT_RENDER_MODE_LIGHT &&
( FT_IS_FIXED_WIDTH( slot->face ) ||
( af_face_globals_is_digit( loader->globals, glyph_index ) &&
style_metrics->digits_have_same_width ) ) )
{
slot->metrics.horiAdvance =
FT_MulFix( slot->metrics.horiAdvance,
style_metrics->scaler.x_scale );
/* Set delta values to 0. Otherwise code that uses them is */
/* going to ruin the fixed advance width. */
slot->lsb_delta = 0;
slot->rsb_delta = 0;
}
else
{
/* non-spacing glyphs must stay as-is */
if ( slot->metrics.horiAdvance )
slot->metrics.horiAdvance = loader->pp2.x - loader->pp1.x;
}
slot->metrics.vertAdvance = FT_MulFix( slot->metrics.vertAdvance,
style_metrics->scaler.y_scale );
slot->metrics.horiAdvance = FT_PIX_ROUND( slot->metrics.horiAdvance );
slot->metrics.vertAdvance = FT_PIX_ROUND( slot->metrics.vertAdvance );
slot->format = FT_GLYPH_FORMAT_OUTLINE;
}
Exit:
return error;
}
/*
* Compute amount of font units the face should be emboldened by, in
* analogy to the CFF driver's `cf2_computeDarkening' function. See there
* for details of the algorithm.
*
* XXX: Currently a crude adaption of the original algorithm. Do better?
*/
FT_LOCAL_DEF( FT_Fixed )
af_loader_compute_darkening( AF_Loader loader,
FT_Face face,
FT_Pos standard_width )
{
AF_Module module = loader->globals->module;
FT_UShort units_per_EM;
FT_Fixed ppem, em_ratio;
FT_Fixed stem_width, stem_width_per_1000, scaled_stem, darken_amount;
FT_Int log_base_2;
FT_Int x1, y1, x2, y2, x3, y3, x4, y4;
ppem = FT_MAX( af_intToFixed( 4 ),
af_intToFixed( face->size->metrics.x_ppem ) );
units_per_EM = face->units_per_EM;
em_ratio = FT_DivFix( af_intToFixed( 1000 ),
af_intToFixed ( units_per_EM ) );
if ( em_ratio < af_floatToFixed( .01 ) )
{
/* If something goes wrong, don't embolden. */
return 0;
}
x1 = module->darken_params[0];
y1 = module->darken_params[1];
x2 = module->darken_params[2];
y2 = module->darken_params[3];
x3 = module->darken_params[4];
y3 = module->darken_params[5];
x4 = module->darken_params[6];
y4 = module->darken_params[7];
if ( standard_width <= 0 )
{
stem_width = af_intToFixed( 75 ); /* taken from cf2font.c */
stem_width_per_1000 = stem_width;
}
else
{
stem_width = af_intToFixed( standard_width );
stem_width_per_1000 = FT_MulFix( stem_width, em_ratio );
}
log_base_2 = FT_MSB( (FT_UInt32)stem_width_per_1000 ) +
FT_MSB( (FT_UInt32)ppem );
if ( log_base_2 >= 46 )
{
/* possible overflow */
scaled_stem = af_intToFixed( x4 );
}
else
scaled_stem = FT_MulFix( stem_width_per_1000, ppem );
/* now apply the darkening parameters */
if ( scaled_stem < af_intToFixed( x1 ) )
darken_amount = FT_DivFix( af_intToFixed( y1 ), ppem );
else if ( scaled_stem < af_intToFixed( x2 ) )
{
FT_Int xdelta = x2 - x1;
FT_Int ydelta = y2 - y1;
FT_Int x = stem_width_per_1000 -
FT_DivFix( af_intToFixed( x1 ), ppem );
if ( !xdelta )
goto Try_x3;
darken_amount = FT_MulDiv( x, ydelta, xdelta ) +
FT_DivFix( af_intToFixed( y1 ), ppem );
}
else if ( scaled_stem < af_intToFixed( x3 ) )
{
Try_x3:
{
FT_Int xdelta = x3 - x2;
FT_Int ydelta = y3 - y2;
FT_Int x = stem_width_per_1000 -
FT_DivFix( af_intToFixed( x2 ), ppem );
if ( !xdelta )
goto Try_x4;
darken_amount = FT_MulDiv( x, ydelta, xdelta ) +
FT_DivFix( af_intToFixed( y2 ), ppem );
}
}
else if ( scaled_stem < af_intToFixed( x4 ) )
{
Try_x4:
{
FT_Int xdelta = x4 - x3;
FT_Int ydelta = y4 - y3;
FT_Int x = stem_width_per_1000 -
FT_DivFix( af_intToFixed( x3 ), ppem );
if ( !xdelta )
goto Use_y4;
darken_amount = FT_MulDiv( x, ydelta, xdelta ) +
FT_DivFix( af_intToFixed( y3 ), ppem );
}
}
else
{
Use_y4:
darken_amount = FT_DivFix( af_intToFixed( y4 ), ppem );
}
/* Convert darken_amount from per 1000 em to true character space. */
return FT_DivFix( darken_amount, em_ratio );
}
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/autofit/afloader.c
|
C++
|
gpl-3.0
| 24,105
|
/****************************************************************************
*
* afloader.h
*
* Auto-fitter glyph loading routines (specification).
*
* Copyright (C) 2003-2022 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 AFLOADER_H_
#define AFLOADER_H_
#include "afhints.h"
#include "afmodule.h"
#include "afglobal.h"
FT_BEGIN_HEADER
/*
* The autofitter module's (global) data structure to communicate with
* actual fonts. If necessary, `local' data like the current face, the
* current face's auto-hint data, or the current glyph's parameters
* relevant to auto-hinting are `swapped in'. Cf. functions like
* `af_loader_reset' and `af_loader_load_g'.
*/
typedef struct AF_LoaderRec_
{
/* current face data */
FT_Face face;
AF_FaceGlobals globals;
/* current glyph data */
AF_GlyphHints hints;
AF_StyleMetrics metrics;
FT_Bool transformed;
FT_Matrix trans_matrix;
FT_Vector trans_delta;
FT_Vector pp1;
FT_Vector pp2;
/* we don't handle vertical phantom points */
} AF_LoaderRec, *AF_Loader;
FT_LOCAL( void )
af_loader_init( AF_Loader loader,
AF_GlyphHints hints );
FT_LOCAL( FT_Error )
af_loader_reset( AF_Loader loader,
AF_Module module,
FT_Face face );
FT_LOCAL( void )
af_loader_done( AF_Loader loader );
FT_LOCAL( FT_Error )
af_loader_load_glyph( AF_Loader loader,
AF_Module module,
FT_Face face,
FT_UInt gindex,
FT_Int32 load_flags );
FT_LOCAL_DEF( FT_Fixed )
af_loader_compute_darkening( AF_Loader loader,
FT_Face face,
FT_Pos standard_width );
/* */
FT_END_HEADER
#endif /* AFLOADER_H_ */
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/autofit/afloader.h
|
C++
|
gpl-3.0
| 2,273
|
/****************************************************************************
*
* afmodule.c
*
* Auto-fitter module implementation (body).
*
* Copyright (C) 2003-2022 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.
*
*/
#include "afglobal.h"
#include "afmodule.h"
#include "afloader.h"
#include "aferrors.h"
#ifdef FT_DEBUG_AUTOFIT
#ifndef FT_MAKE_OPTION_SINGLE_OBJECT
#ifdef __cplusplus
extern "C" {
#endif
extern void
af_glyph_hints_dump_segments( AF_GlyphHints hints,
FT_Bool to_stdout );
extern void
af_glyph_hints_dump_points( AF_GlyphHints hints,
FT_Bool to_stdout );
extern void
af_glyph_hints_dump_edges( AF_GlyphHints hints,
FT_Bool to_stdout );
#ifdef __cplusplus
}
#endif
#endif
int _af_debug_disable_horz_hints;
int _af_debug_disable_vert_hints;
int _af_debug_disable_blue_hints;
/* we use a global object instead of a local one for debugging */
static AF_GlyphHintsRec _af_debug_hints_rec[1];
void* _af_debug_hints = _af_debug_hints_rec;
#endif
#include <freetype/internal/ftobjs.h>
#include <freetype/internal/ftdebug.h>
#include <freetype/ftdriver.h>
#include <freetype/internal/services/svprop.h>
/**************************************************************************
*
* The macro FT_COMPONENT is used in trace mode. It is an implicit
* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
* messages during execution.
*/
#undef FT_COMPONENT
#define FT_COMPONENT afmodule
static FT_Error
af_property_get_face_globals( FT_Face face,
AF_FaceGlobals* aglobals,
AF_Module module )
{
FT_Error error = FT_Err_Ok;
AF_FaceGlobals globals;
if ( !face )
return FT_THROW( Invalid_Face_Handle );
globals = (AF_FaceGlobals)face->autohint.data;
if ( !globals )
{
/* trigger computation of the global style data */
/* in case it hasn't been done yet */
error = af_face_globals_new( face, &globals, module );
if ( !error )
{
face->autohint.data =
(FT_Pointer)globals;
face->autohint.finalizer =
(FT_Generic_Finalizer)af_face_globals_free;
}
}
if ( !error )
*aglobals = globals;
return error;
}
static FT_Error
af_property_set( FT_Module ft_module,
const char* property_name,
const void* value,
FT_Bool value_is_string )
{
FT_Error error = FT_Err_Ok;
AF_Module module = (AF_Module)ft_module;
#ifndef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
FT_UNUSED( value_is_string );
#endif
if ( !ft_strcmp( property_name, "fallback-script" ) )
{
FT_UInt* fallback_script;
FT_UInt ss;
#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
if ( value_is_string )
return FT_THROW( Invalid_Argument );
#endif
fallback_script = (FT_UInt*)value;
/* We translate the fallback script to a fallback style that uses */
/* `fallback-script' as its script and `AF_COVERAGE_NONE' as its */
/* coverage value. */
for ( ss = 0; af_style_classes[ss]; ss++ )
{
AF_StyleClass style_class = af_style_classes[ss];
if ( (FT_UInt)style_class->script == *fallback_script &&
style_class->coverage == AF_COVERAGE_DEFAULT )
{
module->fallback_style = ss;
break;
}
}
if ( !af_style_classes[ss] )
{
FT_TRACE2(( "af_property_set: Invalid value %d for property `%s'\n",
*fallback_script, property_name ));
return FT_THROW( Invalid_Argument );
}
return error;
}
else if ( !ft_strcmp( property_name, "default-script" ) )
{
FT_UInt* default_script;
#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
if ( value_is_string )
return FT_THROW( Invalid_Argument );
#endif
default_script = (FT_UInt*)value;
module->default_script = *default_script;
return error;
}
else if ( !ft_strcmp( property_name, "increase-x-height" ) )
{
FT_Prop_IncreaseXHeight* prop;
AF_FaceGlobals globals;
#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
if ( value_is_string )
return FT_THROW( Invalid_Argument );
#endif
prop = (FT_Prop_IncreaseXHeight*)value;
error = af_property_get_face_globals( prop->face, &globals, module );
if ( !error )
globals->increase_x_height = prop->limit;
return error;
}
else if ( !ft_strcmp( property_name, "darkening-parameters" ) )
{
FT_Int* darken_params;
FT_Int x1, y1, x2, y2, x3, y3, x4, y4;
#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
FT_Int dp[8];
if ( value_is_string )
{
const char* s = (const char*)value;
char* ep;
int i;
/* eight comma-separated numbers */
for ( i = 0; i < 7; i++ )
{
dp[i] = (FT_Int)ft_strtol( s, &ep, 10 );
if ( *ep != ',' || s == ep )
return FT_THROW( Invalid_Argument );
s = ep + 1;
}
dp[7] = (FT_Int)ft_strtol( s, &ep, 10 );
if ( !( *ep == '\0' || *ep == ' ' ) || s == ep )
return FT_THROW( Invalid_Argument );
darken_params = dp;
}
else
#endif
darken_params = (FT_Int*)value;
x1 = darken_params[0];
y1 = darken_params[1];
x2 = darken_params[2];
y2 = darken_params[3];
x3 = darken_params[4];
y3 = darken_params[5];
x4 = darken_params[6];
y4 = darken_params[7];
if ( x1 < 0 || x2 < 0 || x3 < 0 || x4 < 0 ||
y1 < 0 || y2 < 0 || y3 < 0 || y4 < 0 ||
x1 > x2 || x2 > x3 || x3 > x4 ||
y1 > 500 || y2 > 500 || y3 > 500 || y4 > 500 )
return FT_THROW( Invalid_Argument );
module->darken_params[0] = x1;
module->darken_params[1] = y1;
module->darken_params[2] = x2;
module->darken_params[3] = y2;
module->darken_params[4] = x3;
module->darken_params[5] = y3;
module->darken_params[6] = x4;
module->darken_params[7] = y4;
return error;
}
else if ( !ft_strcmp( property_name, "no-stem-darkening" ) )
{
#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
if ( value_is_string )
{
const char* s = (const char*)value;
long nsd = ft_strtol( s, NULL, 10 );
if ( !nsd )
module->no_stem_darkening = FALSE;
else
module->no_stem_darkening = TRUE;
}
else
#endif
{
FT_Bool* no_stem_darkening = (FT_Bool*)value;
module->no_stem_darkening = *no_stem_darkening;
}
return error;
}
FT_TRACE2(( "af_property_set: missing property `%s'\n",
property_name ));
return FT_THROW( Missing_Property );
}
static FT_Error
af_property_get( FT_Module ft_module,
const char* property_name,
void* value )
{
FT_Error error = FT_Err_Ok;
AF_Module module = (AF_Module)ft_module;
FT_UInt fallback_style = module->fallback_style;
FT_UInt default_script = module->default_script;
if ( !ft_strcmp( property_name, "glyph-to-script-map" ) )
{
FT_Prop_GlyphToScriptMap* prop = (FT_Prop_GlyphToScriptMap*)value;
AF_FaceGlobals globals;
error = af_property_get_face_globals( prop->face, &globals, module );
if ( !error )
prop->map = globals->glyph_styles;
return error;
}
else if ( !ft_strcmp( property_name, "fallback-script" ) )
{
FT_UInt* val = (FT_UInt*)value;
AF_StyleClass style_class = af_style_classes[fallback_style];
*val = style_class->script;
return error;
}
else if ( !ft_strcmp( property_name, "default-script" ) )
{
FT_UInt* val = (FT_UInt*)value;
*val = default_script;
return error;
}
else if ( !ft_strcmp( property_name, "increase-x-height" ) )
{
FT_Prop_IncreaseXHeight* prop = (FT_Prop_IncreaseXHeight*)value;
AF_FaceGlobals globals;
error = af_property_get_face_globals( prop->face, &globals, module );
if ( !error )
prop->limit = globals->increase_x_height;
return error;
}
else if ( !ft_strcmp( property_name, "darkening-parameters" ) )
{
FT_Int* darken_params = module->darken_params;
FT_Int* val = (FT_Int*)value;
val[0] = darken_params[0];
val[1] = darken_params[1];
val[2] = darken_params[2];
val[3] = darken_params[3];
val[4] = darken_params[4];
val[5] = darken_params[5];
val[6] = darken_params[6];
val[7] = darken_params[7];
return error;
}
else if ( !ft_strcmp( property_name, "no-stem-darkening" ) )
{
FT_Bool no_stem_darkening = module->no_stem_darkening;
FT_Bool* val = (FT_Bool*)value;
*val = no_stem_darkening;
return error;
}
FT_TRACE2(( "af_property_get: missing property `%s'\n",
property_name ));
return FT_THROW( Missing_Property );
}
FT_DEFINE_SERVICE_PROPERTIESREC(
af_service_properties,
(FT_Properties_SetFunc)af_property_set, /* set_property */
(FT_Properties_GetFunc)af_property_get ) /* get_property */
FT_DEFINE_SERVICEDESCREC1(
af_services,
FT_SERVICE_ID_PROPERTIES, &af_service_properties )
FT_CALLBACK_DEF( FT_Module_Interface )
af_get_interface( FT_Module module,
const char* module_interface )
{
FT_UNUSED( module );
return ft_service_list_lookup( af_services, module_interface );
}
FT_CALLBACK_DEF( FT_Error )
af_autofitter_init( FT_Module ft_module ) /* AF_Module */
{
AF_Module module = (AF_Module)ft_module;
module->fallback_style = AF_STYLE_FALLBACK;
module->default_script = AF_SCRIPT_DEFAULT;
module->no_stem_darkening = TRUE;
module->darken_params[0] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1;
module->darken_params[1] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1;
module->darken_params[2] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2;
module->darken_params[3] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y2;
module->darken_params[4] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3;
module->darken_params[5] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y3;
module->darken_params[6] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4;
module->darken_params[7] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4;
return FT_Err_Ok;
}
FT_CALLBACK_DEF( void )
af_autofitter_done( FT_Module ft_module ) /* AF_Module */
{
FT_UNUSED( ft_module );
#ifdef FT_DEBUG_AUTOFIT
if ( _af_debug_hints_rec->memory )
af_glyph_hints_done( _af_debug_hints_rec );
#endif
}
FT_CALLBACK_DEF( FT_Error )
af_autofitter_load_glyph( AF_Module module,
FT_GlyphSlot slot,
FT_Size size,
FT_UInt glyph_index,
FT_Int32 load_flags )
{
FT_Error error = FT_Err_Ok;
FT_Memory memory = module->root.library->memory;
#ifdef FT_DEBUG_AUTOFIT
/* in debug mode, we use a global object that survives this routine */
AF_GlyphHints hints = _af_debug_hints_rec;
AF_LoaderRec loader[1];
FT_UNUSED( size );
if ( hints->memory )
af_glyph_hints_done( hints );
af_glyph_hints_init( hints, memory );
af_loader_init( loader, hints );
error = af_loader_load_glyph( loader, module, slot->face,
glyph_index, load_flags );
#ifdef FT_DEBUG_LEVEL_TRACE
if ( ft_trace_levels[FT_TRACE_COMP( FT_COMPONENT )] )
{
#endif
af_glyph_hints_dump_points( hints, 0 );
af_glyph_hints_dump_segments( hints, 0 );
af_glyph_hints_dump_edges( hints, 0 );
#ifdef FT_DEBUG_LEVEL_TRACE
}
#endif
af_loader_done( loader );
return error;
#else /* !FT_DEBUG_AUTOFIT */
AF_GlyphHintsRec hints[1];
AF_LoaderRec loader[1];
FT_UNUSED( size );
af_glyph_hints_init( hints, memory );
af_loader_init( loader, hints );
error = af_loader_load_glyph( loader, module, slot->face,
glyph_index, load_flags );
af_loader_done( loader );
af_glyph_hints_done( hints );
return error;
#endif /* !FT_DEBUG_AUTOFIT */
}
FT_DEFINE_AUTOHINTER_INTERFACE(
af_autofitter_interface,
NULL, /* reset_face */
NULL, /* get_global_hints */
NULL, /* done_global_hints */
(FT_AutoHinter_GlyphLoadFunc)af_autofitter_load_glyph /* load_glyph */
)
FT_DEFINE_MODULE(
autofit_module_class,
FT_MODULE_HINTER,
sizeof ( AF_ModuleRec ),
"autofitter",
0x10000L, /* version 1.0 of the autofitter */
0x20000L, /* requires FreeType 2.0 or above */
(const void*)&af_autofitter_interface,
(FT_Module_Constructor)af_autofitter_init, /* module_init */
(FT_Module_Destructor) af_autofitter_done, /* module_done */
(FT_Module_Requester) af_get_interface /* get_interface */
)
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/autofit/afmodule.c
|
C++
|
gpl-3.0
| 14,033
|
/****************************************************************************
*
* afmodule.h
*
* Auto-fitter module implementation (specification).
*
* Copyright (C) 2003-2022 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 AFMODULE_H_
#define AFMODULE_H_
#include <freetype/internal/ftobjs.h>
#include <freetype/ftmodapi.h>
FT_BEGIN_HEADER
/*
* This is the `extended' FT_Module structure that holds the
* autofitter's global data.
*/
typedef struct AF_ModuleRec_
{
FT_ModuleRec root;
FT_UInt fallback_style;
FT_UInt default_script;
FT_Bool no_stem_darkening;
FT_Int darken_params[8];
} AF_ModuleRec, *AF_Module;
FT_DECLARE_AUTOHINTER_INTERFACE( af_autofitter_interface )
FT_DECLARE_MODULE( autofit_module_class )
FT_END_HEADER
#endif /* AFMODULE_H_ */
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/autofit/afmodule.h
|
C++
|
gpl-3.0
| 1,181
|
/****************************************************************************
*
* afranges.c
*
* Auto-fitter Unicode script ranges (body).
*
* Copyright (C) 2013-2022 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.
*
*/
#include "afranges.h"
/*
* The algorithm for assigning properties and styles to the `glyph_styles'
* array is as follows (cf. the implementation in
* `af_face_globals_compute_style_coverage').
*
* Walk over all scripts (as listed in `afscript.h').
*
* For a given script, walk over all styles (as listed in `afstyles.h').
* The order of styles is important and should be as follows.
*
* - First come styles based on OpenType features (small caps, for
* example). Since features rely on glyph indices, thus completely
* bypassing character codes, no properties are assigned.
*
* - Next comes the default style, using the character ranges as defined
* below. This also assigns properties.
*
* Note that there also exist fallback scripts, mainly covering
* superscript and subscript glyphs of a script that are not present as
* OpenType features. Fallback scripts are defined below, also
* assigning properties; they are applied after the corresponding
* script.
*
*/
/* XXX Check base character ranges again: */
/* Right now, they are quickly derived by visual inspection. */
/* I can imagine that fine-tuning is necessary. */
/* for the auto-hinter, a `non-base character' is something that should */
/* not be affected by blue zones, regardless of whether this is a */
/* spacing or no-spacing glyph */
/* the `af_xxxx_nonbase_uniranges' ranges must be strict subsets */
/* of the corresponding `af_xxxx_uniranges' ranges */
const AF_Script_UniRangeRec af_adlm_uniranges[] =
{
AF_UNIRANGE_REC( 0x1E900, 0x1E95F ), /* Adlam */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_adlm_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0x1D944, 0x1E94A ),
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_arab_uniranges[] =
{
AF_UNIRANGE_REC( 0x0600, 0x06FF ), /* Arabic */
AF_UNIRANGE_REC( 0x0750, 0x07FF ), /* Arabic Supplement */
AF_UNIRANGE_REC( 0x08A0, 0x08FF ), /* Arabic Extended-A */
AF_UNIRANGE_REC( 0xFB50, 0xFDFF ), /* Arabic Presentation Forms-A */
AF_UNIRANGE_REC( 0xFE70, 0xFEFF ), /* Arabic Presentation Forms-B */
AF_UNIRANGE_REC( 0x1EE00, 0x1EEFF ), /* Arabic Mathematical Alphabetic Symbols */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_arab_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0x0600, 0x0605 ),
AF_UNIRANGE_REC( 0x0610, 0x061A ),
AF_UNIRANGE_REC( 0x064B, 0x065F ),
AF_UNIRANGE_REC( 0x0670, 0x0670 ),
AF_UNIRANGE_REC( 0x06D6, 0x06DC ),
AF_UNIRANGE_REC( 0x06DF, 0x06E4 ),
AF_UNIRANGE_REC( 0x06E7, 0x06E8 ),
AF_UNIRANGE_REC( 0x06EA, 0x06ED ),
AF_UNIRANGE_REC( 0x08D4, 0x08E1 ),
AF_UNIRANGE_REC( 0x08D3, 0x08FF ),
AF_UNIRANGE_REC( 0xFBB2, 0xFBC1 ),
AF_UNIRANGE_REC( 0xFE70, 0xFE70 ),
AF_UNIRANGE_REC( 0xFE72, 0xFE72 ),
AF_UNIRANGE_REC( 0xFE74, 0xFE74 ),
AF_UNIRANGE_REC( 0xFE76, 0xFE76 ),
AF_UNIRANGE_REC( 0xFE78, 0xFE78 ),
AF_UNIRANGE_REC( 0xFE7A, 0xFE7A ),
AF_UNIRANGE_REC( 0xFE7C, 0xFE7C ),
AF_UNIRANGE_REC( 0xFE7E, 0xFE7E ),
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_armn_uniranges[] =
{
AF_UNIRANGE_REC( 0x0530, 0x058F ), /* Armenian */
AF_UNIRANGE_REC( 0xFB13, 0xFB17 ), /* Alphab. Present. Forms (Armenian) */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_armn_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0x0559, 0x055F ),
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_avst_uniranges[] =
{
AF_UNIRANGE_REC( 0x10B00, 0x10B3F ), /* Avestan */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_avst_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0x10B39, 0x10B3F ),
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_bamu_uniranges[] =
{
AF_UNIRANGE_REC( 0xA6A0, 0xA6FF ), /* Bamum */
#if 0
/* The characters in the Bamum supplement are pictograms, */
/* not (directly) related to the syllabic Bamum script */
AF_UNIRANGE_REC( 0x16800, 0x16A3F ), /* Bamum Supplement */
#endif
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_bamu_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0xA6F0, 0xA6F1 ),
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_beng_uniranges[] =
{
AF_UNIRANGE_REC( 0x0980, 0x09FF ), /* Bengali */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_beng_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0x0981, 0x0981 ),
AF_UNIRANGE_REC( 0x09BC, 0x09BC ),
AF_UNIRANGE_REC( 0x09C1, 0x09C4 ),
AF_UNIRANGE_REC( 0x09CD, 0x09CD ),
AF_UNIRANGE_REC( 0x09E2, 0x09E3 ),
AF_UNIRANGE_REC( 0x09FE, 0x09FE ),
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_buhd_uniranges[] =
{
AF_UNIRANGE_REC( 0x1740, 0x175F ), /* Buhid */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_buhd_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0x1752, 0x1753 ),
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_cakm_uniranges[] =
{
AF_UNIRANGE_REC( 0x11100, 0x1114F ), /* Chakma */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_cakm_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0x11100, 0x11102 ),
AF_UNIRANGE_REC( 0x11127, 0x11134 ),
AF_UNIRANGE_REC( 0x11146, 0x11146 ),
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_cans_uniranges[] =
{
AF_UNIRANGE_REC( 0x1400, 0x167F ), /* Unified Canadian Aboriginal Syllabics */
AF_UNIRANGE_REC( 0x18B0, 0x18FF ), /* Unified Canadian Aboriginal Syllabics Extended */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_cans_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_cari_uniranges[] =
{
AF_UNIRANGE_REC( 0x102A0, 0x102DF ), /* Carian */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_cari_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_cher_uniranges[] =
{
AF_UNIRANGE_REC( 0x13A0, 0x13FF ), /* Cherokee */
AF_UNIRANGE_REC( 0xAB70, 0xABBF ), /* Cherokee Supplement */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_cher_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_copt_uniranges[] =
{
AF_UNIRANGE_REC( 0x2C80, 0x2CFF ), /* Coptic */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_copt_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0x2CEF, 0x2CF1 ),
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_cprt_uniranges[] =
{
AF_UNIRANGE_REC( 0x10800, 0x1083F ), /* Cypriot */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_cprt_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_cyrl_uniranges[] =
{
AF_UNIRANGE_REC( 0x0400, 0x04FF ), /* Cyrillic */
AF_UNIRANGE_REC( 0x0500, 0x052F ), /* Cyrillic Supplement */
AF_UNIRANGE_REC( 0x2DE0, 0x2DFF ), /* Cyrillic Extended-A */
AF_UNIRANGE_REC( 0xA640, 0xA69F ), /* Cyrillic Extended-B */
AF_UNIRANGE_REC( 0x1C80, 0x1C8F ), /* Cyrillic Extended-C */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_cyrl_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0x0483, 0x0489 ),
AF_UNIRANGE_REC( 0x2DE0, 0x2DFF ),
AF_UNIRANGE_REC( 0xA66F, 0xA67F ),
AF_UNIRANGE_REC( 0xA69E, 0xA69F ),
AF_UNIRANGE_REC( 0, 0 )
};
/* There are some characters in the Devanagari Unicode block that are */
/* generic to Indic scripts; we omit them so that their presence doesn't */
/* trigger Devanagari. */
const AF_Script_UniRangeRec af_deva_uniranges[] =
{
AF_UNIRANGE_REC( 0x0900, 0x093B ), /* Devanagari */
/* omitting U+093C nukta */
AF_UNIRANGE_REC( 0x093D, 0x0950 ), /* ... continued */
/* omitting U+0951 udatta, U+0952 anudatta */
AF_UNIRANGE_REC( 0x0953, 0x0963 ), /* ... continued */
/* omitting U+0964 danda, U+0965 double danda */
AF_UNIRANGE_REC( 0x0966, 0x097F ), /* ... continued */
AF_UNIRANGE_REC( 0x20B9, 0x20B9 ), /* (new) Rupee sign */
AF_UNIRANGE_REC( 0xA8E0, 0xA8FF ), /* Devanagari Extended */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_deva_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0x0900, 0x0902 ),
AF_UNIRANGE_REC( 0x093A, 0x093A ),
AF_UNIRANGE_REC( 0x0941, 0x0948 ),
AF_UNIRANGE_REC( 0x094D, 0x094D ),
AF_UNIRANGE_REC( 0x0953, 0x0957 ),
AF_UNIRANGE_REC( 0x0962, 0x0963 ),
AF_UNIRANGE_REC( 0xA8E0, 0xA8F1 ),
AF_UNIRANGE_REC( 0xA8FF, 0xA8FF ),
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_dsrt_uniranges[] =
{
AF_UNIRANGE_REC( 0x10400, 0x1044F ), /* Deseret */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_dsrt_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_ethi_uniranges[] =
{
AF_UNIRANGE_REC( 0x1200, 0x137F ), /* Ethiopic */
AF_UNIRANGE_REC( 0x1380, 0x139F ), /* Ethiopic Supplement */
AF_UNIRANGE_REC( 0x2D80, 0x2DDF ), /* Ethiopic Extended */
AF_UNIRANGE_REC( 0xAB00, 0xAB2F ), /* Ethiopic Extended-A */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_ethi_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0x135D, 0x135F ),
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_geor_uniranges[] =
{
AF_UNIRANGE_REC( 0x10D0, 0x10FF ), /* Georgian (Mkhedruli) */
AF_UNIRANGE_REC( 0x1C90, 0x1CBF ), /* Georgian Extended (Mtavruli) */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_geor_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_geok_uniranges[] =
{
/* Khutsuri */
AF_UNIRANGE_REC( 0x10A0, 0x10CD ), /* Georgian (Asomtavruli) */
AF_UNIRANGE_REC( 0x2D00, 0x2D2D ), /* Georgian Supplement (Nuskhuri) */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_geok_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_glag_uniranges[] =
{
AF_UNIRANGE_REC( 0x2C00, 0x2C5F ), /* Glagolitic */
AF_UNIRANGE_REC( 0x1E000, 0x1E02F ), /* Glagolitic Supplement */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_glag_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0x1E000, 0x1E02F ),
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_goth_uniranges[] =
{
AF_UNIRANGE_REC( 0x10330, 0x1034F ), /* Gothic */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_goth_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_grek_uniranges[] =
{
AF_UNIRANGE_REC( 0x0370, 0x03FF ), /* Greek and Coptic */
AF_UNIRANGE_REC( 0x1F00, 0x1FFF ), /* Greek Extended */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_grek_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0x037A, 0x037A ),
AF_UNIRANGE_REC( 0x0384, 0x0385 ),
AF_UNIRANGE_REC( 0x1FBD, 0x1FC1 ),
AF_UNIRANGE_REC( 0x1FCD, 0x1FCF ),
AF_UNIRANGE_REC( 0x1FDD, 0x1FDF ),
AF_UNIRANGE_REC( 0x1FED, 0x1FEF ),
AF_UNIRANGE_REC( 0x1FFD, 0x1FFE ),
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_gujr_uniranges[] =
{
AF_UNIRANGE_REC( 0x0A80, 0x0AFF ), /* Gujarati */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_gujr_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0x0A81, 0x0A82 ),
AF_UNIRANGE_REC( 0x0ABC, 0x0ABC ),
AF_UNIRANGE_REC( 0x0AC1, 0x0AC8 ),
AF_UNIRANGE_REC( 0x0ACD, 0x0ACD ),
AF_UNIRANGE_REC( 0x0AE2, 0x0AE3 ),
AF_UNIRANGE_REC( 0x0AFA, 0x0AFF ),
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_guru_uniranges[] =
{
AF_UNIRANGE_REC( 0x0A00, 0x0A7F ), /* Gurmukhi */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_guru_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0x0A01, 0x0A02 ),
AF_UNIRANGE_REC( 0x0A3C, 0x0A3C ),
AF_UNIRANGE_REC( 0x0A41, 0x0A51 ),
AF_UNIRANGE_REC( 0x0A70, 0x0A71 ),
AF_UNIRANGE_REC( 0x0A75, 0x0A75 ),
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_hebr_uniranges[] =
{
AF_UNIRANGE_REC( 0x0590, 0x05FF ), /* Hebrew */
AF_UNIRANGE_REC( 0xFB1D, 0xFB4F ), /* Alphab. Present. Forms (Hebrew) */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_hebr_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0x0591, 0x05BF ),
AF_UNIRANGE_REC( 0x05C1, 0x05C2 ),
AF_UNIRANGE_REC( 0x05C4, 0x05C5 ),
AF_UNIRANGE_REC( 0x05C7, 0x05C7 ),
AF_UNIRANGE_REC( 0xFB1E, 0xFB1E ),
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_kali_uniranges[] =
{
AF_UNIRANGE_REC( 0xA900, 0xA92F ), /* Kayah Li */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_kali_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0xA926, 0xA92D ),
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_knda_uniranges[] =
{
AF_UNIRANGE_REC( 0x0C80, 0x0CFF ), /* Kannada */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_knda_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0x0C81, 0x0C81 ),
AF_UNIRANGE_REC( 0x0CBC, 0x0CBC ),
AF_UNIRANGE_REC( 0x0CBF, 0x0CBF ),
AF_UNIRANGE_REC( 0x0CC6, 0x0CC6 ),
AF_UNIRANGE_REC( 0x0CCC, 0x0CCD ),
AF_UNIRANGE_REC( 0x0CE2, 0x0CE3 ),
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_khmr_uniranges[] =
{
AF_UNIRANGE_REC( 0x1780, 0x17FF ), /* Khmer */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_khmr_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0x17B7, 0x17BD ),
AF_UNIRANGE_REC( 0x17C6, 0x17C6 ),
AF_UNIRANGE_REC( 0x17C9, 0x17D3 ),
AF_UNIRANGE_REC( 0x17DD, 0x17DD ),
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_khms_uniranges[] =
{
AF_UNIRANGE_REC( 0x19E0, 0x19FF ), /* Khmer Symbols */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_khms_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_lao_uniranges[] =
{
AF_UNIRANGE_REC( 0x0E80, 0x0EFF ), /* Lao */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_lao_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0x0EB1, 0x0EB1 ),
AF_UNIRANGE_REC( 0x0EB4, 0x0EBC ),
AF_UNIRANGE_REC( 0x0EC8, 0x0ECD ),
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_latn_uniranges[] =
{
AF_UNIRANGE_REC( 0x0020, 0x007F ), /* Basic Latin (no control chars) */
AF_UNIRANGE_REC( 0x00A0, 0x00A9 ), /* Latin-1 Supplement (no control chars) */
AF_UNIRANGE_REC( 0x00AB, 0x00B1 ), /* ... continued */
AF_UNIRANGE_REC( 0x00B4, 0x00B8 ), /* ... continued */
AF_UNIRANGE_REC( 0x00BB, 0x00FF ), /* ... continued */
AF_UNIRANGE_REC( 0x0100, 0x017F ), /* Latin Extended-A */
AF_UNIRANGE_REC( 0x0180, 0x024F ), /* Latin Extended-B */
AF_UNIRANGE_REC( 0x0250, 0x02AF ), /* IPA Extensions */
AF_UNIRANGE_REC( 0x02B9, 0x02DF ), /* Spacing Modifier Letters */
AF_UNIRANGE_REC( 0x02E5, 0x02FF ), /* ... continued */
AF_UNIRANGE_REC( 0x0300, 0x036F ), /* Combining Diacritical Marks */
AF_UNIRANGE_REC( 0x1AB0, 0x1ABE ), /* Combining Diacritical Marks Extended */
AF_UNIRANGE_REC( 0x1D00, 0x1D2B ), /* Phonetic Extensions */
AF_UNIRANGE_REC( 0x1D6B, 0x1D77 ), /* ... continued */
AF_UNIRANGE_REC( 0x1D79, 0x1D7F ), /* ... continued */
AF_UNIRANGE_REC( 0x1D80, 0x1D9A ), /* Phonetic Extensions Supplement */
AF_UNIRANGE_REC( 0x1DC0, 0x1DFF ), /* Combining Diacritical Marks Supplement */
AF_UNIRANGE_REC( 0x1E00, 0x1EFF ), /* Latin Extended Additional */
AF_UNIRANGE_REC( 0x2000, 0x206F ), /* General Punctuation */
AF_UNIRANGE_REC( 0x20A0, 0x20B8 ), /* Currency Symbols ... */
AF_UNIRANGE_REC( 0x20BA, 0x20CF ), /* ... except new Rupee sign */
AF_UNIRANGE_REC( 0x2150, 0x218F ), /* Number Forms */
AF_UNIRANGE_REC( 0x2C60, 0x2C7B ), /* Latin Extended-C */
AF_UNIRANGE_REC( 0x2C7E, 0x2C7F ), /* ... continued */
AF_UNIRANGE_REC( 0x2E00, 0x2E7F ), /* Supplemental Punctuation */
AF_UNIRANGE_REC( 0xA720, 0xA76F ), /* Latin Extended-D */
AF_UNIRANGE_REC( 0xA771, 0xA7F7 ), /* ... continued */
AF_UNIRANGE_REC( 0xA7FA, 0xA7FF ), /* ... continued */
AF_UNIRANGE_REC( 0xAB30, 0xAB5B ), /* Latin Extended-E */
AF_UNIRANGE_REC( 0xAB60, 0xAB6F ), /* ... continued */
AF_UNIRANGE_REC( 0xFB00, 0xFB06 ), /* Alphab. Present. Forms (Latin Ligs) */
AF_UNIRANGE_REC( 0x1D400, 0x1D7FF ), /* Mathematical Alphanumeric Symbols */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_latn_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0x005E, 0x0060 ),
AF_UNIRANGE_REC( 0x007E, 0x007E ),
AF_UNIRANGE_REC( 0x00A8, 0x00A9 ),
AF_UNIRANGE_REC( 0x00AE, 0x00B0 ),
AF_UNIRANGE_REC( 0x00B4, 0x00B4 ),
AF_UNIRANGE_REC( 0x00B8, 0x00B8 ),
AF_UNIRANGE_REC( 0x00BC, 0x00BE ),
AF_UNIRANGE_REC( 0x02B9, 0x02DF ),
AF_UNIRANGE_REC( 0x02E5, 0x02FF ),
AF_UNIRANGE_REC( 0x0300, 0x036F ),
AF_UNIRANGE_REC( 0x1AB0, 0x1ABE ),
AF_UNIRANGE_REC( 0x1DC0, 0x1DFF ),
AF_UNIRANGE_REC( 0x2017, 0x2017 ),
AF_UNIRANGE_REC( 0x203E, 0x203E ),
AF_UNIRANGE_REC( 0xA788, 0xA788 ),
AF_UNIRANGE_REC( 0xA7F8, 0xA7FA ),
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_latb_uniranges[] =
{
AF_UNIRANGE_REC( 0x1D62, 0x1D6A ), /* some small subscript letters */
AF_UNIRANGE_REC( 0x2080, 0x209C ), /* subscript digits and letters */
AF_UNIRANGE_REC( 0x2C7C, 0x2C7C ), /* latin subscript small letter j */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_latb_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_latp_uniranges[] =
{
AF_UNIRANGE_REC( 0x00AA, 0x00AA ), /* feminine ordinal indicator */
AF_UNIRANGE_REC( 0x00B2, 0x00B3 ), /* superscript two and three */
AF_UNIRANGE_REC( 0x00B9, 0x00BA ), /* superscript one, masc. ord. indic. */
AF_UNIRANGE_REC( 0x02B0, 0x02B8 ), /* some latin superscript mod. letters */
AF_UNIRANGE_REC( 0x02E0, 0x02E4 ), /* some IPA modifier letters */
AF_UNIRANGE_REC( 0x1D2C, 0x1D61 ), /* latin superscript modifier letters */
AF_UNIRANGE_REC( 0x1D78, 0x1D78 ), /* modifier letter cyrillic en */
AF_UNIRANGE_REC( 0x1D9B, 0x1DBF ), /* more modifier letters */
AF_UNIRANGE_REC( 0x2070, 0x207F ), /* superscript digits and letters */
AF_UNIRANGE_REC( 0x2C7D, 0x2C7D ), /* modifier letter capital v */
AF_UNIRANGE_REC( 0xA770, 0xA770 ), /* modifier letter us */
AF_UNIRANGE_REC( 0xA7F8, 0xA7F9 ), /* more modifier letters */
AF_UNIRANGE_REC( 0xAB5C, 0xAB5F ), /* more modifier letters */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_latp_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_lisu_uniranges[] =
{
AF_UNIRANGE_REC( 0xA4D0, 0xA4FF ), /* Lisu */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_lisu_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_mlym_uniranges[] =
{
AF_UNIRANGE_REC( 0x0D00, 0x0D7F ), /* Malayalam */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_mlym_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0x0D00, 0x0D01 ),
AF_UNIRANGE_REC( 0x0D3B, 0x0D3C ),
AF_UNIRANGE_REC( 0x0D4D, 0x0D4E ),
AF_UNIRANGE_REC( 0x0D62, 0x0D63 ),
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_medf_uniranges[] =
{
AF_UNIRANGE_REC( 0x16E40, 0x16E9F ), /* Medefaidrin */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_medf_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_mong_uniranges[] =
{
AF_UNIRANGE_REC( 0x1800, 0x18AF ), /* Mongolian */
AF_UNIRANGE_REC( 0x11660, 0x1167F ), /* Mongolian Supplement */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_mong_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0x1885, 0x1886 ),
AF_UNIRANGE_REC( 0x18A9, 0x18A9 ),
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_mymr_uniranges[] =
{
AF_UNIRANGE_REC( 0x1000, 0x109F ), /* Myanmar */
AF_UNIRANGE_REC( 0xA9E0, 0xA9FF ), /* Myanmar Extended-B */
AF_UNIRANGE_REC( 0xAA60, 0xAA7F ), /* Myanmar Extended-A */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_mymr_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0x102D, 0x1030 ),
AF_UNIRANGE_REC( 0x1032, 0x1037 ),
AF_UNIRANGE_REC( 0x103A, 0x103A ),
AF_UNIRANGE_REC( 0x103D, 0x103E ),
AF_UNIRANGE_REC( 0x1058, 0x1059 ),
AF_UNIRANGE_REC( 0x105E, 0x1060 ),
AF_UNIRANGE_REC( 0x1071, 0x1074 ),
AF_UNIRANGE_REC( 0x1082, 0x1082 ),
AF_UNIRANGE_REC( 0x1085, 0x1086 ),
AF_UNIRANGE_REC( 0x108D, 0x108D ),
AF_UNIRANGE_REC( 0xA9E5, 0xA9E5 ),
AF_UNIRANGE_REC( 0xAA7C, 0xAA7C ),
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_nkoo_uniranges[] =
{
AF_UNIRANGE_REC( 0x07C0, 0x07FF ), /* N'Ko */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_nkoo_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0x07EB, 0x07F5 ),
AF_UNIRANGE_REC( 0x07FD, 0x07FD ),
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_none_uniranges[] =
{
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_none_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_olck_uniranges[] =
{
AF_UNIRANGE_REC( 0x1C50, 0x1C7F ), /* Ol Chiki */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_olck_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_orkh_uniranges[] =
{
AF_UNIRANGE_REC( 0x10C00, 0x10C4F ), /* Old Turkic */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_orkh_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_osge_uniranges[] =
{
AF_UNIRANGE_REC( 0x104B0, 0x104FF ), /* Osage */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_osge_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_osma_uniranges[] =
{
AF_UNIRANGE_REC( 0x10480, 0x104AF ), /* Osmanya */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_osma_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_rohg_uniranges[] =
{
AF_UNIRANGE_REC( 0x10D00, 0x10D3F ), /* Hanifi Rohingya */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_rohg_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_saur_uniranges[] =
{
AF_UNIRANGE_REC( 0xA880, 0xA8DF ), /* Saurashtra */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_saur_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0xA880, 0xA881 ),
AF_UNIRANGE_REC( 0xA8B4, 0xA8C5 ),
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_shaw_uniranges[] =
{
AF_UNIRANGE_REC( 0x10450, 0x1047F ), /* Shavian */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_shaw_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_sinh_uniranges[] =
{
AF_UNIRANGE_REC( 0x0D80, 0x0DFF ), /* Sinhala */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_sinh_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0x0DCA, 0x0DCA ),
AF_UNIRANGE_REC( 0x0DD2, 0x0DD6 ),
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_sund_uniranges[] =
{
AF_UNIRANGE_REC( 0x1B80, 0x1BBF ), /* Sundanese */
AF_UNIRANGE_REC( 0x1CC0, 0x1CCF ), /* Sundanese Supplement */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_sund_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0x1B80, 0x1B82 ),
AF_UNIRANGE_REC( 0x1BA1, 0x1BAD ),
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_taml_uniranges[] =
{
AF_UNIRANGE_REC( 0x0B80, 0x0BFF ), /* Tamil */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_taml_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0x0B82, 0x0B82 ),
AF_UNIRANGE_REC( 0x0BC0, 0x0BC2 ),
AF_UNIRANGE_REC( 0x0BCD, 0x0BCD ),
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_tavt_uniranges[] =
{
AF_UNIRANGE_REC( 0xAA80, 0xAADF ), /* Tai Viet */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_tavt_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0xAAB0, 0xAAB0 ),
AF_UNIRANGE_REC( 0xAAB2, 0xAAB4 ),
AF_UNIRANGE_REC( 0xAAB7, 0xAAB8 ),
AF_UNIRANGE_REC( 0xAABE, 0xAABF ),
AF_UNIRANGE_REC( 0xAAC1, 0xAAC1 ),
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_telu_uniranges[] =
{
AF_UNIRANGE_REC( 0x0C00, 0x0C7F ), /* Telugu */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_telu_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0x0C00, 0x0C00 ),
AF_UNIRANGE_REC( 0x0C04, 0x0C04 ),
AF_UNIRANGE_REC( 0x0C3E, 0x0C40 ),
AF_UNIRANGE_REC( 0x0C46, 0x0C56 ),
AF_UNIRANGE_REC( 0x0C62, 0x0C63 ),
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_thai_uniranges[] =
{
AF_UNIRANGE_REC( 0x0E00, 0x0E7F ), /* Thai */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_thai_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0x0E31, 0x0E31 ),
AF_UNIRANGE_REC( 0x0E34, 0x0E3A ),
AF_UNIRANGE_REC( 0x0E47, 0x0E4E ),
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_tfng_uniranges[] =
{
AF_UNIRANGE_REC( 0x2D30, 0x2D7F ), /* Tifinagh */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_tfng_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_vaii_uniranges[] =
{
AF_UNIRANGE_REC( 0xA500, 0xA63F ), /* Vai */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_vaii_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0, 0 )
};
#ifdef AF_CONFIG_OPTION_INDIC
const AF_Script_UniRangeRec af_limb_uniranges[] =
{
AF_UNIRANGE_REC( 0x1900, 0x194F ), /* Limbu */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_limb_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0x1920, 0x1922 ),
AF_UNIRANGE_REC( 0x1927, 0x1934 ),
AF_UNIRANGE_REC( 0x1937, 0x193B ),
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_orya_uniranges[] =
{
AF_UNIRANGE_REC( 0x0B00, 0x0B7F ), /* Oriya */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_orya_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0x0B01, 0x0B02 ),
AF_UNIRANGE_REC( 0x0B3C, 0x0B3C ),
AF_UNIRANGE_REC( 0x0B3F, 0x0B3F ),
AF_UNIRANGE_REC( 0x0B41, 0x0B44 ),
AF_UNIRANGE_REC( 0x0B4D, 0x0B56 ),
AF_UNIRANGE_REC( 0x0B62, 0x0B63 ),
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_sylo_uniranges[] =
{
AF_UNIRANGE_REC( 0xA800, 0xA82F ), /* Syloti Nagri */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_sylo_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0xA802, 0xA802 ),
AF_UNIRANGE_REC( 0xA806, 0xA806 ),
AF_UNIRANGE_REC( 0xA80B, 0xA80B ),
AF_UNIRANGE_REC( 0xA825, 0xA826 ),
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_tibt_uniranges[] =
{
AF_UNIRANGE_REC( 0x0F00, 0x0FFF ), /* Tibetan */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_tibt_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0x0F18, 0x0F19 ),
AF_UNIRANGE_REC( 0x0F35, 0x0F35 ),
AF_UNIRANGE_REC( 0x0F37, 0x0F37 ),
AF_UNIRANGE_REC( 0x0F39, 0x0F39 ),
AF_UNIRANGE_REC( 0x0F3E, 0x0F3F ),
AF_UNIRANGE_REC( 0x0F71, 0x0F7E ),
AF_UNIRANGE_REC( 0x0F80, 0x0F84 ),
AF_UNIRANGE_REC( 0x0F86, 0x0F87 ),
AF_UNIRANGE_REC( 0x0F8D, 0x0FBC ),
AF_UNIRANGE_REC( 0, 0 )
};
#endif /* !AF_CONFIG_OPTION_INDIC */
#ifdef AF_CONFIG_OPTION_CJK
/* this corresponds to Unicode 6.0 */
const AF_Script_UniRangeRec af_hani_uniranges[] =
{
AF_UNIRANGE_REC( 0x1100, 0x11FF ), /* Hangul Jamo */
AF_UNIRANGE_REC( 0x2E80, 0x2EFF ), /* CJK Radicals Supplement */
AF_UNIRANGE_REC( 0x2F00, 0x2FDF ), /* Kangxi Radicals */
AF_UNIRANGE_REC( 0x2FF0, 0x2FFF ), /* Ideographic Description Characters */
AF_UNIRANGE_REC( 0x3000, 0x303F ), /* CJK Symbols and Punctuation */
AF_UNIRANGE_REC( 0x3040, 0x309F ), /* Hiragana */
AF_UNIRANGE_REC( 0x30A0, 0x30FF ), /* Katakana */
AF_UNIRANGE_REC( 0x3100, 0x312F ), /* Bopomofo */
AF_UNIRANGE_REC( 0x3130, 0x318F ), /* Hangul Compatibility Jamo */
AF_UNIRANGE_REC( 0x3190, 0x319F ), /* Kanbun */
AF_UNIRANGE_REC( 0x31A0, 0x31BF ), /* Bopomofo Extended */
AF_UNIRANGE_REC( 0x31C0, 0x31EF ), /* CJK Strokes */
AF_UNIRANGE_REC( 0x31F0, 0x31FF ), /* Katakana Phonetic Extensions */
AF_UNIRANGE_REC( 0x3300, 0x33FF ), /* CJK Compatibility */
AF_UNIRANGE_REC( 0x3400, 0x4DBF ), /* CJK Unified Ideographs Extension A */
AF_UNIRANGE_REC( 0x4DC0, 0x4DFF ), /* Yijing Hexagram Symbols */
AF_UNIRANGE_REC( 0x4E00, 0x9FFF ), /* CJK Unified Ideographs */
AF_UNIRANGE_REC( 0xA960, 0xA97F ), /* Hangul Jamo Extended-A */
AF_UNIRANGE_REC( 0xAC00, 0xD7AF ), /* Hangul Syllables */
AF_UNIRANGE_REC( 0xD7B0, 0xD7FF ), /* Hangul Jamo Extended-B */
AF_UNIRANGE_REC( 0xF900, 0xFAFF ), /* CJK Compatibility Ideographs */
AF_UNIRANGE_REC( 0xFE10, 0xFE1F ), /* Vertical forms */
AF_UNIRANGE_REC( 0xFE30, 0xFE4F ), /* CJK Compatibility Forms */
AF_UNIRANGE_REC( 0xFF00, 0xFFEF ), /* Halfwidth and Fullwidth Forms */
AF_UNIRANGE_REC( 0x1B000, 0x1B0FF ), /* Kana Supplement */
AF_UNIRANGE_REC( 0x1B100, 0x1B12F ), /* Kana Extended-A */
AF_UNIRANGE_REC( 0x1D300, 0x1D35F ), /* Tai Xuan Hing Symbols */
AF_UNIRANGE_REC( 0x20000, 0x2A6DF ), /* CJK Unified Ideographs Extension B */
AF_UNIRANGE_REC( 0x2A700, 0x2B73F ), /* CJK Unified Ideographs Extension C */
AF_UNIRANGE_REC( 0x2B740, 0x2B81F ), /* CJK Unified Ideographs Extension D */
AF_UNIRANGE_REC( 0x2B820, 0x2CEAF ), /* CJK Unified Ideographs Extension E */
AF_UNIRANGE_REC( 0x2CEB0, 0x2EBEF ), /* CJK Unified Ideographs Extension F */
AF_UNIRANGE_REC( 0x2F800, 0x2FA1F ), /* CJK Compatibility Ideographs Supplement */
AF_UNIRANGE_REC( 0, 0 )
};
const AF_Script_UniRangeRec af_hani_nonbase_uniranges[] =
{
AF_UNIRANGE_REC( 0x302A, 0x302F ),
AF_UNIRANGE_REC( 0x3190, 0x319F ),
AF_UNIRANGE_REC( 0, 0 )
};
#endif /* !AF_CONFIG_OPTION_CJK */
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/autofit/afranges.c
|
C++
|
gpl-3.0
| 34,997
|
/****************************************************************************
*
* afranges.h
*
* Auto-fitter Unicode script ranges (specification).
*
* Copyright (C) 2013-2022 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 AFRANGES_H_
#define AFRANGES_H_
#include "aftypes.h"
FT_BEGIN_HEADER
#undef SCRIPT
#define SCRIPT( s, S, d, h, H, ss ) \
extern const AF_Script_UniRangeRec af_ ## s ## _uniranges[];
#include "afscript.h"
#undef SCRIPT
#define SCRIPT( s, S, d, h, H, ss ) \
extern const AF_Script_UniRangeRec af_ ## s ## _nonbase_uniranges[];
#include "afscript.h"
/* */
FT_END_HEADER
#endif /* AFRANGES_H_ */
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/autofit/afranges.h
|
C++
|
gpl-3.0
| 1,083
|
/****************************************************************************
*
* afscript.h
*
* Auto-fitter scripts (specification only).
*
* Copyright (C) 2013-2022 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.
*
*/
/* The following part can be included multiple times. */
/* Define `SCRIPT' as needed. */
/* Add new scripts here. The first and second arguments are the */
/* script name in lowercase and uppercase, respectively, followed */
/* by a description string. Then comes the corresponding HarfBuzz */
/* script name tag, followed by a string of standard characters (to */
/* derive the standard width and height of stems). */
/* */
/* Note that fallback scripts only have a default style, thus we */
/* use `HB_SCRIPT_INVALID' as the HarfBuzz script name tag for */
/* them. */
SCRIPT( adlm, ADLM,
"Adlam",
HB_SCRIPT_ADLAM,
HINTING_BOTTOM_TO_TOP,
"\xF0\x9E\xA4\x8C \xF0\x9E\xA4\xAE" ) /* 𞤌 𞤮 */
SCRIPT( arab, ARAB,
"Arabic",
HB_SCRIPT_ARABIC,
HINTING_BOTTOM_TO_TOP,
"\xD9\x84 \xD8\xAD \xD9\x80" ) /* ل ح ـ */
SCRIPT( armn, ARMN,
"Armenian",
HB_SCRIPT_ARMENIAN,
HINTING_BOTTOM_TO_TOP,
"\xD5\xBD \xD5\x8D" ) /* ս Ս */
SCRIPT( avst, AVST,
"Avestan",
HB_SCRIPT_AVESTAN,
HINTING_BOTTOM_TO_TOP,
"\xF0\x90\xAC\x9A" ) /* 𐬚 */
SCRIPT( bamu, BAMU,
"Bamum",
HB_SCRIPT_BAMUM,
HINTING_BOTTOM_TO_TOP,
"\xEA\x9B\x81 \xEA\x9B\xAF" ) /* ꛁ ꛯ */
/* there are no simple forms for letters; we thus use two digit shapes */
SCRIPT( beng, BENG,
"Bengali",
HB_SCRIPT_BENGALI,
HINTING_TOP_TO_BOTTOM,
"\xE0\xA7\xA6 \xE0\xA7\xAA" ) /* ০ ৪ */
SCRIPT( buhd, BUHD,
"Buhid",
HB_SCRIPT_BUHID,
HINTING_BOTTOM_TO_TOP,
"\xE1\x9D\x8B \xE1\x9D\x8F" ) /* ᝋ ᝏ */
SCRIPT( cakm, CAKM,
"Chakma",
HB_SCRIPT_CHAKMA,
HINTING_BOTTOM_TO_TOP,
"\xF0\x91\x84\xA4 \xF0\x91\x84\x89 \xF0\x91\x84\x9B" ) /* 𑄤 𑄉 𑄛 */
SCRIPT( cans, CANS,
"Canadian Syllabics",
HB_SCRIPT_CANADIAN_SYLLABICS,
HINTING_BOTTOM_TO_TOP,
"\xE1\x91\x8C \xE1\x93\x9A" ) /* ᑌ ᓚ */
SCRIPT( cari, CARI,
"Carian",
HB_SCRIPT_CARIAN,
HINTING_BOTTOM_TO_TOP,
"\xF0\x90\x8A\xAB \xF0\x90\x8B\x89" ) /* 𐊫 𐋉 */
SCRIPT( cher, CHER,
"Cherokee",
HB_SCRIPT_CHEROKEE,
HINTING_BOTTOM_TO_TOP,
"\xE1\x8E\xA4 \xE1\x8F\x85 \xEA\xAE\x95" ) /* Ꭴ Ꮕ ꮕ */
SCRIPT( copt, COPT,
"Coptic",
HB_SCRIPT_COPTIC,
HINTING_BOTTOM_TO_TOP,
"\xE2\xB2\x9E \xE2\xB2\x9F" ) /* Ⲟ ⲟ */
SCRIPT( cprt, CPRT,
"Cypriot",
HB_SCRIPT_CYPRIOT,
HINTING_BOTTOM_TO_TOP,
"\xF0\x90\xA0\x85 \xF0\x90\xA0\xA3" ) /* 𐠅 𐠣 */
SCRIPT( cyrl, CYRL,
"Cyrillic",
HB_SCRIPT_CYRILLIC,
HINTING_BOTTOM_TO_TOP,
"\xD0\xBE \xD0\x9E" ) /* о О */
SCRIPT( deva, DEVA,
"Devanagari",
HB_SCRIPT_DEVANAGARI,
HINTING_TOP_TO_BOTTOM,
"\xE0\xA4\xA0 \xE0\xA4\xB5 \xE0\xA4\x9F" ) /* ठ व ट */
SCRIPT( dsrt, DSRT,
"Deseret",
HB_SCRIPT_DESERET,
HINTING_BOTTOM_TO_TOP,
"\xF0\x90\x90\x84 \xF0\x90\x90\xAC" ) /* 𐐄 𐐬 */
SCRIPT( ethi, ETHI,
"Ethiopic",
HB_SCRIPT_ETHIOPIC,
HINTING_BOTTOM_TO_TOP,
"\xE1\x8B\x90" ) /* ዐ */
SCRIPT( geor, GEOR,
"Georgian (Mkhedruli)",
HB_SCRIPT_GEORGIAN,
HINTING_BOTTOM_TO_TOP,
"\xE1\x83\x98 \xE1\x83\x94 \xE1\x83\x90 \xE1\xB2\xBF" ) /* ი ე ა Ი */
SCRIPT( geok, GEOK,
"Georgian (Khutsuri)",
HB_SCRIPT_INVALID,
HINTING_BOTTOM_TO_TOP,
"\xE1\x82\xB6 \xE1\x82\xB1 \xE2\xB4\x99" ) /* Ⴖ Ⴑ ⴙ */
SCRIPT( glag, GLAG,
"Glagolitic",
HB_SCRIPT_GLAGOLITIC,
HINTING_BOTTOM_TO_TOP,
"\xE2\xB0\x95 \xE2\xB1\x85" ) /* Ⱅ ⱅ */
SCRIPT( goth, GOTH,
"Gothic",
HB_SCRIPT_GOTHIC,
HINTING_TOP_TO_BOTTOM,
"\xF0\x90\x8C\xB4 \xF0\x90\x8C\xBE \xF0\x90\x8D\x83" ) /* 𐌴 𐌾 𐍃 */
SCRIPT( grek, GREK,
"Greek",
HB_SCRIPT_GREEK,
HINTING_BOTTOM_TO_TOP,
"\xCE\xBF \xCE\x9F" ) /* ο Ο */
SCRIPT( gujr, GUJR,
"Gujarati",
HB_SCRIPT_GUJARATI,
HINTING_BOTTOM_TO_TOP,
"\xE0\xAA\x9F \xE0\xAB\xA6" ) /* ટ ૦ */
SCRIPT( guru, GURU,
"Gurmukhi",
HB_SCRIPT_GURMUKHI,
HINTING_TOP_TO_BOTTOM,
"\xE0\xA8\xA0 \xE0\xA8\xB0 \xE0\xA9\xA6" ) /* ਠ ਰ ੦ */
SCRIPT( hebr, HEBR,
"Hebrew",
HB_SCRIPT_HEBREW,
HINTING_BOTTOM_TO_TOP,
"\xD7\x9D" ) /* ם */
SCRIPT( kali, KALI,
"Kayah Li",
HB_SCRIPT_KAYAH_LI,
HINTING_BOTTOM_TO_TOP,
"\xEA\xA4\x8D \xEA\xA4\x80" ) /* ꤍ ꤀ */
/* only digit zero has a simple shape in the Khmer script */
SCRIPT( khmr, KHMR,
"Khmer",
HB_SCRIPT_KHMER,
HINTING_BOTTOM_TO_TOP,
"\xE1\x9F\xA0" ) /* ០ */
SCRIPT( khms, KHMS,
"Khmer Symbols",
HB_SCRIPT_INVALID,
HINTING_BOTTOM_TO_TOP,
"\xE1\xA7\xA1 \xE1\xA7\xAA" ) /* ᧡ ᧪ */
SCRIPT( knda, KNDA,
"Kannada",
HB_SCRIPT_KANNADA,
HINTING_BOTTOM_TO_TOP,
"\xE0\xB3\xA6 \xE0\xB2\xAC" ) /* ೦ ಬ */
/* only digit zero has a simple shape in the Lao script */
SCRIPT( lao, LAO,
"Lao",
HB_SCRIPT_LAO,
HINTING_BOTTOM_TO_TOP,
"\xE0\xBB\x90" ) /* ໐ */
SCRIPT( latn, LATN,
"Latin",
HB_SCRIPT_LATIN,
HINTING_BOTTOM_TO_TOP,
"o O 0" )
SCRIPT( latb, LATB,
"Latin Subscript Fallback",
HB_SCRIPT_INVALID,
HINTING_BOTTOM_TO_TOP,
"\xE2\x82\x92 \xE2\x82\x80" ) /* ₒ ₀ */
SCRIPT( latp, LATP,
"Latin Superscript Fallback",
HB_SCRIPT_INVALID,
HINTING_BOTTOM_TO_TOP,
"\xE1\xB5\x92 \xE1\xB4\xBC \xE2\x81\xB0" ) /* ᵒ ᴼ ⁰ */
SCRIPT( lisu, LISU,
"Lisu",
HB_SCRIPT_LISU,
HINTING_BOTTOM_TO_TOP,
"\xEA\x93\xB3" ) /* ꓳ */
SCRIPT( mlym, MLYM,
"Malayalam",
HB_SCRIPT_MALAYALAM,
HINTING_BOTTOM_TO_TOP,
"\xE0\xB4\xA0 \xE0\xB4\xB1" ) /* ഠ റ */
SCRIPT( medf, MEDF,
"Medefaidrin",
HB_SCRIPT_MEDEFAIDRIN,
HINTING_BOTTOM_TO_TOP,
"\xF0\x96\xB9\xA1 \xF0\x96\xB9\x9B \xF0\x96\xB9\xAF" ) /* 𖹡 𖹛 𖹯 */
SCRIPT( mong, MONG,
"Mongolian",
HB_SCRIPT_MONGOLIAN,
HINTING_TOP_TO_BOTTOM,
"\xE1\xA1\x82 \xE1\xA0\xAA" ) /* ᡂ ᠪ */
SCRIPT( mymr, MYMR,
"Myanmar",
HB_SCRIPT_MYANMAR,
HINTING_BOTTOM_TO_TOP,
"\xE1\x80\x9D \xE1\x80\x84 \xE1\x80\x82" ) /* ဝ င ဂ */
SCRIPT( nkoo, NKOO,
"N'Ko",
HB_SCRIPT_NKO,
HINTING_BOTTOM_TO_TOP,
"\xDF\x8B \xDF\x80" ) /* ߋ ߀ */
SCRIPT( none, NONE,
"no script",
HB_SCRIPT_INVALID,
HINTING_BOTTOM_TO_TOP,
"" )
SCRIPT( olck, OLCK,
"Ol Chiki",
HB_SCRIPT_OL_CHIKI,
HINTING_BOTTOM_TO_TOP,
"\xE1\xB1\x9B" ) /* ᱛ */
SCRIPT( orkh, ORKH,
"Old Turkic",
HB_SCRIPT_OLD_TURKIC,
HINTING_BOTTOM_TO_TOP,
"\xF0\x90\xB0\x97" ) /* 𐰗 */
SCRIPT( osge, OSGE,
"Osage",
HB_SCRIPT_OSAGE,
HINTING_BOTTOM_TO_TOP,
"\xF0\x90\x93\x82 \xF0\x90\x93\xAA" ) /* 𐓂 𐓪 */
SCRIPT( osma, OSMA,
"Osmanya",
HB_SCRIPT_OSMANYA,
HINTING_BOTTOM_TO_TOP,
"\xF0\x90\x92\x86 \xF0\x90\x92\xA0" ) /* 𐒆 𐒠 */
SCRIPT( rohg, ROHG,
"Hanifi Rohingya",
HB_SCRIPT_HANIFI_ROHINGYA,
HINTING_BOTTOM_TO_TOP,
"\xF0\x90\xB4\xB0" ) /* 𐴰 */
SCRIPT( saur, SAUR,
"Saurashtra",
HB_SCRIPT_SAURASHTRA,
HINTING_BOTTOM_TO_TOP,
"\xEA\xA2\x9D \xEA\xA3\x90" ) /* ꢝ ꣐ */
SCRIPT( shaw, SHAW,
"Shavian",
HB_SCRIPT_SHAVIAN,
HINTING_BOTTOM_TO_TOP,
"\xF0\x90\x91\xB4" ) /* 𐑴 */
SCRIPT( sinh, SINH,
"Sinhala",
HB_SCRIPT_SINHALA,
HINTING_BOTTOM_TO_TOP,
"\xE0\xB6\xA7" ) /* ට */
/* only digit zero has a simple (round) shape in the Sundanese script */
SCRIPT( sund, SUND,
"Sundanese",
HB_SCRIPT_SUNDANESE,
HINTING_BOTTOM_TO_TOP,
"\xE1\xAE\xB0" ) /* ᮰ */
/* only digit zero has a simple (round) shape in the Tamil script */
SCRIPT( taml, TAML,
"Tamil",
HB_SCRIPT_TAMIL,
HINTING_BOTTOM_TO_TOP,
"\xE0\xAF\xA6" ) /* ௦ */
SCRIPT( tavt, TAVT,
"Tai Viet",
HB_SCRIPT_TAI_VIET,
HINTING_BOTTOM_TO_TOP,
"\xEA\xAA\x92 \xEA\xAA\xAB" ) /* ꪒ ꪫ */
/* there are no simple forms for letters; we thus use two digit shapes */
SCRIPT( telu, TELU,
"Telugu",
HB_SCRIPT_TELUGU,
HINTING_BOTTOM_TO_TOP,
"\xE0\xB1\xA6 \xE0\xB1\xA7" ) /* ౦ ౧ */
SCRIPT( tfng, TFNG,
"Tifinagh",
HB_SCRIPT_TIFINAGH,
HINTING_BOTTOM_TO_TOP,
"\xE2\xB5\x94" ) /* ⵔ */
SCRIPT( thai, THAI,
"Thai",
HB_SCRIPT_THAI,
HINTING_BOTTOM_TO_TOP,
"\xE0\xB8\xB2 \xE0\xB9\x85 \xE0\xB9\x90" ) /* า ๅ ๐ */
SCRIPT( vaii, VAII,
"Vai",
HB_SCRIPT_VAI,
HINTING_BOTTOM_TO_TOP,
"\xEA\x98\x93 \xEA\x96\x9C \xEA\x96\xB4" ) /* ꘓ ꖜ ꖴ */
#ifdef AF_CONFIG_OPTION_INDIC
SCRIPT( limb, LIMB,
"Limbu",
HB_SCRIPT_LIMBU,
HINTING_BOTTOM_TO_TOP,
"o" ) /* XXX */
SCRIPT( orya, ORYA,
"Oriya",
HB_SCRIPT_ORIYA,
HINTING_BOTTOM_TO_TOP,
"o" ) /* XXX */
SCRIPT( sylo, SYLO,
"Syloti Nagri",
HB_SCRIPT_SYLOTI_NAGRI,
HINTING_BOTTOM_TO_TOP,
"o" ) /* XXX */
SCRIPT( tibt, TIBT,
"Tibetan",
HB_SCRIPT_TIBETAN,
HINTING_BOTTOM_TO_TOP,
"o" ) /* XXX */
#endif /* AF_CONFIG_OPTION_INDIC */
#ifdef AF_CONFIG_OPTION_CJK
SCRIPT( hani, HANI,
"CJKV ideographs",
HB_SCRIPT_HAN,
HINTING_BOTTOM_TO_TOP,
"\xE7\x94\xB0 \xE5\x9B\x97" ) /* 田 囗 */
#endif /* AF_CONFIG_OPTION_CJK */
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/autofit/afscript.h
|
C++
|
gpl-3.0
| 11,464
|
/****************************************************************************
*
* afshaper.c
*
* HarfBuzz interface for accessing OpenType features (body).
*
* Copyright (C) 2013-2022 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.
*
*/
#include <freetype/freetype.h>
#include <freetype/ftadvanc.h>
#include "afglobal.h"
#include "aftypes.h"
#include "afshaper.h"
#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
/**************************************************************************
*
* The macro FT_COMPONENT is used in trace mode. It is an implicit
* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
* messages during execution.
*/
#undef FT_COMPONENT
#define FT_COMPONENT afshaper
/*
* We use `sets' (in the HarfBuzz sense, which comes quite near to the
* usual mathematical meaning) to manage both lookups and glyph indices.
*
* 1. For each coverage, collect lookup IDs in a set. Note that an
* auto-hinter `coverage' is represented by one `feature', and a
* feature consists of an arbitrary number of (font specific) `lookup's
* that actually do the mapping job. Please check the OpenType
* specification for more details on features and lookups.
*
* 2. Create glyph ID sets from the corresponding lookup sets.
*
* 3. The glyph set corresponding to AF_COVERAGE_DEFAULT is computed
* with all lookups specific to the OpenType script activated. It
* relies on the order of AF_DEFINE_STYLE_CLASS entries so that
* special coverages (like `oldstyle figures') don't get overwritten.
*
*/
/* load coverage tags */
#undef COVERAGE
#define COVERAGE( name, NAME, description, \
tag1, tag2, tag3, tag4 ) \
static const hb_tag_t name ## _coverage[] = \
{ \
HB_TAG( tag1, tag2, tag3, tag4 ), \
HB_TAG_NONE \
};
#include "afcover.h"
/* define mapping between coverage tags and AF_Coverage */
#undef COVERAGE
#define COVERAGE( name, NAME, description, \
tag1, tag2, tag3, tag4 ) \
name ## _coverage,
static const hb_tag_t* coverages[] =
{
#include "afcover.h"
NULL /* AF_COVERAGE_DEFAULT */
};
/* load HarfBuzz script tags */
#undef SCRIPT
#define SCRIPT( s, S, d, h, H, ss ) h,
static const hb_script_t scripts[] =
{
#include "afscript.h"
};
FT_Error
af_shaper_get_coverage( AF_FaceGlobals globals,
AF_StyleClass style_class,
FT_UShort* gstyles,
FT_Bool default_script )
{
hb_face_t* face;
hb_set_t* gsub_lookups = NULL; /* GSUB lookups for a given script */
hb_set_t* gsub_glyphs = NULL; /* glyphs covered by GSUB lookups */
hb_set_t* gpos_lookups = NULL; /* GPOS lookups for a given script */
hb_set_t* gpos_glyphs = NULL; /* glyphs covered by GPOS lookups */
hb_script_t script;
const hb_tag_t* coverage_tags;
hb_tag_t script_tags[] = { HB_TAG_NONE,
HB_TAG_NONE,
HB_TAG_NONE,
HB_TAG_NONE };
hb_codepoint_t idx;
#ifdef FT_DEBUG_LEVEL_TRACE
int count;
#endif
if ( !globals || !style_class || !gstyles )
return FT_THROW( Invalid_Argument );
face = hb_font_get_face( globals->hb_font );
coverage_tags = coverages[style_class->coverage];
script = scripts[style_class->script];
/* Convert a HarfBuzz script tag into the corresponding OpenType */
/* tag or tags -- some Indic scripts like Devanagari have an old */
/* and a new set of features. */
{
unsigned int tags_count = 3;
hb_tag_t tags[3];
hb_ot_tags_from_script_and_language( script,
HB_LANGUAGE_INVALID,
&tags_count,
tags,
NULL,
NULL );
script_tags[0] = tags_count > 0 ? tags[0] : HB_TAG_NONE;
script_tags[1] = tags_count > 1 ? tags[1] : HB_TAG_NONE;
script_tags[2] = tags_count > 2 ? tags[2] : HB_TAG_NONE;
}
/* If the second tag is HB_OT_TAG_DEFAULT_SCRIPT, change that to */
/* HB_TAG_NONE except for the default script. */
if ( default_script )
{
if ( script_tags[0] == HB_TAG_NONE )
script_tags[0] = HB_OT_TAG_DEFAULT_SCRIPT;
else
{
if ( script_tags[1] == HB_TAG_NONE )
script_tags[1] = HB_OT_TAG_DEFAULT_SCRIPT;
else if ( script_tags[1] != HB_OT_TAG_DEFAULT_SCRIPT )
script_tags[2] = HB_OT_TAG_DEFAULT_SCRIPT;
}
}
else
{
/* we use non-standard tags like `khms' for special purposes; */
/* HarfBuzz maps them to `DFLT', which we don't want to handle here */
if ( script_tags[0] == HB_OT_TAG_DEFAULT_SCRIPT )
goto Exit;
}
gsub_lookups = hb_set_create();
hb_ot_layout_collect_lookups( face,
HB_OT_TAG_GSUB,
script_tags,
NULL,
coverage_tags,
gsub_lookups );
if ( hb_set_is_empty( gsub_lookups ) )
goto Exit; /* nothing to do */
FT_TRACE4(( "GSUB lookups (style `%s'):\n",
af_style_names[style_class->style] ));
FT_TRACE4(( " " ));
#ifdef FT_DEBUG_LEVEL_TRACE
count = 0;
#endif
gsub_glyphs = hb_set_create();
for ( idx = HB_SET_VALUE_INVALID; hb_set_next( gsub_lookups, &idx ); )
{
#ifdef FT_DEBUG_LEVEL_TRACE
FT_TRACE4(( " %d", idx ));
count++;
#endif
/* get output coverage of GSUB feature */
hb_ot_layout_lookup_collect_glyphs( face,
HB_OT_TAG_GSUB,
idx,
NULL,
NULL,
NULL,
gsub_glyphs );
}
#ifdef FT_DEBUG_LEVEL_TRACE
if ( !count )
FT_TRACE4(( " (none)" ));
FT_TRACE4(( "\n" ));
FT_TRACE4(( "\n" ));
#endif
FT_TRACE4(( "GPOS lookups (style `%s'):\n",
af_style_names[style_class->style] ));
FT_TRACE4(( " " ));
gpos_lookups = hb_set_create();
hb_ot_layout_collect_lookups( face,
HB_OT_TAG_GPOS,
script_tags,
NULL,
coverage_tags,
gpos_lookups );
#ifdef FT_DEBUG_LEVEL_TRACE
count = 0;
#endif
gpos_glyphs = hb_set_create();
for ( idx = HB_SET_VALUE_INVALID; hb_set_next( gpos_lookups, &idx ); )
{
#ifdef FT_DEBUG_LEVEL_TRACE
FT_TRACE4(( " %d", idx ));
count++;
#endif
/* get input coverage of GPOS feature */
hb_ot_layout_lookup_collect_glyphs( face,
HB_OT_TAG_GPOS,
idx,
NULL,
gpos_glyphs,
NULL,
NULL );
}
#ifdef FT_DEBUG_LEVEL_TRACE
if ( !count )
FT_TRACE4(( " (none)" ));
FT_TRACE4(( "\n" ));
FT_TRACE4(( "\n" ));
#endif
/*
* We now check whether we can construct blue zones, using glyphs
* covered by the feature only. In case there is not a single zone
* (this is, not a single character is covered), we skip this coverage.
*
*/
if ( style_class->coverage != AF_COVERAGE_DEFAULT )
{
AF_Blue_Stringset bss = style_class->blue_stringset;
const AF_Blue_StringRec* bs = &af_blue_stringsets[bss];
FT_Bool found = 0;
for ( ; bs->string != AF_BLUE_STRING_MAX; bs++ )
{
const char* p = &af_blue_strings[bs->string];
while ( *p )
{
hb_codepoint_t ch;
GET_UTF8_CHAR( ch, p );
for ( idx = HB_SET_VALUE_INVALID; hb_set_next( gsub_lookups,
&idx ); )
{
hb_codepoint_t gidx = FT_Get_Char_Index( globals->face, ch );
if ( hb_ot_layout_lookup_would_substitute( face, idx,
&gidx, 1, 1 ) )
{
found = 1;
break;
}
}
}
}
if ( !found )
{
FT_TRACE4(( " no blue characters found; style skipped\n" ));
goto Exit;
}
}
/*
* Various OpenType features might use the same glyphs at different
* vertical positions; for example, superscript and subscript glyphs
* could be the same. However, the auto-hinter is completely
* agnostic of OpenType features after the feature analysis has been
* completed: The engine then simply receives a glyph index and returns a
* hinted and usually rendered glyph.
*
* Consider the superscript feature of font `pala.ttf': Some of the
* glyphs are `real', this is, they have a zero vertical offset, but
* most of them are small caps glyphs shifted up to the superscript
* position (this is, the `sups' feature is present in both the GSUB and
* GPOS tables). The code for blue zones computation actually uses a
* feature's y offset so that the `real' glyphs get correct hints. But
* later on it is impossible to decide whether a glyph index belongs to,
* say, the small caps or superscript feature.
*
* For this reason, we don't assign a style to a glyph if the current
* feature covers the glyph in both the GSUB and the GPOS tables. This
* is quite a broad condition, assuming that
*
* (a) glyphs that get used in multiple features are present in a
* feature without vertical shift,
*
* and
*
* (b) a feature's GPOS data really moves the glyph vertically.
*
* Not fulfilling condition (a) makes a font larger; it would also
* reduce the number of glyphs that could be addressed directly without
* using OpenType features, so this assumption is rather strong.
*
* Condition (b) is much weaker, and there might be glyphs which get
* missed. However, the OpenType features we are going to handle are
* primarily located in GSUB, and HarfBuzz doesn't provide an API to
* directly get the necessary information from the GPOS table. A
* possible solution might be to directly parse the GPOS table to find
* out whether a glyph gets shifted vertically, but this is something I
* would like to avoid if not really necessary.
*
* Note that we don't follow this logic for the default coverage.
* Complex scripts like Devanagari have mandatory GPOS features to
* position many glyph elements, using mark-to-base or mark-to-ligature
* tables; the number of glyphs missed due to condition (b) would be far
* too large.
*
*/
if ( style_class->coverage != AF_COVERAGE_DEFAULT )
hb_set_subtract( gsub_glyphs, gpos_glyphs );
#ifdef FT_DEBUG_LEVEL_TRACE
FT_TRACE4(( " glyphs without GPOS data (`*' means already assigned)" ));
count = 0;
#endif
for ( idx = HB_SET_VALUE_INVALID; hb_set_next( gsub_glyphs, &idx ); )
{
#ifdef FT_DEBUG_LEVEL_TRACE
if ( !( count % 10 ) )
{
FT_TRACE4(( "\n" ));
FT_TRACE4(( " " ));
}
FT_TRACE4(( " %d", idx ));
count++;
#endif
/* glyph indices returned by `hb_ot_layout_lookup_collect_glyphs' */
/* can be arbitrary: some fonts use fake indices for processing */
/* internal to GSUB or GPOS, which is fully valid */
if ( idx >= (hb_codepoint_t)globals->glyph_count )
continue;
if ( gstyles[idx] == AF_STYLE_UNASSIGNED )
gstyles[idx] = (FT_UShort)style_class->style;
#ifdef FT_DEBUG_LEVEL_TRACE
else
FT_TRACE4(( "*" ));
#endif
}
#ifdef FT_DEBUG_LEVEL_TRACE
if ( !count )
{
FT_TRACE4(( "\n" ));
FT_TRACE4(( " (none)" ));
}
FT_TRACE4(( "\n" ));
FT_TRACE4(( "\n" ));
#endif
Exit:
hb_set_destroy( gsub_lookups );
hb_set_destroy( gsub_glyphs );
hb_set_destroy( gpos_lookups );
hb_set_destroy( gpos_glyphs );
return FT_Err_Ok;
}
/* construct HarfBuzz features */
#undef COVERAGE
#define COVERAGE( name, NAME, description, \
tag1, tag2, tag3, tag4 ) \
static const hb_feature_t name ## _feature[] = \
{ \
{ \
HB_TAG( tag1, tag2, tag3, tag4 ), \
1, 0, (unsigned int)-1 \
} \
};
#include "afcover.h"
/* define mapping between HarfBuzz features and AF_Coverage */
#undef COVERAGE
#define COVERAGE( name, NAME, description, \
tag1, tag2, tag3, tag4 ) \
name ## _feature,
static const hb_feature_t* features[] =
{
#include "afcover.h"
NULL /* AF_COVERAGE_DEFAULT */
};
void*
af_shaper_buf_create( FT_Face face )
{
FT_UNUSED( face );
return (void*)hb_buffer_create();
}
void
af_shaper_buf_destroy( FT_Face face,
void* buf )
{
FT_UNUSED( face );
hb_buffer_destroy( (hb_buffer_t*)buf );
}
const char*
af_shaper_get_cluster( const char* p,
AF_StyleMetrics metrics,
void* buf_,
unsigned int* count )
{
AF_StyleClass style_class;
const hb_feature_t* feature;
FT_Int upem;
const char* q;
int len;
hb_buffer_t* buf = (hb_buffer_t*)buf_;
hb_font_t* font;
hb_codepoint_t dummy;
upem = (FT_Int)metrics->globals->face->units_per_EM;
style_class = metrics->style_class;
feature = features[style_class->coverage];
font = metrics->globals->hb_font;
/* we shape at a size of units per EM; this means font units */
hb_font_set_scale( font, upem, upem );
while ( *p == ' ' )
p++;
/* count bytes up to next space (or end of buffer) */
q = p;
while ( !( *q == ' ' || *q == '\0' ) )
GET_UTF8_CHAR( dummy, q );
len = (int)( q - p );
/* feed character(s) to the HarfBuzz buffer */
hb_buffer_clear_contents( buf );
hb_buffer_add_utf8( buf, p, len, 0, len );
/* we let HarfBuzz guess the script and writing direction */
hb_buffer_guess_segment_properties( buf );
/* shape buffer, which means conversion from character codes to */
/* glyph indices, possibly applying a feature */
hb_shape( font, buf, feature, feature ? 1 : 0 );
if ( feature )
{
hb_buffer_t* hb_buf = metrics->globals->hb_buf;
unsigned int gcount;
hb_glyph_info_t* ginfo;
unsigned int hb_gcount;
hb_glyph_info_t* hb_ginfo;
/* we have to check whether applying a feature does actually change */
/* glyph indices; otherwise the affected glyph or glyphs aren't */
/* available at all in the feature */
hb_buffer_clear_contents( hb_buf );
hb_buffer_add_utf8( hb_buf, p, len, 0, len );
hb_buffer_guess_segment_properties( hb_buf );
hb_shape( font, hb_buf, NULL, 0 );
ginfo = hb_buffer_get_glyph_infos( buf, &gcount );
hb_ginfo = hb_buffer_get_glyph_infos( hb_buf, &hb_gcount );
if ( gcount == hb_gcount )
{
unsigned int i;
for (i = 0; i < gcount; i++ )
if ( ginfo[i].codepoint != hb_ginfo[i].codepoint )
break;
if ( i == gcount )
{
/* both buffers have identical glyph indices */
hb_buffer_clear_contents( buf );
}
}
}
*count = hb_buffer_get_length( buf );
#ifdef FT_DEBUG_LEVEL_TRACE
if ( feature && *count > 1 )
FT_TRACE1(( "af_shaper_get_cluster:"
" input character mapped to multiple glyphs\n" ));
#endif
return q;
}
FT_ULong
af_shaper_get_elem( AF_StyleMetrics metrics,
void* buf_,
unsigned int idx,
FT_Long* advance,
FT_Long* y_offset )
{
hb_buffer_t* buf = (hb_buffer_t*)buf_;
hb_glyph_info_t* ginfo;
hb_glyph_position_t* gpos;
unsigned int gcount;
FT_UNUSED( metrics );
ginfo = hb_buffer_get_glyph_infos( buf, &gcount );
gpos = hb_buffer_get_glyph_positions( buf, &gcount );
if ( idx >= gcount )
return 0;
if ( advance )
*advance = gpos[idx].x_advance;
if ( y_offset )
*y_offset = gpos[idx].y_offset;
return ginfo[idx].codepoint;
}
#else /* !FT_CONFIG_OPTION_USE_HARFBUZZ */
FT_Error
af_shaper_get_coverage( AF_FaceGlobals globals,
AF_StyleClass style_class,
FT_UShort* gstyles,
FT_Bool default_script )
{
FT_UNUSED( globals );
FT_UNUSED( style_class );
FT_UNUSED( gstyles );
FT_UNUSED( default_script );
return FT_Err_Ok;
}
void*
af_shaper_buf_create( FT_Face face )
{
FT_UNUSED( face );
return NULL;
}
void
af_shaper_buf_destroy( FT_Face face,
void* buf )
{
FT_UNUSED( face );
FT_UNUSED( buf );
}
const char*
af_shaper_get_cluster( const char* p,
AF_StyleMetrics metrics,
void* buf_,
unsigned int* count )
{
FT_Face face = metrics->globals->face;
FT_ULong ch, dummy = 0;
FT_ULong* buf = (FT_ULong*)buf_;
while ( *p == ' ' )
p++;
GET_UTF8_CHAR( ch, p );
/* since we don't have an engine to handle clusters, */
/* we scan the characters but return zero */
while ( !( *p == ' ' || *p == '\0' ) )
GET_UTF8_CHAR( dummy, p );
if ( dummy )
{
*buf = 0;
*count = 0;
}
else
{
*buf = FT_Get_Char_Index( face, ch );
*count = 1;
}
return p;
}
FT_ULong
af_shaper_get_elem( AF_StyleMetrics metrics,
void* buf_,
unsigned int idx,
FT_Long* advance,
FT_Long* y_offset )
{
FT_Face face = metrics->globals->face;
FT_ULong glyph_index = *(FT_ULong*)buf_;
FT_UNUSED( idx );
if ( advance )
FT_Get_Advance( face,
glyph_index,
FT_LOAD_NO_SCALE |
FT_LOAD_NO_HINTING |
FT_LOAD_IGNORE_TRANSFORM,
advance );
if ( y_offset )
*y_offset = 0;
return glyph_index;
}
#endif /* !FT_CONFIG_OPTION_USE_HARFBUZZ */
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/autofit/afshaper.c
|
C++
|
gpl-3.0
| 20,127
|
/****************************************************************************
*
* afshaper.h
*
* HarfBuzz interface for accessing OpenType features (specification).
*
* Copyright (C) 2013-2022 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 AFSHAPER_H_
#define AFSHAPER_H_
#include <freetype/freetype.h>
#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
#include <hb.h>
#include <hb-ot.h>
#include <hb-ft.h>
#endif
FT_BEGIN_HEADER
FT_Error
af_shaper_get_coverage( AF_FaceGlobals globals,
AF_StyleClass style_class,
FT_UShort* gstyles,
FT_Bool default_script );
void*
af_shaper_buf_create( FT_Face face );
void
af_shaper_buf_destroy( FT_Face face,
void* buf );
const char*
af_shaper_get_cluster( const char* p,
AF_StyleMetrics metrics,
void* buf_,
unsigned int* count );
FT_ULong
af_shaper_get_elem( AF_StyleMetrics metrics,
void* buf_,
unsigned int idx,
FT_Long* x_advance,
FT_Long* y_offset );
/* */
FT_END_HEADER
#endif /* AFSHAPER_H_ */
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/autofit/afshaper.h
|
C++
|
gpl-3.0
| 1,655
|
/****************************************************************************
*
* afstyles.h
*
* Auto-fitter styles (specification only).
*
* Copyright (C) 2013-2022 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.
*
*/
/* The following part can be included multiple times. */
/* Define `STYLE' as needed. */
/* Add new styles here. The first and second arguments are the */
/* style name in lowercase and uppercase, respectively, followed */
/* by a description string. The next arguments are the */
/* corresponding writing system, script, blue stringset, and */
/* coverage. */
/* */
/* Note that styles using `AF_COVERAGE_DEFAULT' should always */
/* come after styles with other coverages. Also note that */
/* fallback scripts only use `AF_COVERAGE_DEFAULT' for its */
/* style. */
/* */
/* Example: */
/* */
/* STYLE( cyrl_dflt, CYRL_DFLT, */
/* "Cyrillic default style", */
/* AF_WRITING_SYSTEM_LATIN, */
/* AF_SCRIPT_CYRL, */
/* AF_BLUE_STRINGSET_CYRL, */
/* AF_COVERAGE_DEFAULT ) */
#undef STYLE_LATIN
#define STYLE_LATIN( s, S, f, F, ds, df, C ) \
STYLE( s ## _ ## f, S ## _ ## F, \
ds " " df " style", \
AF_WRITING_SYSTEM_LATIN, \
AF_SCRIPT_ ## S, \
AF_BLUE_STRINGSET_ ## S, \
AF_COVERAGE_ ## C )
#undef META_STYLE_LATIN
#define META_STYLE_LATIN( s, S, ds ) \
STYLE_LATIN( s, S, c2cp, C2CP, ds, \
"petite capitals from capitals", \
PETITE_CAPITALS_FROM_CAPITALS ) \
STYLE_LATIN( s, S, c2sc, C2SC, ds, \
"small capitals from capitals", \
SMALL_CAPITALS_FROM_CAPITALS ) \
STYLE_LATIN( s, S, ordn, ORDN, ds, \
"ordinals", \
ORDINALS ) \
STYLE_LATIN( s, S, pcap, PCAP, ds, \
"petite capitals", \
PETITE_CAPITALS ) \
STYLE_LATIN( s, S, sinf, SINF, ds, \
"scientific inferiors", \
SCIENTIFIC_INFERIORS ) \
STYLE_LATIN( s, S, smcp, SMCP, ds, \
"small capitals", \
SMALL_CAPITALS ) \
STYLE_LATIN( s, S, subs, SUBS, ds, \
"subscript", \
SUBSCRIPT ) \
STYLE_LATIN( s, S, sups, SUPS, ds, \
"superscript", \
SUPERSCRIPT ) \
STYLE_LATIN( s, S, titl, TITL, ds, \
"titling", \
TITLING ) \
STYLE_LATIN( s, S, dflt, DFLT, ds, \
"default", \
DEFAULT )
STYLE( adlm_dflt, ADLM_DFLT,
"Adlam default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_ADLM,
AF_BLUE_STRINGSET_ADLM,
AF_COVERAGE_DEFAULT )
STYLE( arab_dflt, ARAB_DFLT,
"Arabic default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_ARAB,
AF_BLUE_STRINGSET_ARAB,
AF_COVERAGE_DEFAULT )
STYLE( armn_dflt, ARMN_DFLT,
"Armenian default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_ARMN,
AF_BLUE_STRINGSET_ARMN,
AF_COVERAGE_DEFAULT )
STYLE( avst_dflt, AVST_DFLT,
"Avestan default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_AVST,
AF_BLUE_STRINGSET_AVST,
AF_COVERAGE_DEFAULT )
STYLE( bamu_dflt, BAMU_DFLT,
"Bamum default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_BAMU,
AF_BLUE_STRINGSET_BAMU,
AF_COVERAGE_DEFAULT )
STYLE( beng_dflt, BENG_DFLT,
"Bengali default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_BENG,
AF_BLUE_STRINGSET_BENG,
AF_COVERAGE_DEFAULT )
STYLE( buhd_dflt, BUHD_DFLT,
"Buhid default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_BUHD,
AF_BLUE_STRINGSET_BUHD,
AF_COVERAGE_DEFAULT )
STYLE( cakm_dflt, CAKM_DFLT,
"Chakma default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_CAKM,
AF_BLUE_STRINGSET_CAKM,
AF_COVERAGE_DEFAULT )
STYLE( cans_dflt, CANS_DFLT,
"Canadian Syllabics default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_CANS,
AF_BLUE_STRINGSET_CANS,
AF_COVERAGE_DEFAULT )
STYLE( cari_dflt, CARI_DFLT,
"Carian default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_CARI,
AF_BLUE_STRINGSET_CARI,
AF_COVERAGE_DEFAULT )
STYLE( cher_dflt, CHER_DFLT,
"Cherokee default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_CHER,
AF_BLUE_STRINGSET_CHER,
AF_COVERAGE_DEFAULT )
STYLE( copt_dflt, COPT_DFLT,
"Coptic default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_COPT,
AF_BLUE_STRINGSET_COPT,
AF_COVERAGE_DEFAULT )
STYLE( cprt_dflt, CPRT_DFLT,
"Cypriot default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_CPRT,
AF_BLUE_STRINGSET_CPRT,
AF_COVERAGE_DEFAULT )
META_STYLE_LATIN( cyrl, CYRL, "Cyrillic" )
STYLE( deva_dflt, DEVA_DFLT,
"Devanagari default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_DEVA,
AF_BLUE_STRINGSET_DEVA,
AF_COVERAGE_DEFAULT )
STYLE( dsrt_dflt, DSRT_DFLT,
"Deseret default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_DSRT,
AF_BLUE_STRINGSET_DSRT,
AF_COVERAGE_DEFAULT )
STYLE( ethi_dflt, ETHI_DFLT,
"Ethiopic default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_ETHI,
AF_BLUE_STRINGSET_ETHI,
AF_COVERAGE_DEFAULT )
STYLE( geor_dflt, GEOR_DFLT,
"Georgian (Mkhedruli) default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_GEOR,
AF_BLUE_STRINGSET_GEOR,
AF_COVERAGE_DEFAULT )
STYLE( geok_dflt, GEOK_DFLT,
"Georgian (Khutsuri) default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_GEOK,
AF_BLUE_STRINGSET_GEOK,
AF_COVERAGE_DEFAULT )
STYLE( glag_dflt, GLAG_DFLT,
"Glagolitic default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_GLAG,
AF_BLUE_STRINGSET_GLAG,
AF_COVERAGE_DEFAULT )
STYLE( goth_dflt, GOTH_DFLT,
"Gothic default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_GOTH,
AF_BLUE_STRINGSET_GOTH,
AF_COVERAGE_DEFAULT )
META_STYLE_LATIN( grek, GREK, "Greek" )
STYLE( gujr_dflt, GUJR_DFLT,
"Gujarati default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_GUJR,
AF_BLUE_STRINGSET_GUJR,
AF_COVERAGE_DEFAULT )
STYLE( guru_dflt, GURU_DFLT,
"Gurmukhi default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_GURU,
AF_BLUE_STRINGSET_GURU,
AF_COVERAGE_DEFAULT )
STYLE( hebr_dflt, HEBR_DFLT,
"Hebrew default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_HEBR,
AF_BLUE_STRINGSET_HEBR,
AF_COVERAGE_DEFAULT )
STYLE( kali_dflt, KALI_DFLT,
"Kayah Li default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_KALI,
AF_BLUE_STRINGSET_KALI,
AF_COVERAGE_DEFAULT )
STYLE( khmr_dflt, KHMR_DFLT,
"Khmer default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_KHMR,
AF_BLUE_STRINGSET_KHMR,
AF_COVERAGE_DEFAULT )
STYLE( khms_dflt, KHMS_DFLT,
"Khmer Symbols default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_KHMS,
AF_BLUE_STRINGSET_KHMS,
AF_COVERAGE_DEFAULT )
STYLE( knda_dflt, KNDA_DFLT,
"Kannada default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_KNDA,
AF_BLUE_STRINGSET_KNDA,
AF_COVERAGE_DEFAULT )
STYLE( lao_dflt, LAO_DFLT,
"Lao default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_LAO,
AF_BLUE_STRINGSET_LAO,
AF_COVERAGE_DEFAULT )
META_STYLE_LATIN( latn, LATN, "Latin" )
STYLE( latb_dflt, LATB_DFLT,
"Latin subscript fallback default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_LATB,
AF_BLUE_STRINGSET_LATB,
AF_COVERAGE_DEFAULT )
STYLE( latp_dflt, LATP_DFLT,
"Latin superscript fallback default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_LATP,
AF_BLUE_STRINGSET_LATP,
AF_COVERAGE_DEFAULT )
STYLE( lisu_dflt, LISU_DFLT,
"Lisu default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_LISU,
AF_BLUE_STRINGSET_LISU,
AF_COVERAGE_DEFAULT )
STYLE( mlym_dflt, MLYM_DFLT,
"Malayalam default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_MLYM,
AF_BLUE_STRINGSET_MLYM,
AF_COVERAGE_DEFAULT )
STYLE( medf_dflt, MEDF_DFLT,
"Medefaidrin default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_MEDF,
AF_BLUE_STRINGSET_MEDF,
AF_COVERAGE_DEFAULT )
STYLE( mong_dflt, MONG_DFLT,
"Mongolian default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_MONG,
AF_BLUE_STRINGSET_MONG,
AF_COVERAGE_DEFAULT )
STYLE( mymr_dflt, MYMR_DFLT,
"Myanmar default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_MYMR,
AF_BLUE_STRINGSET_MYMR,
AF_COVERAGE_DEFAULT )
STYLE( nkoo_dflt, NKOO_DFLT,
"N'Ko default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_NKOO,
AF_BLUE_STRINGSET_NKOO,
AF_COVERAGE_DEFAULT )
STYLE( none_dflt, NONE_DFLT,
"no style",
AF_WRITING_SYSTEM_DUMMY,
AF_SCRIPT_NONE,
AF_BLUE_STRINGSET_NONE,
AF_COVERAGE_DEFAULT )
STYLE( olck_dflt, OLCK_DFLT,
"Ol Chiki default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_OLCK,
AF_BLUE_STRINGSET_OLCK,
AF_COVERAGE_DEFAULT )
STYLE( orkh_dflt, ORKH_DFLT,
"Old Turkic default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_ORKH,
AF_BLUE_STRINGSET_ORKH,
AF_COVERAGE_DEFAULT )
STYLE( osge_dflt, OSGE_DFLT,
"Osage default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_OSGE,
AF_BLUE_STRINGSET_OSGE,
AF_COVERAGE_DEFAULT )
STYLE( osma_dflt, OSMA_DFLT,
"Osmanya default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_OSMA,
AF_BLUE_STRINGSET_OSMA,
AF_COVERAGE_DEFAULT )
STYLE( rohg_dflt, ROHG_DFLT,
"Hanifi Rohingya default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_ROHG,
AF_BLUE_STRINGSET_ROHG,
AF_COVERAGE_DEFAULT )
STYLE( saur_dflt, SAUR_DFLT,
"Saurashtra default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_SAUR,
AF_BLUE_STRINGSET_SAUR,
AF_COVERAGE_DEFAULT )
STYLE( shaw_dflt, SHAW_DFLT,
"Shavian default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_SHAW,
AF_BLUE_STRINGSET_SHAW,
AF_COVERAGE_DEFAULT )
STYLE( sinh_dflt, SINH_DFLT,
"Sinhala default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_SINH,
AF_BLUE_STRINGSET_SINH,
AF_COVERAGE_DEFAULT )
STYLE( sund_dflt, SUND_DFLT,
"Sundanese default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_SUND,
AF_BLUE_STRINGSET_SUND,
AF_COVERAGE_DEFAULT )
STYLE( taml_dflt, TAML_DFLT,
"Tamil default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_TAML,
AF_BLUE_STRINGSET_TAML,
AF_COVERAGE_DEFAULT )
STYLE( tavt_dflt, TAVT_DFLT,
"Tai Viet default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_TAVT,
AF_BLUE_STRINGSET_TAVT,
AF_COVERAGE_DEFAULT )
STYLE( telu_dflt, TELU_DFLT,
"Telugu default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_TELU,
AF_BLUE_STRINGSET_TELU,
AF_COVERAGE_DEFAULT )
STYLE( tfng_dflt, TFNG_DFLT,
"Tifinagh default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_TFNG,
AF_BLUE_STRINGSET_TFNG,
AF_COVERAGE_DEFAULT )
STYLE( thai_dflt, THAI_DFLT,
"Thai default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_THAI,
AF_BLUE_STRINGSET_THAI,
AF_COVERAGE_DEFAULT )
STYLE( vaii_dflt, VAII_DFLT,
"Vai default style",
AF_WRITING_SYSTEM_LATIN,
AF_SCRIPT_VAII,
AF_BLUE_STRINGSET_VAII,
AF_COVERAGE_DEFAULT )
#ifdef AF_CONFIG_OPTION_INDIC
/* no blue stringset support for the Indic writing system yet */
#undef STYLE_DEFAULT_INDIC
#define STYLE_DEFAULT_INDIC( s, S, d ) \
STYLE( s ## _dflt, S ## _DFLT, \
d " default style", \
AF_WRITING_SYSTEM_INDIC, \
AF_SCRIPT_ ## S, \
(AF_Blue_Stringset)0, \
AF_COVERAGE_DEFAULT )
STYLE_DEFAULT_INDIC( limb, LIMB, "Limbu" )
STYLE_DEFAULT_INDIC( orya, ORYA, "Oriya" )
STYLE_DEFAULT_INDIC( sylo, SYLO, "Syloti Nagri" )
STYLE_DEFAULT_INDIC( tibt, TIBT, "Tibetan" )
#endif /* AF_CONFIG_OPTION_INDIC */
#ifdef AF_CONFIG_OPTION_CJK
STYLE( hani_dflt, HANI_DFLT,
"CJKV ideographs default style",
AF_WRITING_SYSTEM_CJK,
AF_SCRIPT_HANI,
AF_BLUE_STRINGSET_HANI,
AF_COVERAGE_DEFAULT )
#endif /* AF_CONFIG_OPTION_CJK */
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/autofit/afstyles.h
|
C++
|
gpl-3.0
| 15,115
|
/****************************************************************************
*
* aftypes.h
*
* Auto-fitter types (specification only).
*
* Copyright (C) 2003-2022 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.
*
*/
/*************************************************************************
*
* The auto-fitter is a complete rewrite of the old auto-hinter.
* Its main feature is the ability to differentiate between different
* writing systems and scripts in order to apply specific rules.
*
* The code has also been compartmentalized into several entities that
* should make algorithmic experimentation easier than with the old
* code.
*
*************************************************************************/
#ifndef AFTYPES_H_
#define AFTYPES_H_
#include <freetype/freetype.h>
#include <freetype/ftoutln.h>
#include <freetype/internal/ftobjs.h>
#include <freetype/internal/ftdebug.h>
#include "afblue.h"
#ifdef FT_DEBUG_AUTOFIT
#include FT_CONFIG_STANDARD_LIBRARY_H
#endif
FT_BEGIN_HEADER
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** D E B U G G I N G *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
#ifdef FT_DEBUG_AUTOFIT
extern int _af_debug_disable_horz_hints;
extern int _af_debug_disable_vert_hints;
extern int _af_debug_disable_blue_hints;
extern void* _af_debug_hints;
#endif /* FT_DEBUG_AUTOFIT */
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** U T I L I T Y S T U F F *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
typedef struct AF_WidthRec_
{
FT_Pos org; /* original position/width in font units */
FT_Pos cur; /* current/scaled position/width in device subpixels */
FT_Pos fit; /* current/fitted position/width in device subpixels */
} AF_WidthRec, *AF_Width;
FT_LOCAL( void )
af_sort_pos( FT_UInt count,
FT_Pos* table );
FT_LOCAL( void )
af_sort_and_quantize_widths( FT_UInt* count,
AF_Width widths,
FT_Pos threshold );
/*
* opaque handle to glyph-specific hints -- see `afhints.h' for more
* details
*/
typedef struct AF_GlyphHintsRec_* AF_GlyphHints;
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** S C A L E R S *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
/*
* A scaler models the target pixel device that will receive the
* auto-hinted glyph image.
*/
#define AF_SCALER_FLAG_NO_HORIZONTAL 1U /* disable horizontal hinting */
#define AF_SCALER_FLAG_NO_VERTICAL 2U /* disable vertical hinting */
#define AF_SCALER_FLAG_NO_ADVANCE 4U /* disable advance hinting */
typedef struct AF_ScalerRec_
{
FT_Face face; /* source font face */
FT_Fixed x_scale; /* from font units to 1/64th device pixels */
FT_Fixed y_scale; /* from font units to 1/64th device pixels */
FT_Pos x_delta; /* in 1/64th device pixels */
FT_Pos y_delta; /* in 1/64th device pixels */
FT_Render_Mode render_mode; /* monochrome, anti-aliased, LCD, etc. */
FT_UInt32 flags; /* additional control flags, see above */
} AF_ScalerRec, *AF_Scaler;
#define AF_SCALER_EQUAL_SCALES( a, b ) \
( (a)->x_scale == (b)->x_scale && \
(a)->y_scale == (b)->y_scale && \
(a)->x_delta == (b)->x_delta && \
(a)->y_delta == (b)->y_delta )
typedef struct AF_StyleMetricsRec_* AF_StyleMetrics;
/*
* This function parses an FT_Face to compute global metrics for
* a specific style.
*/
typedef FT_Error
(*AF_WritingSystem_InitMetricsFunc)( AF_StyleMetrics metrics,
FT_Face face );
typedef void
(*AF_WritingSystem_ScaleMetricsFunc)( AF_StyleMetrics metrics,
AF_Scaler scaler );
typedef void
(*AF_WritingSystem_DoneMetricsFunc)( AF_StyleMetrics metrics );
typedef void
(*AF_WritingSystem_GetStdWidthsFunc)( AF_StyleMetrics metrics,
FT_Pos* stdHW,
FT_Pos* stdVW );
typedef FT_Error
(*AF_WritingSystem_InitHintsFunc)( AF_GlyphHints hints,
AF_StyleMetrics metrics );
typedef FT_Error
(*AF_WritingSystem_ApplyHintsFunc)( FT_UInt glyph_index,
AF_GlyphHints hints,
FT_Outline* outline,
AF_StyleMetrics metrics );
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** W R I T I N G S Y S T E M S *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
/*
* For the auto-hinter, a writing system consists of multiple scripts that
* can be handled similarly *in a typographical way*; the relationship is
* not based on history. For example, both the Greek and the unrelated
* Armenian scripts share the same features like ascender, descender,
* x-height, etc. Essentially, a writing system is covered by a
* submodule of the auto-fitter; it contains
*
* - a specific global analyzer that computes global metrics specific to
* the script (based on script-specific characters to identify ascender
* height, x-height, etc.),
*
* - a specific glyph analyzer that computes segments and edges for each
* glyph covered by the script,
*
* - a specific grid-fitting algorithm that distorts the scaled glyph
* outline according to the results of the glyph analyzer.
*/
#undef WRITING_SYSTEM
#define WRITING_SYSTEM( ws, WS ) \
AF_WRITING_SYSTEM_ ## WS,
/* The list of known writing systems. */
typedef enum AF_WritingSystem_
{
#include "afws-iter.h"
AF_WRITING_SYSTEM_MAX /* do not remove */
} AF_WritingSystem;
typedef struct AF_WritingSystemClassRec_
{
AF_WritingSystem writing_system;
FT_Offset style_metrics_size;
AF_WritingSystem_InitMetricsFunc style_metrics_init;
AF_WritingSystem_ScaleMetricsFunc style_metrics_scale;
AF_WritingSystem_DoneMetricsFunc style_metrics_done;
AF_WritingSystem_GetStdWidthsFunc style_metrics_getstdw;
AF_WritingSystem_InitHintsFunc style_hints_init;
AF_WritingSystem_ApplyHintsFunc style_hints_apply;
} AF_WritingSystemClassRec;
typedef const AF_WritingSystemClassRec* AF_WritingSystemClass;
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** S C R I P T S *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
/*
* Each script is associated with two sets of Unicode ranges to test
* whether the font face supports the script, and which non-base
* characters the script contains.
*
* We use four-letter script tags from the OpenType specification,
* extended by `NONE', which indicates `no script'.
*/
#undef SCRIPT
#define SCRIPT( s, S, d, h, H, ss ) \
AF_SCRIPT_ ## S,
/* The list of known scripts. */
typedef enum AF_Script_
{
#include "afscript.h"
AF_SCRIPT_MAX /* do not remove */
} AF_Script;
typedef struct AF_Script_UniRangeRec_
{
FT_UInt32 first;
FT_UInt32 last;
} AF_Script_UniRangeRec;
#define AF_UNIRANGE_REC( a, b ) { (FT_UInt32)(a), (FT_UInt32)(b) }
typedef const AF_Script_UniRangeRec* AF_Script_UniRange;
typedef struct AF_ScriptClassRec_
{
AF_Script script;
/* last element in the ranges must be { 0, 0 } */
AF_Script_UniRange script_uni_ranges;
AF_Script_UniRange script_uni_nonbase_ranges;
FT_Bool top_to_bottom_hinting;
const char* standard_charstring; /* for default width and height */
} AF_ScriptClassRec;
typedef const AF_ScriptClassRec* AF_ScriptClass;
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** C O V E R A G E S *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
/*
* Usually, a font contains more glyphs than can be addressed by its
* character map.
*
* In the PostScript font world, encoding vectors specific to a given
* task are used to select such glyphs, and these glyphs can be often
* recognized by having a suffix in its glyph names. For example, a
* superscript glyph `A' might be called `A.sup'. Unfortunately, this
* naming scheme is not standardized and thus unusable for us.
*
* In the OpenType world, a better solution was invented, namely
* `features', which cleanly separate a character's input encoding from
* the corresponding glyph's appearance, and which don't use glyph names
* at all. For our purposes, and slightly generalized, an OpenType
* feature is a name of a mapping that maps character codes to
* non-standard glyph indices (features get used for other things also).
* For example, the `sups' feature provides superscript glyphs, thus
* mapping character codes like `A' or `B' to superscript glyph
* representation forms. How this mapping happens is completely
* uninteresting to us.
*
* For the auto-hinter, a `coverage' represents all glyphs of an OpenType
* feature collected in a set (as listed below) that can be hinted
* together. To continue the above example, superscript glyphs must not
* be hinted together with normal glyphs because the blue zones
* completely differ.
*
* Note that FreeType itself doesn't compute coverages; it only provides
* the glyphs addressable by the default Unicode character map. Instead,
* we use the HarfBuzz library (if available), which has many functions
* exactly for this purpose.
*
* AF_COVERAGE_DEFAULT is special: It should cover everything that isn't
* listed separately (including the glyphs addressable by the character
* map). In case HarfBuzz isn't available, it exactly covers the glyphs
* addressable by the character map.
*
*/
#undef COVERAGE
#define COVERAGE( name, NAME, description, \
tag1, tag2, tag3, tag4 ) \
AF_COVERAGE_ ## NAME,
typedef enum AF_Coverage_
{
#include "afcover.h"
AF_COVERAGE_DEFAULT
} AF_Coverage;
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** S T Y L E S *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
/*
* The topmost structure for modelling the auto-hinter glyph input data
* is a `style class', grouping everything together.
*/
#undef STYLE
#define STYLE( s, S, d, ws, sc, ss, c ) \
AF_STYLE_ ## S,
/* The list of known styles. */
typedef enum AF_Style_
{
#include "afstyles.h"
AF_STYLE_MAX /* do not remove */
} AF_Style;
typedef struct AF_StyleClassRec_
{
AF_Style style;
AF_WritingSystem writing_system;
AF_Script script;
AF_Blue_Stringset blue_stringset;
AF_Coverage coverage;
} AF_StyleClassRec;
typedef const AF_StyleClassRec* AF_StyleClass;
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** S T Y L E M E T R I C S *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
typedef struct AF_FaceGlobalsRec_* AF_FaceGlobals;
/* This is the main structure that combines everything. Autofit modules */
/* specific to writing systems derive their structures from it, for */
/* example `AF_LatinMetrics'. */
typedef struct AF_StyleMetricsRec_
{
AF_StyleClass style_class;
AF_ScalerRec scaler;
FT_Bool digits_have_same_width;
AF_FaceGlobals globals; /* to access properties */
} AF_StyleMetricsRec;
#define AF_HINTING_BOTTOM_TO_TOP 0
#define AF_HINTING_TOP_TO_BOTTOM 1
/* Declare and define vtables for classes */
#define AF_DECLARE_WRITING_SYSTEM_CLASS( writing_system_class ) \
FT_CALLBACK_TABLE const AF_WritingSystemClassRec \
writing_system_class;
#define AF_DEFINE_WRITING_SYSTEM_CLASS( \
writing_system_class, \
system, \
m_size, \
m_init, \
m_scale, \
m_done, \
m_stdw, \
h_init, \
h_apply ) \
FT_CALLBACK_TABLE_DEF \
const AF_WritingSystemClassRec writing_system_class = \
{ \
system, \
\
m_size, \
\
m_init, \
m_scale, \
m_done, \
m_stdw, \
\
h_init, \
h_apply \
};
#define AF_DECLARE_SCRIPT_CLASS( script_class ) \
FT_CALLBACK_TABLE const AF_ScriptClassRec \
script_class;
#define AF_DEFINE_SCRIPT_CLASS( \
script_class, \
script, \
ranges, \
nonbase_ranges, \
top_to_bottom, \
std_charstring ) \
FT_CALLBACK_TABLE_DEF \
const AF_ScriptClassRec script_class = \
{ \
script, \
ranges, \
nonbase_ranges, \
top_to_bottom, \
std_charstring, \
};
#define AF_DECLARE_STYLE_CLASS( style_class ) \
FT_CALLBACK_TABLE const AF_StyleClassRec \
style_class;
#define AF_DEFINE_STYLE_CLASS( \
style_class, \
style, \
writing_system, \
script, \
blue_stringset, \
coverage ) \
FT_CALLBACK_TABLE_DEF \
const AF_StyleClassRec style_class = \
{ \
style, \
writing_system, \
script, \
blue_stringset, \
coverage \
};
/* */
FT_END_HEADER
#endif /* AFTYPES_H_ */
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/autofit/aftypes.h
|
C++
|
gpl-3.0
| 18,638
|
/****************************************************************************
*
* afws-decl.h
*
* Auto-fitter writing system declarations (specification only).
*
* Copyright (C) 2013-2022 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 AFWS_DECL_H_
#define AFWS_DECL_H_
/* Since preprocessor directives can't create other preprocessor */
/* directives, we have to include the header files manually. */
#include "afdummy.h"
#include "aflatin.h"
#include "afcjk.h"
#include "afindic.h"
#endif /* AFWS_DECL_H_ */
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/autofit/afws-decl.h
|
C++
|
gpl-3.0
| 872
|
/****************************************************************************
*
* afws-iter.h
*
* Auto-fitter writing systems iterator (specification only).
*
* Copyright (C) 2013-2022 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 header may be included multiple times. */
/* Define `WRITING_SYSTEM' as needed. */
/* Add new writing systems here. The arguments are the writing system */
/* name in lowercase and uppercase, respectively. */
WRITING_SYSTEM( dummy, DUMMY )
WRITING_SYSTEM( latin, LATIN )
WRITING_SYSTEM( cjk, CJK )
WRITING_SYSTEM( indic, INDIC )
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/autofit/afws-iter.h
|
C++
|
gpl-3.0
| 966
|
/****************************************************************************
*
* autofit.c
*
* Auto-fitter module (body).
*
* Copyright (C) 2003-2022 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.
*
*/
#define FT_MAKE_OPTION_SINGLE_OBJECT
#include "afblue.c"
#include "afcjk.c"
#include "afdummy.c"
#include "afglobal.c"
#include "afhints.c"
#include "afindic.c"
#include "aflatin.c"
#include "afloader.c"
#include "afmodule.c"
#include "afranges.c"
#include "afshaper.c"
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/autofit/autofit.c
|
C++
|
gpl-3.0
| 813
|
#
# FreeType 2 auto-fitter module definition
#
# Copyright (C) 2003-2022 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.
FTMODULE_H_COMMANDS += AUTOFIT_MODULE
define AUTOFIT_MODULE
$(OPEN_DRIVER) FT_Module_Class, autofit_module_class $(CLOSE_DRIVER)
$(ECHO_DRIVER)autofit $(ECHO_DRIVER_DESC)automatic hinting module$(ECHO_DRIVER_DONE)
endef
# EOF
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/autofit/module.mk
|
mk
|
gpl-3.0
| 662
|
#
# FreeType 2 auto-fitter module configuration rules
#
# Copyright (C) 2003-2022 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.
# AUTOF driver directory
#
AUTOF_DIR := $(SRC_DIR)/autofit
# compilation flags for the driver
#
AUTOF_COMPILE := $(CC) $(ANSIFLAGS) \
$I$(subst /,$(COMPILER_SEP),$(AUTOF_DIR)) \
$(INCLUDE_FLAGS) \
$(FT_CFLAGS)
# AUTOF driver sources (i.e., C files)
#
AUTOF_DRV_SRC := $(AUTOF_DIR)/afblue.c \
$(AUTOF_DIR)/afcjk.c \
$(AUTOF_DIR)/afdummy.c \
$(AUTOF_DIR)/afglobal.c \
$(AUTOF_DIR)/afhints.c \
$(AUTOF_DIR)/afindic.c \
$(AUTOF_DIR)/aflatin.c \
$(AUTOF_DIR)/afloader.c \
$(AUTOF_DIR)/afmodule.c \
$(AUTOF_DIR)/afranges.c \
$(AUTOF_DIR)/afshaper.c \
# AUTOF driver headers
#
AUTOF_DRV_H := $(AUTOF_DRV_SRC:%c=%h) \
$(AUTOF_DIR)/afcover.h \
$(AUTOF_DIR)/aferrors.h \
$(AUTOF_DIR)/afscript.h \
$(AUTOF_DIR)/afstyles.h \
$(AUTOF_DIR)/aftypes.h \
$(AUTOF_DIR)/afws-decl.h \
$(AUTOF_DIR)/afws-iter.h
# AUTOF driver object(s)
#
# AUTOF_DRV_OBJ_M is used during `multi' builds.
# AUTOF_DRV_OBJ_S is used during `single' builds.
#
AUTOF_DRV_OBJ_M := $(AUTOF_DRV_SRC:$(AUTOF_DIR)/%.c=$(OBJ_DIR)/%.$O)
AUTOF_DRV_OBJ_S := $(OBJ_DIR)/autofit.$O
# AUTOF driver source file for single build
#
AUTOF_DRV_SRC_S := $(AUTOF_DIR)/autofit.c
# AUTOF driver - single object
#
$(AUTOF_DRV_OBJ_S): $(AUTOF_DRV_SRC_S) $(AUTOF_DRV_SRC) \
$(FREETYPE_H) $(AUTOF_DRV_H)
$(AUTOF_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $(AUTOF_DRV_SRC_S))
# AUTOF driver - multiple objects
#
$(OBJ_DIR)/%.$O: $(AUTOF_DIR)/%.c $(FREETYPE_H) $(AUTOF_DRV_H)
$(AUTOF_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<)
# update main driver object lists
#
DRV_OBJS_S += $(AUTOF_DRV_OBJ_S)
DRV_OBJS_M += $(AUTOF_DRV_OBJ_M)
# EOF
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/autofit/rules.mk
|
mk
|
gpl-3.0
| 2,461
|
/****************************************************************************
*
* ftadvanc.c
*
* Quick computation of advance widths (body).
*
* Copyright (C) 2008-2022 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.
*
*/
#include <freetype/internal/ftdebug.h>
#include <freetype/ftadvanc.h>
#include <freetype/internal/ftobjs.h>
static FT_Error
_ft_face_scale_advances( FT_Face face,
FT_Fixed* advances,
FT_UInt count,
FT_Int32 flags )
{
FT_Fixed scale;
FT_UInt nn;
if ( flags & FT_LOAD_NO_SCALE )
return FT_Err_Ok;
if ( !face->size )
return FT_THROW( Invalid_Size_Handle );
if ( flags & FT_LOAD_VERTICAL_LAYOUT )
scale = face->size->metrics.y_scale;
else
scale = face->size->metrics.x_scale;
/* this must be the same scaling as to get linear{Hori,Vert}Advance */
/* (see `FT_Load_Glyph' implementation in src/base/ftobjs.c) */
for ( nn = 0; nn < count; nn++ )
advances[nn] = FT_MulDiv( advances[nn], scale, 64 );
return FT_Err_Ok;
}
/* at the moment, we can perform fast advance retrieval only in */
/* the following cases: */
/* */
/* - unscaled load */
/* - unhinted load */
/* - light-hinted load */
/* - if a variations font, it must have an `HVAR' or `VVAR' */
/* table (thus the old MM or GX fonts don't qualify; this */
/* gets checked by the driver-specific functions) */
#define LOAD_ADVANCE_FAST_CHECK( face, flags ) \
( flags & ( FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING ) || \
FT_LOAD_TARGET_MODE( flags ) == FT_RENDER_MODE_LIGHT )
/* documentation is in ftadvanc.h */
FT_EXPORT_DEF( FT_Error )
FT_Get_Advance( FT_Face face,
FT_UInt gindex,
FT_Int32 flags,
FT_Fixed *padvance )
{
FT_Face_GetAdvancesFunc func;
if ( !face )
return FT_THROW( Invalid_Face_Handle );
if ( !padvance )
return FT_THROW( Invalid_Argument );
if ( gindex >= (FT_UInt)face->num_glyphs )
return FT_THROW( Invalid_Glyph_Index );
func = face->driver->clazz->get_advances;
if ( func && LOAD_ADVANCE_FAST_CHECK( face, flags ) )
{
FT_Error error;
error = func( face, gindex, 1, flags, padvance );
if ( !error )
return _ft_face_scale_advances( face, padvance, 1, flags );
if ( FT_ERR_NEQ( error, Unimplemented_Feature ) )
return error;
}
return FT_Get_Advances( face, gindex, 1, flags, padvance );
}
/* documentation is in ftadvanc.h */
FT_EXPORT_DEF( FT_Error )
FT_Get_Advances( FT_Face face,
FT_UInt start,
FT_UInt count,
FT_Int32 flags,
FT_Fixed *padvances )
{
FT_Error error = FT_Err_Ok;
FT_Face_GetAdvancesFunc func;
FT_UInt num, end, nn;
FT_Int factor;
if ( !face )
return FT_THROW( Invalid_Face_Handle );
if ( !padvances )
return FT_THROW( Invalid_Argument );
num = (FT_UInt)face->num_glyphs;
end = start + count;
if ( start >= num || end < start || end > num )
return FT_THROW( Invalid_Glyph_Index );
if ( count == 0 )
return FT_Err_Ok;
func = face->driver->clazz->get_advances;
if ( func && LOAD_ADVANCE_FAST_CHECK( face, flags ) )
{
error = func( face, start, count, flags, padvances );
if ( !error )
return _ft_face_scale_advances( face, padvances, count, flags );
if ( FT_ERR_NEQ( error, Unimplemented_Feature ) )
return error;
}
error = FT_Err_Ok;
if ( flags & FT_ADVANCE_FLAG_FAST_ONLY )
return FT_THROW( Unimplemented_Feature );
flags |= (FT_UInt32)FT_LOAD_ADVANCE_ONLY;
factor = ( flags & FT_LOAD_NO_SCALE ) ? 1 : 1024;
for ( nn = 0; nn < count; nn++ )
{
error = FT_Load_Glyph( face, start + nn, flags );
if ( error )
break;
/* scale from 26.6 to 16.16, unless NO_SCALE was requested */
padvances[nn] = ( flags & FT_LOAD_VERTICAL_LAYOUT )
? face->glyph->advance.y * factor
: face->glyph->advance.x * factor;
}
return error;
}
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/base/ftadvanc.c
|
C++
|
gpl-3.0
| 4,906
|
/****************************************************************************
*
* ftbase.c
*
* Single object library component (body only).
*
* Copyright (C) 1996-2022 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.
*
*/
#define FT_MAKE_OPTION_SINGLE_OBJECT
#include "ftadvanc.c"
#include "ftcalc.c"
#include "ftcolor.c"
#include "ftdbgmem.c"
#include "fterrors.c"
#include "ftfntfmt.c"
#include "ftgloadr.c"
#include "fthash.c"
#include "ftlcdfil.c"
#include "ftmac.c"
#include "ftobjs.c"
#include "ftoutln.c"
#include "ftpsprop.c"
#include "ftrfork.c"
#include "ftsnames.c"
#include "ftstream.c"
#include "fttrigon.c"
#include "ftutil.c"
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/base/ftbase.c
|
C++
|
gpl-3.0
| 980
|
/****************************************************************************
*
* ftbase.h
*
* Private functions used in the `base' module (specification).
*
* Copyright (C) 2008-2022 by
* David Turner, Robert Wilhelm, Werner Lemberg, and suzuki toshiya.
*
* 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 FTBASE_H_
#define FTBASE_H_
#include <freetype/internal/ftobjs.h>
FT_BEGIN_HEADER
FT_DECLARE_GLYPH( ft_bitmap_glyph_class )
FT_DECLARE_GLYPH( ft_outline_glyph_class )
FT_DECLARE_GLYPH( ft_svg_glyph_class )
#ifdef FT_CONFIG_OPTION_MAC_FONTS
/* MacOS resource fork cannot exceed 16MB at least for Carbon code; */
/* see https://support.microsoft.com/en-us/kb/130437 */
#define FT_MAC_RFORK_MAX_LEN 0x00FFFFFFUL
/* Assume the stream is sfnt-wrapped PS Type1 or sfnt-wrapped CID-keyed */
/* font, and try to load a face specified by the face_index. */
FT_LOCAL( FT_Error )
open_face_PS_from_sfnt_stream( FT_Library library,
FT_Stream stream,
FT_Long face_index,
FT_Int num_params,
FT_Parameter *params,
FT_Face *aface );
/* Create a new FT_Face given a buffer and a driver name. */
/* From ftmac.c. */
FT_LOCAL( FT_Error )
open_face_from_buffer( FT_Library library,
FT_Byte* base,
FT_ULong size,
FT_Long face_index,
const char* driver_name,
FT_Face *aface );
#if defined( FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK ) && \
!defined( FT_MACINTOSH )
/* Mac OS X/Darwin kernel often changes recommended method to access */
/* the resource fork and older methods makes the kernel issue the */
/* warning of deprecated method. To calm it down, the methods based */
/* on Darwin VFS should be grouped and skip the rest methods after */
/* the case the resource is opened but found to lack a font in it. */
FT_LOCAL( FT_Bool )
ft_raccess_rule_by_darwin_vfs( FT_Library library, FT_UInt rule_index );
#endif
#endif /* FT_CONFIG_OPTION_MAC_FONTS */
FT_END_HEADER
#endif /* FTBASE_H_ */
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/base/ftbase.h
|
C++
|
gpl-3.0
| 2,651
|
/****************************************************************************
*
* ftbbox.c
*
* FreeType bbox computation (body).
*
* Copyright (C) 1996-2022 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 component has a _single_ role: to compute exact outline bounding
* boxes.
*
*/
#include <freetype/internal/ftdebug.h>
#include <freetype/ftbbox.h>
#include <freetype/ftimage.h>
#include <freetype/ftoutln.h>
#include <freetype/internal/ftcalc.h>
#include <freetype/internal/ftobjs.h>
typedef struct TBBox_Rec_
{
FT_Vector last;
FT_BBox bbox;
} TBBox_Rec;
#define FT_UPDATE_BBOX( p, bbox ) \
FT_BEGIN_STMNT \
if ( p->x < bbox.xMin ) \
bbox.xMin = p->x; \
if ( p->x > bbox.xMax ) \
bbox.xMax = p->x; \
if ( p->y < bbox.yMin ) \
bbox.yMin = p->y; \
if ( p->y > bbox.yMax ) \
bbox.yMax = p->y; \
FT_END_STMNT
#define CHECK_X( p, bbox ) \
( p->x < bbox.xMin || p->x > bbox.xMax )
#define CHECK_Y( p, bbox ) \
( p->y < bbox.yMin || p->y > bbox.yMax )
/**************************************************************************
*
* @Function:
* BBox_Move_To
*
* @Description:
* This function is used as a `move_to' emitter during
* FT_Outline_Decompose(). It simply records the destination point
* in `user->last'. We also update bbox in case contour starts with
* an implicit `on' point.
*
* @Input:
* to ::
* A pointer to the destination vector.
*
* @InOut:
* user ::
* A pointer to the current walk context.
*
* @Return:
* Always 0. Needed for the interface only.
*/
static int
BBox_Move_To( FT_Vector* to,
TBBox_Rec* user )
{
FT_UPDATE_BBOX( to, user->bbox );
user->last = *to;
return 0;
}
/**************************************************************************
*
* @Function:
* BBox_Line_To
*
* @Description:
* This function is used as a `line_to' emitter during
* FT_Outline_Decompose(). It simply records the destination point
* in `user->last'; no further computations are necessary because
* bbox already contains both explicit ends of the line segment.
*
* @Input:
* to ::
* A pointer to the destination vector.
*
* @InOut:
* user ::
* A pointer to the current walk context.
*
* @Return:
* Always 0. Needed for the interface only.
*/
static int
BBox_Line_To( FT_Vector* to,
TBBox_Rec* user )
{
user->last = *to;
return 0;
}
/**************************************************************************
*
* @Function:
* BBox_Conic_Check
*
* @Description:
* Find the extrema of a 1-dimensional conic Bezier curve and update
* a bounding range. This version uses direct computation, as it
* doesn't need square roots.
*
* @Input:
* y1 ::
* The start coordinate.
*
* y2 ::
* The coordinate of the control point.
*
* y3 ::
* The end coordinate.
*
* @InOut:
* min ::
* The address of the current minimum.
*
* max ::
* The address of the current maximum.
*/
static void
BBox_Conic_Check( FT_Pos y1,
FT_Pos y2,
FT_Pos y3,
FT_Pos* min,
FT_Pos* max )
{
/* This function is only called when a control off-point is outside */
/* the bbox that contains all on-points. It finds a local extremum */
/* within the segment, equal to (y1*y3 - y2*y2)/(y1 - 2*y2 + y3). */
/* Or, offsetting from y2, we get */
y1 -= y2;
y3 -= y2;
y2 += FT_MulDiv( y1, y3, y1 + y3 );
if ( y2 < *min )
*min = y2;
if ( y2 > *max )
*max = y2;
}
/**************************************************************************
*
* @Function:
* BBox_Conic_To
*
* @Description:
* This function is used as a `conic_to' emitter during
* FT_Outline_Decompose(). It checks a conic Bezier curve with the
* current bounding box, and computes its extrema if necessary to
* update it.
*
* @Input:
* control ::
* A pointer to a control point.
*
* to ::
* A pointer to the destination vector.
*
* @InOut:
* user ::
* The address of the current walk context.
*
* @Return:
* Always 0. Needed for the interface only.
*
* @Note:
* In the case of a non-monotonous arc, we compute directly the
* extremum coordinates, as it is sufficiently fast.
*/
static int
BBox_Conic_To( FT_Vector* control,
FT_Vector* to,
TBBox_Rec* user )
{
/* in case `to' is implicit and not included in bbox yet */
FT_UPDATE_BBOX( to, user->bbox );
if ( CHECK_X( control, user->bbox ) )
BBox_Conic_Check( user->last.x,
control->x,
to->x,
&user->bbox.xMin,
&user->bbox.xMax );
if ( CHECK_Y( control, user->bbox ) )
BBox_Conic_Check( user->last.y,
control->y,
to->y,
&user->bbox.yMin,
&user->bbox.yMax );
user->last = *to;
return 0;
}
/**************************************************************************
*
* @Function:
* BBox_Cubic_Check
*
* @Description:
* Find the extrema of a 1-dimensional cubic Bezier curve and
* update a bounding range. This version uses iterative splitting
* because it is faster than the exact solution with square roots.
*
* @Input:
* p1 ::
* The start coordinate.
*
* p2 ::
* The coordinate of the first control point.
*
* p3 ::
* The coordinate of the second control point.
*
* p4 ::
* The end coordinate.
*
* @InOut:
* min ::
* The address of the current minimum.
*
* max ::
* The address of the current maximum.
*/
static FT_Pos
cubic_peak( FT_Pos q1,
FT_Pos q2,
FT_Pos q3,
FT_Pos q4 )
{
FT_Pos peak = 0;
FT_Int shift;
/* This function finds a peak of a cubic segment if it is above 0 */
/* using iterative bisection of the segment, or returns 0. */
/* The fixed-point arithmetic of bisection is inherently stable */
/* but may loose accuracy in the two lowest bits. To compensate, */
/* we upscale the segment if there is room. Large values may need */
/* to be downscaled to avoid overflows during bisection. */
/* It is called with either q2 or q3 positive, which is necessary */
/* for the peak to exist and avoids undefined FT_MSB. */
shift = 27 - FT_MSB( (FT_UInt32)( FT_ABS( q1 ) |
FT_ABS( q2 ) |
FT_ABS( q3 ) |
FT_ABS( q4 ) ) );
if ( shift > 0 )
{
/* upscaling too much just wastes time */
if ( shift > 2 )
shift = 2;
q1 *= 1 << shift;
q2 *= 1 << shift;
q3 *= 1 << shift;
q4 *= 1 << shift;
}
else
{
q1 >>= -shift;
q2 >>= -shift;
q3 >>= -shift;
q4 >>= -shift;
}
/* for a peak to exist above 0, the cubic segment must have */
/* at least one of its control off-points above 0. */
while ( q2 > 0 || q3 > 0 )
{
/* determine which half contains the maximum and split */
if ( q1 + q2 > q3 + q4 ) /* first half */
{
q4 = q4 + q3;
q3 = q3 + q2;
q2 = q2 + q1;
q4 = q4 + q3;
q3 = q3 + q2;
q4 = ( q4 + q3 ) >> 3;
q3 = q3 >> 2;
q2 = q2 >> 1;
}
else /* second half */
{
q1 = q1 + q2;
q2 = q2 + q3;
q3 = q3 + q4;
q1 = q1 + q2;
q2 = q2 + q3;
q1 = ( q1 + q2 ) >> 3;
q2 = q2 >> 2;
q3 = q3 >> 1;
}
/* check whether either end reached the maximum */
if ( q1 == q2 && q1 >= q3 )
{
peak = q1;
break;
}
if ( q3 == q4 && q2 <= q4 )
{
peak = q4;
break;
}
}
if ( shift > 0 )
peak >>= shift;
else
peak <<= -shift;
return peak;
}
static void
BBox_Cubic_Check( FT_Pos p1,
FT_Pos p2,
FT_Pos p3,
FT_Pos p4,
FT_Pos* min,
FT_Pos* max )
{
/* This function is only called when a control off-point is outside */
/* the bbox that contains all on-points. So at least one of the */
/* conditions below holds and cubic_peak is called with at least one */
/* non-zero argument. */
if ( p2 > *max || p3 > *max )
*max += cubic_peak( p1 - *max, p2 - *max, p3 - *max, p4 - *max );
/* now flip the signs to update the minimum */
if ( p2 < *min || p3 < *min )
*min -= cubic_peak( *min - p1, *min - p2, *min - p3, *min - p4 );
}
/**************************************************************************
*
* @Function:
* BBox_Cubic_To
*
* @Description:
* This function is used as a `cubic_to' emitter during
* FT_Outline_Decompose(). It checks a cubic Bezier curve with the
* current bounding box, and computes its extrema if necessary to
* update it.
*
* @Input:
* control1 ::
* A pointer to the first control point.
*
* control2 ::
* A pointer to the second control point.
*
* to ::
* A pointer to the destination vector.
*
* @InOut:
* user ::
* The address of the current walk context.
*
* @Return:
* Always 0. Needed for the interface only.
*
* @Note:
* In the case of a non-monotonous arc, we don't compute directly
* extremum coordinates, we subdivide instead.
*/
static int
BBox_Cubic_To( FT_Vector* control1,
FT_Vector* control2,
FT_Vector* to,
TBBox_Rec* user )
{
/* We don't need to check `to' since it is always an on-point, */
/* thus within the bbox. Only segments with an off-point outside */
/* the bbox can possibly reach new extreme values. */
if ( CHECK_X( control1, user->bbox ) ||
CHECK_X( control2, user->bbox ) )
BBox_Cubic_Check( user->last.x,
control1->x,
control2->x,
to->x,
&user->bbox.xMin,
&user->bbox.xMax );
if ( CHECK_Y( control1, user->bbox ) ||
CHECK_Y( control2, user->bbox ) )
BBox_Cubic_Check( user->last.y,
control1->y,
control2->y,
to->y,
&user->bbox.yMin,
&user->bbox.yMax );
user->last = *to;
return 0;
}
FT_DEFINE_OUTLINE_FUNCS(
bbox_interface,
(FT_Outline_MoveTo_Func) BBox_Move_To, /* move_to */
(FT_Outline_LineTo_Func) BBox_Line_To, /* line_to */
(FT_Outline_ConicTo_Func)BBox_Conic_To, /* conic_to */
(FT_Outline_CubicTo_Func)BBox_Cubic_To, /* cubic_to */
0, /* shift */
0 /* delta */
)
/* documentation is in ftbbox.h */
FT_EXPORT_DEF( FT_Error )
FT_Outline_Get_BBox( FT_Outline* outline,
FT_BBox *abbox )
{
FT_BBox cbox = { 0x7FFFFFFFL, 0x7FFFFFFFL,
-0x7FFFFFFFL, -0x7FFFFFFFL };
FT_BBox bbox = { 0x7FFFFFFFL, 0x7FFFFFFFL,
-0x7FFFFFFFL, -0x7FFFFFFFL };
FT_Vector* vec;
FT_UShort n;
if ( !abbox )
return FT_THROW( Invalid_Argument );
if ( !outline )
return FT_THROW( Invalid_Outline );
/* if outline is empty, return (0,0,0,0) */
if ( outline->n_points == 0 || outline->n_contours <= 0 )
{
abbox->xMin = abbox->xMax = 0;
abbox->yMin = abbox->yMax = 0;
return 0;
}
/* We compute the control box as well as the bounding box of */
/* all `on' points in the outline. Then, if the two boxes */
/* coincide, we exit immediately. */
vec = outline->points;
for ( n = 0; n < outline->n_points; n++ )
{
FT_UPDATE_BBOX( vec, cbox );
if ( FT_CURVE_TAG( outline->tags[n] ) == FT_CURVE_TAG_ON )
FT_UPDATE_BBOX( vec, bbox );
vec++;
}
/* test two boxes for equality */
if ( cbox.xMin < bbox.xMin || cbox.xMax > bbox.xMax ||
cbox.yMin < bbox.yMin || cbox.yMax > bbox.yMax )
{
/* the two boxes are different, now walk over the outline to */
/* get the Bezier arc extrema. */
FT_Error error;
TBBox_Rec user;
user.bbox = bbox;
error = FT_Outline_Decompose( outline, &bbox_interface, &user );
if ( error )
return error;
*abbox = user.bbox;
}
else
*abbox = bbox;
return FT_Err_Ok;
}
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/base/ftbbox.c
|
C++
|
gpl-3.0
| 14,052
|
/****************************************************************************
*
* ftbdf.c
*
* FreeType API for accessing BDF-specific strings (body).
*
* Copyright (C) 2002-2022 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.
*
*/
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/ftobjs.h>
#include <freetype/internal/services/svbdf.h>
/* documentation is in ftbdf.h */
FT_EXPORT_DEF( FT_Error )
FT_Get_BDF_Charset_ID( FT_Face face,
const char* *acharset_encoding,
const char* *acharset_registry )
{
FT_Error error;
const char* encoding = NULL;
const char* registry = NULL;
FT_Service_BDF service;
if ( !face )
return FT_THROW( Invalid_Face_Handle );
FT_FACE_FIND_SERVICE( face, service, BDF );
if ( service && service->get_charset_id )
error = service->get_charset_id( face, &encoding, ®istry );
else
error = FT_THROW( Invalid_Argument );
if ( acharset_encoding )
*acharset_encoding = encoding;
if ( acharset_registry )
*acharset_registry = registry;
return error;
}
/* documentation is in ftbdf.h */
FT_EXPORT_DEF( FT_Error )
FT_Get_BDF_Property( FT_Face face,
const char* prop_name,
BDF_PropertyRec *aproperty )
{
FT_Error error;
FT_Service_BDF service;
if ( !face )
return FT_THROW( Invalid_Face_Handle );
if ( !aproperty )
return FT_THROW( Invalid_Argument );
aproperty->type = BDF_PROPERTY_TYPE_NONE;
FT_FACE_FIND_SERVICE( face, service, BDF );
if ( service && service->get_property )
error = service->get_property( face, prop_name, aproperty );
else
error = FT_THROW( Invalid_Argument );
return error;
}
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/base/ftbdf.c
|
C++
|
gpl-3.0
| 2,177
|
/****************************************************************************
*
* ftbitmap.c
*
* FreeType utility functions for bitmaps (body).
*
* Copyright (C) 2004-2022 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.
*
*/
#include <freetype/internal/ftdebug.h>
#include <freetype/ftbitmap.h>
#include <freetype/ftimage.h>
#include <freetype/internal/ftobjs.h>
/**************************************************************************
*
* The macro FT_COMPONENT is used in trace mode. It is an implicit
* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
* messages during execution.
*/
#undef FT_COMPONENT
#define FT_COMPONENT bitmap
static
const FT_Bitmap null_bitmap = { 0, 0, 0, NULL, 0, 0, 0, NULL };
/* documentation is in ftbitmap.h */
FT_EXPORT_DEF( void )
FT_Bitmap_Init( FT_Bitmap *abitmap )
{
if ( abitmap )
*abitmap = null_bitmap;
}
/* deprecated function name; retained for ABI compatibility */
FT_EXPORT_DEF( void )
FT_Bitmap_New( FT_Bitmap *abitmap )
{
if ( abitmap )
*abitmap = null_bitmap;
}
/* documentation is in ftbitmap.h */
FT_EXPORT_DEF( FT_Error )
FT_Bitmap_Copy( FT_Library library,
const FT_Bitmap *source,
FT_Bitmap *target)
{
FT_Memory memory;
FT_Error error = FT_Err_Ok;
FT_Int pitch;
FT_ULong size;
FT_Int source_pitch_sign, target_pitch_sign;
if ( !library )
return FT_THROW( Invalid_Library_Handle );
if ( !source || !target )
return FT_THROW( Invalid_Argument );
if ( source == target )
return FT_Err_Ok;
source_pitch_sign = source->pitch < 0 ? -1 : 1;
target_pitch_sign = target->pitch < 0 ? -1 : 1;
if ( !source->buffer )
{
*target = *source;
if ( source_pitch_sign != target_pitch_sign )
target->pitch = -target->pitch;
return FT_Err_Ok;
}
memory = library->memory;
pitch = source->pitch;
if ( pitch < 0 )
pitch = -pitch;
size = (FT_ULong)pitch * source->rows;
if ( target->buffer )
{
FT_Int target_pitch = target->pitch;
FT_ULong target_size;
if ( target_pitch < 0 )
target_pitch = -target_pitch;
target_size = (FT_ULong)target_pitch * target->rows;
if ( target_size != size )
FT_MEM_QREALLOC( target->buffer, target_size, size );
}
else
FT_MEM_QALLOC( target->buffer, size );
if ( !error )
{
unsigned char *p;
p = target->buffer;
*target = *source;
target->buffer = p;
if ( source_pitch_sign == target_pitch_sign )
FT_MEM_COPY( target->buffer, source->buffer, size );
else
{
/* take care of bitmap flow */
FT_UInt i;
FT_Byte* s = source->buffer;
FT_Byte* t = target->buffer;
t += (FT_ULong)pitch * ( target->rows - 1 );
for ( i = target->rows; i > 0; i-- )
{
FT_ARRAY_COPY( t, s, pitch );
s += pitch;
t -= pitch;
}
}
}
return error;
}
/* Enlarge `bitmap' horizontally and vertically by `xpixels' */
/* and `ypixels', respectively. */
static FT_Error
ft_bitmap_assure_buffer( FT_Memory memory,
FT_Bitmap* bitmap,
FT_UInt xpixels,
FT_UInt ypixels )
{
FT_Error error;
unsigned int pitch;
unsigned int new_pitch;
FT_UInt bpp;
FT_UInt width, height;
unsigned char* buffer = NULL;
width = bitmap->width;
height = bitmap->rows;
pitch = (unsigned int)FT_ABS( bitmap->pitch );
switch ( bitmap->pixel_mode )
{
case FT_PIXEL_MODE_MONO:
bpp = 1;
new_pitch = ( width + xpixels + 7 ) >> 3;
break;
case FT_PIXEL_MODE_GRAY2:
bpp = 2;
new_pitch = ( width + xpixels + 3 ) >> 2;
break;
case FT_PIXEL_MODE_GRAY4:
bpp = 4;
new_pitch = ( width + xpixels + 1 ) >> 1;
break;
case FT_PIXEL_MODE_GRAY:
case FT_PIXEL_MODE_LCD:
case FT_PIXEL_MODE_LCD_V:
bpp = 8;
new_pitch = width + xpixels;
break;
default:
return FT_THROW( Invalid_Glyph_Format );
}
/* if no need to allocate memory */
if ( ypixels == 0 && new_pitch <= pitch )
{
/* zero the padding */
FT_UInt bit_width = pitch * 8;
FT_UInt bit_last = ( width + xpixels ) * bpp;
if ( bit_last < bit_width )
{
FT_Byte* line = bitmap->buffer + ( bit_last >> 3 );
FT_Byte* end = bitmap->buffer + pitch;
FT_UInt shift = bit_last & 7;
FT_UInt mask = 0xFF00U >> shift;
FT_UInt count = height;
for ( ; count > 0; count--, line += pitch, end += pitch )
{
FT_Byte* write = line;
if ( shift > 0 )
{
write[0] = (FT_Byte)( write[0] & mask );
write++;
}
if ( write < end )
FT_MEM_ZERO( write, end - write );
}
}
return FT_Err_Ok;
}
/* otherwise allocate new buffer */
if ( FT_QALLOC_MULT( buffer, bitmap->rows + ypixels, new_pitch ) )
return error;
/* new rows get added at the top of the bitmap, */
/* thus take care of the flow direction */
if ( bitmap->pitch > 0 )
{
FT_UInt len = ( width * bpp + 7 ) >> 3;
unsigned char* in = bitmap->buffer;
unsigned char* out = buffer;
unsigned char* limit = bitmap->buffer + pitch * bitmap->rows;
unsigned int delta = new_pitch - len;
FT_MEM_ZERO( out, new_pitch * ypixels );
out += new_pitch * ypixels;
while ( in < limit )
{
FT_MEM_COPY( out, in, len );
in += pitch;
out += len;
/* we use FT_QALLOC_MULT, which doesn't zero out the buffer; */
/* consequently, we have to manually zero out the remaining bytes */
FT_MEM_ZERO( out, delta );
out += delta;
}
}
else
{
FT_UInt len = ( width * bpp + 7 ) >> 3;
unsigned char* in = bitmap->buffer;
unsigned char* out = buffer;
unsigned char* limit = bitmap->buffer + pitch * bitmap->rows;
unsigned int delta = new_pitch - len;
while ( in < limit )
{
FT_MEM_COPY( out, in, len );
in += pitch;
out += len;
FT_MEM_ZERO( out, delta );
out += delta;
}
FT_MEM_ZERO( out, new_pitch * ypixels );
}
FT_FREE( bitmap->buffer );
bitmap->buffer = buffer;
/* set pitch only, width and height are left untouched */
if ( bitmap->pitch < 0 )
bitmap->pitch = -(int)new_pitch;
else
bitmap->pitch = (int)new_pitch;
return FT_Err_Ok;
}
/* documentation is in ftbitmap.h */
FT_EXPORT_DEF( FT_Error )
FT_Bitmap_Embolden( FT_Library library,
FT_Bitmap* bitmap,
FT_Pos xStrength,
FT_Pos yStrength )
{
FT_Error error;
unsigned char* p;
FT_Int i, x, pitch;
FT_UInt y;
FT_Int xstr, ystr;
if ( !library )
return FT_THROW( Invalid_Library_Handle );
if ( !bitmap || !bitmap->buffer )
return FT_THROW( Invalid_Argument );
if ( ( ( FT_PIX_ROUND( xStrength ) >> 6 ) > FT_INT_MAX ) ||
( ( FT_PIX_ROUND( yStrength ) >> 6 ) > FT_INT_MAX ) )
return FT_THROW( Invalid_Argument );
xstr = (FT_Int)FT_PIX_ROUND( xStrength ) >> 6;
ystr = (FT_Int)FT_PIX_ROUND( yStrength ) >> 6;
if ( xstr == 0 && ystr == 0 )
return FT_Err_Ok;
else if ( xstr < 0 || ystr < 0 )
return FT_THROW( Invalid_Argument );
switch ( bitmap->pixel_mode )
{
case FT_PIXEL_MODE_GRAY2:
case FT_PIXEL_MODE_GRAY4:
{
FT_Bitmap tmp;
/* convert to 8bpp */
FT_Bitmap_Init( &tmp );
error = FT_Bitmap_Convert( library, bitmap, &tmp, 1 );
if ( error )
return error;
FT_Bitmap_Done( library, bitmap );
*bitmap = tmp;
}
break;
case FT_PIXEL_MODE_MONO:
if ( xstr > 8 )
xstr = 8;
break;
case FT_PIXEL_MODE_LCD:
xstr *= 3;
break;
case FT_PIXEL_MODE_LCD_V:
ystr *= 3;
break;
case FT_PIXEL_MODE_BGRA:
/* We don't embolden color glyphs. */
return FT_Err_Ok;
}
error = ft_bitmap_assure_buffer( library->memory, bitmap,
(FT_UInt)xstr, (FT_UInt)ystr );
if ( error )
return error;
/* take care of bitmap flow */
pitch = bitmap->pitch;
if ( pitch > 0 )
p = bitmap->buffer + pitch * ystr;
else
{
pitch = -pitch;
p = bitmap->buffer + (FT_UInt)pitch * ( bitmap->rows - 1 );
}
/* for each row */
for ( y = 0; y < bitmap->rows; y++ )
{
/*
* Horizontally:
*
* From the last pixel on, make each pixel or'ed with the
* `xstr' pixels before it.
*/
for ( x = pitch - 1; x >= 0; x-- )
{
unsigned char tmp;
tmp = p[x];
for ( i = 1; i <= xstr; i++ )
{
if ( bitmap->pixel_mode == FT_PIXEL_MODE_MONO )
{
p[x] |= tmp >> i;
/* the maximum value of 8 for `xstr' comes from here */
if ( x > 0 )
p[x] |= p[x - 1] << ( 8 - i );
#if 0
if ( p[x] == 0xFF )
break;
#endif
}
else
{
if ( x - i >= 0 )
{
if ( p[x] + p[x - i] > bitmap->num_grays - 1 )
{
p[x] = (unsigned char)( bitmap->num_grays - 1 );
break;
}
else
{
p[x] = (unsigned char)( p[x] + p[x - i] );
if ( p[x] == bitmap->num_grays - 1 )
break;
}
}
else
break;
}
}
}
/*
* Vertically:
*
* Make the above `ystr' rows or'ed with it.
*/
for ( x = 1; x <= ystr; x++ )
{
unsigned char* q;
q = p - bitmap->pitch * x;
for ( i = 0; i < pitch; i++ )
q[i] |= p[i];
}
p += bitmap->pitch;
}
bitmap->width += (FT_UInt)xstr;
bitmap->rows += (FT_UInt)ystr;
return FT_Err_Ok;
}
static FT_Byte
ft_gray_for_premultiplied_srgb_bgra( const FT_Byte* bgra )
{
FT_UInt a = bgra[3];
FT_UInt l;
/* Short-circuit transparent color to avoid division by zero. */
if ( !a )
return 0;
/*
* Luminosity for sRGB is defined using ~0.2126,0.7152,0.0722
* coefficients for RGB channels *on the linear colors*.
* A gamma of 2.2 is fair to assume. And then, we need to
* undo the premultiplication too.
*
* http://www.brucelindbloom.com/index.html?WorkingSpaceInfo.html#SideNotes
*
* We do the computation with integers only, applying a gamma of 2.0.
* We guarantee 32-bit arithmetic to avoid overflow but the resulting
* luminosity fits into 16 bits.
*
*/
l = ( 4731UL /* 0.072186 * 65536 */ * bgra[0] * bgra[0] +
46868UL /* 0.715158 * 65536 */ * bgra[1] * bgra[1] +
13937UL /* 0.212656 * 65536 */ * bgra[2] * bgra[2] ) >> 16;
/*
* Final transparency can be determined as follows.
*
* - If alpha is zero, we want 0.
* - If alpha is zero and luminosity is zero, we want 255.
* - If alpha is zero and luminosity is one, we want 0.
*
* So the formula is a * (1 - l) = a - l * a.
*
* We still need to undo premultiplication by dividing l by a*a.
*
*/
return (FT_Byte)( a - l / a );
}
/* documentation is in ftbitmap.h */
FT_EXPORT_DEF( FT_Error )
FT_Bitmap_Convert( FT_Library library,
const FT_Bitmap *source,
FT_Bitmap *target,
FT_Int alignment )
{
FT_Error error = FT_Err_Ok;
FT_Memory memory;
FT_Byte* s;
FT_Byte* t;
if ( !library )
return FT_THROW( Invalid_Library_Handle );
if ( !source || !target )
return FT_THROW( Invalid_Argument );
memory = library->memory;
switch ( source->pixel_mode )
{
case FT_PIXEL_MODE_MONO:
case FT_PIXEL_MODE_GRAY:
case FT_PIXEL_MODE_GRAY2:
case FT_PIXEL_MODE_GRAY4:
case FT_PIXEL_MODE_LCD:
case FT_PIXEL_MODE_LCD_V:
case FT_PIXEL_MODE_BGRA:
{
FT_Int pad, old_target_pitch, target_pitch;
FT_ULong old_size;
old_target_pitch = target->pitch;
if ( old_target_pitch < 0 )
old_target_pitch = -old_target_pitch;
old_size = target->rows * (FT_UInt)old_target_pitch;
target->pixel_mode = FT_PIXEL_MODE_GRAY;
target->rows = source->rows;
target->width = source->width;
pad = 0;
if ( alignment > 0 )
{
pad = (FT_Int)source->width % alignment;
if ( pad != 0 )
pad = alignment - pad;
}
target_pitch = (FT_Int)source->width + pad;
if ( target_pitch > 0 &&
(FT_ULong)target->rows > FT_ULONG_MAX / (FT_ULong)target_pitch )
return FT_THROW( Invalid_Argument );
if ( FT_QREALLOC( target->buffer,
old_size, target->rows * (FT_UInt)target_pitch ) )
return error;
target->pitch = target->pitch < 0 ? -target_pitch : target_pitch;
}
break;
default:
error = FT_THROW( Invalid_Argument );
}
s = source->buffer;
t = target->buffer;
/* take care of bitmap flow */
if ( source->pitch < 0 )
s -= source->pitch * (FT_Int)( source->rows - 1 );
if ( target->pitch < 0 )
t -= target->pitch * (FT_Int)( target->rows - 1 );
switch ( source->pixel_mode )
{
case FT_PIXEL_MODE_MONO:
{
FT_UInt i;
target->num_grays = 2;
for ( i = source->rows; i > 0; i-- )
{
FT_Byte* ss = s;
FT_Byte* tt = t;
FT_UInt j;
/* get the full bytes */
for ( j = source->width >> 3; j > 0; j-- )
{
FT_Int val = ss[0]; /* avoid a byte->int cast on each line */
tt[0] = (FT_Byte)( ( val & 0x80 ) >> 7 );
tt[1] = (FT_Byte)( ( val & 0x40 ) >> 6 );
tt[2] = (FT_Byte)( ( val & 0x20 ) >> 5 );
tt[3] = (FT_Byte)( ( val & 0x10 ) >> 4 );
tt[4] = (FT_Byte)( ( val & 0x08 ) >> 3 );
tt[5] = (FT_Byte)( ( val & 0x04 ) >> 2 );
tt[6] = (FT_Byte)( ( val & 0x02 ) >> 1 );
tt[7] = (FT_Byte)( val & 0x01 );
tt += 8;
ss += 1;
}
/* get remaining pixels (if any) */
j = source->width & 7;
if ( j > 0 )
{
FT_Int val = *ss;
for ( ; j > 0; j-- )
{
tt[0] = (FT_Byte)( ( val & 0x80 ) >> 7);
val <<= 1;
tt += 1;
}
}
s += source->pitch;
t += target->pitch;
}
}
break;
case FT_PIXEL_MODE_GRAY:
case FT_PIXEL_MODE_LCD:
case FT_PIXEL_MODE_LCD_V:
{
FT_UInt width = source->width;
FT_UInt i;
target->num_grays = 256;
for ( i = source->rows; i > 0; i-- )
{
FT_ARRAY_COPY( t, s, width );
s += source->pitch;
t += target->pitch;
}
}
break;
case FT_PIXEL_MODE_GRAY2:
{
FT_UInt i;
target->num_grays = 4;
for ( i = source->rows; i > 0; i-- )
{
FT_Byte* ss = s;
FT_Byte* tt = t;
FT_UInt j;
/* get the full bytes */
for ( j = source->width >> 2; j > 0; j-- )
{
FT_Int val = ss[0];
tt[0] = (FT_Byte)( ( val & 0xC0 ) >> 6 );
tt[1] = (FT_Byte)( ( val & 0x30 ) >> 4 );
tt[2] = (FT_Byte)( ( val & 0x0C ) >> 2 );
tt[3] = (FT_Byte)( ( val & 0x03 ) );
ss += 1;
tt += 4;
}
j = source->width & 3;
if ( j > 0 )
{
FT_Int val = ss[0];
for ( ; j > 0; j-- )
{
tt[0] = (FT_Byte)( ( val & 0xC0 ) >> 6 );
val <<= 2;
tt += 1;
}
}
s += source->pitch;
t += target->pitch;
}
}
break;
case FT_PIXEL_MODE_GRAY4:
{
FT_UInt i;
target->num_grays = 16;
for ( i = source->rows; i > 0; i-- )
{
FT_Byte* ss = s;
FT_Byte* tt = t;
FT_UInt j;
/* get the full bytes */
for ( j = source->width >> 1; j > 0; j-- )
{
FT_Int val = ss[0];
tt[0] = (FT_Byte)( ( val & 0xF0 ) >> 4 );
tt[1] = (FT_Byte)( ( val & 0x0F ) );
ss += 1;
tt += 2;
}
if ( source->width & 1 )
tt[0] = (FT_Byte)( ( ss[0] & 0xF0 ) >> 4 );
s += source->pitch;
t += target->pitch;
}
}
break;
case FT_PIXEL_MODE_BGRA:
{
FT_UInt i;
target->num_grays = 256;
for ( i = source->rows; i > 0; i-- )
{
FT_Byte* ss = s;
FT_Byte* tt = t;
FT_UInt j;
for ( j = source->width; j > 0; j-- )
{
tt[0] = ft_gray_for_premultiplied_srgb_bgra( ss );
ss += 4;
tt += 1;
}
s += source->pitch;
t += target->pitch;
}
}
break;
default:
;
}
return error;
}
/* documentation is in ftbitmap.h */
FT_EXPORT_DEF( FT_Error )
FT_Bitmap_Blend( FT_Library library,
const FT_Bitmap* source_,
const FT_Vector source_offset_,
FT_Bitmap* target,
FT_Vector *atarget_offset,
FT_Color color )
{
FT_Error error = FT_Err_Ok;
FT_Memory memory;
FT_Bitmap source_bitmap;
const FT_Bitmap* source;
FT_Vector source_offset;
FT_Vector target_offset;
FT_Bool free_source_bitmap = 0;
FT_Bool free_target_bitmap_on_error = 0;
FT_Pos source_llx, source_lly, source_urx, source_ury;
FT_Pos target_llx, target_lly, target_urx, target_ury;
FT_Pos final_llx, final_lly, final_urx, final_ury;
unsigned int final_rows, final_width;
long x, y;
if ( !library || !target || !source_ || !atarget_offset )
return FT_THROW( Invalid_Argument );
memory = library->memory;
if ( !( target->pixel_mode == FT_PIXEL_MODE_NONE ||
( target->pixel_mode == FT_PIXEL_MODE_BGRA &&
target->buffer ) ) )
return FT_THROW( Invalid_Argument );
if ( source_->pixel_mode == FT_PIXEL_MODE_NONE )
return FT_Err_Ok; /* nothing to do */
/* pitches must have the same sign */
if ( target->pixel_mode == FT_PIXEL_MODE_BGRA &&
( source_->pitch ^ target->pitch ) < 0 )
return FT_THROW( Invalid_Argument );
if ( !( source_->width && source_->rows ) )
return FT_Err_Ok; /* nothing to do */
/* assure integer pixel offsets */
source_offset.x = FT_PIX_FLOOR( source_offset_.x );
source_offset.y = FT_PIX_FLOOR( source_offset_.y );
target_offset.x = FT_PIX_FLOOR( atarget_offset->x );
target_offset.y = FT_PIX_FLOOR( atarget_offset->y );
/* get source bitmap dimensions */
source_llx = source_offset.x;
if ( FT_LONG_MIN + (FT_Pos)( source_->rows << 6 ) + 64 > source_offset.y )
{
FT_TRACE5((
"FT_Bitmap_Blend: y coordinate overflow in source bitmap\n" ));
return FT_THROW( Invalid_Argument );
}
source_lly = source_offset.y - ( source_->rows << 6 );
if ( FT_LONG_MAX - (FT_Pos)( source_->width << 6 ) - 64 < source_llx )
{
FT_TRACE5((
"FT_Bitmap_Blend: x coordinate overflow in source bitmap\n" ));
return FT_THROW( Invalid_Argument );
}
source_urx = source_llx + ( source_->width << 6 );
source_ury = source_offset.y;
/* get target bitmap dimensions */
if ( target->width && target->rows )
{
target_llx = target_offset.x;
if ( FT_LONG_MIN + (FT_Pos)( target->rows << 6 ) > target_offset.y )
{
FT_TRACE5((
"FT_Bitmap_Blend: y coordinate overflow in target bitmap\n" ));
return FT_THROW( Invalid_Argument );
}
target_lly = target_offset.y - ( target->rows << 6 );
if ( FT_LONG_MAX - (FT_Pos)( target->width << 6 ) < target_llx )
{
FT_TRACE5((
"FT_Bitmap_Blend: x coordinate overflow in target bitmap\n" ));
return FT_THROW( Invalid_Argument );
}
target_urx = target_llx + ( target->width << 6 );
target_ury = target_offset.y;
}
else
{
target_llx = FT_LONG_MAX;
target_lly = FT_LONG_MAX;
target_urx = FT_LONG_MIN;
target_ury = FT_LONG_MIN;
}
/* compute final bitmap dimensions */
final_llx = FT_MIN( source_llx, target_llx );
final_lly = FT_MIN( source_lly, target_lly );
final_urx = FT_MAX( source_urx, target_urx );
final_ury = FT_MAX( source_ury, target_ury );
final_width = ( final_urx - final_llx ) >> 6;
final_rows = ( final_ury - final_lly ) >> 6;
#ifdef FT_DEBUG_LEVEL_TRACE
FT_TRACE5(( "FT_Bitmap_Blend:\n" ));
FT_TRACE5(( " source bitmap: (%ld, %ld) -- (%ld, %ld); %d x %d\n",
source_llx / 64, source_lly / 64,
source_urx / 64, source_ury / 64,
source_->width, source_->rows ));
if ( target->width && target->rows )
FT_TRACE5(( " target bitmap: (%ld, %ld) -- (%ld, %ld); %d x %d\n",
target_llx / 64, target_lly / 64,
target_urx / 64, target_ury / 64,
target->width, target->rows ));
else
FT_TRACE5(( " target bitmap: empty\n" ));
if ( final_width && final_rows )
FT_TRACE5(( " final bitmap: (%ld, %ld) -- (%ld, %ld); %d x %d\n",
final_llx / 64, final_lly / 64,
final_urx / 64, final_ury / 64,
final_width, final_rows ));
else
FT_TRACE5(( " final bitmap: empty\n" ));
#endif /* FT_DEBUG_LEVEL_TRACE */
if ( !( final_width && final_rows ) )
return FT_Err_Ok; /* nothing to do */
/* for blending, set offset vector of final bitmap */
/* temporarily to (0,0) */
source_llx -= final_llx;
source_lly -= final_lly;
if ( target->width && target->rows )
{
target_llx -= final_llx;
target_lly -= final_lly;
}
/* set up target bitmap */
if ( target->pixel_mode == FT_PIXEL_MODE_NONE )
{
/* create new empty bitmap */
target->width = final_width;
target->rows = final_rows;
target->pixel_mode = FT_PIXEL_MODE_BGRA;
target->pitch = (int)final_width * 4;
target->num_grays = 256;
if ( FT_LONG_MAX / target->pitch < (int)target->rows )
{
FT_TRACE5(( "FT_Blend_Bitmap: target bitmap too large (%d x %d)\n",
final_width, final_rows ));
return FT_THROW( Invalid_Argument );
}
if ( FT_ALLOC( target->buffer, target->pitch * (int)target->rows ) )
return error;
free_target_bitmap_on_error = 1;
}
else if ( target->width != final_width ||
target->rows != final_rows )
{
/* adjust old bitmap to enlarged size */
int pitch, new_pitch;
unsigned char* buffer = NULL;
pitch = target->pitch;
if ( pitch < 0 )
pitch = -pitch;
new_pitch = (int)final_width * 4;
if ( FT_LONG_MAX / new_pitch < (int)final_rows )
{
FT_TRACE5(( "FT_Blend_Bitmap: target bitmap too large (%d x %d)\n",
final_width, final_rows ));
return FT_THROW( Invalid_Argument );
}
/* TODO: provide an in-buffer solution for large bitmaps */
/* to avoid allocation of a new buffer */
if ( FT_ALLOC( buffer, new_pitch * (int)final_rows ) )
goto Error;
/* copy data to new buffer */
x = target_llx >> 6;
y = target_lly >> 6;
/* the bitmap flow is from top to bottom, */
/* but y is measured from bottom to top */
if ( target->pitch < 0 )
{
/* XXX */
}
else
{
unsigned char* p =
target->buffer;
unsigned char* q =
buffer +
( final_rows - y - target->rows ) * new_pitch +
x * 4;
unsigned char* limit_p =
p + pitch * (int)target->rows;
while ( p < limit_p )
{
FT_MEM_COPY( q, p, pitch );
p += pitch;
q += new_pitch;
}
}
FT_FREE( target->buffer );
target->width = final_width;
target->rows = final_rows;
if ( target->pitch < 0 )
target->pitch = -new_pitch;
else
target->pitch = new_pitch;
target->buffer = buffer;
}
/* adjust source bitmap if necessary */
if ( source_->pixel_mode != FT_PIXEL_MODE_GRAY )
{
FT_Bitmap_Init( &source_bitmap );
error = FT_Bitmap_Convert( library, source_, &source_bitmap, 1 );
if ( error )
goto Error;
source = &source_bitmap;
free_source_bitmap = 1;
}
else
source = source_;
/* do blending; the code below returns pre-multiplied channels, */
/* similar to what FreeType gets from `CBDT' tables */
x = source_llx >> 6;
y = source_lly >> 6;
/* the bitmap flow is from top to bottom, */
/* but y is measured from bottom to top */
if ( target->pitch < 0 )
{
/* XXX */
}
else
{
unsigned char* p =
source->buffer;
unsigned char* q =
target->buffer +
( target->rows - y - source->rows ) * target->pitch +
x * 4;
unsigned char* limit_p =
p + source->pitch * (int)source->rows;
while ( p < limit_p )
{
unsigned char* r = p;
unsigned char* s = q;
unsigned char* limit_r = r + source->width;
while ( r < limit_r )
{
int aa = *r++;
int fa = color.alpha * aa / 255;
int fb = color.blue * fa / 255;
int fg = color.green * fa / 255;
int fr = color.red * fa / 255;
int ba2 = 255 - fa;
int bb = s[0];
int bg = s[1];
int br = s[2];
int ba = s[3];
*s++ = (unsigned char)( bb * ba2 / 255 + fb );
*s++ = (unsigned char)( bg * ba2 / 255 + fg );
*s++ = (unsigned char)( br * ba2 / 255 + fr );
*s++ = (unsigned char)( ba * ba2 / 255 + fa );
}
p += source->pitch;
q += target->pitch;
}
}
atarget_offset->x = final_llx;
atarget_offset->y = final_lly + ( final_rows << 6 );
Error:
if ( error && free_target_bitmap_on_error )
FT_Bitmap_Done( library, target );
if ( free_source_bitmap )
FT_Bitmap_Done( library, &source_bitmap );
return error;
}
/* documentation is in ftbitmap.h */
FT_EXPORT_DEF( FT_Error )
FT_GlyphSlot_Own_Bitmap( FT_GlyphSlot slot )
{
if ( slot && slot->format == FT_GLYPH_FORMAT_BITMAP &&
!( slot->internal->flags & FT_GLYPH_OWN_BITMAP ) )
{
FT_Bitmap bitmap;
FT_Error error;
FT_Bitmap_Init( &bitmap );
error = FT_Bitmap_Copy( slot->library, &slot->bitmap, &bitmap );
if ( error )
return error;
slot->bitmap = bitmap;
slot->internal->flags |= FT_GLYPH_OWN_BITMAP;
}
return FT_Err_Ok;
}
/* documentation is in ftbitmap.h */
FT_EXPORT_DEF( FT_Error )
FT_Bitmap_Done( FT_Library library,
FT_Bitmap *bitmap )
{
FT_Memory memory;
if ( !library )
return FT_THROW( Invalid_Library_Handle );
if ( !bitmap )
return FT_THROW( Invalid_Argument );
memory = library->memory;
FT_FREE( bitmap->buffer );
*bitmap = null_bitmap;
return FT_Err_Ok;
}
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/base/ftbitmap.c
|
C++
|
gpl-3.0
| 29,168
|
/****************************************************************************
*
* ftcalc.c
*
* Arithmetic computations (body).
*
* Copyright (C) 1996-2022 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.
*
*/
/**************************************************************************
*
* Support for 1-complement arithmetic has been totally dropped in this
* release. You can still write your own code if you need it.
*
*/
/**************************************************************************
*
* Implementing basic computation routines.
*
* FT_MulDiv(), FT_MulFix(), FT_DivFix(), FT_RoundFix(), FT_CeilFix(),
* and FT_FloorFix() are declared in freetype.h.
*
*/
#include <freetype/ftglyph.h>
#include <freetype/fttrigon.h>
#include <freetype/internal/ftcalc.h>
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/ftobjs.h>
#ifdef FT_MULFIX_ASSEMBLER
#undef FT_MulFix
#endif
/* we need to emulate a 64-bit data type if a real one isn't available */
#ifndef FT_INT64
typedef struct FT_Int64_
{
FT_UInt32 lo;
FT_UInt32 hi;
} FT_Int64;
#endif /* !FT_INT64 */
/**************************************************************************
*
* The macro FT_COMPONENT is used in trace mode. It is an implicit
* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
* messages during execution.
*/
#undef FT_COMPONENT
#define FT_COMPONENT calc
/* transfer sign, leaving a positive number; */
/* we need an unsigned value to safely negate INT_MIN (or LONG_MIN) */
#define FT_MOVE_SIGN( x, x_unsigned, s ) \
FT_BEGIN_STMNT \
if ( x < 0 ) \
{ \
x_unsigned = 0U - (x_unsigned); \
s = -s; \
} \
FT_END_STMNT
/* The following three functions are available regardless of whether */
/* FT_INT64 is defined. */
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Fixed )
FT_RoundFix( FT_Fixed a )
{
return ( ADD_LONG( a, 0x8000L - ( a < 0 ) ) ) & ~0xFFFFL;
}
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Fixed )
FT_CeilFix( FT_Fixed a )
{
return ( ADD_LONG( a, 0xFFFFL ) ) & ~0xFFFFL;
}
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Fixed )
FT_FloorFix( FT_Fixed a )
{
return a & ~0xFFFFL;
}
#ifndef FT_MSB
FT_BASE_DEF( FT_Int )
FT_MSB( FT_UInt32 z )
{
FT_Int shift = 0;
/* determine msb bit index in `shift' */
if ( z & 0xFFFF0000UL )
{
z >>= 16;
shift += 16;
}
if ( z & 0x0000FF00UL )
{
z >>= 8;
shift += 8;
}
if ( z & 0x000000F0UL )
{
z >>= 4;
shift += 4;
}
if ( z & 0x0000000CUL )
{
z >>= 2;
shift += 2;
}
if ( z & 0x00000002UL )
{
/* z >>= 1; */
shift += 1;
}
return shift;
}
#endif /* !FT_MSB */
/* documentation is in ftcalc.h */
FT_BASE_DEF( FT_Fixed )
FT_Hypot( FT_Fixed x,
FT_Fixed y )
{
FT_Vector v;
v.x = x;
v.y = y;
return FT_Vector_Length( &v );
}
#ifdef FT_INT64
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Long )
FT_MulDiv( FT_Long a_,
FT_Long b_,
FT_Long c_ )
{
FT_Int s = 1;
FT_UInt64 a, b, c, d;
FT_Long d_;
a = (FT_UInt64)a_;
b = (FT_UInt64)b_;
c = (FT_UInt64)c_;
FT_MOVE_SIGN( a_, a, s );
FT_MOVE_SIGN( b_, b, s );
FT_MOVE_SIGN( c_, c, s );
d = c > 0 ? ( a * b + ( c >> 1 ) ) / c
: 0x7FFFFFFFUL;
d_ = (FT_Long)d;
return s < 0 ? NEG_LONG( d_ ) : d_;
}
/* documentation is in ftcalc.h */
FT_BASE_DEF( FT_Long )
FT_MulDiv_No_Round( FT_Long a_,
FT_Long b_,
FT_Long c_ )
{
FT_Int s = 1;
FT_UInt64 a, b, c, d;
FT_Long d_;
a = (FT_UInt64)a_;
b = (FT_UInt64)b_;
c = (FT_UInt64)c_;
FT_MOVE_SIGN( a_, a, s );
FT_MOVE_SIGN( b_, b, s );
FT_MOVE_SIGN( c_, c, s );
d = c > 0 ? a * b / c
: 0x7FFFFFFFUL;
d_ = (FT_Long)d;
return s < 0 ? NEG_LONG( d_ ) : d_;
}
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Long )
FT_MulFix( FT_Long a_,
FT_Long b_ )
{
#ifdef FT_MULFIX_ASSEMBLER
return FT_MULFIX_ASSEMBLER( (FT_Int32)a_, (FT_Int32)b_ );
#else
FT_Int64 ab = (FT_Int64)a_ * (FT_Int64)b_;
/* this requires arithmetic right shift of signed numbers */
return (FT_Long)( ( ab + 0x8000L - ( ab < 0 ) ) >> 16 );
#endif /* FT_MULFIX_ASSEMBLER */
}
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Long )
FT_DivFix( FT_Long a_,
FT_Long b_ )
{
FT_Int s = 1;
FT_UInt64 a, b, q;
FT_Long q_;
a = (FT_UInt64)a_;
b = (FT_UInt64)b_;
FT_MOVE_SIGN( a_, a, s );
FT_MOVE_SIGN( b_, b, s );
q = b > 0 ? ( ( a << 16 ) + ( b >> 1 ) ) / b
: 0x7FFFFFFFUL;
q_ = (FT_Long)q;
return s < 0 ? NEG_LONG( q_ ) : q_;
}
#else /* !FT_INT64 */
static void
ft_multo64( FT_UInt32 x,
FT_UInt32 y,
FT_Int64 *z )
{
FT_UInt32 lo1, hi1, lo2, hi2, lo, hi, i1, i2;
lo1 = x & 0x0000FFFFU; hi1 = x >> 16;
lo2 = y & 0x0000FFFFU; hi2 = y >> 16;
lo = lo1 * lo2;
i1 = lo1 * hi2;
i2 = lo2 * hi1;
hi = hi1 * hi2;
/* Check carry overflow of i1 + i2 */
i1 += i2;
hi += (FT_UInt32)( i1 < i2 ) << 16;
hi += i1 >> 16;
i1 = i1 << 16;
/* Check carry overflow of i1 + lo */
lo += i1;
hi += ( lo < i1 );
z->lo = lo;
z->hi = hi;
}
static FT_UInt32
ft_div64by32( FT_UInt32 hi,
FT_UInt32 lo,
FT_UInt32 y )
{
FT_UInt32 r, q;
FT_Int i;
if ( hi >= y )
return (FT_UInt32)0x7FFFFFFFL;
/* We shift as many bits as we can into the high register, perform */
/* 32-bit division with modulo there, then work through the remaining */
/* bits with long division. This optimization is especially noticeable */
/* for smaller dividends that barely use the high register. */
i = 31 - FT_MSB( hi );
r = ( hi << i ) | ( lo >> ( 32 - i ) ); lo <<= i; /* left 64-bit shift */
q = r / y;
r -= q * y; /* remainder */
i = 32 - i; /* bits remaining in low register */
do
{
q <<= 1;
r = ( r << 1 ) | ( lo >> 31 ); lo <<= 1;
if ( r >= y )
{
r -= y;
q |= 1;
}
} while ( --i );
return q;
}
static void
FT_Add64( FT_Int64* x,
FT_Int64* y,
FT_Int64 *z )
{
FT_UInt32 lo, hi;
lo = x->lo + y->lo;
hi = x->hi + y->hi + ( lo < x->lo );
z->lo = lo;
z->hi = hi;
}
/* The FT_MulDiv function has been optimized thanks to ideas from */
/* Graham Asher and Alexei Podtelezhnikov. The trick is to optimize */
/* a rather common case when everything fits within 32-bits. */
/* */
/* We compute 'a*b+c/2', then divide it by 'c' (all positive values). */
/* */
/* The product of two positive numbers never exceeds the square of */
/* its mean values. Therefore, we always avoid the overflow by */
/* imposing */
/* */
/* (a + b) / 2 <= sqrt(X - c/2) , */
/* */
/* where X = 2^32 - 1, the maximum unsigned 32-bit value, and using */
/* unsigned arithmetic. Now we replace `sqrt' with a linear function */
/* that is smaller or equal for all values of c in the interval */
/* [0;X/2]; it should be equal to sqrt(X) and sqrt(3X/4) at the */
/* endpoints. Substituting the linear solution and explicit numbers */
/* we get */
/* */
/* a + b <= 131071.99 - c / 122291.84 . */
/* */
/* In practice, we should use a faster and even stronger inequality */
/* */
/* a + b <= 131071 - (c >> 16) */
/* */
/* or, alternatively, */
/* */
/* a + b <= 129894 - (c >> 17) . */
/* */
/* FT_MulFix, on the other hand, is optimized for a small value of */
/* the first argument, when the second argument can be much larger. */
/* This can be achieved by scaling the second argument and the limit */
/* in the above inequalities. For example, */
/* */
/* a + (b >> 8) <= (131071 >> 4) */
/* */
/* covers the practical range of use. The actual test below is a bit */
/* tighter to avoid the border case overflows. */
/* */
/* In the case of FT_DivFix, the exact overflow check */
/* */
/* a << 16 <= X - c/2 */
/* */
/* is scaled down by 2^16 and we use */
/* */
/* a <= 65535 - (c >> 17) . */
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Long )
FT_MulDiv( FT_Long a_,
FT_Long b_,
FT_Long c_ )
{
FT_Int s = 1;
FT_UInt32 a, b, c;
/* XXX: this function does not allow 64-bit arguments */
a = (FT_UInt32)a_;
b = (FT_UInt32)b_;
c = (FT_UInt32)c_;
FT_MOVE_SIGN( a_, a, s );
FT_MOVE_SIGN( b_, b, s );
FT_MOVE_SIGN( c_, c, s );
if ( c == 0 )
a = 0x7FFFFFFFUL;
else if ( a + b <= 129894UL - ( c >> 17 ) )
a = ( a * b + ( c >> 1 ) ) / c;
else
{
FT_Int64 temp, temp2;
ft_multo64( a, b, &temp );
temp2.hi = 0;
temp2.lo = c >> 1;
FT_Add64( &temp, &temp2, &temp );
/* last attempt to ditch long division */
a = ( temp.hi == 0 ) ? temp.lo / c
: ft_div64by32( temp.hi, temp.lo, c );
}
a_ = (FT_Long)a;
return s < 0 ? NEG_LONG( a_ ) : a_;
}
FT_BASE_DEF( FT_Long )
FT_MulDiv_No_Round( FT_Long a_,
FT_Long b_,
FT_Long c_ )
{
FT_Int s = 1;
FT_UInt32 a, b, c;
/* XXX: this function does not allow 64-bit arguments */
a = (FT_UInt32)a_;
b = (FT_UInt32)b_;
c = (FT_UInt32)c_;
FT_MOVE_SIGN( a_, a, s );
FT_MOVE_SIGN( b_, b, s );
FT_MOVE_SIGN( c_, c, s );
if ( c == 0 )
a = 0x7FFFFFFFUL;
else if ( a + b <= 131071UL )
a = a * b / c;
else
{
FT_Int64 temp;
ft_multo64( a, b, &temp );
/* last attempt to ditch long division */
a = ( temp.hi == 0 ) ? temp.lo / c
: ft_div64by32( temp.hi, temp.lo, c );
}
a_ = (FT_Long)a;
return s < 0 ? NEG_LONG( a_ ) : a_;
}
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Long )
FT_MulFix( FT_Long a_,
FT_Long b_ )
{
#ifdef FT_MULFIX_ASSEMBLER
return FT_MULFIX_ASSEMBLER( a_, b_ );
#elif 0
/*
* This code is nonportable. See comment below.
*
* However, on a platform where right-shift of a signed quantity fills
* the leftmost bits by copying the sign bit, it might be faster.
*/
FT_Long sa, sb;
FT_UInt32 a, b;
/*
* This is a clever way of converting a signed number `a' into its
* absolute value (stored back into `a') and its sign. The sign is
* stored in `sa'; 0 means `a' was positive or zero, and -1 means `a'
* was negative. (Similarly for `b' and `sb').
*
* Unfortunately, it doesn't work (at least not portably).
*
* It makes the assumption that right-shift on a negative signed value
* fills the leftmost bits by copying the sign bit. This is wrong.
* According to K&R 2nd ed, section `A7.8 Shift Operators' on page 206,
* the result of right-shift of a negative signed value is
* implementation-defined. At least one implementation fills the
* leftmost bits with 0s (i.e., it is exactly the same as an unsigned
* right shift). This means that when `a' is negative, `sa' ends up
* with the value 1 rather than -1. After that, everything else goes
* wrong.
*/
sa = ( a_ >> ( sizeof ( a_ ) * 8 - 1 ) );
a = ( a_ ^ sa ) - sa;
sb = ( b_ >> ( sizeof ( b_ ) * 8 - 1 ) );
b = ( b_ ^ sb ) - sb;
a = (FT_UInt32)a_;
b = (FT_UInt32)b_;
if ( a + ( b >> 8 ) <= 8190UL )
a = ( a * b + 0x8000U ) >> 16;
else
{
FT_UInt32 al = a & 0xFFFFUL;
a = ( a >> 16 ) * b + al * ( b >> 16 ) +
( ( al * ( b & 0xFFFFUL ) + 0x8000UL ) >> 16 );
}
sa ^= sb;
a = ( a ^ sa ) - sa;
return (FT_Long)a;
#else /* 0 */
FT_Int s = 1;
FT_UInt32 a, b;
/* XXX: this function does not allow 64-bit arguments */
a = (FT_UInt32)a_;
b = (FT_UInt32)b_;
FT_MOVE_SIGN( a_, a, s );
FT_MOVE_SIGN( b_, b, s );
if ( a + ( b >> 8 ) <= 8190UL )
a = ( a * b + 0x8000UL ) >> 16;
else
{
FT_UInt32 al = a & 0xFFFFUL;
a = ( a >> 16 ) * b + al * ( b >> 16 ) +
( ( al * ( b & 0xFFFFUL ) + 0x8000UL ) >> 16 );
}
a_ = (FT_Long)a;
return s < 0 ? NEG_LONG( a_ ) : a_;
#endif /* 0 */
}
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Long )
FT_DivFix( FT_Long a_,
FT_Long b_ )
{
FT_Int s = 1;
FT_UInt32 a, b, q;
FT_Long q_;
/* XXX: this function does not allow 64-bit arguments */
a = (FT_UInt32)a_;
b = (FT_UInt32)b_;
FT_MOVE_SIGN( a_, a, s );
FT_MOVE_SIGN( b_, b, s );
if ( b == 0 )
{
/* check for division by 0 */
q = 0x7FFFFFFFUL;
}
else if ( a <= 65535UL - ( b >> 17 ) )
{
/* compute result directly */
q = ( ( a << 16 ) + ( b >> 1 ) ) / b;
}
else
{
/* we need more bits; we have to do it by hand */
FT_Int64 temp, temp2;
temp.hi = a >> 16;
temp.lo = a << 16;
temp2.hi = 0;
temp2.lo = b >> 1;
FT_Add64( &temp, &temp2, &temp );
q = ft_div64by32( temp.hi, temp.lo, b );
}
q_ = (FT_Long)q;
return s < 0 ? NEG_LONG( q_ ) : q_;
}
#endif /* !FT_INT64 */
/* documentation is in ftglyph.h */
FT_EXPORT_DEF( void )
FT_Matrix_Multiply( const FT_Matrix* a,
FT_Matrix *b )
{
FT_Fixed xx, xy, yx, yy;
if ( !a || !b )
return;
xx = ADD_LONG( FT_MulFix( a->xx, b->xx ),
FT_MulFix( a->xy, b->yx ) );
xy = ADD_LONG( FT_MulFix( a->xx, b->xy ),
FT_MulFix( a->xy, b->yy ) );
yx = ADD_LONG( FT_MulFix( a->yx, b->xx ),
FT_MulFix( a->yy, b->yx ) );
yy = ADD_LONG( FT_MulFix( a->yx, b->xy ),
FT_MulFix( a->yy, b->yy ) );
b->xx = xx;
b->xy = xy;
b->yx = yx;
b->yy = yy;
}
/* documentation is in ftglyph.h */
FT_EXPORT_DEF( FT_Error )
FT_Matrix_Invert( FT_Matrix* matrix )
{
FT_Pos delta, xx, yy;
if ( !matrix )
return FT_THROW( Invalid_Argument );
/* compute discriminant */
delta = FT_MulFix( matrix->xx, matrix->yy ) -
FT_MulFix( matrix->xy, matrix->yx );
if ( !delta )
return FT_THROW( Invalid_Argument ); /* matrix can't be inverted */
matrix->xy = -FT_DivFix( matrix->xy, delta );
matrix->yx = -FT_DivFix( matrix->yx, delta );
xx = matrix->xx;
yy = matrix->yy;
matrix->xx = FT_DivFix( yy, delta );
matrix->yy = FT_DivFix( xx, delta );
return FT_Err_Ok;
}
/* documentation is in ftcalc.h */
FT_BASE_DEF( void )
FT_Matrix_Multiply_Scaled( const FT_Matrix* a,
FT_Matrix *b,
FT_Long scaling )
{
FT_Fixed xx, xy, yx, yy;
FT_Long val = 0x10000L * scaling;
if ( !a || !b )
return;
xx = ADD_LONG( FT_MulDiv( a->xx, b->xx, val ),
FT_MulDiv( a->xy, b->yx, val ) );
xy = ADD_LONG( FT_MulDiv( a->xx, b->xy, val ),
FT_MulDiv( a->xy, b->yy, val ) );
yx = ADD_LONG( FT_MulDiv( a->yx, b->xx, val ),
FT_MulDiv( a->yy, b->yx, val ) );
yy = ADD_LONG( FT_MulDiv( a->yx, b->xy, val ),
FT_MulDiv( a->yy, b->yy, val ) );
b->xx = xx;
b->xy = xy;
b->yx = yx;
b->yy = yy;
}
/* documentation is in ftcalc.h */
FT_BASE_DEF( FT_Bool )
FT_Matrix_Check( const FT_Matrix* matrix )
{
FT_Matrix m;
FT_Fixed val[4];
FT_Fixed nonzero_minval, maxval;
FT_Fixed temp1, temp2;
FT_UInt i;
if ( !matrix )
return 0;
val[0] = FT_ABS( matrix->xx );
val[1] = FT_ABS( matrix->xy );
val[2] = FT_ABS( matrix->yx );
val[3] = FT_ABS( matrix->yy );
/*
* To avoid overflow, we ensure that each value is not larger than
*
* int(sqrt(2^31 / 4)) = 23170 ;
*
* we also check that no value becomes zero if we have to scale.
*/
maxval = 0;
nonzero_minval = FT_LONG_MAX;
for ( i = 0; i < 4; i++ )
{
if ( val[i] > maxval )
maxval = val[i];
if ( val[i] && val[i] < nonzero_minval )
nonzero_minval = val[i];
}
/* we only handle 32bit values */
if ( maxval > 0x7FFFFFFFL )
return 0;
if ( maxval > 23170 )
{
FT_Fixed scale = FT_DivFix( maxval, 23170 );
if ( !FT_DivFix( nonzero_minval, scale ) )
return 0; /* value range too large */
m.xx = FT_DivFix( matrix->xx, scale );
m.xy = FT_DivFix( matrix->xy, scale );
m.yx = FT_DivFix( matrix->yx, scale );
m.yy = FT_DivFix( matrix->yy, scale );
}
else
m = *matrix;
temp1 = FT_ABS( m.xx * m.yy - m.xy * m.yx );
temp2 = m.xx * m.xx + m.xy * m.xy + m.yx * m.yx + m.yy * m.yy;
if ( temp1 == 0 ||
temp2 / temp1 > 50 )
return 0;
return 1;
}
/* documentation is in ftcalc.h */
FT_BASE_DEF( void )
FT_Vector_Transform_Scaled( FT_Vector* vector,
const FT_Matrix* matrix,
FT_Long scaling )
{
FT_Pos xz, yz;
FT_Long val = 0x10000L * scaling;
if ( !vector || !matrix )
return;
xz = ADD_LONG( FT_MulDiv( vector->x, matrix->xx, val ),
FT_MulDiv( vector->y, matrix->xy, val ) );
yz = ADD_LONG( FT_MulDiv( vector->x, matrix->yx, val ),
FT_MulDiv( vector->y, matrix->yy, val ) );
vector->x = xz;
vector->y = yz;
}
/* documentation is in ftcalc.h */
FT_BASE_DEF( FT_UInt32 )
FT_Vector_NormLen( FT_Vector* vector )
{
FT_Int32 x_ = vector->x;
FT_Int32 y_ = vector->y;
FT_Int32 b, z;
FT_UInt32 x, y, u, v, l;
FT_Int sx = 1, sy = 1, shift;
x = (FT_UInt32)x_;
y = (FT_UInt32)y_;
FT_MOVE_SIGN( x_, x, sx );
FT_MOVE_SIGN( y_, y, sy );
/* trivial cases */
if ( x == 0 )
{
if ( y > 0 )
vector->y = sy * 0x10000;
return y;
}
else if ( y == 0 )
{
if ( x > 0 )
vector->x = sx * 0x10000;
return x;
}
/* Estimate length and prenormalize by shifting so that */
/* the new approximate length is between 2/3 and 4/3. */
/* The magic constant 0xAAAAAAAAUL (2/3 of 2^32) helps */
/* achieve this in 16.16 fixed-point representation. */
l = x > y ? x + ( y >> 1 )
: y + ( x >> 1 );
shift = 31 - FT_MSB( l );
shift -= 15 + ( l >= ( 0xAAAAAAAAUL >> shift ) );
if ( shift > 0 )
{
x <<= shift;
y <<= shift;
/* re-estimate length for tiny vectors */
l = x > y ? x + ( y >> 1 )
: y + ( x >> 1 );
}
else
{
x >>= -shift;
y >>= -shift;
l >>= -shift;
}
/* lower linear approximation for reciprocal length minus one */
b = 0x10000 - (FT_Int32)l;
x_ = (FT_Int32)x;
y_ = (FT_Int32)y;
/* Newton's iterations */
do
{
u = (FT_UInt32)( x_ + ( x_ * b >> 16 ) );
v = (FT_UInt32)( y_ + ( y_ * b >> 16 ) );
/* Normalized squared length in the parentheses approaches 2^32. */
/* On two's complement systems, converting to signed gives the */
/* difference with 2^32 even if the expression wraps around. */
z = -(FT_Int32)( u * u + v * v ) / 0x200;
z = z * ( ( 0x10000 + b ) >> 8 ) / 0x10000;
b += z;
} while ( z > 0 );
vector->x = sx < 0 ? -(FT_Pos)u : (FT_Pos)u;
vector->y = sy < 0 ? -(FT_Pos)v : (FT_Pos)v;
/* Conversion to signed helps to recover from likely wrap around */
/* in calculating the prenormalized length, because it gives the */
/* correct difference with 2^32 on two's complement systems. */
l = (FT_UInt32)( 0x10000 + (FT_Int32)( u * x + v * y ) / 0x10000 );
if ( shift > 0 )
l = ( l + ( 1 << ( shift - 1 ) ) ) >> shift;
else
l <<= -shift;
return l;
}
#if 0
/* documentation is in ftcalc.h */
FT_BASE_DEF( FT_Int32 )
FT_SqrtFixed( FT_Int32 x )
{
FT_UInt32 root, rem_hi, rem_lo, test_div;
FT_Int count;
root = 0;
if ( x > 0 )
{
rem_hi = 0;
rem_lo = (FT_UInt32)x;
count = 24;
do
{
rem_hi = ( rem_hi << 2 ) | ( rem_lo >> 30 );
rem_lo <<= 2;
root <<= 1;
test_div = ( root << 1 ) + 1;
if ( rem_hi >= test_div )
{
rem_hi -= test_div;
root += 1;
}
} while ( --count );
}
return (FT_Int32)root;
}
#endif /* 0 */
/* documentation is in ftcalc.h */
FT_BASE_DEF( FT_Int )
ft_corner_orientation( FT_Pos in_x,
FT_Pos in_y,
FT_Pos out_x,
FT_Pos out_y )
{
/* we silently ignore overflow errors since such large values */
/* lead to even more (harmless) rendering errors later on */
#ifdef FT_INT64
FT_Int64 delta = SUB_INT64( MUL_INT64( in_x, out_y ),
MUL_INT64( in_y, out_x ) );
return ( delta > 0 ) - ( delta < 0 );
#else
FT_Int result;
if ( ADD_LONG( FT_ABS( in_x ), FT_ABS( out_y ) ) <= 131071L &&
ADD_LONG( FT_ABS( in_y ), FT_ABS( out_x ) ) <= 131071L )
{
FT_Long z1 = MUL_LONG( in_x, out_y );
FT_Long z2 = MUL_LONG( in_y, out_x );
if ( z1 > z2 )
result = +1;
else if ( z1 < z2 )
result = -1;
else
result = 0;
}
else /* products might overflow 32 bits */
{
FT_Int64 z1, z2;
/* XXX: this function does not allow 64-bit arguments */
ft_multo64( (FT_UInt32)in_x, (FT_UInt32)out_y, &z1 );
ft_multo64( (FT_UInt32)in_y, (FT_UInt32)out_x, &z2 );
if ( z1.hi > z2.hi )
result = +1;
else if ( z1.hi < z2.hi )
result = -1;
else if ( z1.lo > z2.lo )
result = +1;
else if ( z1.lo < z2.lo )
result = -1;
else
result = 0;
}
/* XXX: only the sign of return value, +1/0/-1 must be used */
return result;
#endif
}
/* documentation is in ftcalc.h */
FT_BASE_DEF( FT_Int )
ft_corner_is_flat( FT_Pos in_x,
FT_Pos in_y,
FT_Pos out_x,
FT_Pos out_y )
{
FT_Pos ax = in_x + out_x;
FT_Pos ay = in_y + out_y;
FT_Pos d_in, d_out, d_hypot;
/* The idea of this function is to compare the length of the */
/* hypotenuse with the `in' and `out' length. The `corner' */
/* represented by `in' and `out' is flat if the hypotenuse's */
/* length isn't too large. */
/* */
/* This approach has the advantage that the angle between */
/* `in' and `out' is not checked. In case one of the two */
/* vectors is `dominant', this is, much larger than the */
/* other vector, we thus always have a flat corner. */
/* */
/* hypotenuse */
/* x---------------------------x */
/* \ / */
/* \ / */
/* in \ / out */
/* \ / */
/* o */
/* Point */
d_in = FT_HYPOT( in_x, in_y );
d_out = FT_HYPOT( out_x, out_y );
d_hypot = FT_HYPOT( ax, ay );
/* now do a simple length comparison: */
/* */
/* d_in + d_out < 17/16 d_hypot */
return ( d_in + d_out - d_hypot ) < ( d_hypot >> 4 );
}
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/base/ftcalc.c
|
C++
|
gpl-3.0
| 26,877
|
/****************************************************************************
*
* ftcid.c
*
* FreeType API for accessing CID font information.
*
* Copyright (C) 2007-2022 by
* Derek Clegg and Michael Toftdal.
*
* 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.
*
*/
#include <freetype/ftcid.h>
#include <freetype/internal/ftobjs.h>
#include <freetype/internal/services/svcid.h>
/* documentation is in ftcid.h */
FT_EXPORT_DEF( FT_Error )
FT_Get_CID_Registry_Ordering_Supplement( FT_Face face,
const char* *registry,
const char* *ordering,
FT_Int *supplement)
{
FT_Error error;
const char* r = NULL;
const char* o = NULL;
FT_Int s = 0;
error = FT_ERR( Invalid_Argument );
if ( face )
{
FT_Service_CID service;
FT_FACE_FIND_SERVICE( face, service, CID );
if ( service && service->get_ros )
error = service->get_ros( face, &r, &o, &s );
}
if ( registry )
*registry = r;
if ( ordering )
*ordering = o;
if ( supplement )
*supplement = s;
return error;
}
FT_EXPORT_DEF( FT_Error )
FT_Get_CID_Is_Internally_CID_Keyed( FT_Face face,
FT_Bool *is_cid )
{
FT_Error error = FT_ERR( Invalid_Argument );
FT_Bool ic = 0;
if ( face )
{
FT_Service_CID service;
FT_FACE_FIND_SERVICE( face, service, CID );
if ( service && service->get_is_cid )
error = service->get_is_cid( face, &ic);
}
if ( is_cid )
*is_cid = ic;
return error;
}
FT_EXPORT_DEF( FT_Error )
FT_Get_CID_From_Glyph_Index( FT_Face face,
FT_UInt glyph_index,
FT_UInt *cid )
{
FT_Error error = FT_ERR( Invalid_Argument );
FT_UInt c = 0;
if ( face )
{
FT_Service_CID service;
FT_FACE_FIND_SERVICE( face, service, CID );
if ( service && service->get_cid_from_glyph_index )
error = service->get_cid_from_glyph_index( face, glyph_index, &c);
}
if ( cid )
*cid = c;
return error;
}
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/base/ftcid.c
|
C++
|
gpl-3.0
| 2,540
|
/****************************************************************************
*
* ftcolor.c
*
* FreeType's glyph color management (body).
*
* Copyright (C) 2018-2022 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.
*
*/
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/sfnt.h>
#include <freetype/internal/tttypes.h>
#include <freetype/ftcolor.h>
#ifdef TT_CONFIG_OPTION_COLOR_LAYERS
static
const FT_Palette_Data null_palette_data = { 0, NULL, NULL, 0, NULL };
/* documentation is in ftcolor.h */
FT_EXPORT_DEF( FT_Error )
FT_Palette_Data_Get( FT_Face face,
FT_Palette_Data *apalette_data )
{
if ( !face )
return FT_THROW( Invalid_Face_Handle );
if ( !apalette_data)
return FT_THROW( Invalid_Argument );
if ( FT_IS_SFNT( face ) )
*apalette_data = ( (TT_Face)face )->palette_data;
else
*apalette_data = null_palette_data;
return FT_Err_Ok;
}
/* documentation is in ftcolor.h */
FT_EXPORT_DEF( FT_Error )
FT_Palette_Select( FT_Face face,
FT_UShort palette_index,
FT_Color* *apalette )
{
FT_Error error;
TT_Face ttface;
SFNT_Service sfnt;
if ( !face )
return FT_THROW( Invalid_Face_Handle );
if ( !FT_IS_SFNT( face ) )
{
if ( apalette )
*apalette = NULL;
return FT_Err_Ok;
}
ttface = (TT_Face)face;
sfnt = (SFNT_Service)ttface->sfnt;
error = sfnt->set_palette( ttface, palette_index );
if ( error )
return error;
ttface->palette_index = palette_index;
if ( apalette )
*apalette = ttface->palette;
return FT_Err_Ok;
}
/* documentation is in ftcolor.h */
FT_EXPORT_DEF( FT_Error )
FT_Palette_Set_Foreground_Color( FT_Face face,
FT_Color foreground_color )
{
TT_Face ttface;
if ( !face )
return FT_THROW( Invalid_Face_Handle );
if ( !FT_IS_SFNT( face ) )
return FT_Err_Ok;
ttface = (TT_Face)face;
ttface->foreground_color = foreground_color;
ttface->have_foreground_color = 1;
return FT_Err_Ok;
}
#else /* !TT_CONFIG_OPTION_COLOR_LAYERS */
FT_EXPORT_DEF( FT_Error )
FT_Palette_Data_Get( FT_Face face,
FT_Palette_Data *apalette_data )
{
FT_UNUSED( face );
FT_UNUSED( apalette_data );
return FT_THROW( Unimplemented_Feature );
}
FT_EXPORT_DEF( FT_Error )
FT_Palette_Select( FT_Face face,
FT_UShort palette_index,
FT_Color* *apalette )
{
FT_UNUSED( face );
FT_UNUSED( palette_index );
FT_UNUSED( apalette );
return FT_THROW( Unimplemented_Feature );
}
FT_EXPORT_DEF( FT_Error )
FT_Palette_Set_Foreground_Color( FT_Face face,
FT_Color foreground_color )
{
FT_UNUSED( face );
FT_UNUSED( foreground_color );
return FT_THROW( Unimplemented_Feature );
}
#endif /* !TT_CONFIG_OPTION_COLOR_LAYERS */
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/base/ftcolor.c
|
C++
|
gpl-3.0
| 3,416
|
/****************************************************************************
*
* ftdbgmem.c
*
* Memory debugger (body).
*
* Copyright (C) 2001-2022 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.
*
*/
#include <ft2build.h>
#include FT_CONFIG_CONFIG_H
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/ftmemory.h>
#include <freetype/ftsystem.h>
#include <freetype/fterrors.h>
#include <freetype/fttypes.h>
#ifdef FT_DEBUG_MEMORY
#define KEEPALIVE /* `Keep alive' means that freed blocks aren't released
* to the heap. This is useful to detect double-frees
* or weird heap corruption, but it uses large amounts of
* memory, however.
*/
#include FT_CONFIG_STANDARD_LIBRARY_H
FT_BASE_DEF( const char* ) _ft_debug_file = NULL;
FT_BASE_DEF( long ) _ft_debug_lineno = 0;
extern void
FT_DumpMemory( FT_Memory memory );
typedef struct FT_MemSourceRec_* FT_MemSource;
typedef struct FT_MemNodeRec_* FT_MemNode;
typedef struct FT_MemTableRec_* FT_MemTable;
#define FT_MEM_VAL( addr ) ( (FT_PtrDist)(FT_Pointer)( addr ) )
/*
* This structure holds statistics for a single allocation/release
* site. This is useful to know where memory operations happen the
* most.
*/
typedef struct FT_MemSourceRec_
{
const char* file_name;
long line_no;
FT_Long cur_blocks; /* current number of allocated blocks */
FT_Long max_blocks; /* max. number of allocated blocks */
FT_Long all_blocks; /* total number of blocks allocated */
FT_Long cur_size; /* current cumulative allocated size */
FT_Long max_size; /* maximum cumulative allocated size */
FT_Long all_size; /* total cumulative allocated size */
FT_Long cur_max; /* current maximum allocated size */
FT_UInt32 hash;
FT_MemSource link;
} FT_MemSourceRec;
/*
* We don't need a resizable array for the memory sources because
* their number is pretty limited within FreeType.
*/
#define FT_MEM_SOURCE_BUCKETS 128
/*
* This structure holds information related to a single allocated
* memory block. If KEEPALIVE is defined, blocks that are freed by
* FreeType are never released to the system. Instead, their `size'
* field is set to `-size'. This is mainly useful to detect double
* frees, at the price of a large memory footprint during execution.
*/
typedef struct FT_MemNodeRec_
{
FT_Byte* address;
FT_Long size; /* < 0 if the block was freed */
FT_MemSource source;
#ifdef KEEPALIVE
const char* free_file_name;
FT_Long free_line_no;
#endif
FT_MemNode link;
} FT_MemNodeRec;
/*
* The global structure, containing compound statistics and all hash
* tables.
*/
typedef struct FT_MemTableRec_
{
FT_Long size;
FT_Long nodes;
FT_MemNode* buckets;
FT_Long alloc_total;
FT_Long alloc_current;
FT_Long alloc_max;
FT_Long alloc_count;
FT_Bool bound_total;
FT_Long alloc_total_max;
FT_Bool bound_count;
FT_Long alloc_count_max;
FT_MemSource sources[FT_MEM_SOURCE_BUCKETS];
FT_Bool keep_alive;
FT_Memory memory;
FT_Pointer memory_user;
FT_Alloc_Func alloc;
FT_Free_Func free;
FT_Realloc_Func realloc;
} FT_MemTableRec;
#define FT_MEM_SIZE_MIN 7
#define FT_MEM_SIZE_MAX 13845163
#define FT_FILENAME( x ) ( (x) ? (x) : "unknown file" )
/*
* Prime numbers are ugly to handle. It would be better to implement
* L-Hashing, which is 10% faster and doesn't require divisions.
*/
static const FT_Int ft_mem_primes[] =
{
7,
11,
19,
37,
73,
109,
163,
251,
367,
557,
823,
1237,
1861,
2777,
4177,
6247,
9371,
14057,
21089,
31627,
47431,
71143,
106721,
160073,
240101,
360163,
540217,
810343,
1215497,
1823231,
2734867,
4102283,
6153409,
9230113,
13845163,
};
static FT_Long
ft_mem_closest_prime( FT_Long num )
{
size_t i;
for ( i = 0;
i < sizeof ( ft_mem_primes ) / sizeof ( ft_mem_primes[0] ); i++ )
if ( ft_mem_primes[i] > num )
return ft_mem_primes[i];
return FT_MEM_SIZE_MAX;
}
static void
ft_mem_debug_panic( const char* fmt,
... )
{
va_list ap;
printf( "FreeType.Debug: " );
va_start( ap, fmt );
vprintf( fmt, ap );
va_end( ap );
printf( "\n" );
exit( EXIT_FAILURE );
}
static FT_Pointer
ft_mem_table_alloc( FT_MemTable table,
FT_Long size )
{
FT_Memory memory = table->memory;
FT_Pointer block;
memory->user = table->memory_user;
block = table->alloc( memory, size );
memory->user = table;
return block;
}
static void
ft_mem_table_free( FT_MemTable table,
FT_Pointer block )
{
FT_Memory memory = table->memory;
memory->user = table->memory_user;
table->free( memory, block );
memory->user = table;
}
static void
ft_mem_table_resize( FT_MemTable table )
{
FT_Long new_size;
new_size = ft_mem_closest_prime( table->nodes );
if ( new_size != table->size )
{
FT_MemNode* new_buckets;
FT_Long i;
new_buckets = (FT_MemNode *)
ft_mem_table_alloc(
table,
new_size * (FT_Long)sizeof ( FT_MemNode ) );
if ( !new_buckets )
return;
FT_ARRAY_ZERO( new_buckets, new_size );
for ( i = 0; i < table->size; i++ )
{
FT_MemNode node, next, *pnode;
FT_PtrDist hash;
node = table->buckets[i];
while ( node )
{
next = node->link;
hash = FT_MEM_VAL( node->address ) % (FT_PtrDist)new_size;
pnode = new_buckets + hash;
node->link = pnode[0];
pnode[0] = node;
node = next;
}
}
if ( table->buckets )
ft_mem_table_free( table, table->buckets );
table->buckets = new_buckets;
table->size = new_size;
}
}
static void
ft_mem_table_destroy( FT_MemTable table )
{
FT_Long i;
FT_Long leak_count = 0;
FT_Long leaks = 0;
/* remove all blocks from the table, revealing leaked ones */
for ( i = 0; i < table->size; i++ )
{
FT_MemNode *pnode = table->buckets + i, next, node = *pnode;
while ( node )
{
next = node->link;
node->link = NULL;
if ( node->size > 0 )
{
printf(
"leaked memory block at address %p, size %8ld in (%s:%ld)\n",
(void*)node->address,
node->size,
FT_FILENAME( node->source->file_name ),
node->source->line_no );
leak_count++;
leaks += node->size;
ft_mem_table_free( table, node->address );
}
node->address = NULL;
node->size = 0;
ft_mem_table_free( table, node );
node = next;
}
table->buckets[i] = NULL;
}
ft_mem_table_free( table, table->buckets );
table->buckets = NULL;
table->size = 0;
table->nodes = 0;
/* remove all sources */
for ( i = 0; i < FT_MEM_SOURCE_BUCKETS; i++ )
{
FT_MemSource source, next;
for ( source = table->sources[i]; source != NULL; source = next )
{
next = source->link;
ft_mem_table_free( table, source );
}
table->sources[i] = NULL;
}
printf( "FreeType: total memory allocations = %ld\n",
table->alloc_total );
printf( "FreeType: maximum memory footprint = %ld\n",
table->alloc_max );
if ( leak_count > 0 )
ft_mem_debug_panic(
"FreeType: %ld bytes of memory leaked in %ld blocks\n",
leaks, leak_count );
printf( "FreeType: no memory leaks detected\n" );
}
static FT_MemNode*
ft_mem_table_get_nodep( FT_MemTable table,
FT_Byte* address )
{
FT_PtrDist hash;
FT_MemNode *pnode, node;
hash = FT_MEM_VAL( address );
pnode = table->buckets + ( hash % (FT_PtrDist)table->size );
for (;;)
{
node = pnode[0];
if ( !node )
break;
if ( node->address == address )
break;
pnode = &node->link;
}
return pnode;
}
static FT_MemSource
ft_mem_table_get_source( FT_MemTable table )
{
FT_UInt32 hash;
FT_MemSource node, *pnode;
/* cast to FT_PtrDist first since void* can be larger */
/* than FT_UInt32 and GCC 4.1.1 emits a warning */
hash = (FT_UInt32)(FT_PtrDist)(void*)_ft_debug_file +
(FT_UInt32)( 5 * _ft_debug_lineno );
pnode = &table->sources[hash % FT_MEM_SOURCE_BUCKETS];
for (;;)
{
node = *pnode;
if ( !node )
break;
if ( node->file_name == _ft_debug_file &&
node->line_no == _ft_debug_lineno )
goto Exit;
pnode = &node->link;
}
node = (FT_MemSource)ft_mem_table_alloc( table, sizeof ( *node ) );
if ( !node )
ft_mem_debug_panic(
"not enough memory to perform memory debugging\n" );
node->file_name = _ft_debug_file;
node->line_no = _ft_debug_lineno;
node->cur_blocks = 0;
node->max_blocks = 0;
node->all_blocks = 0;
node->cur_size = 0;
node->max_size = 0;
node->all_size = 0;
node->cur_max = 0;
node->link = NULL;
node->hash = hash;
*pnode = node;
Exit:
return node;
}
static void
ft_mem_table_set( FT_MemTable table,
FT_Byte* address,
FT_Long size,
FT_Long delta )
{
FT_MemNode *pnode, node;
if ( table )
{
FT_MemSource source;
pnode = ft_mem_table_get_nodep( table, address );
node = *pnode;
if ( node )
{
if ( node->size < 0 )
{
/* This block was already freed. Our memory is now completely */
/* corrupted! */
/* This can only happen in keep-alive mode. */
ft_mem_debug_panic(
"memory heap corrupted (allocating freed block)" );
}
else
{
/* This block was already allocated. This means that our memory */
/* is also corrupted! */
ft_mem_debug_panic(
"memory heap corrupted (re-allocating allocated block at"
" %p, of size %ld)\n"
"org=%s:%d new=%s:%d\n",
node->address, node->size,
FT_FILENAME( node->source->file_name ), node->source->line_no,
FT_FILENAME( _ft_debug_file ), _ft_debug_lineno );
}
}
/* we need to create a new node in this table */
node = (FT_MemNode)ft_mem_table_alloc( table, sizeof ( *node ) );
if ( !node )
ft_mem_debug_panic( "not enough memory to run memory tests" );
node->address = address;
node->size = size;
node->source = source = ft_mem_table_get_source( table );
if ( delta == 0 )
{
/* this is an allocation */
source->all_blocks++;
source->cur_blocks++;
if ( source->cur_blocks > source->max_blocks )
source->max_blocks = source->cur_blocks;
}
if ( size > source->cur_max )
source->cur_max = size;
if ( delta != 0 )
{
/* we are growing or shrinking a reallocated block */
source->cur_size += delta;
table->alloc_current += delta;
}
else
{
/* we are allocating a new block */
source->cur_size += size;
table->alloc_current += size;
}
source->all_size += size;
if ( source->cur_size > source->max_size )
source->max_size = source->cur_size;
node->free_file_name = NULL;
node->free_line_no = 0;
node->link = pnode[0];
pnode[0] = node;
table->nodes++;
table->alloc_total += size;
if ( table->alloc_current > table->alloc_max )
table->alloc_max = table->alloc_current;
if ( table->nodes * 3 < table->size ||
table->size * 3 < table->nodes )
ft_mem_table_resize( table );
}
}
static void
ft_mem_table_remove( FT_MemTable table,
FT_Byte* address,
FT_Long delta )
{
if ( table )
{
FT_MemNode *pnode, node;
pnode = ft_mem_table_get_nodep( table, address );
node = *pnode;
if ( node )
{
FT_MemSource source;
if ( node->size < 0 )
ft_mem_debug_panic(
"freeing memory block at %p more than once\n"
" at (%s:%ld)!\n"
" Block was allocated at (%s:%ld)\n"
" and released at (%s:%ld).",
address,
FT_FILENAME( _ft_debug_file ), _ft_debug_lineno,
FT_FILENAME( node->source->file_name ), node->source->line_no,
FT_FILENAME( node->free_file_name ), node->free_line_no );
/* scramble the node's content for additional safety */
FT_MEM_SET( address, 0xF3, node->size );
if ( delta == 0 )
{
source = node->source;
source->cur_blocks--;
source->cur_size -= node->size;
table->alloc_current -= node->size;
}
if ( table->keep_alive )
{
/* we simply invert the node's size to indicate that the node */
/* was freed. */
node->size = -node->size;
node->free_file_name = _ft_debug_file;
node->free_line_no = _ft_debug_lineno;
}
else
{
table->nodes--;
*pnode = node->link;
node->size = 0;
node->source = NULL;
ft_mem_table_free( table, node );
if ( table->nodes * 3 < table->size ||
table->size * 3 < table->nodes )
ft_mem_table_resize( table );
}
}
else
ft_mem_debug_panic(
"trying to free unknown block at %p in (%s:%ld)\n",
address,
FT_FILENAME( _ft_debug_file ), _ft_debug_lineno );
}
}
static FT_Pointer
ft_mem_debug_alloc( FT_Memory memory,
FT_Long size )
{
FT_MemTable table = (FT_MemTable)memory->user;
FT_Byte* block;
if ( size <= 0 )
ft_mem_debug_panic( "negative block size allocation (%ld)", size );
/* return NULL if the maximum number of allocations was reached */
if ( table->bound_count &&
table->alloc_count >= table->alloc_count_max )
return NULL;
/* return NULL if this allocation would overflow the maximum heap size */
if ( table->bound_total &&
table->alloc_total_max - table->alloc_current > size )
return NULL;
block = (FT_Byte *)ft_mem_table_alloc( table, size );
if ( block )
{
ft_mem_table_set( table, block, size, 0 );
table->alloc_count++;
}
_ft_debug_file = "<unknown>";
_ft_debug_lineno = 0;
return (FT_Pointer)block;
}
static void
ft_mem_debug_free( FT_Memory memory,
FT_Pointer block )
{
FT_MemTable table = (FT_MemTable)memory->user;
if ( !block )
ft_mem_debug_panic( "trying to free NULL in (%s:%ld)",
FT_FILENAME( _ft_debug_file ),
_ft_debug_lineno );
ft_mem_table_remove( table, (FT_Byte*)block, 0 );
if ( !table->keep_alive )
ft_mem_table_free( table, block );
table->alloc_count--;
_ft_debug_file = "<unknown>";
_ft_debug_lineno = 0;
}
static FT_Pointer
ft_mem_debug_realloc( FT_Memory memory,
FT_Long cur_size,
FT_Long new_size,
FT_Pointer block )
{
FT_MemTable table = (FT_MemTable)memory->user;
FT_MemNode node, *pnode;
FT_Pointer new_block;
FT_Long delta;
const char* file_name = FT_FILENAME( _ft_debug_file );
FT_Long line_no = _ft_debug_lineno;
/* unlikely, but possible */
if ( new_size == cur_size )
return block;
/* the following is valid according to ANSI C */
#if 0
if ( !block || !cur_size )
ft_mem_debug_panic( "trying to reallocate NULL in (%s:%ld)",
file_name, line_no );
#endif
/* while the following is allowed in ANSI C also, we abort since */
/* such case should be handled by FreeType. */
if ( new_size <= 0 )
ft_mem_debug_panic(
"trying to reallocate %p to size 0 (current is %ld) in (%s:%ld)",
block, cur_size, file_name, line_no );
/* check `cur_size' value */
pnode = ft_mem_table_get_nodep( table, (FT_Byte*)block );
node = *pnode;
if ( !node )
ft_mem_debug_panic(
"trying to reallocate unknown block at %p in (%s:%ld)",
block, file_name, line_no );
if ( node->size <= 0 )
ft_mem_debug_panic(
"trying to reallocate freed block at %p in (%s:%ld)",
block, file_name, line_no );
if ( node->size != cur_size )
ft_mem_debug_panic( "invalid ft_realloc request for %p. cur_size is "
"%ld instead of %ld in (%s:%ld)",
block, cur_size, node->size, file_name, line_no );
/* return NULL if the maximum number of allocations was reached */
if ( table->bound_count &&
table->alloc_count >= table->alloc_count_max )
return NULL;
delta = new_size - cur_size;
/* return NULL if this allocation would overflow the maximum heap size */
if ( delta > 0 &&
table->bound_total &&
table->alloc_current + delta > table->alloc_total_max )
return NULL;
new_block = (FT_Pointer)ft_mem_table_alloc( table, new_size );
if ( !new_block )
return NULL;
ft_mem_table_set( table, (FT_Byte*)new_block, new_size, delta );
ft_memcpy( new_block, block, cur_size < new_size ? (size_t)cur_size
: (size_t)new_size );
ft_mem_table_remove( table, (FT_Byte*)block, delta );
_ft_debug_file = "<unknown>";
_ft_debug_lineno = 0;
if ( !table->keep_alive )
ft_mem_table_free( table, block );
return new_block;
}
extern void
ft_mem_debug_init( FT_Memory memory )
{
FT_MemTable table;
if ( !ft_getenv( "FT2_DEBUG_MEMORY" ) )
return;
table = (FT_MemTable)memory->alloc( memory, sizeof ( *table ) );
if ( table )
{
FT_ZERO( table );
table->memory = memory;
table->memory_user = memory->user;
table->alloc = memory->alloc;
table->realloc = memory->realloc;
table->free = memory->free;
ft_mem_table_resize( table );
if ( table->size )
{
const char* p;
memory->user = table;
memory->alloc = ft_mem_debug_alloc;
memory->realloc = ft_mem_debug_realloc;
memory->free = ft_mem_debug_free;
p = ft_getenv( "FT2_ALLOC_TOTAL_MAX" );
if ( p )
{
FT_Long total_max = ft_strtol( p, NULL, 10 );
if ( total_max > 0 )
{
table->bound_total = 1;
table->alloc_total_max = total_max;
}
}
p = ft_getenv( "FT2_ALLOC_COUNT_MAX" );
if ( p )
{
FT_Long total_count = ft_strtol( p, NULL, 10 );
if ( total_count > 0 )
{
table->bound_count = 1;
table->alloc_count_max = total_count;
}
}
p = ft_getenv( "FT2_KEEP_ALIVE" );
if ( p )
{
FT_Long keep_alive = ft_strtol( p, NULL, 10 );
if ( keep_alive > 0 )
table->keep_alive = 1;
}
}
else
memory->free( memory, table );
}
}
extern void
ft_mem_debug_done( FT_Memory memory )
{
if ( memory->free == ft_mem_debug_free )
{
FT_MemTable table = (FT_MemTable)memory->user;
FT_DumpMemory( memory );
ft_mem_table_destroy( table );
memory->free = table->free;
memory->realloc = table->realloc;
memory->alloc = table->alloc;
memory->user = table->memory_user;
memory->free( memory, table );
}
}
static int
ft_mem_source_compare( const void* p1,
const void* p2 )
{
FT_MemSource s1 = *(FT_MemSource*)p1;
FT_MemSource s2 = *(FT_MemSource*)p2;
if ( s2->max_size > s1->max_size )
return 1;
else if ( s2->max_size < s1->max_size )
return -1;
else
return 0;
}
extern void
FT_DumpMemory( FT_Memory memory )
{
if ( memory->free == ft_mem_debug_free )
{
FT_MemTable table = (FT_MemTable)memory->user;
FT_MemSource* bucket = table->sources;
FT_MemSource* limit = bucket + FT_MEM_SOURCE_BUCKETS;
FT_MemSource* sources;
FT_Int nn, count;
const char* fmt;
count = 0;
for ( ; bucket < limit; bucket++ )
{
FT_MemSource source = *bucket;
for ( ; source; source = source->link )
count++;
}
sources = (FT_MemSource*)
ft_mem_table_alloc(
table, count * (FT_Long)sizeof ( *sources ) );
count = 0;
for ( bucket = table->sources; bucket < limit; bucket++ )
{
FT_MemSource source = *bucket;
for ( ; source; source = source->link )
sources[count++] = source;
}
ft_qsort( sources,
(size_t)count,
sizeof ( *sources ),
ft_mem_source_compare );
printf( "FreeType Memory Dump: "
"current=%ld max=%ld total=%ld count=%ld\n",
table->alloc_current, table->alloc_max,
table->alloc_total, table->alloc_count );
printf( " block block sizes sizes sizes source\n" );
printf( " count high sum highsum max location\n" );
printf( "-------------------------------------------------\n" );
fmt = "%6ld %6ld %8ld %8ld %8ld %s:%d\n";
for ( nn = 0; nn < count; nn++ )
{
FT_MemSource source = sources[nn];
printf( fmt,
source->cur_blocks, source->max_blocks,
source->cur_size, source->max_size, source->cur_max,
FT_FILENAME( source->file_name ),
source->line_no );
}
printf( "------------------------------------------------\n" );
ft_mem_table_free( table, sources );
}
}
#else /* !FT_DEBUG_MEMORY */
/* ANSI C doesn't like empty source files */
typedef int _debug_mem_dummy;
#endif /* !FT_DEBUG_MEMORY */
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/base/ftdbgmem.c
|
C++
|
gpl-3.0
| 23,915
|
/****************************************************************************
*
* ftdebug.c
*
* Debugging and logging component (body).
*
* Copyright (C) 1996-2022 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 component contains various macros and functions used to ease the
* debugging of the FreeType engine. Its main purpose is in assertion
* checking, tracing, and error detection.
*
* There are now three debugging modes:
*
* - trace mode
*
* Error and trace messages are sent to the log file (which can be the
* standard error output).
*
* - error mode
*
* Only error messages are generated.
*
* - release mode:
*
* No error message is sent or generated. The code is free from any
* debugging parts.
*
*/
#include <freetype/freetype.h>
#include <freetype/ftlogging.h>
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/ftobjs.h>
#ifdef FT_DEBUG_LOGGING
/**************************************************************************
*
* Variables used to control logging.
*
* 1. `ft_default_trace_level` stores the value of trace levels, which are
* provided to FreeType using the `FT2_DEBUG` environment variable.
*
* 2. `ft_fileptr` stores the `FILE*` handle.
*
* 3. `ft_component` is a string that holds the name of `FT_COMPONENT`.
*
* 4. The flag `ft_component_flag` prints the name of `FT_COMPONENT` along
* with the actual log message if set to true.
*
* 5. The flag `ft_timestamp_flag` prints time along with the actual log
* message if set to ture.
*
* 6. `ft_have_newline_char` is used to differentiate between a log
* message with and without a trailing newline character.
*
* 7. `ft_custom_trace_level` stores the custom trace level value, which
* is provided by the user at run-time.
*
* We use `static` to avoid 'unused variable' warnings.
*
*/
static const char* ft_default_trace_level = NULL;
static FILE* ft_fileptr = NULL;
static const char* ft_component = NULL;
static FT_Bool ft_component_flag = FALSE;
static FT_Bool ft_timestamp_flag = FALSE;
static FT_Bool ft_have_newline_char = TRUE;
static const char* ft_custom_trace_level = NULL;
/* declared in ftdebug.h */
dlg_handler ft_default_log_handler = NULL;
FT_Custom_Log_Handler custom_output_handler = NULL;
#endif /* FT_DEBUG_LOGGING */
#ifdef FT_DEBUG_LEVEL_ERROR
/* documentation is in ftdebug.h */
FT_BASE_DEF( void )
FT_Message( const char* fmt,
... )
{
va_list ap;
va_start( ap, fmt );
vfprintf( stderr, fmt, ap );
va_end( ap );
}
/* documentation is in ftdebug.h */
FT_BASE_DEF( void )
FT_Panic( const char* fmt,
... )
{
va_list ap;
va_start( ap, fmt );
vfprintf( stderr, fmt, ap );
va_end( ap );
exit( EXIT_FAILURE );
}
/* documentation is in ftdebug.h */
FT_BASE_DEF( int )
FT_Throw( FT_Error error,
int line,
const char* file )
{
#if 0
/* activating the code in this block makes FreeType very chatty */
fprintf( stderr,
"%s:%d: error 0x%02x: %s\n",
file,
line,
error,
FT_Error_String( error ) );
#else
FT_UNUSED( error );
FT_UNUSED( line );
FT_UNUSED( file );
#endif
return 0;
}
#endif /* FT_DEBUG_LEVEL_ERROR */
#ifdef FT_DEBUG_LEVEL_TRACE
/* array of trace levels, initialized to 0; */
/* this gets adjusted at run-time */
static int ft_trace_levels_enabled[trace_count];
/* array of trace levels, always initialized to 0 */
static int ft_trace_levels_disabled[trace_count];
/* a pointer to either `ft_trace_levels_enabled' */
/* or `ft_trace_levels_disabled' */
int* ft_trace_levels;
/* define array of trace toggle names */
#define FT_TRACE_DEF( x ) #x ,
static const char* ft_trace_toggles[trace_count + 1] =
{
#include <freetype/internal/fttrace.h>
NULL
};
#undef FT_TRACE_DEF
/* documentation is in ftdebug.h */
FT_BASE_DEF( FT_Int )
FT_Trace_Get_Count( void )
{
return trace_count;
}
/* documentation is in ftdebug.h */
FT_BASE_DEF( const char * )
FT_Trace_Get_Name( FT_Int idx )
{
int max = FT_Trace_Get_Count();
if ( idx < max )
return ft_trace_toggles[idx];
else
return NULL;
}
/* documentation is in ftdebug.h */
FT_BASE_DEF( void )
FT_Trace_Disable( void )
{
ft_trace_levels = ft_trace_levels_disabled;
}
/* documentation is in ftdebug.h */
FT_BASE_DEF( void )
FT_Trace_Enable( void )
{
ft_trace_levels = ft_trace_levels_enabled;
}
/**************************************************************************
*
* Initialize the tracing sub-system. This is done by retrieving the
* value of the `FT2_DEBUG' environment variable. It must be a list of
* toggles, separated by spaces, `;', or `,'. Example:
*
* export FT2_DEBUG="any:3 memory:7 stream:5"
*
* This requests that all levels be set to 3, except the trace level for
* the memory and stream components which are set to 7 and 5,
* respectively.
*
* See the file `include/freetype/internal/fttrace.h' for details of
* the available toggle names.
*
* The level must be between 0 and 7; 0 means quiet (except for serious
* runtime errors), and 7 means _very_ verbose.
*/
FT_BASE_DEF( void )
ft_debug_init( void )
{
const char* ft2_debug = NULL;
#ifdef FT_DEBUG_LOGGING
if ( ft_custom_trace_level != NULL )
ft2_debug = ft_custom_trace_level;
else
ft2_debug = ft_default_trace_level;
#else
ft2_debug = ft_getenv( "FT2_DEBUG" );
#endif
if ( ft2_debug )
{
const char* p = ft2_debug;
const char* q;
for ( ; *p; p++ )
{
/* skip leading whitespace and separators */
if ( *p == ' ' || *p == '\t' || *p == ',' || *p == ';' || *p == '=' )
continue;
#ifdef FT_DEBUG_LOGGING
/* check extra arguments for logging */
if ( *p == '-' )
{
const char* r = ++p;
if ( *r == 'v' )
{
const char* s = ++r;
ft_component_flag = TRUE;
if ( *s == 't' )
{
ft_timestamp_flag = TRUE;
p++;
}
p++;
}
else if ( *r == 't' )
{
const char* s = ++r;
ft_timestamp_flag = TRUE;
if ( *s == 'v' )
{
ft_component_flag = TRUE;
p++;
}
p++;
}
}
#endif /* FT_DEBUG_LOGGING */
/* read toggle name, followed by ':' */
q = p;
while ( *p && *p != ':' )
p++;
if ( !*p )
break;
if ( *p == ':' && p > q )
{
FT_Int n, i, len = (FT_Int)( p - q );
FT_Int level = -1, found = -1;
for ( n = 0; n < trace_count; n++ )
{
const char* toggle = ft_trace_toggles[n];
for ( i = 0; i < len; i++ )
{
if ( toggle[i] != q[i] )
break;
}
if ( i == len && toggle[i] == 0 )
{
found = n;
break;
}
}
/* read level */
p++;
if ( *p )
{
level = *p - '0';
if ( level < 0 || level > 7 )
level = -1;
}
if ( found >= 0 && level >= 0 )
{
if ( found == trace_any )
{
/* special case for `any' */
for ( n = 0; n < trace_count; n++ )
ft_trace_levels_enabled[n] = level;
}
else
ft_trace_levels_enabled[found] = level;
}
}
}
}
ft_trace_levels = ft_trace_levels_enabled;
}
#else /* !FT_DEBUG_LEVEL_TRACE */
FT_BASE_DEF( void )
ft_debug_init( void )
{
/* nothing */
}
FT_BASE_DEF( FT_Int )
FT_Trace_Get_Count( void )
{
return 0;
}
FT_BASE_DEF( const char * )
FT_Trace_Get_Name( FT_Int idx )
{
FT_UNUSED( idx );
return NULL;
}
FT_BASE_DEF( void )
FT_Trace_Disable( void )
{
/* nothing */
}
/* documentation is in ftdebug.h */
FT_BASE_DEF( void )
FT_Trace_Enable( void )
{
/* nothing */
}
#endif /* !FT_DEBUG_LEVEL_TRACE */
#ifdef FT_DEBUG_LOGGING
/**************************************************************************
*
* Initialize and de-initialize 'dlg' library.
*
*/
FT_BASE_DEF( void )
ft_logging_init( void )
{
ft_default_log_handler = ft_log_handler;
ft_default_trace_level = ft_getenv( "FT2_DEBUG" );
if ( ft_getenv( "FT_LOGGING_FILE" ) )
ft_fileptr = ft_fopen( ft_getenv( "FT_LOGGING_FILE" ), "w" );
else
ft_fileptr = stderr;
ft_debug_init();
/* Set the default output handler for 'dlg'. */
dlg_set_handler( ft_default_log_handler, NULL );
}
FT_BASE_DEF( void )
ft_logging_deinit( void )
{
if ( ft_fileptr != stderr )
ft_fclose( ft_fileptr );
}
/**************************************************************************
*
* An output log handler for FreeType.
*
*/
FT_BASE_DEF( void )
ft_log_handler( const struct dlg_origin* origin,
const char* string,
void* data )
{
char features_buf[128];
char* bufp = features_buf;
FT_UNUSED( data );
if ( ft_have_newline_char )
{
const char* features = NULL;
size_t features_length = 0;
#define FEATURES_TIMESTAMP "[%h:%m] "
#define FEATURES_COMPONENT "[%t] "
#define FEATURES_TIMESTAMP_COMPONENT "[%h:%m %t] "
if ( ft_timestamp_flag && ft_component_flag )
{
features = FEATURES_TIMESTAMP_COMPONENT;
features_length = sizeof ( FEATURES_TIMESTAMP_COMPONENT );
}
else if ( ft_timestamp_flag )
{
features = FEATURES_TIMESTAMP;
features_length = sizeof ( FEATURES_TIMESTAMP );
}
else if ( ft_component_flag )
{
features = FEATURES_COMPONENT;
features_length = sizeof ( FEATURES_COMPONENT );
}
if ( ft_component_flag || ft_timestamp_flag )
{
ft_strncpy( features_buf, features, features_length );
bufp += features_length - 1;
}
if ( ft_component_flag )
{
size_t tag_length = ft_strlen( *origin->tags );
size_t i;
/* To vertically align tracing messages we compensate the */
/* different FT_COMPONENT string lengths by inserting an */
/* appropriate amount of space characters. */
for ( i = 0;
i < FT_MAX_TRACE_LEVEL_LENGTH - tag_length;
i++ )
*bufp++ = ' ';
}
}
/* Finally add the format string for the tracing message. */
*bufp++ = '%';
*bufp++ = 'c';
*bufp = '\0';
dlg_generic_outputf_stream( ft_fileptr,
(const char*)features_buf,
origin,
string,
dlg_default_output_styles,
true );
if ( ft_strrchr( string, '\n' ) )
ft_have_newline_char = TRUE;
else
ft_have_newline_char = FALSE;
}
/* documentation is in ftdebug.h */
FT_BASE_DEF( void )
ft_add_tag( const char* tag )
{
ft_component = tag;
dlg_add_tag( tag, NULL );
}
/* documentation is in ftdebug.h */
FT_BASE_DEF( void )
ft_remove_tag( const char* tag )
{
dlg_remove_tag( tag, NULL );
}
/* documentation is in ftlogging.h */
FT_EXPORT_DEF( void )
FT_Trace_Set_Level( const char* level )
{
ft_component_flag = FALSE;
ft_timestamp_flag = FALSE;
ft_custom_trace_level = level;
ft_debug_init();
}
/* documentation is in ftlogging.h */
FT_EXPORT_DEF( void )
FT_Trace_Set_Default_Level( void )
{
ft_component_flag = FALSE;
ft_timestamp_flag = FALSE;
ft_custom_trace_level = NULL;
ft_debug_init();
}
/**************************************************************************
*
* Functions to handle a custom log handler.
*
*/
/* documentation is in ftlogging.h */
FT_EXPORT_DEF( void )
FT_Set_Log_Handler( FT_Custom_Log_Handler handler )
{
custom_output_handler = handler;
}
/* documentation is in ftlogging.h */
FT_EXPORT_DEF( void )
FT_Set_Default_Log_Handler( void )
{
custom_output_handler = NULL;
}
/* documentation is in ftdebug.h */
FT_BASE_DEF( void )
FT_Logging_Callback( const char* fmt,
... )
{
va_list ap;
va_start( ap, fmt );
custom_output_handler( ft_component, fmt, ap );
va_end( ap );
}
#else /* !FT_DEBUG_LOGGING */
FT_EXPORT_DEF( void )
FT_Trace_Set_Level( const char* level )
{
FT_UNUSED( level );
}
FT_EXPORT_DEF( void )
FT_Trace_Set_Default_Level( void )
{
/* nothing */
}
FT_EXPORT_DEF( void )
FT_Set_Log_Handler( FT_Custom_Log_Handler handler )
{
FT_UNUSED( handler );
}
FT_EXPORT_DEF( void )
FT_Set_Default_Log_Handler( void )
{
/* nothing */
}
#endif /* !FT_DEBUG_LOGGING */
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/base/ftdebug.c
|
C++
|
gpl-3.0
| 14,105
|
/****************************************************************************
*
* fterrors.c
*
* FreeType API for error code handling.
*
* Copyright (C) 2018-2022 by
* Armin Hasitzka, 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.
*
*/
#include <freetype/internal/ftdebug.h>
#include <freetype/fterrors.h>
/* documentation is in fterrors.h */
FT_EXPORT_DEF( const char* )
FT_Error_String( FT_Error error_code )
{
if ( error_code < 0 ||
error_code >= FT_ERR_CAT( FT_ERR_PREFIX, Max ) )
return NULL;
#if defined( FT_CONFIG_OPTION_ERROR_STRINGS ) || \
defined( FT_DEBUG_LEVEL_ERROR )
#undef FTERRORS_H_
#define FT_ERROR_START_LIST switch ( FT_ERROR_BASE( error_code ) ) {
#define FT_ERRORDEF( e, v, s ) case v: return s;
#define FT_ERROR_END_LIST }
#include <freetype/fterrors.h>
#endif /* defined( FT_CONFIG_OPTION_ERROR_STRINGS ) || ... */
return NULL;
}
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/base/fterrors.c
|
C++
|
gpl-3.0
| 1,267
|
/****************************************************************************
*
* ftfntfmt.c
*
* FreeType utility file for font formats (body).
*
* Copyright (C) 2002-2022 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.
*
*/
#include <freetype/ftfntfmt.h>
#include <freetype/internal/ftobjs.h>
#include <freetype/internal/services/svfntfmt.h>
/* documentation is in ftfntfmt.h */
FT_EXPORT_DEF( const char* )
FT_Get_Font_Format( FT_Face face )
{
const char* result = NULL;
if ( face )
FT_FACE_FIND_SERVICE( face, result, FONT_FORMAT );
return result;
}
/* deprecated function name; retained for ABI compatibility */
FT_EXPORT_DEF( const char* )
FT_Get_X11_Font_Format( FT_Face face )
{
const char* result = NULL;
if ( face )
FT_FACE_FIND_SERVICE( face, result, FONT_FORMAT );
return result;
}
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/base/ftfntfmt.c
|
C++
|
gpl-3.0
| 1,203
|
/****************************************************************************
*
* ftfstype.c
*
* FreeType utility file to access FSType data (body).
*
* Copyright (C) 2008-2022 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.
*
*/
#include <freetype/t1tables.h>
#include <freetype/tttables.h>
#include <freetype/internal/ftserv.h>
#include <freetype/internal/services/svpsinfo.h>
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_UShort )
FT_Get_FSType_Flags( FT_Face face )
{
TT_OS2* os2;
/* first, try to get the fs_type directly from the font */
if ( face )
{
FT_Service_PsInfo service = NULL;
FT_FACE_FIND_SERVICE( face, service, POSTSCRIPT_INFO );
if ( service && service->ps_get_font_extra )
{
PS_FontExtraRec extra;
if ( !service->ps_get_font_extra( face, &extra ) &&
extra.fs_type != 0 )
return extra.fs_type;
}
}
/* look at FSType before fsType for Type42 */
if ( ( os2 = (TT_OS2*)FT_Get_Sfnt_Table( face, FT_SFNT_OS2 ) ) != NULL &&
os2->version != 0xFFFFU )
return os2->fsType;
return 0;
}
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/base/ftfstype.c
|
C++
|
gpl-3.0
| 1,551
|
/****************************************************************************
*
* ftgasp.c
*
* Access of TrueType's `gasp' table (body).
*
* Copyright (C) 2007-2022 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.
*
*/
#include <freetype/ftgasp.h>
#include <freetype/internal/tttypes.h>
FT_EXPORT_DEF( FT_Int )
FT_Get_Gasp( FT_Face face,
FT_UInt ppem )
{
FT_Int result = FT_GASP_NO_TABLE;
if ( face && FT_IS_SFNT( face ) )
{
TT_Face ttface = (TT_Face)face;
if ( ttface->gasp.numRanges > 0 )
{
TT_GaspRange range = ttface->gasp.gaspRanges;
TT_GaspRange range_end = range + ttface->gasp.numRanges;
while ( ppem > range->maxPPEM )
{
range++;
if ( range >= range_end )
goto Exit;
}
result = range->gaspFlag;
/* ensure that we don't have spurious bits */
if ( ttface->gasp.version == 0 )
result &= 3;
}
}
Exit:
return result;
}
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/base/ftgasp.c
|
C++
|
gpl-3.0
| 1,355
|
/****************************************************************************
*
* ftgloadr.c
*
* The FreeType glyph loader (body).
*
* Copyright (C) 2002-2022 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.
*
*/
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/ftgloadr.h>
#include <freetype/internal/ftmemory.h>
#include <freetype/internal/ftobjs.h>
#undef FT_COMPONENT
#define FT_COMPONENT gloader
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** *****/
/***** G L Y P H L O A D E R *****/
/***** *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/**************************************************************************
*
* The glyph loader is a simple object which is used to load a set of
* glyphs easily. It is critical for the correct loading of composites.
*
* Ideally, one can see it as a stack of abstract `glyph' objects.
*
* loader.base Is really the bottom of the stack. It describes a
* single glyph image made of the juxtaposition of
* several glyphs (those `in the stack').
*
* loader.current Describes the top of the stack, on which a new
* glyph can be loaded.
*
* Rewind Clears the stack.
* Prepare Set up `loader.current' for addition of a new glyph
* image.
* Add Add the `current' glyph image to the `base' one,
* and prepare for another one.
*
* The glyph loader is now a base object. Each driver used to
* re-implement it in one way or the other, which wasted code and
* energy.
*
*/
/* create a new glyph loader */
FT_BASE_DEF( FT_Error )
FT_GlyphLoader_New( FT_Memory memory,
FT_GlyphLoader *aloader )
{
FT_GlyphLoader loader = NULL;
FT_Error error;
if ( !FT_NEW( loader ) )
{
loader->memory = memory;
*aloader = loader;
}
return error;
}
/* rewind the glyph loader - reset counters to 0 */
FT_BASE_DEF( void )
FT_GlyphLoader_Rewind( FT_GlyphLoader loader )
{
FT_GlyphLoad base = &loader->base;
FT_GlyphLoad current = &loader->current;
base->outline.n_points = 0;
base->outline.n_contours = 0;
base->outline.flags = 0;
base->num_subglyphs = 0;
*current = *base;
}
/* reset glyph loader, free all allocated tables, */
/* and start from zero */
FT_BASE_DEF( void )
FT_GlyphLoader_Reset( FT_GlyphLoader loader )
{
FT_Memory memory = loader->memory;
FT_FREE( loader->base.outline.points );
FT_FREE( loader->base.outline.tags );
FT_FREE( loader->base.outline.contours );
FT_FREE( loader->base.extra_points );
FT_FREE( loader->base.subglyphs );
loader->base.extra_points2 = NULL;
loader->max_points = 0;
loader->max_contours = 0;
loader->max_subglyphs = 0;
FT_GlyphLoader_Rewind( loader );
}
/* delete a glyph loader */
FT_BASE_DEF( void )
FT_GlyphLoader_Done( FT_GlyphLoader loader )
{
if ( loader )
{
FT_Memory memory = loader->memory;
FT_GlyphLoader_Reset( loader );
FT_FREE( loader );
}
}
/* re-adjust the `current' outline fields */
static void
FT_GlyphLoader_Adjust_Points( FT_GlyphLoader loader )
{
FT_Outline* base = &loader->base.outline;
FT_Outline* current = &loader->current.outline;
current->points = FT_OFFSET( base->points, base->n_points );
current->tags = FT_OFFSET( base->tags, base->n_points );
current->contours = FT_OFFSET( base->contours, base->n_contours );
/* handle extra points table - if any */
if ( loader->use_extra )
{
loader->current.extra_points = loader->base.extra_points +
base->n_points;
loader->current.extra_points2 = loader->base.extra_points2 +
base->n_points;
}
}
FT_BASE_DEF( FT_Error )
FT_GlyphLoader_CreateExtra( FT_GlyphLoader loader )
{
FT_Error error;
FT_Memory memory = loader->memory;
if ( loader->max_points == 0 ||
loader->base.extra_points != NULL )
return FT_Err_Ok;
if ( !FT_NEW_ARRAY( loader->base.extra_points, 2 * loader->max_points ) )
{
loader->use_extra = 1;
loader->base.extra_points2 = loader->base.extra_points +
loader->max_points;
FT_GlyphLoader_Adjust_Points( loader );
}
return error;
}
/* re-adjust the `current' subglyphs field */
static void
FT_GlyphLoader_Adjust_Subglyphs( FT_GlyphLoader loader )
{
FT_GlyphLoad base = &loader->base;
FT_GlyphLoad current = &loader->current;
current->subglyphs = FT_OFFSET( base->subglyphs, base->num_subglyphs );
}
/* Ensure that we can add `n_points' and `n_contours' to our glyph. */
/* This function reallocates its outline tables if necessary. Note that */
/* it DOESN'T change the number of points within the loader! */
/* */
FT_BASE_DEF( FT_Error )
FT_GlyphLoader_CheckPoints( FT_GlyphLoader loader,
FT_UInt n_points,
FT_UInt n_contours )
{
FT_Memory memory = loader->memory;
FT_Error error = FT_Err_Ok;
FT_Outline* base = &loader->base.outline;
FT_Outline* current = &loader->current.outline;
FT_Bool adjust = 0;
FT_UInt new_max, old_max;
error = FT_GlyphLoader_CreateExtra( loader );
if ( error )
return error;
/* check points & tags */
new_max = (FT_UInt)base->n_points + (FT_UInt)current->n_points +
n_points;
old_max = loader->max_points;
if ( new_max > old_max )
{
new_max = FT_PAD_CEIL( new_max, 8 );
if ( new_max > FT_OUTLINE_POINTS_MAX )
return FT_THROW( Array_Too_Large );
if ( FT_RENEW_ARRAY( base->points, old_max, new_max ) ||
FT_RENEW_ARRAY( base->tags, old_max, new_max ) )
goto Exit;
if ( loader->use_extra )
{
if ( FT_RENEW_ARRAY( loader->base.extra_points,
old_max * 2, new_max * 2 ) )
goto Exit;
FT_ARRAY_MOVE( loader->base.extra_points + new_max,
loader->base.extra_points + old_max,
old_max );
loader->base.extra_points2 = loader->base.extra_points + new_max;
}
adjust = 1;
loader->max_points = new_max;
}
error = FT_GlyphLoader_CreateExtra( loader );
if ( error )
return error;
/* check contours */
old_max = loader->max_contours;
new_max = (FT_UInt)base->n_contours + (FT_UInt)current->n_contours +
n_contours;
if ( new_max > old_max )
{
new_max = FT_PAD_CEIL( new_max, 4 );
if ( new_max > FT_OUTLINE_CONTOURS_MAX )
return FT_THROW( Array_Too_Large );
if ( FT_RENEW_ARRAY( base->contours, old_max, new_max ) )
goto Exit;
adjust = 1;
loader->max_contours = new_max;
}
if ( adjust )
FT_GlyphLoader_Adjust_Points( loader );
Exit:
if ( error )
FT_GlyphLoader_Reset( loader );
return error;
}
/* Ensure that we can add `n_subglyphs' to our glyph. this function */
/* reallocates its subglyphs table if necessary. Note that it DOES */
/* NOT change the number of subglyphs within the loader! */
/* */
FT_BASE_DEF( FT_Error )
FT_GlyphLoader_CheckSubGlyphs( FT_GlyphLoader loader,
FT_UInt n_subs )
{
FT_Memory memory = loader->memory;
FT_Error error = FT_Err_Ok;
FT_UInt new_max, old_max;
FT_GlyphLoad base = &loader->base;
FT_GlyphLoad current = &loader->current;
new_max = base->num_subglyphs + current->num_subglyphs + n_subs;
old_max = loader->max_subglyphs;
if ( new_max > old_max )
{
new_max = FT_PAD_CEIL( new_max, 2 );
if ( FT_RENEW_ARRAY( base->subglyphs, old_max, new_max ) )
goto Exit;
loader->max_subglyphs = new_max;
FT_GlyphLoader_Adjust_Subglyphs( loader );
}
Exit:
return error;
}
/* prepare loader for the addition of a new glyph on top of the base one */
FT_BASE_DEF( void )
FT_GlyphLoader_Prepare( FT_GlyphLoader loader )
{
FT_GlyphLoad current = &loader->current;
current->outline.n_points = 0;
current->outline.n_contours = 0;
current->num_subglyphs = 0;
FT_GlyphLoader_Adjust_Points ( loader );
FT_GlyphLoader_Adjust_Subglyphs( loader );
}
/* add current glyph to the base image -- and prepare for another */
FT_BASE_DEF( void )
FT_GlyphLoader_Add( FT_GlyphLoader loader )
{
FT_GlyphLoad base;
FT_GlyphLoad current;
FT_Int n_curr_contours;
FT_Int n_base_points;
FT_Int n;
if ( !loader )
return;
base = &loader->base;
current = &loader->current;
n_curr_contours = current->outline.n_contours;
n_base_points = base->outline.n_points;
base->outline.n_points =
(short)( base->outline.n_points + current->outline.n_points );
base->outline.n_contours =
(short)( base->outline.n_contours + current->outline.n_contours );
base->num_subglyphs += current->num_subglyphs;
/* adjust contours count in newest outline */
for ( n = 0; n < n_curr_contours; n++ )
current->outline.contours[n] =
(short)( current->outline.contours[n] + n_base_points );
/* prepare for another new glyph image */
FT_GlyphLoader_Prepare( loader );
}
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/base/ftgloadr.c
|
C++
|
gpl-3.0
| 10,942
|
/****************************************************************************
*
* ftglyph.c
*
* FreeType convenience functions to handle glyphs (body).
*
* Copyright (C) 1996-2022 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 file contains the definition of several convenience functions
* that can be used by client applications to easily retrieve glyph
* bitmaps and outlines from a given face.
*
* These functions should be optional if you are writing a font server
* or text layout engine on top of FreeType. However, they are pretty
* handy for many other simple uses of the library.
*
*/
#include <freetype/internal/ftdebug.h>
#include <freetype/ftglyph.h>
#include <freetype/ftoutln.h>
#include <freetype/ftbitmap.h>
#include <freetype/internal/ftobjs.h>
#include <freetype/otsvg.h>
#include "ftbase.h"
/**************************************************************************
*
* The macro FT_COMPONENT is used in trace mode. It is an implicit
* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
* messages during execution.
*/
#undef FT_COMPONENT
#define FT_COMPONENT glyph
/*************************************************************************/
/*************************************************************************/
/**** ****/
/**** FT_BitmapGlyph support ****/
/**** ****/
/*************************************************************************/
/*************************************************************************/
FT_CALLBACK_DEF( FT_Error )
ft_bitmap_glyph_init( FT_Glyph bitmap_glyph,
FT_GlyphSlot slot )
{
FT_BitmapGlyph glyph = (FT_BitmapGlyph)bitmap_glyph;
FT_Error error = FT_Err_Ok;
FT_Library library = FT_GLYPH( glyph )->library;
if ( slot->format != FT_GLYPH_FORMAT_BITMAP )
{
error = FT_THROW( Invalid_Glyph_Format );
goto Exit;
}
glyph->left = slot->bitmap_left;
glyph->top = slot->bitmap_top;
/* do lazy copying whenever possible */
if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP )
{
glyph->bitmap = slot->bitmap;
slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;
}
else
{
FT_Bitmap_Init( &glyph->bitmap );
error = FT_Bitmap_Copy( library, &slot->bitmap, &glyph->bitmap );
}
Exit:
return error;
}
FT_CALLBACK_DEF( FT_Error )
ft_bitmap_glyph_copy( FT_Glyph bitmap_source,
FT_Glyph bitmap_target )
{
FT_Library library = bitmap_source->library;
FT_BitmapGlyph source = (FT_BitmapGlyph)bitmap_source;
FT_BitmapGlyph target = (FT_BitmapGlyph)bitmap_target;
target->left = source->left;
target->top = source->top;
return FT_Bitmap_Copy( library, &source->bitmap, &target->bitmap );
}
FT_CALLBACK_DEF( void )
ft_bitmap_glyph_done( FT_Glyph bitmap_glyph )
{
FT_BitmapGlyph glyph = (FT_BitmapGlyph)bitmap_glyph;
FT_Library library = FT_GLYPH( glyph )->library;
FT_Bitmap_Done( library, &glyph->bitmap );
}
FT_CALLBACK_DEF( void )
ft_bitmap_glyph_bbox( FT_Glyph bitmap_glyph,
FT_BBox* cbox )
{
FT_BitmapGlyph glyph = (FT_BitmapGlyph)bitmap_glyph;
cbox->xMin = glyph->left * 64;
cbox->xMax = cbox->xMin + (FT_Pos)( glyph->bitmap.width * 64 );
cbox->yMax = glyph->top * 64;
cbox->yMin = cbox->yMax - (FT_Pos)( glyph->bitmap.rows * 64 );
}
FT_DEFINE_GLYPH(
ft_bitmap_glyph_class,
sizeof ( FT_BitmapGlyphRec ),
FT_GLYPH_FORMAT_BITMAP,
ft_bitmap_glyph_init, /* FT_Glyph_InitFunc glyph_init */
ft_bitmap_glyph_done, /* FT_Glyph_DoneFunc glyph_done */
ft_bitmap_glyph_copy, /* FT_Glyph_CopyFunc glyph_copy */
NULL, /* FT_Glyph_TransformFunc glyph_transform */
ft_bitmap_glyph_bbox, /* FT_Glyph_GetBBoxFunc glyph_bbox */
NULL /* FT_Glyph_PrepareFunc glyph_prepare */
)
/*************************************************************************/
/*************************************************************************/
/**** ****/
/**** FT_OutlineGlyph support ****/
/**** ****/
/*************************************************************************/
/*************************************************************************/
FT_CALLBACK_DEF( FT_Error )
ft_outline_glyph_init( FT_Glyph outline_glyph,
FT_GlyphSlot slot )
{
FT_OutlineGlyph glyph = (FT_OutlineGlyph)outline_glyph;
FT_Error error = FT_Err_Ok;
FT_Library library = FT_GLYPH( glyph )->library;
FT_Outline* source = &slot->outline;
FT_Outline* target = &glyph->outline;
/* check format in glyph slot */
if ( slot->format != FT_GLYPH_FORMAT_OUTLINE )
{
error = FT_THROW( Invalid_Glyph_Format );
goto Exit;
}
/* allocate new outline */
error = FT_Outline_New( library,
(FT_UInt)source->n_points,
source->n_contours,
&glyph->outline );
if ( error )
goto Exit;
FT_Outline_Copy( source, target );
Exit:
return error;
}
FT_CALLBACK_DEF( void )
ft_outline_glyph_done( FT_Glyph outline_glyph )
{
FT_OutlineGlyph glyph = (FT_OutlineGlyph)outline_glyph;
FT_Outline_Done( FT_GLYPH( glyph )->library, &glyph->outline );
}
FT_CALLBACK_DEF( FT_Error )
ft_outline_glyph_copy( FT_Glyph outline_source,
FT_Glyph outline_target )
{
FT_OutlineGlyph source = (FT_OutlineGlyph)outline_source;
FT_OutlineGlyph target = (FT_OutlineGlyph)outline_target;
FT_Error error;
FT_Library library = FT_GLYPH( source )->library;
error = FT_Outline_New( library,
(FT_UInt)source->outline.n_points,
source->outline.n_contours,
&target->outline );
if ( !error )
FT_Outline_Copy( &source->outline, &target->outline );
return error;
}
FT_CALLBACK_DEF( void )
ft_outline_glyph_transform( FT_Glyph outline_glyph,
const FT_Matrix* matrix,
const FT_Vector* delta )
{
FT_OutlineGlyph glyph = (FT_OutlineGlyph)outline_glyph;
if ( matrix )
FT_Outline_Transform( &glyph->outline, matrix );
if ( delta )
FT_Outline_Translate( &glyph->outline, delta->x, delta->y );
}
FT_CALLBACK_DEF( void )
ft_outline_glyph_bbox( FT_Glyph outline_glyph,
FT_BBox* bbox )
{
FT_OutlineGlyph glyph = (FT_OutlineGlyph)outline_glyph;
FT_Outline_Get_CBox( &glyph->outline, bbox );
}
FT_CALLBACK_DEF( FT_Error )
ft_outline_glyph_prepare( FT_Glyph outline_glyph,
FT_GlyphSlot slot )
{
FT_OutlineGlyph glyph = (FT_OutlineGlyph)outline_glyph;
slot->format = FT_GLYPH_FORMAT_OUTLINE;
slot->outline = glyph->outline;
slot->outline.flags &= ~FT_OUTLINE_OWNER;
return FT_Err_Ok;
}
FT_DEFINE_GLYPH(
ft_outline_glyph_class,
sizeof ( FT_OutlineGlyphRec ),
FT_GLYPH_FORMAT_OUTLINE,
ft_outline_glyph_init, /* FT_Glyph_InitFunc glyph_init */
ft_outline_glyph_done, /* FT_Glyph_DoneFunc glyph_done */
ft_outline_glyph_copy, /* FT_Glyph_CopyFunc glyph_copy */
ft_outline_glyph_transform, /* FT_Glyph_TransformFunc glyph_transform */
ft_outline_glyph_bbox, /* FT_Glyph_GetBBoxFunc glyph_bbox */
ft_outline_glyph_prepare /* FT_Glyph_PrepareFunc glyph_prepare */
)
#ifdef FT_CONFIG_OPTION_SVG
/*************************************************************************/
/*************************************************************************/
/**** ****/
/**** FT_SvgGlyph support ****/
/**** ****/
/*************************************************************************/
/*************************************************************************/
FT_CALLBACK_DEF( FT_Error )
ft_svg_glyph_init( FT_Glyph svg_glyph,
FT_GlyphSlot slot )
{
FT_ULong doc_length;
FT_SVG_Document document;
FT_SvgGlyph glyph = (FT_SvgGlyph)svg_glyph;
FT_Error error = FT_Err_Ok;
FT_Memory memory = FT_GLYPH( glyph )->library->memory;
if ( slot->format != FT_GLYPH_FORMAT_SVG )
{
error = FT_THROW( Invalid_Glyph_Format );
goto Exit;
}
if ( slot->other == NULL )
{
error = FT_THROW( Invalid_Slot_Handle );
goto Exit;
}
document = (FT_SVG_Document)slot->other;
if ( document->svg_document_length == 0 )
{
error = FT_THROW( Invalid_Slot_Handle );
goto Exit;
}
/* allocate a new document */
doc_length = document->svg_document_length;
if ( FT_QALLOC( glyph->svg_document, doc_length ) )
goto Exit;
glyph->svg_document_length = doc_length;
glyph->glyph_index = slot->glyph_index;
glyph->metrics = document->metrics;
glyph->units_per_EM = document->units_per_EM;
glyph->start_glyph_id = document->start_glyph_id;
glyph->end_glyph_id = document->end_glyph_id;
glyph->transform = document->transform;
glyph->delta = document->delta;
/* copy the document into glyph */
FT_MEM_COPY( glyph->svg_document, document->svg_document, doc_length );
Exit:
return error;
}
FT_CALLBACK_DEF( void )
ft_svg_glyph_done( FT_Glyph svg_glyph )
{
FT_SvgGlyph glyph = (FT_SvgGlyph)svg_glyph;
FT_Memory memory = svg_glyph->library->memory;
/* just free the memory */
FT_FREE( glyph->svg_document );
}
FT_CALLBACK_DEF( FT_Error )
ft_svg_glyph_copy( FT_Glyph svg_source,
FT_Glyph svg_target )
{
FT_SvgGlyph source = (FT_SvgGlyph)svg_source;
FT_SvgGlyph target = (FT_SvgGlyph)svg_target;
FT_Error error = FT_Err_Ok;
FT_Memory memory = FT_GLYPH( source )->library->memory;
if ( svg_source->format != FT_GLYPH_FORMAT_SVG )
{
error = FT_THROW( Invalid_Glyph_Format );
goto Exit;
}
if ( source->svg_document_length == 0 )
{
error = FT_THROW( Invalid_Slot_Handle );
goto Exit;
}
target->glyph_index = source->glyph_index;
target->svg_document_length = source->svg_document_length;
target->metrics = source->metrics;
target->units_per_EM = source->units_per_EM;
target->start_glyph_id = source->start_glyph_id;
target->end_glyph_id = source->end_glyph_id;
target->transform = source->transform;
target->delta = source->delta;
/* allocate space for the SVG document */
if ( FT_QALLOC( target->svg_document, target->svg_document_length ) )
goto Exit;
/* copy the document */
FT_MEM_COPY( target->svg_document,
source->svg_document,
target->svg_document_length );
Exit:
return error;
}
FT_CALLBACK_DEF( void )
ft_svg_glyph_transform( FT_Glyph svg_glyph,
const FT_Matrix* _matrix,
const FT_Vector* _delta )
{
FT_SvgGlyph glyph = (FT_SvgGlyph)svg_glyph;
FT_Matrix* matrix = (FT_Matrix*)_matrix;
FT_Vector* delta = (FT_Vector*)_delta;
FT_Matrix tmp_matrix;
FT_Vector tmp_delta;
FT_Matrix a, b;
FT_Pos x, y;
if ( !matrix )
{
tmp_matrix.xx = 0x10000;
tmp_matrix.xy = 0;
tmp_matrix.yx = 0;
tmp_matrix.yy = 0x10000;
matrix = &tmp_matrix;
}
if ( !delta )
{
tmp_delta.x = 0;
tmp_delta.y = 0;
delta = &tmp_delta;
}
a = glyph->transform;
b = *matrix;
FT_Matrix_Multiply( &b, &a );
x = ADD_LONG( ADD_LONG( FT_MulFix( matrix->xx, glyph->delta.x ),
FT_MulFix( matrix->xy, glyph->delta.y ) ),
delta->x );
y = ADD_LONG( ADD_LONG( FT_MulFix( matrix->yx, glyph->delta.x ),
FT_MulFix( matrix->yy, glyph->delta.y ) ),
delta->y );
glyph->delta.x = x;
glyph->delta.y = y;
glyph->transform = a;
}
FT_CALLBACK_DEF( FT_Error )
ft_svg_glyph_prepare( FT_Glyph svg_glyph,
FT_GlyphSlot slot )
{
FT_SvgGlyph glyph = (FT_SvgGlyph)svg_glyph;
FT_Error error = FT_Err_Ok;
FT_Memory memory = svg_glyph->library->memory;
FT_SVG_Document document = NULL;
if ( FT_NEW( document ) )
return error;
document->svg_document = glyph->svg_document;
document->svg_document_length = glyph->svg_document_length;
document->metrics = glyph->metrics;
document->units_per_EM = glyph->units_per_EM;
document->start_glyph_id = glyph->start_glyph_id;
document->end_glyph_id = glyph->end_glyph_id;
document->transform = glyph->transform;
document->delta = glyph->delta;
slot->format = FT_GLYPH_FORMAT_SVG;
slot->glyph_index = glyph->glyph_index;
slot->other = document;
return error;
}
FT_DEFINE_GLYPH(
ft_svg_glyph_class,
sizeof ( FT_SvgGlyphRec ),
FT_GLYPH_FORMAT_SVG,
ft_svg_glyph_init, /* FT_Glyph_InitFunc glyph_init */
ft_svg_glyph_done, /* FT_Glyph_DoneFunc glyph_done */
ft_svg_glyph_copy, /* FT_Glyph_CopyFunc glyph_copy */
ft_svg_glyph_transform, /* FT_Glyph_TransformFunc glyph_transform */
NULL, /* FT_Glyph_GetBBoxFunc glyph_bbox */
ft_svg_glyph_prepare /* FT_Glyph_PrepareFunc glyph_prepare */
)
#endif /* FT_CONFIG_OPTION_SVG */
/*************************************************************************/
/*************************************************************************/
/**** ****/
/**** FT_Glyph class and API ****/
/**** ****/
/*************************************************************************/
/*************************************************************************/
static FT_Error
ft_new_glyph( FT_Library library,
const FT_Glyph_Class* clazz,
FT_Glyph* aglyph )
{
FT_Memory memory = library->memory;
FT_Error error;
FT_Glyph glyph = NULL;
*aglyph = NULL;
if ( !FT_ALLOC( glyph, clazz->glyph_size ) )
{
glyph->library = library;
glyph->clazz = clazz;
glyph->format = clazz->glyph_format;
*aglyph = glyph;
}
return error;
}
/* documentation is in ftglyph.h */
FT_EXPORT_DEF( FT_Error )
FT_Glyph_Copy( FT_Glyph source,
FT_Glyph *target )
{
FT_Glyph copy;
FT_Error error;
const FT_Glyph_Class* clazz;
/* check arguments */
if ( !target || !source || !source->clazz )
{
error = FT_THROW( Invalid_Argument );
goto Exit;
}
*target = NULL;
if ( !source || !source->clazz )
{
error = FT_THROW( Invalid_Argument );
goto Exit;
}
clazz = source->clazz;
error = ft_new_glyph( source->library, clazz, © );
if ( error )
goto Exit;
copy->advance = source->advance;
copy->format = source->format;
if ( clazz->glyph_copy )
error = clazz->glyph_copy( source, copy );
if ( error )
FT_Done_Glyph( copy );
else
*target = copy;
Exit:
return error;
}
/* documentation is in ftglyph.h */
FT_EXPORT( FT_Error )
FT_New_Glyph( FT_Library library,
FT_Glyph_Format format,
FT_Glyph *aglyph )
{
const FT_Glyph_Class* clazz = NULL;
if ( !library || !aglyph )
return FT_THROW( Invalid_Argument );
/* if it is a bitmap, that's easy :-) */
if ( format == FT_GLYPH_FORMAT_BITMAP )
clazz = &ft_bitmap_glyph_class;
/* if it is an outline */
else if ( format == FT_GLYPH_FORMAT_OUTLINE )
clazz = &ft_outline_glyph_class;
#ifdef FT_CONFIG_OPTION_SVG
/* if it is an SVG glyph */
else if ( format == FT_GLYPH_FORMAT_SVG )
clazz = &ft_svg_glyph_class;
#endif
else
{
/* try to find a renderer that supports the glyph image format */
FT_Renderer render = FT_Lookup_Renderer( library, format, 0 );
if ( render )
clazz = &render->glyph_class;
}
if ( !clazz )
return FT_THROW( Invalid_Glyph_Format );
/* create FT_Glyph object */
return ft_new_glyph( library, clazz, aglyph );
}
/* documentation is in ftglyph.h */
FT_EXPORT_DEF( FT_Error )
FT_Get_Glyph( FT_GlyphSlot slot,
FT_Glyph *aglyph )
{
FT_Error error;
FT_Glyph glyph;
if ( !slot )
return FT_THROW( Invalid_Slot_Handle );
if ( !aglyph )
return FT_THROW( Invalid_Argument );
/* create FT_Glyph object */
error = FT_New_Glyph( slot->library, slot->format, &glyph );
if ( error )
goto Exit;
/* copy advance while converting 26.6 to 16.16 format */
if ( slot->advance.x >= 0x8000L * 64 ||
slot->advance.x <= -0x8000L * 64 )
{
FT_ERROR(( "FT_Get_Glyph: advance width too large\n" ));
error = FT_THROW( Invalid_Argument );
goto Exit2;
}
if ( slot->advance.y >= 0x8000L * 64 ||
slot->advance.y <= -0x8000L * 64 )
{
FT_ERROR(( "FT_Get_Glyph: advance height too large\n" ));
error = FT_THROW( Invalid_Argument );
goto Exit2;
}
glyph->advance.x = slot->advance.x * 1024;
glyph->advance.y = slot->advance.y * 1024;
/* now import the image from the glyph slot */
error = glyph->clazz->glyph_init( glyph, slot );
Exit2:
/* if an error occurred, destroy the glyph */
if ( error )
FT_Done_Glyph( glyph );
else
*aglyph = glyph;
Exit:
return error;
}
/* documentation is in ftglyph.h */
FT_EXPORT_DEF( FT_Error )
FT_Glyph_Transform( FT_Glyph glyph,
const FT_Matrix* matrix,
const FT_Vector* delta )
{
FT_Error error = FT_Err_Ok;
if ( !glyph || !glyph->clazz )
error = FT_THROW( Invalid_Argument );
else
{
const FT_Glyph_Class* clazz = glyph->clazz;
if ( clazz->glyph_transform )
{
/* transform glyph image */
clazz->glyph_transform( glyph, matrix, delta );
/* transform advance vector */
if ( matrix )
FT_Vector_Transform( &glyph->advance, matrix );
}
else
error = FT_THROW( Invalid_Glyph_Format );
}
return error;
}
/* documentation is in ftglyph.h */
FT_EXPORT_DEF( void )
FT_Glyph_Get_CBox( FT_Glyph glyph,
FT_UInt bbox_mode,
FT_BBox *acbox )
{
const FT_Glyph_Class* clazz;
if ( !acbox )
return;
acbox->xMin = acbox->yMin = acbox->xMax = acbox->yMax = 0;
if ( !glyph || !glyph->clazz )
return;
clazz = glyph->clazz;
if ( !clazz->glyph_bbox )
return;
/* retrieve bbox in 26.6 coordinates */
clazz->glyph_bbox( glyph, acbox );
/* perform grid fitting if needed */
if ( bbox_mode == FT_GLYPH_BBOX_GRIDFIT ||
bbox_mode == FT_GLYPH_BBOX_PIXELS )
{
acbox->xMin = FT_PIX_FLOOR( acbox->xMin );
acbox->yMin = FT_PIX_FLOOR( acbox->yMin );
acbox->xMax = FT_PIX_CEIL_LONG( acbox->xMax );
acbox->yMax = FT_PIX_CEIL_LONG( acbox->yMax );
}
/* convert to integer pixels if needed */
if ( bbox_mode == FT_GLYPH_BBOX_TRUNCATE ||
bbox_mode == FT_GLYPH_BBOX_PIXELS )
{
acbox->xMin >>= 6;
acbox->yMin >>= 6;
acbox->xMax >>= 6;
acbox->yMax >>= 6;
}
}
/* documentation is in ftglyph.h */
FT_EXPORT_DEF( FT_Error )
FT_Glyph_To_Bitmap( FT_Glyph* the_glyph,
FT_Render_Mode render_mode,
const FT_Vector* origin,
FT_Bool destroy )
{
FT_GlyphSlotRec dummy;
FT_GlyphSlot_InternalRec dummy_internal;
FT_Error error = FT_Err_Ok;
FT_Glyph b, glyph;
FT_BitmapGlyph bitmap = NULL;
const FT_Glyph_Class* clazz;
FT_Library library;
/* check argument */
if ( !the_glyph )
goto Bad;
glyph = *the_glyph;
if ( !glyph )
goto Bad;
clazz = glyph->clazz;
library = glyph->library;
if ( !library || !clazz )
goto Bad;
/* when called with a bitmap glyph, do nothing and return successfully */
if ( clazz == &ft_bitmap_glyph_class )
goto Exit;
if ( !clazz->glyph_prepare )
goto Bad;
/* we render the glyph into a glyph bitmap using a `dummy' glyph slot */
/* then calling FT_Render_Glyph_Internal() */
FT_ZERO( &dummy );
FT_ZERO( &dummy_internal );
dummy.internal = &dummy_internal;
dummy.library = library;
dummy.format = clazz->glyph_format;
/* create result bitmap glyph */
error = ft_new_glyph( library, &ft_bitmap_glyph_class, &b );
if ( error )
goto Exit;
bitmap = (FT_BitmapGlyph)b;
#if 1
/* if `origin' is set, translate the glyph image */
if ( origin )
FT_Glyph_Transform( glyph, NULL, origin );
#else
FT_UNUSED( origin );
#endif
/* prepare dummy slot for rendering */
error = clazz->glyph_prepare( glyph, &dummy );
if ( !error )
error = FT_Render_Glyph_Internal( glyph->library, &dummy, render_mode );
#ifdef FT_CONFIG_OPTION_SVG
if ( clazz == &ft_svg_glyph_class )
{
FT_Memory memory = library->memory;
FT_FREE( dummy.other );
}
#endif
#if 1
if ( !destroy && origin )
{
FT_Vector v;
v.x = -origin->x;
v.y = -origin->y;
FT_Glyph_Transform( glyph, NULL, &v );
}
#endif
if ( error )
goto Exit;
/* in case of success, copy the bitmap to the glyph bitmap */
error = ft_bitmap_glyph_init( (FT_Glyph)bitmap, &dummy );
if ( error )
goto Exit;
/* copy advance */
bitmap->root.advance = glyph->advance;
if ( destroy )
FT_Done_Glyph( glyph );
*the_glyph = FT_GLYPH( bitmap );
Exit:
if ( error && bitmap )
FT_Done_Glyph( FT_GLYPH( bitmap ) );
return error;
Bad:
error = FT_THROW( Invalid_Argument );
goto Exit;
}
/* documentation is in ftglyph.h */
FT_EXPORT_DEF( void )
FT_Done_Glyph( FT_Glyph glyph )
{
if ( glyph )
{
FT_Memory memory = glyph->library->memory;
const FT_Glyph_Class* clazz = glyph->clazz;
if ( clazz->glyph_done )
clazz->glyph_done( glyph );
FT_FREE( glyph );
}
}
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/base/ftglyph.c
|
C++
|
gpl-3.0
| 24,186
|
/****************************************************************************
*
* ftgxval.c
*
* FreeType API for validating TrueTypeGX/AAT tables (body).
*
* Copyright (C) 2004-2022 by
* Masatake YAMATO, Redhat K.K,
* 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.
*
*/
/****************************************************************************
*
* gxvalid is derived from both gxlayout module and otvalid module.
* Development of gxlayout is supported by the Information-technology
* Promotion Agency(IPA), Japan.
*
*/
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/ftobjs.h>
#include <freetype/internal/services/svgxval.h>
/* documentation is in ftgxval.h */
FT_EXPORT_DEF( FT_Error )
FT_TrueTypeGX_Validate( FT_Face face,
FT_UInt validation_flags,
FT_Bytes tables[FT_VALIDATE_GX_LENGTH],
FT_UInt table_length )
{
FT_Service_GXvalidate service;
FT_Error error;
if ( !face )
{
error = FT_THROW( Invalid_Face_Handle );
goto Exit;
}
if ( !tables )
{
error = FT_THROW( Invalid_Argument );
goto Exit;
}
FT_FACE_FIND_GLOBAL_SERVICE( face, service, GX_VALIDATE );
if ( service )
error = service->validate( face,
validation_flags,
tables,
table_length );
else
error = FT_THROW( Unimplemented_Feature );
Exit:
return error;
}
FT_EXPORT_DEF( void )
FT_TrueTypeGX_Free( FT_Face face,
FT_Bytes table )
{
FT_Memory memory;
if ( !face )
return;
memory = FT_FACE_MEMORY( face );
FT_FREE( table );
}
FT_EXPORT_DEF( FT_Error )
FT_ClassicKern_Validate( FT_Face face,
FT_UInt validation_flags,
FT_Bytes *ckern_table )
{
FT_Service_CKERNvalidate service;
FT_Error error;
if ( !face )
{
error = FT_THROW( Invalid_Face_Handle );
goto Exit;
}
if ( !ckern_table )
{
error = FT_THROW( Invalid_Argument );
goto Exit;
}
FT_FACE_FIND_GLOBAL_SERVICE( face, service, CLASSICKERN_VALIDATE );
if ( service )
error = service->validate( face,
validation_flags,
ckern_table );
else
error = FT_THROW( Unimplemented_Feature );
Exit:
return error;
}
FT_EXPORT_DEF( void )
FT_ClassicKern_Free( FT_Face face,
FT_Bytes table )
{
FT_Memory memory;
if ( !face )
return;
memory = FT_FACE_MEMORY( face );
FT_FREE( table );
}
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/base/ftgxval.c
|
C++
|
gpl-3.0
| 3,125
|
/****************************************************************************
*
* fthash.c
*
* Hashing functions (body).
*
*/
/*
* Copyright 2000 Computing Research Labs, New Mexico State University
* Copyright 2001-2015
* Francesco Zappa Nardelli
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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 AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COMPUTING RESEARCH LAB OR NEW MEXICO STATE UNIVERSITY BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
* OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**************************************************************************
*
* This file is based on code from bdf.c,v 1.22 2000/03/16 20:08:50
*
* taken from Mark Leisher's xmbdfed package
*
*/
#include <freetype/internal/fthash.h>
#include <freetype/internal/ftmemory.h>
#define INITIAL_HT_SIZE 241
static FT_ULong
hash_str_lookup( FT_Hashkey* key )
{
const char* kp = key->str;
FT_ULong res = 0;
/* Mocklisp hash function. */
while ( *kp )
res = ( res << 5 ) - res + (FT_ULong)*kp++;
return res;
}
static FT_ULong
hash_num_lookup( FT_Hashkey* key )
{
FT_ULong num = (FT_ULong)key->num;
FT_ULong res;
/* Mocklisp hash function. */
res = num & 0xFF;
res = ( res << 5 ) - res + ( ( num >> 8 ) & 0xFF );
res = ( res << 5 ) - res + ( ( num >> 16 ) & 0xFF );
res = ( res << 5 ) - res + ( ( num >> 24 ) & 0xFF );
return res;
}
static FT_Bool
hash_str_compare( FT_Hashkey* a,
FT_Hashkey* b )
{
if ( a->str[0] == b->str[0] &&
ft_strcmp( a->str, b->str ) == 0 )
return 1;
return 0;
}
static FT_Bool
hash_num_compare( FT_Hashkey* a,
FT_Hashkey* b )
{
if ( a->num == b->num )
return 1;
return 0;
}
static FT_Hashnode*
hash_bucket( FT_Hashkey key,
FT_Hash hash )
{
FT_ULong res = 0;
FT_Hashnode* bp = hash->table;
FT_Hashnode* ndp;
res = (hash->lookup)( &key );
ndp = bp + ( res % hash->size );
while ( *ndp )
{
if ( (hash->compare)( &(*ndp)->key, &key ) )
break;
ndp--;
if ( ndp < bp )
ndp = bp + ( hash->size - 1 );
}
return ndp;
}
static FT_Error
hash_rehash( FT_Hash hash,
FT_Memory memory )
{
FT_Hashnode* obp = hash->table;
FT_Hashnode* bp;
FT_Hashnode* nbp;
FT_UInt i, sz = hash->size;
FT_Error error = FT_Err_Ok;
hash->size <<= 1;
hash->limit = hash->size / 3;
if ( FT_NEW_ARRAY( hash->table, hash->size ) )
goto Exit;
for ( i = 0, bp = obp; i < sz; i++, bp++ )
{
if ( *bp )
{
nbp = hash_bucket( (*bp)->key, hash );
*nbp = *bp;
}
}
FT_FREE( obp );
Exit:
return error;
}
static FT_Error
hash_init( FT_Hash hash,
FT_Bool is_num,
FT_Memory memory )
{
FT_UInt sz = INITIAL_HT_SIZE;
FT_Error error;
hash->size = sz;
hash->limit = sz / 3;
hash->used = 0;
if ( is_num )
{
hash->lookup = hash_num_lookup;
hash->compare = hash_num_compare;
}
else
{
hash->lookup = hash_str_lookup;
hash->compare = hash_str_compare;
}
FT_MEM_NEW_ARRAY( hash->table, sz );
return error;
}
FT_Error
ft_hash_str_init( FT_Hash hash,
FT_Memory memory )
{
return hash_init( hash, 0, memory );
}
FT_Error
ft_hash_num_init( FT_Hash hash,
FT_Memory memory )
{
return hash_init( hash, 1, memory );
}
void
ft_hash_str_free( FT_Hash hash,
FT_Memory memory )
{
if ( hash )
{
FT_UInt sz = hash->size;
FT_Hashnode* bp = hash->table;
FT_UInt i;
for ( i = 0; i < sz; i++, bp++ )
FT_FREE( *bp );
FT_FREE( hash->table );
}
}
/* `ft_hash_num_free' is the same as `ft_hash_str_free' */
static FT_Error
hash_insert( FT_Hashkey key,
size_t data,
FT_Hash hash,
FT_Memory memory )
{
FT_Hashnode nn;
FT_Hashnode* bp = hash_bucket( key, hash );
FT_Error error = FT_Err_Ok;
nn = *bp;
if ( !nn )
{
if ( FT_QNEW( nn ) )
goto Exit;
*bp = nn;
nn->key = key;
nn->data = data;
if ( hash->used >= hash->limit )
{
error = hash_rehash( hash, memory );
if ( error )
goto Exit;
}
hash->used++;
}
else
nn->data = data;
Exit:
return error;
}
FT_Error
ft_hash_str_insert( const char* key,
size_t data,
FT_Hash hash,
FT_Memory memory )
{
FT_Hashkey hk;
hk.str = key;
return hash_insert( hk, data, hash, memory );
}
FT_Error
ft_hash_num_insert( FT_Int num,
size_t data,
FT_Hash hash,
FT_Memory memory )
{
FT_Hashkey hk;
hk.num = num;
return hash_insert( hk, data, hash, memory );
}
static size_t*
hash_lookup( FT_Hashkey key,
FT_Hash hash )
{
FT_Hashnode* np = hash_bucket( key, hash );
return (*np) ? &(*np)->data
: NULL;
}
size_t*
ft_hash_str_lookup( const char* key,
FT_Hash hash )
{
FT_Hashkey hk;
hk.str = key;
return hash_lookup( hk, hash );
}
size_t*
ft_hash_num_lookup( FT_Int num,
FT_Hash hash )
{
FT_Hashkey hk;
hk.num = num;
return hash_lookup( hk, hash );
}
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/base/fthash.c
|
C++
|
gpl-3.0
| 6,657
|
/****************************************************************************
*
* ftinit.c
*
* FreeType initialization layer (body).
*
* Copyright (C) 1996-2022 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.
*
*/
/**************************************************************************
*
* The purpose of this file is to implement the following two
* functions:
*
* FT_Add_Default_Modules():
* This function is used to add the set of default modules to a
* fresh new library object. The set is taken from the header file
* `freetype/config/ftmodule.h'. See the document `FreeType 2.0
* Build System' for more information.
*
* FT_Init_FreeType():
* This function creates a system object for the current platform,
* builds a library out of it, then calls FT_Default_Drivers().
*
* Note that even if FT_Init_FreeType() uses the implementation of the
* system object defined at build time, client applications are still
* able to provide their own `ftsystem.c'.
*
*/
#include <ft2build.h>
#include FT_CONFIG_CONFIG_H
#include <freetype/internal/ftobjs.h>
#include <freetype/internal/ftdebug.h>
#include <freetype/ftmodapi.h>
/**************************************************************************
*
* The macro FT_COMPONENT is used in trace mode. It is an implicit
* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
* messages during execution.
*/
#undef FT_COMPONENT
#define FT_COMPONENT init
#undef FT_USE_MODULE
#ifdef __cplusplus
#define FT_USE_MODULE( type, x ) extern "C" const type x;
#else
#define FT_USE_MODULE( type, x ) extern const type x;
#endif
#include FT_CONFIG_MODULES_H
#undef FT_USE_MODULE
#define FT_USE_MODULE( type, x ) (const FT_Module_Class*)&(x),
static
const FT_Module_Class* const ft_default_modules[] =
{
#include FT_CONFIG_MODULES_H
0
};
/* documentation is in ftmodapi.h */
FT_EXPORT_DEF( void )
FT_Add_Default_Modules( FT_Library library )
{
FT_Error error;
const FT_Module_Class* const* cur;
/* GCC 4.6 warns the type difference:
* FT_Module_Class** != const FT_Module_Class* const*
*/
cur = (const FT_Module_Class* const*)ft_default_modules;
/* test for valid `library' delayed to FT_Add_Module() */
while ( *cur )
{
error = FT_Add_Module( library, *cur );
/* notify errors, but don't stop */
if ( error )
FT_TRACE0(( "FT_Add_Default_Module:"
" Cannot install `%s', error = 0x%x\n",
(*cur)->module_name, error ));
cur++;
}
}
#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
#define MAX_LENGTH 128
/* documentation is in ftmodapi.h */
FT_EXPORT_DEF( void )
FT_Set_Default_Properties( FT_Library library )
{
const char* env;
const char* p;
const char* q;
char module_name[MAX_LENGTH + 1];
char property_name[MAX_LENGTH + 1];
char property_value[MAX_LENGTH + 1];
int i;
env = ft_getenv( "FREETYPE_PROPERTIES" );
if ( !env )
return;
for ( p = env; *p; p++ )
{
/* skip leading whitespace and separators */
if ( *p == ' ' || *p == '\t' )
continue;
/* read module name, followed by `:' */
q = p;
for ( i = 0; i < MAX_LENGTH; i++ )
{
if ( !*p || *p == ':' )
break;
module_name[i] = *p++;
}
module_name[i] = '\0';
if ( !*p || *p != ':' || p == q )
break;
/* read property name, followed by `=' */
q = ++p;
for ( i = 0; i < MAX_LENGTH; i++ )
{
if ( !*p || *p == '=' )
break;
property_name[i] = *p++;
}
property_name[i] = '\0';
if ( !*p || *p != '=' || p == q )
break;
/* read property value, followed by whitespace (if any) */
q = ++p;
for ( i = 0; i < MAX_LENGTH; i++ )
{
if ( !*p || *p == ' ' || *p == '\t' )
break;
property_value[i] = *p++;
}
property_value[i] = '\0';
if ( !( *p == '\0' || *p == ' ' || *p == '\t' ) || p == q )
break;
/* we completely ignore errors */
ft_property_string_set( library,
module_name,
property_name,
property_value );
if ( !*p )
break;
}
}
#else
FT_EXPORT_DEF( void )
FT_Set_Default_Properties( FT_Library library )
{
FT_UNUSED( library );
}
#endif
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Error )
FT_Init_FreeType( FT_Library *alibrary )
{
FT_Error error;
FT_Memory memory;
#ifdef FT_DEBUG_LOGGING
ft_logging_init();
#endif
/* check of `alibrary' delayed to `FT_New_Library' */
/* First of all, allocate a new system object -- this function is part */
/* of the system-specific component, i.e. `ftsystem.c'. */
memory = FT_New_Memory();
if ( !memory )
{
FT_ERROR(( "FT_Init_FreeType: cannot find memory manager\n" ));
return FT_THROW( Unimplemented_Feature );
}
/* build a library out of it, then fill it with the set of */
/* default drivers. */
error = FT_New_Library( memory, alibrary );
if ( error )
FT_Done_Memory( memory );
else
FT_Add_Default_Modules( *alibrary );
FT_Set_Default_Properties( *alibrary );
return error;
}
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Error )
FT_Done_FreeType( FT_Library library )
{
FT_Memory memory;
if ( !library )
return FT_THROW( Invalid_Library_Handle );
memory = library->memory;
/* Discard the library object */
FT_Done_Library( library );
/* discard memory manager */
FT_Done_Memory( memory );
#ifdef FT_DEBUG_LOGGING
ft_logging_deinit();
#endif
return FT_Err_Ok;
}
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/base/ftinit.c
|
C++
|
gpl-3.0
| 6,339
|
/****************************************************************************
*
* ftlcdfil.c
*
* FreeType API for color filtering of subpixel bitmap glyphs (body).
*
* Copyright (C) 2006-2022 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.
*
*/
#include <freetype/internal/ftdebug.h>
#include <freetype/ftlcdfil.h>
#include <freetype/ftimage.h>
#include <freetype/internal/ftobjs.h>
#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
/* define USE_LEGACY to implement the legacy filter */
#define USE_LEGACY
#define FT_SHIFTCLAMP( x ) ( x >>= 8, (FT_Byte)( x > 255 ? 255 : x ) )
/* add padding according to filter weights */
FT_BASE_DEF( void )
ft_lcd_padding( FT_BBox* cbox,
FT_GlyphSlot slot,
FT_Render_Mode mode )
{
FT_Byte* lcd_weights;
FT_Bitmap_LcdFilterFunc lcd_filter_func;
/* Per-face LCD filtering takes priority if set up. */
if ( slot->face && slot->face->internal->lcd_filter_func )
{
lcd_weights = slot->face->internal->lcd_weights;
lcd_filter_func = slot->face->internal->lcd_filter_func;
}
else
{
lcd_weights = slot->library->lcd_weights;
lcd_filter_func = slot->library->lcd_filter_func;
}
if ( lcd_filter_func == ft_lcd_filter_fir )
{
if ( mode == FT_RENDER_MODE_LCD )
{
cbox->xMin -= lcd_weights[0] ? 43 :
lcd_weights[1] ? 22 : 0;
cbox->xMax += lcd_weights[4] ? 43 :
lcd_weights[3] ? 22 : 0;
}
else if ( mode == FT_RENDER_MODE_LCD_V )
{
cbox->yMin -= lcd_weights[0] ? 43 :
lcd_weights[1] ? 22 : 0;
cbox->yMax += lcd_weights[4] ? 43 :
lcd_weights[3] ? 22 : 0;
}
}
}
/* FIR filter used by the default and light filters */
FT_BASE_DEF( void )
ft_lcd_filter_fir( FT_Bitmap* bitmap,
FT_LcdFiveTapFilter weights )
{
FT_UInt width = (FT_UInt)bitmap->width;
FT_UInt height = (FT_UInt)bitmap->rows;
FT_Int pitch = bitmap->pitch;
FT_Byte* origin = bitmap->buffer;
FT_Byte mode = bitmap->pixel_mode;
/* take care of bitmap flow */
if ( pitch > 0 && height > 0 )
origin += pitch * (FT_Int)( height - 1 );
/* horizontal in-place FIR filter */
if ( mode == FT_PIXEL_MODE_LCD && width >= 2 )
{
FT_Byte* line = origin;
/* `fir' must be at least 32 bit wide, since the sum of */
/* the values in `weights' can exceed 0xFF */
for ( ; height > 0; height--, line -= pitch )
{
FT_UInt fir[5];
FT_UInt val, xx;
val = line[0];
fir[2] = weights[2] * val;
fir[3] = weights[3] * val;
fir[4] = weights[4] * val;
val = line[1];
fir[1] = fir[2] + weights[1] * val;
fir[2] = fir[3] + weights[2] * val;
fir[3] = fir[4] + weights[3] * val;
fir[4] = weights[4] * val;
for ( xx = 2; xx < width; xx++ )
{
val = line[xx];
fir[0] = fir[1] + weights[0] * val;
fir[1] = fir[2] + weights[1] * val;
fir[2] = fir[3] + weights[2] * val;
fir[3] = fir[4] + weights[3] * val;
fir[4] = weights[4] * val;
line[xx - 2] = FT_SHIFTCLAMP( fir[0] );
}
line[xx - 2] = FT_SHIFTCLAMP( fir[1] );
line[xx - 1] = FT_SHIFTCLAMP( fir[2] );
}
}
/* vertical in-place FIR filter */
else if ( mode == FT_PIXEL_MODE_LCD_V && height >= 2 )
{
FT_Byte* column = origin;
for ( ; width > 0; width--, column++ )
{
FT_Byte* col = column;
FT_UInt fir[5];
FT_UInt val, yy;
val = col[0];
fir[2] = weights[2] * val;
fir[3] = weights[3] * val;
fir[4] = weights[4] * val;
col -= pitch;
val = col[0];
fir[1] = fir[2] + weights[1] * val;
fir[2] = fir[3] + weights[2] * val;
fir[3] = fir[4] + weights[3] * val;
fir[4] = weights[4] * val;
col -= pitch;
for ( yy = 2; yy < height; yy++, col -= pitch )
{
val = col[0];
fir[0] = fir[1] + weights[0] * val;
fir[1] = fir[2] + weights[1] * val;
fir[2] = fir[3] + weights[2] * val;
fir[3] = fir[4] + weights[3] * val;
fir[4] = weights[4] * val;
col[pitch * 2] = FT_SHIFTCLAMP( fir[0] );
}
col[pitch * 2] = FT_SHIFTCLAMP( fir[1] );
col[pitch] = FT_SHIFTCLAMP( fir[2] );
}
}
}
#ifdef USE_LEGACY
/* intra-pixel filter used by the legacy filter */
static void
_ft_lcd_filter_legacy( FT_Bitmap* bitmap,
FT_Byte* weights )
{
FT_UInt width = (FT_UInt)bitmap->width;
FT_UInt height = (FT_UInt)bitmap->rows;
FT_Int pitch = bitmap->pitch;
FT_Byte* origin = bitmap->buffer;
FT_Byte mode = bitmap->pixel_mode;
static const unsigned int filters[3][3] =
{
{ 65538 * 9/13, 65538 * 1/6, 65538 * 1/13 },
{ 65538 * 3/13, 65538 * 4/6, 65538 * 3/13 },
{ 65538 * 1/13, 65538 * 1/6, 65538 * 9/13 }
};
FT_UNUSED( weights );
/* take care of bitmap flow */
if ( pitch > 0 && height > 0 )
origin += pitch * (FT_Int)( height - 1 );
/* horizontal in-place intra-pixel filter */
if ( mode == FT_PIXEL_MODE_LCD && width >= 3 )
{
FT_Byte* line = origin;
for ( ; height > 0; height--, line -= pitch )
{
FT_UInt xx;
for ( xx = 0; xx < width; xx += 3 )
{
FT_UInt r, g, b;
FT_UInt p;
p = line[xx];
r = filters[0][0] * p;
g = filters[0][1] * p;
b = filters[0][2] * p;
p = line[xx + 1];
r += filters[1][0] * p;
g += filters[1][1] * p;
b += filters[1][2] * p;
p = line[xx + 2];
r += filters[2][0] * p;
g += filters[2][1] * p;
b += filters[2][2] * p;
line[xx] = (FT_Byte)( r / 65536 );
line[xx + 1] = (FT_Byte)( g / 65536 );
line[xx + 2] = (FT_Byte)( b / 65536 );
}
}
}
else if ( mode == FT_PIXEL_MODE_LCD_V && height >= 3 )
{
FT_Byte* column = origin;
for ( ; width > 0; width--, column++ )
{
FT_Byte* col = column - 2 * pitch;
for ( ; height > 0; height -= 3, col -= 3 * pitch )
{
FT_UInt r, g, b;
FT_UInt p;
p = col[0];
r = filters[0][0] * p;
g = filters[0][1] * p;
b = filters[0][2] * p;
p = col[pitch];
r += filters[1][0] * p;
g += filters[1][1] * p;
b += filters[1][2] * p;
p = col[pitch * 2];
r += filters[2][0] * p;
g += filters[2][1] * p;
b += filters[2][2] * p;
col[0] = (FT_Byte)( r / 65536 );
col[pitch] = (FT_Byte)( g / 65536 );
col[pitch * 2] = (FT_Byte)( b / 65536 );
}
}
}
}
#endif /* USE_LEGACY */
/* documentation in ftlcdfil.h */
FT_EXPORT_DEF( FT_Error )
FT_Library_SetLcdFilterWeights( FT_Library library,
unsigned char *weights )
{
if ( !library )
return FT_THROW( Invalid_Library_Handle );
if ( !weights )
return FT_THROW( Invalid_Argument );
ft_memcpy( library->lcd_weights, weights, FT_LCD_FILTER_FIVE_TAPS );
library->lcd_filter_func = ft_lcd_filter_fir;
return FT_Err_Ok;
}
/* documentation in ftlcdfil.h */
FT_EXPORT_DEF( FT_Error )
FT_Library_SetLcdFilter( FT_Library library,
FT_LcdFilter filter )
{
static const FT_LcdFiveTapFilter default_weights =
{ 0x08, 0x4d, 0x56, 0x4d, 0x08 };
static const FT_LcdFiveTapFilter light_weights =
{ 0x00, 0x55, 0x56, 0x55, 0x00 };
if ( !library )
return FT_THROW( Invalid_Library_Handle );
switch ( filter )
{
case FT_LCD_FILTER_NONE:
library->lcd_filter_func = NULL;
break;
case FT_LCD_FILTER_DEFAULT:
ft_memcpy( library->lcd_weights,
default_weights,
FT_LCD_FILTER_FIVE_TAPS );
library->lcd_filter_func = ft_lcd_filter_fir;
break;
case FT_LCD_FILTER_LIGHT:
ft_memcpy( library->lcd_weights,
light_weights,
FT_LCD_FILTER_FIVE_TAPS );
library->lcd_filter_func = ft_lcd_filter_fir;
break;
#ifdef USE_LEGACY
case FT_LCD_FILTER_LEGACY:
case FT_LCD_FILTER_LEGACY1:
library->lcd_filter_func = _ft_lcd_filter_legacy;
break;
#endif
default:
return FT_THROW( Invalid_Argument );
}
return FT_Err_Ok;
}
FT_EXPORT_DEF( FT_Error )
FT_Library_SetLcdGeometry( FT_Library library,
FT_Vector sub[3] )
{
FT_UNUSED( library );
FT_UNUSED( sub );
return FT_THROW( Unimplemented_Feature );
}
#else /* !FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
/* add padding to accommodate outline shifts */
FT_BASE_DEF( void )
ft_lcd_padding( FT_BBox* cbox,
FT_GlyphSlot slot,
FT_Render_Mode mode )
{
FT_Vector* sub = slot->library->lcd_geometry;
if ( mode == FT_RENDER_MODE_LCD )
{
cbox->xMin -= FT_MAX( FT_MAX( sub[0].x, sub[1].x ), sub[2].x );
cbox->xMax -= FT_MIN( FT_MIN( sub[0].x, sub[1].x ), sub[2].x );
cbox->yMin -= FT_MAX( FT_MAX( sub[0].y, sub[1].y ), sub[2].y );
cbox->yMax -= FT_MIN( FT_MIN( sub[0].y, sub[1].y ), sub[2].y );
}
else if ( mode == FT_RENDER_MODE_LCD_V )
{
cbox->xMin -= FT_MAX( FT_MAX( sub[0].y, sub[1].y ), sub[2].y );
cbox->xMax -= FT_MIN( FT_MIN( sub[0].y, sub[1].y ), sub[2].y );
cbox->yMin += FT_MIN( FT_MIN( sub[0].x, sub[1].x ), sub[2].x );
cbox->yMax += FT_MAX( FT_MAX( sub[0].x, sub[1].x ), sub[2].x );
}
}
FT_EXPORT_DEF( FT_Error )
FT_Library_SetLcdFilterWeights( FT_Library library,
unsigned char *weights )
{
FT_UNUSED( library );
FT_UNUSED( weights );
return FT_THROW( Unimplemented_Feature );
}
FT_EXPORT_DEF( FT_Error )
FT_Library_SetLcdFilter( FT_Library library,
FT_LcdFilter filter )
{
FT_UNUSED( library );
FT_UNUSED( filter );
return FT_THROW( Unimplemented_Feature );
}
/* documentation in ftlcdfil.h */
FT_EXPORT_DEF( FT_Error )
FT_Library_SetLcdGeometry( FT_Library library,
FT_Vector sub[3] )
{
if ( !library )
return FT_THROW( Invalid_Library_Handle );
if ( !sub )
return FT_THROW( Invalid_Argument );
ft_memcpy( library->lcd_geometry, sub, 3 * sizeof( FT_Vector ) );
return FT_Err_Ok;
}
#endif /* !FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/base/ftlcdfil.c
|
C++
|
gpl-3.0
| 11,455
|
/****************************************************************************
*
* ftmac.c
*
* Mac FOND support. Written by just@letterror.com.
* Heavily modified by mpsuzuki, George Williams, and Sean McBride.
*
* This file is for Mac OS X only; see builds/mac/ftoldmac.c for
* classic platforms built by MPW.
*
* Copyright (C) 1996-2022 by
* Just van Rossum, 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.
*
*/
/*
Notes
Mac suitcase files can (and often do!) contain multiple fonts. To
support this I use the face_index argument of FT_(Open|New)_Face()
functions, and pretend the suitcase file is a collection.
Warning: fbit and NFNT bitmap resources are not supported yet. In old
sfnt fonts, bitmap glyph data for each size is stored in each `NFNT'
resources instead of the `bdat' table in the sfnt resource. Therefore,
face->num_fixed_sizes is set to 0, because bitmap data in `NFNT'
resource is unavailable at present.
The Mac FOND support works roughly like this:
- Check whether the offered stream points to a Mac suitcase file. This
is done by checking the file type: it has to be 'FFIL' or 'tfil'. The
stream that gets passed to our init_face() routine is a stdio stream,
which isn't usable for us, since the FOND resources live in the
resource fork. So we just grab the stream->pathname field.
- Read the FOND resource into memory, then check whether there is a
TrueType font and/or(!) a Type 1 font available.
- If there is a Type 1 font available (as a separate `LWFN' file), read
its data into memory, massage it slightly so it becomes PFB data, wrap
it into a memory stream, load the Type 1 driver and delegate the rest
of the work to it by calling FT_Open_Face(). (XXX TODO: after this
has been done, the kerning data from the FOND resource should be
appended to the face: On the Mac there are usually no AFM files
available. However, this is tricky since we need to map Mac char
codes to ps glyph names to glyph ID's...)
- If there is a TrueType font (an `sfnt' resource), read it into memory,
wrap it into a memory stream, load the TrueType driver and delegate
the rest of the work to it, by calling FT_Open_Face().
- Some suitcase fonts (notably Onyx) might point the `LWFN' file to
itself, even though it doesn't contains `POST' resources. To handle
this special case without opening the file an extra time, we just
ignore errors from the `LWFN' and fallback to the `sfnt' if both are
available.
*/
#include <freetype/freetype.h>
#include <freetype/tttags.h>
#include <freetype/internal/ftstream.h>
#include "ftbase.h"
#ifdef FT_MACINTOSH
/* This is for Mac OS X. Without redefinition, OS_INLINE */
/* expands to `static inline' which doesn't survive the */
/* -ansi compilation flag of GCC. */
#if !HAVE_ANSI_OS_INLINE
#undef OS_INLINE
#define OS_INLINE static __inline__
#endif
/* `configure' checks the availability of `ResourceIndex' strictly */
/* and sets HAVE_TYPE_RESOURCE_INDEX 1 or 0 always. If it is */
/* not set (e.g., a build without `configure'), the availability */
/* is guessed from the SDK version. */
#ifndef HAVE_TYPE_RESOURCE_INDEX
#if !defined( MAC_OS_X_VERSION_10_5 ) || \
( MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5 )
#define HAVE_TYPE_RESOURCE_INDEX 0
#else
#define HAVE_TYPE_RESOURCE_INDEX 1
#endif
#endif /* !HAVE_TYPE_RESOURCE_INDEX */
#if ( HAVE_TYPE_RESOURCE_INDEX == 0 )
typedef short ResourceIndex;
#endif
#include <CoreServices/CoreServices.h>
#include <ApplicationServices/ApplicationServices.h>
#include <sys/syslimits.h> /* PATH_MAX */
/* Don't want warnings about our own use of deprecated functions. */
#define FT_DEPRECATED_ATTRIBUTE
#include <freetype/ftmac.h>
#ifndef kATSOptionFlagsUnRestrictedScope /* since Mac OS X 10.1 */
#define kATSOptionFlagsUnRestrictedScope kATSOptionFlagsDefault
#endif
/* Set PREFER_LWFN to 1 if LWFN (Type 1) is preferred over
TrueType in case *both* are available (this is not common,
but it *is* possible). */
#ifndef PREFER_LWFN
#define PREFER_LWFN 1
#endif
/* This function is deprecated because FSSpec is deprecated in Mac OS X */
FT_EXPORT_DEF( FT_Error )
FT_GetFile_From_Mac_Name( const char* fontName,
FSSpec* pathSpec,
FT_Long* face_index )
{
FT_UNUSED( fontName );
FT_UNUSED( pathSpec );
FT_UNUSED( face_index );
return FT_THROW( Unimplemented_Feature );
}
/* Private function. */
/* The FSSpec type has been discouraged for a long time, */
/* unfortunately an FSRef replacement API for */
/* ATSFontGetFileSpecification() is only available in */
/* Mac OS X 10.5 and later. */
static OSStatus
FT_ATSFontGetFileReference( ATSFontRef ats_font_id,
FSRef* ats_font_ref )
{
#if defined( MAC_OS_X_VERSION_10_5 ) && \
( MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 )
OSStatus err;
err = ATSFontGetFileReference( ats_font_id, ats_font_ref );
return err;
#elif __LP64__ /* No 64bit Carbon API on legacy platforms */
FT_UNUSED( ats_font_id );
FT_UNUSED( ats_font_ref );
return fnfErr;
#else /* 32bit Carbon API on legacy platforms */
OSStatus err;
FSSpec spec;
err = ATSFontGetFileSpecification( ats_font_id, &spec );
if ( noErr == err )
err = FSpMakeFSRef( &spec, ats_font_ref );
return err;
#endif
}
static FT_Error
FT_GetFileRef_From_Mac_ATS_Name( const char* fontName,
FSRef* ats_font_ref,
FT_Long* face_index )
{
CFStringRef cf_fontName;
ATSFontRef ats_font_id;
*face_index = 0;
cf_fontName = CFStringCreateWithCString( NULL, fontName,
kCFStringEncodingMacRoman );
ats_font_id = ATSFontFindFromName( cf_fontName,
kATSOptionFlagsUnRestrictedScope );
CFRelease( cf_fontName );
if ( ats_font_id == 0 || ats_font_id == 0xFFFFFFFFUL )
return FT_THROW( Unknown_File_Format );
if ( noErr != FT_ATSFontGetFileReference( ats_font_id, ats_font_ref ) )
return FT_THROW( Unknown_File_Format );
/* face_index calculation by searching preceding fontIDs */
/* with same FSRef */
{
ATSFontRef id2 = ats_font_id - 1;
FSRef ref2;
while ( id2 > 0 )
{
if ( noErr != FT_ATSFontGetFileReference( id2, &ref2 ) )
break;
if ( noErr != FSCompareFSRefs( ats_font_ref, &ref2 ) )
break;
id2 --;
}
*face_index = ats_font_id - ( id2 + 1 );
}
return FT_Err_Ok;
}
FT_EXPORT_DEF( FT_Error )
FT_GetFilePath_From_Mac_ATS_Name( const char* fontName,
UInt8* path,
UInt32 maxPathSize,
FT_Long* face_index )
{
FSRef ref;
FT_Error err;
if ( !fontName || !face_index )
return FT_THROW( Invalid_Argument);
err = FT_GetFileRef_From_Mac_ATS_Name( fontName, &ref, face_index );
if ( err )
return err;
if ( noErr != FSRefMakePath( &ref, path, maxPathSize ) )
return FT_THROW( Unknown_File_Format );
return FT_Err_Ok;
}
/* This function is deprecated because FSSpec is deprecated in Mac OS X */
FT_EXPORT_DEF( FT_Error )
FT_GetFile_From_Mac_ATS_Name( const char* fontName,
FSSpec* pathSpec,
FT_Long* face_index )
{
#if ( __LP64__ ) || ( defined( MAC_OS_X_VERSION_10_5 ) && \
( MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 ) )
FT_UNUSED( fontName );
FT_UNUSED( pathSpec );
FT_UNUSED( face_index );
return FT_THROW( Unimplemented_Feature );
#else
FSRef ref;
FT_Error err;
if ( !fontName || !face_index )
return FT_THROW( Invalid_Argument );
err = FT_GetFileRef_From_Mac_ATS_Name( fontName, &ref, face_index );
if ( err )
return err;
if ( noErr != FSGetCatalogInfo( &ref, kFSCatInfoNone, NULL, NULL,
pathSpec, NULL ) )
return FT_THROW( Unknown_File_Format );
return FT_Err_Ok;
#endif
}
static OSErr
FT_FSPathMakeRes( const UInt8* pathname,
ResFileRefNum* res )
{
OSErr err;
FSRef ref;
if ( noErr != FSPathMakeRef( pathname, &ref, FALSE ) )
return FT_THROW( Cannot_Open_Resource );
/* at present, no support for dfont format */
err = FSOpenResourceFile( &ref, 0, NULL, fsRdPerm, res );
if ( noErr == err )
return err;
/* fallback to original resource-fork font */
*res = FSOpenResFile( &ref, fsRdPerm );
err = ResError();
return err;
}
/* Return the file type for given pathname */
static OSType
get_file_type_from_path( const UInt8* pathname )
{
FSRef ref;
FSCatalogInfo info;
if ( noErr != FSPathMakeRef( pathname, &ref, FALSE ) )
return ( OSType ) 0;
if ( noErr != FSGetCatalogInfo( &ref, kFSCatInfoFinderInfo, &info,
NULL, NULL, NULL ) )
return ( OSType ) 0;
return ((FInfo *)(info.finderInfo))->fdType;
}
/* Given a PostScript font name, create the Macintosh LWFN file name. */
static void
create_lwfn_name( char* ps_name,
Str255 lwfn_file_name )
{
int max = 5, count = 0;
FT_Byte* p = lwfn_file_name;
FT_Byte* q = (FT_Byte*)ps_name;
lwfn_file_name[0] = 0;
while ( *q )
{
if ( ft_isupper( *q ) )
{
if ( count )
max = 3;
count = 0;
}
if ( count < max && ( ft_isalnum( *q ) || *q == '_' ) )
{
*++p = *q;
lwfn_file_name[0]++;
count++;
}
q++;
}
}
static short
count_faces_sfnt( char* fond_data )
{
/* The count is 1 greater than the value in the FOND. */
/* Isn't that cute? :-) */
return EndianS16_BtoN( *( (short*)( fond_data +
sizeof ( FamRec ) ) ) ) + 1;
}
static short
count_faces_scalable( char* fond_data )
{
AsscEntry* assoc;
short i, face, face_all;
face_all = EndianS16_BtoN( *( (short *)( fond_data +
sizeof ( FamRec ) ) ) ) + 1;
assoc = (AsscEntry*)( fond_data + sizeof ( FamRec ) + 2 );
face = 0;
for ( i = 0; i < face_all; i++ )
{
if ( 0 == EndianS16_BtoN( assoc[i].fontSize ) )
face++;
}
return face;
}
/* Look inside the FOND data, answer whether there should be an SFNT
resource, and answer the name of a possible LWFN Type 1 file.
Thanks to Paul Miller (paulm@profoundeffects.com) for the fix
to load a face OTHER than the first one in the FOND!
*/
static void
parse_fond( char* fond_data,
short* have_sfnt,
ResID* sfnt_id,
Str255 lwfn_file_name,
short face_index )
{
AsscEntry* assoc;
AsscEntry* base_assoc;
FamRec* fond;
*sfnt_id = 0;
*have_sfnt = 0;
lwfn_file_name[0] = 0;
fond = (FamRec*)fond_data;
assoc = (AsscEntry*)( fond_data + sizeof ( FamRec ) + 2 );
base_assoc = assoc;
/* the maximum faces in a FOND is 48, size of StyleTable.indexes[] */
if ( 47 < face_index )
return;
/* Let's do a little range checking before we get too excited here */
if ( face_index < count_faces_sfnt( fond_data ) )
{
assoc += face_index; /* add on the face_index! */
/* if the face at this index is not scalable,
fall back to the first one (old behavior) */
if ( EndianS16_BtoN( assoc->fontSize ) == 0 )
{
*have_sfnt = 1;
*sfnt_id = EndianS16_BtoN( assoc->fontID );
}
else if ( base_assoc->fontSize == 0 )
{
*have_sfnt = 1;
*sfnt_id = EndianS16_BtoN( base_assoc->fontID );
}
}
if ( EndianS32_BtoN( fond->ffStylOff ) )
{
unsigned char* p = (unsigned char*)fond_data;
StyleTable* style;
unsigned short string_count;
char ps_name[256];
unsigned char* names[64];
int i;
p += EndianS32_BtoN( fond->ffStylOff );
style = (StyleTable*)p;
p += sizeof ( StyleTable );
string_count = EndianS16_BtoN( *(short*)(p) );
string_count = FT_MIN( 64, string_count );
p += sizeof ( short );
for ( i = 0; i < string_count; i++ )
{
names[i] = p;
p += names[i][0];
p++;
}
{
size_t ps_name_len = (size_t)names[0][0];
if ( ps_name_len != 0 )
{
ft_memcpy(ps_name, names[0] + 1, ps_name_len);
ps_name[ps_name_len] = 0;
}
if ( style->indexes[face_index] > 1 &&
style->indexes[face_index] <= string_count )
{
unsigned char* suffixes = names[style->indexes[face_index] - 1];
for ( i = 1; i <= suffixes[0]; i++ )
{
unsigned char* s;
size_t j = suffixes[i] - 1;
if ( j < string_count && ( s = names[j] ) != NULL )
{
size_t s_len = (size_t)s[0];
if ( s_len != 0 && ps_name_len + s_len < sizeof ( ps_name ) )
{
ft_memcpy( ps_name + ps_name_len, s + 1, s_len );
ps_name_len += s_len;
ps_name[ps_name_len] = 0;
}
}
}
}
}
create_lwfn_name( ps_name, lwfn_file_name );
}
}
static FT_Error
lookup_lwfn_by_fond( const UInt8* path_fond,
ConstStr255Param base_lwfn,
UInt8* path_lwfn,
size_t path_size )
{
FSRef ref, par_ref;
size_t dirname_len;
/* Pathname for FSRef can be in various formats: HFS, HFS+, and POSIX. */
/* We should not extract parent directory by string manipulation. */
if ( noErr != FSPathMakeRef( path_fond, &ref, FALSE ) )
return FT_THROW( Invalid_Argument );
if ( noErr != FSGetCatalogInfo( &ref, kFSCatInfoNone,
NULL, NULL, NULL, &par_ref ) )
return FT_THROW( Invalid_Argument );
if ( noErr != FSRefMakePath( &par_ref, path_lwfn, path_size ) )
return FT_THROW( Invalid_Argument );
if ( ft_strlen( (char *)path_lwfn ) + 1 + base_lwfn[0] > path_size )
return FT_THROW( Invalid_Argument );
/* now we have absolute dirname in path_lwfn */
ft_strcat( (char *)path_lwfn, "/" );
dirname_len = ft_strlen( (char *)path_lwfn );
ft_strcat( (char *)path_lwfn, (char *)base_lwfn + 1 );
path_lwfn[dirname_len + base_lwfn[0]] = '\0';
if ( noErr != FSPathMakeRef( path_lwfn, &ref, FALSE ) )
return FT_THROW( Cannot_Open_Resource );
if ( noErr != FSGetCatalogInfo( &ref, kFSCatInfoNone,
NULL, NULL, NULL, NULL ) )
return FT_THROW( Cannot_Open_Resource );
return FT_Err_Ok;
}
static short
count_faces( Handle fond,
const UInt8* pathname )
{
ResID sfnt_id;
short have_sfnt, have_lwfn;
Str255 lwfn_file_name;
UInt8 buff[PATH_MAX];
FT_Error err;
short num_faces;
have_sfnt = have_lwfn = 0;
parse_fond( *fond, &have_sfnt, &sfnt_id, lwfn_file_name, 0 );
if ( lwfn_file_name[0] )
{
err = lookup_lwfn_by_fond( pathname, lwfn_file_name,
buff, sizeof ( buff ) );
if ( !err )
have_lwfn = 1;
}
if ( have_lwfn && ( !have_sfnt || PREFER_LWFN ) )
num_faces = 1;
else
num_faces = count_faces_scalable( *fond );
return num_faces;
}
/* Read Type 1 data from the POST resources inside the LWFN file,
return a PFB buffer. This is somewhat convoluted because the FT2
PFB parser wants the ASCII header as one chunk, and the LWFN
chunks are often not organized that way, so we glue chunks
of the same type together. */
static FT_Error
read_lwfn( FT_Memory memory,
ResFileRefNum res,
FT_Byte** pfb_data,
FT_ULong* size )
{
FT_Error error = FT_Err_Ok;
ResID res_id;
unsigned char *buffer, *p, *size_p = NULL;
FT_ULong total_size = 0;
FT_ULong old_total_size = 0;
FT_ULong post_size, pfb_chunk_size;
Handle post_data;
char code, last_code;
UseResFile( res );
/* First pass: load all POST resources, and determine the size of */
/* the output buffer. */
res_id = 501;
last_code = -1;
for (;;)
{
post_data = Get1Resource( TTAG_POST, res_id++ );
if ( !post_data )
break; /* we are done */
code = (*post_data)[0];
if ( code != last_code )
{
if ( code == 5 )
total_size += 2; /* just the end code */
else
total_size += 6; /* code + 4 bytes chunk length */
}
total_size += (FT_ULong)GetHandleSize( post_data ) - 2;
last_code = code;
/* detect resource fork overflow */
if ( FT_MAC_RFORK_MAX_LEN < total_size )
{
error = FT_THROW( Array_Too_Large );
goto Error;
}
old_total_size = total_size;
}
if ( FT_QALLOC( buffer, (FT_Long)total_size ) )
goto Error;
/* Second pass: append all POST data to the buffer, add PFB fields. */
/* Glue all consecutive chunks of the same type together. */
p = buffer;
res_id = 501;
last_code = -1;
pfb_chunk_size = 0;
for (;;)
{
post_data = Get1Resource( TTAG_POST, res_id++ );
if ( !post_data )
break; /* we are done */
post_size = (FT_ULong)GetHandleSize( post_data ) - 2;
code = (*post_data)[0];
if ( code != last_code )
{
if ( last_code != -1 )
{
/* we are done adding a chunk, fill in the size field */
if ( size_p )
{
*size_p++ = (FT_Byte)( pfb_chunk_size & 0xFF );
*size_p++ = (FT_Byte)( ( pfb_chunk_size >> 8 ) & 0xFF );
*size_p++ = (FT_Byte)( ( pfb_chunk_size >> 16 ) & 0xFF );
*size_p++ = (FT_Byte)( ( pfb_chunk_size >> 24 ) & 0xFF );
}
pfb_chunk_size = 0;
}
*p++ = 0x80;
if ( code == 5 )
*p++ = 0x03; /* the end */
else if ( code == 2 )
*p++ = 0x02; /* binary segment */
else
*p++ = 0x01; /* ASCII segment */
if ( code != 5 )
{
size_p = p; /* save for later */
p += 4; /* make space for size field */
}
}
ft_memcpy( p, *post_data + 2, post_size );
pfb_chunk_size += post_size;
p += post_size;
last_code = code;
}
*pfb_data = buffer;
*size = total_size;
Error:
CloseResFile( res );
return error;
}
/* Create a new FT_Face from a file path to an LWFN file. */
static FT_Error
FT_New_Face_From_LWFN( FT_Library library,
const UInt8* pathname,
FT_Long face_index,
FT_Face* aface )
{
FT_Byte* pfb_data;
FT_ULong pfb_size;
FT_Error error;
ResFileRefNum res;
if ( noErr != FT_FSPathMakeRes( pathname, &res ) )
return FT_THROW( Cannot_Open_Resource );
pfb_data = NULL;
pfb_size = 0;
error = read_lwfn( library->memory, res, &pfb_data, &pfb_size );
CloseResFile( res ); /* PFB is already loaded, useless anymore */
if ( error )
return error;
return open_face_from_buffer( library,
pfb_data,
pfb_size,
face_index,
"type1",
aface );
}
/* Create a new FT_Face from an SFNT resource, specified by res ID. */
static FT_Error
FT_New_Face_From_SFNT( FT_Library library,
ResID sfnt_id,
FT_Long face_index,
FT_Face* aface )
{
Handle sfnt = NULL;
FT_Byte* sfnt_data;
size_t sfnt_size;
FT_Error error = FT_Err_Ok;
FT_Memory memory = library->memory;
int is_cff, is_sfnt_ps;
sfnt = GetResource( TTAG_sfnt, sfnt_id );
if ( !sfnt )
return FT_THROW( Invalid_Handle );
sfnt_size = (FT_ULong)GetHandleSize( sfnt );
/* detect resource fork overflow */
if ( FT_MAC_RFORK_MAX_LEN < sfnt_size )
return FT_THROW( Array_Too_Large );
if ( FT_QALLOC( sfnt_data, (FT_Long)sfnt_size ) )
{
ReleaseResource( sfnt );
return error;
}
ft_memcpy( sfnt_data, *sfnt, sfnt_size );
ReleaseResource( sfnt );
is_cff = sfnt_size > 4 && !ft_memcmp( sfnt_data, "OTTO", 4 );
is_sfnt_ps = sfnt_size > 4 && !ft_memcmp( sfnt_data, "typ1", 4 );
if ( is_sfnt_ps )
{
FT_Stream stream;
if ( FT_NEW( stream ) )
goto Try_OpenType;
FT_Stream_OpenMemory( stream, sfnt_data, sfnt_size );
if ( !open_face_PS_from_sfnt_stream( library,
stream,
face_index,
0, NULL,
aface ) )
{
FT_Stream_Close( stream );
FT_FREE( stream );
FT_FREE( sfnt_data );
goto Exit;
}
FT_FREE( stream );
}
Try_OpenType:
error = open_face_from_buffer( library,
sfnt_data,
sfnt_size,
face_index,
is_cff ? "cff" : "truetype",
aface );
Exit:
return error;
}
/* Create a new FT_Face from a file path to a suitcase file. */
static FT_Error
FT_New_Face_From_Suitcase( FT_Library library,
const UInt8* pathname,
FT_Long face_index,
FT_Face* aface )
{
FT_Error error = FT_ERR( Cannot_Open_Resource );
ResFileRefNum res_ref;
ResourceIndex res_index;
Handle fond;
short num_faces_in_res;
if ( noErr != FT_FSPathMakeRes( pathname, &res_ref ) )
return FT_THROW( Cannot_Open_Resource );
UseResFile( res_ref );
if ( ResError() )
return FT_THROW( Cannot_Open_Resource );
num_faces_in_res = 0;
for ( res_index = 1; ; res_index++ )
{
short num_faces_in_fond;
fond = Get1IndResource( TTAG_FOND, res_index );
if ( ResError() )
break;
num_faces_in_fond = count_faces( fond, pathname );
num_faces_in_res += num_faces_in_fond;
if ( 0 <= face_index && face_index < num_faces_in_fond && error )
error = FT_New_Face_From_FOND( library, fond, face_index, aface );
face_index -= num_faces_in_fond;
}
CloseResFile( res_ref );
if ( !error && aface && *aface )
(*aface)->num_faces = num_faces_in_res;
return error;
}
/* documentation is in ftmac.h */
FT_EXPORT_DEF( FT_Error )
FT_New_Face_From_FOND( FT_Library library,
Handle fond,
FT_Long face_index,
FT_Face* aface )
{
short have_sfnt, have_lwfn = 0;
ResID sfnt_id, fond_id;
OSType fond_type;
Str255 fond_name;
Str255 lwfn_file_name;
UInt8 path_lwfn[PATH_MAX];
OSErr err;
FT_Error error = FT_Err_Ok;
/* check of `library' and `aface' delayed to `FT_New_Face_From_XXX' */
GetResInfo( fond, &fond_id, &fond_type, fond_name );
if ( ResError() != noErr || fond_type != TTAG_FOND )
return FT_THROW( Invalid_File_Format );
parse_fond( *fond, &have_sfnt, &sfnt_id, lwfn_file_name, face_index );
if ( lwfn_file_name[0] )
{
ResFileRefNum res;
res = HomeResFile( fond );
if ( noErr != ResError() )
goto found_no_lwfn_file;
{
UInt8 path_fond[PATH_MAX];
FSRef ref;
err = FSGetForkCBInfo( res, kFSInvalidVolumeRefNum,
NULL, NULL, NULL, &ref, NULL );
if ( noErr != err )
goto found_no_lwfn_file;
err = FSRefMakePath( &ref, path_fond, sizeof ( path_fond ) );
if ( noErr != err )
goto found_no_lwfn_file;
error = lookup_lwfn_by_fond( path_fond, lwfn_file_name,
path_lwfn, sizeof ( path_lwfn ) );
if ( !error )
have_lwfn = 1;
}
}
if ( have_lwfn && ( !have_sfnt || PREFER_LWFN ) )
error = FT_New_Face_From_LWFN( library,
path_lwfn,
face_index,
aface );
else
error = FT_THROW( Unknown_File_Format );
found_no_lwfn_file:
if ( have_sfnt && error )
error = FT_New_Face_From_SFNT( library,
sfnt_id,
face_index,
aface );
return error;
}
/* Common function to load a new FT_Face from a resource file. */
static FT_Error
FT_New_Face_From_Resource( FT_Library library,
const UInt8* pathname,
FT_Long face_index,
FT_Face* aface )
{
OSType file_type;
FT_Error error;
/* LWFN is a (very) specific file format, check for it explicitly */
file_type = get_file_type_from_path( pathname );
if ( file_type == TTAG_LWFN )
return FT_New_Face_From_LWFN( library, pathname, face_index, aface );
/* Otherwise the file type doesn't matter (there are more than */
/* `FFIL' and `tfil'). Just try opening it as a font suitcase; */
/* if it works, fine. */
error = FT_New_Face_From_Suitcase( library, pathname, face_index, aface );
if ( error )
{
/* let it fall through to normal loader (.ttf, .otf, etc.); */
/* we signal this by returning no error and no FT_Face */
*aface = NULL;
}
return FT_Err_Ok;
}
/**************************************************************************
*
* @Function:
* FT_New_Face
*
* @Description:
* This is the Mac-specific implementation of FT_New_Face. In
* addition to the standard FT_New_Face() functionality, it also
* accepts pathnames to Mac suitcase files. For further
* documentation see the original FT_New_Face() in freetype.h.
*/
FT_EXPORT_DEF( FT_Error )
FT_New_Face( FT_Library library,
const char* pathname,
FT_Long face_index,
FT_Face* aface )
{
FT_Open_Args args;
FT_Error error;
/* test for valid `library' and `aface' delayed to FT_Open_Face() */
if ( !pathname )
return FT_THROW( Invalid_Argument );
*aface = NULL;
/* try resourcefork based font: LWFN, FFIL */
error = FT_New_Face_From_Resource( library, (UInt8 *)pathname,
face_index, aface );
if ( error || *aface )
return error;
/* let it fall through to normal loader (.ttf, .otf, etc.) */
args.flags = FT_OPEN_PATHNAME;
args.pathname = (char*)pathname;
return FT_Open_Face( library, &args, face_index, aface );
}
/**************************************************************************
*
* @Function:
* FT_New_Face_From_FSRef
*
* @Description:
* FT_New_Face_From_FSRef is identical to FT_New_Face except it
* accepts an FSRef instead of a path.
*
* This function is deprecated because Carbon data types (FSRef)
* are not cross-platform, and thus not suitable for the FreeType API.
*/
FT_EXPORT_DEF( FT_Error )
FT_New_Face_From_FSRef( FT_Library library,
const FSRef* ref,
FT_Long face_index,
FT_Face* aface )
{
FT_Error error;
FT_Open_Args args;
OSErr err;
UInt8 pathname[PATH_MAX];
/* check of `library' and `aface' delayed to */
/* `FT_New_Face_From_Resource' */
if ( !ref )
return FT_THROW( Invalid_Argument );
err = FSRefMakePath( ref, pathname, sizeof ( pathname ) );
if ( err )
error = FT_THROW( Cannot_Open_Resource );
error = FT_New_Face_From_Resource( library, pathname, face_index, aface );
if ( error || *aface )
return error;
/* fallback to datafork font */
args.flags = FT_OPEN_PATHNAME;
args.pathname = (char*)pathname;
return FT_Open_Face( library, &args, face_index, aface );
}
/**************************************************************************
*
* @Function:
* FT_New_Face_From_FSSpec
*
* @Description:
* FT_New_Face_From_FSSpec is identical to FT_New_Face except it
* accepts an FSSpec instead of a path.
*
* This function is deprecated because FSSpec is deprecated in Mac OS X
*/
FT_EXPORT_DEF( FT_Error )
FT_New_Face_From_FSSpec( FT_Library library,
const FSSpec* spec,
FT_Long face_index,
FT_Face* aface )
{
#if ( __LP64__ ) || ( defined( MAC_OS_X_VERSION_10_5 ) && \
( MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 ) )
FT_UNUSED( library );
FT_UNUSED( spec );
FT_UNUSED( face_index );
FT_UNUSED( aface );
return FT_THROW( Unimplemented_Feature );
#else
FSRef ref;
/* check of `library' and `aface' delayed to `FT_New_Face_From_FSRef' */
if ( !spec || FSpMakeFSRef( spec, &ref ) != noErr )
return FT_THROW( Invalid_Argument );
else
return FT_New_Face_From_FSRef( library, &ref, face_index, aface );
#endif
}
#else /* !FT_MACINTOSH */
/* ANSI C doesn't like empty source files */
typedef int _ft_mac_dummy;
#endif /* !FT_MACINTOSH */
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/base/ftmac.c
|
C++
|
gpl-3.0
| 31,476
|
/****************************************************************************
*
* ftmm.c
*
* Multiple Master font support (body).
*
* Copyright (C) 1996-2022 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.
*
*/
#include <freetype/internal/ftdebug.h>
#include <freetype/ftmm.h>
#include <freetype/internal/ftobjs.h>
#include <freetype/internal/services/svmm.h>
#include <freetype/internal/services/svmetric.h>
/**************************************************************************
*
* The macro FT_COMPONENT is used in trace mode. It is an implicit
* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
* messages during execution.
*/
#undef FT_COMPONENT
#define FT_COMPONENT mm
static FT_Error
ft_face_get_mm_service( FT_Face face,
FT_Service_MultiMasters *aservice )
{
FT_Error error;
*aservice = NULL;
if ( !face )
return FT_THROW( Invalid_Face_Handle );
error = FT_ERR( Invalid_Argument );
if ( FT_HAS_MULTIPLE_MASTERS( face ) )
{
FT_FACE_LOOKUP_SERVICE( face,
*aservice,
MULTI_MASTERS );
if ( *aservice )
error = FT_Err_Ok;
}
return error;
}
static FT_Error
ft_face_get_mvar_service( FT_Face face,
FT_Service_MetricsVariations *aservice )
{
FT_Error error;
*aservice = NULL;
if ( !face )
return FT_THROW( Invalid_Face_Handle );
error = FT_ERR( Invalid_Argument );
if ( FT_HAS_MULTIPLE_MASTERS( face ) )
{
FT_FACE_LOOKUP_SERVICE( face,
*aservice,
METRICS_VARIATIONS );
if ( *aservice )
error = FT_Err_Ok;
}
return error;
}
/* documentation is in ftmm.h */
FT_EXPORT_DEF( FT_Error )
FT_Get_Multi_Master( FT_Face face,
FT_Multi_Master *amaster )
{
FT_Error error;
FT_Service_MultiMasters service;
/* check of `face' delayed to `ft_face_get_mm_service' */
if ( !amaster )
return FT_THROW( Invalid_Argument );
error = ft_face_get_mm_service( face, &service );
if ( !error )
{
error = FT_ERR( Invalid_Argument );
if ( service->get_mm )
error = service->get_mm( face, amaster );
}
return error;
}
/* documentation is in ftmm.h */
FT_EXPORT_DEF( FT_Error )
FT_Get_MM_Var( FT_Face face,
FT_MM_Var* *amaster )
{
FT_Error error;
FT_Service_MultiMasters service;
/* check of `face' delayed to `ft_face_get_mm_service' */
if ( !amaster )
return FT_THROW( Invalid_Argument );
error = ft_face_get_mm_service( face, &service );
if ( !error )
{
error = FT_ERR( Invalid_Argument );
if ( service->get_mm_var )
error = service->get_mm_var( face, amaster );
}
return error;
}
/* documentation is in ftmm.h */
FT_EXPORT_DEF( FT_Error )
FT_Done_MM_Var( FT_Library library,
FT_MM_Var* amaster )
{
FT_Memory memory;
if ( !library )
return FT_THROW( Invalid_Library_Handle );
memory = library->memory;
FT_FREE( amaster );
return FT_Err_Ok;
}
/* documentation is in ftmm.h */
FT_EXPORT_DEF( FT_Error )
FT_Set_MM_Design_Coordinates( FT_Face face,
FT_UInt num_coords,
FT_Long* coords )
{
FT_Error error;
FT_Service_MultiMasters service;
/* check of `face' delayed to `ft_face_get_mm_service' */
if ( num_coords && !coords )
return FT_THROW( Invalid_Argument );
error = ft_face_get_mm_service( face, &service );
if ( !error )
{
error = FT_ERR( Invalid_Argument );
if ( service->set_mm_design )
error = service->set_mm_design( face, num_coords, coords );
}
/* enforce recomputation of auto-hinting data */
if ( !error && face->autohint.finalizer )
{
face->autohint.finalizer( face->autohint.data );
face->autohint.data = NULL;
}
return error;
}
/* documentation is in ftmm.h */
FT_EXPORT_DEF( FT_Error )
FT_Set_MM_WeightVector( FT_Face face,
FT_UInt len,
FT_Fixed* weightvector )
{
FT_Error error;
FT_Service_MultiMasters service;
/* check of `face' delayed to `ft_face_get_mm_service' */
if ( len && !weightvector )
return FT_THROW( Invalid_Argument );
error = ft_face_get_mm_service( face, &service );
if ( !error )
{
error = FT_ERR( Invalid_Argument );
if ( service->set_mm_weightvector )
error = service->set_mm_weightvector( face, len, weightvector );
}
/* enforce recomputation of auto-hinting data */
if ( !error && face->autohint.finalizer )
{
face->autohint.finalizer( face->autohint.data );
face->autohint.data = NULL;
}
return error;
}
FT_EXPORT_DEF( FT_Error )
FT_Get_MM_WeightVector( FT_Face face,
FT_UInt* len,
FT_Fixed* weightvector )
{
FT_Error error;
FT_Service_MultiMasters service;
/* check of `face' delayed to `ft_face_get_mm_service' */
if ( len && !weightvector )
return FT_THROW( Invalid_Argument );
error = ft_face_get_mm_service( face, &service );
if ( !error )
{
error = FT_ERR( Invalid_Argument );
if ( service->get_mm_weightvector )
error = service->get_mm_weightvector( face, len, weightvector );
}
return error;
}
/* documentation is in ftmm.h */
FT_EXPORT_DEF( FT_Error )
FT_Set_Var_Design_Coordinates( FT_Face face,
FT_UInt num_coords,
FT_Fixed* coords )
{
FT_Error error;
FT_Service_MultiMasters service_mm = NULL;
FT_Service_MetricsVariations service_mvar = NULL;
/* check of `face' delayed to `ft_face_get_mm_service' */
if ( num_coords && !coords )
return FT_THROW( Invalid_Argument );
error = ft_face_get_mm_service( face, &service_mm );
if ( !error )
{
error = FT_ERR( Invalid_Argument );
if ( service_mm->set_var_design )
error = service_mm->set_var_design( face, num_coords, coords );
/* internal error code -1 means `no change'; we can exit immediately */
if ( error == -1 )
return FT_Err_Ok;
}
if ( !error )
{
(void)ft_face_get_mvar_service( face, &service_mvar );
if ( service_mvar && service_mvar->metrics_adjust )
service_mvar->metrics_adjust( face );
}
/* enforce recomputation of auto-hinting data */
if ( !error && face->autohint.finalizer )
{
face->autohint.finalizer( face->autohint.data );
face->autohint.data = NULL;
}
return error;
}
/* documentation is in ftmm.h */
FT_EXPORT_DEF( FT_Error )
FT_Get_Var_Design_Coordinates( FT_Face face,
FT_UInt num_coords,
FT_Fixed* coords )
{
FT_Error error;
FT_Service_MultiMasters service;
/* check of `face' delayed to `ft_face_get_mm_service' */
if ( !coords )
return FT_THROW( Invalid_Argument );
error = ft_face_get_mm_service( face, &service );
if ( !error )
{
error = FT_ERR( Invalid_Argument );
if ( service->get_var_design )
error = service->get_var_design( face, num_coords, coords );
}
return error;
}
/* documentation is in ftmm.h */
FT_EXPORT_DEF( FT_Error )
FT_Set_MM_Blend_Coordinates( FT_Face face,
FT_UInt num_coords,
FT_Fixed* coords )
{
FT_Error error;
FT_Service_MultiMasters service_mm = NULL;
FT_Service_MetricsVariations service_mvar = NULL;
/* check of `face' delayed to `ft_face_get_mm_service' */
if ( num_coords && !coords )
return FT_THROW( Invalid_Argument );
error = ft_face_get_mm_service( face, &service_mm );
if ( !error )
{
error = FT_ERR( Invalid_Argument );
if ( service_mm->set_mm_blend )
error = service_mm->set_mm_blend( face, num_coords, coords );
/* internal error code -1 means `no change'; we can exit immediately */
if ( error == -1 )
return FT_Err_Ok;
}
if ( !error )
{
(void)ft_face_get_mvar_service( face, &service_mvar );
if ( service_mvar && service_mvar->metrics_adjust )
service_mvar->metrics_adjust( face );
}
/* enforce recomputation of auto-hinting data */
if ( !error && face->autohint.finalizer )
{
face->autohint.finalizer( face->autohint.data );
face->autohint.data = NULL;
}
return error;
}
/* documentation is in ftmm.h */
/* This is exactly the same as the previous function. It exists for */
/* orthogonality. */
FT_EXPORT_DEF( FT_Error )
FT_Set_Var_Blend_Coordinates( FT_Face face,
FT_UInt num_coords,
FT_Fixed* coords )
{
FT_Error error;
FT_Service_MultiMasters service_mm = NULL;
FT_Service_MetricsVariations service_mvar = NULL;
/* check of `face' delayed to `ft_face_get_mm_service' */
if ( num_coords && !coords )
return FT_THROW( Invalid_Argument );
error = ft_face_get_mm_service( face, &service_mm );
if ( !error )
{
error = FT_ERR( Invalid_Argument );
if ( service_mm->set_mm_blend )
error = service_mm->set_mm_blend( face, num_coords, coords );
/* internal error code -1 means `no change'; we can exit immediately */
if ( error == -1 )
return FT_Err_Ok;
}
if ( !error )
{
(void)ft_face_get_mvar_service( face, &service_mvar );
if ( service_mvar && service_mvar->metrics_adjust )
service_mvar->metrics_adjust( face );
}
/* enforce recomputation of auto-hinting data */
if ( !error && face->autohint.finalizer )
{
face->autohint.finalizer( face->autohint.data );
face->autohint.data = NULL;
}
return error;
}
/* documentation is in ftmm.h */
FT_EXPORT_DEF( FT_Error )
FT_Get_MM_Blend_Coordinates( FT_Face face,
FT_UInt num_coords,
FT_Fixed* coords )
{
FT_Error error;
FT_Service_MultiMasters service;
/* check of `face' delayed to `ft_face_get_mm_service' */
if ( !coords )
return FT_THROW( Invalid_Argument );
error = ft_face_get_mm_service( face, &service );
if ( !error )
{
error = FT_ERR( Invalid_Argument );
if ( service->get_mm_blend )
error = service->get_mm_blend( face, num_coords, coords );
}
return error;
}
/* documentation is in ftmm.h */
/* This is exactly the same as the previous function. It exists for */
/* orthogonality. */
FT_EXPORT_DEF( FT_Error )
FT_Get_Var_Blend_Coordinates( FT_Face face,
FT_UInt num_coords,
FT_Fixed* coords )
{
FT_Error error;
FT_Service_MultiMasters service;
/* check of `face' delayed to `ft_face_get_mm_service' */
if ( !coords )
return FT_THROW( Invalid_Argument );
error = ft_face_get_mm_service( face, &service );
if ( !error )
{
error = FT_ERR( Invalid_Argument );
if ( service->get_mm_blend )
error = service->get_mm_blend( face, num_coords, coords );
}
return error;
}
/* documentation is in ftmm.h */
FT_EXPORT_DEF( FT_Error )
FT_Get_Var_Axis_Flags( FT_MM_Var* master,
FT_UInt axis_index,
FT_UInt* flags )
{
FT_UShort* axis_flags;
if ( !master || !flags )
return FT_THROW( Invalid_Argument );
if ( axis_index >= master->num_axis )
return FT_THROW( Invalid_Argument );
/* the axis flags array immediately follows the data of `master' */
axis_flags = (FT_UShort*)&( master[1] );
*flags = axis_flags[axis_index];
return FT_Err_Ok;
}
/* documentation is in ftmm.h */
FT_EXPORT_DEF( FT_Error )
FT_Set_Named_Instance( FT_Face face,
FT_UInt instance_index )
{
FT_Error error;
FT_Service_MultiMasters service_mm = NULL;
FT_Service_MetricsVariations service_mvar = NULL;
/* check of `face' delayed to `ft_face_get_mm_service' */
error = ft_face_get_mm_service( face, &service_mm );
if ( !error )
{
error = FT_ERR( Invalid_Argument );
if ( service_mm->set_instance )
error = service_mm->set_instance( face, instance_index );
}
if ( !error )
{
(void)ft_face_get_mvar_service( face, &service_mvar );
if ( service_mvar && service_mvar->metrics_adjust )
service_mvar->metrics_adjust( face );
}
/* enforce recomputation of auto-hinting data */
if ( !error && face->autohint.finalizer )
{
face->autohint.finalizer( face->autohint.data );
face->autohint.data = NULL;
}
if ( !error )
{
face->face_index = ( instance_index << 16 ) |
( face->face_index & 0xFFFFL );
face->face_flags &= ~FT_FACE_FLAG_VARIATION;
}
return error;
}
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/base/ftmm.c
|
C++
|
gpl-3.0
| 14,176
|
/****************************************************************************
*
* ftobjs.c
*
* The FreeType private base classes (body).
*
* Copyright (C) 1996-2022 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.
*
*/
#include <freetype/ftlist.h>
#include <freetype/ftoutln.h>
#include <freetype/ftfntfmt.h>
#include <freetype/otsvg.h>
#include <freetype/internal/ftvalid.h>
#include <freetype/internal/ftobjs.h>
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/ftrfork.h>
#include <freetype/internal/ftstream.h>
#include <freetype/internal/sfnt.h> /* for SFNT_Load_Table_Func */
#include <freetype/internal/psaux.h> /* for PS_Driver */
#include <freetype/internal/svginterface.h>
#include <freetype/tttables.h>
#include <freetype/tttags.h>
#include <freetype/ttnameid.h>
#include <freetype/internal/services/svprop.h>
#include <freetype/internal/services/svsfnt.h>
#include <freetype/internal/services/svpostnm.h>
#include <freetype/internal/services/svgldict.h>
#include <freetype/internal/services/svttcmap.h>
#include <freetype/internal/services/svkern.h>
#include <freetype/internal/services/svtteng.h>
#include <freetype/ftdriver.h>
#ifdef FT_CONFIG_OPTION_MAC_FONTS
#include "ftbase.h"
#endif
#ifdef FT_DEBUG_LEVEL_TRACE
#include <freetype/ftbitmap.h>
#if defined( _MSC_VER ) /* Visual C++ (and Intel C++) */
/* We disable the warning `conversion from XXX to YYY, */
/* possible loss of data' in order to compile cleanly with */
/* the maximum level of warnings: `md5.c' is non-FreeType */
/* code, and it gets used during development builds only. */
#pragma warning( push )
#pragma warning( disable : 4244 )
#endif /* _MSC_VER */
/* It's easiest to include `md5.c' directly. However, since OpenSSL */
/* also provides the same functions, there might be conflicts if */
/* both FreeType and OpenSSL are built as static libraries. For */
/* this reason, we put the MD5 stuff into the `FT_' namespace. */
#define MD5_u32plus FT_MD5_u32plus
#define MD5_CTX FT_MD5_CTX
#define MD5_Init FT_MD5_Init
#define MD5_Update FT_MD5_Update
#define MD5_Final FT_MD5_Final
#undef HAVE_OPENSSL
#include "md5.c"
#if defined( _MSC_VER )
#pragma warning( pop )
#endif
/* This array must stay in sync with the @FT_Pixel_Mode enumeration */
/* (in file `ftimage.h`). */
static const char* const pixel_modes[] =
{
"none",
"monochrome bitmap",
"gray 8-bit bitmap",
"gray 2-bit bitmap",
"gray 4-bit bitmap",
"LCD 8-bit bitmap",
"vertical LCD 8-bit bitmap",
"BGRA 32-bit color image bitmap",
"SDF 8-bit bitmap"
};
#endif /* FT_DEBUG_LEVEL_TRACE */
#define GRID_FIT_METRICS
/* forward declaration */
static FT_Error
ft_open_face_internal( FT_Library library,
const FT_Open_Args* args,
FT_Long face_index,
FT_Face *aface,
FT_Bool test_mac_fonts );
FT_BASE_DEF( FT_Pointer )
ft_service_list_lookup( FT_ServiceDesc service_descriptors,
const char* service_id )
{
FT_Pointer result = NULL;
FT_ServiceDesc desc = service_descriptors;
if ( desc && service_id )
{
for ( ; desc->serv_id != NULL; desc++ )
{
if ( ft_strcmp( desc->serv_id, service_id ) == 0 )
{
result = (FT_Pointer)desc->serv_data;
break;
}
}
}
return result;
}
FT_BASE_DEF( void )
ft_validator_init( FT_Validator valid,
const FT_Byte* base,
const FT_Byte* limit,
FT_ValidationLevel level )
{
valid->base = base;
valid->limit = limit;
valid->level = level;
valid->error = FT_Err_Ok;
}
FT_BASE_DEF( FT_Int )
ft_validator_run( FT_Validator valid )
{
/* This function doesn't work! None should call it. */
FT_UNUSED( valid );
return -1;
}
FT_BASE_DEF( void )
ft_validator_error( FT_Validator valid,
FT_Error error )
{
/* since the cast below also disables the compiler's */
/* type check, we introduce a dummy variable, which */
/* will be optimized away */
volatile ft_jmp_buf* jump_buffer = &valid->jump_buffer;
valid->error = error;
/* throw away volatileness; use `jump_buffer' or the */
/* compiler may warn about an unused local variable */
ft_longjmp( *(ft_jmp_buf*) jump_buffer, 1 );
}
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/**** ****/
/**** ****/
/**** S T R E A M ****/
/**** ****/
/**** ****/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/* create a new input stream from an FT_Open_Args structure */
/* */
FT_BASE_DEF( FT_Error )
FT_Stream_New( FT_Library library,
const FT_Open_Args* args,
FT_Stream *astream )
{
FT_Error error;
FT_Memory memory;
FT_Stream stream = NULL;
FT_UInt mode;
*astream = NULL;
if ( !library )
return FT_THROW( Invalid_Library_Handle );
if ( !args )
return FT_THROW( Invalid_Argument );
memory = library->memory;
mode = args->flags &
( FT_OPEN_MEMORY | FT_OPEN_STREAM | FT_OPEN_PATHNAME );
if ( mode == FT_OPEN_MEMORY )
{
/* create a memory-based stream */
if ( FT_NEW( stream ) )
goto Exit;
FT_Stream_OpenMemory( stream,
(const FT_Byte*)args->memory_base,
(FT_ULong)args->memory_size );
stream->memory = memory;
}
#ifndef FT_CONFIG_OPTION_DISABLE_STREAM_SUPPORT
else if ( mode == FT_OPEN_PATHNAME )
{
/* create a normal system stream */
if ( FT_NEW( stream ) )
goto Exit;
stream->memory = memory;
error = FT_Stream_Open( stream, args->pathname );
if ( error )
FT_FREE( stream );
}
else if ( ( mode == FT_OPEN_STREAM ) && args->stream )
{
/* use an existing, user-provided stream */
/* in this case, we do not need to allocate a new stream object */
/* since the caller is responsible for closing it himself */
stream = args->stream;
stream->memory = memory;
error = FT_Err_Ok;
}
#endif
else
{
error = FT_THROW( Invalid_Argument );
if ( ( args->flags & FT_OPEN_STREAM ) && args->stream )
FT_Stream_Close( args->stream );
}
if ( !error )
*astream = stream;
Exit:
return error;
}
FT_BASE_DEF( void )
FT_Stream_Free( FT_Stream stream,
FT_Int external )
{
if ( stream )
{
FT_Memory memory = stream->memory;
FT_Stream_Close( stream );
if ( !external )
FT_FREE( stream );
}
}
/**************************************************************************
*
* The macro FT_COMPONENT is used in trace mode. It is an implicit
* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
* messages during execution.
*/
#undef FT_COMPONENT
#define FT_COMPONENT objs
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/**** ****/
/**** ****/
/**** FACE, SIZE & GLYPH SLOT OBJECTS ****/
/**** ****/
/**** ****/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
static FT_Error
ft_glyphslot_init( FT_GlyphSlot slot )
{
FT_Driver driver = slot->face->driver;
FT_Driver_Class clazz = driver->clazz;
FT_Memory memory = driver->root.memory;
FT_Error error = FT_Err_Ok;
FT_Slot_Internal internal = NULL;
slot->library = driver->root.library;
if ( FT_NEW( internal ) )
goto Exit;
slot->internal = internal;
if ( FT_DRIVER_USES_OUTLINES( driver ) )
error = FT_GlyphLoader_New( memory, &internal->loader );
if ( !error && clazz->init_slot )
error = clazz->init_slot( slot );
#ifdef FT_CONFIG_OPTION_SVG
/* if SVG table exists, allocate the space in `slot->other` */
if ( slot->face->face_flags & FT_FACE_FLAG_SVG )
{
FT_SVG_Document document = NULL;
if ( FT_NEW( document ) )
goto Exit;
slot->other = document;
}
#endif
Exit:
return error;
}
FT_BASE_DEF( void )
ft_glyphslot_free_bitmap( FT_GlyphSlot slot )
{
if ( slot->internal && ( slot->internal->flags & FT_GLYPH_OWN_BITMAP ) )
{
FT_Memory memory = FT_FACE_MEMORY( slot->face );
FT_FREE( slot->bitmap.buffer );
slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;
}
else
{
/* assume that the bitmap buffer was stolen or not */
/* allocated from the heap */
slot->bitmap.buffer = NULL;
}
}
/* overflow-resistant presetting of bitmap position and dimensions; */
/* also check whether the size is too large for rendering */
FT_BASE_DEF( FT_Bool )
ft_glyphslot_preset_bitmap( FT_GlyphSlot slot,
FT_Render_Mode mode,
const FT_Vector* origin )
{
FT_Outline* outline = &slot->outline;
FT_Bitmap* bitmap = &slot->bitmap;
FT_Pixel_Mode pixel_mode;
FT_BBox cbox, pbox;
FT_Pos x_shift = 0;
FT_Pos y_shift = 0;
FT_Pos x_left, y_top;
FT_Pos width, height, pitch;
if ( slot->format == FT_GLYPH_FORMAT_SVG )
{
FT_Module module;
SVG_Service svg_service;
module = FT_Get_Module( slot->library, "ot-svg" );
svg_service = (SVG_Service)module->clazz->module_interface;
return (FT_Bool)svg_service->preset_slot( module, slot, FALSE );
}
else if ( slot->format != FT_GLYPH_FORMAT_OUTLINE )
return 1;
if ( origin )
{
x_shift = origin->x;
y_shift = origin->y;
}
/* compute the control box, and grid-fit it, */
/* taking into account the origin shift */
FT_Outline_Get_CBox( outline, &cbox );
/* rough estimate of pixel box */
pbox.xMin = ( cbox.xMin >> 6 ) + ( x_shift >> 6 );
pbox.yMin = ( cbox.yMin >> 6 ) + ( y_shift >> 6 );
pbox.xMax = ( cbox.xMax >> 6 ) + ( x_shift >> 6 );
pbox.yMax = ( cbox.yMax >> 6 ) + ( y_shift >> 6 );
/* tiny remainder box */
cbox.xMin = ( cbox.xMin & 63 ) + ( x_shift & 63 );
cbox.yMin = ( cbox.yMin & 63 ) + ( y_shift & 63 );
cbox.xMax = ( cbox.xMax & 63 ) + ( x_shift & 63 );
cbox.yMax = ( cbox.yMax & 63 ) + ( y_shift & 63 );
switch ( mode )
{
case FT_RENDER_MODE_MONO:
pixel_mode = FT_PIXEL_MODE_MONO;
#if 1
/* x */
/* undocumented but confirmed: bbox values get rounded; */
/* we do asymmetric rounding so that the center of a pixel */
/* gets always included */
pbox.xMin += ( cbox.xMin + 31 ) >> 6;
pbox.xMax += ( cbox.xMax + 32 ) >> 6;
/* if the bbox collapsed, we add a pixel based on the total */
/* rounding remainder to cover most of the original cbox */
if ( pbox.xMin == pbox.xMax )
{
if ( ( ( cbox.xMin + 31 ) & 63 ) - 31 +
( ( cbox.xMax + 32 ) & 63 ) - 32 < 0 )
pbox.xMin -= 1;
else
pbox.xMax += 1;
}
/* y */
pbox.yMin += ( cbox.yMin + 31 ) >> 6;
pbox.yMax += ( cbox.yMax + 32 ) >> 6;
if ( pbox.yMin == pbox.yMax )
{
if ( ( ( cbox.yMin + 31 ) & 63 ) - 31 +
( ( cbox.yMax + 32 ) & 63 ) - 32 < 0 )
pbox.yMin -= 1;
else
pbox.yMax += 1;
}
break;
#else
goto Adjust;
#endif
case FT_RENDER_MODE_LCD:
pixel_mode = FT_PIXEL_MODE_LCD;
ft_lcd_padding( &cbox, slot, mode );
goto Adjust;
case FT_RENDER_MODE_LCD_V:
pixel_mode = FT_PIXEL_MODE_LCD_V;
ft_lcd_padding( &cbox, slot, mode );
goto Adjust;
case FT_RENDER_MODE_NORMAL:
case FT_RENDER_MODE_LIGHT:
default:
pixel_mode = FT_PIXEL_MODE_GRAY;
Adjust:
pbox.xMin += cbox.xMin >> 6;
pbox.yMin += cbox.yMin >> 6;
pbox.xMax += ( cbox.xMax + 63 ) >> 6;
pbox.yMax += ( cbox.yMax + 63 ) >> 6;
}
x_left = pbox.xMin;
y_top = pbox.yMax;
width = pbox.xMax - pbox.xMin;
height = pbox.yMax - pbox.yMin;
switch ( pixel_mode )
{
case FT_PIXEL_MODE_MONO:
pitch = ( ( width + 15 ) >> 4 ) << 1;
break;
case FT_PIXEL_MODE_LCD:
width *= 3;
pitch = FT_PAD_CEIL( width, 4 );
break;
case FT_PIXEL_MODE_LCD_V:
height *= 3;
/* fall through */
case FT_PIXEL_MODE_GRAY:
default:
pitch = width;
}
slot->bitmap_left = (FT_Int)x_left;
slot->bitmap_top = (FT_Int)y_top;
bitmap->pixel_mode = (unsigned char)pixel_mode;
bitmap->num_grays = 256;
bitmap->width = (unsigned int)width;
bitmap->rows = (unsigned int)height;
bitmap->pitch = pitch;
if ( pbox.xMin < -0x8000 || pbox.xMax > 0x7FFF ||
pbox.yMin < -0x8000 || pbox.yMax > 0x7FFF )
{
FT_TRACE3(( "ft_glyphslot_preset_bitmap: [%ld %ld %ld %ld]\n",
pbox.xMin, pbox.yMin, pbox.xMax, pbox.yMax ));
return 1;
}
return 0;
}
FT_BASE_DEF( void )
ft_glyphslot_set_bitmap( FT_GlyphSlot slot,
FT_Byte* buffer )
{
ft_glyphslot_free_bitmap( slot );
slot->bitmap.buffer = buffer;
FT_ASSERT( (slot->internal->flags & FT_GLYPH_OWN_BITMAP) == 0 );
}
FT_BASE_DEF( FT_Error )
ft_glyphslot_alloc_bitmap( FT_GlyphSlot slot,
FT_ULong size )
{
FT_Memory memory = FT_FACE_MEMORY( slot->face );
FT_Error error;
if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP )
FT_FREE( slot->bitmap.buffer );
else
slot->internal->flags |= FT_GLYPH_OWN_BITMAP;
FT_MEM_ALLOC( slot->bitmap.buffer, size );
return error;
}
static void
ft_glyphslot_clear( FT_GlyphSlot slot )
{
/* free bitmap if needed */
ft_glyphslot_free_bitmap( slot );
/* clear all public fields in the glyph slot */
slot->glyph_index = 0;
FT_ZERO( &slot->metrics );
FT_ZERO( &slot->outline );
slot->bitmap.width = 0;
slot->bitmap.rows = 0;
slot->bitmap.pitch = 0;
slot->bitmap.pixel_mode = 0;
/* `slot->bitmap.buffer' has been handled by ft_glyphslot_free_bitmap */
slot->bitmap_left = 0;
slot->bitmap_top = 0;
slot->num_subglyphs = 0;
slot->subglyphs = NULL;
slot->control_data = NULL;
slot->control_len = 0;
#ifndef FT_CONFIG_OPTION_SVG
slot->other = NULL;
#else
if ( !( slot->face->face_flags & FT_FACE_FLAG_SVG ) )
slot->other = NULL;
else
{
if ( slot->internal->flags & FT_GLYPH_OWN_GZIP_SVG )
{
FT_Memory memory = slot->face->memory;
FT_SVG_Document doc = (FT_SVG_Document)slot->other;
FT_FREE( doc->svg_document );
slot->internal->load_flags &= ~FT_GLYPH_OWN_GZIP_SVG;
}
}
#endif
slot->format = FT_GLYPH_FORMAT_NONE;
slot->linearHoriAdvance = 0;
slot->linearVertAdvance = 0;
slot->advance.x = 0;
slot->advance.y = 0;
slot->lsb_delta = 0;
slot->rsb_delta = 0;
}
static void
ft_glyphslot_done( FT_GlyphSlot slot )
{
FT_Driver driver = slot->face->driver;
FT_Driver_Class clazz = driver->clazz;
FT_Memory memory = driver->root.memory;
#ifdef FT_CONFIG_OPTION_SVG
if ( slot->face->face_flags & FT_FACE_FLAG_SVG )
{
/* free memory in case SVG was there */
if ( slot->internal->flags & FT_GLYPH_OWN_GZIP_SVG )
{
FT_SVG_Document doc = (FT_SVG_Document)slot->other;
FT_FREE( doc->svg_document );
slot->internal->flags &= ~FT_GLYPH_OWN_GZIP_SVG;
}
FT_FREE( slot->other );
}
#endif
if ( clazz->done_slot )
clazz->done_slot( slot );
/* free bitmap buffer if needed */
ft_glyphslot_free_bitmap( slot );
/* slot->internal might be NULL in out-of-memory situations */
if ( slot->internal )
{
/* free glyph loader */
if ( FT_DRIVER_USES_OUTLINES( driver ) )
{
FT_GlyphLoader_Done( slot->internal->loader );
slot->internal->loader = NULL;
}
FT_FREE( slot->internal );
}
}
/* documentation is in ftobjs.h */
FT_BASE_DEF( FT_Error )
FT_New_GlyphSlot( FT_Face face,
FT_GlyphSlot *aslot )
{
FT_Error error;
FT_Driver driver;
FT_Driver_Class clazz;
FT_Memory memory;
FT_GlyphSlot slot = NULL;
if ( !face )
return FT_THROW( Invalid_Face_Handle );
if ( !face->driver )
return FT_THROW( Invalid_Argument );
driver = face->driver;
clazz = driver->clazz;
memory = driver->root.memory;
FT_TRACE4(( "FT_New_GlyphSlot: Creating new slot object\n" ));
if ( !FT_ALLOC( slot, clazz->slot_object_size ) )
{
slot->face = face;
error = ft_glyphslot_init( slot );
if ( error )
{
ft_glyphslot_done( slot );
FT_FREE( slot );
goto Exit;
}
slot->next = face->glyph;
face->glyph = slot;
if ( aslot )
*aslot = slot;
}
else if ( aslot )
*aslot = NULL;
Exit:
FT_TRACE4(( "FT_New_GlyphSlot: Return 0x%x\n", error ));
return error;
}
/* documentation is in ftobjs.h */
FT_BASE_DEF( void )
FT_Done_GlyphSlot( FT_GlyphSlot slot )
{
if ( slot )
{
FT_Driver driver = slot->face->driver;
FT_Memory memory = driver->root.memory;
FT_GlyphSlot prev;
FT_GlyphSlot cur;
/* Remove slot from its parent face's list */
prev = NULL;
cur = slot->face->glyph;
while ( cur )
{
if ( cur == slot )
{
if ( !prev )
slot->face->glyph = cur->next;
else
prev->next = cur->next;
/* finalize client-specific data */
if ( slot->generic.finalizer )
slot->generic.finalizer( slot );
ft_glyphslot_done( slot );
FT_FREE( slot );
break;
}
prev = cur;
cur = cur->next;
}
}
}
/* documentation is in freetype.h */
FT_EXPORT_DEF( void )
FT_Set_Transform( FT_Face face,
FT_Matrix* matrix,
FT_Vector* delta )
{
FT_Face_Internal internal;
if ( !face )
return;
internal = face->internal;
internal->transform_flags = 0;
if ( !matrix )
{
internal->transform_matrix.xx = 0x10000L;
internal->transform_matrix.xy = 0;
internal->transform_matrix.yx = 0;
internal->transform_matrix.yy = 0x10000L;
matrix = &internal->transform_matrix;
}
else
internal->transform_matrix = *matrix;
/* set transform_flags bit flag 0 if `matrix' isn't the identity */
if ( ( matrix->xy | matrix->yx ) ||
matrix->xx != 0x10000L ||
matrix->yy != 0x10000L )
internal->transform_flags |= 1;
if ( !delta )
{
internal->transform_delta.x = 0;
internal->transform_delta.y = 0;
delta = &internal->transform_delta;
}
else
internal->transform_delta = *delta;
/* set transform_flags bit flag 1 if `delta' isn't the null vector */
if ( delta->x | delta->y )
internal->transform_flags |= 2;
}
/* documentation is in freetype.h */
FT_EXPORT_DEF( void )
FT_Get_Transform( FT_Face face,
FT_Matrix* matrix,
FT_Vector* delta )
{
FT_Face_Internal internal;
if ( !face )
return;
internal = face->internal;
if ( matrix )
*matrix = internal->transform_matrix;
if ( delta )
*delta = internal->transform_delta;
}
static FT_Renderer
ft_lookup_glyph_renderer( FT_GlyphSlot slot );
#ifdef GRID_FIT_METRICS
static void
ft_glyphslot_grid_fit_metrics( FT_GlyphSlot slot,
FT_Bool vertical )
{
FT_Glyph_Metrics* metrics = &slot->metrics;
FT_Pos right, bottom;
if ( vertical )
{
metrics->horiBearingX = FT_PIX_FLOOR( metrics->horiBearingX );
metrics->horiBearingY = FT_PIX_CEIL_LONG( metrics->horiBearingY );
right = FT_PIX_CEIL_LONG( ADD_LONG( metrics->vertBearingX,
metrics->width ) );
bottom = FT_PIX_CEIL_LONG( ADD_LONG( metrics->vertBearingY,
metrics->height ) );
metrics->vertBearingX = FT_PIX_FLOOR( metrics->vertBearingX );
metrics->vertBearingY = FT_PIX_FLOOR( metrics->vertBearingY );
metrics->width = SUB_LONG( right,
metrics->vertBearingX );
metrics->height = SUB_LONG( bottom,
metrics->vertBearingY );
}
else
{
metrics->vertBearingX = FT_PIX_FLOOR( metrics->vertBearingX );
metrics->vertBearingY = FT_PIX_FLOOR( metrics->vertBearingY );
right = FT_PIX_CEIL_LONG( ADD_LONG( metrics->horiBearingX,
metrics->width ) );
bottom = FT_PIX_FLOOR( SUB_LONG( metrics->horiBearingY,
metrics->height ) );
metrics->horiBearingX = FT_PIX_FLOOR( metrics->horiBearingX );
metrics->horiBearingY = FT_PIX_CEIL_LONG( metrics->horiBearingY );
metrics->width = SUB_LONG( right,
metrics->horiBearingX );
metrics->height = SUB_LONG( metrics->horiBearingY,
bottom );
}
metrics->horiAdvance = FT_PIX_ROUND_LONG( metrics->horiAdvance );
metrics->vertAdvance = FT_PIX_ROUND_LONG( metrics->vertAdvance );
}
#endif /* GRID_FIT_METRICS */
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Error )
FT_Load_Glyph( FT_Face face,
FT_UInt glyph_index,
FT_Int32 load_flags )
{
FT_Error error;
FT_Driver driver;
FT_GlyphSlot slot;
FT_Library library;
FT_Bool autohint = FALSE;
FT_Module hinter;
TT_Face ttface = (TT_Face)face;
if ( !face || !face->size || !face->glyph )
return FT_THROW( Invalid_Face_Handle );
/* The validity test for `glyph_index' is performed by the */
/* font drivers. */
slot = face->glyph;
ft_glyphslot_clear( slot );
driver = face->driver;
library = driver->root.library;
hinter = library->auto_hinter;
/* undefined scale means no scale */
if ( face->size->metrics.x_ppem == 0 ||
face->size->metrics.y_ppem == 0 )
load_flags |= FT_LOAD_NO_SCALE;
/* resolve load flags dependencies */
if ( load_flags & FT_LOAD_NO_RECURSE )
load_flags |= FT_LOAD_NO_SCALE |
FT_LOAD_IGNORE_TRANSFORM;
if ( load_flags & FT_LOAD_NO_SCALE )
{
load_flags |= FT_LOAD_NO_HINTING |
FT_LOAD_NO_BITMAP;
load_flags &= ~FT_LOAD_RENDER;
}
if ( load_flags & FT_LOAD_BITMAP_METRICS_ONLY )
load_flags &= ~FT_LOAD_RENDER;
/*
* Determine whether we need to auto-hint or not.
* The general rules are:
*
* - Do only auto-hinting if we have
*
* - a hinter module,
* - a scalable font,
* - not a tricky font, and
* - no transforms except simple slants and/or rotations by
* integer multiples of 90 degrees.
*
* - Then, auto-hint if FT_LOAD_FORCE_AUTOHINT is set or if we don't
* have a native font hinter.
*
* - Otherwise, auto-hint for LIGHT hinting mode or if there isn't
* any hinting bytecode in the TrueType/OpenType font.
*
* - Exception: The font is `tricky' and requires the native hinter to
* load properly.
*/
if ( hinter &&
!( load_flags & FT_LOAD_NO_HINTING ) &&
!( load_flags & FT_LOAD_NO_AUTOHINT ) &&
FT_IS_SCALABLE( face ) &&
!FT_IS_TRICKY( face ) &&
( ( load_flags & FT_LOAD_IGNORE_TRANSFORM ) ||
( face->internal->transform_matrix.yx == 0 &&
face->internal->transform_matrix.xx != 0 ) ||
( face->internal->transform_matrix.xx == 0 &&
face->internal->transform_matrix.yx != 0 ) ) )
{
if ( ( load_flags & FT_LOAD_FORCE_AUTOHINT ) ||
!FT_DRIVER_HAS_HINTER( driver ) )
autohint = TRUE;
else
{
FT_Render_Mode mode = FT_LOAD_TARGET_MODE( load_flags );
FT_Bool is_light_type1;
/* only the new Adobe engine (for both CFF and Type 1) is `light'; */
/* we use `strstr' to catch both `Type 1' and `CID Type 1' */
is_light_type1 =
ft_strstr( FT_Get_Font_Format( face ), "Type 1" ) != NULL &&
((PS_Driver)driver)->hinting_engine == FT_HINTING_ADOBE;
/* the check for `num_locations' assures that we actually */
/* test for instructions in a TTF and not in a CFF-based OTF */
/* */
/* since `maxSizeOfInstructions' might be unreliable, we */
/* check the size of the `fpgm' and `prep' tables, too -- */
/* the assumption is that there don't exist real TTFs where */
/* both `fpgm' and `prep' tables are missing */
if ( ( mode == FT_RENDER_MODE_LIGHT &&
( !FT_DRIVER_HINTS_LIGHTLY( driver ) &&
!is_light_type1 ) ) ||
( FT_IS_SFNT( face ) &&
ttface->num_locations &&
ttface->max_profile.maxSizeOfInstructions == 0 &&
ttface->font_program_size == 0 &&
ttface->cvt_program_size == 0 ) )
autohint = TRUE;
}
}
if ( autohint )
{
FT_AutoHinter_Interface hinting;
/* XXX: The use of the `FT_LOAD_XXX_ONLY` flags is not very */
/* elegant. */
/* try to load SVG documents if available */
if ( FT_HAS_SVG( face ) )
{
error = driver->clazz->load_glyph( slot, face->size,
glyph_index,
load_flags | FT_LOAD_SVG_ONLY );
if ( !error && slot->format == FT_GLYPH_FORMAT_SVG )
goto Load_Ok;
}
/* try to load embedded bitmaps if available */
if ( FT_HAS_FIXED_SIZES( face ) &&
( load_flags & FT_LOAD_NO_BITMAP ) == 0 )
{
error = driver->clazz->load_glyph( slot, face->size,
glyph_index,
load_flags | FT_LOAD_SBITS_ONLY );
if ( !error && slot->format == FT_GLYPH_FORMAT_BITMAP )
goto Load_Ok;
}
{
FT_Face_Internal internal = face->internal;
FT_Int transform_flags = internal->transform_flags;
/* since the auto-hinter calls FT_Load_Glyph by itself, */
/* make sure that glyphs aren't transformed */
internal->transform_flags = 0;
/* load auto-hinted outline */
hinting = (FT_AutoHinter_Interface)hinter->clazz->module_interface;
error = hinting->load_glyph( (FT_AutoHinter)hinter,
slot, face->size,
glyph_index, load_flags );
internal->transform_flags = transform_flags;
}
}
else
{
error = driver->clazz->load_glyph( slot,
face->size,
glyph_index,
load_flags );
if ( error )
goto Exit;
if ( slot->format == FT_GLYPH_FORMAT_OUTLINE )
{
/* check that the loaded outline is correct */
error = FT_Outline_Check( &slot->outline );
if ( error )
goto Exit;
#ifdef GRID_FIT_METRICS
if ( !( load_flags & FT_LOAD_NO_HINTING ) )
ft_glyphslot_grid_fit_metrics(
slot,
FT_BOOL( load_flags & FT_LOAD_VERTICAL_LAYOUT ) );
#endif
}
}
Load_Ok:
/* compute the advance */
if ( load_flags & FT_LOAD_VERTICAL_LAYOUT )
{
slot->advance.x = 0;
slot->advance.y = slot->metrics.vertAdvance;
}
else
{
slot->advance.x = slot->metrics.horiAdvance;
slot->advance.y = 0;
}
/* compute the linear advance in 16.16 pixels */
if ( ( load_flags & FT_LOAD_LINEAR_DESIGN ) == 0 &&
FT_IS_SCALABLE( face ) )
{
FT_Size_Metrics* metrics = &face->size->metrics;
/* it's tricky! */
slot->linearHoriAdvance = FT_MulDiv( slot->linearHoriAdvance,
metrics->x_scale, 64 );
slot->linearVertAdvance = FT_MulDiv( slot->linearVertAdvance,
metrics->y_scale, 64 );
}
if ( ( load_flags & FT_LOAD_IGNORE_TRANSFORM ) == 0 )
{
FT_Face_Internal internal = face->internal;
/* now, transform the glyph image if needed */
if ( internal->transform_flags )
{
/* get renderer */
FT_Renderer renderer = ft_lookup_glyph_renderer( slot );
if ( renderer )
error = renderer->clazz->transform_glyph(
renderer, slot,
&internal->transform_matrix,
&internal->transform_delta );
else if ( slot->format == FT_GLYPH_FORMAT_OUTLINE )
{
/* apply `standard' transformation if no renderer is available */
if ( internal->transform_flags & 1 )
FT_Outline_Transform( &slot->outline,
&internal->transform_matrix );
if ( internal->transform_flags & 2 )
FT_Outline_Translate( &slot->outline,
internal->transform_delta.x,
internal->transform_delta.y );
}
/* transform advance */
FT_Vector_Transform( &slot->advance, &internal->transform_matrix );
}
}
slot->glyph_index = glyph_index;
slot->internal->load_flags = load_flags;
/* do we need to render the image or preset the bitmap now? */
if ( !error &&
( load_flags & FT_LOAD_NO_SCALE ) == 0 &&
slot->format != FT_GLYPH_FORMAT_BITMAP &&
slot->format != FT_GLYPH_FORMAT_COMPOSITE )
{
FT_Render_Mode mode = FT_LOAD_TARGET_MODE( load_flags );
if ( mode == FT_RENDER_MODE_NORMAL &&
load_flags & FT_LOAD_MONOCHROME )
mode = FT_RENDER_MODE_MONO;
if ( load_flags & FT_LOAD_RENDER )
error = FT_Render_Glyph( slot, mode );
else
ft_glyphslot_preset_bitmap( slot, mode, NULL );
}
#ifdef FT_DEBUG_LEVEL_TRACE
FT_TRACE5(( "FT_Load_Glyph: index %d, flags 0x%x\n",
glyph_index, load_flags ));
FT_TRACE5(( " bitmap %dx%d %s, %s (mode %d)\n",
slot->bitmap.width,
slot->bitmap.rows,
slot->outline.points ?
slot->bitmap.buffer ? "rendered"
: "preset"
:
slot->internal->flags & FT_GLYPH_OWN_BITMAP ? "owned"
: "unowned",
pixel_modes[slot->bitmap.pixel_mode],
slot->bitmap.pixel_mode ));
FT_TRACE5(( "\n" ));
FT_TRACE5(( " x advance: %f\n", slot->advance.x / 64.0 ));
FT_TRACE5(( " y advance: %f\n", slot->advance.y / 64.0 ));
FT_TRACE5(( " linear x advance: %f\n",
slot->linearHoriAdvance / 65536.0 ));
FT_TRACE5(( " linear y advance: %f\n",
slot->linearVertAdvance / 65536.0 ));
{
FT_Glyph_Metrics* metrics = &slot->metrics;
FT_TRACE5(( " metrics:\n" ));
FT_TRACE5(( " width: %f\n", metrics->width / 64.0 ));
FT_TRACE5(( " height: %f\n", metrics->height / 64.0 ));
FT_TRACE5(( "\n" ));
FT_TRACE5(( " horiBearingX: %f\n", metrics->horiBearingX / 64.0 ));
FT_TRACE5(( " horiBearingY: %f\n", metrics->horiBearingY / 64.0 ));
FT_TRACE5(( " horiAdvance: %f\n", metrics->horiAdvance / 64.0 ));
FT_TRACE5(( "\n" ));
FT_TRACE5(( " vertBearingX: %f\n", metrics->vertBearingX / 64.0 ));
FT_TRACE5(( " vertBearingY: %f\n", metrics->vertBearingY / 64.0 ));
FT_TRACE5(( " vertAdvance: %f\n", metrics->vertAdvance / 64.0 ));
}
#endif
Exit:
return error;
}
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Error )
FT_Load_Char( FT_Face face,
FT_ULong char_code,
FT_Int32 load_flags )
{
FT_UInt glyph_index;
if ( !face )
return FT_THROW( Invalid_Face_Handle );
glyph_index = (FT_UInt)char_code;
if ( face->charmap )
glyph_index = FT_Get_Char_Index( face, char_code );
return FT_Load_Glyph( face, glyph_index, load_flags );
}
/* destructor for sizes list */
static void
destroy_size( FT_Memory memory,
FT_Size size,
FT_Driver driver )
{
/* finalize client-specific data */
if ( size->generic.finalizer )
size->generic.finalizer( size );
/* finalize format-specific stuff */
if ( driver->clazz->done_size )
driver->clazz->done_size( size );
FT_FREE( size->internal );
FT_FREE( size );
}
static void
ft_cmap_done_internal( FT_CMap cmap );
static void
destroy_charmaps( FT_Face face,
FT_Memory memory )
{
FT_Int n;
if ( !face )
return;
for ( n = 0; n < face->num_charmaps; n++ )
{
FT_CMap cmap = FT_CMAP( face->charmaps[n] );
ft_cmap_done_internal( cmap );
face->charmaps[n] = NULL;
}
FT_FREE( face->charmaps );
face->num_charmaps = 0;
}
/* destructor for faces list */
static void
destroy_face( FT_Memory memory,
FT_Face face,
FT_Driver driver )
{
FT_Driver_Class clazz = driver->clazz;
/* discard auto-hinting data */
if ( face->autohint.finalizer )
face->autohint.finalizer( face->autohint.data );
/* Discard glyph slots for this face. */
/* Beware! FT_Done_GlyphSlot() changes the field `face->glyph' */
while ( face->glyph )
FT_Done_GlyphSlot( face->glyph );
/* discard all sizes for this face */
FT_List_Finalize( &face->sizes_list,
(FT_List_Destructor)destroy_size,
memory,
driver );
face->size = NULL;
/* now discard client data */
if ( face->generic.finalizer )
face->generic.finalizer( face );
/* discard charmaps */
destroy_charmaps( face, memory );
/* finalize format-specific stuff */
if ( clazz->done_face )
clazz->done_face( face );
/* close the stream for this face if needed */
FT_Stream_Free(
face->stream,
( face->face_flags & FT_FACE_FLAG_EXTERNAL_STREAM ) != 0 );
face->stream = NULL;
/* get rid of it */
if ( face->internal )
{
FT_FREE( face->internal );
}
FT_FREE( face );
}
static void
Destroy_Driver( FT_Driver driver )
{
FT_List_Finalize( &driver->faces_list,
(FT_List_Destructor)destroy_face,
driver->root.memory,
driver );
}
/**************************************************************************
*
* @Function:
* find_unicode_charmap
*
* @Description:
* This function finds a Unicode charmap, if there is one.
* And if there is more than one, it tries to favour the more
* extensive one, i.e., one that supports UCS-4 against those which
* are limited to the BMP (said UCS-2 encoding.)
*
* This function is called from open_face() (just below), and also
* from FT_Select_Charmap( ..., FT_ENCODING_UNICODE ).
*/
static FT_Error
find_unicode_charmap( FT_Face face )
{
FT_CharMap* first;
FT_CharMap* cur;
/* caller should have already checked that `face' is valid */
FT_ASSERT( face );
first = face->charmaps;
if ( !first )
return FT_THROW( Invalid_CharMap_Handle );
/*
* The original TrueType specification(s) only specified charmap
* formats that are capable of mapping 8 or 16 bit character codes to
* glyph indices.
*
* However, recent updates to the Apple and OpenType specifications
* introduced new formats that are capable of mapping 32-bit character
* codes as well. And these are already used on some fonts, mainly to
* map non-BMP Asian ideographs as defined in Unicode.
*
* For compatibility purposes, these fonts generally come with
* *several* Unicode charmaps:
*
* - One of them in the "old" 16-bit format, that cannot access
* all glyphs in the font.
*
* - Another one in the "new" 32-bit format, that can access all
* the glyphs.
*
* This function has been written to always favor a 32-bit charmap
* when found. Otherwise, a 16-bit one is returned when found.
*/
/* Since the `interesting' table, with IDs (3,10), is normally the */
/* last one, we loop backwards. This loses with type1 fonts with */
/* non-BMP characters (<.0001%), this wins with .ttf with non-BMP */
/* chars (.01% ?), and this is the same about 99.99% of the time! */
cur = first + face->num_charmaps; /* points after the last one */
for ( ; --cur >= first; )
{
if ( cur[0]->encoding == FT_ENCODING_UNICODE )
{
/* XXX If some new encodings to represent UCS-4 are added, */
/* they should be added here. */
if ( ( cur[0]->platform_id == TT_PLATFORM_MICROSOFT &&
cur[0]->encoding_id == TT_MS_ID_UCS_4 ) ||
( cur[0]->platform_id == TT_PLATFORM_APPLE_UNICODE &&
cur[0]->encoding_id == TT_APPLE_ID_UNICODE_32 ) )
{
face->charmap = cur[0];
return FT_Err_Ok;
}
}
}
/* We do not have any UCS-4 charmap. */
/* Do the loop again and search for UCS-2 charmaps. */
cur = first + face->num_charmaps;
for ( ; --cur >= first; )
{
if ( cur[0]->encoding == FT_ENCODING_UNICODE )
{
face->charmap = cur[0];
return FT_Err_Ok;
}
}
return FT_THROW( Invalid_CharMap_Handle );
}
/**************************************************************************
*
* @Function:
* find_variant_selector_charmap
*
* @Description:
* This function finds the variant selector charmap, if there is one.
* There can only be one (platform=0, specific=5, format=14).
*/
static FT_CharMap
find_variant_selector_charmap( FT_Face face )
{
FT_CharMap* first;
FT_CharMap* end;
FT_CharMap* cur;
/* caller should have already checked that `face' is valid */
FT_ASSERT( face );
first = face->charmaps;
if ( !first )
return NULL;
end = first + face->num_charmaps; /* points after the last one */
for ( cur = first; cur < end; cur++ )
{
if ( cur[0]->platform_id == TT_PLATFORM_APPLE_UNICODE &&
cur[0]->encoding_id == TT_APPLE_ID_VARIANT_SELECTOR &&
FT_Get_CMap_Format( cur[0] ) == 14 )
return cur[0];
}
return NULL;
}
/**************************************************************************
*
* @Function:
* open_face
*
* @Description:
* This function does some work for FT_Open_Face().
*/
static FT_Error
open_face( FT_Driver driver,
FT_Stream *astream,
FT_Bool external_stream,
FT_Long face_index,
FT_Int num_params,
FT_Parameter* params,
FT_Face *aface )
{
FT_Memory memory;
FT_Driver_Class clazz;
FT_Face face = NULL;
FT_Face_Internal internal = NULL;
FT_Error error, error2;
clazz = driver->clazz;
memory = driver->root.memory;
/* allocate the face object and perform basic initialization */
if ( FT_ALLOC( face, clazz->face_object_size ) )
goto Fail;
face->driver = driver;
face->memory = memory;
face->stream = *astream;
/* set the FT_FACE_FLAG_EXTERNAL_STREAM bit for FT_Done_Face */
if ( external_stream )
face->face_flags |= FT_FACE_FLAG_EXTERNAL_STREAM;
if ( FT_NEW( internal ) )
goto Fail;
face->internal = internal;
#ifdef FT_CONFIG_OPTION_INCREMENTAL
{
int i;
face->internal->incremental_interface = NULL;
for ( i = 0; i < num_params && !face->internal->incremental_interface;
i++ )
if ( params[i].tag == FT_PARAM_TAG_INCREMENTAL )
face->internal->incremental_interface =
(FT_Incremental_Interface)params[i].data;
}
#endif
face->internal->random_seed = -1;
if ( clazz->init_face )
error = clazz->init_face( *astream,
face,
(FT_Int)face_index,
num_params,
params );
*astream = face->stream; /* Stream may have been changed. */
if ( error )
goto Fail;
/* select Unicode charmap by default */
error2 = find_unicode_charmap( face );
/* if no Unicode charmap can be found, FT_Err_Invalid_CharMap_Handle */
/* is returned. */
/* no error should happen, but we want to play safe */
if ( error2 && FT_ERR_NEQ( error2, Invalid_CharMap_Handle ) )
{
error = error2;
goto Fail;
}
*aface = face;
Fail:
if ( error )
{
destroy_charmaps( face, memory );
if ( clazz->done_face )
clazz->done_face( face );
FT_FREE( internal );
FT_FREE( face );
*aface = NULL;
}
return error;
}
/* there's a Mac-specific extended implementation of FT_New_Face() */
/* in src/base/ftmac.c */
#ifndef FT_MACINTOSH
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Error )
FT_New_Face( FT_Library library,
const char* pathname,
FT_Long face_index,
FT_Face *aface )
{
FT_Open_Args args;
/* test for valid `library' and `aface' delayed to `FT_Open_Face' */
if ( !pathname )
return FT_THROW( Invalid_Argument );
args.flags = FT_OPEN_PATHNAME;
args.pathname = (char*)pathname;
args.stream = NULL;
return ft_open_face_internal( library, &args, face_index, aface, 1 );
}
#endif
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Error )
FT_New_Memory_Face( FT_Library library,
const FT_Byte* file_base,
FT_Long file_size,
FT_Long face_index,
FT_Face *aface )
{
FT_Open_Args args;
/* test for valid `library' and `face' delayed to `FT_Open_Face' */
if ( !file_base )
return FT_THROW( Invalid_Argument );
args.flags = FT_OPEN_MEMORY;
args.memory_base = file_base;
args.memory_size = file_size;
args.stream = NULL;
return ft_open_face_internal( library, &args, face_index, aface, 1 );
}
#ifdef FT_CONFIG_OPTION_MAC_FONTS
/* The behavior here is very similar to that in base/ftmac.c, but it */
/* is designed to work on non-mac systems, so no mac specific calls. */
/* */
/* We look at the file and determine if it is a mac dfont file or a mac */
/* resource file, or a macbinary file containing a mac resource file. */
/* */
/* Unlike ftmac I'm not going to look at a `FOND'. I don't really see */
/* the point, especially since there may be multiple `FOND' resources. */
/* Instead I'll just look for `sfnt' and `POST' resources, ordered as */
/* they occur in the file. */
/* */
/* Note that multiple `POST' resources do not mean multiple postscript */
/* fonts; they all get jammed together to make what is essentially a */
/* pfb file. */
/* */
/* We aren't interested in `NFNT' or `FONT' bitmap resources. */
/* */
/* As soon as we get an `sfnt' load it into memory and pass it off to */
/* FT_Open_Face. */
/* */
/* If we have a (set of) `POST' resources, massage them into a (memory) */
/* pfb file and pass that to FT_Open_Face. (As with ftmac.c I'm not */
/* going to try to save the kerning info. After all that lives in the */
/* `FOND' which isn't in the file containing the `POST' resources so */
/* we don't really have access to it. */
/* Finalizer for a memory stream; gets called by FT_Done_Face(). */
/* It frees the memory it uses. */
/* From `ftmac.c'. */
static void
memory_stream_close( FT_Stream stream )
{
FT_Memory memory = stream->memory;
FT_FREE( stream->base );
stream->size = 0;
stream->close = NULL;
}
/* Create a new memory stream from a buffer and a size. */
/* From `ftmac.c'. */
static FT_Error
new_memory_stream( FT_Library library,
FT_Byte* base,
FT_ULong size,
FT_Stream_CloseFunc close,
FT_Stream *astream )
{
FT_Error error;
FT_Memory memory;
FT_Stream stream = NULL;
if ( !library )
return FT_THROW( Invalid_Library_Handle );
if ( !base )
return FT_THROW( Invalid_Argument );
*astream = NULL;
memory = library->memory;
if ( FT_NEW( stream ) )
goto Exit;
FT_Stream_OpenMemory( stream, base, size );
stream->close = close;
*astream = stream;
Exit:
return error;
}
/* Create a new FT_Face given a buffer and a driver name. */
/* From `ftmac.c'. */
FT_LOCAL_DEF( FT_Error )
open_face_from_buffer( FT_Library library,
FT_Byte* base,
FT_ULong size,
FT_Long face_index,
const char* driver_name,
FT_Face *aface )
{
FT_Open_Args args;
FT_Error error;
FT_Stream stream = NULL;
FT_Memory memory = library->memory;
error = new_memory_stream( library,
base,
size,
memory_stream_close,
&stream );
if ( error )
{
FT_FREE( base );
return error;
}
args.flags = FT_OPEN_STREAM;
args.stream = stream;
if ( driver_name )
{
args.flags = args.flags | FT_OPEN_DRIVER;
args.driver = FT_Get_Module( library, driver_name );
}
#ifdef FT_MACINTOSH
/* At this point, the face index has served its purpose; */
/* whoever calls this function has already used it to */
/* locate the correct font data. We should not propagate */
/* this index to FT_Open_Face() (unless it is negative). */
if ( face_index > 0 )
face_index &= 0x7FFF0000L; /* retain GX data */
#endif
error = ft_open_face_internal( library, &args, face_index, aface, 0 );
if ( !error )
(*aface)->face_flags &= ~FT_FACE_FLAG_EXTERNAL_STREAM;
else
#ifdef FT_MACINTOSH
FT_Stream_Free( stream, 0 );
#else
{
FT_Stream_Close( stream );
FT_FREE( stream );
}
#endif
return error;
}
/* Look up `TYP1' or `CID ' table from sfnt table directory. */
/* `offset' and `length' must exclude the binary header in tables. */
/* Type 1 and CID-keyed font drivers should recognize sfnt-wrapped */
/* format too. Here, since we can't expect that the TrueType font */
/* driver is loaded unconditionally, we must parse the font by */
/* ourselves. We are only interested in the name of the table and */
/* the offset. */
static FT_Error
ft_lookup_PS_in_sfnt_stream( FT_Stream stream,
FT_Long face_index,
FT_ULong* offset,
FT_ULong* length,
FT_Bool* is_sfnt_cid )
{
FT_Error error;
FT_UShort numTables;
FT_Long pstable_index;
FT_ULong tag;
int i;
*offset = 0;
*length = 0;
*is_sfnt_cid = FALSE;
/* TODO: support for sfnt-wrapped PS/CID in TTC format */
/* version check for 'typ1' (should be ignored?) */
if ( FT_READ_ULONG( tag ) )
return error;
if ( tag != TTAG_typ1 )
return FT_THROW( Unknown_File_Format );
if ( FT_READ_USHORT( numTables ) )
return error;
if ( FT_STREAM_SKIP( 2 * 3 ) ) /* skip binary search header */
return error;
pstable_index = -1;
*is_sfnt_cid = FALSE;
for ( i = 0; i < numTables; i++ )
{
if ( FT_READ_ULONG( tag ) || FT_STREAM_SKIP( 4 ) ||
FT_READ_ULONG( *offset ) || FT_READ_ULONG( *length ) )
return error;
if ( tag == TTAG_CID )
{
pstable_index++;
*offset += 22;
*length -= 22;
*is_sfnt_cid = TRUE;
if ( face_index < 0 )
return FT_Err_Ok;
}
else if ( tag == TTAG_TYP1 )
{
pstable_index++;
*offset += 24;
*length -= 24;
*is_sfnt_cid = FALSE;
if ( face_index < 0 )
return FT_Err_Ok;
}
if ( face_index >= 0 && pstable_index == face_index )
return FT_Err_Ok;
}
return FT_THROW( Table_Missing );
}
FT_LOCAL_DEF( FT_Error )
open_face_PS_from_sfnt_stream( FT_Library library,
FT_Stream stream,
FT_Long face_index,
FT_Int num_params,
FT_Parameter *params,
FT_Face *aface )
{
FT_Error error;
FT_Memory memory = library->memory;
FT_ULong offset, length;
FT_ULong pos;
FT_Bool is_sfnt_cid;
FT_Byte* sfnt_ps = NULL;
FT_UNUSED( num_params );
FT_UNUSED( params );
/* ignore GX stuff */
if ( face_index > 0 )
face_index &= 0xFFFFL;
pos = FT_STREAM_POS();
error = ft_lookup_PS_in_sfnt_stream( stream,
face_index,
&offset,
&length,
&is_sfnt_cid );
if ( error )
goto Exit;
if ( offset > stream->size )
{
FT_TRACE2(( "open_face_PS_from_sfnt_stream: invalid table offset\n" ));
error = FT_THROW( Invalid_Table );
goto Exit;
}
else if ( length > stream->size - offset )
{
FT_TRACE2(( "open_face_PS_from_sfnt_stream: invalid table length\n" ));
error = FT_THROW( Invalid_Table );
goto Exit;
}
error = FT_Stream_Seek( stream, pos + offset );
if ( error )
goto Exit;
if ( FT_QALLOC( sfnt_ps, (FT_Long)length ) )
goto Exit;
error = FT_Stream_Read( stream, (FT_Byte *)sfnt_ps, length );
if ( error )
{
FT_FREE( sfnt_ps );
goto Exit;
}
error = open_face_from_buffer( library,
sfnt_ps,
length,
FT_MIN( face_index, 0 ),
is_sfnt_cid ? "cid" : "type1",
aface );
Exit:
{
FT_Error error1;
if ( FT_ERR_EQ( error, Unknown_File_Format ) )
{
error1 = FT_Stream_Seek( stream, pos );
if ( error1 )
return error1;
}
return error;
}
}
#ifndef FT_MACINTOSH
/* The resource header says we've got resource_cnt `POST' (type1) */
/* resources in this file. They all need to be coalesced into */
/* one lump which gets passed on to the type1 driver. */
/* Here can be only one PostScript font in a file so face_index */
/* must be 0 (or -1). */
/* */
static FT_Error
Mac_Read_POST_Resource( FT_Library library,
FT_Stream stream,
FT_Long *offsets,
FT_Long resource_cnt,
FT_Long face_index,
FT_Face *aface )
{
FT_Error error = FT_ERR( Cannot_Open_Resource );
FT_Memory memory = library->memory;
FT_Byte* pfb_data = NULL;
int i, type, flags;
FT_ULong len;
FT_ULong pfb_len, pfb_pos, pfb_lenpos;
FT_ULong rlen, temp;
if ( face_index == -1 )
face_index = 0;
if ( face_index != 0 )
return error;
/* Find the length of all the POST resources, concatenated. Assume */
/* worst case (each resource in its own section). */
pfb_len = 0;
for ( i = 0; i < resource_cnt; i++ )
{
error = FT_Stream_Seek( stream, (FT_ULong)offsets[i] );
if ( error )
goto Exit;
if ( FT_READ_ULONG( temp ) ) /* actually LONG */
goto Exit;
/* FT2 allocator takes signed long buffer length,
* too large value causing overflow should be checked
*/
FT_TRACE4(( " POST fragment #%d: length=0x%08lx"
" total pfb_len=0x%08lx\n",
i, temp, pfb_len + temp + 6 ));
if ( FT_MAC_RFORK_MAX_LEN < temp ||
FT_MAC_RFORK_MAX_LEN - temp < pfb_len + 6 )
{
FT_TRACE2(( " MacOS resource length cannot exceed"
" 0x%08lx\n",
FT_MAC_RFORK_MAX_LEN ));
error = FT_THROW( Invalid_Offset );
goto Exit;
}
pfb_len += temp + 6;
}
FT_TRACE2(( " total buffer size to concatenate"
" %ld POST fragments: 0x%08lx\n",
resource_cnt, pfb_len + 2 ));
if ( pfb_len + 2 < 6 )
{
FT_TRACE2(( " too long fragment length makes"
" pfb_len confused: pfb_len=0x%08lx\n",
pfb_len ));
error = FT_THROW( Array_Too_Large );
goto Exit;
}
if ( FT_QALLOC( pfb_data, (FT_Long)pfb_len + 2 ) )
goto Exit;
pfb_data[0] = 0x80;
pfb_data[1] = 1; /* Ascii section */
pfb_data[2] = 0; /* 4-byte length, fill in later */
pfb_data[3] = 0;
pfb_data[4] = 0;
pfb_data[5] = 0;
pfb_pos = 6;
pfb_lenpos = 2;
len = 0;
type = 1;
for ( i = 0; i < resource_cnt; i++ )
{
error = FT_Stream_Seek( stream, (FT_ULong)offsets[i] );
if ( error )
goto Exit2;
if ( FT_READ_ULONG( rlen ) )
goto Exit2;
/* FT2 allocator takes signed long buffer length,
* too large fragment length causing overflow should be checked
*/
if ( 0x7FFFFFFFUL < rlen )
{
error = FT_THROW( Invalid_Offset );
goto Exit2;
}
if ( FT_READ_USHORT( flags ) )
goto Exit2;
FT_TRACE3(( "POST fragment[%d]:"
" offsets=0x%08lx, rlen=0x%08lx, flags=0x%04x\n",
i, offsets[i], rlen, flags ));
error = FT_ERR( Array_Too_Large );
/* postpone the check of `rlen longer than buffer' */
/* until `FT_Stream_Read' */
if ( ( flags >> 8 ) == 0 ) /* Comment, should not be loaded */
{
FT_TRACE3(( " Skip POST fragment #%d because it is a comment\n",
i ));
continue;
}
/* the flags are part of the resource, so rlen >= 2, */
/* but some fonts declare rlen = 0 for empty fragment */
if ( rlen > 2 )
rlen -= 2;
else
rlen = 0;
if ( ( flags >> 8 ) == type )
len += rlen;
else
{
FT_TRACE3(( " Write POST fragment #%d header (4-byte) to buffer"
" %p + 0x%08lx\n",
i, (void*)pfb_data, pfb_lenpos ));
if ( pfb_lenpos + 3 > pfb_len + 2 )
goto Exit2;
pfb_data[pfb_lenpos ] = (FT_Byte)( len );
pfb_data[pfb_lenpos + 1] = (FT_Byte)( len >> 8 );
pfb_data[pfb_lenpos + 2] = (FT_Byte)( len >> 16 );
pfb_data[pfb_lenpos + 3] = (FT_Byte)( len >> 24 );
if ( ( flags >> 8 ) == 5 ) /* End of font mark */
break;
FT_TRACE3(( " Write POST fragment #%d header (6-byte) to buffer"
" %p + 0x%08lx\n",
i, (void*)pfb_data, pfb_pos ));
if ( pfb_pos + 6 > pfb_len + 2 )
goto Exit2;
pfb_data[pfb_pos++] = 0x80;
type = flags >> 8;
len = rlen;
pfb_data[pfb_pos++] = (FT_Byte)type;
pfb_lenpos = pfb_pos;
pfb_data[pfb_pos++] = 0; /* 4-byte length, fill in later */
pfb_data[pfb_pos++] = 0;
pfb_data[pfb_pos++] = 0;
pfb_data[pfb_pos++] = 0;
}
if ( pfb_pos > pfb_len || pfb_pos + rlen > pfb_len )
goto Exit2;
FT_TRACE3(( " Load POST fragment #%d (%ld byte) to buffer"
" %p + 0x%08lx\n",
i, rlen, (void*)pfb_data, pfb_pos ));
error = FT_Stream_Read( stream, (FT_Byte *)pfb_data + pfb_pos, rlen );
if ( error )
goto Exit2;
pfb_pos += rlen;
}
error = FT_ERR( Array_Too_Large );
if ( pfb_pos + 2 > pfb_len + 2 )
goto Exit2;
pfb_data[pfb_pos++] = 0x80;
pfb_data[pfb_pos++] = 3;
if ( pfb_lenpos + 3 > pfb_len + 2 )
goto Exit2;
pfb_data[pfb_lenpos ] = (FT_Byte)( len );
pfb_data[pfb_lenpos + 1] = (FT_Byte)( len >> 8 );
pfb_data[pfb_lenpos + 2] = (FT_Byte)( len >> 16 );
pfb_data[pfb_lenpos + 3] = (FT_Byte)( len >> 24 );
return open_face_from_buffer( library,
pfb_data,
pfb_pos,
face_index,
"type1",
aface );
Exit2:
if ( FT_ERR_EQ( error, Array_Too_Large ) )
FT_TRACE2(( " Abort due to too-short buffer to store"
" all POST fragments\n" ));
else if ( FT_ERR_EQ( error, Invalid_Offset ) )
FT_TRACE2(( " Abort due to invalid offset in a POST fragment\n" ));
if ( error )
error = FT_ERR( Cannot_Open_Resource );
FT_FREE( pfb_data );
Exit:
return error;
}
/* The resource header says we've got resource_cnt `sfnt' */
/* (TrueType/OpenType) resources in this file. Look through */
/* them for the one indicated by face_index, load it into mem, */
/* pass it on to the truetype driver, and return it. */
/* */
static FT_Error
Mac_Read_sfnt_Resource( FT_Library library,
FT_Stream stream,
FT_Long *offsets,
FT_Long resource_cnt,
FT_Long face_index,
FT_Face *aface )
{
FT_Memory memory = library->memory;
FT_Byte* sfnt_data = NULL;
FT_Error error;
FT_ULong flag_offset;
FT_Long rlen;
int is_cff;
FT_Long face_index_in_resource = 0;
if ( face_index < 0 )
face_index = -face_index - 1;
if ( face_index >= resource_cnt )
return FT_THROW( Cannot_Open_Resource );
flag_offset = (FT_ULong)offsets[face_index];
error = FT_Stream_Seek( stream, flag_offset );
if ( error )
goto Exit;
if ( FT_READ_LONG( rlen ) )
goto Exit;
if ( rlen < 1 )
return FT_THROW( Cannot_Open_Resource );
if ( (FT_ULong)rlen > FT_MAC_RFORK_MAX_LEN )
return FT_THROW( Invalid_Offset );
error = open_face_PS_from_sfnt_stream( library,
stream,
face_index,
0, NULL,
aface );
if ( !error )
goto Exit;
/* rewind sfnt stream before open_face_PS_from_sfnt_stream() */
error = FT_Stream_Seek( stream, flag_offset + 4 );
if ( error )
goto Exit;
if ( FT_QALLOC( sfnt_data, rlen ) )
return error;
error = FT_Stream_Read( stream, (FT_Byte *)sfnt_data, (FT_ULong)rlen );
if ( error ) {
FT_FREE( sfnt_data );
goto Exit;
}
is_cff = rlen > 4 && !ft_memcmp( sfnt_data, "OTTO", 4 );
error = open_face_from_buffer( library,
sfnt_data,
(FT_ULong)rlen,
face_index_in_resource,
is_cff ? "cff" : "truetype",
aface );
Exit:
return error;
}
/* Check for a valid resource fork header, or a valid dfont */
/* header. In a resource fork the first 16 bytes are repeated */
/* at the location specified by bytes 4-7. In a dfont bytes */
/* 4-7 point to 16 bytes of zeroes instead. */
/* */
static FT_Error
IsMacResource( FT_Library library,
FT_Stream stream,
FT_Long resource_offset,
FT_Long face_index,
FT_Face *aface )
{
FT_Memory memory = library->memory;
FT_Error error;
FT_Long map_offset, rdata_pos;
FT_Long *data_offsets;
FT_Long count;
error = FT_Raccess_Get_HeaderInfo( library, stream, resource_offset,
&map_offset, &rdata_pos );
if ( error )
return error;
/* POST resources must be sorted to concatenate properly */
error = FT_Raccess_Get_DataOffsets( library, stream,
map_offset, rdata_pos,
TTAG_POST, TRUE,
&data_offsets, &count );
if ( !error )
{
error = Mac_Read_POST_Resource( library, stream, data_offsets, count,
face_index, aface );
FT_FREE( data_offsets );
/* POST exists in an LWFN providing a single face */
if ( !error )
(*aface)->num_faces = 1;
return error;
}
/* sfnt resources should not be sorted to preserve the face order by
QuickDraw API */
error = FT_Raccess_Get_DataOffsets( library, stream,
map_offset, rdata_pos,
TTAG_sfnt, FALSE,
&data_offsets, &count );
if ( !error )
{
FT_Long face_index_internal = face_index % count;
error = Mac_Read_sfnt_Resource( library, stream, data_offsets, count,
face_index_internal, aface );
FT_FREE( data_offsets );
if ( !error )
(*aface)->num_faces = count;
}
return error;
}
/* Check for a valid macbinary header, and if we find one */
/* check that the (flattened) resource fork in it is valid. */
/* */
static FT_Error
IsMacBinary( FT_Library library,
FT_Stream stream,
FT_Long face_index,
FT_Face *aface )
{
unsigned char header[128];
FT_Error error;
FT_Long dlen, offset;
if ( !stream )
return FT_THROW( Invalid_Stream_Operation );
error = FT_Stream_Seek( stream, 0 );
if ( error )
goto Exit;
error = FT_Stream_Read( stream, (FT_Byte*)header, 128 );
if ( error )
goto Exit;
if ( header[ 0] != 0 ||
header[74] != 0 ||
header[82] != 0 ||
header[ 1] == 0 ||
header[ 1] > 33 ||
header[63] != 0 ||
header[2 + header[1]] != 0 ||
header[0x53] > 0x7F )
return FT_THROW( Unknown_File_Format );
dlen = ( header[0x53] << 24 ) |
( header[0x54] << 16 ) |
( header[0x55] << 8 ) |
header[0x56];
#if 0
rlen = ( header[0x57] << 24 ) |
( header[0x58] << 16 ) |
( header[0x59] << 8 ) |
header[0x5A];
#endif /* 0 */
offset = 128 + ( ( dlen + 127 ) & ~127 );
return IsMacResource( library, stream, offset, face_index, aface );
Exit:
return error;
}
static FT_Error
load_face_in_embedded_rfork( FT_Library library,
FT_Stream stream,
FT_Long face_index,
FT_Face *aface,
const FT_Open_Args *args )
{
#undef FT_COMPONENT
#define FT_COMPONENT raccess
FT_Memory memory = library->memory;
FT_Error error = FT_ERR( Unknown_File_Format );
FT_UInt i;
char* file_names[FT_RACCESS_N_RULES];
FT_Long offsets[FT_RACCESS_N_RULES];
FT_Error errors[FT_RACCESS_N_RULES];
FT_Bool is_darwin_vfs, vfs_rfork_has_no_font = FALSE; /* not tested */
FT_Open_Args args2;
FT_Stream stream2 = NULL;
FT_Raccess_Guess( library, stream,
args->pathname, file_names, offsets, errors );
for ( i = 0; i < FT_RACCESS_N_RULES; i++ )
{
is_darwin_vfs = ft_raccess_rule_by_darwin_vfs( library, i );
if ( is_darwin_vfs && vfs_rfork_has_no_font )
{
FT_TRACE3(( "Skip rule %d: darwin vfs resource fork"
" is already checked and"
" no font is found\n",
i ));
continue;
}
if ( errors[i] )
{
FT_TRACE3(( "Error 0x%x has occurred in rule %d\n",
errors[i], i ));
continue;
}
args2.flags = FT_OPEN_PATHNAME;
args2.pathname = file_names[i] ? file_names[i] : args->pathname;
FT_TRACE3(( "Try rule %d: %s (offset=%ld) ...",
i, args2.pathname, offsets[i] ));
error = FT_Stream_New( library, &args2, &stream2 );
if ( is_darwin_vfs && FT_ERR_EQ( error, Cannot_Open_Stream ) )
vfs_rfork_has_no_font = TRUE;
if ( error )
{
FT_TRACE3(( "failed\n" ));
continue;
}
error = IsMacResource( library, stream2, offsets[i],
face_index, aface );
FT_Stream_Free( stream2, 0 );
FT_TRACE3(( "%s\n", error ? "failed": "successful" ));
if ( !error )
break;
else if ( is_darwin_vfs )
vfs_rfork_has_no_font = TRUE;
}
for (i = 0; i < FT_RACCESS_N_RULES; i++)
{
if ( file_names[i] )
FT_FREE( file_names[i] );
}
/* Caller (load_mac_face) requires FT_Err_Unknown_File_Format. */
if ( error )
error = FT_ERR( Unknown_File_Format );
return error;
#undef FT_COMPONENT
#define FT_COMPONENT objs
}
/* Check for some macintosh formats without Carbon framework. */
/* Is this a macbinary file? If so look at the resource fork. */
/* Is this a mac dfont file? */
/* Is this an old style resource fork? (in data) */
/* Else call load_face_in_embedded_rfork to try extra rules */
/* (defined in `ftrfork.c'). */
/* */
static FT_Error
load_mac_face( FT_Library library,
FT_Stream stream,
FT_Long face_index,
FT_Face *aface,
const FT_Open_Args *args )
{
FT_Error error;
FT_UNUSED( args );
error = IsMacBinary( library, stream, face_index, aface );
if ( FT_ERR_EQ( error, Unknown_File_Format ) )
{
#undef FT_COMPONENT
#define FT_COMPONENT raccess
#ifdef FT_DEBUG_LEVEL_TRACE
FT_TRACE3(( "Try as dfont: " ));
if ( !( args->flags & FT_OPEN_MEMORY ) )
FT_TRACE3(( "%s ...", args->pathname ));
#endif
error = IsMacResource( library, stream, 0, face_index, aface );
FT_TRACE3(( "%s\n", error ? "failed" : "successful" ));
#undef FT_COMPONENT
#define FT_COMPONENT objs
}
if ( ( FT_ERR_EQ( error, Unknown_File_Format ) ||
FT_ERR_EQ( error, Invalid_Stream_Operation ) ) &&
( args->flags & FT_OPEN_PATHNAME ) )
error = load_face_in_embedded_rfork( library, stream,
face_index, aface, args );
return error;
}
#endif
#endif /* !FT_MACINTOSH && FT_CONFIG_OPTION_MAC_FONTS */
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Error )
FT_Open_Face( FT_Library library,
const FT_Open_Args* args,
FT_Long face_index,
FT_Face *aface )
{
return ft_open_face_internal( library, args, face_index, aface, 1 );
}
static FT_Error
ft_open_face_internal( FT_Library library,
const FT_Open_Args* args,
FT_Long face_index,
FT_Face *aface,
FT_Bool test_mac_fonts )
{
FT_Error error;
FT_Driver driver = NULL;
FT_Memory memory = NULL;
FT_Stream stream = NULL;
FT_Face face = NULL;
FT_ListNode node = NULL;
FT_Bool external_stream;
FT_Module* cur;
FT_Module* limit;
#ifndef FT_CONFIG_OPTION_MAC_FONTS
FT_UNUSED( test_mac_fonts );
#endif
/* only use lower 31 bits together with sign bit */
if ( face_index > 0 )
face_index &= 0x7FFFFFFFL;
else
{
face_index = -face_index;
face_index &= 0x7FFFFFFFL;
face_index = -face_index;
}
#ifdef FT_DEBUG_LEVEL_TRACE
FT_TRACE3(( "FT_Open_Face: " ));
if ( face_index < 0 )
FT_TRACE3(( "Requesting number of faces and named instances\n"));
else
{
FT_TRACE3(( "Requesting face %ld", face_index & 0xFFFFL ));
if ( face_index & 0x7FFF0000L )
FT_TRACE3(( ", named instance %ld", face_index >> 16 ));
FT_TRACE3(( "\n" ));
}
#endif
/* test for valid `library' delayed to `FT_Stream_New' */
if ( ( !aface && face_index >= 0 ) || !args )
return FT_THROW( Invalid_Argument );
external_stream = FT_BOOL( ( args->flags & FT_OPEN_STREAM ) &&
args->stream );
/* create input stream */
error = FT_Stream_New( library, args, &stream );
if ( error )
goto Fail3;
memory = library->memory;
/* If the font driver is specified in the `args' structure, use */
/* it. Otherwise, we scan the list of registered drivers. */
if ( ( args->flags & FT_OPEN_DRIVER ) && args->driver )
{
driver = FT_DRIVER( args->driver );
/* not all modules are drivers, so check... */
if ( FT_MODULE_IS_DRIVER( driver ) )
{
FT_Int num_params = 0;
FT_Parameter* params = NULL;
if ( args->flags & FT_OPEN_PARAMS )
{
num_params = args->num_params;
params = args->params;
}
error = open_face( driver, &stream, external_stream, face_index,
num_params, params, &face );
if ( !error )
goto Success;
}
else
error = FT_THROW( Invalid_Handle );
FT_Stream_Free( stream, external_stream );
goto Fail;
}
else
{
error = FT_ERR( Missing_Module );
/* check each font driver for an appropriate format */
cur = library->modules;
limit = cur + library->num_modules;
for ( ; cur < limit; cur++ )
{
/* not all modules are font drivers, so check... */
if ( FT_MODULE_IS_DRIVER( cur[0] ) )
{
FT_Int num_params = 0;
FT_Parameter* params = NULL;
driver = FT_DRIVER( cur[0] );
if ( args->flags & FT_OPEN_PARAMS )
{
num_params = args->num_params;
params = args->params;
}
error = open_face( driver, &stream, external_stream, face_index,
num_params, params, &face );
if ( !error )
goto Success;
#ifdef FT_CONFIG_OPTION_MAC_FONTS
if ( test_mac_fonts &&
ft_strcmp( cur[0]->clazz->module_name, "truetype" ) == 0 &&
FT_ERR_EQ( error, Table_Missing ) )
{
/* TrueType but essential tables are missing */
error = FT_Stream_Seek( stream, 0 );
if ( error )
break;
error = open_face_PS_from_sfnt_stream( library,
stream,
face_index,
num_params,
params,
aface );
if ( !error )
{
FT_Stream_Free( stream, external_stream );
return error;
}
}
#endif
if ( FT_ERR_NEQ( error, Unknown_File_Format ) )
goto Fail3;
}
}
Fail3:
/* If we are on the mac, and we get an */
/* FT_Err_Invalid_Stream_Operation it may be because we have an */
/* empty data fork, so we need to check the resource fork. */
if ( FT_ERR_NEQ( error, Cannot_Open_Stream ) &&
FT_ERR_NEQ( error, Unknown_File_Format ) &&
FT_ERR_NEQ( error, Invalid_Stream_Operation ) )
goto Fail2;
#if !defined( FT_MACINTOSH ) && defined( FT_CONFIG_OPTION_MAC_FONTS )
if ( test_mac_fonts )
{
error = load_mac_face( library, stream, face_index, aface, args );
if ( !error )
{
/* We don't want to go to Success here. We've already done */
/* that. On the other hand, if we succeeded we still need to */
/* close this stream (we opened a different stream which */
/* extracted the interesting information out of this stream */
/* here. That stream will still be open and the face will */
/* point to it). */
FT_Stream_Free( stream, external_stream );
return error;
}
}
if ( FT_ERR_NEQ( error, Unknown_File_Format ) )
goto Fail2;
#endif /* !FT_MACINTOSH && FT_CONFIG_OPTION_MAC_FONTS */
/* no driver is able to handle this format */
error = FT_THROW( Unknown_File_Format );
Fail2:
FT_Stream_Free( stream, external_stream );
goto Fail;
}
Success:
FT_TRACE4(( "FT_Open_Face: New face object, adding to list\n" ));
/* add the face object to its driver's list */
if ( FT_QNEW( node ) )
goto Fail;
node->data = face;
/* don't assume driver is the same as face->driver, so use */
/* face->driver instead. */
FT_List_Add( &face->driver->faces_list, node );
/* now allocate a glyph slot object for the face */
FT_TRACE4(( "FT_Open_Face: Creating glyph slot\n" ));
if ( face_index >= 0 )
{
error = FT_New_GlyphSlot( face, NULL );
if ( error )
goto Fail;
/* finally, allocate a size object for the face */
{
FT_Size size;
FT_TRACE4(( "FT_Open_Face: Creating size object\n" ));
error = FT_New_Size( face, &size );
if ( error )
goto Fail;
face->size = size;
}
}
/* some checks */
if ( FT_IS_SCALABLE( face ) )
{
if ( face->height < 0 )
face->height = (FT_Short)-face->height;
if ( !FT_HAS_VERTICAL( face ) )
face->max_advance_height = (FT_Short)face->height;
}
if ( FT_HAS_FIXED_SIZES( face ) )
{
FT_Int i;
for ( i = 0; i < face->num_fixed_sizes; i++ )
{
FT_Bitmap_Size* bsize = face->available_sizes + i;
if ( bsize->height < 0 )
bsize->height = -bsize->height;
if ( bsize->x_ppem < 0 )
bsize->x_ppem = -bsize->x_ppem;
if ( bsize->y_ppem < 0 )
bsize->y_ppem = -bsize->y_ppem;
/* check whether negation actually has worked */
if ( bsize->height < 0 || bsize->x_ppem < 0 || bsize->y_ppem < 0 )
{
FT_TRACE0(( "FT_Open_Face:"
" Invalid bitmap dimensions for strike %d,"
" now disabled\n", i ));
bsize->width = 0;
bsize->height = 0;
bsize->size = 0;
bsize->x_ppem = 0;
bsize->y_ppem = 0;
}
}
}
/* initialize internal face data */
{
FT_Face_Internal internal = face->internal;
internal->transform_matrix.xx = 0x10000L;
internal->transform_matrix.xy = 0;
internal->transform_matrix.yx = 0;
internal->transform_matrix.yy = 0x10000L;
internal->transform_delta.x = 0;
internal->transform_delta.y = 0;
internal->refcount = 1;
internal->no_stem_darkening = -1;
#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
/* Per-face filtering can only be set up by FT_Face_Properties */
internal->lcd_filter_func = NULL;
#endif
}
if ( aface )
*aface = face;
else
FT_Done_Face( face );
goto Exit;
Fail:
if ( node )
FT_Done_Face( face ); /* face must be in the driver's list */
else if ( face )
destroy_face( memory, face, driver );
Exit:
#ifdef FT_DEBUG_LEVEL_TRACE
if ( !error && face_index < 0 )
{
FT_TRACE3(( "FT_Open_Face: The font has %ld face%s\n",
face->num_faces,
face->num_faces == 1 ? "" : "s" ));
FT_TRACE3(( " and %ld named instance%s for face %ld\n",
face->style_flags >> 16,
( face->style_flags >> 16 ) == 1 ? "" : "s",
-face_index - 1 ));
}
#endif
FT_TRACE4(( "FT_Open_Face: Return 0x%x\n", error ));
return error;
}
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Error )
FT_Attach_File( FT_Face face,
const char* filepathname )
{
FT_Open_Args open;
/* test for valid `face' delayed to `FT_Attach_Stream' */
if ( !filepathname )
return FT_THROW( Invalid_Argument );
open.stream = NULL;
open.flags = FT_OPEN_PATHNAME;
open.pathname = (char*)filepathname;
return FT_Attach_Stream( face, &open );
}
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Error )
FT_Attach_Stream( FT_Face face,
FT_Open_Args* parameters )
{
FT_Stream stream;
FT_Error error;
FT_Driver driver;
FT_Driver_Class clazz;
/* test for valid `parameters' delayed to `FT_Stream_New' */
if ( !face )
return FT_THROW( Invalid_Face_Handle );
driver = face->driver;
if ( !driver )
return FT_THROW( Invalid_Driver_Handle );
error = FT_Stream_New( driver->root.library, parameters, &stream );
if ( error )
goto Exit;
/* we implement FT_Attach_Stream in each driver through the */
/* `attach_file' interface */
error = FT_ERR( Unimplemented_Feature );
clazz = driver->clazz;
if ( clazz->attach_file )
error = clazz->attach_file( face, stream );
/* close the attached stream */
FT_Stream_Free( stream,
FT_BOOL( parameters->stream &&
( parameters->flags & FT_OPEN_STREAM ) ) );
Exit:
return error;
}
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Error )
FT_Reference_Face( FT_Face face )
{
if ( !face )
return FT_THROW( Invalid_Face_Handle );
face->internal->refcount++;
return FT_Err_Ok;
}
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Error )
FT_Done_Face( FT_Face face )
{
FT_Error error;
FT_Driver driver;
FT_Memory memory;
FT_ListNode node;
error = FT_ERR( Invalid_Face_Handle );
if ( face && face->driver )
{
face->internal->refcount--;
if ( face->internal->refcount > 0 )
error = FT_Err_Ok;
else
{
driver = face->driver;
memory = driver->root.memory;
/* find face in driver's list */
node = FT_List_Find( &driver->faces_list, face );
if ( node )
{
/* remove face object from the driver's list */
FT_List_Remove( &driver->faces_list, node );
FT_FREE( node );
/* now destroy the object proper */
destroy_face( memory, face, driver );
error = FT_Err_Ok;
}
}
}
return error;
}
/* documentation is in ftobjs.h */
FT_EXPORT_DEF( FT_Error )
FT_New_Size( FT_Face face,
FT_Size *asize )
{
FT_Error error;
FT_Memory memory;
FT_Driver driver;
FT_Driver_Class clazz;
FT_Size size = NULL;
FT_ListNode node = NULL;
FT_Size_Internal internal = NULL;
if ( !face )
return FT_THROW( Invalid_Face_Handle );
if ( !asize )
return FT_THROW( Invalid_Argument );
if ( !face->driver )
return FT_THROW( Invalid_Driver_Handle );
*asize = NULL;
driver = face->driver;
clazz = driver->clazz;
memory = face->memory;
/* Allocate new size object and perform basic initialisation */
if ( FT_ALLOC( size, clazz->size_object_size ) || FT_QNEW( node ) )
goto Exit;
size->face = face;
if ( FT_NEW( internal ) )
goto Exit;
size->internal = internal;
if ( clazz->init_size )
error = clazz->init_size( size );
/* in case of success, add to the face's list */
if ( !error )
{
*asize = size;
node->data = size;
FT_List_Add( &face->sizes_list, node );
}
Exit:
if ( error )
{
FT_FREE( node );
if ( size )
FT_FREE( size->internal );
FT_FREE( size );
}
return error;
}
/* documentation is in ftobjs.h */
FT_EXPORT_DEF( FT_Error )
FT_Done_Size( FT_Size size )
{
FT_Error error;
FT_Driver driver;
FT_Memory memory;
FT_Face face;
FT_ListNode node;
if ( !size )
return FT_THROW( Invalid_Size_Handle );
face = size->face;
if ( !face )
return FT_THROW( Invalid_Face_Handle );
driver = face->driver;
if ( !driver )
return FT_THROW( Invalid_Driver_Handle );
memory = driver->root.memory;
error = FT_Err_Ok;
node = FT_List_Find( &face->sizes_list, size );
if ( node )
{
FT_List_Remove( &face->sizes_list, node );
FT_FREE( node );
if ( face->size == size )
{
face->size = NULL;
if ( face->sizes_list.head )
face->size = (FT_Size)(face->sizes_list.head->data);
}
destroy_size( memory, size, driver );
}
else
error = FT_THROW( Invalid_Size_Handle );
return error;
}
/* documentation is in ftobjs.h */
FT_BASE_DEF( FT_Error )
FT_Match_Size( FT_Face face,
FT_Size_Request req,
FT_Bool ignore_width,
FT_ULong* size_index )
{
FT_Int i;
FT_Long w, h;
if ( !FT_HAS_FIXED_SIZES( face ) )
return FT_THROW( Invalid_Face_Handle );
/* FT_Bitmap_Size doesn't provide enough info... */
if ( req->type != FT_SIZE_REQUEST_TYPE_NOMINAL )
return FT_THROW( Unimplemented_Feature );
w = FT_REQUEST_WIDTH ( req );
h = FT_REQUEST_HEIGHT( req );
if ( req->width && !req->height )
h = w;
else if ( !req->width && req->height )
w = h;
w = FT_PIX_ROUND( w );
h = FT_PIX_ROUND( h );
if ( !w || !h )
return FT_THROW( Invalid_Pixel_Size );
for ( i = 0; i < face->num_fixed_sizes; i++ )
{
FT_Bitmap_Size* bsize = face->available_sizes + i;
if ( h != FT_PIX_ROUND( bsize->y_ppem ) )
continue;
if ( w == FT_PIX_ROUND( bsize->x_ppem ) || ignore_width )
{
FT_TRACE3(( "FT_Match_Size: bitmap strike %d matches\n", i ));
if ( size_index )
*size_index = (FT_ULong)i;
return FT_Err_Ok;
}
}
FT_TRACE3(( "FT_Match_Size: no matching bitmap strike\n" ));
return FT_THROW( Invalid_Pixel_Size );
}
/* documentation is in ftobjs.h */
FT_BASE_DEF( void )
ft_synthesize_vertical_metrics( FT_Glyph_Metrics* metrics,
FT_Pos advance )
{
FT_Pos height = metrics->height;
/* compensate for glyph with bbox above/below the baseline */
if ( metrics->horiBearingY < 0 )
{
if ( height < metrics->horiBearingY )
height = metrics->horiBearingY;
}
else if ( metrics->horiBearingY > 0 )
height -= metrics->horiBearingY;
/* the factor 1.2 is a heuristical value */
if ( !advance )
advance = height * 12 / 10;
metrics->vertBearingX = metrics->horiBearingX - metrics->horiAdvance / 2;
metrics->vertBearingY = ( advance - height ) / 2;
metrics->vertAdvance = advance;
}
static void
ft_recompute_scaled_metrics( FT_Face face,
FT_Size_Metrics* metrics )
{
/* Compute root ascender, descender, test height, and max_advance */
#ifdef GRID_FIT_METRICS
metrics->ascender = FT_PIX_CEIL( FT_MulFix( face->ascender,
metrics->y_scale ) );
metrics->descender = FT_PIX_FLOOR( FT_MulFix( face->descender,
metrics->y_scale ) );
metrics->height = FT_PIX_ROUND( FT_MulFix( face->height,
metrics->y_scale ) );
metrics->max_advance = FT_PIX_ROUND( FT_MulFix( face->max_advance_width,
metrics->x_scale ) );
#else /* !GRID_FIT_METRICS */
metrics->ascender = FT_MulFix( face->ascender,
metrics->y_scale );
metrics->descender = FT_MulFix( face->descender,
metrics->y_scale );
metrics->height = FT_MulFix( face->height,
metrics->y_scale );
metrics->max_advance = FT_MulFix( face->max_advance_width,
metrics->x_scale );
#endif /* !GRID_FIT_METRICS */
}
FT_BASE_DEF( void )
FT_Select_Metrics( FT_Face face,
FT_ULong strike_index )
{
FT_Size_Metrics* metrics;
FT_Bitmap_Size* bsize;
metrics = &face->size->metrics;
bsize = face->available_sizes + strike_index;
metrics->x_ppem = (FT_UShort)( ( bsize->x_ppem + 32 ) >> 6 );
metrics->y_ppem = (FT_UShort)( ( bsize->y_ppem + 32 ) >> 6 );
if ( FT_IS_SCALABLE( face ) )
{
metrics->x_scale = FT_DivFix( bsize->x_ppem,
face->units_per_EM );
metrics->y_scale = FT_DivFix( bsize->y_ppem,
face->units_per_EM );
ft_recompute_scaled_metrics( face, metrics );
}
else
{
metrics->x_scale = 1L << 16;
metrics->y_scale = 1L << 16;
metrics->ascender = bsize->y_ppem;
metrics->descender = 0;
metrics->height = bsize->height << 6;
metrics->max_advance = bsize->x_ppem;
}
}
FT_BASE_DEF( FT_Error )
FT_Request_Metrics( FT_Face face,
FT_Size_Request req )
{
FT_Error error = FT_Err_Ok;
FT_Size_Metrics* metrics;
metrics = &face->size->metrics;
if ( FT_IS_SCALABLE( face ) )
{
FT_Long w = 0, h = 0, scaled_w = 0, scaled_h = 0;
switch ( req->type )
{
case FT_SIZE_REQUEST_TYPE_NOMINAL:
w = h = face->units_per_EM;
break;
case FT_SIZE_REQUEST_TYPE_REAL_DIM:
w = h = face->ascender - face->descender;
break;
case FT_SIZE_REQUEST_TYPE_BBOX:
w = face->bbox.xMax - face->bbox.xMin;
h = face->bbox.yMax - face->bbox.yMin;
break;
case FT_SIZE_REQUEST_TYPE_CELL:
w = face->max_advance_width;
h = face->ascender - face->descender;
break;
case FT_SIZE_REQUEST_TYPE_SCALES:
metrics->x_scale = (FT_Fixed)req->width;
metrics->y_scale = (FT_Fixed)req->height;
if ( !metrics->x_scale )
metrics->x_scale = metrics->y_scale;
else if ( !metrics->y_scale )
metrics->y_scale = metrics->x_scale;
goto Calculate_Ppem;
case FT_SIZE_REQUEST_TYPE_MAX:
break;
}
/* to be on the safe side */
if ( w < 0 )
w = -w;
if ( h < 0 )
h = -h;
scaled_w = FT_REQUEST_WIDTH ( req );
scaled_h = FT_REQUEST_HEIGHT( req );
/* determine scales */
if ( req->width )
{
metrics->x_scale = FT_DivFix( scaled_w, w );
if ( req->height )
{
metrics->y_scale = FT_DivFix( scaled_h, h );
if ( req->type == FT_SIZE_REQUEST_TYPE_CELL )
{
if ( metrics->y_scale > metrics->x_scale )
metrics->y_scale = metrics->x_scale;
else
metrics->x_scale = metrics->y_scale;
}
}
else
{
metrics->y_scale = metrics->x_scale;
scaled_h = FT_MulDiv( scaled_w, h, w );
}
}
else
{
metrics->x_scale = metrics->y_scale = FT_DivFix( scaled_h, h );
scaled_w = FT_MulDiv( scaled_h, w, h );
}
Calculate_Ppem:
/* calculate the ppems */
if ( req->type != FT_SIZE_REQUEST_TYPE_NOMINAL )
{
scaled_w = FT_MulFix( face->units_per_EM, metrics->x_scale );
scaled_h = FT_MulFix( face->units_per_EM, metrics->y_scale );
}
scaled_w = ( scaled_w + 32 ) >> 6;
scaled_h = ( scaled_h + 32 ) >> 6;
if ( scaled_w > (FT_Long)FT_USHORT_MAX ||
scaled_h > (FT_Long)FT_USHORT_MAX )
{
FT_ERROR(( "FT_Request_Metrics: Resulting ppem size too large\n" ));
error = FT_ERR( Invalid_Pixel_Size );
goto Exit;
}
metrics->x_ppem = (FT_UShort)scaled_w;
metrics->y_ppem = (FT_UShort)scaled_h;
ft_recompute_scaled_metrics( face, metrics );
}
else
{
FT_ZERO( metrics );
metrics->x_scale = 1L << 16;
metrics->y_scale = 1L << 16;
}
Exit:
return error;
}
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Error )
FT_Select_Size( FT_Face face,
FT_Int strike_index )
{
FT_Error error = FT_Err_Ok;
FT_Driver_Class clazz;
if ( !face || !FT_HAS_FIXED_SIZES( face ) )
return FT_THROW( Invalid_Face_Handle );
if ( strike_index < 0 || strike_index >= face->num_fixed_sizes )
return FT_THROW( Invalid_Argument );
clazz = face->driver->clazz;
if ( clazz->select_size )
{
error = clazz->select_size( face->size, (FT_ULong)strike_index );
FT_TRACE5(( "FT_Select_Size (%s driver):\n",
face->driver->root.clazz->module_name ));
}
else
{
FT_Select_Metrics( face, (FT_ULong)strike_index );
FT_TRACE5(( "FT_Select_Size:\n" ));
}
#ifdef FT_DEBUG_LEVEL_TRACE
{
FT_Size_Metrics* metrics = &face->size->metrics;
FT_TRACE5(( " x scale: %ld (%f)\n",
metrics->x_scale, metrics->x_scale / 65536.0 ));
FT_TRACE5(( " y scale: %ld (%f)\n",
metrics->y_scale, metrics->y_scale / 65536.0 ));
FT_TRACE5(( " ascender: %f\n", metrics->ascender / 64.0 ));
FT_TRACE5(( " descender: %f\n", metrics->descender / 64.0 ));
FT_TRACE5(( " height: %f\n", metrics->height / 64.0 ));
FT_TRACE5(( " max advance: %f\n", metrics->max_advance / 64.0 ));
FT_TRACE5(( " x ppem: %d\n", metrics->x_ppem ));
FT_TRACE5(( " y ppem: %d\n", metrics->y_ppem ));
}
#endif
return error;
}
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Error )
FT_Request_Size( FT_Face face,
FT_Size_Request req )
{
FT_Error error;
FT_Driver_Class clazz;
FT_ULong strike_index;
if ( !face )
return FT_THROW( Invalid_Face_Handle );
if ( !face->size )
return FT_THROW( Invalid_Size_Handle );
if ( !req || req->width < 0 || req->height < 0 ||
req->type >= FT_SIZE_REQUEST_TYPE_MAX )
return FT_THROW( Invalid_Argument );
/* signal the auto-hinter to recompute its size metrics */
/* (if requested) */
face->size->internal->autohint_metrics.x_scale = 0;
clazz = face->driver->clazz;
if ( clazz->request_size )
{
error = clazz->request_size( face->size, req );
FT_TRACE5(( "FT_Request_Size (%s driver):\n",
face->driver->root.clazz->module_name ));
}
else if ( !FT_IS_SCALABLE( face ) && FT_HAS_FIXED_SIZES( face ) )
{
/*
* The reason that a driver doesn't have `request_size' defined is
* either that the scaling here suffices or that the supported formats
* are bitmap-only and size matching is not implemented.
*
* In the latter case, a simple size matching is done.
*/
error = FT_Match_Size( face, req, 0, &strike_index );
if ( error )
goto Exit;
return FT_Select_Size( face, (FT_Int)strike_index );
}
else
{
error = FT_Request_Metrics( face, req );
if ( error )
goto Exit;
FT_TRACE5(( "FT_Request_Size:\n" ));
}
#ifdef FT_DEBUG_LEVEL_TRACE
{
FT_Size_Metrics* metrics = &face->size->metrics;
FT_TRACE5(( " x scale: %ld (%f)\n",
metrics->x_scale, metrics->x_scale / 65536.0 ));
FT_TRACE5(( " y scale: %ld (%f)\n",
metrics->y_scale, metrics->y_scale / 65536.0 ));
FT_TRACE5(( " ascender: %f\n", metrics->ascender / 64.0 ));
FT_TRACE5(( " descender: %f\n", metrics->descender / 64.0 ));
FT_TRACE5(( " height: %f\n", metrics->height / 64.0 ));
FT_TRACE5(( " max advance: %f\n", metrics->max_advance / 64.0 ));
FT_TRACE5(( " x ppem: %d\n", metrics->x_ppem ));
FT_TRACE5(( " y ppem: %d\n", metrics->y_ppem ));
}
#endif
Exit:
return error;
}
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Error )
FT_Set_Char_Size( FT_Face face,
FT_F26Dot6 char_width,
FT_F26Dot6 char_height,
FT_UInt horz_resolution,
FT_UInt vert_resolution )
{
FT_Size_RequestRec req;
/* check of `face' delayed to `FT_Request_Size' */
if ( !char_width )
char_width = char_height;
else if ( !char_height )
char_height = char_width;
if ( !horz_resolution )
horz_resolution = vert_resolution;
else if ( !vert_resolution )
vert_resolution = horz_resolution;
if ( char_width < 1 * 64 )
char_width = 1 * 64;
if ( char_height < 1 * 64 )
char_height = 1 * 64;
if ( !horz_resolution )
horz_resolution = vert_resolution = 72;
req.type = FT_SIZE_REQUEST_TYPE_NOMINAL;
req.width = char_width;
req.height = char_height;
req.horiResolution = horz_resolution;
req.vertResolution = vert_resolution;
return FT_Request_Size( face, &req );
}
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Error )
FT_Set_Pixel_Sizes( FT_Face face,
FT_UInt pixel_width,
FT_UInt pixel_height )
{
FT_Size_RequestRec req;
/* check of `face' delayed to `FT_Request_Size' */
if ( pixel_width == 0 )
pixel_width = pixel_height;
else if ( pixel_height == 0 )
pixel_height = pixel_width;
if ( pixel_width < 1 )
pixel_width = 1;
if ( pixel_height < 1 )
pixel_height = 1;
/* use `>=' to avoid potential compiler warning on 16bit platforms */
if ( pixel_width >= 0xFFFFU )
pixel_width = 0xFFFFU;
if ( pixel_height >= 0xFFFFU )
pixel_height = 0xFFFFU;
req.type = FT_SIZE_REQUEST_TYPE_NOMINAL;
req.width = (FT_Long)( pixel_width << 6 );
req.height = (FT_Long)( pixel_height << 6 );
req.horiResolution = 0;
req.vertResolution = 0;
return FT_Request_Size( face, &req );
}
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Error )
FT_Get_Kerning( FT_Face face,
FT_UInt left_glyph,
FT_UInt right_glyph,
FT_UInt kern_mode,
FT_Vector *akerning )
{
FT_Error error = FT_Err_Ok;
FT_Driver driver;
if ( !face )
return FT_THROW( Invalid_Face_Handle );
if ( !akerning )
return FT_THROW( Invalid_Argument );
driver = face->driver;
akerning->x = 0;
akerning->y = 0;
if ( driver->clazz->get_kerning )
{
error = driver->clazz->get_kerning( face,
left_glyph,
right_glyph,
akerning );
if ( !error )
{
if ( kern_mode != FT_KERNING_UNSCALED )
{
akerning->x = FT_MulFix( akerning->x, face->size->metrics.x_scale );
akerning->y = FT_MulFix( akerning->y, face->size->metrics.y_scale );
if ( kern_mode != FT_KERNING_UNFITTED )
{
FT_Pos orig_x = akerning->x;
FT_Pos orig_y = akerning->y;
/* we scale down kerning values for small ppem values */
/* to avoid that rounding makes them too big. */
/* `25' has been determined heuristically. */
if ( face->size->metrics.x_ppem < 25 )
akerning->x = FT_MulDiv( orig_x,
face->size->metrics.x_ppem, 25 );
if ( face->size->metrics.y_ppem < 25 )
akerning->y = FT_MulDiv( orig_y,
face->size->metrics.y_ppem, 25 );
akerning->x = FT_PIX_ROUND( akerning->x );
akerning->y = FT_PIX_ROUND( akerning->y );
#ifdef FT_DEBUG_LEVEL_TRACE
{
FT_Pos orig_x_rounded = FT_PIX_ROUND( orig_x );
FT_Pos orig_y_rounded = FT_PIX_ROUND( orig_y );
if ( akerning->x != orig_x_rounded ||
akerning->y != orig_y_rounded )
FT_TRACE5(( "FT_Get_Kerning: horizontal kerning"
" (%ld, %ld) scaled down to (%ld, %ld) pixels\n",
orig_x_rounded / 64, orig_y_rounded / 64,
akerning->x / 64, akerning->y / 64 ));
}
#endif
}
}
}
}
return error;
}
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Error )
FT_Get_Track_Kerning( FT_Face face,
FT_Fixed point_size,
FT_Int degree,
FT_Fixed* akerning )
{
FT_Service_Kerning service;
FT_Error error = FT_Err_Ok;
if ( !face )
return FT_THROW( Invalid_Face_Handle );
if ( !akerning )
return FT_THROW( Invalid_Argument );
FT_FACE_FIND_SERVICE( face, service, KERNING );
if ( !service )
return FT_THROW( Unimplemented_Feature );
error = service->get_track( face,
point_size,
degree,
akerning );
return error;
}
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Error )
FT_Select_Charmap( FT_Face face,
FT_Encoding encoding )
{
FT_CharMap* cur;
FT_CharMap* limit;
if ( !face )
return FT_THROW( Invalid_Face_Handle );
/* FT_ENCODING_NONE is a valid encoding for BDF, PCF, and Windows FNT */
if ( encoding == FT_ENCODING_NONE && !face->num_charmaps )
return FT_THROW( Invalid_Argument );
/* FT_ENCODING_UNICODE is special. We try to find the `best' Unicode */
/* charmap available, i.e., one with UCS-4 characters, if possible. */
/* */
/* This is done by find_unicode_charmap() above, to share code. */
if ( encoding == FT_ENCODING_UNICODE )
return find_unicode_charmap( face );
cur = face->charmaps;
if ( !cur )
return FT_THROW( Invalid_CharMap_Handle );
limit = cur + face->num_charmaps;
for ( ; cur < limit; cur++ )
{
if ( cur[0]->encoding == encoding )
{
face->charmap = cur[0];
return FT_Err_Ok;
}
}
return FT_THROW( Invalid_Argument );
}
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Error )
FT_Set_Charmap( FT_Face face,
FT_CharMap charmap )
{
FT_CharMap* cur;
FT_CharMap* limit;
if ( !face )
return FT_THROW( Invalid_Face_Handle );
cur = face->charmaps;
if ( !cur || !charmap )
return FT_THROW( Invalid_CharMap_Handle );
limit = cur + face->num_charmaps;
for ( ; cur < limit; cur++ )
{
if ( cur[0] == charmap &&
FT_Get_CMap_Format ( charmap ) != 14 )
{
face->charmap = cur[0];
return FT_Err_Ok;
}
}
return FT_THROW( Invalid_Argument );
}
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Int )
FT_Get_Charmap_Index( FT_CharMap charmap )
{
FT_Int i;
if ( !charmap || !charmap->face )
return -1;
for ( i = 0; i < charmap->face->num_charmaps; i++ )
if ( charmap->face->charmaps[i] == charmap )
break;
FT_ASSERT( i < charmap->face->num_charmaps );
return i;
}
static void
ft_cmap_done_internal( FT_CMap cmap )
{
FT_CMap_Class clazz = cmap->clazz;
FT_Face face = cmap->charmap.face;
FT_Memory memory = FT_FACE_MEMORY( face );
if ( clazz->done )
clazz->done( cmap );
FT_FREE( cmap );
}
FT_BASE_DEF( void )
FT_CMap_Done( FT_CMap cmap )
{
if ( cmap )
{
FT_Face face = cmap->charmap.face;
FT_Memory memory = FT_FACE_MEMORY( face );
FT_Error error;
FT_Int i, j;
for ( i = 0; i < face->num_charmaps; i++ )
{
if ( (FT_CMap)face->charmaps[i] == cmap )
{
FT_CharMap last_charmap = face->charmaps[face->num_charmaps - 1];
if ( FT_QRENEW_ARRAY( face->charmaps,
face->num_charmaps,
face->num_charmaps - 1 ) )
return;
/* remove it from our list of charmaps */
for ( j = i + 1; j < face->num_charmaps; j++ )
{
if ( j == face->num_charmaps - 1 )
face->charmaps[j - 1] = last_charmap;
else
face->charmaps[j - 1] = face->charmaps[j];
}
face->num_charmaps--;
if ( (FT_CMap)face->charmap == cmap )
face->charmap = NULL;
ft_cmap_done_internal( cmap );
break;
}
}
}
}
FT_BASE_DEF( FT_Error )
FT_CMap_New( FT_CMap_Class clazz,
FT_Pointer init_data,
FT_CharMap charmap,
FT_CMap *acmap )
{
FT_Error error;
FT_Face face;
FT_Memory memory;
FT_CMap cmap = NULL;
if ( !clazz || !charmap || !charmap->face )
return FT_THROW( Invalid_Argument );
face = charmap->face;
memory = FT_FACE_MEMORY( face );
if ( !FT_ALLOC( cmap, clazz->size ) )
{
cmap->charmap = *charmap;
cmap->clazz = clazz;
if ( clazz->init )
{
error = clazz->init( cmap, init_data );
if ( error )
goto Fail;
}
/* add it to our list of charmaps */
if ( FT_QRENEW_ARRAY( face->charmaps,
face->num_charmaps,
face->num_charmaps + 1 ) )
goto Fail;
face->charmaps[face->num_charmaps++] = (FT_CharMap)cmap;
}
Exit:
if ( acmap )
*acmap = cmap;
return error;
Fail:
ft_cmap_done_internal( cmap );
cmap = NULL;
goto Exit;
}
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_UInt )
FT_Get_Char_Index( FT_Face face,
FT_ULong charcode )
{
FT_UInt result = 0;
if ( face && face->charmap )
{
FT_CMap cmap = FT_CMAP( face->charmap );
if ( charcode > 0xFFFFFFFFUL )
{
FT_TRACE1(( "FT_Get_Char_Index: too large charcode" ));
FT_TRACE1(( " 0x%lx is truncated\n", charcode ));
}
result = cmap->clazz->char_index( cmap, (FT_UInt32)charcode );
if ( result >= (FT_UInt)face->num_glyphs )
result = 0;
}
return result;
}
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_ULong )
FT_Get_First_Char( FT_Face face,
FT_UInt *agindex )
{
FT_ULong result = 0;
FT_UInt gindex = 0;
/* only do something if we have a charmap, and we have glyphs at all */
if ( face && face->charmap && face->num_glyphs )
{
gindex = FT_Get_Char_Index( face, 0 );
if ( gindex == 0 )
result = FT_Get_Next_Char( face, 0, &gindex );
}
if ( agindex )
*agindex = gindex;
return result;
}
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_ULong )
FT_Get_Next_Char( FT_Face face,
FT_ULong charcode,
FT_UInt *agindex )
{
FT_ULong result = 0;
FT_UInt gindex = 0;
if ( face && face->charmap && face->num_glyphs )
{
FT_UInt32 code = (FT_UInt32)charcode;
FT_CMap cmap = FT_CMAP( face->charmap );
do
{
gindex = cmap->clazz->char_next( cmap, &code );
} while ( gindex >= (FT_UInt)face->num_glyphs );
result = ( gindex == 0 ) ? 0 : code;
}
if ( agindex )
*agindex = gindex;
return result;
}
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Error )
FT_Face_Properties( FT_Face face,
FT_UInt num_properties,
FT_Parameter* properties )
{
FT_Error error = FT_Err_Ok;
if ( num_properties > 0 && !properties )
{
error = FT_THROW( Invalid_Argument );
goto Exit;
}
for ( ; num_properties > 0; num_properties-- )
{
if ( properties->tag == FT_PARAM_TAG_STEM_DARKENING )
{
if ( properties->data )
{
if ( *( (FT_Bool*)properties->data ) == TRUE )
face->internal->no_stem_darkening = FALSE;
else
face->internal->no_stem_darkening = TRUE;
}
else
{
/* use module default */
face->internal->no_stem_darkening = -1;
}
}
else if ( properties->tag == FT_PARAM_TAG_LCD_FILTER_WEIGHTS )
{
#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
if ( properties->data )
{
ft_memcpy( face->internal->lcd_weights,
properties->data,
FT_LCD_FILTER_FIVE_TAPS );
face->internal->lcd_filter_func = ft_lcd_filter_fir;
}
#else
error = FT_THROW( Unimplemented_Feature );
goto Exit;
#endif
}
else if ( properties->tag == FT_PARAM_TAG_RANDOM_SEED )
{
if ( properties->data )
{
face->internal->random_seed = *( (FT_Int32*)properties->data );
if ( face->internal->random_seed < 0 )
face->internal->random_seed = 0;
}
else
{
/* use module default */
face->internal->random_seed = -1;
}
}
else
{
error = FT_THROW( Invalid_Argument );
goto Exit;
}
if ( error )
break;
properties++;
}
Exit:
return error;
}
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_UInt )
FT_Face_GetCharVariantIndex( FT_Face face,
FT_ULong charcode,
FT_ULong variantSelector )
{
FT_UInt result = 0;
if ( face &&
face->charmap &&
face->charmap->encoding == FT_ENCODING_UNICODE )
{
FT_CharMap charmap = find_variant_selector_charmap( face );
FT_CMap ucmap = FT_CMAP( face->charmap );
if ( charmap )
{
FT_CMap vcmap = FT_CMAP( charmap );
if ( charcode > 0xFFFFFFFFUL )
{
FT_TRACE1(( "FT_Face_GetCharVariantIndex:"
" too large charcode" ));
FT_TRACE1(( " 0x%lx is truncated\n", charcode ));
}
if ( variantSelector > 0xFFFFFFFFUL )
{
FT_TRACE1(( "FT_Face_GetCharVariantIndex:"
" too large variantSelector" ));
FT_TRACE1(( " 0x%lx is truncated\n", variantSelector ));
}
result = vcmap->clazz->char_var_index( vcmap, ucmap,
(FT_UInt32)charcode,
(FT_UInt32)variantSelector );
}
}
return result;
}
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Int )
FT_Face_GetCharVariantIsDefault( FT_Face face,
FT_ULong charcode,
FT_ULong variantSelector )
{
FT_Int result = -1;
if ( face )
{
FT_CharMap charmap = find_variant_selector_charmap( face );
if ( charmap )
{
FT_CMap vcmap = FT_CMAP( charmap );
if ( charcode > 0xFFFFFFFFUL )
{
FT_TRACE1(( "FT_Face_GetCharVariantIsDefault:"
" too large charcode" ));
FT_TRACE1(( " 0x%lx is truncated\n", charcode ));
}
if ( variantSelector > 0xFFFFFFFFUL )
{
FT_TRACE1(( "FT_Face_GetCharVariantIsDefault:"
" too large variantSelector" ));
FT_TRACE1(( " 0x%lx is truncated\n", variantSelector ));
}
result = vcmap->clazz->char_var_default( vcmap,
(FT_UInt32)charcode,
(FT_UInt32)variantSelector );
}
}
return result;
}
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_UInt32* )
FT_Face_GetVariantSelectors( FT_Face face )
{
FT_UInt32 *result = NULL;
if ( face )
{
FT_CharMap charmap = find_variant_selector_charmap( face );
if ( charmap )
{
FT_CMap vcmap = FT_CMAP( charmap );
FT_Memory memory = FT_FACE_MEMORY( face );
result = vcmap->clazz->variant_list( vcmap, memory );
}
}
return result;
}
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_UInt32* )
FT_Face_GetVariantsOfChar( FT_Face face,
FT_ULong charcode )
{
FT_UInt32 *result = NULL;
if ( face )
{
FT_CharMap charmap = find_variant_selector_charmap( face );
if ( charmap )
{
FT_CMap vcmap = FT_CMAP( charmap );
FT_Memory memory = FT_FACE_MEMORY( face );
if ( charcode > 0xFFFFFFFFUL )
{
FT_TRACE1(( "FT_Face_GetVariantsOfChar: too large charcode" ));
FT_TRACE1(( " 0x%lx is truncated\n", charcode ));
}
result = vcmap->clazz->charvariant_list( vcmap, memory,
(FT_UInt32)charcode );
}
}
return result;
}
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_UInt32* )
FT_Face_GetCharsOfVariant( FT_Face face,
FT_ULong variantSelector )
{
FT_UInt32 *result = NULL;
if ( face )
{
FT_CharMap charmap = find_variant_selector_charmap( face );
if ( charmap )
{
FT_CMap vcmap = FT_CMAP( charmap );
FT_Memory memory = FT_FACE_MEMORY( face );
if ( variantSelector > 0xFFFFFFFFUL )
{
FT_TRACE1(( "FT_Get_Char_Index: too large variantSelector" ));
FT_TRACE1(( " 0x%lx is truncated\n", variantSelector ));
}
result = vcmap->clazz->variantchar_list( vcmap, memory,
(FT_UInt32)variantSelector );
}
}
return result;
}
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_UInt )
FT_Get_Name_Index( FT_Face face,
const FT_String* glyph_name )
{
FT_UInt result = 0;
if ( face &&
FT_HAS_GLYPH_NAMES( face ) &&
glyph_name )
{
FT_Service_GlyphDict service;
FT_FACE_LOOKUP_SERVICE( face,
service,
GLYPH_DICT );
if ( service && service->name_index )
result = service->name_index( face, glyph_name );
}
return result;
}
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Error )
FT_Get_Glyph_Name( FT_Face face,
FT_UInt glyph_index,
FT_Pointer buffer,
FT_UInt buffer_max )
{
FT_Error error;
FT_Service_GlyphDict service;
if ( !face )
return FT_THROW( Invalid_Face_Handle );
if ( !buffer || buffer_max == 0 )
return FT_THROW( Invalid_Argument );
/* clean up buffer */
((FT_Byte*)buffer)[0] = '\0';
if ( (FT_Long)glyph_index >= face->num_glyphs )
return FT_THROW( Invalid_Glyph_Index );
if ( !FT_HAS_GLYPH_NAMES( face ) )
return FT_THROW( Invalid_Argument );
FT_FACE_LOOKUP_SERVICE( face, service, GLYPH_DICT );
if ( service && service->get_name )
error = service->get_name( face, glyph_index, buffer, buffer_max );
else
error = FT_THROW( Invalid_Argument );
return error;
}
/* documentation is in freetype.h */
FT_EXPORT_DEF( const char* )
FT_Get_Postscript_Name( FT_Face face )
{
const char* result = NULL;
if ( !face )
goto Exit;
if ( !result )
{
FT_Service_PsFontName service;
FT_FACE_LOOKUP_SERVICE( face,
service,
POSTSCRIPT_FONT_NAME );
if ( service && service->get_ps_font_name )
result = service->get_ps_font_name( face );
}
Exit:
return result;
}
/* documentation is in tttables.h */
FT_EXPORT_DEF( void* )
FT_Get_Sfnt_Table( FT_Face face,
FT_Sfnt_Tag tag )
{
void* table = NULL;
FT_Service_SFNT_Table service;
if ( face && FT_IS_SFNT( face ) )
{
FT_FACE_FIND_SERVICE( face, service, SFNT_TABLE );
if ( service )
table = service->get_table( face, tag );
}
return table;
}
/* documentation is in tttables.h */
FT_EXPORT_DEF( FT_Error )
FT_Load_Sfnt_Table( FT_Face face,
FT_ULong tag,
FT_Long offset,
FT_Byte* buffer,
FT_ULong* length )
{
FT_Service_SFNT_Table service;
if ( !face || !FT_IS_SFNT( face ) )
return FT_THROW( Invalid_Face_Handle );
FT_FACE_FIND_SERVICE( face, service, SFNT_TABLE );
if ( !service )
return FT_THROW( Unimplemented_Feature );
return service->load_table( face, tag, offset, buffer, length );
}
/* documentation is in tttables.h */
FT_EXPORT_DEF( FT_Error )
FT_Sfnt_Table_Info( FT_Face face,
FT_UInt table_index,
FT_ULong *tag,
FT_ULong *length )
{
FT_Service_SFNT_Table service;
FT_ULong offset;
/* test for valid `length' delayed to `service->table_info' */
if ( !face || !FT_IS_SFNT( face ) )
return FT_THROW( Invalid_Face_Handle );
FT_FACE_FIND_SERVICE( face, service, SFNT_TABLE );
if ( !service )
return FT_THROW( Unimplemented_Feature );
return service->table_info( face, table_index, tag, &offset, length );
}
/* documentation is in tttables.h */
FT_EXPORT_DEF( FT_ULong )
FT_Get_CMap_Language_ID( FT_CharMap charmap )
{
FT_Service_TTCMaps service;
FT_Face face;
TT_CMapInfo cmap_info;
if ( !charmap || !charmap->face )
return 0;
face = charmap->face;
FT_FACE_FIND_SERVICE( face, service, TT_CMAP );
if ( !service )
return 0;
if ( service->get_cmap_info( charmap, &cmap_info ))
return 0;
return cmap_info.language;
}
/* documentation is in tttables.h */
FT_EXPORT_DEF( FT_Long )
FT_Get_CMap_Format( FT_CharMap charmap )
{
FT_Service_TTCMaps service;
FT_Face face;
TT_CMapInfo cmap_info;
if ( !charmap || !charmap->face )
return -1;
face = charmap->face;
FT_FACE_FIND_SERVICE( face, service, TT_CMAP );
if ( !service )
return -1;
if ( service->get_cmap_info( charmap, &cmap_info ))
return -1;
return cmap_info.format;
}
/* documentation is in ftsizes.h */
FT_EXPORT_DEF( FT_Error )
FT_Activate_Size( FT_Size size )
{
FT_Face face;
if ( !size )
return FT_THROW( Invalid_Size_Handle );
face = size->face;
if ( !face || !face->driver )
return FT_THROW( Invalid_Face_Handle );
/* we don't need anything more complex than that; all size objects */
/* are already listed by the face */
face->size = size;
return FT_Err_Ok;
}
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/**** ****/
/**** ****/
/**** R E N D E R E R S ****/
/**** ****/
/**** ****/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/* lookup a renderer by glyph format in the library's list */
FT_BASE_DEF( FT_Renderer )
FT_Lookup_Renderer( FT_Library library,
FT_Glyph_Format format,
FT_ListNode* node )
{
FT_ListNode cur;
FT_Renderer result = NULL;
if ( !library )
goto Exit;
cur = library->renderers.head;
if ( node )
{
if ( *node )
cur = (*node)->next;
*node = NULL;
}
while ( cur )
{
FT_Renderer renderer = FT_RENDERER( cur->data );
if ( renderer->glyph_format == format )
{
if ( node )
*node = cur;
result = renderer;
break;
}
cur = cur->next;
}
Exit:
return result;
}
static FT_Renderer
ft_lookup_glyph_renderer( FT_GlyphSlot slot )
{
FT_Face face = slot->face;
FT_Library library = FT_FACE_LIBRARY( face );
FT_Renderer result = library->cur_renderer;
if ( !result || result->glyph_format != slot->format )
result = FT_Lookup_Renderer( library, slot->format, 0 );
return result;
}
static void
ft_set_current_renderer( FT_Library library )
{
FT_Renderer renderer;
renderer = FT_Lookup_Renderer( library, FT_GLYPH_FORMAT_OUTLINE, 0 );
library->cur_renderer = renderer;
}
static FT_Error
ft_add_renderer( FT_Module module )
{
FT_Library library = module->library;
FT_Memory memory = library->memory;
FT_Error error;
FT_ListNode node = NULL;
if ( FT_QNEW( node ) )
goto Exit;
{
FT_Renderer render = FT_RENDERER( module );
FT_Renderer_Class* clazz = (FT_Renderer_Class*)module->clazz;
render->clazz = clazz;
render->glyph_format = clazz->glyph_format;
/* allocate raster object if needed */
if ( clazz->raster_class && clazz->raster_class->raster_new )
{
error = clazz->raster_class->raster_new( memory, &render->raster );
if ( error )
goto Fail;
render->raster_render = clazz->raster_class->raster_render;
render->render = clazz->render_glyph;
}
#ifdef FT_CONFIG_OPTION_SVG
if ( clazz->glyph_format == FT_GLYPH_FORMAT_SVG )
render->render = clazz->render_glyph;
#endif
/* add to list */
node->data = module;
FT_List_Add( &library->renderers, node );
ft_set_current_renderer( library );
}
Fail:
if ( error )
FT_FREE( node );
Exit:
return error;
}
static void
ft_remove_renderer( FT_Module module )
{
FT_Library library;
FT_Memory memory;
FT_ListNode node;
library = module->library;
if ( !library )
return;
memory = library->memory;
node = FT_List_Find( &library->renderers, module );
if ( node )
{
FT_Renderer render = FT_RENDERER( module );
/* release raster object, if any */
if ( render->raster )
render->clazz->raster_class->raster_done( render->raster );
/* remove from list */
FT_List_Remove( &library->renderers, node );
FT_FREE( node );
ft_set_current_renderer( library );
}
}
/* documentation is in ftrender.h */
FT_EXPORT_DEF( FT_Renderer )
FT_Get_Renderer( FT_Library library,
FT_Glyph_Format format )
{
/* test for valid `library' delayed to `FT_Lookup_Renderer' */
return FT_Lookup_Renderer( library, format, 0 );
}
/* documentation is in ftrender.h */
FT_EXPORT_DEF( FT_Error )
FT_Set_Renderer( FT_Library library,
FT_Renderer renderer,
FT_UInt num_params,
FT_Parameter* parameters )
{
FT_ListNode node;
FT_Error error = FT_Err_Ok;
FT_Renderer_SetModeFunc set_mode;
if ( !library )
{
error = FT_THROW( Invalid_Library_Handle );
goto Exit;
}
if ( !renderer )
{
error = FT_THROW( Invalid_Argument );
goto Exit;
}
if ( num_params > 0 && !parameters )
{
error = FT_THROW( Invalid_Argument );
goto Exit;
}
node = FT_List_Find( &library->renderers, renderer );
if ( !node )
{
error = FT_THROW( Invalid_Argument );
goto Exit;
}
FT_List_Up( &library->renderers, node );
if ( renderer->glyph_format == FT_GLYPH_FORMAT_OUTLINE )
library->cur_renderer = renderer;
set_mode = renderer->clazz->set_mode;
for ( ; num_params > 0; num_params-- )
{
error = set_mode( renderer, parameters->tag, parameters->data );
if ( error )
break;
parameters++;
}
Exit:
return error;
}
FT_BASE_DEF( FT_Error )
FT_Render_Glyph_Internal( FT_Library library,
FT_GlyphSlot slot,
FT_Render_Mode render_mode )
{
FT_Error error = FT_Err_Ok;
FT_Face face = slot->face;
FT_Renderer renderer;
switch ( slot->format )
{
default:
if ( slot->internal->load_flags & FT_LOAD_COLOR )
{
FT_LayerIterator iterator;
FT_UInt base_glyph = slot->glyph_index;
FT_Bool have_layers;
FT_UInt glyph_index;
FT_UInt color_index;
/* check whether we have colored glyph layers */
iterator.p = NULL;
have_layers = FT_Get_Color_Glyph_Layer( face,
base_glyph,
&glyph_index,
&color_index,
&iterator );
if ( have_layers )
{
error = FT_New_GlyphSlot( face, NULL );
if ( !error )
{
TT_Face ttface = (TT_Face)face;
SFNT_Service sfnt = (SFNT_Service)ttface->sfnt;
do
{
FT_Int32 load_flags = slot->internal->load_flags;
/* disable the `FT_LOAD_COLOR' flag to avoid recursion */
/* right here in this function */
load_flags &= ~FT_LOAD_COLOR;
/* render into the new `face->glyph' glyph slot */
load_flags |= FT_LOAD_RENDER;
error = FT_Load_Glyph( face, glyph_index, load_flags );
if ( error )
break;
/* blend new `face->glyph' into old `slot'; */
/* at the first call, `slot' is still empty */
error = sfnt->colr_blend( ttface,
color_index,
slot,
face->glyph );
if ( error )
break;
} while ( FT_Get_Color_Glyph_Layer( face,
base_glyph,
&glyph_index,
&color_index,
&iterator ) );
if ( !error )
slot->format = FT_GLYPH_FORMAT_BITMAP;
/* this call also restores `slot' as the glyph slot */
FT_Done_GlyphSlot( face->glyph );
}
if ( !error )
return error;
/* Failed to do the colored layer. Draw outline instead. */
slot->format = FT_GLYPH_FORMAT_OUTLINE;
}
}
{
FT_ListNode node = NULL;
/* small shortcut for the very common case */
if ( slot->format == FT_GLYPH_FORMAT_OUTLINE )
{
renderer = library->cur_renderer;
node = library->renderers.head;
}
else
renderer = FT_Lookup_Renderer( library, slot->format, &node );
error = FT_ERR( Cannot_Render_Glyph );
while ( renderer )
{
error = renderer->render( renderer, slot, render_mode, NULL );
if ( !error ||
FT_ERR_NEQ( error, Cannot_Render_Glyph ) )
break;
/* FT_Err_Cannot_Render_Glyph is returned if the render mode */
/* is unsupported by the current renderer for this glyph image */
/* format. */
/* now, look for another renderer that supports the same */
/* format. */
renderer = FT_Lookup_Renderer( library, slot->format, &node );
}
/* it is not an error if we cannot render a bitmap glyph */
if ( FT_ERR_EQ( error, Cannot_Render_Glyph ) &&
slot->format == FT_GLYPH_FORMAT_BITMAP )
error = FT_Err_Ok;
}
}
#ifdef FT_DEBUG_LEVEL_TRACE
#undef FT_COMPONENT
#define FT_COMPONENT checksum
/*
* Computing the MD5 checksum is expensive, unnecessarily distorting a
* possible profiling of FreeType if compiled with tracing support. For
* this reason, we execute the following code only if explicitly
* requested.
*/
/* we use FT_TRACE3 in this block */
if ( !error &&
ft_trace_levels[trace_checksum] >= 3 &&
slot->bitmap.buffer )
{
FT_Bitmap bitmap;
FT_Error err;
FT_Bitmap_Init( &bitmap );
/* we convert to a single bitmap format for computing the checksum */
/* this also converts the bitmap flow to `down' (i.e., pitch > 0) */
err = FT_Bitmap_Convert( library, &slot->bitmap, &bitmap, 1 );
if ( !err )
{
MD5_CTX ctx;
unsigned char md5[16];
unsigned long coverage = 0;
int i, j;
int rows = (int)bitmap.rows;
int pitch = bitmap.pitch;
FT_TRACE3(( "FT_Render_Glyph: bitmap %dx%d, %s (mode %d)\n",
pitch,
rows,
pixel_modes[slot->bitmap.pixel_mode],
slot->bitmap.pixel_mode ));
for ( i = 0; i < rows; i++ )
for ( j = 0; j < pitch; j++ )
coverage += bitmap.buffer[i * pitch + j];
FT_TRACE3(( " Total coverage: %lu\n", coverage ));
MD5_Init( &ctx );
if ( bitmap.buffer )
MD5_Update( &ctx, bitmap.buffer,
(unsigned long)rows * (unsigned long)pitch );
MD5_Final( md5, &ctx );
FT_TRACE3(( " MD5 checksum: " ));
for ( i = 0; i < 16; i++ )
FT_TRACE3(( "%02X", md5[i] ));
FT_TRACE3(( "\n" ));
}
FT_Bitmap_Done( library, &bitmap );
}
/*
* Dump bitmap in Netpbm format (PBM or PGM).
*/
/* we use FT_TRACE7 in this block */
if ( !error &&
ft_trace_levels[trace_checksum] >= 7 &&
slot->bitmap.buffer )
{
if ( slot->bitmap.rows < 128U &&
slot->bitmap.width < 128U )
{
int rows = (int)slot->bitmap.rows;
int width = (int)slot->bitmap.width;
int pitch = slot->bitmap.pitch;
int i, j, m;
unsigned char* topleft = slot->bitmap.buffer;
if ( pitch < 0 )
topleft -= pitch * ( rows - 1 );
FT_TRACE7(( "Netpbm image: start\n" ));
switch ( slot->bitmap.pixel_mode )
{
case FT_PIXEL_MODE_MONO:
FT_TRACE7(( "P1 %d %d\n", width, rows ));
for ( i = 0; i < rows; i++ )
{
for ( j = 0; j < width; )
for ( m = 128; m > 0 && j < width; m >>= 1, j++ )
FT_TRACE7(( " %d",
( topleft[i * pitch + j / 8] & m ) != 0 ));
FT_TRACE7(( "\n" ));
}
break;
default:
FT_TRACE7(( "P2 %d %d 255\n", width, rows ));
for ( i = 0; i < rows; i++ )
{
for ( j = 0; j < width; j += 1 )
FT_TRACE7(( " %3u", topleft[i * pitch + j] ));
FT_TRACE7(( "\n" ));
}
}
FT_TRACE7(( "Netpbm image: end\n" ));
}
else
FT_TRACE7(( "Netpbm image: too large, omitted\n" ));
}
#undef FT_COMPONENT
#define FT_COMPONENT objs
#endif /* FT_DEBUG_LEVEL_TRACE */
return error;
}
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Error )
FT_Render_Glyph( FT_GlyphSlot slot,
FT_Render_Mode render_mode )
{
FT_Library library;
if ( !slot || !slot->face )
return FT_THROW( Invalid_Argument );
library = FT_FACE_LIBRARY( slot->face );
return FT_Render_Glyph_Internal( library, slot, render_mode );
}
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/**** ****/
/**** ****/
/**** M O D U L E S ****/
/**** ****/
/**** ****/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/**************************************************************************
*
* @Function:
* Destroy_Module
*
* @Description:
* Destroys a given module object. For drivers, this also destroys
* all child faces.
*
* @InOut:
* module ::
* A handle to the target driver object.
*
* @Note:
* The driver _must_ be LOCKED!
*/
static void
Destroy_Module( FT_Module module )
{
FT_Memory memory = module->memory;
FT_Module_Class* clazz = module->clazz;
FT_Library library = module->library;
if ( library && library->auto_hinter == module )
library->auto_hinter = NULL;
/* if the module is a renderer */
if ( FT_MODULE_IS_RENDERER( module ) )
ft_remove_renderer( module );
/* if the module is a font driver, add some steps */
if ( FT_MODULE_IS_DRIVER( module ) )
Destroy_Driver( FT_DRIVER( module ) );
/* finalize the module object */
if ( clazz->module_done )
clazz->module_done( module );
/* discard it */
FT_FREE( module );
}
/* documentation is in ftmodapi.h */
FT_EXPORT_DEF( FT_Error )
FT_Add_Module( FT_Library library,
const FT_Module_Class* clazz )
{
FT_Error error;
FT_Memory memory;
FT_Module module = NULL;
FT_UInt nn;
#define FREETYPE_VER_FIXED ( ( (FT_Long)FREETYPE_MAJOR << 16 ) | \
FREETYPE_MINOR )
if ( !library )
return FT_THROW( Invalid_Library_Handle );
if ( !clazz )
return FT_THROW( Invalid_Argument );
/* check FreeType version */
if ( clazz->module_requires > FREETYPE_VER_FIXED )
return FT_THROW( Invalid_Version );
/* look for a module with the same name in the library's table */
for ( nn = 0; nn < library->num_modules; nn++ )
{
module = library->modules[nn];
if ( ft_strcmp( module->clazz->module_name, clazz->module_name ) == 0 )
{
/* this installed module has the same name, compare their versions */
if ( clazz->module_version <= module->clazz->module_version )
return FT_THROW( Lower_Module_Version );
/* remove the module from our list, then exit the loop to replace */
/* it by our new version.. */
FT_Remove_Module( library, module );
break;
}
}
memory = library->memory;
error = FT_Err_Ok;
if ( library->num_modules >= FT_MAX_MODULES )
{
error = FT_THROW( Too_Many_Drivers );
goto Exit;
}
/* allocate module object */
if ( FT_ALLOC( module, clazz->module_size ) )
goto Exit;
/* base initialization */
module->library = library;
module->memory = memory;
module->clazz = (FT_Module_Class*)clazz;
/* check whether the module is a renderer - this must be performed */
/* before the normal module initialization */
if ( FT_MODULE_IS_RENDERER( module ) )
{
/* add to the renderers list */
error = ft_add_renderer( module );
if ( error )
goto Fail;
}
/* is the module a auto-hinter? */
if ( FT_MODULE_IS_HINTER( module ) )
library->auto_hinter = module;
/* if the module is a font driver */
if ( FT_MODULE_IS_DRIVER( module ) )
{
FT_Driver driver = FT_DRIVER( module );
driver->clazz = (FT_Driver_Class)module->clazz;
}
if ( clazz->module_init )
{
error = clazz->module_init( module );
if ( error )
goto Fail;
}
/* add module to the library's table */
library->modules[library->num_modules++] = module;
Exit:
return error;
Fail:
if ( FT_MODULE_IS_RENDERER( module ) )
{
FT_Renderer renderer = FT_RENDERER( module );
if ( renderer->clazz &&
renderer->clazz->glyph_format == FT_GLYPH_FORMAT_OUTLINE &&
renderer->raster )
renderer->clazz->raster_class->raster_done( renderer->raster );
}
FT_FREE( module );
goto Exit;
}
/* documentation is in ftmodapi.h */
FT_EXPORT_DEF( FT_Module )
FT_Get_Module( FT_Library library,
const char* module_name )
{
FT_Module result = NULL;
FT_Module* cur;
FT_Module* limit;
if ( !library || !module_name )
return result;
cur = library->modules;
limit = cur + library->num_modules;
for ( ; cur < limit; cur++ )
if ( ft_strcmp( cur[0]->clazz->module_name, module_name ) == 0 )
{
result = cur[0];
break;
}
return result;
}
/* documentation is in ftobjs.h */
FT_BASE_DEF( const void* )
FT_Get_Module_Interface( FT_Library library,
const char* mod_name )
{
FT_Module module;
/* test for valid `library' delayed to FT_Get_Module() */
module = FT_Get_Module( library, mod_name );
return module ? module->clazz->module_interface : 0;
}
FT_BASE_DEF( FT_Pointer )
ft_module_get_service( FT_Module module,
const char* service_id,
FT_Bool global )
{
FT_Pointer result = NULL;
if ( module )
{
FT_ASSERT( module->clazz && module->clazz->get_interface );
/* first, look for the service in the module */
if ( module->clazz->get_interface )
result = module->clazz->get_interface( module, service_id );
if ( global && !result )
{
/* we didn't find it, look in all other modules then */
FT_Library library = module->library;
FT_Module* cur = library->modules;
FT_Module* limit = cur + library->num_modules;
for ( ; cur < limit; cur++ )
{
if ( cur[0] != module )
{
FT_ASSERT( cur[0]->clazz );
if ( cur[0]->clazz->get_interface )
{
result = cur[0]->clazz->get_interface( cur[0], service_id );
if ( result )
break;
}
}
}
}
}
return result;
}
/* documentation is in ftmodapi.h */
FT_EXPORT_DEF( FT_Error )
FT_Remove_Module( FT_Library library,
FT_Module module )
{
/* try to find the module from the table, then remove it from there */
if ( !library )
return FT_THROW( Invalid_Library_Handle );
if ( module )
{
FT_Module* cur = library->modules;
FT_Module* limit = cur + library->num_modules;
for ( ; cur < limit; cur++ )
{
if ( cur[0] == module )
{
/* remove it from the table */
library->num_modules--;
limit--;
while ( cur < limit )
{
cur[0] = cur[1];
cur++;
}
limit[0] = NULL;
/* destroy the module */
Destroy_Module( module );
return FT_Err_Ok;
}
}
}
return FT_THROW( Invalid_Driver_Handle );
}
static FT_Error
ft_property_do( FT_Library library,
const FT_String* module_name,
const FT_String* property_name,
void* value,
FT_Bool set,
FT_Bool value_is_string )
{
FT_Module* cur;
FT_Module* limit;
FT_Module_Interface interface;
FT_Service_Properties service;
#ifdef FT_DEBUG_LEVEL_ERROR
const FT_String* set_name = "FT_Property_Set";
const FT_String* get_name = "FT_Property_Get";
const FT_String* func_name = set ? set_name : get_name;
#endif
FT_Bool missing_func;
if ( !library )
return FT_THROW( Invalid_Library_Handle );
if ( !module_name || !property_name || !value )
return FT_THROW( Invalid_Argument );
cur = library->modules;
limit = cur + library->num_modules;
/* search module */
for ( ; cur < limit; cur++ )
if ( !ft_strcmp( cur[0]->clazz->module_name, module_name ) )
break;
if ( cur == limit )
{
FT_TRACE2(( "%s: can't find module `%s'\n",
func_name, module_name ));
return FT_THROW( Missing_Module );
}
/* check whether we have a service interface */
if ( !cur[0]->clazz->get_interface )
{
FT_TRACE2(( "%s: module `%s' doesn't support properties\n",
func_name, module_name ));
return FT_THROW( Unimplemented_Feature );
}
/* search property service */
interface = cur[0]->clazz->get_interface( cur[0],
FT_SERVICE_ID_PROPERTIES );
if ( !interface )
{
FT_TRACE2(( "%s: module `%s' doesn't support properties\n",
func_name, module_name ));
return FT_THROW( Unimplemented_Feature );
}
service = (FT_Service_Properties)interface;
if ( set )
missing_func = FT_BOOL( !service->set_property );
else
missing_func = FT_BOOL( !service->get_property );
if ( missing_func )
{
FT_TRACE2(( "%s: property service of module `%s' is broken\n",
func_name, module_name ));
return FT_THROW( Unimplemented_Feature );
}
return set ? service->set_property( cur[0],
property_name,
value,
value_is_string )
: service->get_property( cur[0],
property_name,
value );
}
/* documentation is in ftmodapi.h */
FT_EXPORT_DEF( FT_Error )
FT_Property_Set( FT_Library library,
const FT_String* module_name,
const FT_String* property_name,
const void* value )
{
return ft_property_do( library,
module_name,
property_name,
(void*)value,
TRUE,
FALSE );
}
/* documentation is in ftmodapi.h */
FT_EXPORT_DEF( FT_Error )
FT_Property_Get( FT_Library library,
const FT_String* module_name,
const FT_String* property_name,
void* value )
{
return ft_property_do( library,
module_name,
property_name,
value,
FALSE,
FALSE );
}
#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
/* this variant is used for handling the FREETYPE_PROPERTIES */
/* environment variable */
FT_BASE_DEF( FT_Error )
ft_property_string_set( FT_Library library,
const FT_String* module_name,
const FT_String* property_name,
FT_String* value )
{
return ft_property_do( library,
module_name,
property_name,
(void*)value,
TRUE,
TRUE );
}
#endif
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/**** ****/
/**** ****/
/**** L I B R A R Y ****/
/**** ****/
/**** ****/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/* documentation is in ftmodapi.h */
FT_EXPORT_DEF( FT_Error )
FT_Reference_Library( FT_Library library )
{
if ( !library )
return FT_THROW( Invalid_Library_Handle );
library->refcount++;
return FT_Err_Ok;
}
/* documentation is in ftmodapi.h */
FT_EXPORT_DEF( FT_Error )
FT_New_Library( FT_Memory memory,
FT_Library *alibrary )
{
FT_Library library = NULL;
FT_Error error;
if ( !memory || !alibrary )
return FT_THROW( Invalid_Argument );
#ifndef FT_DEBUG_LOGGING
#ifdef FT_DEBUG_LEVEL_ERROR
/* init debugging support */
ft_debug_init();
#endif /* FT_DEBUG_LEVEL_ERROR */
#endif /* !FT_DEBUG_LOGGING */
/* first of all, allocate the library object */
if ( FT_NEW( library ) )
return error;
library->memory = memory;
library->version_major = FREETYPE_MAJOR;
library->version_minor = FREETYPE_MINOR;
library->version_patch = FREETYPE_PATCH;
library->refcount = 1;
/* That's ok now */
*alibrary = library;
return FT_Err_Ok;
}
/* documentation is in freetype.h */
FT_EXPORT_DEF( void )
FT_Library_Version( FT_Library library,
FT_Int *amajor,
FT_Int *aminor,
FT_Int *apatch )
{
FT_Int major = 0;
FT_Int minor = 0;
FT_Int patch = 0;
if ( library )
{
major = library->version_major;
minor = library->version_minor;
patch = library->version_patch;
}
if ( amajor )
*amajor = major;
if ( aminor )
*aminor = minor;
if ( apatch )
*apatch = patch;
}
/* documentation is in ftmodapi.h */
FT_EXPORT_DEF( FT_Error )
FT_Done_Library( FT_Library library )
{
FT_Memory memory;
if ( !library )
return FT_THROW( Invalid_Library_Handle );
library->refcount--;
if ( library->refcount > 0 )
goto Exit;
memory = library->memory;
/*
* Close all faces in the library. If we don't do this, we can have
* some subtle memory leaks.
*
* Example:
*
* - the cff font driver uses the pshinter module in cff_size_done
* - if the pshinter module is destroyed before the cff font driver,
* opened FT_Face objects managed by the driver are not properly
* destroyed, resulting in a memory leak
*
* Some faces are dependent on other faces, like Type42 faces that
* depend on TrueType faces synthesized internally.
*
* The order of drivers should be specified in driver_name[].
*/
{
FT_UInt m, n;
const char* driver_name[] = { "type42", NULL };
for ( m = 0;
m < sizeof ( driver_name ) / sizeof ( driver_name[0] );
m++ )
{
for ( n = 0; n < library->num_modules; n++ )
{
FT_Module module = library->modules[n];
const char* module_name = module->clazz->module_name;
FT_List faces;
if ( driver_name[m] &&
ft_strcmp( module_name, driver_name[m] ) != 0 )
continue;
if ( ( module->clazz->module_flags & FT_MODULE_FONT_DRIVER ) == 0 )
continue;
FT_TRACE7(( "FT_Done_Library: close faces for %s\n", module_name ));
faces = &FT_DRIVER( module )->faces_list;
while ( faces->head )
{
FT_Done_Face( FT_FACE( faces->head->data ) );
if ( faces->head )
FT_TRACE0(( "FT_Done_Library: failed to free some faces\n" ));
}
}
}
}
/* Close all other modules in the library */
#if 1
/* XXX Modules are removed in the reversed order so that */
/* type42 module is removed before truetype module. This */
/* avoids double free in some occasions. It is a hack. */
while ( library->num_modules > 0 )
FT_Remove_Module( library,
library->modules[library->num_modules - 1] );
#else
{
FT_UInt n;
for ( n = 0; n < library->num_modules; n++ )
{
FT_Module module = library->modules[n];
if ( module )
{
Destroy_Module( module );
library->modules[n] = NULL;
}
}
}
#endif
FT_FREE( library );
Exit:
return FT_Err_Ok;
}
/* documentation is in ftmodapi.h */
FT_EXPORT_DEF( void )
FT_Set_Debug_Hook( FT_Library library,
FT_UInt hook_index,
FT_DebugHook_Func debug_hook )
{
if ( library && debug_hook &&
hook_index <
( sizeof ( library->debug_hooks ) / sizeof ( void* ) ) )
library->debug_hooks[hook_index] = debug_hook;
}
/* documentation is in ftmodapi.h */
FT_EXPORT_DEF( FT_TrueTypeEngineType )
FT_Get_TrueType_Engine_Type( FT_Library library )
{
FT_TrueTypeEngineType result = FT_TRUETYPE_ENGINE_TYPE_NONE;
if ( library )
{
FT_Module module = FT_Get_Module( library, "truetype" );
if ( module )
{
FT_Service_TrueTypeEngine service;
service = (FT_Service_TrueTypeEngine)
ft_module_get_service( module,
FT_SERVICE_ID_TRUETYPE_ENGINE,
0 );
if ( service )
result = service->engine_type;
}
}
return result;
}
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Error )
FT_Get_SubGlyph_Info( FT_GlyphSlot glyph,
FT_UInt sub_index,
FT_Int *p_index,
FT_UInt *p_flags,
FT_Int *p_arg1,
FT_Int *p_arg2,
FT_Matrix *p_transform )
{
FT_Error error = FT_ERR( Invalid_Argument );
if ( glyph &&
glyph->subglyphs &&
glyph->format == FT_GLYPH_FORMAT_COMPOSITE &&
sub_index < glyph->num_subglyphs )
{
FT_SubGlyph subg = glyph->subglyphs + sub_index;
*p_index = subg->index;
*p_flags = subg->flags;
*p_arg1 = subg->arg1;
*p_arg2 = subg->arg2;
*p_transform = subg->transform;
error = FT_Err_Ok;
}
return error;
}
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Bool )
FT_Get_Color_Glyph_Layer( FT_Face face,
FT_UInt base_glyph,
FT_UInt *aglyph_index,
FT_UInt *acolor_index,
FT_LayerIterator* iterator )
{
TT_Face ttface;
SFNT_Service sfnt;
if ( !face ||
!aglyph_index ||
!acolor_index ||
!iterator ||
base_glyph >= (FT_UInt)face->num_glyphs )
return 0;
if ( !FT_IS_SFNT( face ) )
return 0;
ttface = (TT_Face)face;
sfnt = (SFNT_Service)ttface->sfnt;
if ( sfnt->get_colr_layer )
return sfnt->get_colr_layer( ttface,
base_glyph,
aglyph_index,
acolor_index,
iterator );
else
return 0;
}
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Bool )
FT_Get_Color_Glyph_Paint( FT_Face face,
FT_UInt base_glyph,
FT_Color_Root_Transform root_transform,
FT_OpaquePaint* paint )
{
TT_Face ttface;
SFNT_Service sfnt;
if ( !face || !paint )
return 0;
if ( !FT_IS_SFNT( face ) )
return 0;
ttface = (TT_Face)face;
sfnt = (SFNT_Service)ttface->sfnt;
if ( sfnt->get_colr_layer )
return sfnt->get_colr_glyph_paint( ttface,
base_glyph,
root_transform,
paint );
else
return 0;
}
/* documentation is in ftcolor.h */
FT_EXPORT_DEF( FT_Bool )
FT_Get_Color_Glyph_ClipBox( FT_Face face,
FT_UInt base_glyph,
FT_ClipBox* clip_box )
{
TT_Face ttface;
SFNT_Service sfnt;
if ( !face || !clip_box )
return 0;
if ( !FT_IS_SFNT( face ) )
return 0;
ttface = (TT_Face)face;
sfnt = (SFNT_Service)ttface->sfnt;
if ( sfnt->get_color_glyph_clipbox )
return sfnt->get_color_glyph_clipbox( ttface,
base_glyph,
clip_box );
else
return 0;
}
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Bool )
FT_Get_Paint_Layers( FT_Face face,
FT_LayerIterator* layer_iterator,
FT_OpaquePaint* paint )
{
TT_Face ttface;
SFNT_Service sfnt;
if ( !face || !paint || !layer_iterator )
return 0;
if ( !FT_IS_SFNT( face ) )
return 0;
ttface = (TT_Face)face;
sfnt = (SFNT_Service)ttface->sfnt;
if ( sfnt->get_paint_layers )
return sfnt->get_paint_layers( ttface, layer_iterator, paint );
else
return 0;
}
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Bool )
FT_Get_Paint( FT_Face face,
FT_OpaquePaint opaque_paint,
FT_COLR_Paint* paint )
{
TT_Face ttface;
SFNT_Service sfnt;
if ( !face || !paint )
return 0;
if ( !FT_IS_SFNT( face ) )
return 0;
ttface = (TT_Face)face;
sfnt = (SFNT_Service)ttface->sfnt;
if ( sfnt->get_paint )
return sfnt->get_paint( ttface, opaque_paint, paint );
else
return 0;
}
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Bool )
FT_Get_Colorline_Stops ( FT_Face face,
FT_ColorStop * color_stop,
FT_ColorStopIterator *iterator )
{
TT_Face ttface;
SFNT_Service sfnt;
if ( !face || !color_stop || !iterator )
return 0;
if ( !FT_IS_SFNT( face ) )
return 0;
ttface = (TT_Face)face;
sfnt = (SFNT_Service)ttface->sfnt;
if ( sfnt->get_colorline_stops )
return sfnt->get_colorline_stops ( ttface, color_stop, iterator );
else
return 0;
}
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/base/ftobjs.c
|
C++
|
gpl-3.0
| 160,606
|
/****************************************************************************
*
* ftotval.c
*
* FreeType API for validating OpenType tables (body).
*
* Copyright (C) 2004-2022 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.
*
*/
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/ftobjs.h>
#include <freetype/internal/services/svotval.h>
#include <freetype/ftotval.h>
/* documentation is in ftotval.h */
FT_EXPORT_DEF( FT_Error )
FT_OpenType_Validate( FT_Face face,
FT_UInt validation_flags,
FT_Bytes *BASE_table,
FT_Bytes *GDEF_table,
FT_Bytes *GPOS_table,
FT_Bytes *GSUB_table,
FT_Bytes *JSTF_table )
{
FT_Service_OTvalidate service;
FT_Error error;
if ( !face )
{
error = FT_THROW( Invalid_Face_Handle );
goto Exit;
}
if ( !( BASE_table &&
GDEF_table &&
GPOS_table &&
GSUB_table &&
JSTF_table ) )
{
error = FT_THROW( Invalid_Argument );
goto Exit;
}
FT_FACE_FIND_GLOBAL_SERVICE( face, service, OPENTYPE_VALIDATE );
if ( service )
error = service->validate( face,
validation_flags,
BASE_table,
GDEF_table,
GPOS_table,
GSUB_table,
JSTF_table );
else
error = FT_THROW( Unimplemented_Feature );
Exit:
return error;
}
FT_EXPORT_DEF( void )
FT_OpenType_Free( FT_Face face,
FT_Bytes table )
{
FT_Memory memory;
if ( !face )
return;
memory = FT_FACE_MEMORY( face );
FT_FREE( table );
}
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/base/ftotval.c
|
C++
|
gpl-3.0
| 2,216
|
/****************************************************************************
*
* ftoutln.c
*
* FreeType outline management (body).
*
* Copyright (C) 1996-2022 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.
*
*/
#include <freetype/ftoutln.h>
#include <freetype/internal/ftobjs.h>
#include <freetype/internal/ftcalc.h>
#include <freetype/internal/ftdebug.h>
#include <freetype/fttrigon.h>
/**************************************************************************
*
* The macro FT_COMPONENT is used in trace mode. It is an implicit
* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
* messages during execution.
*/
#undef FT_COMPONENT
#define FT_COMPONENT outline
static
const FT_Outline null_outline = { 0, 0, NULL, NULL, NULL, 0 };
/* documentation is in ftoutln.h */
FT_EXPORT_DEF( FT_Error )
FT_Outline_Decompose( FT_Outline* outline,
const FT_Outline_Funcs* func_interface,
void* user )
{
#undef SCALED
#define SCALED( x ) ( (x) * ( 1L << shift ) - delta )
FT_Vector v_last;
FT_Vector v_control;
FT_Vector v_start;
FT_Vector* point;
FT_Vector* limit;
char* tags;
FT_Error error;
FT_Int n; /* index of contour in outline */
FT_UInt first; /* index of first point in contour */
FT_Int tag; /* current point's state */
FT_Int shift;
FT_Pos delta;
if ( !outline )
return FT_THROW( Invalid_Outline );
if ( !func_interface )
return FT_THROW( Invalid_Argument );
shift = func_interface->shift;
delta = func_interface->delta;
first = 0;
for ( n = 0; n < outline->n_contours; n++ )
{
FT_Int last; /* index of last point in contour */
FT_TRACE5(( "FT_Outline_Decompose: Outline %d\n", n ));
last = outline->contours[n];
if ( last < 0 )
goto Invalid_Outline;
limit = outline->points + last;
v_start = outline->points[first];
v_start.x = SCALED( v_start.x );
v_start.y = SCALED( v_start.y );
v_last = outline->points[last];
v_last.x = SCALED( v_last.x );
v_last.y = SCALED( v_last.y );
v_control = v_start;
point = outline->points + first;
tags = outline->tags + first;
tag = FT_CURVE_TAG( tags[0] );
/* A contour cannot start with a cubic control point! */
if ( tag == FT_CURVE_TAG_CUBIC )
goto Invalid_Outline;
/* check first point to determine origin */
if ( tag == FT_CURVE_TAG_CONIC )
{
/* first point is conic control. Yes, this happens. */
if ( FT_CURVE_TAG( outline->tags[last] ) == FT_CURVE_TAG_ON )
{
/* start at last point if it is on the curve */
v_start = v_last;
limit--;
}
else
{
/* if both first and last points are conic, */
/* start at their middle and record its position */
/* for closure */
v_start.x = ( v_start.x + v_last.x ) / 2;
v_start.y = ( v_start.y + v_last.y ) / 2;
/* v_last = v_start; */
}
point--;
tags--;
}
FT_TRACE5(( " move to (%.2f, %.2f)\n",
v_start.x / 64.0, v_start.y / 64.0 ));
error = func_interface->move_to( &v_start, user );
if ( error )
goto Exit;
while ( point < limit )
{
point++;
tags++;
tag = FT_CURVE_TAG( tags[0] );
switch ( tag )
{
case FT_CURVE_TAG_ON: /* emit a single line_to */
{
FT_Vector vec;
vec.x = SCALED( point->x );
vec.y = SCALED( point->y );
FT_TRACE5(( " line to (%.2f, %.2f)\n",
vec.x / 64.0, vec.y / 64.0 ));
error = func_interface->line_to( &vec, user );
if ( error )
goto Exit;
continue;
}
case FT_CURVE_TAG_CONIC: /* consume conic arcs */
v_control.x = SCALED( point->x );
v_control.y = SCALED( point->y );
Do_Conic:
if ( point < limit )
{
FT_Vector vec;
FT_Vector v_middle;
point++;
tags++;
tag = FT_CURVE_TAG( tags[0] );
vec.x = SCALED( point->x );
vec.y = SCALED( point->y );
if ( tag == FT_CURVE_TAG_ON )
{
FT_TRACE5(( " conic to (%.2f, %.2f)"
" with control (%.2f, %.2f)\n",
vec.x / 64.0, vec.y / 64.0,
v_control.x / 64.0, v_control.y / 64.0 ));
error = func_interface->conic_to( &v_control, &vec, user );
if ( error )
goto Exit;
continue;
}
if ( tag != FT_CURVE_TAG_CONIC )
goto Invalid_Outline;
v_middle.x = ( v_control.x + vec.x ) / 2;
v_middle.y = ( v_control.y + vec.y ) / 2;
FT_TRACE5(( " conic to (%.2f, %.2f)"
" with control (%.2f, %.2f)\n",
v_middle.x / 64.0, v_middle.y / 64.0,
v_control.x / 64.0, v_control.y / 64.0 ));
error = func_interface->conic_to( &v_control, &v_middle, user );
if ( error )
goto Exit;
v_control = vec;
goto Do_Conic;
}
FT_TRACE5(( " conic to (%.2f, %.2f)"
" with control (%.2f, %.2f)\n",
v_start.x / 64.0, v_start.y / 64.0,
v_control.x / 64.0, v_control.y / 64.0 ));
error = func_interface->conic_to( &v_control, &v_start, user );
goto Close;
default: /* FT_CURVE_TAG_CUBIC */
{
FT_Vector vec1, vec2;
if ( point + 1 > limit ||
FT_CURVE_TAG( tags[1] ) != FT_CURVE_TAG_CUBIC )
goto Invalid_Outline;
point += 2;
tags += 2;
vec1.x = SCALED( point[-2].x );
vec1.y = SCALED( point[-2].y );
vec2.x = SCALED( point[-1].x );
vec2.y = SCALED( point[-1].y );
if ( point <= limit )
{
FT_Vector vec;
vec.x = SCALED( point->x );
vec.y = SCALED( point->y );
FT_TRACE5(( " cubic to (%.2f, %.2f)"
" with controls (%.2f, %.2f) and (%.2f, %.2f)\n",
vec.x / 64.0, vec.y / 64.0,
vec1.x / 64.0, vec1.y / 64.0,
vec2.x / 64.0, vec2.y / 64.0 ));
error = func_interface->cubic_to( &vec1, &vec2, &vec, user );
if ( error )
goto Exit;
continue;
}
FT_TRACE5(( " cubic to (%.2f, %.2f)"
" with controls (%.2f, %.2f) and (%.2f, %.2f)\n",
v_start.x / 64.0, v_start.y / 64.0,
vec1.x / 64.0, vec1.y / 64.0,
vec2.x / 64.0, vec2.y / 64.0 ));
error = func_interface->cubic_to( &vec1, &vec2, &v_start, user );
goto Close;
}
}
}
/* close the contour with a line segment */
FT_TRACE5(( " line to (%.2f, %.2f)\n",
v_start.x / 64.0, v_start.y / 64.0 ));
error = func_interface->line_to( &v_start, user );
Close:
if ( error )
goto Exit;
first = (FT_UInt)last + 1;
}
FT_TRACE5(( "FT_Outline_Decompose: Done\n" ));
return FT_Err_Ok;
Invalid_Outline:
error = FT_THROW( Invalid_Outline );
/* fall through */
Exit:
FT_TRACE5(( "FT_Outline_Decompose: Error 0x%x\n", error ));
return error;
}
/* documentation is in ftoutln.h */
FT_EXPORT_DEF( FT_Error )
FT_Outline_New( FT_Library library,
FT_UInt numPoints,
FT_Int numContours,
FT_Outline *anoutline )
{
FT_Error error;
FT_Memory memory;
if ( !library )
return FT_THROW( Invalid_Library_Handle );
memory = library->memory;
if ( !anoutline || !memory )
return FT_THROW( Invalid_Argument );
*anoutline = null_outline;
if ( numContours < 0 ||
(FT_UInt)numContours > numPoints )
return FT_THROW( Invalid_Argument );
if ( numPoints > FT_OUTLINE_POINTS_MAX )
return FT_THROW( Array_Too_Large );
if ( FT_NEW_ARRAY( anoutline->points, numPoints ) ||
FT_NEW_ARRAY( anoutline->tags, numPoints ) ||
FT_NEW_ARRAY( anoutline->contours, numContours ) )
goto Fail;
anoutline->n_points = (FT_Short)numPoints;
anoutline->n_contours = (FT_Short)numContours;
anoutline->flags |= FT_OUTLINE_OWNER;
return FT_Err_Ok;
Fail:
anoutline->flags |= FT_OUTLINE_OWNER;
FT_Outline_Done( library, anoutline );
return error;
}
/* documentation is in ftoutln.h */
FT_EXPORT_DEF( FT_Error )
FT_Outline_Check( FT_Outline* outline )
{
if ( outline )
{
FT_Int n_points = outline->n_points;
FT_Int n_contours = outline->n_contours;
FT_Int end0, end;
FT_Int n;
/* empty glyph? */
if ( n_points == 0 && n_contours == 0 )
return FT_Err_Ok;
/* check point and contour counts */
if ( n_points <= 0 || n_contours <= 0 )
goto Bad;
end0 = end = -1;
for ( n = 0; n < n_contours; n++ )
{
end = outline->contours[n];
/* note that we don't accept empty contours */
if ( end <= end0 || end >= n_points )
goto Bad;
end0 = end;
}
if ( end != n_points - 1 )
goto Bad;
/* XXX: check the tags array */
return FT_Err_Ok;
}
Bad:
return FT_THROW( Invalid_Argument );
}
/* documentation is in ftoutln.h */
FT_EXPORT_DEF( FT_Error )
FT_Outline_Copy( const FT_Outline* source,
FT_Outline *target )
{
FT_Int is_owner;
if ( !source || !target )
return FT_THROW( Invalid_Outline );
if ( source->n_points != target->n_points ||
source->n_contours != target->n_contours )
return FT_THROW( Invalid_Argument );
if ( source == target )
return FT_Err_Ok;
if ( source->n_points )
{
FT_ARRAY_COPY( target->points, source->points, source->n_points );
FT_ARRAY_COPY( target->tags, source->tags, source->n_points );
}
if ( source->n_contours )
FT_ARRAY_COPY( target->contours, source->contours, source->n_contours );
/* copy all flags, except the `FT_OUTLINE_OWNER' one */
is_owner = target->flags & FT_OUTLINE_OWNER;
target->flags = source->flags;
target->flags &= ~FT_OUTLINE_OWNER;
target->flags |= is_owner;
return FT_Err_Ok;
}
/* documentation is in ftoutln.h */
FT_EXPORT_DEF( FT_Error )
FT_Outline_Done( FT_Library library,
FT_Outline* outline )
{
FT_Memory memory;
if ( !library )
return FT_THROW( Invalid_Library_Handle );
if ( !outline )
return FT_THROW( Invalid_Outline );
memory = library->memory;
if ( !memory )
return FT_THROW( Invalid_Argument );
if ( outline->flags & FT_OUTLINE_OWNER )
{
FT_FREE( outline->points );
FT_FREE( outline->tags );
FT_FREE( outline->contours );
}
*outline = null_outline;
return FT_Err_Ok;
}
/* documentation is in ftoutln.h */
FT_EXPORT_DEF( void )
FT_Outline_Get_CBox( const FT_Outline* outline,
FT_BBox *acbox )
{
FT_Pos xMin, yMin, xMax, yMax;
if ( outline && acbox )
{
if ( outline->n_points == 0 )
{
xMin = 0;
yMin = 0;
xMax = 0;
yMax = 0;
}
else
{
FT_Vector* vec = outline->points;
FT_Vector* limit = vec + outline->n_points;
xMin = xMax = vec->x;
yMin = yMax = vec->y;
vec++;
for ( ; vec < limit; vec++ )
{
FT_Pos x, y;
x = vec->x;
if ( x < xMin ) xMin = x;
if ( x > xMax ) xMax = x;
y = vec->y;
if ( y < yMin ) yMin = y;
if ( y > yMax ) yMax = y;
}
}
acbox->xMin = xMin;
acbox->xMax = xMax;
acbox->yMin = yMin;
acbox->yMax = yMax;
}
}
/* documentation is in ftoutln.h */
FT_EXPORT_DEF( void )
FT_Outline_Translate( const FT_Outline* outline,
FT_Pos xOffset,
FT_Pos yOffset )
{
FT_UShort n;
FT_Vector* vec;
if ( !outline )
return;
vec = outline->points;
for ( n = 0; n < outline->n_points; n++ )
{
vec->x = ADD_LONG( vec->x, xOffset );
vec->y = ADD_LONG( vec->y, yOffset );
vec++;
}
}
/* documentation is in ftoutln.h */
FT_EXPORT_DEF( void )
FT_Outline_Reverse( FT_Outline* outline )
{
FT_UShort n;
FT_Int first, last;
if ( !outline )
return;
first = 0;
for ( n = 0; n < outline->n_contours; n++ )
{
last = outline->contours[n];
/* reverse point table */
{
FT_Vector* p = outline->points + first;
FT_Vector* q = outline->points + last;
FT_Vector swap;
while ( p < q )
{
swap = *p;
*p = *q;
*q = swap;
p++;
q--;
}
}
/* reverse tags table */
{
char* p = outline->tags + first;
char* q = outline->tags + last;
while ( p < q )
{
char swap;
swap = *p;
*p = *q;
*q = swap;
p++;
q--;
}
}
first = last + 1;
}
outline->flags ^= FT_OUTLINE_REVERSE_FILL;
}
/* documentation is in ftoutln.h */
FT_EXPORT_DEF( FT_Error )
FT_Outline_Render( FT_Library library,
FT_Outline* outline,
FT_Raster_Params* params )
{
FT_Error error;
FT_Renderer renderer;
FT_ListNode node;
FT_BBox cbox;
if ( !library )
return FT_THROW( Invalid_Library_Handle );
if ( !outline )
return FT_THROW( Invalid_Outline );
if ( !params )
return FT_THROW( Invalid_Argument );
FT_Outline_Get_CBox( outline, &cbox );
if ( cbox.xMin < -0x1000000L || cbox.yMin < -0x1000000L ||
cbox.xMax > 0x1000000L || cbox.yMax > 0x1000000L )
return FT_THROW( Invalid_Outline );
renderer = library->cur_renderer;
node = library->renderers.head;
params->source = (void*)outline;
/* preset clip_box for direct mode */
if ( params->flags & FT_RASTER_FLAG_DIRECT &&
!( params->flags & FT_RASTER_FLAG_CLIP ) )
{
params->clip_box.xMin = cbox.xMin >> 6;
params->clip_box.yMin = cbox.yMin >> 6;
params->clip_box.xMax = ( cbox.xMax + 63 ) >> 6;
params->clip_box.yMax = ( cbox.yMax + 63 ) >> 6;
}
error = FT_ERR( Cannot_Render_Glyph );
while ( renderer )
{
error = renderer->raster_render( renderer->raster, params );
if ( !error || FT_ERR_NEQ( error, Cannot_Render_Glyph ) )
break;
/* FT_Err_Cannot_Render_Glyph is returned if the render mode */
/* is unsupported by the current renderer for this glyph image */
/* format */
/* now, look for another renderer that supports the same */
/* format */
renderer = FT_Lookup_Renderer( library, FT_GLYPH_FORMAT_OUTLINE,
&node );
}
return error;
}
/* documentation is in ftoutln.h */
FT_EXPORT_DEF( FT_Error )
FT_Outline_Get_Bitmap( FT_Library library,
FT_Outline* outline,
const FT_Bitmap *abitmap )
{
FT_Raster_Params params;
if ( !abitmap )
return FT_THROW( Invalid_Argument );
/* other checks are delayed to `FT_Outline_Render' */
params.target = abitmap;
params.flags = 0;
if ( abitmap->pixel_mode == FT_PIXEL_MODE_GRAY ||
abitmap->pixel_mode == FT_PIXEL_MODE_LCD ||
abitmap->pixel_mode == FT_PIXEL_MODE_LCD_V )
params.flags |= FT_RASTER_FLAG_AA;
return FT_Outline_Render( library, outline, ¶ms );
}
/* documentation is in freetype.h */
FT_EXPORT_DEF( void )
FT_Vector_Transform( FT_Vector* vector,
const FT_Matrix* matrix )
{
FT_Pos xz, yz;
if ( !vector || !matrix )
return;
xz = FT_MulFix( vector->x, matrix->xx ) +
FT_MulFix( vector->y, matrix->xy );
yz = FT_MulFix( vector->x, matrix->yx ) +
FT_MulFix( vector->y, matrix->yy );
vector->x = xz;
vector->y = yz;
}
/* documentation is in ftoutln.h */
FT_EXPORT_DEF( void )
FT_Outline_Transform( const FT_Outline* outline,
const FT_Matrix* matrix )
{
FT_Vector* vec;
FT_Vector* limit;
if ( !outline || !matrix || !outline->points )
return;
vec = outline->points;
limit = vec + outline->n_points;
for ( ; vec < limit; vec++ )
FT_Vector_Transform( vec, matrix );
}
#if 0
#define FT_OUTLINE_GET_CONTOUR( outline, c, first, last ) \
do \
{ \
(first) = ( c > 0 ) ? (outline)->points + \
(outline)->contours[c - 1] + 1 \
: (outline)->points; \
(last) = (outline)->points + (outline)->contours[c]; \
} while ( 0 )
/* Is a point in some contour? */
/* */
/* We treat every point of the contour as if it */
/* it were ON. That is, we allow false positives, */
/* but disallow false negatives. (XXX really?) */
static FT_Bool
ft_contour_has( FT_Outline* outline,
FT_Short c,
FT_Vector* point )
{
FT_Vector* first;
FT_Vector* last;
FT_Vector* a;
FT_Vector* b;
FT_UInt n = 0;
FT_OUTLINE_GET_CONTOUR( outline, c, first, last );
for ( a = first; a <= last; a++ )
{
FT_Pos x;
FT_Int intersect;
b = ( a == last ) ? first : a + 1;
intersect = ( a->y - point->y ) ^ ( b->y - point->y );
/* a and b are on the same side */
if ( intersect >= 0 )
{
if ( intersect == 0 && a->y == point->y )
{
if ( ( a->x <= point->x && b->x >= point->x ) ||
( a->x >= point->x && b->x <= point->x ) )
return 1;
}
continue;
}
x = a->x + ( b->x - a->x ) * (point->y - a->y ) / ( b->y - a->y );
if ( x < point->x )
n++;
else if ( x == point->x )
return 1;
}
return n & 1;
}
static FT_Bool
ft_contour_enclosed( FT_Outline* outline,
FT_UShort c )
{
FT_Vector* first;
FT_Vector* last;
FT_Short i;
FT_OUTLINE_GET_CONTOUR( outline, c, first, last );
for ( i = 0; i < outline->n_contours; i++ )
{
if ( i != c && ft_contour_has( outline, i, first ) )
{
FT_Vector* pt;
for ( pt = first + 1; pt <= last; pt++ )
if ( !ft_contour_has( outline, i, pt ) )
return 0;
return 1;
}
}
return 0;
}
/* This version differs from the public one in that each */
/* part (contour not enclosed in another contour) of the */
/* outline is checked for orientation. This is */
/* necessary for some buggy CJK fonts. */
static FT_Orientation
ft_outline_get_orientation( FT_Outline* outline )
{
FT_Short i;
FT_Vector* first;
FT_Vector* last;
FT_Orientation orient = FT_ORIENTATION_NONE;
first = outline->points;
for ( i = 0; i < outline->n_contours; i++, first = last + 1 )
{
FT_Vector* point;
FT_Vector* xmin_point;
FT_Pos xmin;
last = outline->points + outline->contours[i];
/* skip degenerate contours */
if ( last < first + 2 )
continue;
if ( ft_contour_enclosed( outline, i ) )
continue;
xmin = first->x;
xmin_point = first;
for ( point = first + 1; point <= last; point++ )
{
if ( point->x < xmin )
{
xmin = point->x;
xmin_point = point;
}
}
/* check the orientation of the contour */
{
FT_Vector* prev;
FT_Vector* next;
FT_Orientation o;
prev = ( xmin_point == first ) ? last : xmin_point - 1;
next = ( xmin_point == last ) ? first : xmin_point + 1;
if ( FT_Atan2( prev->x - xmin_point->x, prev->y - xmin_point->y ) >
FT_Atan2( next->x - xmin_point->x, next->y - xmin_point->y ) )
o = FT_ORIENTATION_POSTSCRIPT;
else
o = FT_ORIENTATION_TRUETYPE;
if ( orient == FT_ORIENTATION_NONE )
orient = o;
else if ( orient != o )
return FT_ORIENTATION_NONE;
}
}
return orient;
}
#endif /* 0 */
/* documentation is in ftoutln.h */
FT_EXPORT_DEF( FT_Error )
FT_Outline_Embolden( FT_Outline* outline,
FT_Pos strength )
{
return FT_Outline_EmboldenXY( outline, strength, strength );
}
/* documentation is in ftoutln.h */
FT_EXPORT_DEF( FT_Error )
FT_Outline_EmboldenXY( FT_Outline* outline,
FT_Pos xstrength,
FT_Pos ystrength )
{
FT_Vector* points;
FT_Int c, first, last;
FT_Orientation orientation;
if ( !outline )
return FT_THROW( Invalid_Outline );
xstrength /= 2;
ystrength /= 2;
if ( xstrength == 0 && ystrength == 0 )
return FT_Err_Ok;
orientation = FT_Outline_Get_Orientation( outline );
if ( orientation == FT_ORIENTATION_NONE )
{
if ( outline->n_contours )
return FT_THROW( Invalid_Argument );
else
return FT_Err_Ok;
}
points = outline->points;
first = 0;
for ( c = 0; c < outline->n_contours; c++ )
{
FT_Vector in, out, anchor, shift;
FT_Fixed l_in, l_out, l_anchor = 0, l, q, d;
FT_Int i, j, k;
l_in = 0;
last = outline->contours[c];
/* pacify compiler */
in.x = in.y = anchor.x = anchor.y = 0;
/* Counter j cycles though the points; counter i advances only */
/* when points are moved; anchor k marks the first moved point. */
for ( i = last, j = first, k = -1;
j != i && i != k;
j = j < last ? j + 1 : first )
{
if ( j != k )
{
out.x = points[j].x - points[i].x;
out.y = points[j].y - points[i].y;
l_out = (FT_Fixed)FT_Vector_NormLen( &out );
if ( l_out == 0 )
continue;
}
else
{
out = anchor;
l_out = l_anchor;
}
if ( l_in != 0 )
{
if ( k < 0 )
{
k = i;
anchor = in;
l_anchor = l_in;
}
d = FT_MulFix( in.x, out.x ) + FT_MulFix( in.y, out.y );
/* shift only if turn is less than ~160 degrees */
if ( d > -0xF000L )
{
d = d + 0x10000L;
/* shift components along lateral bisector in proper orientation */
shift.x = in.y + out.y;
shift.y = in.x + out.x;
if ( orientation == FT_ORIENTATION_TRUETYPE )
shift.x = -shift.x;
else
shift.y = -shift.y;
/* restrict shift magnitude to better handle collapsing segments */
q = FT_MulFix( out.x, in.y ) - FT_MulFix( out.y, in.x );
if ( orientation == FT_ORIENTATION_TRUETYPE )
q = -q;
l = FT_MIN( l_in, l_out );
/* non-strict inequalities avoid divide-by-zero when q == l == 0 */
if ( FT_MulFix( xstrength, q ) <= FT_MulFix( l, d ) )
shift.x = FT_MulDiv( shift.x, xstrength, d );
else
shift.x = FT_MulDiv( shift.x, l, q );
if ( FT_MulFix( ystrength, q ) <= FT_MulFix( l, d ) )
shift.y = FT_MulDiv( shift.y, ystrength, d );
else
shift.y = FT_MulDiv( shift.y, l, q );
}
else
shift.x = shift.y = 0;
for ( ;
i != j;
i = i < last ? i + 1 : first )
{
points[i].x += xstrength + shift.x;
points[i].y += ystrength + shift.y;
}
}
else
i = j;
in = out;
l_in = l_out;
}
first = last + 1;
}
return FT_Err_Ok;
}
/* documentation is in ftoutln.h */
FT_EXPORT_DEF( FT_Orientation )
FT_Outline_Get_Orientation( FT_Outline* outline )
{
FT_BBox cbox = { 0, 0, 0, 0 };
FT_Int xshift, yshift;
FT_Vector* points;
FT_Vector v_prev, v_cur;
FT_Int c, n, first;
FT_Pos area = 0;
if ( !outline || outline->n_points <= 0 )
return FT_ORIENTATION_TRUETYPE;
/* We use the nonzero winding rule to find the orientation. */
/* Since glyph outlines behave much more `regular' than arbitrary */
/* cubic or quadratic curves, this test deals with the polygon */
/* only that is spanned up by the control points. */
FT_Outline_Get_CBox( outline, &cbox );
/* Handle collapsed outlines to avoid undefined FT_MSB. */
if ( cbox.xMin == cbox.xMax || cbox.yMin == cbox.yMax )
return FT_ORIENTATION_NONE;
/* Reject values large outlines. */
if ( cbox.xMin < -0x1000000L || cbox.yMin < -0x1000000L ||
cbox.xMax > 0x1000000L || cbox.yMax > 0x1000000L )
return FT_ORIENTATION_NONE;
xshift = FT_MSB( (FT_UInt32)( FT_ABS( cbox.xMax ) |
FT_ABS( cbox.xMin ) ) ) - 14;
xshift = FT_MAX( xshift, 0 );
yshift = FT_MSB( (FT_UInt32)( cbox.yMax - cbox.yMin ) ) - 14;
yshift = FT_MAX( yshift, 0 );
points = outline->points;
first = 0;
for ( c = 0; c < outline->n_contours; c++ )
{
FT_Int last = outline->contours[c];
v_prev.x = points[last].x >> xshift;
v_prev.y = points[last].y >> yshift;
for ( n = first; n <= last; n++ )
{
v_cur.x = points[n].x >> xshift;
v_cur.y = points[n].y >> yshift;
area = ADD_LONG( area,
MUL_LONG( v_cur.y - v_prev.y,
v_cur.x + v_prev.x ) );
v_prev = v_cur;
}
first = last + 1;
}
if ( area > 0 )
return FT_ORIENTATION_POSTSCRIPT;
else if ( area < 0 )
return FT_ORIENTATION_TRUETYPE;
else
return FT_ORIENTATION_NONE;
}
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/base/ftoutln.c
|
C++
|
gpl-3.0
| 27,990
|
/****************************************************************************
*
* ftpatent.c
*
* FreeType API for checking patented TrueType bytecode instructions
* (body). Obsolete, retained for backward compatibility.
*
* Copyright (C) 2007-2022 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.
*
*/
#include <freetype/freetype.h>
#include <freetype/tttags.h>
#include <freetype/internal/ftobjs.h>
#include <freetype/internal/ftstream.h>
#include <freetype/internal/services/svsfnt.h>
#include <freetype/internal/services/svttglyf.h>
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Bool )
FT_Face_CheckTrueTypePatents( FT_Face face )
{
FT_UNUSED( face );
return FALSE;
}
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Bool )
FT_Face_SetUnpatentedHinting( FT_Face face,
FT_Bool value )
{
FT_UNUSED( face );
FT_UNUSED( value );
return FALSE;
}
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/base/ftpatent.c
|
C++
|
gpl-3.0
| 1,245
|
/****************************************************************************
*
* ftpfr.c
*
* FreeType API for accessing PFR-specific data (body).
*
* Copyright (C) 2002-2022 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.
*
*/
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/ftobjs.h>
#include <freetype/internal/services/svpfr.h>
/* check the format */
static FT_Service_PfrMetrics
ft_pfr_check( FT_Face face )
{
FT_Service_PfrMetrics service = NULL;
if ( face )
FT_FACE_LOOKUP_SERVICE( face, service, PFR_METRICS );
return service;
}
/* documentation is in ftpfr.h */
FT_EXPORT_DEF( FT_Error )
FT_Get_PFR_Metrics( FT_Face face,
FT_UInt *aoutline_resolution,
FT_UInt *ametrics_resolution,
FT_Fixed *ametrics_x_scale,
FT_Fixed *ametrics_y_scale )
{
FT_Error error = FT_Err_Ok;
FT_Service_PfrMetrics service;
if ( !face )
return FT_THROW( Invalid_Face_Handle );
service = ft_pfr_check( face );
if ( service )
{
error = service->get_metrics( face,
aoutline_resolution,
ametrics_resolution,
ametrics_x_scale,
ametrics_y_scale );
}
else
{
FT_Fixed x_scale, y_scale;
/* this is not a PFR font */
if ( aoutline_resolution )
*aoutline_resolution = face->units_per_EM;
if ( ametrics_resolution )
*ametrics_resolution = face->units_per_EM;
x_scale = y_scale = 0x10000L;
if ( face->size )
{
x_scale = face->size->metrics.x_scale;
y_scale = face->size->metrics.y_scale;
}
if ( ametrics_x_scale )
*ametrics_x_scale = x_scale;
if ( ametrics_y_scale )
*ametrics_y_scale = y_scale;
error = FT_THROW( Unknown_File_Format );
}
return error;
}
/* documentation is in ftpfr.h */
FT_EXPORT_DEF( FT_Error )
FT_Get_PFR_Kerning( FT_Face face,
FT_UInt left,
FT_UInt right,
FT_Vector *avector )
{
FT_Error error;
FT_Service_PfrMetrics service;
if ( !face )
return FT_THROW( Invalid_Face_Handle );
if ( !avector )
return FT_THROW( Invalid_Argument );
service = ft_pfr_check( face );
if ( service )
error = service->get_kerning( face, left, right, avector );
else
error = FT_Get_Kerning( face, left, right,
FT_KERNING_UNSCALED, avector );
return error;
}
/* documentation is in ftpfr.h */
FT_EXPORT_DEF( FT_Error )
FT_Get_PFR_Advance( FT_Face face,
FT_UInt gindex,
FT_Pos *aadvance )
{
FT_Error error;
FT_Service_PfrMetrics service;
if ( !face )
return FT_THROW( Invalid_Face_Handle );
if ( !aadvance )
return FT_THROW( Invalid_Argument );
service = ft_pfr_check( face );
if ( service )
error = service->get_advance( face, gindex, aadvance );
else
/* XXX: TODO: PROVIDE ADVANCE-LOADING METHOD TO ALL FONT DRIVERS */
error = FT_THROW( Invalid_Argument );
return error;
}
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/base/ftpfr.c
|
C++
|
gpl-3.0
| 3,730
|
/****************************************************************************
*
* ftpsprop.c
*
* Get and set properties of PostScript drivers (body).
* See `ftdriver.h' for available properties.
*
* Copyright (C) 2017-2022 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.
*
*/
#include <freetype/ftdriver.h>
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/psaux.h>
#include <freetype/internal/ftobjs.h>
#include <freetype/internal/ftpsprop.h>
/**************************************************************************
*
* The macro FT_COMPONENT is used in trace mode. It is an implicit
* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
* messages during execution.
*/
#undef FT_COMPONENT
#define FT_COMPONENT psprops
FT_BASE_CALLBACK_DEF( FT_Error )
ps_property_set( FT_Module module, /* PS_Driver */
const char* property_name,
const void* value,
FT_Bool value_is_string )
{
FT_Error error = FT_Err_Ok;
PS_Driver driver = (PS_Driver)module;
#ifndef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
FT_UNUSED( value_is_string );
#endif
if ( !ft_strcmp( property_name, "darkening-parameters" ) )
{
FT_Int* darken_params;
FT_Int x1, y1, x2, y2, x3, y3, x4, y4;
#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
FT_Int dp[8];
if ( value_is_string )
{
const char* s = (const char*)value;
char* ep;
int i;
/* eight comma-separated numbers */
for ( i = 0; i < 7; i++ )
{
dp[i] = (FT_Int)ft_strtol( s, &ep, 10 );
if ( *ep != ',' || s == ep )
return FT_THROW( Invalid_Argument );
s = ep + 1;
}
dp[7] = (FT_Int)ft_strtol( s, &ep, 10 );
if ( !( *ep == '\0' || *ep == ' ' ) || s == ep )
return FT_THROW( Invalid_Argument );
darken_params = dp;
}
else
#endif
darken_params = (FT_Int*)value;
x1 = darken_params[0];
y1 = darken_params[1];
x2 = darken_params[2];
y2 = darken_params[3];
x3 = darken_params[4];
y3 = darken_params[5];
x4 = darken_params[6];
y4 = darken_params[7];
if ( x1 < 0 || x2 < 0 || x3 < 0 || x4 < 0 ||
y1 < 0 || y2 < 0 || y3 < 0 || y4 < 0 ||
x1 > x2 || x2 > x3 || x3 > x4 ||
y1 > 500 || y2 > 500 || y3 > 500 || y4 > 500 )
return FT_THROW( Invalid_Argument );
driver->darken_params[0] = x1;
driver->darken_params[1] = y1;
driver->darken_params[2] = x2;
driver->darken_params[3] = y2;
driver->darken_params[4] = x3;
driver->darken_params[5] = y3;
driver->darken_params[6] = x4;
driver->darken_params[7] = y4;
return error;
}
else if ( !ft_strcmp( property_name, "hinting-engine" ) )
{
#if defined( CFF_CONFIG_OPTION_OLD_ENGINE ) || \
defined( T1_CONFIG_OPTION_OLD_ENGINE )
const char* module_name = module->clazz->module_name;
#endif
#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
if ( value_is_string )
{
const char* s = (const char*)value;
if ( !ft_strcmp( s, "adobe" ) )
driver->hinting_engine = FT_HINTING_ADOBE;
#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
else if ( !ft_strcmp( module_name, "cff" ) &&
!ft_strcmp( s, "freetype" ) )
driver->hinting_engine = FT_HINTING_FREETYPE;
#endif
#ifdef T1_CONFIG_OPTION_OLD_ENGINE
else if ( ( !ft_strcmp( module_name, "type1" ) ||
!ft_strcmp( module_name, "t1cid" ) ) &&
!ft_strcmp( s, "freetype" ) )
driver->hinting_engine = FT_HINTING_FREETYPE;
#endif
else
return FT_THROW( Invalid_Argument );
}
else
#endif /* FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES */
{
FT_UInt* hinting_engine = (FT_UInt*)value;
if ( *hinting_engine == FT_HINTING_ADOBE
#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
|| ( *hinting_engine == FT_HINTING_FREETYPE &&
!ft_strcmp( module_name, "cff" ) )
#endif
#ifdef T1_CONFIG_OPTION_OLD_ENGINE
|| ( *hinting_engine == FT_HINTING_FREETYPE &&
( !ft_strcmp( module_name, "type1" ) ||
!ft_strcmp( module_name, "t1cid" ) ) )
#endif
)
driver->hinting_engine = *hinting_engine;
else
error = FT_ERR( Unimplemented_Feature );
}
return error;
}
else if ( !ft_strcmp( property_name, "no-stem-darkening" ) )
{
#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
if ( value_is_string )
{
const char* s = (const char*)value;
long nsd = ft_strtol( s, NULL, 10 );
if ( !nsd )
driver->no_stem_darkening = FALSE;
else
driver->no_stem_darkening = TRUE;
}
else
#endif
{
FT_Bool* no_stem_darkening = (FT_Bool*)value;
driver->no_stem_darkening = *no_stem_darkening;
}
return error;
}
else if ( !ft_strcmp( property_name, "random-seed" ) )
{
FT_Int32 random_seed;
#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
if ( value_is_string )
{
const char* s = (const char*)value;
random_seed = (FT_Int32)ft_strtol( s, NULL, 10 );
}
else
#endif
random_seed = *(FT_Int32*)value;
if ( random_seed < 0 )
random_seed = 0;
driver->random_seed = random_seed;
return error;
}
FT_TRACE2(( "ps_property_set: missing property `%s'\n",
property_name ));
return FT_THROW( Missing_Property );
}
FT_BASE_CALLBACK_DEF( FT_Error )
ps_property_get( FT_Module module, /* PS_Driver */
const char* property_name,
void* value )
{
FT_Error error = FT_Err_Ok;
PS_Driver driver = (PS_Driver)module;
if ( !ft_strcmp( property_name, "darkening-parameters" ) )
{
FT_Int* darken_params = driver->darken_params;
FT_Int* val = (FT_Int*)value;
val[0] = darken_params[0];
val[1] = darken_params[1];
val[2] = darken_params[2];
val[3] = darken_params[3];
val[4] = darken_params[4];
val[5] = darken_params[5];
val[6] = darken_params[6];
val[7] = darken_params[7];
return error;
}
else if ( !ft_strcmp( property_name, "hinting-engine" ) )
{
FT_UInt hinting_engine = driver->hinting_engine;
FT_UInt* val = (FT_UInt*)value;
*val = hinting_engine;
return error;
}
else if ( !ft_strcmp( property_name, "no-stem-darkening" ) )
{
FT_Bool no_stem_darkening = driver->no_stem_darkening;
FT_Bool* val = (FT_Bool*)value;
*val = no_stem_darkening;
return error;
}
FT_TRACE2(( "ps_property_get: missing property `%s'\n",
property_name ));
return FT_THROW( Missing_Property );
}
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/base/ftpsprop.c
|
C++
|
gpl-3.0
| 7,500
|
/****************************************************************************
*
* ftrfork.c
*
* Embedded resource forks accessor (body).
*
* Copyright (C) 2004-2022 by
* Masatake YAMATO and Redhat K.K.
*
* FT_Raccess_Get_HeaderInfo() and raccess_guess_darwin_hfsplus() are
* derived from ftobjs.c.
*
* 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.
*
*/
/****************************************************************************
* Development of the code in this file is support of
* Information-technology Promotion Agency, Japan.
*/
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/ftstream.h>
#include <freetype/internal/ftrfork.h>
#include "ftbase.h"
#undef FT_COMPONENT
#define FT_COMPONENT raccess
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/**** ****/
/**** ****/
/**** Resource fork directory access ****/
/**** ****/
/**** ****/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
FT_BASE_DEF( FT_Error )
FT_Raccess_Get_HeaderInfo( FT_Library library,
FT_Stream stream,
FT_Long rfork_offset,
FT_Long *map_offset,
FT_Long *rdata_pos )
{
FT_Error error;
unsigned char head[16], head2[16];
FT_Long map_pos, map_len, rdata_len;
int allzeros, allmatch, i;
FT_Long type_list;
FT_UNUSED( library );
error = FT_Stream_Seek( stream, (FT_ULong)rfork_offset );
if ( error )
return error;
error = FT_Stream_Read( stream, (FT_Byte*)head, 16 );
if ( error )
return error;
/* ensure positive values */
if ( head[0] >= 0x80 ||
head[4] >= 0x80 ||
head[8] >= 0x80 ||
head[12] >= 0x80 )
return FT_THROW( Unknown_File_Format );
*rdata_pos = ( head[ 0] << 24 ) |
( head[ 1] << 16 ) |
( head[ 2] << 8 ) |
head[ 3];
map_pos = ( head[ 4] << 24 ) |
( head[ 5] << 16 ) |
( head[ 6] << 8 ) |
head[ 7];
rdata_len = ( head[ 8] << 24 ) |
( head[ 9] << 16 ) |
( head[10] << 8 ) |
head[11];
map_len = ( head[12] << 24 ) |
( head[13] << 16 ) |
( head[14] << 8 ) |
head[15];
/* the map must not be empty */
if ( !map_pos )
return FT_THROW( Unknown_File_Format );
/* check whether rdata and map overlap */
if ( *rdata_pos < map_pos )
{
if ( *rdata_pos > map_pos - rdata_len )
return FT_THROW( Unknown_File_Format );
}
else
{
if ( map_pos > *rdata_pos - map_len )
return FT_THROW( Unknown_File_Format );
}
/* check whether end of rdata or map exceeds stream size */
if ( FT_LONG_MAX - rdata_len < *rdata_pos ||
FT_LONG_MAX - map_len < map_pos ||
FT_LONG_MAX - ( *rdata_pos + rdata_len ) < rfork_offset ||
FT_LONG_MAX - ( map_pos + map_len ) < rfork_offset ||
(FT_ULong)( rfork_offset + *rdata_pos + rdata_len ) > stream->size ||
(FT_ULong)( rfork_offset + map_pos + map_len ) > stream->size )
return FT_THROW( Unknown_File_Format );
*rdata_pos += rfork_offset;
map_pos += rfork_offset;
error = FT_Stream_Seek( stream, (FT_ULong)map_pos );
if ( error )
return error;
head2[15] = (FT_Byte)( head[15] + 1 ); /* make it be different */
error = FT_Stream_Read( stream, (FT_Byte*)head2, 16 );
if ( error )
return error;
allzeros = 1;
allmatch = 1;
for ( i = 0; i < 16; i++ )
{
if ( head2[i] != 0 )
allzeros = 0;
if ( head2[i] != head[i] )
allmatch = 0;
}
if ( !allzeros && !allmatch )
return FT_THROW( Unknown_File_Format );
/* If we have reached this point then it is probably a mac resource */
/* file. Now, does it contain any interesting resources? */
(void)FT_STREAM_SKIP( 4 /* skip handle to next resource map */
+ 2 /* skip file resource number */
+ 2 ); /* skip attributes */
if ( FT_READ_SHORT( type_list ) )
return error;
if ( type_list < 0 )
return FT_THROW( Unknown_File_Format );
error = FT_Stream_Seek( stream, (FT_ULong)( map_pos + type_list ) );
if ( error )
return error;
*map_offset = map_pos + type_list;
return FT_Err_Ok;
}
FT_COMPARE_DEF( int )
ft_raccess_sort_ref_by_id( const void* a,
const void* b )
{
return ( (FT_RFork_Ref*)a )->res_id - ( (FT_RFork_Ref*)b )->res_id;
}
FT_BASE_DEF( FT_Error )
FT_Raccess_Get_DataOffsets( FT_Library library,
FT_Stream stream,
FT_Long map_offset,
FT_Long rdata_pos,
FT_Long tag,
FT_Bool sort_by_res_id,
FT_Long **offsets,
FT_Long *count )
{
FT_Error error;
int i, j, cnt, subcnt;
FT_Long tag_internal, rpos;
FT_Memory memory = library->memory;
FT_Long temp;
FT_Long *offsets_internal = NULL;
FT_RFork_Ref *ref = NULL;
FT_TRACE3(( "\n" ));
error = FT_Stream_Seek( stream, (FT_ULong)map_offset );
if ( error )
return error;
if ( FT_READ_SHORT( cnt ) )
return error;
cnt++;
/* `rpos' is a signed 16bit integer offset to resource records; the */
/* size of a resource record is 12 bytes. The map header is 28 bytes, */
/* and a type list needs 10 bytes or more. If we assume that the name */
/* list is empty and we have only a single entry in the type list, */
/* there can be at most */
/* */
/* (32768 - 28 - 10) / 12 = 2727 */
/* */
/* resources. */
/* */
/* A type list starts with a two-byte counter, followed by 10-byte */
/* type records. Assuming that there are no resources, the number of */
/* type records can be at most */
/* */
/* (32768 - 28 - 2) / 8 = 4079 */
/* */
if ( cnt > 4079 )
return FT_THROW( Invalid_Table );
for ( i = 0; i < cnt; i++ )
{
if ( FT_READ_LONG( tag_internal ) ||
FT_READ_SHORT( subcnt ) ||
FT_READ_SHORT( rpos ) )
return error;
FT_TRACE2(( "Resource tags: %c%c%c%c\n",
(char)( 0xFF & ( tag_internal >> 24 ) ),
(char)( 0xFF & ( tag_internal >> 16 ) ),
(char)( 0xFF & ( tag_internal >> 8 ) ),
(char)( 0xFF & ( tag_internal >> 0 ) ) ));
FT_TRACE3(( " : subcount=%d, suboffset=0x%04lx\n",
subcnt, rpos ));
if ( tag_internal == tag )
{
*count = subcnt + 1;
rpos += map_offset;
/* a zero count might be valid in the resource specification, */
/* however, it is completely useless to us */
if ( *count < 1 || *count > 2727 )
return FT_THROW( Invalid_Table );
error = FT_Stream_Seek( stream, (FT_ULong)rpos );
if ( error )
return error;
if ( FT_QNEW_ARRAY( ref, *count ) )
return error;
for ( j = 0; j < *count; j++ )
{
if ( FT_READ_SHORT( ref[j].res_id ) )
goto Exit;
if ( FT_STREAM_SKIP( 2 ) ) /* resource name offset */
goto Exit;
if ( FT_READ_LONG( temp ) ) /* attributes (8bit), offset (24bit) */
goto Exit;
if ( FT_STREAM_SKIP( 4 ) ) /* mbz */
goto Exit;
/*
* According to Inside Macintosh: More Macintosh Toolbox,
* "Resource IDs" (1-46), there are some reserved IDs.
* However, FreeType2 is not a font synthesizer, no need
* to check the acceptable resource ID.
*/
if ( temp < 0 )
{
error = FT_THROW( Invalid_Table );
goto Exit;
}
ref[j].offset = temp & 0xFFFFFFL;
FT_TRACE3(( " [%d]:"
" resource_id=0x%04x, offset=0x%08lx\n",
j, (FT_UShort)ref[j].res_id, ref[j].offset ));
}
if ( sort_by_res_id )
{
ft_qsort( ref,
(size_t)*count,
sizeof ( FT_RFork_Ref ),
ft_raccess_sort_ref_by_id );
FT_TRACE3(( " -- sort resources by their ids --\n" ));
for ( j = 0; j < *count; j++ )
FT_TRACE3(( " [%d]:"
" resource_id=0x%04x, offset=0x%08lx\n",
j, ref[j].res_id, ref[j].offset ));
}
if ( FT_QNEW_ARRAY( offsets_internal, *count ) )
goto Exit;
/* XXX: duplicated reference ID,
* gap between reference IDs are acceptable?
* further investigation on Apple implementation is needed.
*/
for ( j = 0; j < *count; j++ )
offsets_internal[j] = rdata_pos + ref[j].offset;
*offsets = offsets_internal;
error = FT_Err_Ok;
Exit:
FT_FREE( ref );
return error;
}
}
return FT_THROW( Cannot_Open_Resource );
}
#ifdef FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/**** ****/
/**** ****/
/**** Guessing functions ****/
/**** ****/
/**** When you add a new guessing function, ****/
/**** update FT_RACCESS_N_RULES in ftrfork.h. ****/
/**** ****/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
static FT_Error
raccess_guess_apple_double( FT_Library library,
FT_Stream stream,
char *base_file_name,
char **result_file_name,
FT_Long *result_offset );
static FT_Error
raccess_guess_apple_single( FT_Library library,
FT_Stream stream,
char *base_file_name,
char **result_file_name,
FT_Long *result_offset );
static FT_Error
raccess_guess_darwin_ufs_export( FT_Library library,
FT_Stream stream,
char *base_file_name,
char **result_file_name,
FT_Long *result_offset );
static FT_Error
raccess_guess_darwin_newvfs( FT_Library library,
FT_Stream stream,
char *base_file_name,
char **result_file_name,
FT_Long *result_offset );
static FT_Error
raccess_guess_darwin_hfsplus( FT_Library library,
FT_Stream stream,
char *base_file_name,
char **result_file_name,
FT_Long *result_offset );
static FT_Error
raccess_guess_vfat( FT_Library library,
FT_Stream stream,
char *base_file_name,
char **result_file_name,
FT_Long *result_offset );
static FT_Error
raccess_guess_linux_cap( FT_Library library,
FT_Stream stream,
char *base_file_name,
char **result_file_name,
FT_Long *result_offset );
static FT_Error
raccess_guess_linux_double( FT_Library library,
FT_Stream stream,
char *base_file_name,
char **result_file_name,
FT_Long *result_offset );
static FT_Error
raccess_guess_linux_netatalk( FT_Library library,
FT_Stream stream,
char *base_file_name,
char **result_file_name,
FT_Long *result_offset );
CONST_FT_RFORK_RULE_ARRAY_BEGIN(ft_raccess_guess_table,
ft_raccess_guess_rec)
CONST_FT_RFORK_RULE_ARRAY_ENTRY(apple_double, apple_double)
CONST_FT_RFORK_RULE_ARRAY_ENTRY(apple_single, apple_single)
CONST_FT_RFORK_RULE_ARRAY_ENTRY(darwin_ufs_export, darwin_ufs_export)
CONST_FT_RFORK_RULE_ARRAY_ENTRY(darwin_newvfs, darwin_newvfs)
CONST_FT_RFORK_RULE_ARRAY_ENTRY(darwin_hfsplus, darwin_hfsplus)
CONST_FT_RFORK_RULE_ARRAY_ENTRY(vfat, vfat)
CONST_FT_RFORK_RULE_ARRAY_ENTRY(linux_cap, linux_cap)
CONST_FT_RFORK_RULE_ARRAY_ENTRY(linux_double, linux_double)
CONST_FT_RFORK_RULE_ARRAY_ENTRY(linux_netatalk, linux_netatalk)
CONST_FT_RFORK_RULE_ARRAY_END
/*************************************************************************/
/**** ****/
/**** Helper functions ****/
/**** ****/
/*************************************************************************/
static FT_Error
raccess_guess_apple_generic( FT_Library library,
FT_Stream stream,
char *base_file_name,
FT_Int32 magic,
FT_Long *result_offset );
static FT_Error
raccess_guess_linux_double_from_file_name( FT_Library library,
char* file_name,
FT_Long *result_offset );
static char *
raccess_make_file_name( FT_Memory memory,
const char *original_name,
const char *insertion );
FT_BASE_DEF( void )
FT_Raccess_Guess( FT_Library library,
FT_Stream stream,
char* base_name,
char **new_names,
FT_Long *offsets,
FT_Error *errors )
{
FT_Int i;
for ( i = 0; i < FT_RACCESS_N_RULES; i++ )
{
new_names[i] = NULL;
if ( NULL != stream )
errors[i] = FT_Stream_Seek( stream, 0 );
else
errors[i] = FT_Err_Ok;
if ( errors[i] )
continue;
errors[i] = ft_raccess_guess_table[i].func( library,
stream, base_name,
&(new_names[i]),
&(offsets[i]) );
}
return;
}
#if defined( FT_CONFIG_OPTION_MAC_FONTS ) && !defined( FT_MACINTOSH )
static FT_RFork_Rule
raccess_get_rule_type_from_rule_index( FT_Library library,
FT_UInt rule_index )
{
FT_UNUSED( library );
if ( rule_index >= FT_RACCESS_N_RULES )
return FT_RFork_Rule_invalid;
return ft_raccess_guess_table[rule_index].type;
}
/*
* For this function, refer ftbase.h.
*/
FT_LOCAL_DEF( FT_Bool )
ft_raccess_rule_by_darwin_vfs( FT_Library library,
FT_UInt rule_index )
{
switch( raccess_get_rule_type_from_rule_index( library, rule_index ) )
{
case FT_RFork_Rule_darwin_newvfs:
case FT_RFork_Rule_darwin_hfsplus:
return TRUE;
default:
return FALSE;
}
}
#endif
static FT_Error
raccess_guess_apple_double( FT_Library library,
FT_Stream stream,
char *base_file_name,
char **result_file_name,
FT_Long *result_offset )
{
FT_Int32 magic = ( 0x00 << 24 ) |
( 0x05 << 16 ) |
( 0x16 << 8 ) |
0x07;
*result_file_name = NULL;
if ( NULL == stream )
return FT_THROW( Cannot_Open_Stream );
return raccess_guess_apple_generic( library, stream, base_file_name,
magic, result_offset );
}
static FT_Error
raccess_guess_apple_single( FT_Library library,
FT_Stream stream,
char *base_file_name,
char **result_file_name,
FT_Long *result_offset )
{
FT_Int32 magic = ( 0x00 << 24 ) |
( 0x05 << 16 ) |
( 0x16 << 8 ) |
0x00;
*result_file_name = NULL;
if ( NULL == stream )
return FT_THROW( Cannot_Open_Stream );
return raccess_guess_apple_generic( library, stream, base_file_name,
magic, result_offset );
}
static FT_Error
raccess_guess_darwin_ufs_export( FT_Library library,
FT_Stream stream,
char *base_file_name,
char **result_file_name,
FT_Long *result_offset )
{
char* newpath;
FT_Error error;
FT_Memory memory;
FT_UNUSED( stream );
memory = library->memory;
newpath = raccess_make_file_name( memory, base_file_name, "._" );
if ( !newpath )
return FT_THROW( Out_Of_Memory );
error = raccess_guess_linux_double_from_file_name( library, newpath,
result_offset );
if ( !error )
*result_file_name = newpath;
else
FT_FREE( newpath );
return error;
}
static FT_Error
raccess_guess_darwin_hfsplus( FT_Library library,
FT_Stream stream,
char *base_file_name,
char **result_file_name,
FT_Long *result_offset )
{
/*
Only meaningful on systems with hfs+ drivers (or Macs).
*/
FT_Error error;
char* newpath = NULL;
FT_Memory memory;
FT_Long base_file_len = (FT_Long)ft_strlen( base_file_name );
FT_UNUSED( stream );
memory = library->memory;
if ( base_file_len + 6 > FT_INT_MAX )
return FT_THROW( Array_Too_Large );
if ( FT_QALLOC( newpath, base_file_len + 6 ) )
return error;
FT_MEM_COPY( newpath, base_file_name, base_file_len );
FT_MEM_COPY( newpath + base_file_len, "/rsrc", 6 );
*result_file_name = newpath;
*result_offset = 0;
return FT_Err_Ok;
}
static FT_Error
raccess_guess_darwin_newvfs( FT_Library library,
FT_Stream stream,
char *base_file_name,
char **result_file_name,
FT_Long *result_offset )
{
/*
Only meaningful on systems with Mac OS X (> 10.1).
*/
FT_Error error;
char* newpath = NULL;
FT_Memory memory;
FT_Long base_file_len = (FT_Long)ft_strlen( base_file_name );
FT_UNUSED( stream );
memory = library->memory;
if ( base_file_len + 18 > FT_INT_MAX )
return FT_THROW( Array_Too_Large );
if ( FT_QALLOC( newpath, base_file_len + 18 ) )
return error;
FT_MEM_COPY( newpath, base_file_name, base_file_len );
FT_MEM_COPY( newpath + base_file_len, "/..namedfork/rsrc", 18 );
*result_file_name = newpath;
*result_offset = 0;
return FT_Err_Ok;
}
static FT_Error
raccess_guess_vfat( FT_Library library,
FT_Stream stream,
char *base_file_name,
char **result_file_name,
FT_Long *result_offset )
{
char* newpath;
FT_Memory memory;
FT_UNUSED( stream );
memory = library->memory;
newpath = raccess_make_file_name( memory, base_file_name,
"resource.frk/" );
if ( !newpath )
return FT_THROW( Out_Of_Memory );
*result_file_name = newpath;
*result_offset = 0;
return FT_Err_Ok;
}
static FT_Error
raccess_guess_linux_cap( FT_Library library,
FT_Stream stream,
char *base_file_name,
char **result_file_name,
FT_Long *result_offset )
{
char* newpath;
FT_Memory memory;
FT_UNUSED( stream );
memory = library->memory;
newpath = raccess_make_file_name( memory, base_file_name, ".resource/" );
if ( !newpath )
return FT_THROW( Out_Of_Memory );
*result_file_name = newpath;
*result_offset = 0;
return FT_Err_Ok;
}
static FT_Error
raccess_guess_linux_double( FT_Library library,
FT_Stream stream,
char *base_file_name,
char **result_file_name,
FT_Long *result_offset )
{
char* newpath;
FT_Error error;
FT_Memory memory;
FT_UNUSED( stream );
memory = library->memory;
newpath = raccess_make_file_name( memory, base_file_name, "%" );
if ( !newpath )
return FT_THROW( Out_Of_Memory );
error = raccess_guess_linux_double_from_file_name( library, newpath,
result_offset );
if ( !error )
*result_file_name = newpath;
else
FT_FREE( newpath );
return error;
}
static FT_Error
raccess_guess_linux_netatalk( FT_Library library,
FT_Stream stream,
char *base_file_name,
char **result_file_name,
FT_Long *result_offset )
{
char* newpath;
FT_Error error;
FT_Memory memory;
FT_UNUSED( stream );
memory = library->memory;
newpath = raccess_make_file_name( memory, base_file_name,
".AppleDouble/" );
if ( !newpath )
return FT_THROW( Out_Of_Memory );
error = raccess_guess_linux_double_from_file_name( library, newpath,
result_offset );
if ( !error )
*result_file_name = newpath;
else
FT_FREE( newpath );
return error;
}
static FT_Error
raccess_guess_apple_generic( FT_Library library,
FT_Stream stream,
char *base_file_name,
FT_Int32 magic,
FT_Long *result_offset )
{
FT_Int32 magic_from_stream;
FT_Error error;
FT_Int32 version_number = 0;
FT_UShort n_of_entries;
int i;
FT_Int32 entry_id, entry_offset, entry_length = 0;
const FT_Int32 resource_fork_entry_id = 0x2;
FT_UNUSED( library );
FT_UNUSED( base_file_name );
FT_UNUSED( version_number );
FT_UNUSED( entry_length );
if ( FT_READ_LONG( magic_from_stream ) )
return error;
if ( magic_from_stream != magic )
return FT_THROW( Unknown_File_Format );
if ( FT_READ_LONG( version_number ) )
return error;
/* filler */
error = FT_Stream_Skip( stream, 16 );
if ( error )
return error;
if ( FT_READ_USHORT( n_of_entries ) )
return error;
if ( n_of_entries == 0 )
return FT_THROW( Unknown_File_Format );
for ( i = 0; i < n_of_entries; i++ )
{
if ( FT_READ_LONG( entry_id ) )
return error;
if ( entry_id == resource_fork_entry_id )
{
if ( FT_READ_LONG( entry_offset ) ||
FT_READ_LONG( entry_length ) )
continue;
*result_offset = entry_offset;
return FT_Err_Ok;
}
else
{
error = FT_Stream_Skip( stream, 4 + 4 ); /* offset + length */
if ( error )
return error;
}
}
return FT_THROW( Unknown_File_Format );
}
static FT_Error
raccess_guess_linux_double_from_file_name( FT_Library library,
char *file_name,
FT_Long *result_offset )
{
FT_Open_Args args2;
FT_Stream stream2;
char* nouse = NULL;
FT_Error error;
args2.flags = FT_OPEN_PATHNAME;
args2.pathname = file_name;
error = FT_Stream_New( library, &args2, &stream2 );
if ( error )
return error;
error = raccess_guess_apple_double( library, stream2, file_name,
&nouse, result_offset );
FT_Stream_Free( stream2, 0 );
return error;
}
static char*
raccess_make_file_name( FT_Memory memory,
const char *original_name,
const char *insertion )
{
char* new_name = NULL;
const char* tmp;
const char* slash;
size_t new_length;
FT_Error error;
new_length = ft_strlen( original_name ) + ft_strlen( insertion );
if ( FT_QALLOC( new_name, new_length + 1 ) )
return NULL;
tmp = ft_strrchr( original_name, '/' );
if ( tmp )
{
ft_strncpy( new_name,
original_name,
(size_t)( tmp - original_name + 1 ) );
new_name[tmp - original_name + 1] = '\0';
slash = tmp + 1;
}
else
{
slash = original_name;
new_name[0] = '\0';
}
ft_strcat( new_name, insertion );
ft_strcat( new_name, slash );
return new_name;
}
#else /* !FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK */
/**************************************************************************
* Dummy function; just sets errors
*/
FT_BASE_DEF( void )
FT_Raccess_Guess( FT_Library library,
FT_Stream stream,
char *base_name,
char **new_names,
FT_Long *offsets,
FT_Error *errors )
{
FT_Int i;
FT_UNUSED( library );
FT_UNUSED( stream );
FT_UNUSED( base_name );
for ( i = 0; i < FT_RACCESS_N_RULES; i++ )
{
new_names[i] = NULL;
offsets[i] = 0;
errors[i] = FT_ERR( Unimplemented_Feature );
}
}
#endif /* !FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK */
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/base/ftrfork.c
|
C++
|
gpl-3.0
| 29,453
|
/****************************************************************************
*
* ftsnames.c
*
* Simple interface to access SFNT name tables (which are used
* to hold font names, copyright info, notices, etc.) (body).
*
* This is _not_ used to retrieve glyph names!
*
* Copyright (C) 1996-2022 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.
*
*/
#include <freetype/internal/ftdebug.h>
#include <freetype/ftsnames.h>
#include <freetype/internal/tttypes.h>
#include <freetype/internal/ftstream.h>
#ifdef TT_CONFIG_OPTION_SFNT_NAMES
/* documentation is in ftsnames.h */
FT_EXPORT_DEF( FT_UInt )
FT_Get_Sfnt_Name_Count( FT_Face face )
{
return ( face && FT_IS_SFNT( face ) ) ? ((TT_Face)face)->num_names : 0;
}
/* documentation is in ftsnames.h */
FT_EXPORT_DEF( FT_Error )
FT_Get_Sfnt_Name( FT_Face face,
FT_UInt idx,
FT_SfntName *aname )
{
FT_Error error = FT_ERR( Invalid_Argument );
if ( aname && face && FT_IS_SFNT( face ) )
{
TT_Face ttface = (TT_Face)face;
if ( idx < (FT_UInt)ttface->num_names )
{
TT_Name entry = ttface->name_table.names + idx;
/* load name on demand */
if ( entry->stringLength > 0 && !entry->string )
{
FT_Memory memory = face->memory;
FT_Stream stream = face->stream;
if ( FT_QNEW_ARRAY ( entry->string, entry->stringLength ) ||
FT_STREAM_SEEK( entry->stringOffset ) ||
FT_STREAM_READ( entry->string, entry->stringLength ) )
{
FT_FREE( entry->string );
entry->stringLength = 0;
}
}
aname->platform_id = entry->platformID;
aname->encoding_id = entry->encodingID;
aname->language_id = entry->languageID;
aname->name_id = entry->nameID;
aname->string = (FT_Byte*)entry->string;
aname->string_len = entry->stringLength;
error = FT_Err_Ok;
}
}
return error;
}
/* documentation is in ftsnames.h */
FT_EXPORT_DEF( FT_Error )
FT_Get_Sfnt_LangTag( FT_Face face,
FT_UInt langID,
FT_SfntLangTag *alangTag )
{
FT_Error error = FT_ERR( Invalid_Argument );
if ( alangTag && face && FT_IS_SFNT( face ) )
{
TT_Face ttface = (TT_Face)face;
if ( ttface->name_table.format != 1 )
return FT_THROW( Invalid_Table );
if ( langID > 0x8000U &&
langID - 0x8000U < ttface->name_table.numLangTagRecords )
{
TT_LangTag entry = ttface->name_table.langTags +
( langID - 0x8000U );
/* load name on demand */
if ( entry->stringLength > 0 && !entry->string )
{
FT_Memory memory = face->memory;
FT_Stream stream = face->stream;
if ( FT_QNEW_ARRAY ( entry->string, entry->stringLength ) ||
FT_STREAM_SEEK( entry->stringOffset ) ||
FT_STREAM_READ( entry->string, entry->stringLength ) )
{
FT_FREE( entry->string );
entry->stringLength = 0;
}
}
alangTag->string = (FT_Byte*)entry->string;
alangTag->string_len = entry->stringLength;
error = FT_Err_Ok;
}
}
return error;
}
#else /* !TT_CONFIG_OPTION_SFNT_NAMES */
FT_EXPORT_DEF( FT_UInt )
FT_Get_Sfnt_Name_Count( FT_Face face )
{
FT_UNUSED( face );
return 0;
}
FT_EXPORT_DEF( FT_Error )
FT_Get_Sfnt_Name( FT_Face face,
FT_UInt idx,
FT_SfntName *aname )
{
FT_UNUSED( face );
FT_UNUSED( idx );
FT_UNUSED( aname );
return FT_THROW( Unimplemented_Feature );
}
FT_EXPORT_DEF( FT_Error )
FT_Get_Sfnt_LangTag( FT_Face face,
FT_UInt langID,
FT_SfntLangTag *alangTag )
{
FT_UNUSED( face );
FT_UNUSED( langID );
FT_UNUSED( alangTag );
return FT_THROW( Unimplemented_Feature );
}
#endif /* !TT_CONFIG_OPTION_SFNT_NAMES */
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/base/ftsnames.c
|
C++
|
gpl-3.0
| 4,580
|
/****************************************************************************
*
* ftstream.c
*
* I/O stream support (body).
*
* Copyright (C) 2000-2022 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.
*
*/
#include <freetype/internal/ftstream.h>
#include <freetype/internal/ftdebug.h>
/**************************************************************************
*
* The macro FT_COMPONENT is used in trace mode. It is an implicit
* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
* messages during execution.
*/
#undef FT_COMPONENT
#define FT_COMPONENT stream
FT_BASE_DEF( void )
FT_Stream_OpenMemory( FT_Stream stream,
const FT_Byte* base,
FT_ULong size )
{
stream->base = (FT_Byte*) base;
stream->size = size;
stream->pos = 0;
stream->cursor = NULL;
stream->read = NULL;
stream->close = NULL;
}
FT_BASE_DEF( void )
FT_Stream_Close( FT_Stream stream )
{
if ( stream && stream->close )
stream->close( stream );
}
FT_BASE_DEF( FT_Error )
FT_Stream_Seek( FT_Stream stream,
FT_ULong pos )
{
FT_Error error = FT_Err_Ok;
if ( stream->read )
{
if ( stream->read( stream, pos, NULL, 0 ) )
{
FT_ERROR(( "FT_Stream_Seek:"
" invalid i/o; pos = 0x%lx, size = 0x%lx\n",
pos, stream->size ));
error = FT_THROW( Invalid_Stream_Operation );
}
}
/* note that seeking to the first position after the file is valid */
else if ( pos > stream->size )
{
FT_ERROR(( "FT_Stream_Seek:"
" invalid i/o; pos = 0x%lx, size = 0x%lx\n",
pos, stream->size ));
error = FT_THROW( Invalid_Stream_Operation );
}
if ( !error )
stream->pos = pos;
return error;
}
FT_BASE_DEF( FT_Error )
FT_Stream_Skip( FT_Stream stream,
FT_Long distance )
{
if ( distance < 0 )
return FT_THROW( Invalid_Stream_Operation );
return FT_Stream_Seek( stream, stream->pos + (FT_ULong)distance );
}
FT_BASE_DEF( FT_ULong )
FT_Stream_Pos( FT_Stream stream )
{
return stream->pos;
}
FT_BASE_DEF( FT_Error )
FT_Stream_Read( FT_Stream stream,
FT_Byte* buffer,
FT_ULong count )
{
return FT_Stream_ReadAt( stream, stream->pos, buffer, count );
}
FT_BASE_DEF( FT_Error )
FT_Stream_ReadAt( FT_Stream stream,
FT_ULong pos,
FT_Byte* buffer,
FT_ULong count )
{
FT_Error error = FT_Err_Ok;
FT_ULong read_bytes;
if ( pos >= stream->size )
{
FT_ERROR(( "FT_Stream_ReadAt:"
" invalid i/o; pos = 0x%lx, size = 0x%lx\n",
pos, stream->size ));
return FT_THROW( Invalid_Stream_Operation );
}
if ( stream->read )
read_bytes = stream->read( stream, pos, buffer, count );
else
{
read_bytes = stream->size - pos;
if ( read_bytes > count )
read_bytes = count;
FT_MEM_COPY( buffer, stream->base + pos, read_bytes );
}
stream->pos = pos + read_bytes;
if ( read_bytes < count )
{
FT_ERROR(( "FT_Stream_ReadAt:"
" invalid read; expected %lu bytes, got %lu\n",
count, read_bytes ));
error = FT_THROW( Invalid_Stream_Operation );
}
return error;
}
FT_BASE_DEF( FT_ULong )
FT_Stream_TryRead( FT_Stream stream,
FT_Byte* buffer,
FT_ULong count )
{
FT_ULong read_bytes = 0;
if ( stream->pos >= stream->size )
goto Exit;
if ( stream->read )
read_bytes = stream->read( stream, stream->pos, buffer, count );
else
{
read_bytes = stream->size - stream->pos;
if ( read_bytes > count )
read_bytes = count;
FT_MEM_COPY( buffer, stream->base + stream->pos, read_bytes );
}
stream->pos += read_bytes;
Exit:
return read_bytes;
}
FT_BASE_DEF( FT_Error )
FT_Stream_ExtractFrame( FT_Stream stream,
FT_ULong count,
FT_Byte** pbytes )
{
FT_Error error;
error = FT_Stream_EnterFrame( stream, count );
if ( !error )
{
*pbytes = (FT_Byte*)stream->cursor;
/* equivalent to FT_Stream_ExitFrame(), with no memory block release */
stream->cursor = NULL;
stream->limit = NULL;
}
return error;
}
FT_BASE_DEF( void )
FT_Stream_ReleaseFrame( FT_Stream stream,
FT_Byte** pbytes )
{
if ( stream && stream->read )
{
FT_Memory memory = stream->memory;
#ifdef FT_DEBUG_MEMORY
ft_mem_free( memory, *pbytes );
#else
FT_FREE( *pbytes );
#endif
}
*pbytes = NULL;
}
FT_BASE_DEF( FT_Error )
FT_Stream_EnterFrame( FT_Stream stream,
FT_ULong count )
{
FT_Error error = FT_Err_Ok;
FT_ULong read_bytes;
FT_TRACE7(( "FT_Stream_EnterFrame: %ld bytes\n", count ));
/* check for nested frame access */
FT_ASSERT( stream && stream->cursor == 0 );
if ( stream->read )
{
/* allocate the frame in memory */
FT_Memory memory = stream->memory;
/* simple sanity check */
if ( count > stream->size )
{
FT_ERROR(( "FT_Stream_EnterFrame:"
" frame size (%lu) larger than stream size (%lu)\n",
count, stream->size ));
error = FT_THROW( Invalid_Stream_Operation );
goto Exit;
}
#ifdef FT_DEBUG_MEMORY
/* assume _ft_debug_file and _ft_debug_lineno are already set */
stream->base = (unsigned char*)ft_mem_qalloc( memory,
(FT_Long)count,
&error );
if ( error )
goto Exit;
#else
if ( FT_QALLOC( stream->base, count ) )
goto Exit;
#endif
/* read it */
read_bytes = stream->read( stream, stream->pos,
stream->base, count );
if ( read_bytes < count )
{
FT_ERROR(( "FT_Stream_EnterFrame:"
" invalid read; expected %lu bytes, got %lu\n",
count, read_bytes ));
FT_FREE( stream->base );
error = FT_THROW( Invalid_Stream_Operation );
}
stream->cursor = stream->base;
stream->limit = FT_OFFSET( stream->cursor, count );
stream->pos += read_bytes;
}
else
{
/* check current and new position */
if ( stream->pos >= stream->size ||
stream->size - stream->pos < count )
{
FT_ERROR(( "FT_Stream_EnterFrame:"
" invalid i/o; pos = 0x%lx, count = %lu, size = 0x%lx\n",
stream->pos, count, stream->size ));
error = FT_THROW( Invalid_Stream_Operation );
goto Exit;
}
/* set cursor */
stream->cursor = stream->base + stream->pos;
stream->limit = stream->cursor + count;
stream->pos += count;
}
Exit:
return error;
}
FT_BASE_DEF( void )
FT_Stream_ExitFrame( FT_Stream stream )
{
/* IMPORTANT: The assertion stream->cursor != 0 was removed, given */
/* that it is possible to access a frame of length 0 in */
/* some weird fonts (usually, when accessing an array of */
/* 0 records, like in some strange kern tables). */
/* */
/* In this case, the loader code handles the 0-length table */
/* gracefully; however, stream.cursor is really set to 0 by the */
/* FT_Stream_EnterFrame() call, and this is not an error. */
FT_TRACE7(( "FT_Stream_ExitFrame\n" ));
FT_ASSERT( stream );
if ( stream->read )
{
FT_Memory memory = stream->memory;
#ifdef FT_DEBUG_MEMORY
ft_mem_free( memory, stream->base );
stream->base = NULL;
#else
FT_FREE( stream->base );
#endif
}
stream->cursor = NULL;
stream->limit = NULL;
}
FT_BASE_DEF( FT_Byte )
FT_Stream_GetByte( FT_Stream stream )
{
FT_Byte result;
FT_ASSERT( stream && stream->cursor );
result = 0;
if ( stream->cursor < stream->limit )
result = *stream->cursor++;
return result;
}
FT_BASE_DEF( FT_UShort )
FT_Stream_GetUShort( FT_Stream stream )
{
FT_Byte* p;
FT_UShort result;
FT_ASSERT( stream && stream->cursor );
result = 0;
p = stream->cursor;
if ( p + 1 < stream->limit )
result = FT_NEXT_USHORT( p );
stream->cursor = p;
return result;
}
FT_BASE_DEF( FT_UShort )
FT_Stream_GetUShortLE( FT_Stream stream )
{
FT_Byte* p;
FT_UShort result;
FT_ASSERT( stream && stream->cursor );
result = 0;
p = stream->cursor;
if ( p + 1 < stream->limit )
result = FT_NEXT_USHORT_LE( p );
stream->cursor = p;
return result;
}
FT_BASE_DEF( FT_ULong )
FT_Stream_GetUOffset( FT_Stream stream )
{
FT_Byte* p;
FT_ULong result;
FT_ASSERT( stream && stream->cursor );
result = 0;
p = stream->cursor;
if ( p + 2 < stream->limit )
result = FT_NEXT_UOFF3( p );
stream->cursor = p;
return result;
}
FT_BASE_DEF( FT_ULong )
FT_Stream_GetULong( FT_Stream stream )
{
FT_Byte* p;
FT_ULong result;
FT_ASSERT( stream && stream->cursor );
result = 0;
p = stream->cursor;
if ( p + 3 < stream->limit )
result = FT_NEXT_ULONG( p );
stream->cursor = p;
return result;
}
FT_BASE_DEF( FT_ULong )
FT_Stream_GetULongLE( FT_Stream stream )
{
FT_Byte* p;
FT_ULong result;
FT_ASSERT( stream && stream->cursor );
result = 0;
p = stream->cursor;
if ( p + 3 < stream->limit )
result = FT_NEXT_ULONG_LE( p );
stream->cursor = p;
return result;
}
FT_BASE_DEF( FT_Byte )
FT_Stream_ReadByte( FT_Stream stream,
FT_Error* error )
{
FT_Byte result = 0;
FT_ASSERT( stream );
if ( stream->pos < stream->size )
{
if ( stream->read )
{
if ( stream->read( stream, stream->pos, &result, 1L ) != 1L )
goto Fail;
}
else
result = stream->base[stream->pos];
}
else
goto Fail;
stream->pos++;
*error = FT_Err_Ok;
return result;
Fail:
*error = FT_THROW( Invalid_Stream_Operation );
FT_ERROR(( "FT_Stream_ReadByte:"
" invalid i/o; pos = 0x%lx, size = 0x%lx\n",
stream->pos, stream->size ));
return result;
}
FT_BASE_DEF( FT_UShort )
FT_Stream_ReadUShort( FT_Stream stream,
FT_Error* error )
{
FT_Byte reads[2];
FT_Byte* p;
FT_UShort result = 0;
FT_ASSERT( stream );
if ( stream->pos + 1 < stream->size )
{
if ( stream->read )
{
if ( stream->read( stream, stream->pos, reads, 2L ) != 2L )
goto Fail;
p = reads;
}
else
p = stream->base + stream->pos;
if ( p )
result = FT_NEXT_USHORT( p );
}
else
goto Fail;
stream->pos += 2;
*error = FT_Err_Ok;
return result;
Fail:
*error = FT_THROW( Invalid_Stream_Operation );
FT_ERROR(( "FT_Stream_ReadUShort:"
" invalid i/o; pos = 0x%lx, size = 0x%lx\n",
stream->pos, stream->size ));
return result;
}
FT_BASE_DEF( FT_UShort )
FT_Stream_ReadUShortLE( FT_Stream stream,
FT_Error* error )
{
FT_Byte reads[2];
FT_Byte* p;
FT_UShort result = 0;
FT_ASSERT( stream );
if ( stream->pos + 1 < stream->size )
{
if ( stream->read )
{
if ( stream->read( stream, stream->pos, reads, 2L ) != 2L )
goto Fail;
p = reads;
}
else
p = stream->base + stream->pos;
if ( p )
result = FT_NEXT_USHORT_LE( p );
}
else
goto Fail;
stream->pos += 2;
*error = FT_Err_Ok;
return result;
Fail:
*error = FT_THROW( Invalid_Stream_Operation );
FT_ERROR(( "FT_Stream_ReadUShortLE:"
" invalid i/o; pos = 0x%lx, size = 0x%lx\n",
stream->pos, stream->size ));
return result;
}
FT_BASE_DEF( FT_ULong )
FT_Stream_ReadUOffset( FT_Stream stream,
FT_Error* error )
{
FT_Byte reads[3];
FT_Byte* p;
FT_ULong result = 0;
FT_ASSERT( stream );
if ( stream->pos + 2 < stream->size )
{
if ( stream->read )
{
if (stream->read( stream, stream->pos, reads, 3L ) != 3L )
goto Fail;
p = reads;
}
else
p = stream->base + stream->pos;
if ( p )
result = FT_NEXT_UOFF3( p );
}
else
goto Fail;
stream->pos += 3;
*error = FT_Err_Ok;
return result;
Fail:
*error = FT_THROW( Invalid_Stream_Operation );
FT_ERROR(( "FT_Stream_ReadUOffset:"
" invalid i/o; pos = 0x%lx, size = 0x%lx\n",
stream->pos, stream->size ));
return result;
}
FT_BASE_DEF( FT_ULong )
FT_Stream_ReadULong( FT_Stream stream,
FT_Error* error )
{
FT_Byte reads[4];
FT_Byte* p;
FT_ULong result = 0;
FT_ASSERT( stream );
if ( stream->pos + 3 < stream->size )
{
if ( stream->read )
{
if ( stream->read( stream, stream->pos, reads, 4L ) != 4L )
goto Fail;
p = reads;
}
else
p = stream->base + stream->pos;
if ( p )
result = FT_NEXT_ULONG( p );
}
else
goto Fail;
stream->pos += 4;
*error = FT_Err_Ok;
return result;
Fail:
*error = FT_THROW( Invalid_Stream_Operation );
FT_ERROR(( "FT_Stream_ReadULong:"
" invalid i/o; pos = 0x%lx, size = 0x%lx\n",
stream->pos, stream->size ));
return result;
}
FT_BASE_DEF( FT_ULong )
FT_Stream_ReadULongLE( FT_Stream stream,
FT_Error* error )
{
FT_Byte reads[4];
FT_Byte* p;
FT_ULong result = 0;
FT_ASSERT( stream );
if ( stream->pos + 3 < stream->size )
{
if ( stream->read )
{
if ( stream->read( stream, stream->pos, reads, 4L ) != 4L )
goto Fail;
p = reads;
}
else
p = stream->base + stream->pos;
if ( p )
result = FT_NEXT_ULONG_LE( p );
}
else
goto Fail;
stream->pos += 4;
*error = FT_Err_Ok;
return result;
Fail:
*error = FT_THROW( Invalid_Stream_Operation );
FT_ERROR(( "FT_Stream_ReadULongLE:"
" invalid i/o; pos = 0x%lx, size = 0x%lx\n",
stream->pos, stream->size ));
return result;
}
FT_BASE_DEF( FT_Error )
FT_Stream_ReadFields( FT_Stream stream,
const FT_Frame_Field* fields,
void* structure )
{
FT_Error error;
FT_Bool frame_accessed = 0;
FT_Byte* cursor;
if ( !fields )
return FT_THROW( Invalid_Argument );
if ( !stream )
return FT_THROW( Invalid_Stream_Handle );
cursor = stream->cursor;
error = FT_Err_Ok;
do
{
FT_ULong value;
FT_Int sign_shift;
FT_Byte* p;
switch ( fields->value )
{
case ft_frame_start: /* access a new frame */
error = FT_Stream_EnterFrame( stream, fields->offset );
if ( error )
goto Exit;
frame_accessed = 1;
cursor = stream->cursor;
fields++;
continue; /* loop! */
case ft_frame_bytes: /* read a byte sequence */
case ft_frame_skip: /* skip some bytes */
{
FT_UInt len = fields->size;
if ( cursor + len > stream->limit )
{
error = FT_THROW( Invalid_Stream_Operation );
goto Exit;
}
if ( fields->value == ft_frame_bytes )
{
p = (FT_Byte*)structure + fields->offset;
FT_MEM_COPY( p, cursor, len );
}
cursor += len;
fields++;
continue;
}
case ft_frame_byte:
case ft_frame_schar: /* read a single byte */
value = FT_NEXT_BYTE( cursor );
sign_shift = 24;
break;
case ft_frame_short_be:
case ft_frame_ushort_be: /* read a 2-byte big-endian short */
value = FT_NEXT_USHORT( cursor );
sign_shift = 16;
break;
case ft_frame_short_le:
case ft_frame_ushort_le: /* read a 2-byte little-endian short */
value = FT_NEXT_USHORT_LE( cursor );
sign_shift = 16;
break;
case ft_frame_long_be:
case ft_frame_ulong_be: /* read a 4-byte big-endian long */
value = FT_NEXT_ULONG( cursor );
sign_shift = 0;
break;
case ft_frame_long_le:
case ft_frame_ulong_le: /* read a 4-byte little-endian long */
value = FT_NEXT_ULONG_LE( cursor );
sign_shift = 0;
break;
case ft_frame_off3_be:
case ft_frame_uoff3_be: /* read a 3-byte big-endian long */
value = FT_NEXT_UOFF3( cursor );
sign_shift = 8;
break;
case ft_frame_off3_le:
case ft_frame_uoff3_le: /* read a 3-byte little-endian long */
value = FT_NEXT_UOFF3_LE( cursor );
sign_shift = 8;
break;
default:
/* otherwise, exit the loop */
stream->cursor = cursor;
goto Exit;
}
/* now, compute the signed value is necessary */
if ( fields->value & FT_FRAME_OP_SIGNED )
value = (FT_ULong)( (FT_Int32)( value << sign_shift ) >> sign_shift );
/* finally, store the value in the object */
p = (FT_Byte*)structure + fields->offset;
switch ( fields->size )
{
case ( 8 / FT_CHAR_BIT ):
*(FT_Byte*)p = (FT_Byte)value;
break;
case ( 16 / FT_CHAR_BIT ):
*(FT_UShort*)p = (FT_UShort)value;
break;
case ( 32 / FT_CHAR_BIT ):
*(FT_UInt32*)p = (FT_UInt32)value;
break;
default: /* for 64-bit systems */
*(FT_ULong*)p = (FT_ULong)value;
}
/* go to next field */
fields++;
}
while ( 1 );
Exit:
/* close the frame if it was opened by this read */
if ( frame_accessed )
FT_Stream_ExitFrame( stream );
return error;
}
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/base/ftstream.c
|
C++
|
gpl-3.0
| 19,264
|
/****************************************************************************
*
* ftstroke.c
*
* FreeType path stroker (body).
*
* Copyright (C) 2002-2022 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.
*
*/
#include <freetype/ftstroke.h>
#include <freetype/fttrigon.h>
#include <freetype/ftoutln.h>
#include <freetype/internal/ftmemory.h>
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/ftobjs.h>
/* declare an extern to access `ft_outline_glyph_class' globally */
/* allocated in `ftglyph.c' */
FT_CALLBACK_TABLE const FT_Glyph_Class ft_outline_glyph_class;
/* documentation is in ftstroke.h */
FT_EXPORT_DEF( FT_StrokerBorder )
FT_Outline_GetInsideBorder( FT_Outline* outline )
{
FT_Orientation o = FT_Outline_Get_Orientation( outline );
return o == FT_ORIENTATION_TRUETYPE ? FT_STROKER_BORDER_RIGHT
: FT_STROKER_BORDER_LEFT;
}
/* documentation is in ftstroke.h */
FT_EXPORT_DEF( FT_StrokerBorder )
FT_Outline_GetOutsideBorder( FT_Outline* outline )
{
FT_Orientation o = FT_Outline_Get_Orientation( outline );
return o == FT_ORIENTATION_TRUETYPE ? FT_STROKER_BORDER_LEFT
: FT_STROKER_BORDER_RIGHT;
}
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** BEZIER COMPUTATIONS *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
#define FT_SMALL_CONIC_THRESHOLD ( FT_ANGLE_PI / 6 )
#define FT_SMALL_CUBIC_THRESHOLD ( FT_ANGLE_PI / 8 )
#define FT_EPSILON 2
#define FT_IS_SMALL( x ) ( (x) > -FT_EPSILON && (x) < FT_EPSILON )
static FT_Pos
ft_pos_abs( FT_Pos x )
{
return x >= 0 ? x : -x;
}
static void
ft_conic_split( FT_Vector* base )
{
FT_Pos a, b;
base[4].x = base[2].x;
a = base[0].x + base[1].x;
b = base[1].x + base[2].x;
base[3].x = b >> 1;
base[2].x = ( a + b ) >> 2;
base[1].x = a >> 1;
base[4].y = base[2].y;
a = base[0].y + base[1].y;
b = base[1].y + base[2].y;
base[3].y = b >> 1;
base[2].y = ( a + b ) >> 2;
base[1].y = a >> 1;
}
static FT_Bool
ft_conic_is_small_enough( FT_Vector* base,
FT_Angle *angle_in,
FT_Angle *angle_out )
{
FT_Vector d1, d2;
FT_Angle theta;
FT_Int close1, close2;
d1.x = base[1].x - base[2].x;
d1.y = base[1].y - base[2].y;
d2.x = base[0].x - base[1].x;
d2.y = base[0].y - base[1].y;
close1 = FT_IS_SMALL( d1.x ) && FT_IS_SMALL( d1.y );
close2 = FT_IS_SMALL( d2.x ) && FT_IS_SMALL( d2.y );
if ( close1 )
{
if ( close2 )
{
/* basically a point; */
/* do nothing to retain original direction */
}
else
{
*angle_in =
*angle_out = FT_Atan2( d2.x, d2.y );
}
}
else /* !close1 */
{
if ( close2 )
{
*angle_in =
*angle_out = FT_Atan2( d1.x, d1.y );
}
else
{
*angle_in = FT_Atan2( d1.x, d1.y );
*angle_out = FT_Atan2( d2.x, d2.y );
}
}
theta = ft_pos_abs( FT_Angle_Diff( *angle_in, *angle_out ) );
return FT_BOOL( theta < FT_SMALL_CONIC_THRESHOLD );
}
static void
ft_cubic_split( FT_Vector* base )
{
FT_Pos a, b, c;
base[6].x = base[3].x;
a = base[0].x + base[1].x;
b = base[1].x + base[2].x;
c = base[2].x + base[3].x;
base[5].x = c >> 1;
c += b;
base[4].x = c >> 2;
base[1].x = a >> 1;
a += b;
base[2].x = a >> 2;
base[3].x = ( a + c ) >> 3;
base[6].y = base[3].y;
a = base[0].y + base[1].y;
b = base[1].y + base[2].y;
c = base[2].y + base[3].y;
base[5].y = c >> 1;
c += b;
base[4].y = c >> 2;
base[1].y = a >> 1;
a += b;
base[2].y = a >> 2;
base[3].y = ( a + c ) >> 3;
}
/* Return the average of `angle1' and `angle2'. */
/* This gives correct result even if `angle1' and `angle2' */
/* have opposite signs. */
static FT_Angle
ft_angle_mean( FT_Angle angle1,
FT_Angle angle2 )
{
return angle1 + FT_Angle_Diff( angle1, angle2 ) / 2;
}
static FT_Bool
ft_cubic_is_small_enough( FT_Vector* base,
FT_Angle *angle_in,
FT_Angle *angle_mid,
FT_Angle *angle_out )
{
FT_Vector d1, d2, d3;
FT_Angle theta1, theta2;
FT_Int close1, close2, close3;
d1.x = base[2].x - base[3].x;
d1.y = base[2].y - base[3].y;
d2.x = base[1].x - base[2].x;
d2.y = base[1].y - base[2].y;
d3.x = base[0].x - base[1].x;
d3.y = base[0].y - base[1].y;
close1 = FT_IS_SMALL( d1.x ) && FT_IS_SMALL( d1.y );
close2 = FT_IS_SMALL( d2.x ) && FT_IS_SMALL( d2.y );
close3 = FT_IS_SMALL( d3.x ) && FT_IS_SMALL( d3.y );
if ( close1 )
{
if ( close2 )
{
if ( close3 )
{
/* basically a point; */
/* do nothing to retain original direction */
}
else /* !close3 */
{
*angle_in =
*angle_mid =
*angle_out = FT_Atan2( d3.x, d3.y );
}
}
else /* !close2 */
{
if ( close3 )
{
*angle_in =
*angle_mid =
*angle_out = FT_Atan2( d2.x, d2.y );
}
else /* !close3 */
{
*angle_in =
*angle_mid = FT_Atan2( d2.x, d2.y );
*angle_out = FT_Atan2( d3.x, d3.y );
}
}
}
else /* !close1 */
{
if ( close2 )
{
if ( close3 )
{
*angle_in =
*angle_mid =
*angle_out = FT_Atan2( d1.x, d1.y );
}
else /* !close3 */
{
*angle_in = FT_Atan2( d1.x, d1.y );
*angle_out = FT_Atan2( d3.x, d3.y );
*angle_mid = ft_angle_mean( *angle_in, *angle_out );
}
}
else /* !close2 */
{
if ( close3 )
{
*angle_in = FT_Atan2( d1.x, d1.y );
*angle_mid =
*angle_out = FT_Atan2( d2.x, d2.y );
}
else /* !close3 */
{
*angle_in = FT_Atan2( d1.x, d1.y );
*angle_mid = FT_Atan2( d2.x, d2.y );
*angle_out = FT_Atan2( d3.x, d3.y );
}
}
}
theta1 = ft_pos_abs( FT_Angle_Diff( *angle_in, *angle_mid ) );
theta2 = ft_pos_abs( FT_Angle_Diff( *angle_mid, *angle_out ) );
return FT_BOOL( theta1 < FT_SMALL_CUBIC_THRESHOLD &&
theta2 < FT_SMALL_CUBIC_THRESHOLD );
}
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** STROKE BORDERS *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
typedef enum FT_StrokeTags_
{
FT_STROKE_TAG_ON = 1, /* on-curve point */
FT_STROKE_TAG_CUBIC = 2, /* cubic off-point */
FT_STROKE_TAG_BEGIN = 4, /* sub-path start */
FT_STROKE_TAG_END = 8 /* sub-path end */
} FT_StrokeTags;
#define FT_STROKE_TAG_BEGIN_END ( FT_STROKE_TAG_BEGIN | FT_STROKE_TAG_END )
typedef struct FT_StrokeBorderRec_
{
FT_UInt num_points;
FT_UInt max_points;
FT_Vector* points;
FT_Byte* tags;
FT_Bool movable; /* TRUE for ends of lineto borders */
FT_Int start; /* index of current sub-path start point */
FT_Memory memory;
FT_Bool valid;
} FT_StrokeBorderRec, *FT_StrokeBorder;
static FT_Error
ft_stroke_border_grow( FT_StrokeBorder border,
FT_UInt new_points )
{
FT_UInt old_max = border->max_points;
FT_UInt new_max = border->num_points + new_points;
FT_Error error = FT_Err_Ok;
if ( new_max > old_max )
{
FT_UInt cur_max = old_max;
FT_Memory memory = border->memory;
while ( cur_max < new_max )
cur_max += ( cur_max >> 1 ) + 16;
if ( FT_RENEW_ARRAY( border->points, old_max, cur_max ) ||
FT_RENEW_ARRAY( border->tags, old_max, cur_max ) )
goto Exit;
border->max_points = cur_max;
}
Exit:
return error;
}
static void
ft_stroke_border_close( FT_StrokeBorder border,
FT_Bool reverse )
{
FT_UInt start = (FT_UInt)border->start;
FT_UInt count = border->num_points;
FT_ASSERT( border->start >= 0 );
/* don't record empty paths! */
if ( count <= start + 1U )
border->num_points = start;
else
{
/* copy the last point to the start of this sub-path, since */
/* it contains the `adjusted' starting coordinates */
border->num_points = --count;
border->points[start] = border->points[count];
border->tags[start] = border->tags[count];
if ( reverse )
{
/* reverse the points */
{
FT_Vector* vec1 = border->points + start + 1;
FT_Vector* vec2 = border->points + count - 1;
for ( ; vec1 < vec2; vec1++, vec2-- )
{
FT_Vector tmp;
tmp = *vec1;
*vec1 = *vec2;
*vec2 = tmp;
}
}
/* then the tags */
{
FT_Byte* tag1 = border->tags + start + 1;
FT_Byte* tag2 = border->tags + count - 1;
for ( ; tag1 < tag2; tag1++, tag2-- )
{
FT_Byte tmp;
tmp = *tag1;
*tag1 = *tag2;
*tag2 = tmp;
}
}
}
border->tags[start ] |= FT_STROKE_TAG_BEGIN;
border->tags[count - 1] |= FT_STROKE_TAG_END;
}
border->start = -1;
border->movable = FALSE;
}
static FT_Error
ft_stroke_border_lineto( FT_StrokeBorder border,
FT_Vector* to,
FT_Bool movable )
{
FT_Error error = FT_Err_Ok;
FT_ASSERT( border->start >= 0 );
if ( border->movable )
{
/* move last point */
border->points[border->num_points - 1] = *to;
}
else
{
/* don't add zero-length lineto, but always add moveto */
if ( border->num_points > (FT_UInt)border->start &&
FT_IS_SMALL( border->points[border->num_points - 1].x - to->x ) &&
FT_IS_SMALL( border->points[border->num_points - 1].y - to->y ) )
return error;
/* add one point */
error = ft_stroke_border_grow( border, 1 );
if ( !error )
{
FT_Vector* vec = border->points + border->num_points;
FT_Byte* tag = border->tags + border->num_points;
vec[0] = *to;
tag[0] = FT_STROKE_TAG_ON;
border->num_points += 1;
}
}
border->movable = movable;
return error;
}
static FT_Error
ft_stroke_border_conicto( FT_StrokeBorder border,
FT_Vector* control,
FT_Vector* to )
{
FT_Error error;
FT_ASSERT( border->start >= 0 );
error = ft_stroke_border_grow( border, 2 );
if ( !error )
{
FT_Vector* vec = border->points + border->num_points;
FT_Byte* tag = border->tags + border->num_points;
vec[0] = *control;
vec[1] = *to;
tag[0] = 0;
tag[1] = FT_STROKE_TAG_ON;
border->num_points += 2;
}
border->movable = FALSE;
return error;
}
static FT_Error
ft_stroke_border_cubicto( FT_StrokeBorder border,
FT_Vector* control1,
FT_Vector* control2,
FT_Vector* to )
{
FT_Error error;
FT_ASSERT( border->start >= 0 );
error = ft_stroke_border_grow( border, 3 );
if ( !error )
{
FT_Vector* vec = border->points + border->num_points;
FT_Byte* tag = border->tags + border->num_points;
vec[0] = *control1;
vec[1] = *control2;
vec[2] = *to;
tag[0] = FT_STROKE_TAG_CUBIC;
tag[1] = FT_STROKE_TAG_CUBIC;
tag[2] = FT_STROKE_TAG_ON;
border->num_points += 3;
}
border->movable = FALSE;
return error;
}
#define FT_ARC_CUBIC_ANGLE ( FT_ANGLE_PI / 2 )
static FT_Error
ft_stroke_border_arcto( FT_StrokeBorder border,
FT_Vector* center,
FT_Fixed radius,
FT_Angle angle_start,
FT_Angle angle_diff )
{
FT_Fixed coef;
FT_Vector a0, a1, a2, a3;
FT_Int i, arcs = 1;
FT_Error error = FT_Err_Ok;
/* number of cubic arcs to draw */
while ( angle_diff > FT_ARC_CUBIC_ANGLE * arcs ||
-angle_diff > FT_ARC_CUBIC_ANGLE * arcs )
arcs++;
/* control tangents */
coef = FT_Tan( angle_diff / ( 4 * arcs ) );
coef += coef / 3;
/* compute start and first control point */
FT_Vector_From_Polar( &a0, radius, angle_start );
a1.x = FT_MulFix( -a0.y, coef );
a1.y = FT_MulFix( a0.x, coef );
a0.x += center->x;
a0.y += center->y;
a1.x += a0.x;
a1.y += a0.y;
for ( i = 1; i <= arcs; i++ )
{
/* compute end and second control point */
FT_Vector_From_Polar( &a3, radius,
angle_start + i * angle_diff / arcs );
a2.x = FT_MulFix( a3.y, coef );
a2.y = FT_MulFix( -a3.x, coef );
a3.x += center->x;
a3.y += center->y;
a2.x += a3.x;
a2.y += a3.y;
/* add cubic arc */
error = ft_stroke_border_cubicto( border, &a1, &a2, &a3 );
if ( error )
break;
/* a0 = a3; */
a1.x = a3.x - a2.x + a3.x;
a1.y = a3.y - a2.y + a3.y;
}
return error;
}
static FT_Error
ft_stroke_border_moveto( FT_StrokeBorder border,
FT_Vector* to )
{
/* close current open path if any ? */
if ( border->start >= 0 )
ft_stroke_border_close( border, FALSE );
border->start = (FT_Int)border->num_points;
border->movable = FALSE;
return ft_stroke_border_lineto( border, to, FALSE );
}
static void
ft_stroke_border_init( FT_StrokeBorder border,
FT_Memory memory )
{
border->memory = memory;
border->points = NULL;
border->tags = NULL;
border->num_points = 0;
border->max_points = 0;
border->start = -1;
border->valid = FALSE;
}
static void
ft_stroke_border_reset( FT_StrokeBorder border )
{
border->num_points = 0;
border->start = -1;
border->valid = FALSE;
}
static void
ft_stroke_border_done( FT_StrokeBorder border )
{
FT_Memory memory = border->memory;
FT_FREE( border->points );
FT_FREE( border->tags );
border->num_points = 0;
border->max_points = 0;
border->start = -1;
border->valid = FALSE;
}
static FT_Error
ft_stroke_border_get_counts( FT_StrokeBorder border,
FT_UInt *anum_points,
FT_UInt *anum_contours )
{
FT_Error error = FT_Err_Ok;
FT_UInt num_points = 0;
FT_UInt num_contours = 0;
FT_UInt count = border->num_points;
FT_Vector* point = border->points;
FT_Byte* tags = border->tags;
FT_Int in_contour = 0;
for ( ; count > 0; count--, num_points++, point++, tags++ )
{
if ( tags[0] & FT_STROKE_TAG_BEGIN )
{
if ( in_contour != 0 )
goto Fail;
in_contour = 1;
}
else if ( in_contour == 0 )
goto Fail;
if ( tags[0] & FT_STROKE_TAG_END )
{
in_contour = 0;
num_contours++;
}
}
if ( in_contour != 0 )
goto Fail;
border->valid = TRUE;
Exit:
*anum_points = num_points;
*anum_contours = num_contours;
return error;
Fail:
num_points = 0;
num_contours = 0;
goto Exit;
}
static void
ft_stroke_border_export( FT_StrokeBorder border,
FT_Outline* outline )
{
/* copy point locations */
if ( border->num_points )
FT_ARRAY_COPY( outline->points + outline->n_points,
border->points,
border->num_points );
/* copy tags */
{
FT_UInt count = border->num_points;
FT_Byte* read = border->tags;
FT_Byte* write = (FT_Byte*)outline->tags + outline->n_points;
for ( ; count > 0; count--, read++, write++ )
{
if ( *read & FT_STROKE_TAG_ON )
*write = FT_CURVE_TAG_ON;
else if ( *read & FT_STROKE_TAG_CUBIC )
*write = FT_CURVE_TAG_CUBIC;
else
*write = FT_CURVE_TAG_CONIC;
}
}
/* copy contours */
{
FT_UInt count = border->num_points;
FT_Byte* tags = border->tags;
FT_Short* write = outline->contours + outline->n_contours;
FT_Short idx = (FT_Short)outline->n_points;
for ( ; count > 0; count--, tags++, idx++ )
{
if ( *tags & FT_STROKE_TAG_END )
{
*write++ = idx;
outline->n_contours++;
}
}
}
outline->n_points += (short)border->num_points;
FT_ASSERT( FT_Outline_Check( outline ) == 0 );
}
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** STROKER *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
#define FT_SIDE_TO_ROTATE( s ) ( FT_ANGLE_PI2 - (s) * FT_ANGLE_PI )
typedef struct FT_StrokerRec_
{
FT_Angle angle_in; /* direction into curr join */
FT_Angle angle_out; /* direction out of join */
FT_Vector center; /* current position */
FT_Fixed line_length; /* length of last lineto */
FT_Bool first_point; /* is this the start? */
FT_Bool subpath_open; /* is the subpath open? */
FT_Angle subpath_angle; /* subpath start direction */
FT_Vector subpath_start; /* subpath start position */
FT_Fixed subpath_line_length; /* subpath start lineto len */
FT_Bool handle_wide_strokes; /* use wide strokes logic? */
FT_Stroker_LineCap line_cap;
FT_Stroker_LineJoin line_join;
FT_Stroker_LineJoin line_join_saved;
FT_Fixed miter_limit;
FT_Fixed radius;
FT_StrokeBorderRec borders[2];
FT_Library library;
} FT_StrokerRec;
/* documentation is in ftstroke.h */
FT_EXPORT_DEF( FT_Error )
FT_Stroker_New( FT_Library library,
FT_Stroker *astroker )
{
FT_Error error; /* assigned in FT_NEW */
FT_Memory memory;
FT_Stroker stroker = NULL;
if ( !library )
return FT_THROW( Invalid_Library_Handle );
if ( !astroker )
return FT_THROW( Invalid_Argument );
memory = library->memory;
if ( !FT_NEW( stroker ) )
{
stroker->library = library;
ft_stroke_border_init( &stroker->borders[0], memory );
ft_stroke_border_init( &stroker->borders[1], memory );
}
*astroker = stroker;
return error;
}
/* documentation is in ftstroke.h */
FT_EXPORT_DEF( void )
FT_Stroker_Set( FT_Stroker stroker,
FT_Fixed radius,
FT_Stroker_LineCap line_cap,
FT_Stroker_LineJoin line_join,
FT_Fixed miter_limit )
{
if ( !stroker )
return;
stroker->radius = radius;
stroker->line_cap = line_cap;
stroker->line_join = line_join;
stroker->miter_limit = miter_limit;
/* ensure miter limit has sensible value */
if ( stroker->miter_limit < 0x10000L )
stroker->miter_limit = 0x10000L;
/* save line join style: */
/* line join style can be temporarily changed when stroking curves */
stroker->line_join_saved = line_join;
FT_Stroker_Rewind( stroker );
}
/* documentation is in ftstroke.h */
FT_EXPORT_DEF( void )
FT_Stroker_Rewind( FT_Stroker stroker )
{
if ( stroker )
{
ft_stroke_border_reset( &stroker->borders[0] );
ft_stroke_border_reset( &stroker->borders[1] );
}
}
/* documentation is in ftstroke.h */
FT_EXPORT_DEF( void )
FT_Stroker_Done( FT_Stroker stroker )
{
if ( stroker )
{
FT_Memory memory = stroker->library->memory;
ft_stroke_border_done( &stroker->borders[0] );
ft_stroke_border_done( &stroker->borders[1] );
stroker->library = NULL;
FT_FREE( stroker );
}
}
/* create a circular arc at a corner or cap */
static FT_Error
ft_stroker_arcto( FT_Stroker stroker,
FT_Int side )
{
FT_Angle total, rotate;
FT_Fixed radius = stroker->radius;
FT_Error error = FT_Err_Ok;
FT_StrokeBorder border = stroker->borders + side;
rotate = FT_SIDE_TO_ROTATE( side );
total = FT_Angle_Diff( stroker->angle_in, stroker->angle_out );
if ( total == FT_ANGLE_PI )
total = -rotate * 2;
error = ft_stroke_border_arcto( border,
&stroker->center,
radius,
stroker->angle_in + rotate,
total );
border->movable = FALSE;
return error;
}
/* add a cap at the end of an opened path */
static FT_Error
ft_stroker_cap( FT_Stroker stroker,
FT_Angle angle,
FT_Int side )
{
FT_Error error = FT_Err_Ok;
if ( stroker->line_cap == FT_STROKER_LINECAP_ROUND )
{
/* add a round cap */
stroker->angle_in = angle;
stroker->angle_out = angle + FT_ANGLE_PI;
error = ft_stroker_arcto( stroker, side );
}
else
{
/* add a square or butt cap */
FT_Vector middle, delta;
FT_Fixed radius = stroker->radius;
FT_StrokeBorder border = stroker->borders + side;
/* compute middle point and first angle point */
FT_Vector_From_Polar( &middle, radius, angle );
delta.x = side ? middle.y : -middle.y;
delta.y = side ? -middle.x : middle.x;
if ( stroker->line_cap == FT_STROKER_LINECAP_SQUARE )
{
middle.x += stroker->center.x;
middle.y += stroker->center.y;
}
else /* FT_STROKER_LINECAP_BUTT */
{
middle.x = stroker->center.x;
middle.y = stroker->center.y;
}
delta.x += middle.x;
delta.y += middle.y;
error = ft_stroke_border_lineto( border, &delta, FALSE );
if ( error )
goto Exit;
/* compute second angle point */
delta.x = middle.x - delta.x + middle.x;
delta.y = middle.y - delta.y + middle.y;
error = ft_stroke_border_lineto( border, &delta, FALSE );
}
Exit:
return error;
}
/* process an inside corner, i.e. compute intersection */
static FT_Error
ft_stroker_inside( FT_Stroker stroker,
FT_Int side,
FT_Fixed line_length )
{
FT_StrokeBorder border = stroker->borders + side;
FT_Angle phi, theta, rotate;
FT_Fixed length;
FT_Vector sigma = { 0, 0 };
FT_Vector delta;
FT_Error error = FT_Err_Ok;
FT_Bool intersect; /* use intersection of lines? */
rotate = FT_SIDE_TO_ROTATE( side );
theta = FT_Angle_Diff( stroker->angle_in, stroker->angle_out ) / 2;
/* Only intersect borders if between two lineto's and both */
/* lines are long enough (line_length is zero for curves). */
/* Also avoid U-turns of nearly 180 degree. */
if ( !border->movable || line_length == 0 ||
theta > 0x59C000 || theta < -0x59C000 )
intersect = FALSE;
else
{
/* compute minimum required length of lines */
FT_Fixed min_length;
FT_Vector_Unit( &sigma, theta );
min_length =
ft_pos_abs( FT_MulDiv( stroker->radius, sigma.y, sigma.x ) );
intersect = FT_BOOL( min_length &&
stroker->line_length >= min_length &&
line_length >= min_length );
}
if ( !intersect )
{
FT_Vector_From_Polar( &delta, stroker->radius,
stroker->angle_out + rotate );
delta.x += stroker->center.x;
delta.y += stroker->center.y;
border->movable = FALSE;
}
else
{
/* compute median angle */
phi = stroker->angle_in + theta + rotate;
length = FT_DivFix( stroker->radius, sigma.x );
FT_Vector_From_Polar( &delta, length, phi );
delta.x += stroker->center.x;
delta.y += stroker->center.y;
}
error = ft_stroke_border_lineto( border, &delta, FALSE );
return error;
}
/* process an outside corner, i.e. compute bevel/miter/round */
static FT_Error
ft_stroker_outside( FT_Stroker stroker,
FT_Int side,
FT_Fixed line_length )
{
FT_StrokeBorder border = stroker->borders + side;
FT_Error error;
FT_Angle rotate;
if ( stroker->line_join == FT_STROKER_LINEJOIN_ROUND )
error = ft_stroker_arcto( stroker, side );
else
{
/* this is a mitered (pointed) or beveled (truncated) corner */
FT_Fixed radius = stroker->radius;
FT_Vector sigma = { 0, 0 };
FT_Angle theta = 0, phi = 0;
FT_Bool bevel, fixed_bevel;
rotate = FT_SIDE_TO_ROTATE( side );
bevel =
FT_BOOL( stroker->line_join == FT_STROKER_LINEJOIN_BEVEL );
fixed_bevel =
FT_BOOL( stroker->line_join != FT_STROKER_LINEJOIN_MITER_VARIABLE );
/* check miter limit first */
if ( !bevel )
{
theta = FT_Angle_Diff( stroker->angle_in, stroker->angle_out ) / 2;
if ( theta == FT_ANGLE_PI2 )
theta = -rotate;
phi = stroker->angle_in + theta + rotate;
FT_Vector_From_Polar( &sigma, stroker->miter_limit, theta );
/* is miter limit exceeded? */
if ( sigma.x < 0x10000L )
{
/* don't create variable bevels for very small deviations; */
/* FT_Sin(x) = 0 for x <= 57 */
if ( fixed_bevel || ft_pos_abs( theta ) > 57 )
bevel = TRUE;
}
}
if ( bevel ) /* this is a bevel (broken angle) */
{
if ( fixed_bevel )
{
/* the outer corners are simply joined together */
FT_Vector delta;
/* add bevel */
FT_Vector_From_Polar( &delta,
radius,
stroker->angle_out + rotate );
delta.x += stroker->center.x;
delta.y += stroker->center.y;
border->movable = FALSE;
error = ft_stroke_border_lineto( border, &delta, FALSE );
}
else /* variable bevel or clipped miter */
{
/* the miter is truncated */
FT_Vector middle, delta;
FT_Fixed coef;
/* compute middle point and first angle point */
FT_Vector_From_Polar( &middle,
FT_MulFix( radius, stroker->miter_limit ),
phi );
coef = FT_DivFix( 0x10000L - sigma.x, sigma.y );
delta.x = FT_MulFix( middle.y, coef );
delta.y = FT_MulFix( -middle.x, coef );
middle.x += stroker->center.x;
middle.y += stroker->center.y;
delta.x += middle.x;
delta.y += middle.y;
error = ft_stroke_border_lineto( border, &delta, FALSE );
if ( error )
goto Exit;
/* compute second angle point */
delta.x = middle.x - delta.x + middle.x;
delta.y = middle.y - delta.y + middle.y;
error = ft_stroke_border_lineto( border, &delta, FALSE );
if ( error )
goto Exit;
/* finally, add an end point; only needed if not lineto */
/* (line_length is zero for curves) */
if ( line_length == 0 )
{
FT_Vector_From_Polar( &delta,
radius,
stroker->angle_out + rotate );
delta.x += stroker->center.x;
delta.y += stroker->center.y;
error = ft_stroke_border_lineto( border, &delta, FALSE );
}
}
}
else /* this is a miter (intersection) */
{
FT_Fixed length;
FT_Vector delta;
length = FT_MulDiv( stroker->radius, stroker->miter_limit, sigma.x );
FT_Vector_From_Polar( &delta, length, phi );
delta.x += stroker->center.x;
delta.y += stroker->center.y;
error = ft_stroke_border_lineto( border, &delta, FALSE );
if ( error )
goto Exit;
/* now add an end point; only needed if not lineto */
/* (line_length is zero for curves) */
if ( line_length == 0 )
{
FT_Vector_From_Polar( &delta,
stroker->radius,
stroker->angle_out + rotate );
delta.x += stroker->center.x;
delta.y += stroker->center.y;
error = ft_stroke_border_lineto( border, &delta, FALSE );
}
}
}
Exit:
return error;
}
static FT_Error
ft_stroker_process_corner( FT_Stroker stroker,
FT_Fixed line_length )
{
FT_Error error = FT_Err_Ok;
FT_Angle turn;
FT_Int inside_side;
turn = FT_Angle_Diff( stroker->angle_in, stroker->angle_out );
/* no specific corner processing is required if the turn is 0 */
if ( turn == 0 )
goto Exit;
/* when we turn to the right, the inside side is 0 */
/* otherwise, the inside side is 1 */
inside_side = ( turn < 0 );
/* process the inside side */
error = ft_stroker_inside( stroker, inside_side, line_length );
if ( error )
goto Exit;
/* process the outside side */
error = ft_stroker_outside( stroker, !inside_side, line_length );
Exit:
return error;
}
/* add two points to the left and right borders corresponding to the */
/* start of the subpath */
static FT_Error
ft_stroker_subpath_start( FT_Stroker stroker,
FT_Angle start_angle,
FT_Fixed line_length )
{
FT_Vector delta;
FT_Vector point;
FT_Error error;
FT_StrokeBorder border;
FT_Vector_From_Polar( &delta, stroker->radius,
start_angle + FT_ANGLE_PI2 );
point.x = stroker->center.x + delta.x;
point.y = stroker->center.y + delta.y;
border = stroker->borders;
error = ft_stroke_border_moveto( border, &point );
if ( error )
goto Exit;
point.x = stroker->center.x - delta.x;
point.y = stroker->center.y - delta.y;
border++;
error = ft_stroke_border_moveto( border, &point );
/* save angle, position, and line length for last join */
/* (line_length is zero for curves) */
stroker->subpath_angle = start_angle;
stroker->first_point = FALSE;
stroker->subpath_line_length = line_length;
Exit:
return error;
}
/* documentation is in ftstroke.h */
FT_EXPORT_DEF( FT_Error )
FT_Stroker_LineTo( FT_Stroker stroker,
FT_Vector* to )
{
FT_Error error = FT_Err_Ok;
FT_StrokeBorder border;
FT_Vector delta;
FT_Angle angle;
FT_Int side;
FT_Fixed line_length;
if ( !stroker || !to )
return FT_THROW( Invalid_Argument );
delta.x = to->x - stroker->center.x;
delta.y = to->y - stroker->center.y;
/* a zero-length lineto is a no-op; avoid creating a spurious corner */
if ( delta.x == 0 && delta.y == 0 )
goto Exit;
/* compute length of line */
line_length = FT_Vector_Length( &delta );
angle = FT_Atan2( delta.x, delta.y );
FT_Vector_From_Polar( &delta, stroker->radius, angle + FT_ANGLE_PI2 );
/* process corner if necessary */
if ( stroker->first_point )
{
/* This is the first segment of a subpath. We need to */
/* add a point to each border at their respective starting */
/* point locations. */
error = ft_stroker_subpath_start( stroker, angle, line_length );
if ( error )
goto Exit;
}
else
{
/* process the current corner */
stroker->angle_out = angle;
error = ft_stroker_process_corner( stroker, line_length );
if ( error )
goto Exit;
}
/* now add a line segment to both the `inside' and `outside' paths */
for ( border = stroker->borders, side = 1; side >= 0; side--, border++ )
{
FT_Vector point;
point.x = to->x + delta.x;
point.y = to->y + delta.y;
/* the ends of lineto borders are movable */
error = ft_stroke_border_lineto( border, &point, TRUE );
if ( error )
goto Exit;
delta.x = -delta.x;
delta.y = -delta.y;
}
stroker->angle_in = angle;
stroker->center = *to;
stroker->line_length = line_length;
Exit:
return error;
}
/* documentation is in ftstroke.h */
FT_EXPORT_DEF( FT_Error )
FT_Stroker_ConicTo( FT_Stroker stroker,
FT_Vector* control,
FT_Vector* to )
{
FT_Error error = FT_Err_Ok;
FT_Vector bez_stack[34];
FT_Vector* arc;
FT_Vector* limit = bez_stack + 30;
FT_Bool first_arc = TRUE;
if ( !stroker || !control || !to )
{
error = FT_THROW( Invalid_Argument );
goto Exit;
}
/* if all control points are coincident, this is a no-op; */
/* avoid creating a spurious corner */
if ( FT_IS_SMALL( stroker->center.x - control->x ) &&
FT_IS_SMALL( stroker->center.y - control->y ) &&
FT_IS_SMALL( control->x - to->x ) &&
FT_IS_SMALL( control->y - to->y ) )
{
stroker->center = *to;
goto Exit;
}
arc = bez_stack;
arc[0] = *to;
arc[1] = *control;
arc[2] = stroker->center;
while ( arc >= bez_stack )
{
FT_Angle angle_in, angle_out;
/* initialize with current direction */
angle_in = angle_out = stroker->angle_in;
if ( arc < limit &&
!ft_conic_is_small_enough( arc, &angle_in, &angle_out ) )
{
if ( stroker->first_point )
stroker->angle_in = angle_in;
ft_conic_split( arc );
arc += 2;
continue;
}
if ( first_arc )
{
first_arc = FALSE;
/* process corner if necessary */
if ( stroker->first_point )
error = ft_stroker_subpath_start( stroker, angle_in, 0 );
else
{
stroker->angle_out = angle_in;
error = ft_stroker_process_corner( stroker, 0 );
}
}
else if ( ft_pos_abs( FT_Angle_Diff( stroker->angle_in, angle_in ) ) >
FT_SMALL_CONIC_THRESHOLD / 4 )
{
/* if the deviation from one arc to the next is too great, */
/* add a round corner */
stroker->center = arc[2];
stroker->angle_out = angle_in;
stroker->line_join = FT_STROKER_LINEJOIN_ROUND;
error = ft_stroker_process_corner( stroker, 0 );
/* reinstate line join style */
stroker->line_join = stroker->line_join_saved;
}
if ( error )
goto Exit;
/* the arc's angle is small enough; we can add it directly to each */
/* border */
{
FT_Vector ctrl, end;
FT_Angle theta, phi, rotate, alpha0 = 0;
FT_Fixed length;
FT_StrokeBorder border;
FT_Int side;
theta = FT_Angle_Diff( angle_in, angle_out ) / 2;
phi = angle_in + theta;
length = FT_DivFix( stroker->radius, FT_Cos( theta ) );
/* compute direction of original arc */
if ( stroker->handle_wide_strokes )
alpha0 = FT_Atan2( arc[0].x - arc[2].x, arc[0].y - arc[2].y );
for ( border = stroker->borders, side = 0;
side <= 1;
side++, border++ )
{
rotate = FT_SIDE_TO_ROTATE( side );
/* compute control point */
FT_Vector_From_Polar( &ctrl, length, phi + rotate );
ctrl.x += arc[1].x;
ctrl.y += arc[1].y;
/* compute end point */
FT_Vector_From_Polar( &end, stroker->radius, angle_out + rotate );
end.x += arc[0].x;
end.y += arc[0].y;
if ( stroker->handle_wide_strokes )
{
FT_Vector start;
FT_Angle alpha1;
/* determine whether the border radius is greater than the */
/* radius of curvature of the original arc */
start = border->points[border->num_points - 1];
alpha1 = FT_Atan2( end.x - start.x, end.y - start.y );
/* is the direction of the border arc opposite to */
/* that of the original arc? */
if ( ft_pos_abs( FT_Angle_Diff( alpha0, alpha1 ) ) >
FT_ANGLE_PI / 2 )
{
FT_Angle beta, gamma;
FT_Vector bvec, delta;
FT_Fixed blen, sinA, sinB, alen;
/* use the sine rule to find the intersection point */
beta = FT_Atan2( arc[2].x - start.x, arc[2].y - start.y );
gamma = FT_Atan2( arc[0].x - end.x, arc[0].y - end.y );
bvec.x = end.x - start.x;
bvec.y = end.y - start.y;
blen = FT_Vector_Length( &bvec );
sinA = ft_pos_abs( FT_Sin( alpha1 - gamma ) );
sinB = ft_pos_abs( FT_Sin( beta - gamma ) );
alen = FT_MulDiv( blen, sinA, sinB );
FT_Vector_From_Polar( &delta, alen, beta );
delta.x += start.x;
delta.y += start.y;
/* circumnavigate the negative sector backwards */
border->movable = FALSE;
error = ft_stroke_border_lineto( border, &delta, FALSE );
if ( error )
goto Exit;
error = ft_stroke_border_lineto( border, &end, FALSE );
if ( error )
goto Exit;
error = ft_stroke_border_conicto( border, &ctrl, &start );
if ( error )
goto Exit;
/* and then move to the endpoint */
error = ft_stroke_border_lineto( border, &end, FALSE );
if ( error )
goto Exit;
continue;
}
/* else fall through */
}
/* simply add an arc */
error = ft_stroke_border_conicto( border, &ctrl, &end );
if ( error )
goto Exit;
}
}
arc -= 2;
stroker->angle_in = angle_out;
}
stroker->center = *to;
stroker->line_length = 0;
Exit:
return error;
}
/* documentation is in ftstroke.h */
FT_EXPORT_DEF( FT_Error )
FT_Stroker_CubicTo( FT_Stroker stroker,
FT_Vector* control1,
FT_Vector* control2,
FT_Vector* to )
{
FT_Error error = FT_Err_Ok;
FT_Vector bez_stack[37];
FT_Vector* arc;
FT_Vector* limit = bez_stack + 32;
FT_Bool first_arc = TRUE;
if ( !stroker || !control1 || !control2 || !to )
{
error = FT_THROW( Invalid_Argument );
goto Exit;
}
/* if all control points are coincident, this is a no-op; */
/* avoid creating a spurious corner */
if ( FT_IS_SMALL( stroker->center.x - control1->x ) &&
FT_IS_SMALL( stroker->center.y - control1->y ) &&
FT_IS_SMALL( control1->x - control2->x ) &&
FT_IS_SMALL( control1->y - control2->y ) &&
FT_IS_SMALL( control2->x - to->x ) &&
FT_IS_SMALL( control2->y - to->y ) )
{
stroker->center = *to;
goto Exit;
}
arc = bez_stack;
arc[0] = *to;
arc[1] = *control2;
arc[2] = *control1;
arc[3] = stroker->center;
while ( arc >= bez_stack )
{
FT_Angle angle_in, angle_mid, angle_out;
/* initialize with current direction */
angle_in = angle_out = angle_mid = stroker->angle_in;
if ( arc < limit &&
!ft_cubic_is_small_enough( arc, &angle_in,
&angle_mid, &angle_out ) )
{
if ( stroker->first_point )
stroker->angle_in = angle_in;
ft_cubic_split( arc );
arc += 3;
continue;
}
if ( first_arc )
{
first_arc = FALSE;
/* process corner if necessary */
if ( stroker->first_point )
error = ft_stroker_subpath_start( stroker, angle_in, 0 );
else
{
stroker->angle_out = angle_in;
error = ft_stroker_process_corner( stroker, 0 );
}
}
else if ( ft_pos_abs( FT_Angle_Diff( stroker->angle_in, angle_in ) ) >
FT_SMALL_CUBIC_THRESHOLD / 4 )
{
/* if the deviation from one arc to the next is too great, */
/* add a round corner */
stroker->center = arc[3];
stroker->angle_out = angle_in;
stroker->line_join = FT_STROKER_LINEJOIN_ROUND;
error = ft_stroker_process_corner( stroker, 0 );
/* reinstate line join style */
stroker->line_join = stroker->line_join_saved;
}
if ( error )
goto Exit;
/* the arc's angle is small enough; we can add it directly to each */
/* border */
{
FT_Vector ctrl1, ctrl2, end;
FT_Angle theta1, phi1, theta2, phi2, rotate, alpha0 = 0;
FT_Fixed length1, length2;
FT_StrokeBorder border;
FT_Int side;
theta1 = FT_Angle_Diff( angle_in, angle_mid ) / 2;
theta2 = FT_Angle_Diff( angle_mid, angle_out ) / 2;
phi1 = ft_angle_mean( angle_in, angle_mid );
phi2 = ft_angle_mean( angle_mid, angle_out );
length1 = FT_DivFix( stroker->radius, FT_Cos( theta1 ) );
length2 = FT_DivFix( stroker->radius, FT_Cos( theta2 ) );
/* compute direction of original arc */
if ( stroker->handle_wide_strokes )
alpha0 = FT_Atan2( arc[0].x - arc[3].x, arc[0].y - arc[3].y );
for ( border = stroker->borders, side = 0;
side <= 1;
side++, border++ )
{
rotate = FT_SIDE_TO_ROTATE( side );
/* compute control points */
FT_Vector_From_Polar( &ctrl1, length1, phi1 + rotate );
ctrl1.x += arc[2].x;
ctrl1.y += arc[2].y;
FT_Vector_From_Polar( &ctrl2, length2, phi2 + rotate );
ctrl2.x += arc[1].x;
ctrl2.y += arc[1].y;
/* compute end point */
FT_Vector_From_Polar( &end, stroker->radius, angle_out + rotate );
end.x += arc[0].x;
end.y += arc[0].y;
if ( stroker->handle_wide_strokes )
{
FT_Vector start;
FT_Angle alpha1;
/* determine whether the border radius is greater than the */
/* radius of curvature of the original arc */
start = border->points[border->num_points - 1];
alpha1 = FT_Atan2( end.x - start.x, end.y - start.y );
/* is the direction of the border arc opposite to */
/* that of the original arc? */
if ( ft_pos_abs( FT_Angle_Diff( alpha0, alpha1 ) ) >
FT_ANGLE_PI / 2 )
{
FT_Angle beta, gamma;
FT_Vector bvec, delta;
FT_Fixed blen, sinA, sinB, alen;
/* use the sine rule to find the intersection point */
beta = FT_Atan2( arc[3].x - start.x, arc[3].y - start.y );
gamma = FT_Atan2( arc[0].x - end.x, arc[0].y - end.y );
bvec.x = end.x - start.x;
bvec.y = end.y - start.y;
blen = FT_Vector_Length( &bvec );
sinA = ft_pos_abs( FT_Sin( alpha1 - gamma ) );
sinB = ft_pos_abs( FT_Sin( beta - gamma ) );
alen = FT_MulDiv( blen, sinA, sinB );
FT_Vector_From_Polar( &delta, alen, beta );
delta.x += start.x;
delta.y += start.y;
/* circumnavigate the negative sector backwards */
border->movable = FALSE;
error = ft_stroke_border_lineto( border, &delta, FALSE );
if ( error )
goto Exit;
error = ft_stroke_border_lineto( border, &end, FALSE );
if ( error )
goto Exit;
error = ft_stroke_border_cubicto( border,
&ctrl2,
&ctrl1,
&start );
if ( error )
goto Exit;
/* and then move to the endpoint */
error = ft_stroke_border_lineto( border, &end, FALSE );
if ( error )
goto Exit;
continue;
}
/* else fall through */
}
/* simply add an arc */
error = ft_stroke_border_cubicto( border, &ctrl1, &ctrl2, &end );
if ( error )
goto Exit;
}
}
arc -= 3;
stroker->angle_in = angle_out;
}
stroker->center = *to;
stroker->line_length = 0;
Exit:
return error;
}
/* documentation is in ftstroke.h */
FT_EXPORT_DEF( FT_Error )
FT_Stroker_BeginSubPath( FT_Stroker stroker,
FT_Vector* to,
FT_Bool open )
{
if ( !stroker || !to )
return FT_THROW( Invalid_Argument );
/* We cannot process the first point, because there is not enough */
/* information regarding its corner/cap. The latter will be processed */
/* in the `FT_Stroker_EndSubPath' routine. */
/* */
stroker->first_point = TRUE;
stroker->center = *to;
stroker->subpath_open = open;
/* Determine if we need to check whether the border radius is greater */
/* than the radius of curvature of a curve, to handle this case */
/* specially. This is only required if bevel joins or butt caps may */
/* be created, because round & miter joins and round & square caps */
/* cover the negative sector created with wide strokes. */
stroker->handle_wide_strokes =
FT_BOOL( stroker->line_join != FT_STROKER_LINEJOIN_ROUND ||
( stroker->subpath_open &&
stroker->line_cap == FT_STROKER_LINECAP_BUTT ) );
/* record the subpath start point for each border */
stroker->subpath_start = *to;
stroker->angle_in = 0;
return FT_Err_Ok;
}
static FT_Error
ft_stroker_add_reverse_left( FT_Stroker stroker,
FT_Bool open )
{
FT_StrokeBorder right = stroker->borders + 0;
FT_StrokeBorder left = stroker->borders + 1;
FT_Int new_points;
FT_Error error = FT_Err_Ok;
FT_ASSERT( left->start >= 0 );
new_points = (FT_Int)left->num_points - left->start;
if ( new_points > 0 )
{
error = ft_stroke_border_grow( right, (FT_UInt)new_points );
if ( error )
goto Exit;
{
FT_Vector* dst_point = right->points + right->num_points;
FT_Byte* dst_tag = right->tags + right->num_points;
FT_Vector* src_point = left->points + left->num_points - 1;
FT_Byte* src_tag = left->tags + left->num_points - 1;
while ( src_point >= left->points + left->start )
{
*dst_point = *src_point;
*dst_tag = *src_tag;
if ( open )
dst_tag[0] &= ~FT_STROKE_TAG_BEGIN_END;
else
{
FT_Byte ttag =
(FT_Byte)( dst_tag[0] & FT_STROKE_TAG_BEGIN_END );
/* switch begin/end tags if necessary */
if ( ttag == FT_STROKE_TAG_BEGIN ||
ttag == FT_STROKE_TAG_END )
dst_tag[0] ^= FT_STROKE_TAG_BEGIN_END;
}
src_point--;
src_tag--;
dst_point++;
dst_tag++;
}
}
left->num_points = (FT_UInt)left->start;
right->num_points += (FT_UInt)new_points;
right->movable = FALSE;
left->movable = FALSE;
}
Exit:
return error;
}
/* documentation is in ftstroke.h */
/* there's a lot of magic in this function! */
FT_EXPORT_DEF( FT_Error )
FT_Stroker_EndSubPath( FT_Stroker stroker )
{
FT_Error error = FT_Err_Ok;
if ( !stroker )
{
error = FT_THROW( Invalid_Argument );
goto Exit;
}
if ( stroker->subpath_open )
{
FT_StrokeBorder right = stroker->borders;
/* All right, this is an opened path, we need to add a cap between */
/* right & left, add the reverse of left, then add a final cap */
/* between left & right. */
error = ft_stroker_cap( stroker, stroker->angle_in, 0 );
if ( error )
goto Exit;
/* add reversed points from `left' to `right' */
error = ft_stroker_add_reverse_left( stroker, TRUE );
if ( error )
goto Exit;
/* now add the final cap */
stroker->center = stroker->subpath_start;
error = ft_stroker_cap( stroker,
stroker->subpath_angle + FT_ANGLE_PI, 0 );
if ( error )
goto Exit;
/* Now end the right subpath accordingly. The left one is */
/* rewind and doesn't need further processing. */
ft_stroke_border_close( right, FALSE );
}
else
{
/* close the path if needed */
if ( !FT_IS_SMALL( stroker->center.x - stroker->subpath_start.x ) ||
!FT_IS_SMALL( stroker->center.y - stroker->subpath_start.y ) )
{
error = FT_Stroker_LineTo( stroker, &stroker->subpath_start );
if ( error )
goto Exit;
}
/* process the corner */
stroker->angle_out = stroker->subpath_angle;
error = ft_stroker_process_corner( stroker,
stroker->subpath_line_length );
if ( error )
goto Exit;
/* then end our two subpaths */
ft_stroke_border_close( stroker->borders + 0, FALSE );
ft_stroke_border_close( stroker->borders + 1, TRUE );
}
Exit:
return error;
}
/* documentation is in ftstroke.h */
FT_EXPORT_DEF( FT_Error )
FT_Stroker_GetBorderCounts( FT_Stroker stroker,
FT_StrokerBorder border,
FT_UInt *anum_points,
FT_UInt *anum_contours )
{
FT_UInt num_points = 0, num_contours = 0;
FT_Error error;
if ( !stroker || border > 1 )
{
error = FT_THROW( Invalid_Argument );
goto Exit;
}
error = ft_stroke_border_get_counts( stroker->borders + border,
&num_points, &num_contours );
Exit:
if ( anum_points )
*anum_points = num_points;
if ( anum_contours )
*anum_contours = num_contours;
return error;
}
/* documentation is in ftstroke.h */
FT_EXPORT_DEF( FT_Error )
FT_Stroker_GetCounts( FT_Stroker stroker,
FT_UInt *anum_points,
FT_UInt *anum_contours )
{
FT_UInt count1, count2, num_points = 0;
FT_UInt count3, count4, num_contours = 0;
FT_Error error;
if ( !stroker )
{
error = FT_THROW( Invalid_Argument );
goto Exit;
}
error = ft_stroke_border_get_counts( stroker->borders + 0,
&count1, &count2 );
if ( error )
goto Exit;
error = ft_stroke_border_get_counts( stroker->borders + 1,
&count3, &count4 );
if ( error )
goto Exit;
num_points = count1 + count3;
num_contours = count2 + count4;
Exit:
if ( anum_points )
*anum_points = num_points;
if ( anum_contours )
*anum_contours = num_contours;
return error;
}
/* documentation is in ftstroke.h */
FT_EXPORT_DEF( void )
FT_Stroker_ExportBorder( FT_Stroker stroker,
FT_StrokerBorder border,
FT_Outline* outline )
{
if ( !stroker || !outline )
return;
if ( border == FT_STROKER_BORDER_LEFT ||
border == FT_STROKER_BORDER_RIGHT )
{
FT_StrokeBorder sborder = & stroker->borders[border];
if ( sborder->valid )
ft_stroke_border_export( sborder, outline );
}
}
/* documentation is in ftstroke.h */
FT_EXPORT_DEF( void )
FT_Stroker_Export( FT_Stroker stroker,
FT_Outline* outline )
{
FT_Stroker_ExportBorder( stroker, FT_STROKER_BORDER_LEFT, outline );
FT_Stroker_ExportBorder( stroker, FT_STROKER_BORDER_RIGHT, outline );
}
/* documentation is in ftstroke.h */
/*
* The following is very similar to FT_Outline_Decompose, except
* that we do support opened paths, and do not scale the outline.
*/
FT_EXPORT_DEF( FT_Error )
FT_Stroker_ParseOutline( FT_Stroker stroker,
FT_Outline* outline,
FT_Bool opened )
{
FT_Vector v_last;
FT_Vector v_control;
FT_Vector v_start;
FT_Vector* point;
FT_Vector* limit;
char* tags;
FT_Error error;
FT_Int n; /* index of contour in outline */
FT_UInt first; /* index of first point in contour */
FT_Int tag; /* current point's state */
if ( !outline )
return FT_THROW( Invalid_Outline );
if ( !stroker )
return FT_THROW( Invalid_Argument );
FT_Stroker_Rewind( stroker );
first = 0;
for ( n = 0; n < outline->n_contours; n++ )
{
FT_UInt last; /* index of last point in contour */
last = (FT_UInt)outline->contours[n];
limit = outline->points + last;
/* skip empty points; we don't stroke these */
if ( last <= first )
{
first = last + 1;
continue;
}
v_start = outline->points[first];
v_last = outline->points[last];
v_control = v_start;
point = outline->points + first;
tags = outline->tags + first;
tag = FT_CURVE_TAG( tags[0] );
/* A contour cannot start with a cubic control point! */
if ( tag == FT_CURVE_TAG_CUBIC )
goto Invalid_Outline;
/* check first point to determine origin */
if ( tag == FT_CURVE_TAG_CONIC )
{
/* First point is conic control. Yes, this happens. */
if ( FT_CURVE_TAG( outline->tags[last] ) == FT_CURVE_TAG_ON )
{
/* start at last point if it is on the curve */
v_start = v_last;
limit--;
}
else
{
/* if both first and last points are conic, */
/* start at their middle */
v_start.x = ( v_start.x + v_last.x ) / 2;
v_start.y = ( v_start.y + v_last.y ) / 2;
}
point--;
tags--;
}
error = FT_Stroker_BeginSubPath( stroker, &v_start, opened );
if ( error )
goto Exit;
while ( point < limit )
{
point++;
tags++;
tag = FT_CURVE_TAG( tags[0] );
switch ( tag )
{
case FT_CURVE_TAG_ON: /* emit a single line_to */
{
FT_Vector vec;
vec.x = point->x;
vec.y = point->y;
error = FT_Stroker_LineTo( stroker, &vec );
if ( error )
goto Exit;
continue;
}
case FT_CURVE_TAG_CONIC: /* consume conic arcs */
v_control.x = point->x;
v_control.y = point->y;
Do_Conic:
if ( point < limit )
{
FT_Vector vec;
FT_Vector v_middle;
point++;
tags++;
tag = FT_CURVE_TAG( tags[0] );
vec = point[0];
if ( tag == FT_CURVE_TAG_ON )
{
error = FT_Stroker_ConicTo( stroker, &v_control, &vec );
if ( error )
goto Exit;
continue;
}
if ( tag != FT_CURVE_TAG_CONIC )
goto Invalid_Outline;
v_middle.x = ( v_control.x + vec.x ) / 2;
v_middle.y = ( v_control.y + vec.y ) / 2;
error = FT_Stroker_ConicTo( stroker, &v_control, &v_middle );
if ( error )
goto Exit;
v_control = vec;
goto Do_Conic;
}
error = FT_Stroker_ConicTo( stroker, &v_control, &v_start );
goto Close;
default: /* FT_CURVE_TAG_CUBIC */
{
FT_Vector vec1, vec2;
if ( point + 1 > limit ||
FT_CURVE_TAG( tags[1] ) != FT_CURVE_TAG_CUBIC )
goto Invalid_Outline;
point += 2;
tags += 2;
vec1 = point[-2];
vec2 = point[-1];
if ( point <= limit )
{
FT_Vector vec;
vec = point[0];
error = FT_Stroker_CubicTo( stroker, &vec1, &vec2, &vec );
if ( error )
goto Exit;
continue;
}
error = FT_Stroker_CubicTo( stroker, &vec1, &vec2, &v_start );
goto Close;
}
}
}
Close:
if ( error )
goto Exit;
/* don't try to end the path if no segments have been generated */
if ( !stroker->first_point )
{
error = FT_Stroker_EndSubPath( stroker );
if ( error )
goto Exit;
}
first = last + 1;
}
return FT_Err_Ok;
Exit:
return error;
Invalid_Outline:
return FT_THROW( Invalid_Outline );
}
/* documentation is in ftstroke.h */
FT_EXPORT_DEF( FT_Error )
FT_Glyph_Stroke( FT_Glyph *pglyph,
FT_Stroker stroker,
FT_Bool destroy )
{
FT_Error error = FT_ERR( Invalid_Argument );
FT_Glyph glyph = NULL;
if ( !pglyph )
goto Exit;
glyph = *pglyph;
if ( !glyph || glyph->clazz != &ft_outline_glyph_class )
goto Exit;
{
FT_Glyph copy;
error = FT_Glyph_Copy( glyph, © );
if ( error )
goto Exit;
glyph = copy;
}
{
FT_OutlineGlyph oglyph = (FT_OutlineGlyph)glyph;
FT_Outline* outline = &oglyph->outline;
FT_UInt num_points, num_contours;
error = FT_Stroker_ParseOutline( stroker, outline, FALSE );
if ( error )
goto Fail;
FT_Stroker_GetCounts( stroker, &num_points, &num_contours );
FT_Outline_Done( glyph->library, outline );
error = FT_Outline_New( glyph->library,
num_points,
(FT_Int)num_contours,
outline );
if ( error )
goto Fail;
outline->n_points = 0;
outline->n_contours = 0;
FT_Stroker_Export( stroker, outline );
}
if ( destroy )
FT_Done_Glyph( *pglyph );
*pglyph = glyph;
goto Exit;
Fail:
FT_Done_Glyph( glyph );
glyph = NULL;
if ( !destroy )
*pglyph = NULL;
Exit:
return error;
}
/* documentation is in ftstroke.h */
FT_EXPORT_DEF( FT_Error )
FT_Glyph_StrokeBorder( FT_Glyph *pglyph,
FT_Stroker stroker,
FT_Bool inside,
FT_Bool destroy )
{
FT_Error error = FT_ERR( Invalid_Argument );
FT_Glyph glyph = NULL;
if ( !pglyph )
goto Exit;
glyph = *pglyph;
if ( !glyph || glyph->clazz != &ft_outline_glyph_class )
goto Exit;
{
FT_Glyph copy;
error = FT_Glyph_Copy( glyph, © );
if ( error )
goto Exit;
glyph = copy;
}
{
FT_OutlineGlyph oglyph = (FT_OutlineGlyph)glyph;
FT_StrokerBorder border;
FT_Outline* outline = &oglyph->outline;
FT_UInt num_points, num_contours;
border = FT_Outline_GetOutsideBorder( outline );
if ( inside )
{
if ( border == FT_STROKER_BORDER_LEFT )
border = FT_STROKER_BORDER_RIGHT;
else
border = FT_STROKER_BORDER_LEFT;
}
error = FT_Stroker_ParseOutline( stroker, outline, FALSE );
if ( error )
goto Fail;
FT_Stroker_GetBorderCounts( stroker, border,
&num_points, &num_contours );
FT_Outline_Done( glyph->library, outline );
error = FT_Outline_New( glyph->library,
num_points,
(FT_Int)num_contours,
outline );
if ( error )
goto Fail;
outline->n_points = 0;
outline->n_contours = 0;
FT_Stroker_ExportBorder( stroker, border, outline );
}
if ( destroy )
FT_Done_Glyph( *pglyph );
*pglyph = glyph;
goto Exit;
Fail:
FT_Done_Glyph( glyph );
glyph = NULL;
if ( !destroy )
*pglyph = NULL;
Exit:
return error;
}
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/base/ftstroke.c
|
C++
|
gpl-3.0
| 64,771
|
/****************************************************************************
*
* ftsynth.c
*
* FreeType synthesizing code for emboldening and slanting (body).
*
* Copyright (C) 2000-2022 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.
*
*/
#include <freetype/ftsynth.h>
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/ftobjs.h>
#include <freetype/ftoutln.h>
#include <freetype/ftbitmap.h>
/**************************************************************************
*
* The macro FT_COMPONENT is used in trace mode. It is an implicit
* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
* messages during execution.
*/
#undef FT_COMPONENT
#define FT_COMPONENT synth
/*************************************************************************/
/*************************************************************************/
/**** ****/
/**** EXPERIMENTAL OBLIQUING SUPPORT ****/
/**** ****/
/*************************************************************************/
/*************************************************************************/
/* documentation is in ftsynth.h */
FT_EXPORT_DEF( void )
FT_GlyphSlot_Oblique( FT_GlyphSlot slot )
{
FT_Matrix transform;
FT_Outline* outline;
if ( !slot )
return;
outline = &slot->outline;
/* only oblique outline glyphs */
if ( slot->format != FT_GLYPH_FORMAT_OUTLINE )
return;
/* we don't touch the advance width */
/* For italic, simply apply a shear transform, with an angle */
/* of about 12 degrees. */
transform.xx = 0x10000L;
transform.yx = 0x00000L;
transform.xy = 0x0366AL;
transform.yy = 0x10000L;
FT_Outline_Transform( outline, &transform );
}
/*************************************************************************/
/*************************************************************************/
/**** ****/
/**** EXPERIMENTAL EMBOLDENING SUPPORT ****/
/**** ****/
/*************************************************************************/
/*************************************************************************/
/* documentation is in ftsynth.h */
FT_EXPORT_DEF( void )
FT_GlyphSlot_Embolden( FT_GlyphSlot slot )
{
FT_Library library;
FT_Face face;
FT_Error error;
FT_Pos xstr, ystr;
if ( !slot )
return;
library = slot->library;
face = slot->face;
if ( slot->format != FT_GLYPH_FORMAT_OUTLINE &&
slot->format != FT_GLYPH_FORMAT_BITMAP )
return;
/* some reasonable strength */
xstr = FT_MulFix( face->units_per_EM,
face->size->metrics.y_scale ) / 24;
ystr = xstr;
if ( slot->format == FT_GLYPH_FORMAT_OUTLINE )
FT_Outline_EmboldenXY( &slot->outline, xstr, ystr );
else /* slot->format == FT_GLYPH_FORMAT_BITMAP */
{
/* round to full pixels */
xstr &= ~63;
if ( xstr == 0 )
xstr = 1 << 6;
ystr &= ~63;
/*
* XXX: overflow check for 16-bit system, for compatibility
* with FT_GlyphSlot_Embolden() since FreeType 2.1.10.
* unfortunately, this function return no informations
* about the cause of error.
*/
if ( ( ystr >> 6 ) > FT_INT_MAX || ( ystr >> 6 ) < FT_INT_MIN )
{
FT_TRACE1(( "FT_GlyphSlot_Embolden:" ));
FT_TRACE1(( "too strong emboldening parameter ystr=%ld\n", ystr ));
return;
}
error = FT_GlyphSlot_Own_Bitmap( slot );
if ( error )
return;
error = FT_Bitmap_Embolden( library, &slot->bitmap, xstr, ystr );
if ( error )
return;
}
if ( slot->advance.x )
slot->advance.x += xstr;
if ( slot->advance.y )
slot->advance.y += ystr;
slot->metrics.width += xstr;
slot->metrics.height += ystr;
slot->metrics.horiAdvance += xstr;
slot->metrics.vertAdvance += ystr;
slot->metrics.horiBearingY += ystr;
/* XXX: 16-bit overflow case must be excluded before here */
if ( slot->format == FT_GLYPH_FORMAT_BITMAP )
slot->bitmap_top += (FT_Int)( ystr >> 6 );
}
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/base/ftsynth.c
|
C++
|
gpl-3.0
| 4,878
|
/****************************************************************************
*
* ftsystem.c
*
* ANSI-specific FreeType low-level system interface (body).
*
* Copyright (C) 1996-2022 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 file contains the default interface used by FreeType to access
* low-level, i.e. memory management, i/o access as well as thread
* synchronisation. It can be replaced by user-specific routines if
* necessary.
*
*/
#include <ft2build.h>
#include FT_CONFIG_CONFIG_H
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/ftstream.h>
#include <freetype/ftsystem.h>
#include <freetype/fterrors.h>
#include <freetype/fttypes.h>
/**************************************************************************
*
* MEMORY MANAGEMENT INTERFACE
*
*/
/**************************************************************************
*
* It is not necessary to do any error checking for the
* allocation-related functions. This will be done by the higher level
* routines like ft_mem_alloc() or ft_mem_realloc().
*
*/
/**************************************************************************
*
* @Function:
* ft_alloc
*
* @Description:
* The memory allocation function.
*
* @Input:
* memory ::
* A pointer to the memory object.
*
* size ::
* The requested size in bytes.
*
* @Return:
* The address of newly allocated block.
*/
FT_CALLBACK_DEF( void* )
ft_alloc( FT_Memory memory,
long size )
{
FT_UNUSED( memory );
return ft_smalloc( (size_t)size );
}
/**************************************************************************
*
* @Function:
* ft_realloc
*
* @Description:
* The memory reallocation function.
*
* @Input:
* memory ::
* A pointer to the memory object.
*
* cur_size ::
* The current size of the allocated memory block.
*
* new_size ::
* The newly requested size in bytes.
*
* block ::
* The current address of the block in memory.
*
* @Return:
* The address of the reallocated memory block.
*/
FT_CALLBACK_DEF( void* )
ft_realloc( FT_Memory memory,
long cur_size,
long new_size,
void* block )
{
FT_UNUSED( memory );
FT_UNUSED( cur_size );
return ft_srealloc( block, (size_t)new_size );
}
/**************************************************************************
*
* @Function:
* ft_free
*
* @Description:
* The memory release function.
*
* @Input:
* memory ::
* A pointer to the memory object.
*
* block ::
* The address of block in memory to be freed.
*/
FT_CALLBACK_DEF( void )
ft_free( FT_Memory memory,
void* block )
{
FT_UNUSED( memory );
ft_sfree( block );
}
/**************************************************************************
*
* RESOURCE MANAGEMENT INTERFACE
*
*/
#ifndef FT_CONFIG_OPTION_DISABLE_STREAM_SUPPORT
/**************************************************************************
*
* The macro FT_COMPONENT is used in trace mode. It is an implicit
* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
* messages during execution.
*/
#undef FT_COMPONENT
#define FT_COMPONENT io
/* We use the macro STREAM_FILE for convenience to extract the */
/* system-specific stream handle from a given FreeType stream object */
#define STREAM_FILE( stream ) ( (FT_FILE*)stream->descriptor.pointer )
/**************************************************************************
*
* @Function:
* ft_ansi_stream_close
*
* @Description:
* The function to close a stream.
*
* @Input:
* stream ::
* A pointer to the stream object.
*/
FT_CALLBACK_DEF( void )
ft_ansi_stream_close( FT_Stream stream )
{
ft_fclose( STREAM_FILE( stream ) );
stream->descriptor.pointer = NULL;
stream->size = 0;
stream->base = NULL;
}
/**************************************************************************
*
* @Function:
* ft_ansi_stream_io
*
* @Description:
* The function to open a stream.
*
* @Input:
* stream ::
* A pointer to the stream object.
*
* offset ::
* The position in the data stream to start reading.
*
* buffer ::
* The address of buffer to store the read data.
*
* count ::
* The number of bytes to read from the stream.
*
* @Return:
* The number of bytes actually read. If `count' is zero (this is,
* the function is used for seeking), a non-zero return value
* indicates an error.
*/
FT_CALLBACK_DEF( unsigned long )
ft_ansi_stream_io( FT_Stream stream,
unsigned long offset,
unsigned char* buffer,
unsigned long count )
{
FT_FILE* file;
if ( !count && offset > stream->size )
return 1;
file = STREAM_FILE( stream );
if ( stream->pos != offset )
ft_fseek( file, (long)offset, SEEK_SET );
return (unsigned long)ft_fread( buffer, 1, count, file );
}
/* documentation is in ftstream.h */
FT_BASE_DEF( FT_Error )
FT_Stream_Open( FT_Stream stream,
const char* filepathname )
{
FT_FILE* file;
if ( !stream )
return FT_THROW( Invalid_Stream_Handle );
stream->descriptor.pointer = NULL;
stream->pathname.pointer = (char*)filepathname;
stream->base = NULL;
stream->pos = 0;
stream->read = NULL;
stream->close = NULL;
file = ft_fopen( filepathname, "rb" );
if ( !file )
{
FT_ERROR(( "FT_Stream_Open:"
" could not open `%s'\n", filepathname ));
return FT_THROW( Cannot_Open_Resource );
}
ft_fseek( file, 0, SEEK_END );
stream->size = (unsigned long)ft_ftell( file );
if ( !stream->size )
{
FT_ERROR(( "FT_Stream_Open:" ));
FT_ERROR(( " opened `%s' but zero-sized\n", filepathname ));
ft_fclose( file );
return FT_THROW( Cannot_Open_Stream );
}
ft_fseek( file, 0, SEEK_SET );
stream->descriptor.pointer = file;
stream->read = ft_ansi_stream_io;
stream->close = ft_ansi_stream_close;
FT_TRACE1(( "FT_Stream_Open:" ));
FT_TRACE1(( " opened `%s' (%ld bytes) successfully\n",
filepathname, stream->size ));
return FT_Err_Ok;
}
#endif /* !FT_CONFIG_OPTION_DISABLE_STREAM_SUPPORT */
#ifdef FT_DEBUG_MEMORY
extern FT_Int
ft_mem_debug_init( FT_Memory memory );
extern void
ft_mem_debug_done( FT_Memory memory );
#endif
/* documentation is in ftobjs.h */
FT_BASE_DEF( FT_Memory )
FT_New_Memory( void )
{
FT_Memory memory;
memory = (FT_Memory)ft_smalloc( sizeof ( *memory ) );
if ( memory )
{
memory->user = NULL;
memory->alloc = ft_alloc;
memory->realloc = ft_realloc;
memory->free = ft_free;
#ifdef FT_DEBUG_MEMORY
ft_mem_debug_init( memory );
#endif
}
return memory;
}
/* documentation is in ftobjs.h */
FT_BASE_DEF( void )
FT_Done_Memory( FT_Memory memory )
{
#ifdef FT_DEBUG_MEMORY
ft_mem_debug_done( memory );
#endif
ft_sfree( memory );
}
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/base/ftsystem.c
|
C++
|
gpl-3.0
| 7,982
|
/****************************************************************************
*
* fttrigon.c
*
* FreeType trigonometric functions (body).
*
* Copyright (C) 2001-2022 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 a fixed-point CORDIC implementation of trigonometric
* functions as well as transformations between Cartesian and polar
* coordinates. The angles are represented as 16.16 fixed-point values
* in degrees, i.e., the angular resolution is 2^-16 degrees. Note that
* only vectors longer than 2^16*180/pi (or at least 22 bits) on a
* discrete Cartesian grid can have the same or better angular
* resolution. Therefore, to maintain this precision, some functions
* require an interim upscaling of the vectors, whereas others operate
* with 24-bit long vectors directly.
*
*/
#include <freetype/internal/ftobjs.h>
#include <freetype/internal/ftcalc.h>
#include <freetype/fttrigon.h>
/* the Cordic shrink factor 0.858785336480436 * 2^32 */
#define FT_TRIG_SCALE 0xDBD95B16UL
/* the highest bit in overflow-safe vector components, */
/* MSB of 0.858785336480436 * sqrt(0.5) * 2^30 */
#define FT_TRIG_SAFE_MSB 29
/* this table was generated for FT_PI = 180L << 16, i.e. degrees */
#define FT_TRIG_MAX_ITERS 23
static const FT_Angle
ft_trig_arctan_table[] =
{
1740967L, 919879L, 466945L, 234379L, 117304L, 58666L, 29335L,
14668L, 7334L, 3667L, 1833L, 917L, 458L, 229L, 115L,
57L, 29L, 14L, 7L, 4L, 2L, 1L
};
#ifdef FT_INT64
/* multiply a given value by the CORDIC shrink factor */
static FT_Fixed
ft_trig_downscale( FT_Fixed val )
{
FT_Int s = 1;
if ( val < 0 )
{
val = -val;
s = -1;
}
/* 0x40000000 comes from regression analysis between true */
/* and CORDIC hypotenuse, so it minimizes the error */
val = (FT_Fixed)(
( (FT_UInt64)val * FT_TRIG_SCALE + 0x40000000UL ) >> 32 );
return s < 0 ? -val : val;
}
#else /* !FT_INT64 */
/* multiply a given value by the CORDIC shrink factor */
static FT_Fixed
ft_trig_downscale( FT_Fixed val )
{
FT_Int s = 1;
FT_UInt32 lo1, hi1, lo2, hi2, lo, hi, i1, i2;
if ( val < 0 )
{
val = -val;
s = -1;
}
lo1 = (FT_UInt32)val & 0x0000FFFFU;
hi1 = (FT_UInt32)val >> 16;
lo2 = FT_TRIG_SCALE & 0x0000FFFFU;
hi2 = FT_TRIG_SCALE >> 16;
lo = lo1 * lo2;
i1 = lo1 * hi2;
i2 = lo2 * hi1;
hi = hi1 * hi2;
/* Check carry overflow of i1 + i2 */
i1 += i2;
hi += (FT_UInt32)( i1 < i2 ) << 16;
hi += i1 >> 16;
i1 = i1 << 16;
/* Check carry overflow of i1 + lo */
lo += i1;
hi += ( lo < i1 );
/* 0x40000000 comes from regression analysis between true */
/* and CORDIC hypotenuse, so it minimizes the error */
/* Check carry overflow of lo + 0x40000000 */
lo += 0x40000000UL;
hi += ( lo < 0x40000000UL );
val = (FT_Fixed)hi;
return s < 0 ? -val : val;
}
#endif /* !FT_INT64 */
/* undefined and never called for zero vector */
static FT_Int
ft_trig_prenorm( FT_Vector* vec )
{
FT_Pos x, y;
FT_Int shift;
x = vec->x;
y = vec->y;
shift = FT_MSB( (FT_UInt32)( FT_ABS( x ) | FT_ABS( y ) ) );
if ( shift <= FT_TRIG_SAFE_MSB )
{
shift = FT_TRIG_SAFE_MSB - shift;
vec->x = (FT_Pos)( (FT_ULong)x << shift );
vec->y = (FT_Pos)( (FT_ULong)y << shift );
}
else
{
shift -= FT_TRIG_SAFE_MSB;
vec->x = x >> shift;
vec->y = y >> shift;
shift = -shift;
}
return shift;
}
static void
ft_trig_pseudo_rotate( FT_Vector* vec,
FT_Angle theta )
{
FT_Int i;
FT_Fixed x, y, xtemp, b;
const FT_Angle *arctanptr;
x = vec->x;
y = vec->y;
/* Rotate inside [-PI/4,PI/4] sector */
while ( theta < -FT_ANGLE_PI4 )
{
xtemp = y;
y = -x;
x = xtemp;
theta += FT_ANGLE_PI2;
}
while ( theta > FT_ANGLE_PI4 )
{
xtemp = -y;
y = x;
x = xtemp;
theta -= FT_ANGLE_PI2;
}
arctanptr = ft_trig_arctan_table;
/* Pseudorotations, with right shifts */
for ( i = 1, b = 1; i < FT_TRIG_MAX_ITERS; b <<= 1, i++ )
{
if ( theta < 0 )
{
xtemp = x + ( ( y + b ) >> i );
y = y - ( ( x + b ) >> i );
x = xtemp;
theta += *arctanptr++;
}
else
{
xtemp = x - ( ( y + b ) >> i );
y = y + ( ( x + b ) >> i );
x = xtemp;
theta -= *arctanptr++;
}
}
vec->x = x;
vec->y = y;
}
static void
ft_trig_pseudo_polarize( FT_Vector* vec )
{
FT_Angle theta;
FT_Int i;
FT_Fixed x, y, xtemp, b;
const FT_Angle *arctanptr;
x = vec->x;
y = vec->y;
/* Get the vector into [-PI/4,PI/4] sector */
if ( y > x )
{
if ( y > -x )
{
theta = FT_ANGLE_PI2;
xtemp = y;
y = -x;
x = xtemp;
}
else
{
theta = y > 0 ? FT_ANGLE_PI : -FT_ANGLE_PI;
x = -x;
y = -y;
}
}
else
{
if ( y < -x )
{
theta = -FT_ANGLE_PI2;
xtemp = -y;
y = x;
x = xtemp;
}
else
{
theta = 0;
}
}
arctanptr = ft_trig_arctan_table;
/* Pseudorotations, with right shifts */
for ( i = 1, b = 1; i < FT_TRIG_MAX_ITERS; b <<= 1, i++ )
{
if ( y > 0 )
{
xtemp = x + ( ( y + b ) >> i );
y = y - ( ( x + b ) >> i );
x = xtemp;
theta += *arctanptr++;
}
else
{
xtemp = x - ( ( y + b ) >> i );
y = y + ( ( x + b ) >> i );
x = xtemp;
theta -= *arctanptr++;
}
}
/* round theta to acknowledge its error that mostly comes */
/* from accumulated rounding errors in the arctan table */
if ( theta >= 0 )
theta = FT_PAD_ROUND( theta, 16 );
else
theta = -FT_PAD_ROUND( -theta, 16 );
vec->x = x;
vec->y = theta;
}
/* documentation is in fttrigon.h */
FT_EXPORT_DEF( FT_Fixed )
FT_Cos( FT_Angle angle )
{
FT_Vector v;
FT_Vector_Unit( &v, angle );
return v.x;
}
/* documentation is in fttrigon.h */
FT_EXPORT_DEF( FT_Fixed )
FT_Sin( FT_Angle angle )
{
FT_Vector v;
FT_Vector_Unit( &v, angle );
return v.y;
}
/* documentation is in fttrigon.h */
FT_EXPORT_DEF( FT_Fixed )
FT_Tan( FT_Angle angle )
{
FT_Vector v = { 1 << 24, 0 };
ft_trig_pseudo_rotate( &v, angle );
return FT_DivFix( v.y, v.x );
}
/* documentation is in fttrigon.h */
FT_EXPORT_DEF( FT_Angle )
FT_Atan2( FT_Fixed dx,
FT_Fixed dy )
{
FT_Vector v;
if ( dx == 0 && dy == 0 )
return 0;
v.x = dx;
v.y = dy;
ft_trig_prenorm( &v );
ft_trig_pseudo_polarize( &v );
return v.y;
}
/* documentation is in fttrigon.h */
FT_EXPORT_DEF( void )
FT_Vector_Unit( FT_Vector* vec,
FT_Angle angle )
{
if ( !vec )
return;
vec->x = FT_TRIG_SCALE >> 8;
vec->y = 0;
ft_trig_pseudo_rotate( vec, angle );
vec->x = ( vec->x + 0x80L ) >> 8;
vec->y = ( vec->y + 0x80L ) >> 8;
}
/* documentation is in fttrigon.h */
FT_EXPORT_DEF( void )
FT_Vector_Rotate( FT_Vector* vec,
FT_Angle angle )
{
FT_Int shift;
FT_Vector v;
if ( !vec || !angle )
return;
v = *vec;
if ( v.x == 0 && v.y == 0 )
return;
shift = ft_trig_prenorm( &v );
ft_trig_pseudo_rotate( &v, angle );
v.x = ft_trig_downscale( v.x );
v.y = ft_trig_downscale( v.y );
if ( shift > 0 )
{
FT_Int32 half = (FT_Int32)1L << ( shift - 1 );
vec->x = ( v.x + half - ( v.x < 0 ) ) >> shift;
vec->y = ( v.y + half - ( v.y < 0 ) ) >> shift;
}
else
{
shift = -shift;
vec->x = (FT_Pos)( (FT_ULong)v.x << shift );
vec->y = (FT_Pos)( (FT_ULong)v.y << shift );
}
}
/* documentation is in fttrigon.h */
FT_EXPORT_DEF( FT_Fixed )
FT_Vector_Length( FT_Vector* vec )
{
FT_Int shift;
FT_Vector v;
if ( !vec )
return 0;
v = *vec;
/* handle trivial cases */
if ( v.x == 0 )
{
return FT_ABS( v.y );
}
else if ( v.y == 0 )
{
return FT_ABS( v.x );
}
/* general case */
shift = ft_trig_prenorm( &v );
ft_trig_pseudo_polarize( &v );
v.x = ft_trig_downscale( v.x );
if ( shift > 0 )
return ( v.x + ( 1L << ( shift - 1 ) ) ) >> shift;
return (FT_Fixed)( (FT_UInt32)v.x << -shift );
}
/* documentation is in fttrigon.h */
FT_EXPORT_DEF( void )
FT_Vector_Polarize( FT_Vector* vec,
FT_Fixed *length,
FT_Angle *angle )
{
FT_Int shift;
FT_Vector v;
if ( !vec || !length || !angle )
return;
v = *vec;
if ( v.x == 0 && v.y == 0 )
return;
shift = ft_trig_prenorm( &v );
ft_trig_pseudo_polarize( &v );
v.x = ft_trig_downscale( v.x );
*length = shift >= 0 ? ( v.x >> shift )
: (FT_Fixed)( (FT_UInt32)v.x << -shift );
*angle = v.y;
}
/* documentation is in fttrigon.h */
FT_EXPORT_DEF( void )
FT_Vector_From_Polar( FT_Vector* vec,
FT_Fixed length,
FT_Angle angle )
{
if ( !vec )
return;
vec->x = length;
vec->y = 0;
FT_Vector_Rotate( vec, angle );
}
/* documentation is in fttrigon.h */
FT_EXPORT_DEF( FT_Angle )
FT_Angle_Diff( FT_Angle angle1,
FT_Angle angle2 )
{
FT_Angle delta = angle2 - angle1;
while ( delta <= -FT_ANGLE_PI )
delta += FT_ANGLE_2PI;
while ( delta > FT_ANGLE_PI )
delta -= FT_ANGLE_2PI;
return delta;
}
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/base/fttrigon.c
|
C++
|
gpl-3.0
| 10,565
|
/****************************************************************************
*
* fttype1.c
*
* FreeType utility file for PS names support (body).
*
* Copyright (C) 2002-2022 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.
*
*/
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/ftobjs.h>
#include <freetype/internal/ftserv.h>
#include <freetype/internal/services/svpsinfo.h>
/* documentation is in t1tables.h */
FT_EXPORT_DEF( FT_Error )
FT_Get_PS_Font_Info( FT_Face face,
PS_FontInfoRec* afont_info )
{
FT_Error error;
FT_Service_PsInfo service;
if ( !face )
return FT_THROW( Invalid_Face_Handle );
if ( !afont_info )
return FT_THROW( Invalid_Argument );
FT_FACE_FIND_SERVICE( face, service, POSTSCRIPT_INFO );
if ( service && service->ps_get_font_info )
error = service->ps_get_font_info( face, afont_info );
else
error = FT_THROW( Invalid_Argument );
return error;
}
/* documentation is in t1tables.h */
FT_EXPORT_DEF( FT_Int )
FT_Has_PS_Glyph_Names( FT_Face face )
{
FT_Int result = 0;
FT_Service_PsInfo service;
if ( face )
{
FT_FACE_FIND_SERVICE( face, service, POSTSCRIPT_INFO );
if ( service && service->ps_has_glyph_names )
result = service->ps_has_glyph_names( face );
}
return result;
}
/* documentation is in t1tables.h */
FT_EXPORT_DEF( FT_Error )
FT_Get_PS_Font_Private( FT_Face face,
PS_PrivateRec* afont_private )
{
FT_Error error;
FT_Service_PsInfo service;
if ( !face )
return FT_THROW( Invalid_Face_Handle );
if ( !afont_private )
return FT_THROW( Invalid_Argument );
FT_FACE_FIND_SERVICE( face, service, POSTSCRIPT_INFO );
if ( service && service->ps_get_font_private )
error = service->ps_get_font_private( face, afont_private );
else
error = FT_THROW( Invalid_Argument );
return error;
}
/* documentation is in t1tables.h */
FT_EXPORT_DEF( FT_Long )
FT_Get_PS_Font_Value( FT_Face face,
PS_Dict_Keys key,
FT_UInt idx,
void *value,
FT_Long value_len )
{
FT_Int result = 0;
FT_Service_PsInfo service = NULL;
if ( face )
{
FT_FACE_FIND_SERVICE( face, service, POSTSCRIPT_INFO );
if ( service && service->ps_get_font_value )
result = service->ps_get_font_value( face, key, idx,
value, value_len );
}
return result;
}
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/base/fttype1.c
|
C++
|
gpl-3.0
| 3,047
|
/****************************************************************************
*
* ftutil.c
*
* FreeType utility file for memory and list management (body).
*
* Copyright (C) 2002-2022 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.
*
*/
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/ftmemory.h>
#include <freetype/internal/ftobjs.h>
#include <freetype/ftlist.h>
/**************************************************************************
*
* The macro FT_COMPONENT is used in trace mode. It is an implicit
* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
* messages during execution.
*/
#undef FT_COMPONENT
#define FT_COMPONENT memory
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** *****/
/***** M E M O R Y M A N A G E M E N T *****/
/***** *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
FT_BASE_DEF( FT_Pointer )
ft_mem_alloc( FT_Memory memory,
FT_Long size,
FT_Error *p_error )
{
FT_Error error;
FT_Pointer block = ft_mem_qalloc( memory, size, &error );
if ( !error && block && size > 0 )
FT_MEM_ZERO( block, size );
*p_error = error;
return block;
}
FT_BASE_DEF( FT_Pointer )
ft_mem_qalloc( FT_Memory memory,
FT_Long size,
FT_Error *p_error )
{
FT_Error error = FT_Err_Ok;
FT_Pointer block = NULL;
if ( size > 0 )
{
block = memory->alloc( memory, size );
if ( !block )
error = FT_THROW( Out_Of_Memory );
}
else if ( size < 0 )
{
/* may help catch/prevent security issues */
error = FT_THROW( Invalid_Argument );
}
*p_error = error;
return block;
}
FT_BASE_DEF( FT_Pointer )
ft_mem_realloc( FT_Memory memory,
FT_Long item_size,
FT_Long cur_count,
FT_Long new_count,
void* block,
FT_Error *p_error )
{
FT_Error error = FT_Err_Ok;
block = ft_mem_qrealloc( memory, item_size,
cur_count, new_count, block, &error );
if ( !error && block && new_count > cur_count )
FT_MEM_ZERO( (char*)block + cur_count * item_size,
( new_count - cur_count ) * item_size );
*p_error = error;
return block;
}
FT_BASE_DEF( FT_Pointer )
ft_mem_qrealloc( FT_Memory memory,
FT_Long item_size,
FT_Long cur_count,
FT_Long new_count,
void* block,
FT_Error *p_error )
{
FT_Error error = FT_Err_Ok;
/* Note that we now accept `item_size == 0' as a valid parameter, in
* order to cover very weird cases where an ALLOC_MULT macro would be
* called.
*/
if ( cur_count < 0 || new_count < 0 || item_size < 0 )
{
/* may help catch/prevent nasty security issues */
error = FT_THROW( Invalid_Argument );
}
else if ( new_count == 0 || item_size == 0 )
{
ft_mem_free( memory, block );
block = NULL;
}
else if ( new_count > FT_INT_MAX / item_size )
{
error = FT_THROW( Array_Too_Large );
}
else if ( cur_count == 0 )
{
FT_ASSERT( !block );
block = memory->alloc( memory, new_count * item_size );
if ( block == NULL )
error = FT_THROW( Out_Of_Memory );
}
else
{
FT_Pointer block2;
FT_Long cur_size = cur_count * item_size;
FT_Long new_size = new_count * item_size;
block2 = memory->realloc( memory, cur_size, new_size, block );
if ( !block2 )
error = FT_THROW( Out_Of_Memory );
else
block = block2;
}
*p_error = error;
return block;
}
FT_BASE_DEF( void )
ft_mem_free( FT_Memory memory,
const void *P )
{
if ( P )
memory->free( memory, (void*)P );
}
FT_BASE_DEF( FT_Pointer )
ft_mem_dup( FT_Memory memory,
const void* address,
FT_ULong size,
FT_Error *p_error )
{
FT_Error error;
FT_Pointer p = ft_mem_qalloc( memory, (FT_Long)size, &error );
if ( !error && address && size > 0 )
ft_memcpy( p, address, size );
*p_error = error;
return p;
}
FT_BASE_DEF( FT_Pointer )
ft_mem_strdup( FT_Memory memory,
const char* str,
FT_Error *p_error )
{
FT_ULong len = str ? (FT_ULong)ft_strlen( str ) + 1
: 0;
return ft_mem_dup( memory, str, len, p_error );
}
FT_BASE_DEF( FT_Int )
ft_mem_strcpyn( char* dst,
const char* src,
FT_ULong size )
{
while ( size > 1 && *src != 0 )
{
*dst++ = *src++;
size--;
}
*dst = 0; /* always zero-terminate */
return *src != 0;
}
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** *****/
/***** D O U B L Y L I N K E D L I S T S *****/
/***** *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
#undef FT_COMPONENT
#define FT_COMPONENT list
/* documentation is in ftlist.h */
FT_EXPORT_DEF( FT_ListNode )
FT_List_Find( FT_List list,
void* data )
{
FT_ListNode cur;
if ( !list )
return NULL;
cur = list->head;
while ( cur )
{
if ( cur->data == data )
return cur;
cur = cur->next;
}
return NULL;
}
/* documentation is in ftlist.h */
FT_EXPORT_DEF( void )
FT_List_Add( FT_List list,
FT_ListNode node )
{
FT_ListNode before;
if ( !list || !node )
return;
before = list->tail;
node->next = NULL;
node->prev = before;
if ( before )
before->next = node;
else
list->head = node;
list->tail = node;
}
/* documentation is in ftlist.h */
FT_EXPORT_DEF( void )
FT_List_Insert( FT_List list,
FT_ListNode node )
{
FT_ListNode after;
if ( !list || !node )
return;
after = list->head;
node->next = after;
node->prev = NULL;
if ( !after )
list->tail = node;
else
after->prev = node;
list->head = node;
}
/* documentation is in ftlist.h */
FT_EXPORT_DEF( void )
FT_List_Remove( FT_List list,
FT_ListNode node )
{
FT_ListNode before, after;
if ( !list || !node )
return;
before = node->prev;
after = node->next;
if ( before )
before->next = after;
else
list->head = after;
if ( after )
after->prev = before;
else
list->tail = before;
}
/* documentation is in ftlist.h */
FT_EXPORT_DEF( void )
FT_List_Up( FT_List list,
FT_ListNode node )
{
FT_ListNode before, after;
if ( !list || !node )
return;
before = node->prev;
after = node->next;
/* check whether we are already on top of the list */
if ( !before )
return;
before->next = after;
if ( after )
after->prev = before;
else
list->tail = before;
node->prev = NULL;
node->next = list->head;
list->head->prev = node;
list->head = node;
}
/* documentation is in ftlist.h */
FT_EXPORT_DEF( FT_Error )
FT_List_Iterate( FT_List list,
FT_List_Iterator iterator,
void* user )
{
FT_ListNode cur;
FT_Error error = FT_Err_Ok;
if ( !list || !iterator )
return FT_THROW( Invalid_Argument );
cur = list->head;
while ( cur )
{
FT_ListNode next = cur->next;
error = iterator( cur, user );
if ( error )
break;
cur = next;
}
return error;
}
/* documentation is in ftlist.h */
FT_EXPORT_DEF( void )
FT_List_Finalize( FT_List list,
FT_List_Destructor destroy,
FT_Memory memory,
void* user )
{
FT_ListNode cur;
if ( !list || !memory )
return;
cur = list->head;
while ( cur )
{
FT_ListNode next = cur->next;
void* data = cur->data;
if ( destroy )
destroy( memory, data, user );
FT_FREE( cur );
cur = next;
}
list->head = NULL;
list->tail = NULL;
}
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/base/ftutil.c
|
C++
|
gpl-3.0
| 10,171
|
/***************************************************************************/
/* */
/* ftver.rc */
/* */
/* FreeType VERSIONINFO resource for Windows DLLs. */
/* */
/* Copyright (C) 2018-2022 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. */
/* */
/***************************************************************************/
#include<windows.h>
#define FT_VERSION 2,12,0,0
#define FT_VERSION_STR "2.12.0"
VS_VERSION_INFO VERSIONINFO
FILEVERSION FT_VERSION
PRODUCTVERSION FT_VERSION
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
#ifdef _DEBUG
FILEFLAGS VS_FF_DEBUG
#endif
#ifdef DLL_EXPORT
FILETYPE VFT_DLL
#define FT_FILENAME "freetype.dll"
#else
FILETYPE VFT_STATIC_LIB
#define FT_FILENAME "freetype.lib"
#endif
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904E4"
BEGIN
VALUE "CompanyName", "The FreeType Project"
VALUE "FileDescription", "Font Rendering Library"
VALUE "FileVersion", FT_VERSION_STR
VALUE "ProductName", "FreeType"
VALUE "ProductVersion", FT_VERSION_STR
VALUE "LegalCopyright", "\251 2000-2022 The FreeType Project www.freetype.org. All rights reserved."
VALUE "InternalName", "freetype"
VALUE "OriginalFilename", FT_FILENAME
END
END
BLOCK "VarFileInfo"
BEGIN
/* The following line should only be modified for localized versions. */
/* It consists of any number of WORD,WORD pairs, with each pair */
/* describing a "language,codepage" combination supported by the file. */
VALUE "Translation", 0x409, 1252
END
END
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/base/ftver.rc
|
rc
|
gpl-3.0
| 2,540
|
/****************************************************************************
*
* ftwinfnt.c
*
* FreeType API for accessing Windows FNT specific info (body).
*
* Copyright (C) 2003-2022 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.
*
*/
#include <freetype/internal/ftdebug.h>
#include <freetype/ftwinfnt.h>
#include <freetype/internal/ftobjs.h>
#include <freetype/internal/services/svwinfnt.h>
/* documentation is in ftwinfnt.h */
FT_EXPORT_DEF( FT_Error )
FT_Get_WinFNT_Header( FT_Face face,
FT_WinFNT_HeaderRec *header )
{
FT_Service_WinFnt service;
FT_Error error;
if ( !face )
return FT_THROW( Invalid_Face_Handle );
if ( !header )
return FT_THROW( Invalid_Argument );
FT_FACE_LOOKUP_SERVICE( face, service, WINFNT );
if ( service )
error = service->get_header( face, header );
else
error = FT_THROW( Invalid_Argument );
return error;
}
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/base/ftwinfnt.c
|
C++
|
gpl-3.0
| 1,306
|
/*
* This is an OpenSSL-compatible implementation of the RSA Data Security, Inc.
* MD5 Message-Digest Algorithm (RFC 1321).
*
* Homepage:
* http://openwall.info/wiki/people/solar/software/public-domain-source-code/md5
*
* Author:
* Alexander Peslyak, better known as Solar Designer <solar at openwall.com>
*
* This software was written by Alexander Peslyak in 2001. No copyright is
* claimed, and the software is hereby placed in the public domain.
* In case this attempt to disclaim copyright and place the software in the
* public domain is deemed null and void, then the software is
* Copyright (c) 2001 Alexander Peslyak and it is hereby released to the
* general public under the following terms:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted.
*
* There's ABSOLUTELY NO WARRANTY, express or implied.
*
* (This is a heavily cut-down "BSD license".)
*
* This differs from Colin Plumb's older public domain implementation in that
* no exactly 32-bit integer data type is required (any 32-bit or wider
* unsigned integer data type will do), there's no compile-time endianness
* configuration, and the function prototypes match OpenSSL's. No code from
* Colin Plumb's implementation has been reused; this comment merely compares
* the properties of the two independent implementations.
*
* The primary goals of this implementation are portability and ease of use.
* It is meant to be fast, but not as fast as possible. Some known
* optimizations are not included to reduce source code size and avoid
* compile-time configuration.
*/
#ifndef HAVE_OPENSSL
#include <string.h>
#include "md5.h"
/*
* The basic MD5 functions.
*
* F and G are optimized compared to their RFC 1321 definitions for
* architectures that lack an AND-NOT instruction, just like in Colin Plumb's
* implementation.
*/
#define F(x, y, z) ((z) ^ ((x) & ((y) ^ (z))))
#define G(x, y, z) ((y) ^ ((z) & ((x) ^ (y))))
#define H(x, y, z) (((x) ^ (y)) ^ (z))
#define H2(x, y, z) ((x) ^ ((y) ^ (z)))
#define I(x, y, z) ((y) ^ ((x) | ~(z)))
/*
* The MD5 transformation for all four rounds.
*/
#define STEP(f, a, b, c, d, x, t, s) \
(a) += f((b), (c), (d)) + (x) + (t); \
(a) = (((a) << (s)) | (((a) & 0xffffffff) >> (32 - (s)))); \
(a) += (b);
/*
* SET reads 4 input bytes in little-endian byte order and stores them in a
* properly aligned word in host byte order.
*
* The check for little-endian architectures that tolerate unaligned memory
* accesses is just an optimization. Nothing will break if it fails to detect
* a suitable architecture.
*
* Unfortunately, this optimization may be a C strict aliasing rules violation
* if the caller's data buffer has effective type that cannot be aliased by
* MD5_u32plus. In practice, this problem may occur if these MD5 routines are
* inlined into a calling function, or with future and dangerously advanced
* link-time optimizations. For the time being, keeping these MD5 routines in
* their own translation unit avoids the problem.
*/
#if defined(__i386__) || defined(__x86_64__) || defined(__vax__)
#define SET(n) \
(*(MD5_u32plus *)&ptr[(n) * 4])
#define GET(n) \
SET(n)
#else
#define SET(n) \
(ctx->block[(n)] = \
(MD5_u32plus)ptr[(n) * 4] | \
((MD5_u32plus)ptr[(n) * 4 + 1] << 8) | \
((MD5_u32plus)ptr[(n) * 4 + 2] << 16) | \
((MD5_u32plus)ptr[(n) * 4 + 3] << 24))
#define GET(n) \
(ctx->block[(n)])
#endif
/*
* This processes one or more 64-byte data blocks, but does NOT update the bit
* counters. There are no alignment requirements.
*/
static const void *body(MD5_CTX *ctx, const void *data, unsigned long size)
{
const unsigned char *ptr;
MD5_u32plus a, b, c, d;
MD5_u32plus saved_a, saved_b, saved_c, saved_d;
ptr = (const unsigned char *)data;
a = ctx->a;
b = ctx->b;
c = ctx->c;
d = ctx->d;
do {
saved_a = a;
saved_b = b;
saved_c = c;
saved_d = d;
/* Round 1 */
STEP(F, a, b, c, d, SET(0), 0xd76aa478, 7)
STEP(F, d, a, b, c, SET(1), 0xe8c7b756, 12)
STEP(F, c, d, a, b, SET(2), 0x242070db, 17)
STEP(F, b, c, d, a, SET(3), 0xc1bdceee, 22)
STEP(F, a, b, c, d, SET(4), 0xf57c0faf, 7)
STEP(F, d, a, b, c, SET(5), 0x4787c62a, 12)
STEP(F, c, d, a, b, SET(6), 0xa8304613, 17)
STEP(F, b, c, d, a, SET(7), 0xfd469501, 22)
STEP(F, a, b, c, d, SET(8), 0x698098d8, 7)
STEP(F, d, a, b, c, SET(9), 0x8b44f7af, 12)
STEP(F, c, d, a, b, SET(10), 0xffff5bb1, 17)
STEP(F, b, c, d, a, SET(11), 0x895cd7be, 22)
STEP(F, a, b, c, d, SET(12), 0x6b901122, 7)
STEP(F, d, a, b, c, SET(13), 0xfd987193, 12)
STEP(F, c, d, a, b, SET(14), 0xa679438e, 17)
STEP(F, b, c, d, a, SET(15), 0x49b40821, 22)
/* Round 2 */
STEP(G, a, b, c, d, GET(1), 0xf61e2562, 5)
STEP(G, d, a, b, c, GET(6), 0xc040b340, 9)
STEP(G, c, d, a, b, GET(11), 0x265e5a51, 14)
STEP(G, b, c, d, a, GET(0), 0xe9b6c7aa, 20)
STEP(G, a, b, c, d, GET(5), 0xd62f105d, 5)
STEP(G, d, a, b, c, GET(10), 0x02441453, 9)
STEP(G, c, d, a, b, GET(15), 0xd8a1e681, 14)
STEP(G, b, c, d, a, GET(4), 0xe7d3fbc8, 20)
STEP(G, a, b, c, d, GET(9), 0x21e1cde6, 5)
STEP(G, d, a, b, c, GET(14), 0xc33707d6, 9)
STEP(G, c, d, a, b, GET(3), 0xf4d50d87, 14)
STEP(G, b, c, d, a, GET(8), 0x455a14ed, 20)
STEP(G, a, b, c, d, GET(13), 0xa9e3e905, 5)
STEP(G, d, a, b, c, GET(2), 0xfcefa3f8, 9)
STEP(G, c, d, a, b, GET(7), 0x676f02d9, 14)
STEP(G, b, c, d, a, GET(12), 0x8d2a4c8a, 20)
/* Round 3 */
STEP(H, a, b, c, d, GET(5), 0xfffa3942, 4)
STEP(H2, d, a, b, c, GET(8), 0x8771f681, 11)
STEP(H, c, d, a, b, GET(11), 0x6d9d6122, 16)
STEP(H2, b, c, d, a, GET(14), 0xfde5380c, 23)
STEP(H, a, b, c, d, GET(1), 0xa4beea44, 4)
STEP(H2, d, a, b, c, GET(4), 0x4bdecfa9, 11)
STEP(H, c, d, a, b, GET(7), 0xf6bb4b60, 16)
STEP(H2, b, c, d, a, GET(10), 0xbebfbc70, 23)
STEP(H, a, b, c, d, GET(13), 0x289b7ec6, 4)
STEP(H2, d, a, b, c, GET(0), 0xeaa127fa, 11)
STEP(H, c, d, a, b, GET(3), 0xd4ef3085, 16)
STEP(H2, b, c, d, a, GET(6), 0x04881d05, 23)
STEP(H, a, b, c, d, GET(9), 0xd9d4d039, 4)
STEP(H2, d, a, b, c, GET(12), 0xe6db99e5, 11)
STEP(H, c, d, a, b, GET(15), 0x1fa27cf8, 16)
STEP(H2, b, c, d, a, GET(2), 0xc4ac5665, 23)
/* Round 4 */
STEP(I, a, b, c, d, GET(0), 0xf4292244, 6)
STEP(I, d, a, b, c, GET(7), 0x432aff97, 10)
STEP(I, c, d, a, b, GET(14), 0xab9423a7, 15)
STEP(I, b, c, d, a, GET(5), 0xfc93a039, 21)
STEP(I, a, b, c, d, GET(12), 0x655b59c3, 6)
STEP(I, d, a, b, c, GET(3), 0x8f0ccc92, 10)
STEP(I, c, d, a, b, GET(10), 0xffeff47d, 15)
STEP(I, b, c, d, a, GET(1), 0x85845dd1, 21)
STEP(I, a, b, c, d, GET(8), 0x6fa87e4f, 6)
STEP(I, d, a, b, c, GET(15), 0xfe2ce6e0, 10)
STEP(I, c, d, a, b, GET(6), 0xa3014314, 15)
STEP(I, b, c, d, a, GET(13), 0x4e0811a1, 21)
STEP(I, a, b, c, d, GET(4), 0xf7537e82, 6)
STEP(I, d, a, b, c, GET(11), 0xbd3af235, 10)
STEP(I, c, d, a, b, GET(2), 0x2ad7d2bb, 15)
STEP(I, b, c, d, a, GET(9), 0xeb86d391, 21)
a += saved_a;
b += saved_b;
c += saved_c;
d += saved_d;
ptr += 64;
} while (size -= 64);
ctx->a = a;
ctx->b = b;
ctx->c = c;
ctx->d = d;
return ptr;
}
void MD5_Init(MD5_CTX *ctx)
{
ctx->a = 0x67452301;
ctx->b = 0xefcdab89;
ctx->c = 0x98badcfe;
ctx->d = 0x10325476;
ctx->lo = 0;
ctx->hi = 0;
}
void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size)
{
MD5_u32plus saved_lo;
unsigned long used, available;
saved_lo = ctx->lo;
if ((ctx->lo = (saved_lo + size) & 0x1fffffff) < saved_lo)
ctx->hi++;
ctx->hi += size >> 29;
used = saved_lo & 0x3f;
if (used) {
available = 64 - used;
if (size < available) {
memcpy(&ctx->buffer[used], data, size);
return;
}
memcpy(&ctx->buffer[used], data, available);
data = (const unsigned char *)data + available;
size -= available;
body(ctx, ctx->buffer, 64);
}
if (size >= 64) {
data = body(ctx, data, size & ~(unsigned long)0x3f);
size &= 0x3f;
}
memcpy(ctx->buffer, data, size);
}
#define OUT(dst, src) \
(dst)[0] = (unsigned char)(src); \
(dst)[1] = (unsigned char)((src) >> 8); \
(dst)[2] = (unsigned char)((src) >> 16); \
(dst)[3] = (unsigned char)((src) >> 24);
void MD5_Final(unsigned char *result, MD5_CTX *ctx)
{
unsigned long used, available;
used = ctx->lo & 0x3f;
ctx->buffer[used++] = 0x80;
available = 64 - used;
if (available < 8) {
memset(&ctx->buffer[used], 0, available);
body(ctx, ctx->buffer, 64);
used = 0;
available = 64;
}
memset(&ctx->buffer[used], 0, available - 8);
ctx->lo <<= 3;
OUT(&ctx->buffer[56], ctx->lo)
OUT(&ctx->buffer[60], ctx->hi)
body(ctx, ctx->buffer, 64);
OUT(&result[0], ctx->a)
OUT(&result[4], ctx->b)
OUT(&result[8], ctx->c)
OUT(&result[12], ctx->d)
memset(ctx, 0, sizeof(*ctx));
}
#endif
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/base/md5.c
|
C++
|
gpl-3.0
| 8,743
|
/*
* This is an OpenSSL-compatible implementation of the RSA Data Security, Inc.
* MD5 Message-Digest Algorithm (RFC 1321).
*
* Homepage:
* http://openwall.info/wiki/people/solar/software/public-domain-source-code/md5
*
* Author:
* Alexander Peslyak, better known as Solar Designer <solar at openwall.com>
*
* This software was written by Alexander Peslyak in 2001. No copyright is
* claimed, and the software is hereby placed in the public domain.
* In case this attempt to disclaim copyright and place the software in the
* public domain is deemed null and void, then the software is
* Copyright (c) 2001 Alexander Peslyak and it is hereby released to the
* general public under the following terms:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted.
*
* There's ABSOLUTELY NO WARRANTY, express or implied.
*
* See md5.c for more information.
*/
#ifdef HAVE_OPENSSL
#include <openssl/md5.h>
#elif !defined(_MD5_H)
#define _MD5_H
/* Any 32-bit or wider unsigned integer data type will do */
typedef unsigned int MD5_u32plus;
typedef struct {
MD5_u32plus lo, hi;
MD5_u32plus a, b, c, d;
unsigned char buffer[64];
MD5_u32plus block[16];
} MD5_CTX;
extern void MD5_Init(MD5_CTX *ctx);
extern void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size);
extern void MD5_Final(unsigned char *result, MD5_CTX *ctx);
#endif
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/base/md5.h
|
C++
|
gpl-3.0
| 1,410
|
#
# FreeType 2 base layer configuration rules
#
# Copyright (C) 1996-2022 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.
# It sets the following variables which are used by the master Makefile
# after the call:
#
# BASE_OBJ_S: The single-object base layer.
# BASE_OBJ_M: A list of all objects for a multiple-objects build.
# BASE_EXT_OBJ: A list of base layer extensions, i.e., components found
# in `src/base' which are not compiled within the base
# layer proper.
BASE_COMPILE := $(CC) $(ANSIFLAGS) \
$I$(subst /,$(COMPILER_SEP),$(BASE_DIR)) \
$(INCLUDE_FLAGS) \
$(FT_CFLAGS)
# Base layer sources
#
# ftsystem, ftinit, and ftdebug are handled by freetype.mk
#
# All files listed here should be included in `ftbase.c' (for a `single'
# build).
#
BASE_SRC := $(BASE_DIR)/ftadvanc.c \
$(BASE_DIR)/ftcalc.c \
$(BASE_DIR)/ftcolor.c \
$(BASE_DIR)/ftdbgmem.c \
$(BASE_DIR)/fterrors.c \
$(BASE_DIR)/ftfntfmt.c \
$(BASE_DIR)/ftgloadr.c \
$(BASE_DIR)/fthash.c \
$(BASE_DIR)/ftlcdfil.c \
$(BASE_DIR)/ftobjs.c \
$(BASE_DIR)/ftoutln.c \
$(BASE_DIR)/ftpsprop.c \
$(BASE_DIR)/ftrfork.c \
$(BASE_DIR)/ftsnames.c \
$(BASE_DIR)/ftstream.c \
$(BASE_DIR)/fttrigon.c \
$(BASE_DIR)/ftutil.c
ifneq ($(ftmac_c),)
BASE_SRC += $(BASE_DIR)/$(ftmac_c)
endif
# for simplicity, we also handle `md5.c' (which gets included by `ftobjs.h')
BASE_H := $(BASE_DIR)/ftbase.h \
$(BASE_DIR)/md5.c \
$(BASE_DIR)/md5.h
# Base layer `extensions' sources
#
# An extension is added to the library file as a separate object. It is
# then linked to the final executable only if one of its symbols is used by
# the application.
#
BASE_EXT_SRC := $(patsubst %,$(BASE_DIR)/%,$(BASE_EXTENSIONS))
# Default extensions objects
#
BASE_EXT_OBJ := $(BASE_EXT_SRC:$(BASE_DIR)/%.c=$(OBJ_DIR)/%.$O)
# Base layer object(s)
#
# BASE_OBJ_M is used during `multi' builds (each base source file compiles
# to a single object file).
#
# BASE_OBJ_S is used during `single' builds (the whole base layer is
# compiled as a single object file using ftbase.c).
#
BASE_OBJ_M := $(BASE_SRC:$(BASE_DIR)/%.c=$(OBJ_DIR)/%.$O)
BASE_OBJ_S := $(OBJ_DIR)/ftbase.$O
# Base layer root source file for single build
#
BASE_SRC_S := $(BASE_DIR)/ftbase.c
# Base layer - single object build
#
$(BASE_OBJ_S): $(BASE_SRC_S) $(BASE_SRC) $(FREETYPE_H) $(BASE_H)
$(BASE_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $(BASE_SRC_S))
# Multiple objects build + extensions
#
$(OBJ_DIR)/%.$O: $(BASE_DIR)/%.c $(FREETYPE_H) $(BASE_H)
$(BASE_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<)
# EOF
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/base/rules.mk
|
mk
|
gpl-3.0
| 3,222
|
FreeType font driver for BDF fonts
Francesco Zappa Nardelli
<francesco.zappa.nardelli@ens.fr>
Introduction
************
BDF (Bitmap Distribution Format) is a bitmap font format defined by Adobe,
which is intended to be easily understood by both humans and computers.
This code implements a BDF driver for the FreeType library, following the
Adobe Specification V 2.2. The specification of the BDF font format is
available from Adobe's web site:
https://adobe-type-tools.github.io/font-tech-notes/pdfs/5005.BDF_Spec.pdf
Many good bitmap fonts in bdf format come with XFree86 (www.XFree86.org).
They do not define vertical metrics, because the X Consortium BDF
specification has removed them.
Encodings
*********
[This section is out of date, retained for historical reasons. BDF
properties can be retrieved with `FT_Get_BDF_Property`, character set ID
values with `FT_Get_BDF_Charset_ID`.]
The variety of encodings that accompanies bdf fonts appears to encompass the
small set defined in freetype.h. On the other hand, two properties that
specify encoding and registry are usually defined in bdf fonts.
I decided to make these two properties directly accessible, leaving to the
client application the work of interpreting them. For instance:
#include FT_INTERNAL_BDF_TYPES_H
FT_Face face;
BDF_Public_Face bdfface;
FT_New_Face( library, ..., &face );
bdfface = (BDF_Public_Face)face;
if ( ( bdfface->charset_registry == "ISO10646" ) &&
( bdfface->charset_encoding == "1" ) )
[..]
Thus the driver always exports `ft_encoding_none' as face->charmap.encoding.
FT_Get_Char_Index's behavior is unmodified, that is, it converts the ULong
value given as argument into the corresponding glyph number.
If the two properties are not available, Adobe Standard Encoding should be
assumed.
Anti-Aliased Bitmaps
********************
The driver supports an extension to the BDF format as used in Mark Leisher's
xmbdfed bitmap font editor. Microsoft's SBIT tool expects bitmap fonts in
that format for adding anti-aliased them to TrueType fonts. It introduces a
fourth field to the `SIZE' keyword which gives the bpp value (bits per
pixel) of the glyph data in the font. Possible values are 1 (the default),
2 (four gray levels), 4 (16 gray levels), and 8 (256 gray levels). The
driver returns either a bitmap with 1 bit per pixel or a pixmap with 8bits
per pixel (using 4, 16, and 256 gray levels, respectively).
Known problems
**************
- A font is entirely loaded into memory. Obviously, this is not the Right
Thing(TM). If you have big fonts I suggest you convert them into PCF
format (using the bdftopcf utility): the PCF font drive of FreeType can
perform incremental glyph loading.
When I have some time, I will implement on-demand glyph parsing.
- Except for encodings properties, client applications have no visibility of
the PCF_Face object. This means that applications cannot directly access
font tables and must trust FreeType.
- Currently, glyph names are ignored.
I plan to give full visibility of the BDF_Face object in an upcoming
revision of the driver, thus implementing also glyph names.
- As I have never seen a BDF font that defines vertical metrics, vertical
metrics are (parsed and) discarded. If you own a BDF font that defines
vertical metrics, please let me know (I will implement them in 5-10
minutes).
License
*******
Copyright (C) 2001-2002 by Francesco Zappa Nardelli
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
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 AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*** Portions of the driver (that is, bdflib.c and bdf.h):
Copyright 2000 Computing Research Labs, New Mexico State University
Copyright 2001-2002, 2011 Francesco Zappa Nardelli
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
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 AND NONINFRINGEMENT. IN NO EVENT SHALL
THE COMPUTING RESEARCH LAB OR NEW MEXICO STATE UNIVERSITY BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Credits
*******
This driver is based on excellent Mark Leisher's bdf library. If you
find something good in this driver you should probably thank him, not
me.
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/bdf/README
|
none
|
gpl-3.0
| 5,972
|
/* bdf.c
FreeType font driver for bdf files
Copyright (C) 2001, 2002 by
Francesco Zappa Nardelli
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
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 AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#define FT_MAKE_OPTION_SINGLE_OBJECT
#include "bdflib.c"
#include "bdfdrivr.c"
/* END */
|
whupdup/frame
|
real/third_party/freetype-2.12.0/src/bdf/bdf.c
|
C++
|
gpl-3.0
| 1,234
|