From 2f50d873680ce0a43b6ec79df1ac946b91f31e63 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 4 Nov 2009 21:07:03 -0500 Subject: [PATCH] Start filling hb_shape() in --- src/hb-buffer-private.h | 1 + src/hb-shape.c | 40 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/hb-buffer-private.h b/src/hb-buffer-private.h index 47f9b8c3..f40b1c58 100644 --- a/src/hb-buffer-private.h +++ b/src/hb-buffer-private.h @@ -131,6 +131,7 @@ _hb_buffer_allocate_lig_id (hb_buffer_t *buffer); #define IN_GLYPH(pos) (buffer->in_string[(pos)].codepoint) #define IN_INFO(pos) (&buffer->in_string[(pos)]) #define IN_CURGLYPH() (buffer->in_string[buffer->in_pos].codepoint) +#define IN_NEXTGLYPH() (buffer->in_string[buffer->in_pos + 1].codepoint) #define IN_CURINFO() (&buffer->in_string[buffer->in_pos]) #define IN_MASK(pos) (buffer->in_string[(pos)].mask) #define IN_LIGID(pos) (buffer->in_string[(pos)].lig_id) diff --git a/src/hb-shape.c b/src/hb-shape.c index 55e21507..7a0f9795 100644 --- a/src/hb-shape.c +++ b/src/hb-shape.c @@ -28,6 +28,35 @@ #include "hb-shape.h" +#include "hb-buffer-private.h" + +static inline hb_bool_t +is_variation_selector (hb_codepoint_t unicode) +{ + return (unicode >= 0xFE00 && unicode <= 0xFE0F) || + (unicode >= 0xE0100 && unicode <= 0xE01EF); +} + +static void +map_glyphs (hb_face_t *face, + hb_font_t *font, + hb_buffer_t *buffer) +{ + unsigned int count; + + count = buffer->in_length - 1; + + for (buffer->in_pos = 0; buffer->in_pos < count; buffer->in_pos++) { + if (HB_UNLIKELY (is_variation_selector (IN_NEXTGLYPH()))) { + IN_CURGLYPH() = hb_font_get_glyph (face, font, IN_CURGLYPH(), IN_NEXTGLYPH()); + buffer->in_pos++; + } else { + IN_CURGLYPH() = hb_font_get_glyph (face, font, IN_CURGLYPH(), 0); + } + } + IN_CURGLYPH() = hb_font_get_glyph (face, font, IN_CURGLYPH(), 0); +} + void hb_shape (hb_face_t *face, @@ -36,5 +65,14 @@ hb_shape (hb_face_t *face, hb_feature_t *features, unsigned int num_features) { -} + /* form_clusters (buffer); */ + /* do_mirroring (buffer); */ + /* natural direction analysis */ + /* OT preprocess */ + + map_glyphs (face, font, buffer); + /* GSUB */ + /* Default positioning */ + /* GPOS / kern */ +} -- GitLab