Branch
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
/****************************************************************************
*
* afindic.c
*
* Auto-fitter hinting routines for Indic writing system (body).
*
* Copyright (C) 2007-2023 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_StyleMetrics metrics_, /* AF_CJKMetrics */
FT_Face face )
{
AF_CJKMetrics metrics = (AF_CJKMetrics)metrics_;
/* 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 );
}
face->charmap = oldmap;
return FT_Err_Ok;
}
static void
af_indic_metrics_scale( AF_StyleMetrics metrics,
AF_Scaler scaler )
{
/* use CJK routines */
af_cjk_metrics_scale( metrics, scaler );
}
static FT_Error
af_indic_hints_init( AF_GlyphHints hints,
AF_StyleMetrics 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_StyleMetrics 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_StyleMetrics metrics_, /* AF_CJKMetrics */
FT_Pos* stdHW,
FT_Pos* stdVW )
{
AF_CJKMetrics metrics = (AF_CJKMetrics)metrics_;
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 */