Fix scale issues
hb_font_set_scale() now sets the value to be used to represent a unit
pixel. For example, if rendering a 10px font with a 26.6 representation,
you would set scale to (10 << 6). For 10px in 16.16 you would set it to
(10 << 16). This space should be the same space that the get_glyph_metrics
and get_kerning callbacks work in.
diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc
index 3ee031c..82b56c8 100644
--- a/src/hb-ot-layout.cc
+++ b/src/hb-ot-layout.cc
@@ -39,12 +39,11 @@
#include <string.h>
-void
-_hb_ot_layout_init (hb_face_t *face)
+hb_ot_layout_t *
+_hb_ot_layout_new (hb_face_t *face)
{
- hb_ot_layout_t *layout = &face->ot_layout;
-
- memset (layout, 0, sizeof (*layout));
+ /* Remove this object altogether */
+ hb_ot_layout_t *layout = (hb_ot_layout_t *) calloc (1, sizeof (hb_ot_layout_t));
layout->gdef_blob = Sanitizer<GDEF>::sanitize (hb_face_get_table (face, HB_OT_TAG_GDEF));
layout->gdef = Sanitizer<GDEF>::lock_instance (layout->gdef_blob);
@@ -54,13 +53,13 @@
layout->gpos_blob = Sanitizer<GPOS>::sanitize (hb_face_get_table (face, HB_OT_TAG_GPOS));
layout->gpos = Sanitizer<GPOS>::lock_instance (layout->gpos_blob);
+
+ return layout;
}
void
-_hb_ot_layout_fini (hb_face_t *face)
+_hb_ot_layout_free (hb_ot_layout_t *layout)
{
- hb_ot_layout_t *layout = &face->ot_layout;
-
hb_blob_unlock (layout->gdef_blob);
hb_blob_unlock (layout->gsub_blob);
hb_blob_unlock (layout->gpos_blob);
@@ -75,19 +74,19 @@
static const GDEF&
_get_gdef (hb_face_t *face)
{
- return likely (face->ot_layout.gdef) ? *face->ot_layout.gdef : Null(GDEF);
+ return likely (face->ot_layout->gdef) ? *face->ot_layout->gdef : Null(GDEF);
}
static const GSUB&
_get_gsub (hb_face_t *face)
{
- return likely (face->ot_layout.gsub) ? *face->ot_layout.gsub : Null(GSUB);
+ return likely (face->ot_layout->gsub) ? *face->ot_layout->gsub : Null(GSUB);
}
static const GPOS&
_get_gpos (hb_face_t *face)
{
- return likely (face->ot_layout.gpos) ? *face->ot_layout.gpos : Null(GPOS);
+ return likely (face->ot_layout->gpos) ? *face->ot_layout->gpos : Null(GPOS);
}
@@ -106,7 +105,7 @@
hb_bool_t
_hb_ot_layout_has_new_glyph_classes (hb_face_t *face)
{
- return face->ot_layout.new_gdef.len > 0;
+ return face->ot_layout->new_gdef.len > 0;
}
static unsigned int
@@ -118,8 +117,8 @@
klass = gdef.get_glyph_class (glyph);
- if (!klass && glyph < face->ot_layout.new_gdef.len)
- klass = face->ot_layout.new_gdef.klasses[glyph];
+ if (!klass && glyph < face->ot_layout->new_gdef.len)
+ klass = face->ot_layout->new_gdef.klasses[glyph];
switch (klass) {
default:
@@ -215,7 +214,7 @@
/* TODO optimize this? similar to old harfbuzz code for example */
- hb_ot_layout_t *layout = &face->ot_layout;
+ hb_ot_layout_t *layout = face->ot_layout;
hb_ot_layout_class_t gdef_klass;
unsigned int len = layout->new_gdef.len;
@@ -288,7 +287,7 @@
if (HB_OBJECT_IS_INERT (face))
return;
- hb_ot_layout_t *layout = &face->ot_layout;
+ hb_ot_layout_t *layout = face->ot_layout;
if (unlikely (!count || !glyphs || !klasses))
return;