Harfbuzz buffer needs to be reset every time fromString is called
This commit is contained in:
@@ -24,7 +24,10 @@ namespace lime {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
hb_buffer_t *buffer;
|
hb_buffer_t *mBuffer;
|
||||||
|
hb_direction_t mDirection;
|
||||||
|
hb_script_t mScript;
|
||||||
|
hb_language_t mLanguage;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -11,20 +11,20 @@ namespace lime {
|
|||||||
|
|
||||||
if (strlen(script) != 4) return;
|
if (strlen(script) != 4) return;
|
||||||
|
|
||||||
//hb_script_t tag = (hb_script_t)HB_TAG (script[0], script[1], script[2], script[3]);
|
mDirection = (hb_direction_t)direction;
|
||||||
hb_script_t tag = hb_script_from_string (script, -1);
|
mLanguage = hb_language_from_string (language, strlen (language));
|
||||||
|
mScript = hb_script_from_string (script, -1);
|
||||||
|
|
||||||
buffer = hb_buffer_create ();
|
mBuffer = hb_buffer_create ();
|
||||||
hb_buffer_set_direction (buffer, (hb_direction_t)direction);
|
hb_buffer_set_direction (mBuffer, mDirection);
|
||||||
hb_buffer_set_script (buffer, tag);
|
hb_buffer_set_script (mBuffer, mScript);
|
||||||
hb_buffer_set_language (buffer, hb_language_from_string (language, strlen (language)));
|
hb_buffer_set_language (mBuffer, mLanguage);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Text::~Text () {
|
Text::~Text () {
|
||||||
|
|
||||||
hb_buffer_reset (buffer);
|
hb_buffer_destroy (mBuffer);
|
||||||
hb_buffer_destroy (buffer);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,16 +32,20 @@ namespace lime {
|
|||||||
|
|
||||||
font->SetSize (size);
|
font->SetSize (size);
|
||||||
|
|
||||||
|
// reset buffer
|
||||||
|
hb_buffer_reset (mBuffer);
|
||||||
|
hb_buffer_set_direction (mBuffer, mDirection);
|
||||||
|
hb_buffer_set_script (mBuffer, mScript);
|
||||||
|
hb_buffer_set_language (mBuffer, mLanguage);
|
||||||
|
|
||||||
// layout the text
|
// layout the text
|
||||||
int len = strlen (text);
|
hb_buffer_add_utf8 (mBuffer, text, strlen (text), 0, -1);
|
||||||
hb_buffer_add_utf8 (buffer, text, len, 0, len);
|
|
||||||
hb_font_t *hb_font = hb_ft_font_create (font->face, NULL);
|
hb_font_t *hb_font = hb_ft_font_create (font->face, NULL);
|
||||||
hb_shape (hb_font, buffer, NULL, 0);
|
hb_shape (hb_font, mBuffer, NULL, 0);
|
||||||
|
|
||||||
unsigned int glyph_count;
|
unsigned int glyph_count;
|
||||||
hb_glyph_info_t *glyph_info = hb_buffer_get_glyph_infos (buffer, &glyph_count);
|
hb_glyph_info_t *glyph_info = hb_buffer_get_glyph_infos (mBuffer, &glyph_count);
|
||||||
hb_glyph_position_t *glyph_pos = hb_buffer_get_glyph_positions (buffer, &glyph_count);
|
hb_glyph_position_t *glyph_pos = hb_buffer_get_glyph_positions (mBuffer, &glyph_count);
|
||||||
hb_direction_t direction = hb_buffer_get_direction (buffer);
|
|
||||||
|
|
||||||
float hres = 100;
|
float hres = 100;
|
||||||
value pos_info = alloc_array (glyph_count);
|
value pos_info = alloc_array (glyph_count);
|
||||||
|
|||||||
Reference in New Issue
Block a user