1049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project/***************************************************************************/
2049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project/*                                                                         */
3049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project/*  afindic.c                                                              */
4049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project/*                                                                         */
5049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project/*    Auto-fitter hinting routines for Indic scripts (body).               */
6049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project/*                                                                         */
7a2b9955b49034a51dfbc8bf9f4e9d312149cecacXianzhu Wang/*  Copyright 2007, 2011-2013 by                                           */
8049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project/*  Rahul Bhalerao <rahul.bhalerao@redhat.com>, <b.rahul.pm@gmail.com>.    */
9049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project/*                                                                         */
10049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project/*  This file is part of the FreeType project, and may only be used,       */
11049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project/*  modified, and distributed under the terms of the FreeType project      */
12049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
13049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project/*  this file you indicate that you have read the license and              */
14049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project/*  understand and accept it fully.                                        */
15049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project/*                                                                         */
16049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project/***************************************************************************/
17049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project
18049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project
19049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#include "aftypes.h"
20049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#include "aflatin.h"
21049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project
22049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project
23049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#ifdef AF_CONFIG_OPTION_INDIC
24049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project
25049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#include "afindic.h"
26049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#include "aferrors.h"
27049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#include "afcjk.h"
28049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project
29049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project
30c3ee10bfa1f76a18500b487de9c85757375b48f3David 'Digit' Turner#ifdef AF_CONFIG_OPTION_USE_WARPER
31049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#include "afwarp.h"
32049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#endif
33049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project
34049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project
35049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project  static FT_Error
36c3ee10bfa1f76a18500b487de9c85757375b48f3David 'Digit' Turner  af_indic_metrics_init( AF_CJKMetrics  metrics,
37c3ee10bfa1f76a18500b487de9c85757375b48f3David 'Digit' Turner                         FT_Face        face )
38049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project  {
39c3ee10bfa1f76a18500b487de9c85757375b48f3David 'Digit' Turner    /* skip blue zone init in CJK routines */
40c3ee10bfa1f76a18500b487de9c85757375b48f3David 'Digit' Turner    FT_CharMap  oldmap = face->charmap;
41c3ee10bfa1f76a18500b487de9c85757375b48f3David 'Digit' Turner
42c3ee10bfa1f76a18500b487de9c85757375b48f3David 'Digit' Turner
43c3ee10bfa1f76a18500b487de9c85757375b48f3David 'Digit' Turner    metrics->units_per_em = face->units_per_EM;
44c3ee10bfa1f76a18500b487de9c85757375b48f3David 'Digit' Turner
45c3ee10bfa1f76a18500b487de9c85757375b48f3David 'Digit' Turner    if ( FT_Select_Charmap( face, FT_ENCODING_UNICODE ) )
46c3ee10bfa1f76a18500b487de9c85757375b48f3David 'Digit' Turner      face->charmap = NULL;
47c3ee10bfa1f76a18500b487de9c85757375b48f3David 'Digit' Turner    else
48c3ee10bfa1f76a18500b487de9c85757375b48f3David 'Digit' Turner    {
49a2b9955b49034a51dfbc8bf9f4e9d312149cecacXianzhu Wang      af_cjk_metrics_init_widths( metrics, face );
50c3ee10bfa1f76a18500b487de9c85757375b48f3David 'Digit' Turner#if 0
51c3ee10bfa1f76a18500b487de9c85757375b48f3David 'Digit' Turner      /* either need indic specific blue_chars[] or just skip blue zones */
52c3ee10bfa1f76a18500b487de9c85757375b48f3David 'Digit' Turner      af_cjk_metrics_init_blues( metrics, face, af_cjk_blue_chars );
53c3ee10bfa1f76a18500b487de9c85757375b48f3David 'Digit' Turner#endif
54c3ee10bfa1f76a18500b487de9c85757375b48f3David 'Digit' Turner      af_cjk_metrics_check_digits( metrics, face );
55c3ee10bfa1f76a18500b487de9c85757375b48f3David 'Digit' Turner    }
56c3ee10bfa1f76a18500b487de9c85757375b48f3David 'Digit' Turner
57c3ee10bfa1f76a18500b487de9c85757375b48f3David 'Digit' Turner    FT_Set_Charmap( face, oldmap );
58c3ee10bfa1f76a18500b487de9c85757375b48f3David 'Digit' Turner
59a2b9955b49034a51dfbc8bf9f4e9d312149cecacXianzhu Wang    return FT_Err_Ok;
60049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project  }
61049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project
62049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project
63049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project  static void
64c3ee10bfa1f76a18500b487de9c85757375b48f3David 'Digit' Turner  af_indic_metrics_scale( AF_CJKMetrics  metrics,
65c3ee10bfa1f76a18500b487de9c85757375b48f3David 'Digit' Turner                          AF_Scaler      scaler )
66049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project  {
67049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project    /* use CJK routines */
68049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project    af_cjk_metrics_scale( metrics, scaler );
69049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project  }
70049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project
71049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project
72049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project  static FT_Error
73c3ee10bfa1f76a18500b487de9c85757375b48f3David 'Digit' Turner  af_indic_hints_init( AF_GlyphHints  hints,
74c3ee10bfa1f76a18500b487de9c85757375b48f3David 'Digit' Turner                       AF_CJKMetrics  metrics )
75049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project  {
76049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project    /* use CJK routines */
77049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project    return af_cjk_hints_init( hints, metrics );
78049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project  }
79049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project
80049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project
81049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project  static FT_Error
82c3ee10bfa1f76a18500b487de9c85757375b48f3David 'Digit' Turner  af_indic_hints_apply( AF_GlyphHints  hints,
83c3ee10bfa1f76a18500b487de9c85757375b48f3David 'Digit' Turner                        FT_Outline*    outline,
84c3ee10bfa1f76a18500b487de9c85757375b48f3David 'Digit' Turner                        AF_CJKMetrics  metrics )
85049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project  {
86049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project    /* use CJK routines */
87049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project    return af_cjk_hints_apply( hints, outline, metrics );
88049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project  }
89049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project
90049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project
91049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project  /*************************************************************************/
92049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project  /*************************************************************************/
93049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project  /*****                                                               *****/
94049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project  /*****                I N D I C   S C R I P T   C L A S S            *****/
95049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project  /*****                                                               *****/
96049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project  /*************************************************************************/
97049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project  /*************************************************************************/
98049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project
99049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project
100049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project  static const AF_Script_UniRangeRec  af_indic_uniranges[] =
101049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project  {
102049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#if 0
103295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner    AF_UNIRANGE_REC( 0x0100UL, 0xFFFFUL ),  /* why this? */
104049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#endif
105295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner    AF_UNIRANGE_REC( 0x0900UL, 0x0DFFUL),    /* Indic Range */
106c3ee10bfa1f76a18500b487de9c85757375b48f3David 'Digit' Turner    AF_UNIRANGE_REC( 0x0F00UL, 0x0FFFUL),    /* Tibetan */
107c3ee10bfa1f76a18500b487de9c85757375b48f3David 'Digit' Turner    AF_UNIRANGE_REC( 0x1900UL, 0x194FUL),    /* Limbu */
108c3ee10bfa1f76a18500b487de9c85757375b48f3David 'Digit' Turner    AF_UNIRANGE_REC( 0x1B80UL, 0x1BBFUL),    /* Sundanese */
109c3ee10bfa1f76a18500b487de9c85757375b48f3David 'Digit' Turner    AF_UNIRANGE_REC( 0x1C80UL, 0x1CDFUL),    /* Meetei Mayak */
110c3ee10bfa1f76a18500b487de9c85757375b48f3David 'Digit' Turner    AF_UNIRANGE_REC( 0xA800UL, 0xA82FUL),    /* Syloti Nagri */
111c3ee10bfa1f76a18500b487de9c85757375b48f3David 'Digit' Turner    AF_UNIRANGE_REC( 0x11800UL, 0x118DFUL),  /* Sharada */
112295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner    AF_UNIRANGE_REC(      0UL,      0UL)
113049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project  };
114049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project
115049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project
116e3b631da8034f7c6ecc6d809cd9e46d306215c32Xianzhu Wang  AF_DEFINE_SCRIPT_CLASS( af_indic_script_class,
117049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project    AF_SCRIPT_INDIC,
118049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project    af_indic_uniranges,
119a2b9955b49034a51dfbc8bf9f4e9d312149cecacXianzhu Wang    'o', /* XXX */
120049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project
121e3b631da8034f7c6ecc6d809cd9e46d306215c32Xianzhu Wang    sizeof ( AF_CJKMetricsRec ),
122049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project
123049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project    (AF_Script_InitMetricsFunc) af_indic_metrics_init,
124049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project    (AF_Script_ScaleMetricsFunc)af_indic_metrics_scale,
125049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project    (AF_Script_DoneMetricsFunc) NULL,
126049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project
127049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project    (AF_Script_InitHintsFunc)   af_indic_hints_init,
128049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project    (AF_Script_ApplyHintsFunc)  af_indic_hints_apply
129295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner  )
130049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project
131049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#else /* !AF_CONFIG_OPTION_INDIC */
132049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project
133049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project  static const AF_Script_UniRangeRec  af_indic_uniranges[] =
134049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project  {
135049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project    { 0, 0 }
136049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project  };
137049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project
138049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project
139e3b631da8034f7c6ecc6d809cd9e46d306215c32Xianzhu Wang  AF_DEFINE_SCRIPT_CLASS( af_indic_script_class,
140049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project    AF_SCRIPT_INDIC,
141049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project    af_indic_uniranges,
142a2b9955b49034a51dfbc8bf9f4e9d312149cecacXianzhu Wang    0,
143049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project
144e3b631da8034f7c6ecc6d809cd9e46d306215c32Xianzhu Wang    sizeof ( AF_CJKMetricsRec ),
145049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project
146049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project    (AF_Script_InitMetricsFunc) NULL,
147049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project    (AF_Script_ScaleMetricsFunc)NULL,
148049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project    (AF_Script_DoneMetricsFunc) NULL,
149049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project
150049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project    (AF_Script_InitHintsFunc)   NULL,
151049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project    (AF_Script_ApplyHintsFunc)  NULL
152295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner  )
153049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project
154049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#endif /* !AF_CONFIG_OPTION_INDIC */
155049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project
156049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project
157049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project/* END */
158