Skip to content

Commit

Permalink
Bug 1382083 - Update harfbuzz to version 1.4.7. r=jfkthame
Browse files Browse the repository at this point in the history
  • Loading branch information
rvandermeulen committed Jul 19, 2017
1 parent d471c24 commit 7085d0e
Show file tree
Hide file tree
Showing 34 changed files with 420 additions and 299 deletions.
1 change: 1 addition & 0 deletions gfx/harfbuzz/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ EXTRA_DIST = \
harfbuzz.doap \
README.python \
BUILD.md \
CMakeLists.txt \
$(NULL)

MAINTAINERCLEANFILES = \
Expand Down
19 changes: 19 additions & 0 deletions gfx/harfbuzz/NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
Overview of changes leading to 1.4.7
Tuesday, July 18, 2017
====================================

- Multiple Indic, Tibetan, and Cham fixes.
- CoreText: Allow disabling kerning.
- Adjust Arabic feature order again.
- Misc build fixes.


Overview of changes leading to 1.4.6
Sunday, April 23, 2017
====================================

- Graphite2: Fix RTL positioning issue.
- Backlist GDEF of more versions of Padauk and Tahoma.
- New, experimental, cmake alternative build system.


Overview of changes leading to 1.4.5
Friday, March 10, 2017
====================================
Expand Down
4 changes: 2 additions & 2 deletions gfx/harfbuzz/README-mozilla
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
gfx/harfbuzz status as of 2017-04-24:
gfx/harfbuzz status as of 2017-07-19:

This directory contains the harfbuzz source from the 'master' branch of
https://github.com/behdad/harfbuzz.

Current version: 1.4.6
Current version: 1.4.7

UPDATING:

