Add hb_font_[sg]et_ptem() to set/get point size on font
New API:
hb_font_set_ptem()
hb_font_get_ptem()
Needed for hb-coretext optical sizing:
https://github.com/behdad/harfbuzz/issues/360
diff --git a/docs/harfbuzz-sections.txt b/docs/harfbuzz-sections.txt
index 6ceefd2..6d86d94 100644
--- a/docs/harfbuzz-sections.txt
+++ b/docs/harfbuzz-sections.txt
@@ -246,6 +246,7 @@
hb_font_get_nominal_glyph_func_t
hb_font_get_parent
hb_font_get_ppem
+hb_font_get_ptem
hb_font_get_scale
hb_font_get_user_data
hb_font_get_variation_glyph
@@ -261,6 +262,7 @@
hb_font_set_funcs_data
hb_font_set_parent
hb_font_set_ppem
+hb_font_set_ptem
hb_font_set_scale
hb_font_set_user_data
hb_variation_t
diff --git a/src/hb-font-private.hh b/src/hb-font-private.hh
index ed9f2c5..30661c3 100644
--- a/src/hb-font-private.hh
+++ b/src/hb-font-private.hh
@@ -108,6 +108,8 @@
unsigned int x_ppem;
unsigned int y_ppem;
+ float ptem;
+
/* Font variation coordinates. */
unsigned int num_coords;
int *coords;
@@ -123,7 +125,8 @@
DIRTY_FUNCS = 0x0004,
DIRTY_SCALE = 0x0008,
DIRTY_PPEM = 0x0010,
- DIRTY_VARIATIONS = 0x0020,
+ DIRTY_PTEM = 0x0020,
+ DIRTY_VARIATIONS = 0x0040,
} dirty;
struct hb_shaper_data_t shaper_data;
diff --git a/src/hb-font.cc b/src/hb-font.cc
index 50da49e..c47e2c1 100644
--- a/src/hb-font.cc
+++ b/src/hb-font.cc
@@ -1157,6 +1157,7 @@
font->y_scale = parent->y_scale;
font->x_ppem = parent->x_ppem;
font->y_ppem = parent->y_ppem;
+ font->ptem = parent->ptem;
font->num_coords = parent->num_coords;
if (!font->num_coords)
@@ -1199,6 +1200,7 @@
0, /* x_ppem */
0, /* y_ppem */
+ -1, /* ptem */
0, /* num_coords */
NULL, /* coords */
@@ -1597,6 +1599,45 @@
if (y_ppem) *y_ppem = font->y_ppem;
}
+/**
+ * hb_font_set_ptem:
+ * @font: a font.
+ * @ptem:
+ *
+ * Sets "point size" of the font.
+ *
+ * Since: 1.6.0
+ **/
+void
+hb_font_set_ptem (hb_font_t *font, float ptem)
+{
+ if (font->immutable)
+ return;
+
+ if (font->ptem == ptem)
+ return;
+
+ font->dirty |= font->DIRTY_PTEM;
+
+ font->ptem = ptem;
+}
+
+/**
+ * hb_font_get_ptem:
+ * @font: a font.
+ *
+ * Gets the "point size" of the font. A value of -1 means unset.
+ *
+ * Return value: Point size.
+ *
+ * Since: 0.9.2
+ **/
+float
+hb_font_get_ptem (hb_font_t *font)
+{
+ return font->ptem;
+}
+
/*
* Variations
*/
diff --git a/src/hb-font.h b/src/hb-font.h
index 85fb56d..8fb1849 100644
--- a/src/hb-font.h
+++ b/src/hb-font.h
@@ -607,6 +607,16 @@
unsigned int *x_ppem,
unsigned int *y_ppem);
+/*
+ * Point size per EM. Used for optical-sizing in CoreText.
+ * A -1 means "not set".
+ */
+HB_EXTERN void
+hb_font_set_ptem (hb_font_t *font, float ptem);
+
+HB_EXTERN float
+hb_font_get_ptem (hb_font_t *font);
+
HB_EXTERN void
hb_font_set_variations (hb_font_t *font,
const hb_variation_t *variations,