[truetype, snft] Add service methods for `DeltaSetIdxMap` and `VarStore`.
This will be needed for 'COLR' v1 variation support.
* src/truetype/ttgxvar.h (GX_ItemVarData, GX_AxisCoords, GX_VarRegion,
GX_VarItemStore, GX_DeltaSetIdxMap): Move structures to...
* include/freetype/internal/ftmmtypes.h: ... this new file.
* include/freetype/internal/service/svmm.h (MultiMasters): Include
`ftmmtypes.h`.
(FT_Var_Load_Delta_Set_Idx_Map_Func, FT_Var_Load_Item_Var_Store_Func,
FT_Var_Get_Item_Delta_Func, FT_Var_Done_Item_Var_Store_Func,
FT_Var_Done_Delta_Set_Idx_Map_Func): New function typedefs.
(MultiMasters): Add them.
(FT_DEFINE_SERVICE_MULTIMASTERSREC): Updated.
* src/cff/cffdrivr.c (cff_load_item_variation_store,
cff_load_delta_set_index_mapping, cff_get_item_delta,
cff_done_item_variation_store, cff_done_delta_set_index_map): New wrapper
methods calling into mm service.
(cff_service_multi_masters): Updated.
* src/truetype/ttgxvar.c (ft_var_load_item_variation_store,
ft_var_load_delta_set_index_mapping, ft_var_get_item_delta,
ft_var_done_item_variation_store, ft_var_done_delta_set_index_map): Renamed
to ...
(tt_var_load_item_variation_store, tt_var_load_delta_set_index_mapping,
tt_var_get_item_delta, tt_var_done_item_variation_store,
tt_var_done_delta_set_index_map): ... this for consistency.
Mark them as non-static.
* src/truetype/ttgxvar.h: Add corresponding prototypes.
* src/truetype/ttdriver.c (tt_service_gx_multi_masters): Updated.
* src/type1/t1driver.c (t1_service_multi_masters): Updated.
2022-05-19 06:30:47 +02:00
|
|
|
/****************************************************************************
|
|
|
|
*
|
|
|
|
* ftmmtypes.h
|
|
|
|
*
|
|
|
|
* OpenType Variations type definitions for internal use
|
|
|
|
* with the multi-masters service (specification).
|
|
|
|
*
|
2023-01-17 09:18:25 +01:00
|
|
|
* Copyright (C) 2022-2023 by
|
[truetype, snft] Add service methods for `DeltaSetIdxMap` and `VarStore`.
This will be needed for 'COLR' v1 variation support.
* src/truetype/ttgxvar.h (GX_ItemVarData, GX_AxisCoords, GX_VarRegion,
GX_VarItemStore, GX_DeltaSetIdxMap): Move structures to...
* include/freetype/internal/ftmmtypes.h: ... this new file.
* include/freetype/internal/service/svmm.h (MultiMasters): Include
`ftmmtypes.h`.
(FT_Var_Load_Delta_Set_Idx_Map_Func, FT_Var_Load_Item_Var_Store_Func,
FT_Var_Get_Item_Delta_Func, FT_Var_Done_Item_Var_Store_Func,
FT_Var_Done_Delta_Set_Idx_Map_Func): New function typedefs.
(MultiMasters): Add them.
(FT_DEFINE_SERVICE_MULTIMASTERSREC): Updated.
* src/cff/cffdrivr.c (cff_load_item_variation_store,
cff_load_delta_set_index_mapping, cff_get_item_delta,
cff_done_item_variation_store, cff_done_delta_set_index_map): New wrapper
methods calling into mm service.
(cff_service_multi_masters): Updated.
* src/truetype/ttgxvar.c (ft_var_load_item_variation_store,
ft_var_load_delta_set_index_mapping, ft_var_get_item_delta,
ft_var_done_item_variation_store, ft_var_done_delta_set_index_map): Renamed
to ...
(tt_var_load_item_variation_store, tt_var_load_delta_set_index_mapping,
tt_var_get_item_delta, tt_var_done_item_variation_store,
tt_var_done_delta_set_index_map): ... this for consistency.
Mark them as non-static.
* src/truetype/ttgxvar.h: Add corresponding prototypes.
* src/truetype/ttdriver.c (tt_service_gx_multi_masters): Updated.
* src/type1/t1driver.c (t1_service_multi_masters): Updated.
2022-05-19 06:30:47 +02:00
|
|
|
* David Turner, Robert Wilhelm, Werner Lemberg, George Williams, and
|
|
|
|
* Dominik Röttsches.
|
|
|
|
*
|
|
|
|
* 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 FTMMTYPES_H_
|
|
|
|
#define FTMMTYPES_H_
|
|
|
|
|
|
|
|
FT_BEGIN_HEADER
|
|
|
|
|
|
|
|
|
2022-06-29 10:48:53 +02:00
|
|
|
typedef FT_Int32 FT_ItemVarDelta;
|
2022-05-20 16:22:25 +02:00
|
|
|
|
[truetype, snft] Add service methods for `DeltaSetIdxMap` and `VarStore`.
This will be needed for 'COLR' v1 variation support.
* src/truetype/ttgxvar.h (GX_ItemVarData, GX_AxisCoords, GX_VarRegion,
GX_VarItemStore, GX_DeltaSetIdxMap): Move structures to...
* include/freetype/internal/ftmmtypes.h: ... this new file.
* include/freetype/internal/service/svmm.h (MultiMasters): Include
`ftmmtypes.h`.
(FT_Var_Load_Delta_Set_Idx_Map_Func, FT_Var_Load_Item_Var_Store_Func,
FT_Var_Get_Item_Delta_Func, FT_Var_Done_Item_Var_Store_Func,
FT_Var_Done_Delta_Set_Idx_Map_Func): New function typedefs.
(MultiMasters): Add them.
(FT_DEFINE_SERVICE_MULTIMASTERSREC): Updated.
* src/cff/cffdrivr.c (cff_load_item_variation_store,
cff_load_delta_set_index_mapping, cff_get_item_delta,
cff_done_item_variation_store, cff_done_delta_set_index_map): New wrapper
methods calling into mm service.
(cff_service_multi_masters): Updated.
* src/truetype/ttgxvar.c (ft_var_load_item_variation_store,
ft_var_load_delta_set_index_mapping, ft_var_get_item_delta,
ft_var_done_item_variation_store, ft_var_done_delta_set_index_map): Renamed
to ...
(tt_var_load_item_variation_store, tt_var_load_delta_set_index_mapping,
tt_var_get_item_delta, tt_var_done_item_variation_store,
tt_var_done_delta_set_index_map): ... this for consistency.
Mark them as non-static.
* src/truetype/ttgxvar.h: Add corresponding prototypes.
* src/truetype/ttdriver.c (tt_service_gx_multi_masters): Updated.
* src/type1/t1driver.c (t1_service_multi_masters): Updated.
2022-05-19 06:30:47 +02:00
|
|
|
typedef struct GX_ItemVarDataRec_
|
|
|
|
{
|
[truetype] Reduce heap allocation of `deltaSet` variation data.
`deltaSet` is an array of packed integers that can be 32 bits, 16 bits, or
8 bits. Before this change, these values were unpacked to 32-bit integers.
However, this can cause big heap allocations, e.g., around 500 KByte for
'NotoSansCJK'. To reduce this amount, store the packed integers and unpack
them just before passing to the calculation. At calculation time, due to
the variable length of region indices, temporary heap allocations are
necessary. This heap allocation is not negligible and visible in `ftbench`
results. So, use stack-allocated arrays for short array calculations.
Fixes #1230.
* include/freetype/internal/ftmmtypes.h (GX_ItemVarDataRec): New fields
`wordDeltaCount` and `longWords`.
* src/truetype/ttgxvar.c (tt_var_load_item_variation_store): Load packed
data.
(tt_var_get_item_delta): Unpack data before applying.
2023-05-19 05:11:45 +02:00
|
|
|
FT_UInt itemCount; /* Number of delta sets per item. */
|
|
|
|
FT_UInt regionIdxCount; /* Number of region indices. */
|
|
|
|
FT_UInt* regionIndices; /* Array of `regionCount` indices; */
|
|
|
|
/* these index `varRegionList`. */
|
|
|
|
FT_Byte* deltaSet; /* Array of `itemCount` deltas; */
|
|
|
|
/* use `innerIndex` for this array. */
|
|
|
|
FT_UShort wordDeltaCount; /* Number of the first 32-bit ints */
|
|
|
|
/* or 16-bit ints of `deltaSet` */
|
|
|
|
/* depending on `longWords`. */
|
|
|
|
FT_Bool longWords; /* If true, `deltaSet` is a 32-bit */
|
|
|
|
/* array followed by a 16-bit */
|
|
|
|
/* array, otherwise a 16-bit array */
|
|
|
|
/* followed by an 8-bit array. */
|
[truetype, snft] Add service methods for `DeltaSetIdxMap` and `VarStore`.
This will be needed for 'COLR' v1 variation support.
* src/truetype/ttgxvar.h (GX_ItemVarData, GX_AxisCoords, GX_VarRegion,
GX_VarItemStore, GX_DeltaSetIdxMap): Move structures to...
* include/freetype/internal/ftmmtypes.h: ... this new file.
* include/freetype/internal/service/svmm.h (MultiMasters): Include
`ftmmtypes.h`.
(FT_Var_Load_Delta_Set_Idx_Map_Func, FT_Var_Load_Item_Var_Store_Func,
FT_Var_Get_Item_Delta_Func, FT_Var_Done_Item_Var_Store_Func,
FT_Var_Done_Delta_Set_Idx_Map_Func): New function typedefs.
(MultiMasters): Add them.
(FT_DEFINE_SERVICE_MULTIMASTERSREC): Updated.
* src/cff/cffdrivr.c (cff_load_item_variation_store,
cff_load_delta_set_index_mapping, cff_get_item_delta,
cff_done_item_variation_store, cff_done_delta_set_index_map): New wrapper
methods calling into mm service.
(cff_service_multi_masters): Updated.
* src/truetype/ttgxvar.c (ft_var_load_item_variation_store,
ft_var_load_delta_set_index_mapping, ft_var_get_item_delta,
ft_var_done_item_variation_store, ft_var_done_delta_set_index_map): Renamed
to ...
(tt_var_load_item_variation_store, tt_var_load_delta_set_index_mapping,
tt_var_get_item_delta, tt_var_done_item_variation_store,
tt_var_done_delta_set_index_map): ... this for consistency.
Mark them as non-static.
* src/truetype/ttgxvar.h: Add corresponding prototypes.
* src/truetype/ttdriver.c (tt_service_gx_multi_masters): Updated.
* src/type1/t1driver.c (t1_service_multi_masters): Updated.
2022-05-19 06:30:47 +02:00
|
|
|
} GX_ItemVarDataRec, *GX_ItemVarData;
|
|
|
|
|
|
|
|
|
|
|
|
/* contribution of one axis to a region */
|
|
|
|
typedef struct GX_AxisCoordsRec_
|
|
|
|
{
|
|
|
|
FT_Fixed startCoord;
|
|
|
|
FT_Fixed peakCoord; /* zero means no effect (factor = 1) */
|
|
|
|
FT_Fixed endCoord;
|
|
|
|
|
|
|
|
} GX_AxisCoordsRec, *GX_AxisCoords;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct GX_VarRegionRec_
|
|
|
|
{
|
|
|
|
GX_AxisCoords axisList; /* array of axisCount records */
|
|
|
|
|
|
|
|
} GX_VarRegionRec, *GX_VarRegion;
|
|
|
|
|
|
|
|
|
|
|
|
/* item variation store */
|
|
|
|
typedef struct GX_ItemVarStoreRec_
|
|
|
|
{
|
|
|
|
FT_UInt dataCount;
|
|
|
|
GX_ItemVarData varData; /* array of dataCount records; */
|
|
|
|
/* use `outerIndex' for this array */
|
|
|
|
FT_UShort axisCount;
|
|
|
|
FT_UInt regionCount; /* total number of regions defined */
|
|
|
|
GX_VarRegion varRegionList;
|
|
|
|
|
|
|
|
} GX_ItemVarStoreRec, *GX_ItemVarStore;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct GX_DeltaSetIdxMapRec_
|
|
|
|
{
|
|
|
|
FT_ULong mapCount;
|
|
|
|
FT_UInt* outerIndex; /* indices to item var data */
|
|
|
|
FT_UInt* innerIndex; /* indices to delta set */
|
|
|
|
|
|
|
|
} GX_DeltaSetIdxMapRec, *GX_DeltaSetIdxMap;
|
|
|
|
|
|
|
|
|
|
|
|
FT_END_HEADER
|
|
|
|
|
|
|
|
#endif /* FTMMTYPES_H_ */
|
|
|
|
|
|
|
|
|
|
|
|
/* END */
|