| 1 | /**************************************************************************** |
| 2 | * |
| 3 | * afindic.c |
| 4 | * |
| 5 | * Auto-fitter hinting routines for Indic writing system (body). |
| 6 | * |
| 7 | * Copyright (C) 2007-2023 by |
| 8 | * Rahul Bhalerao <rahul.bhalerao@redhat.com>, <b.rahul.pm@gmail.com>. |
| 9 | * |
| 10 | * This file is part of the FreeType project, and may only be used, |
| 11 | * modified, and distributed under the terms of the FreeType project |
| 12 | * license, LICENSE.TXT. By continuing to use, modify, or distribute |
| 13 | * this file you indicate that you have read the license and |
| 14 | * understand and accept it fully. |
| 15 | * |
| 16 | */ |
| 17 | |
| 18 | |
| 19 | #include "aftypes.h" |
| 20 | #include "aflatin.h" |
| 21 | #include "afcjk.h" |
| 22 | |
| 23 | |
| 24 | #ifdef AF_CONFIG_OPTION_INDIC |
| 25 | |
| 26 | #include "afindic.h" |
| 27 | #include "aferrors.h" |
| 28 | |
| 29 | |
| 30 | static FT_Error |
| 31 | af_indic_metrics_init( AF_StyleMetrics metrics_, /* AF_CJKMetrics */ |
| 32 | FT_Face face ) |
| 33 | { |
| 34 | AF_CJKMetrics metrics = (AF_CJKMetrics)metrics_; |
| 35 | |
| 36 | |
| 37 | /* skip blue zone init in CJK routines */ |
| 38 | FT_CharMap oldmap = face->charmap; |
| 39 | |
| 40 | |
| 41 | metrics->units_per_em = face->units_per_EM; |
| 42 | |
| 43 | if ( FT_Select_Charmap( face, FT_ENCODING_UNICODE ) ) |
| 44 | face->charmap = NULL; |
| 45 | else |
| 46 | { |
| 47 | af_cjk_metrics_init_widths( metrics, face ); |
| 48 | #if 0 |
| 49 | /* either need indic specific blue_chars[] or just skip blue zones */ |
| 50 | af_cjk_metrics_init_blues( metrics, face, af_cjk_blue_chars ); |
| 51 | #endif |
| 52 | af_cjk_metrics_check_digits( metrics, face ); |
| 53 | } |
| 54 | |
| 55 | face->charmap = oldmap; |
| 56 | return FT_Err_Ok; |
| 57 | } |
| 58 | |
| 59 | |
| 60 | static void |
| 61 | af_indic_metrics_scale( AF_StyleMetrics metrics, |
| 62 | AF_Scaler scaler ) |
| 63 | { |
| 64 | /* use CJK routines */ |
| 65 | af_cjk_metrics_scale( metrics, scaler ); |
| 66 | } |
| 67 | |
| 68 | |
| 69 | static FT_Error |
| 70 | af_indic_hints_init( AF_GlyphHints hints, |
| 71 | AF_StyleMetrics metrics ) |
| 72 | { |
| 73 | /* use CJK routines */ |
| 74 | return af_cjk_hints_init( hints, metrics ); |
| 75 | } |
| 76 | |
| 77 | |
| 78 | static FT_Error |
| 79 | af_indic_hints_apply( FT_UInt glyph_index, |
| 80 | AF_GlyphHints hints, |
| 81 | FT_Outline* outline, |
| 82 | AF_StyleMetrics metrics ) |
| 83 | { |
| 84 | /* use CJK routines */ |
| 85 | return af_cjk_hints_apply( glyph_index, hints, outline, metrics ); |
| 86 | } |
| 87 | |
| 88 | |
| 89 | /* Extract standard_width from writing system/script specific */ |
| 90 | /* metrics class. */ |
| 91 | |
| 92 | static void |
| 93 | af_indic_get_standard_widths( AF_StyleMetrics metrics_, /* AF_CJKMetrics */ |
| 94 | FT_Pos* stdHW, |
| 95 | FT_Pos* stdVW ) |
| 96 | { |
| 97 | AF_CJKMetrics metrics = (AF_CJKMetrics)metrics_; |
| 98 | |
| 99 | |
| 100 | if ( stdHW ) |
| 101 | *stdHW = metrics->axis[AF_DIMENSION_VERT].standard_width; |
| 102 | |
| 103 | if ( stdVW ) |
| 104 | *stdVW = metrics->axis[AF_DIMENSION_HORZ].standard_width; |
| 105 | } |
| 106 | |
| 107 | |
| 108 | /*************************************************************************/ |
| 109 | /*************************************************************************/ |
| 110 | /***** *****/ |
| 111 | /***** I N D I C S C R I P T C L A S S *****/ |
| 112 | /***** *****/ |
| 113 | /*************************************************************************/ |
| 114 | /*************************************************************************/ |
| 115 | |
| 116 | |
| 117 | AF_DEFINE_WRITING_SYSTEM_CLASS( |
| 118 | af_indic_writing_system_class, |
| 119 | |
| 120 | AF_WRITING_SYSTEM_INDIC, |
| 121 | |
| 122 | sizeof ( AF_CJKMetricsRec ), |
| 123 | |
| 124 | (AF_WritingSystem_InitMetricsFunc) af_indic_metrics_init, /* style_metrics_init */ |
| 125 | (AF_WritingSystem_ScaleMetricsFunc)af_indic_metrics_scale, /* style_metrics_scale */ |
| 126 | (AF_WritingSystem_DoneMetricsFunc) NULL, /* style_metrics_done */ |
| 127 | (AF_WritingSystem_GetStdWidthsFunc)af_indic_get_standard_widths, /* style_metrics_getstdw */ |
| 128 | |
| 129 | (AF_WritingSystem_InitHintsFunc) af_indic_hints_init, /* style_hints_init */ |
| 130 | (AF_WritingSystem_ApplyHintsFunc) af_indic_hints_apply /* style_hints_apply */ |
| 131 | ) |
| 132 | |
| 133 | |
| 134 | #else /* !AF_CONFIG_OPTION_INDIC */ |
| 135 | |
| 136 | |
| 137 | AF_DEFINE_WRITING_SYSTEM_CLASS( |
| 138 | af_indic_writing_system_class, |
| 139 | |
| 140 | AF_WRITING_SYSTEM_INDIC, |
| 141 | |
| 142 | sizeof ( AF_CJKMetricsRec ), |
| 143 | |
| 144 | (AF_WritingSystem_InitMetricsFunc) NULL, /* style_metrics_init */ |
| 145 | (AF_WritingSystem_ScaleMetricsFunc)NULL, /* style_metrics_scale */ |
| 146 | (AF_WritingSystem_DoneMetricsFunc) NULL, /* style_metrics_done */ |
| 147 | (AF_WritingSystem_GetStdWidthsFunc)NULL, /* style_metrics_getstdw */ |
| 148 | |
| 149 | (AF_WritingSystem_InitHintsFunc) NULL, /* style_hints_init */ |
| 150 | (AF_WritingSystem_ApplyHintsFunc) NULL /* style_hints_apply */ |
| 151 | ) |
| 152 | |
| 153 | |
| 154 | #endif /* !AF_CONFIG_OPTION_INDIC */ |
| 155 | |
| 156 | |
| 157 | /* END */ |
| 158 | |