[HarfBuzz] harfbuzz: Branch 'master' - 4 commits
Behdad Esfahbod
behdad at kemper.freedesktop.org
Wed Oct 11 10:36:07 UTC 2017
docs/harfbuzz-sections.txt | 2 +
src/hb-coretext.cc | 2 -
src/hb-face-private.hh | 9 ----
src/hb-face.cc | 17 ---------
src/hb-font-private.hh | 14 +------
src/hb-font.cc | 83 ++++++++++++++++++++++++++-------------------
src/hb-font.h | 10 +++++
7 files changed, 63 insertions(+), 74 deletions(-)
New commits:
commit 16d02a58cf187dbcecc1c796acdc5d3a70ca288e
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Wed Oct 11 12:28:06 2017 +0200
[coretext] Change default font size from 36 to 18
diff --git a/src/hb-coretext.cc b/src/hb-coretext.cc
index ba96d399..5c0b65af 100644
--- a/src/hb-coretext.cc
+++ b/src/hb-coretext.cc
@@ -229,7 +229,7 @@ _hb_coretext_shaper_face_data_create (hb_face_t *face)
* Since we always create CTFont at a fixed size, our CTFont lives in face_data
* instead of font_data. Which is good, because when people change scale on
* hb_font_t, we won't need to update our CTFont. */
- data->ct_font = create_ct_font (data->cg_font, 36.);
+ data->ct_font = create_ct_font (data->cg_font, 18.);
if (unlikely (!data->ct_font))
{
DEBUG_MSG (CORETEXT, face, "CTFont creation failed.");
commit c0c2dbc871667c32ac8eedb11de64078ef24a429
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Wed Oct 11 12:23:35 2017 +0200
Remove dirty tracking
Turns out I don't need this to resolve CoreText optical sizing
issue after all.
https://github.com/behdad/harfbuzz/issues/360
diff --git a/src/hb-face-private.hh b/src/hb-face-private.hh
index 72f08a59..43e7b1cb 100644
--- a/src/hb-face-private.hh
+++ b/src/hb-face-private.hh
@@ -54,13 +54,6 @@ struct hb_face_t {
mutable unsigned int upem; /* Units-per-EM. */
mutable unsigned int num_glyphs; /* Number of glyphs. */
- enum dirty_t {
- DIRTY_NOTHING = 0x0000,
- DIRTY_INDEX = 0x0001,
- DIRTY_UPEM = 0x0002,
- DIRTY_NUM_GLYPHS = 0x0004,
- } dirty;
-
struct hb_shaper_data_t shaper_data; /* Various shaper data. */
/* Various non-shaping data. */
@@ -106,8 +99,6 @@ struct hb_face_t {
HB_INTERNAL void load_num_glyphs (void) const;
};
-HB_MARK_AS_FLAG_T (hb_face_t::dirty_t);
-
extern HB_INTERNAL const hb_face_t _hb_face_nil;
#define HB_SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS
diff --git a/src/hb-face.cc b/src/hb-face.cc
index 22998f00..d7d736d7 100644
--- a/src/hb-face.cc
+++ b/src/hb-face.cc
@@ -51,8 +51,6 @@ const hb_face_t _hb_face_nil = {
1000, /* upem */
0, /* num_glyphs */
- hb_face_t::DIRTY_NOTHING, /* dirty */
-
{
#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_INVALID,
#include "hb-shaper-list.hh"
@@ -367,11 +365,6 @@ hb_face_set_index (hb_face_t *face,
if (face->immutable)
return;
- if (face->index == index)
- return;
-
- face->dirty |= face->DIRTY_INDEX;
-
face->index = index;
}
@@ -407,11 +400,6 @@ hb_face_set_upem (hb_face_t *face,
if (face->immutable)
return;
- if (face->upem == upem)
- return;
-
- face->dirty |= face->DIRTY_UPEM;
-
face->upem = upem;
}
@@ -456,11 +444,6 @@ hb_face_set_glyph_count (hb_face_t *face,
if (face->immutable)
return;
- if (face->num_glyphs == glyph_count)
- return;
-
- face->dirty |= face->DIRTY_NUM_GLYPHS;
-
face->num_glyphs = glyph_count;
}
diff --git a/src/hb-font-private.hh b/src/hb-font-private.hh
index 30661c32..d2801fb8 100644
--- a/src/hb-font-private.hh
+++ b/src/hb-font-private.hh
@@ -118,17 +118,6 @@ struct hb_font_t {
void *user_data;
hb_destroy_func_t destroy;
- enum dirty_t {
- DIRTY_NOTHING = 0x0000,
- DIRTY_FACE = 0x0001,
- DIRTY_PARENT = 0x0002,
- DIRTY_FUNCS = 0x0004,
- DIRTY_SCALE = 0x0008,
- DIRTY_PPEM = 0x0010,
- DIRTY_PTEM = 0x0020,
- DIRTY_VARIATIONS = 0x0040,
- } dirty;
-
struct hb_shaper_data_t shaper_data;
@@ -556,8 +545,6 @@ struct hb_font_t {
}
};
-HB_MARK_AS_FLAG_T (hb_font_t::dirty_t);
-
#define HB_SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS
#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_PROTOTYPE(shaper, font);
#include "hb-shaper-list.hh"
diff --git a/src/hb-font.cc b/src/hb-font.cc
index c47e2c14..88842079 100644
--- a/src/hb-font.cc
+++ b/src/hb-font.cc
@@ -1209,8 +1209,6 @@ hb_font_get_empty (void)
NULL, /* user_data */
NULL, /* destroy */
- hb_font_t::DIRTY_NOTHING, /* dirty */
-
{
#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_INVALID,
#include "hb-shaper-list.hh"
@@ -1363,11 +1361,6 @@ hb_font_set_parent (hb_font_t *font,
if (!parent)
parent = hb_font_get_empty ();
- if (parent == font->parent)
- return;
-
- font->dirty |= font->DIRTY_PARENT;
-
hb_font_t *old = font->parent;
font->parent = hb_font_reference (parent);
@@ -1410,11 +1403,6 @@ hb_font_set_face (hb_font_t *font,
if (unlikely (!face))
face = hb_face_get_empty ();
- if (font->face == face)
- return;
-
- font->dirty |= font->DIRTY_FACE;
-
hb_face_t *old = font->face;
font->face = hb_face_reference (face);
@@ -1468,8 +1456,6 @@ hb_font_set_funcs (hb_font_t *font,
if (!klass)
klass = hb_font_funcs_get_empty ();
- font->dirty |= font->DIRTY_FUNCS;
-
hb_font_funcs_reference (klass);
hb_font_funcs_destroy (font->klass);
font->klass = klass;
@@ -1525,11 +1511,6 @@ hb_font_set_scale (hb_font_t *font,
if (font->immutable)
return;
- if (font->x_scale == x_scale && font->y_scale == y_scale)
- return;
-
- font->dirty |= font->DIRTY_SCALE;
-
font->x_scale = x_scale;
font->y_scale = y_scale;
}
@@ -1571,11 +1552,6 @@ hb_font_set_ppem (hb_font_t *font,
if (font->immutable)
return;
- if (font->x_ppem == x_ppem && font->y_ppem == y_ppem)
- return;
-
- font->dirty |= font->DIRTY_PPEM;
-
font->x_ppem = x_ppem;
font->y_ppem = y_ppem;
}
@@ -1614,11 +1590,6 @@ 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;
}
@@ -1647,16 +1618,6 @@ _hb_font_adopt_var_coords_normalized (hb_font_t *font,
int *coords, /* 2.14 normalized */
unsigned int coords_length)
{
- if (font->num_coords == coords_length &&
- (coords_length == 0 ||
- 0 == memcmp (font->coords, coords, coords_length * sizeof (coords[0]))))
- {
- free (coords);
- return;
- }
-
- font->dirty |= font->DIRTY_VARIATIONS;
-
free (font->coords);
font->coords = coords;
commit b57f18da700837a57df9606290160ea6e96accc8
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Wed Oct 11 11:47:47 2017 +0200
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 6ceefd25..6d86d941 100644
--- a/docs/harfbuzz-sections.txt
+++ b/docs/harfbuzz-sections.txt
@@ -246,6 +246,7 @@ hb_font_get_nominal_glyph
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
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 ed9f2c54..30661c32 100644
--- a/src/hb-font-private.hh
+++ b/src/hb-font-private.hh
@@ -108,6 +108,8 @@ struct hb_font_t {
unsigned int x_ppem;
unsigned int y_ppem;
+ float ptem;
+
/* Font variation coordinates. */
unsigned int num_coords;
int *coords;
@@ -123,7 +125,8 @@ struct hb_font_t {
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 50da49e7..c47e2c14 100644
--- a/src/hb-font.cc
+++ b/src/hb-font.cc
@@ -1157,6 +1157,7 @@ hb_font_create_sub_font (hb_font_t *parent)
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 @@ hb_font_get_empty (void)
0, /* x_ppem */
0, /* y_ppem */
+ -1, /* ptem */
0, /* num_coords */
NULL, /* coords */
@@ -1597,6 +1599,45 @@ hb_font_get_ppem (hb_font_t *font,
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 85fb56d5..8fb1849d 100644
--- a/src/hb-font.h
+++ b/src/hb-font.h
@@ -607,6 +607,16 @@ hb_font_get_ppem (hb_font_t *font,
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,
commit 3f9370d9e5051b1abf2fc94be2e10a39c8069f75
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Wed Oct 11 11:34:53 2017 +0200
Fix TODO item
diff --git a/src/hb-font.cc b/src/hb-font.cc
index a684c234..50da49e7 100644
--- a/src/hb-font.cc
+++ b/src/hb-font.cc
@@ -1158,7 +1158,18 @@ hb_font_create_sub_font (hb_font_t *parent)
font->x_ppem = parent->x_ppem;
font->y_ppem = parent->y_ppem;
- /* TODO: copy variation coordinates. */
+ font->num_coords = parent->num_coords;
+ if (!font->num_coords)
+ font->coords = NULL;
+ else
+ {
+ unsigned int size = parent->num_coords * sizeof (parent->coords[0]);
+ font->coords = (int *) malloc (size);
+ if (unlikely (!font->coords))
+ font->num_coords = 0;
+ else
+ memcpy (font->coords, parent->coords, size);
+ }
return font;
}
More information about the HarfBuzz
mailing list