Expand Down
2 changes: 1 addition & 1 deletion gfx/harfbuzz/configure.ac
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
AC_PREREQ([2.64])
AC_INIT([HarfBuzz],
[1.4.5],
[1.4.7],
[https://github.com/behdad/harfbuzz/issues/new],
[harfbuzz],
[http://harfbuzz.org/])
Expand Down
2 changes: 1 addition & 1 deletion gfx/harfbuzz/src/gen-arabic-table.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def print_joining_table(f):
for (start,end) in ranges:
if p not in [start>>page_bits, end>>page_bits]: continue
offset = "joining_offset_0x%04xu" % start
print " if (hb_in_range (u, 0x%04Xu, 0x%04Xu)) return joining_table[u - 0x%04Xu + %s];" % (start, end, start, offset)
print " if (hb_in_range<hb_codepoint_t> (u, 0x%04Xu, 0x%04Xu)) return joining_table[u - 0x%04Xu + %s];" % (start, end, start, offset)
print " break;"
print ""
print " default:"
Expand Down
2 changes: 1 addition & 1 deletion gfx/harfbuzz/src/gen-indic-table.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def print_block (block, start, end, data):
for (start,end) in zip (starts, ends):
if p not in [start>>page_bits, end>>page_bits]: continue
offset = "indic_offset_0x%04xu" % start
print " if (hb_in_range (u, 0x%04Xu, 0x%04Xu)) return indic_table[u - 0x%04Xu + %s];" % (start, end-1, start, offset)
print " if (hb_in_range<hb_codepoint_t> (u, 0x%04Xu, 0x%04Xu)) return indic_table[u - 0x%04Xu + %s];" % (start, end-1, start, offset)
for u,d in singles.items ():
if p != u>>page_bits: continue
print " if (unlikely (u == 0x%04Xu)) return _(%s,%s);" % (u, short[0][d[0]], short[1][d[1]])
Expand Down
8 changes: 5 additions & 3 deletions gfx/harfbuzz/src/gen-use-table.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,13 @@ def is_SYM_MOD(U, UISC, UGC):
def is_VARIATION_SELECTOR(U, UISC, UGC):
return 0xFE00 <= U <= 0xFE0F
def is_VOWEL(U, UISC, UGC):
# https://github.com/roozbehp/unicode-data/issues/6
return (UISC == Pure_Killer or
(UGC != Lo and UISC in [Vowel, Vowel_Dependent]))
(UGC != Lo and UISC in [Vowel, Vowel_Dependent] and U not in [0xAA29]))
def is_VOWEL_MOD(U, UISC, UGC):
# https://github.com/roozbehp/unicode-data/issues/6
return (UISC in [Tone_Mark, Cantillation_Mark, Register_Shifter, Visarga] or
(UGC != Lo and UISC == Bindu))
(UGC != Lo and (UISC == Bindu or U in [0xAA29])))

use_mapping = {
'B': is_BASE,
Expand Down Expand Up @@ -449,7 +451,7 @@ def print_block (block, start, end, data):
for (start,end) in zip (starts, ends):
if p not in [start>>page_bits, end>>page_bits]: continue
offset = "use_offset_0x%04xu" % start
print " if (hb_in_range (u, 0x%04Xu, 0x%04Xu)) return use_table[u - 0x%04Xu + %s];" % (start, end-1, start, offset)
print " if (hb_in_range<hb_codepoint_t> (u, 0x%04Xu, 0x%04Xu)) return use_table[u - 0x%04Xu + %s];" % (start, end-1, start, offset)
for u,d in singles.items ():
if p != u>>page_bits: continue
print " if (unlikely (u == 0x%04Xu)) return %s;" % (u, d[0])
Expand Down
2 changes: 1 addition & 1 deletion gfx/harfbuzz/src/harfbuzz-icu.pc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ includedir=/usr/local/include

Name: harfbuzz
Description: HarfBuzz text shaping library ICU integration
Version: 1.4.5
Version: 1.4.7

Requires: harfbuzz
Requires.private: icu-uc
Expand Down
2 changes: 1 addition & 1 deletion gfx/harfbuzz/src/harfbuzz.pc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ includedir=/usr/local/include

Name: harfbuzz
Description: HarfBuzz text shaping library
Version: 1.4.5
Version: 1.4.7

Libs: -L${libdir} -lharfbuzz
Libs.private:
Expand Down
8 changes: 4 additions & 4 deletions gfx/harfbuzz/src/hb-atomic-private.hh
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,13 @@ typedef unsigned int hb_atomic_int_impl_t;
#include <builtins.h>


static inline int hb_fetch_and_add(volatile int* AI, unsigned int V) {
static inline int _hb_fetch_and_add(volatile int* AI, unsigned int V) {
__lwsync();
int result = __fetch_and_add(AI, V);
__isync();
return result;
}
static inline int hb_compare_and_swaplp(volatile long* P, long O, long N) {
static inline int _hb_compare_and_swaplp(volatile long* P, long O, long N) {
__sync();
int result = __compare_and_swaplp (P, &O, N);
__sync();
Expand All @@ -139,10 +139,10 @@ static inline int hb_compare_and_swaplp(volatile long* P, long O, long N) {

typedef int hb_atomic_int_impl_t;
#define HB_ATOMIC_INT_IMPL_INIT(V) (V)
#define hb_atomic_int_impl_add(AI, V) hb_fetch_and_add (&(AI), (V))
#define hb_atomic_int_impl_add(AI, V) _hb_fetch_and_add (&(AI), (V))

#define hb_atomic_ptr_impl_get(P) (__sync(), (void *) *(P))
#define hb_atomic_ptr_impl_cmpexch(P,O,N) hb_compare_and_swaplp ((long*)(P), (long)(O), (long)(N))
#define hb_atomic_ptr_impl_cmpexch(P,O,N) _hb_compare_and_swaplp ((long*)(P), (long)(O), (long)(N))

#elif !defined(HB_NO_MT)

Expand Down
4 changes: 2 additions & 2 deletions gfx/harfbuzz/src/hb-buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ hb_buffer_t::merge_clusters_impl (unsigned int start,
if (cluster_level == HB_BUFFER_CLUSTER_LEVEL_CHARACTERS)
return;

unsigned int cluster = info[start].cluster;
uint32_t cluster = info[start].cluster;

for (unsigned int i = start + 1; i < end; i++)
cluster = MIN (cluster, info[i].cluster);
Expand Down Expand Up @@ -583,7 +583,7 @@ hb_buffer_t::merge_out_clusters (unsigned int start,
if (unlikely (end - start < 2))
return;

unsigned int cluster = out_info[start].cluster;
uint32_t cluster = out_info[start].cluster;

for (unsigned int i = start + 1; i < end; i++)
cluster = MIN (cluster, out_info[i].cluster);
Expand Down
48 changes: 43 additions & 5 deletions gfx/harfbuzz/src/hb-common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,18 @@ struct hb_language_item_t {
}

inline hb_language_item_t & operator = (const char *s) {
lang = (hb_language_t) strdup (s);
for (unsigned char *p = (unsigned char *) lang; *p; p++)
*p = canon_map[*p];
/* If a custom allocated is used calling strdup() pairs
badly with a call to the custom free() in finish() below.
Therefore don't call strdup(), implement its behavior.
*/
size_t len = strlen(s) + 1;
lang = (hb_language_t) malloc(len);
if (likely (lang))
{
memcpy((unsigned char *) lang, s, len);
for (unsigned char *p = (unsigned char *) lang; *p; p++)
*p = canon_map[*p];
}

return *this;
}
Expand Down Expand Up @@ -265,6 +274,11 @@ lang_find_or_insert (const char *key)
return NULL;
lang->next = first_lang;
*lang = key;
if (unlikely (!lang->lang))
{
free (lang);
return NULL;
}

if (!hb_atomic_ptr_cmpexch (&langs, first_lang, lang)) {
lang->finish ();
Expand Down Expand Up @@ -656,6 +670,30 @@ parse_uint (const char **pp, const char *end, unsigned int *pv)
return true;
}

static bool
parse_uint32 (const char **pp, const char *end, uint32_t *pv)
{
char buf[32];
unsigned int len = MIN (ARRAY_LENGTH (buf) - 1, (unsigned int) (end - *pp));
strncpy (buf, *pp, len);
buf[len] = '\0';

char *p = buf;
char *pend = p;
unsigned int v;

/* Intentionally use strtol instead of strtoul, such that
* -1 turns into "big number"... */
errno = 0;
v = strtol (p, &pend, 0);
if (errno || p == pend)
return false;

*pv = v;
*pp += pend - p;
return true;
}

static bool
parse_float (const char **pp, const char *end, float *pv)
{
Expand All @@ -679,7 +717,7 @@ parse_float (const char **pp, const char *end, float *pv)
}

static bool
parse_bool (const char **pp, const char *end, unsigned int *pv)
parse_bool (const char **pp, const char *end, uint32_t *pv)
{
parse_space (pp, end);

Expand Down Expand Up @@ -778,7 +816,7 @@ static bool
parse_feature_value_postfix (const char **pp, const char *end, hb_feature_t *feature)
{
bool had_equal = parse_char (pp, end, '=');
bool had_value = parse_uint (pp, end, &feature->value) ||
bool had_value = parse_uint32 (pp, end, &feature->value) ||
parse_bool (pp, end, &feature->value);
/* CSS doesn't use equal-sign between tag and value.
* If there was an equal-sign, then there *must* be a value.
Expand Down
41 changes: 32 additions & 9 deletions gfx/harfbuzz/src/hb-coretext.cc
Original file line number Diff line number Diff line change
Expand Up @@ -641,22 +641,23 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan,
/* active_features.qsort (); */
for (unsigned int j = 0; j < active_features.len; j++)
{
CFStringRef keys[2] = {
CFStringRef keys[] = {
kCTFontFeatureTypeIdentifierKey,
kCTFontFeatureSelectorIdentifierKey
};
CFNumberRef values[2] = {
CFNumberRef values[] = {
CFNumberCreate (kCFAllocatorDefault, kCFNumberIntType, &active_features[j].rec.feature),
CFNumberCreate (kCFAllocatorDefault, kCFNumberIntType, &active_features[j].rec.setting)
};
ASSERT_STATIC (ARRAY_LENGTH (keys) == ARRAY_LENGTH (values));
CFDictionaryRef dict = CFDictionaryCreate (kCFAllocatorDefault,
(const void **) keys,
(const void **) values,
2,
ARRAY_LENGTH (keys),
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
CFRelease (values[0]);
CFRelease (values[1]);
for (unsigned int i = 0; i < ARRAY_LENGTH (values); i++)
CFRelease (values[i]);

CFArrayAppendValue (features_array, dict);
CFRelease (dict);
Expand Down Expand Up @@ -699,9 +700,6 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan,
active_features.remove (feature - active_features.array);
}
}

if (!range_records.len) /* No active feature found. */
goto fail_features;
}
else
{
Expand Down Expand Up @@ -833,7 +831,7 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan,
CFAttributedStringSetAttribute (attr_string, CFRangeMake (0, chars_len),
kCTFontAttributeName, face_data->ct_font);

if (num_features)
if (num_features && range_records.len)
{
unsigned int start = 0;
range_record_t *last_range = &range_records[0];
Expand All @@ -859,6 +857,30 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan,
CFAttributedStringSetAttribute (attr_string, CFRangeMake (start, chars_len - start),
kCTFontAttributeName, last_range->font);
}
/* Enable/disable kern if requested.
*
* Note: once kern is disabled, reenabling it doesn't currently seem to work in CoreText.
*/
if (num_features)
{
unsigned int zeroint = 0;
CFNumberRef zero = CFNumberCreate (kCFAllocatorDefault, kCFNumberIntType, &zeroint);
for (unsigned int i = 0; i < num_features; i++)
{
const hb_feature_t &feature = features[i];
if (feature.tag == HB_TAG('k','e','r','n') &&
feature.start < chars_len && feature.start < feature.end)
{
CFRange feature_range = CFRangeMake (feature.start,
MIN (feature.end, chars_len) - feature.start);
if (feature.value)
CFAttributedStringRemoveAttribute (attr_string, feature_range, kCTKernAttributeName);
else
CFAttributedStringSetAttribute (attr_string, feature_range, kCTKernAttributeName, zero);
}
}
CFRelease (zero);
}

int level = HB_DIRECTION_IS_FORWARD (buffer->props.direction) ? 0 : 1;
CFNumberRef level_number = CFNumberCreate (kCFAllocatorDefault, kCFNumberIntType, &level);
Expand All @@ -868,6 +890,7 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan,
1,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
CFRelease (level_number);
if (unlikely (!options))
FAIL ("CFDictionaryCreate failed");

Expand Down
2 changes: 1 addition & 1 deletion gfx/harfbuzz/src/hb-ot-font.cc
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ struct hb_ot_face_metrics_accelerator_t
return this->default_advance;
}

return this->table->longMetric[MIN (glyph, this->num_advances - 1)].advance
return this->table->longMetric[MIN (glyph, (uint32_t) this->num_advances - 1)].advance
+ this->var->get_advance_var (glyph, font->coords, font->num_coords); // TODO Optimize?!
}
};
Expand Down
Loading

0 comments on commit 7085d0e

Please sign in to comment.