1*2d1272b8SAndroid Build Coastguard Worker /*
2*2d1272b8SAndroid Build Coastguard Worker * Copyright © 2011 Google, Inc.
3*2d1272b8SAndroid Build Coastguard Worker *
4*2d1272b8SAndroid Build Coastguard Worker * This is part of HarfBuzz, a text shaping library.
5*2d1272b8SAndroid Build Coastguard Worker *
6*2d1272b8SAndroid Build Coastguard Worker * Permission is hereby granted, without written agreement and without
7*2d1272b8SAndroid Build Coastguard Worker * license or royalty fees, to use, copy, modify, and distribute this
8*2d1272b8SAndroid Build Coastguard Worker * software and its documentation for any purpose, provided that the
9*2d1272b8SAndroid Build Coastguard Worker * above copyright notice and the following two paragraphs appear in
10*2d1272b8SAndroid Build Coastguard Worker * all copies of this software.
11*2d1272b8SAndroid Build Coastguard Worker *
12*2d1272b8SAndroid Build Coastguard Worker * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
13*2d1272b8SAndroid Build Coastguard Worker * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
14*2d1272b8SAndroid Build Coastguard Worker * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
15*2d1272b8SAndroid Build Coastguard Worker * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
16*2d1272b8SAndroid Build Coastguard Worker * DAMAGE.
17*2d1272b8SAndroid Build Coastguard Worker *
18*2d1272b8SAndroid Build Coastguard Worker * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
19*2d1272b8SAndroid Build Coastguard Worker * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20*2d1272b8SAndroid Build Coastguard Worker * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
21*2d1272b8SAndroid Build Coastguard Worker * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
22*2d1272b8SAndroid Build Coastguard Worker * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
23*2d1272b8SAndroid Build Coastguard Worker *
24*2d1272b8SAndroid Build Coastguard Worker * Google Author(s): Behdad Esfahbod
25*2d1272b8SAndroid Build Coastguard Worker */
26*2d1272b8SAndroid Build Coastguard Worker
27*2d1272b8SAndroid Build Coastguard Worker #include "hb-shaper-impl.hh"
28*2d1272b8SAndroid Build Coastguard Worker
29*2d1272b8SAndroid Build Coastguard Worker #ifndef HB_NO_FALLBACK_SHAPE
30*2d1272b8SAndroid Build Coastguard Worker
31*2d1272b8SAndroid Build Coastguard Worker /*
32*2d1272b8SAndroid Build Coastguard Worker * shaper face data
33*2d1272b8SAndroid Build Coastguard Worker */
34*2d1272b8SAndroid Build Coastguard Worker
35*2d1272b8SAndroid Build Coastguard Worker struct hb_fallback_face_data_t {};
36*2d1272b8SAndroid Build Coastguard Worker
37*2d1272b8SAndroid Build Coastguard Worker hb_fallback_face_data_t *
_hb_fallback_shaper_face_data_create(hb_face_t * face HB_UNUSED)38*2d1272b8SAndroid Build Coastguard Worker _hb_fallback_shaper_face_data_create (hb_face_t *face HB_UNUSED)
39*2d1272b8SAndroid Build Coastguard Worker {
40*2d1272b8SAndroid Build Coastguard Worker return (hb_fallback_face_data_t *) HB_SHAPER_DATA_SUCCEEDED;
41*2d1272b8SAndroid Build Coastguard Worker }
42*2d1272b8SAndroid Build Coastguard Worker
43*2d1272b8SAndroid Build Coastguard Worker void
_hb_fallback_shaper_face_data_destroy(hb_fallback_face_data_t * data HB_UNUSED)44*2d1272b8SAndroid Build Coastguard Worker _hb_fallback_shaper_face_data_destroy (hb_fallback_face_data_t *data HB_UNUSED)
45*2d1272b8SAndroid Build Coastguard Worker {
46*2d1272b8SAndroid Build Coastguard Worker }
47*2d1272b8SAndroid Build Coastguard Worker
48*2d1272b8SAndroid Build Coastguard Worker
49*2d1272b8SAndroid Build Coastguard Worker /*
50*2d1272b8SAndroid Build Coastguard Worker * shaper font data
51*2d1272b8SAndroid Build Coastguard Worker */
52*2d1272b8SAndroid Build Coastguard Worker
53*2d1272b8SAndroid Build Coastguard Worker struct hb_fallback_font_data_t {};
54*2d1272b8SAndroid Build Coastguard Worker
55*2d1272b8SAndroid Build Coastguard Worker hb_fallback_font_data_t *
_hb_fallback_shaper_font_data_create(hb_font_t * font HB_UNUSED)56*2d1272b8SAndroid Build Coastguard Worker _hb_fallback_shaper_font_data_create (hb_font_t *font HB_UNUSED)
57*2d1272b8SAndroid Build Coastguard Worker {
58*2d1272b8SAndroid Build Coastguard Worker return (hb_fallback_font_data_t *) HB_SHAPER_DATA_SUCCEEDED;
59*2d1272b8SAndroid Build Coastguard Worker }
60*2d1272b8SAndroid Build Coastguard Worker
61*2d1272b8SAndroid Build Coastguard Worker void
_hb_fallback_shaper_font_data_destroy(hb_fallback_font_data_t * data HB_UNUSED)62*2d1272b8SAndroid Build Coastguard Worker _hb_fallback_shaper_font_data_destroy (hb_fallback_font_data_t *data HB_UNUSED)
63*2d1272b8SAndroid Build Coastguard Worker {
64*2d1272b8SAndroid Build Coastguard Worker }
65*2d1272b8SAndroid Build Coastguard Worker
66*2d1272b8SAndroid Build Coastguard Worker
67*2d1272b8SAndroid Build Coastguard Worker /*
68*2d1272b8SAndroid Build Coastguard Worker * shaper
69*2d1272b8SAndroid Build Coastguard Worker */
70*2d1272b8SAndroid Build Coastguard Worker
71*2d1272b8SAndroid Build Coastguard Worker hb_bool_t
_hb_fallback_shape(hb_shape_plan_t * shape_plan HB_UNUSED,hb_font_t * font,hb_buffer_t * buffer,const hb_feature_t * features HB_UNUSED,unsigned int num_features HB_UNUSED)72*2d1272b8SAndroid Build Coastguard Worker _hb_fallback_shape (hb_shape_plan_t *shape_plan HB_UNUSED,
73*2d1272b8SAndroid Build Coastguard Worker hb_font_t *font,
74*2d1272b8SAndroid Build Coastguard Worker hb_buffer_t *buffer,
75*2d1272b8SAndroid Build Coastguard Worker const hb_feature_t *features HB_UNUSED,
76*2d1272b8SAndroid Build Coastguard Worker unsigned int num_features HB_UNUSED)
77*2d1272b8SAndroid Build Coastguard Worker {
78*2d1272b8SAndroid Build Coastguard Worker hb_codepoint_t space;
79*2d1272b8SAndroid Build Coastguard Worker bool has_space = (bool) font->get_nominal_glyph (' ', &space);
80*2d1272b8SAndroid Build Coastguard Worker
81*2d1272b8SAndroid Build Coastguard Worker buffer->clear_positions ();
82*2d1272b8SAndroid Build Coastguard Worker
83*2d1272b8SAndroid Build Coastguard Worker hb_direction_t direction = buffer->props.direction;
84*2d1272b8SAndroid Build Coastguard Worker hb_unicode_funcs_t *unicode = buffer->unicode;
85*2d1272b8SAndroid Build Coastguard Worker unsigned int count = buffer->len;
86*2d1272b8SAndroid Build Coastguard Worker hb_glyph_info_t *info = buffer->info;
87*2d1272b8SAndroid Build Coastguard Worker hb_glyph_position_t *pos = buffer->pos;
88*2d1272b8SAndroid Build Coastguard Worker for (unsigned int i = 0; i < count; i++)
89*2d1272b8SAndroid Build Coastguard Worker {
90*2d1272b8SAndroid Build Coastguard Worker if (has_space && unicode->is_default_ignorable (info[i].codepoint)) {
91*2d1272b8SAndroid Build Coastguard Worker info[i].codepoint = space;
92*2d1272b8SAndroid Build Coastguard Worker pos[i].x_advance = 0;
93*2d1272b8SAndroid Build Coastguard Worker pos[i].y_advance = 0;
94*2d1272b8SAndroid Build Coastguard Worker continue;
95*2d1272b8SAndroid Build Coastguard Worker }
96*2d1272b8SAndroid Build Coastguard Worker (void) font->get_nominal_glyph (info[i].codepoint, &info[i].codepoint);
97*2d1272b8SAndroid Build Coastguard Worker font->get_glyph_advance_for_direction (info[i].codepoint,
98*2d1272b8SAndroid Build Coastguard Worker direction,
99*2d1272b8SAndroid Build Coastguard Worker &pos[i].x_advance,
100*2d1272b8SAndroid Build Coastguard Worker &pos[i].y_advance);
101*2d1272b8SAndroid Build Coastguard Worker font->subtract_glyph_origin_for_direction (info[i].codepoint,
102*2d1272b8SAndroid Build Coastguard Worker direction,
103*2d1272b8SAndroid Build Coastguard Worker &pos[i].x_offset,
104*2d1272b8SAndroid Build Coastguard Worker &pos[i].y_offset);
105*2d1272b8SAndroid Build Coastguard Worker }
106*2d1272b8SAndroid Build Coastguard Worker
107*2d1272b8SAndroid Build Coastguard Worker if (HB_DIRECTION_IS_BACKWARD (direction))
108*2d1272b8SAndroid Build Coastguard Worker hb_buffer_reverse (buffer);
109*2d1272b8SAndroid Build Coastguard Worker
110*2d1272b8SAndroid Build Coastguard Worker buffer->clear_glyph_flags ();
111*2d1272b8SAndroid Build Coastguard Worker
112*2d1272b8SAndroid Build Coastguard Worker return true;
113*2d1272b8SAndroid Build Coastguard Worker }
114*2d1272b8SAndroid Build Coastguard Worker
115*2d1272b8SAndroid Build Coastguard Worker #endif
116