blob: c54ad8764bcc86d00ef0e033ca98aad6342e5da0 [file] [log] [blame]
Behdad Esfahbod02aeca92011-08-04 22:31:05 -04001/*
2 * Copyright © 2011 Google, Inc.
3 *
4 * This is part of HarfBuzz, a text shaping library.
5 *
6 * Permission is hereby granted, without written agreement and without
7 * license or royalty fees, to use, copy, modify, and distribute this
8 * software and its documentation for any purpose, provided that the
9 * above copyright notice and the following two paragraphs appear in
10 * all copies of this software.
11 *
12 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
13 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
14 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
15 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
16 * DAMAGE.
17 *
18 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
19 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20 * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
21 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
22 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
23 *
24 * Google Author(s): Behdad Esfahbod
25 */
26
Behdad Esfahbodc77ae402018-08-25 22:36:36 -070027#include "hb-shaper-impl.hh"
Behdad Esfahbod02aeca92011-08-04 22:31:05 -040028
Behdad Esfahbod23768a92019-06-17 20:29:29 -070029#ifndef HB_NO_FALLBACK_SHAPE
Behdad Esfahbod027857d2012-07-26 17:34:25 -040030
31/*
32 * shaper face data
33 */
34
Behdad Esfahbod3d22aef2018-08-01 18:03:32 -070035struct hb_fallback_face_data_t {};
Behdad Esfahbod027857d2012-07-26 17:34:25 -040036
Behdad Esfahbod3d22aef2018-08-01 18:03:32 -070037hb_fallback_face_data_t *
Behdad Esfahbod0beb66e2012-12-05 18:46:04 -050038_hb_fallback_shaper_face_data_create (hb_face_t *face HB_UNUSED)
Behdad Esfahbod027857d2012-07-26 17:34:25 -040039{
Behdad Esfahbod3d22aef2018-08-01 18:03:32 -070040 return (hb_fallback_face_data_t *) HB_SHAPER_DATA_SUCCEEDED;
Behdad Esfahbod027857d2012-07-26 17:34:25 -040041}
42
43void
Behdad Esfahbod3d22aef2018-08-01 18:03:32 -070044_hb_fallback_shaper_face_data_destroy (hb_fallback_face_data_t *data HB_UNUSED)
Behdad Esfahbod027857d2012-07-26 17:34:25 -040045{
46}
47
48
49/*
50 * shaper font data
51 */
52
Behdad Esfahbod3d22aef2018-08-01 18:03:32 -070053struct hb_fallback_font_data_t {};
Behdad Esfahbod027857d2012-07-26 17:34:25 -040054
Behdad Esfahbod3d22aef2018-08-01 18:03:32 -070055hb_fallback_font_data_t *
Behdad Esfahbod0beb66e2012-12-05 18:46:04 -050056_hb_fallback_shaper_font_data_create (hb_font_t *font HB_UNUSED)
Behdad Esfahbod027857d2012-07-26 17:34:25 -040057{
Behdad Esfahbod3d22aef2018-08-01 18:03:32 -070058 return (hb_fallback_font_data_t *) HB_SHAPER_DATA_SUCCEEDED;
Behdad Esfahbod027857d2012-07-26 17:34:25 -040059}
60
61void
Behdad Esfahbod3d22aef2018-08-01 18:03:32 -070062_hb_fallback_shaper_font_data_destroy (hb_fallback_font_data_t *data HB_UNUSED)
Behdad Esfahbod027857d2012-07-26 17:34:25 -040063{
64}
65
66
67/*
Behdad Esfahbod027857d2012-07-26 17:34:25 -040068 * shaper
69 */
Behdad Esfahbod02aeca92011-08-04 22:31:05 -040070
71hb_bool_t
Behdad Esfahbod0beb66e2012-12-05 18:46:04 -050072_hb_fallback_shape (hb_shape_plan_t *shape_plan HB_UNUSED,
Behdad Esfahbodbd26b4d2012-07-26 22:05:39 -040073 hb_font_t *font,
Behdad Esfahbod6bd9b472012-04-12 14:53:53 -040074 hb_buffer_t *buffer,
Behdad Esfahbod93345ed2012-05-13 16:01:08 +020075 const hb_feature_t *features HB_UNUSED,
76 unsigned int num_features HB_UNUSED)
Behdad Esfahbod02aeca92011-08-04 22:31:05 -040077{
Behdad Esfahbod6da9dbf2012-06-08 10:53:35 -040078 hb_codepoint_t space;
Behdad Esfahbod8b5bc142016-02-24 19:05:23 +090079 bool has_space = (bool) font->get_nominal_glyph (' ', &space);
Behdad Esfahbod6da9dbf2012-06-08 10:53:35 -040080
Behdad Esfahbod6da9dbf2012-06-08 10:53:35 -040081 buffer->clear_positions ();
Behdad Esfahbod02aeca92011-08-04 22:31:05 -040082
Behdad Esfahbod7cd33f22014-07-17 14:22:11 -040083 hb_direction_t direction = buffer->props.direction;
84 hb_unicode_funcs_t *unicode = buffer->unicode;
Behdad Esfahbod1b8196c2011-08-09 11:37:46 +020085 unsigned int count = buffer->len;
Behdad Esfahbod7cd33f22014-07-17 14:22:11 -040086 hb_glyph_info_t *info = buffer->info;
87 hb_glyph_position_t *pos = buffer->pos;
Behdad Esfahbod1b8196c2011-08-09 11:37:46 +020088 for (unsigned int i = 0; i < count; i++)
Behdad Esfahbod6da9dbf2012-06-08 10:53:35 -040089 {
Behdad Esfahbod7cd33f22014-07-17 14:22:11 -040090 if (has_space && unicode->is_default_ignorable (info[i].codepoint)) {
91 info[i].codepoint = space;
92 pos[i].x_advance = 0;
93 pos[i].y_advance = 0;
Behdad Esfahbod6da9dbf2012-06-08 10:53:35 -040094 continue;
95 }
Behdad Esfahbod1dd630a2017-02-01 11:57:21 -080096 (void) font->get_nominal_glyph (info[i].codepoint, &info[i].codepoint);
Behdad Esfahbod7cd33f22014-07-17 14:22:11 -040097 font->get_glyph_advance_for_direction (info[i].codepoint,
98 direction,
99 &pos[i].x_advance,
100 &pos[i].y_advance);
101 font->subtract_glyph_origin_for_direction (info[i].codepoint,
102 direction,
103 &pos[i].x_offset,
104 &pos[i].y_offset);
Behdad Esfahbod1b8196c2011-08-09 11:37:46 +0200105 }
106
Behdad Esfahbod7cd33f22014-07-17 14:22:11 -0400107 if (HB_DIRECTION_IS_BACKWARD (direction))
Behdad Esfahbod1b8196c2011-08-09 11:37:46 +0200108 hb_buffer_reverse (buffer);
109
Behdad Esfahbod94d43c02021-12-04 16:56:39 -0800110 buffer->clear_glyph_flags ();
Behdad Esfahbode4da3802017-11-10 17:14:27 -0800111
Behdad Esfahbod0594a242012-06-05 20:35:40 -0400112 return true;
Behdad Esfahbod02aeca92011-08-04 22:31:05 -0400113}
Behdad Esfahbod23768a92019-06-17 20:29:29 -0700114
115#endif