| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright © 2011 Google, Inc. | 2 * Copyright © 2011 Google, Inc. |
| 3 * | 3 * |
| 4 * This is part of HarfBuzz, a text shaping library. | 4 * This is part of HarfBuzz, a text shaping library. |
| 5 * | 5 * |
| 6 * Permission is hereby granted, without written agreement and without | 6 * Permission is hereby granted, without written agreement and without |
| 7 * license or royalty fees, to use, copy, modify, and distribute this | 7 * license or royalty fees, to use, copy, modify, and distribute this |
| 8 * software and its documentation for any purpose, provided that the | 8 * software and its documentation for any purpose, provided that the |
| 9 * above copyright notice and the following two paragraphs appear in | 9 * above copyright notice and the following two paragraphs appear in |
| 10 * all copies of this software. | 10 * all copies of this software. |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 * shaper | 88 * shaper |
| 89 */ | 89 */ |
| 90 | 90 |
| 91 hb_bool_t | 91 hb_bool_t |
| 92 _hb_fallback_shape (hb_shape_plan_t *shape_plan HB_UNUSED, | 92 _hb_fallback_shape (hb_shape_plan_t *shape_plan HB_UNUSED, |
| 93 hb_font_t *font, | 93 hb_font_t *font, |
| 94 hb_buffer_t *buffer, | 94 hb_buffer_t *buffer, |
| 95 const hb_feature_t *features HB_UNUSED, | 95 const hb_feature_t *features HB_UNUSED, |
| 96 unsigned int num_features HB_UNUSED) | 96 unsigned int num_features HB_UNUSED) |
| 97 { | 97 { |
| 98 /* TODO |
| 99 * |
| 100 * - Apply fallback kern. |
| 101 * - Handle Variation Selectors? |
| 102 * - Apply normalization? |
| 103 * |
| 104 * This will make the fallback shaper into a dumb "TrueType" |
| 105 * shaper which many people unfortunately still request. |
| 106 */ |
| 107 |
| 108 bool has_space; |
| 98 hb_codepoint_t space; | 109 hb_codepoint_t space; |
| 99 font->get_glyph (' ', 0, &space); | 110 has_space = font->get_glyph (' ', 0, &space); |
| 100 | 111 |
| 101 buffer->clear_positions (); | 112 buffer->clear_positions (); |
| 102 | 113 |
| 103 unsigned int count = buffer->len; | 114 unsigned int count = buffer->len; |
| 104 | 115 |
| 105 for (unsigned int i = 0; i < count; i++) | 116 for (unsigned int i = 0; i < count; i++) |
| 106 { | 117 { |
| 107 if (buffer->unicode->is_default_ignorable (buffer->info[i].codepoint)) { | 118 if (has_space && buffer->unicode->is_default_ignorable (buffer->info[i].code
point)) { |
| 108 buffer->info[i].codepoint = space; | 119 buffer->info[i].codepoint = space; |
| 109 buffer->pos[i].x_advance = 0; | 120 buffer->pos[i].x_advance = 0; |
| 110 buffer->pos[i].y_advance = 0; | 121 buffer->pos[i].y_advance = 0; |
| 111 continue; | 122 continue; |
| 112 } | 123 } |
| 113 font->get_glyph (buffer->info[i].codepoint, 0, &buffer->info[i].codepoint); | 124 font->get_glyph (buffer->info[i].codepoint, 0, &buffer->info[i].codepoint); |
| 114 font->get_glyph_advance_for_direction (buffer->info[i].codepoint, | 125 font->get_glyph_advance_for_direction (buffer->info[i].codepoint, |
| 115 buffer->props.direction, | 126 buffer->props.direction, |
| 116 &buffer->pos[i].x_advance, | 127 &buffer->pos[i].x_advance, |
| 117 &buffer->pos[i].y_advance); | 128 &buffer->pos[i].y_advance); |
| 118 font->subtract_glyph_origin_for_direction (buffer->info[i].codepoint, | 129 font->subtract_glyph_origin_for_direction (buffer->info[i].codepoint, |
| 119 buffer->props.direction, | 130 buffer->props.direction, |
| 120 &buffer->pos[i].x_offset, | 131 &buffer->pos[i].x_offset, |
| 121 &buffer->pos[i].y_offset); | 132 &buffer->pos[i].y_offset); |
| 122 } | 133 } |
| 123 | 134 |
| 124 if (HB_DIRECTION_IS_BACKWARD (buffer->props.direction)) | 135 if (HB_DIRECTION_IS_BACKWARD (buffer->props.direction)) |
| 125 hb_buffer_reverse (buffer); | 136 hb_buffer_reverse (buffer); |
| 126 | 137 |
| 127 return true; | 138 return true; |
| 128 } | 139 } |
| OLD | NEW |