2011-08-05 04:31:05 +02:00
|
|
|
/*
|
|
|
|
* Copyright © 2011 Google, Inc.
|
|
|
|
*
|
|
|
|
* This is part of HarfBuzz, a text shaping library.
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, without written agreement and without
|
|
|
|
* license or royalty fees, to use, copy, modify, and distribute this
|
|
|
|
* software and its documentation for any purpose, provided that the
|
|
|
|
* above copyright notice and the following two paragraphs appear in
|
|
|
|
* all copies of this software.
|
|
|
|
*
|
|
|
|
* IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
|
|
|
|
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
|
|
|
|
* ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
|
|
|
|
* IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
|
|
|
* DAMAGE.
|
|
|
|
*
|
|
|
|
* THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
|
|
|
|
* BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
|
|
|
|
* ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
|
|
|
|
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
|
|
|
*
|
|
|
|
* Google Author(s): Behdad Esfahbod
|
|
|
|
*/
|
|
|
|
|
2012-07-26 23:34:25 +02:00
|
|
|
#define HB_SHAPER fallback
|
|
|
|
#include "hb-shaper-impl-private.hh"
|
2011-08-05 04:31:05 +02:00
|
|
|
|
2012-07-26 23:34:25 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* shaper face data
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct hb_fallback_shaper_face_data_t {};
|
|
|
|
|
|
|
|
hb_fallback_shaper_face_data_t *
|
2012-12-06 00:46:04 +01:00
|
|
|
_hb_fallback_shaper_face_data_create (hb_face_t *face HB_UNUSED)
|
2012-07-26 23:34:25 +02:00
|
|
|
{
|
|
|
|
return (hb_fallback_shaper_face_data_t *) HB_SHAPER_DATA_SUCCEEDED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-12-06 00:46:04 +01:00
|
|
|
_hb_fallback_shaper_face_data_destroy (hb_fallback_shaper_face_data_t *data HB_UNUSED)
|
2012-07-26 23:34:25 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* shaper font data
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct hb_fallback_shaper_font_data_t {};
|
|
|
|
|
|
|
|
hb_fallback_shaper_font_data_t *
|
2012-12-06 00:46:04 +01:00
|
|
|
_hb_fallback_shaper_font_data_create (hb_font_t *font HB_UNUSED)
|
2012-07-26 23:34:25 +02:00
|
|
|
{
|
|
|
|
return (hb_fallback_shaper_font_data_t *) HB_SHAPER_DATA_SUCCEEDED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-12-06 00:46:04 +01:00
|
|
|
_hb_fallback_shaper_font_data_destroy (hb_fallback_shaper_font_data_t *data HB_UNUSED)
|
2012-07-26 23:34:25 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* shaper shape_plan data
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct hb_fallback_shaper_shape_plan_data_t {};
|
|
|
|
|
|
|
|
hb_fallback_shaper_shape_plan_data_t *
|
2012-08-14 15:33:18 +02:00
|
|
|
_hb_fallback_shaper_shape_plan_data_create (hb_shape_plan_t *shape_plan HB_UNUSED,
|
|
|
|
const hb_feature_t *user_features HB_UNUSED,
|
|
|
|
unsigned int num_user_features HB_UNUSED)
|
2012-07-26 23:34:25 +02:00
|
|
|
{
|
|
|
|
return (hb_fallback_shaper_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-08-14 15:33:18 +02:00
|
|
|
_hb_fallback_shaper_shape_plan_data_destroy (hb_fallback_shaper_shape_plan_data_t *data HB_UNUSED)
|
2012-07-26 23:34:25 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* shaper
|
|
|
|
*/
|
2011-08-05 04:31:05 +02:00
|
|
|
|
|
|
|
hb_bool_t
|
2012-12-06 00:46:04 +01:00
|
|
|
_hb_fallback_shape (hb_shape_plan_t *shape_plan HB_UNUSED,
|
2012-07-27 04:05:39 +02:00
|
|
|
hb_font_t *font,
|
2012-04-12 20:53:53 +02:00
|
|
|
hb_buffer_t *buffer,
|
2012-05-13 16:01:08 +02:00
|
|
|
const hb_feature_t *features HB_UNUSED,
|
|
|
|
unsigned int num_features HB_UNUSED)
|
2011-08-05 04:31:05 +02:00
|
|
|
{
|
2013-11-27 04:57:24 +01:00
|
|
|
/* TODO
|
|
|
|
*
|
|
|
|
* - Apply fallback kern.
|
|
|
|
* - Handle Variation Selectors?
|
|
|
|
* - Apply normalization?
|
|
|
|
*
|
|
|
|
* This will make the fallback shaper into a dumb "TrueType"
|
|
|
|
* shaper which many people unfortunately still request.
|
|
|
|
*/
|
|
|
|
|
2012-06-08 16:53:35 +02:00
|
|
|
hb_codepoint_t space;
|
2014-07-17 20:22:11 +02:00
|
|
|
bool has_space = font->get_glyph (' ', 0, &space);
|
2012-06-08 16:53:35 +02:00
|
|
|
|
|
|
|
buffer->clear_positions ();
|
2011-08-05 04:31:05 +02:00
|
|
|
|
2014-07-17 20:22:11 +02:00
|
|
|
hb_direction_t direction = buffer->props.direction;
|
|
|
|
hb_unicode_funcs_t *unicode = buffer->unicode;
|
2011-08-09 11:37:46 +02:00
|
|
|
unsigned int count = buffer->len;
|
2014-07-17 20:22:11 +02:00
|
|
|
hb_glyph_info_t *info = buffer->info;
|
|
|
|
hb_glyph_position_t *pos = buffer->pos;
|
2011-08-09 11:37:46 +02:00
|
|
|
for (unsigned int i = 0; i < count; i++)
|
2012-06-08 16:53:35 +02:00
|
|
|
{
|
2014-07-17 20:22:11 +02:00
|
|
|
if (has_space && unicode->is_default_ignorable (info[i].codepoint)) {
|
|
|
|
info[i].codepoint = space;
|
|
|
|
pos[i].x_advance = 0;
|
|
|
|
pos[i].y_advance = 0;
|
2012-06-08 16:53:35 +02:00
|
|
|
continue;
|
|
|
|
}
|
2014-07-17 20:22:11 +02:00
|
|
|
font->get_glyph (info[i].codepoint, 0, &info[i].codepoint);
|
|
|
|
font->get_glyph_advance_for_direction (info[i].codepoint,
|
|
|
|
direction,
|
|
|
|
&pos[i].x_advance,
|
|
|
|
&pos[i].y_advance);
|
|
|
|
font->subtract_glyph_origin_for_direction (info[i].codepoint,
|
|
|
|
direction,
|
|
|
|
&pos[i].x_offset,
|
|
|
|
&pos[i].y_offset);
|
2011-08-09 11:37:46 +02:00
|
|
|
}
|
2011-08-05 04:31:05 +02:00
|
|
|
|
2014-07-17 20:22:11 +02:00
|
|
|
if (HB_DIRECTION_IS_BACKWARD (direction))
|
2011-08-09 11:37:46 +02:00
|
|
|
hb_buffer_reverse (buffer);
|
|
|
|
|
2012-06-06 02:35:40 +02:00
|
|
|
return true;
|
2011-08-09 11:37:46 +02:00
|
|
|
}
|