[HarfBuzz] glyph advance difference between coretext and ot backend

2012-07-31 Thread Dohyun Kim
Hi,

I have compiled harfbuzz-ng on Mac OS X Lion.
While testing some fonts, I encounterd a strange mismatch between
coretext and ot backends:

$ ./hb-shape --shapers=coretext /System/Library/Fonts/AppleGothic.ttf ABC
[gid41=0+726|gid42=1+644|gid43=2+685]

$ ./hb-shape --shapers=ot /System/Library/Fonts/AppleGothic.ttf ABC
[gid41=0+743|gid42=1+659|gid43=2+701]

The Units Per Em of AppleGothic is 1000.
However, ot backend under Mac seems to consider upem as 1024 and
increase glyph widths in proportion, resulting in incorrect glyph positions.

BTW, ot backend on ubuntu machine gives the same result as coretext under Mac.

Best,
-- 
Dohyun Kim
College of Law, Dongguk University
Seoul, Republic of Korea
___
HarfBuzz mailing list
HarfBuzz@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/harfbuzz


Re: [HarfBuzz] glyph advance difference between coretext and ot backend

2012-07-31 Thread Rolf Langenhuijzen
I did a similar test with 2 fonts and it was different between the two.. could 
it be some internal font thing that is causing this?

OSX:
hb-shape --shapers=coretext /dev/fonts/MaiolaPro-Regular.otf ABC
[A=0+670|B=1+565|C=2+640]

hb-shape --shapers=ot /dev/fonts/MaiolaPro-Regular.otf ABC
[A=0+660|B=1+555|C=2+630]

hb-shape --shapers=ot /dev/Whitney-Book-Pro.otf ABC
[A=0+691|B=1+547|C=2+638]

hb-shape --shapers=coretext /dev/Whitney-Book-Pro.otf ABC
[A=0+691|B=1+547|C=2+638]

I tried on Ubuntu: 
hb-shape --shapers=ot MaiolaPro-Regular.otf ABC
[A=0+660|B=1+555|C=2+630]

So the same as on OSX, not the same as with coretext as you are getting…

Regards,
Rolf

On Jul 31, 2012, at 12:42 PM, Dohyun Kim wrote:

 Hi,
 
 I have compiled harfbuzz-ng on Mac OS X Lion.
 While testing some fonts, I encounterd a strange mismatch between
 coretext and ot backends:
 
 $ ./hb-shape --shapers=coretext /System/Library/Fonts/AppleGothic.ttf ABC
 [gid41=0+726|gid42=1+644|gid43=2+685]
 
 $ ./hb-shape --shapers=ot /System/Library/Fonts/AppleGothic.ttf ABC
 [gid41=0+743|gid42=1+659|gid43=2+701]
 
 The Units Per Em of AppleGothic is 1000.
 However, ot backend under Mac seems to consider upem as 1024 and
 increase glyph widths in proportion, resulting in incorrect glyph positions.
 
 BTW, ot backend on ubuntu machine gives the same result as coretext under Mac.
 
 Best,
 -- 
 Dohyun Kim
 College of Law, Dongguk University
 Seoul, Republic of Korea
 ___
 HarfBuzz mailing list
 HarfBuzz@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/harfbuzz

___
HarfBuzz mailing list
HarfBuzz@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/harfbuzz


[HarfBuzz] harfbuzz-ng: Branch 'master' - 8 commits

2012-07-31 Thread Behdad Esfahbod
 TODO   |   29 -
 src/hb-old.cc  |   24 ++--
 src/hb-old/harfbuzz-shaper.cpp |1 +
 src/hb-ot-layout-gpos-table.hh |   14 --
 src/hb-ot-layout-gsub-table.hh |5 -
 src/hb-ot-layout.cc|4 ++--
 src/hb-ot-layout.h |3 ++-
 src/hb-ot-shape-complex-arabic.cc  |1 +
 src/hb-ot-shape-complex-indic.cc   |1 +
 src/hb-ot-shape-complex-misc.cc|2 ++
 src/hb-ot-shape-complex-private.hh |2 ++
 src/hb-ot-shape.cc |   37 +
 src/hb-shape.cc|2 ++
 13 files changed, 80 insertions(+), 45 deletions(-)

New commits:
commit 0834d952017a04c6f4599e574cb75ecf3ca27d3b
Author: Behdad Esfahbod beh...@behdad.org
Date:   Wed Aug 1 00:21:09 2012 -0400

[hb-old] Adjust mark positioning parameters

Fallback mark positioning works now...  With hb-ft and hb-view /
hb-shape at least.

diff --git a/src/hb-old.cc b/src/hb-old.cc
index 1f6bf7f..9d1a005 100644
--- a/src/hb-old.cc
+++ b/src/hb-old.cc
@@ -149,12 +149,12 @@ hb_old_getGlyphMetrics (HB_Font old_font,
 
   hb_font_get_glyph_extents (font, glyph, extents);
 
-  metrics-xOffset = extents.x_bearing;
-  metrics-yOffset = extents.y_bearing;
+  metrics-x   = extents.x_bearing;
+  metrics-y   = extents.y_bearing;
   metrics-width   = extents.width;
-  metrics-height  = extents.height;
-  metrics-x   = hb_font_get_glyph_h_advance (font, glyph);
-  metrics-y   = 0;
+  metrics-height  = -extents.height;
+  metrics-xOffset = hb_font_get_glyph_h_advance (font, glyph);
+  metrics-yOffset = 0;
 }
 
 static HB_Fixed
diff --git a/src/hb-old/harfbuzz-shaper.cpp b/src/hb-old/harfbuzz-shaper.cpp
index 62886f3..f410780 100644
--- a/src/hb-old/harfbuzz-shaper.cpp
+++ b/src/hb-old/harfbuzz-shaper.cpp
@@ -63,6 +63,7 @@ static inline void positionCluster(HB_ShaperItem *item, int 
gfrom,  int glast)
 offsetBase += HB_FIXED_CONSTANT(4);
 else
 offsetBase += size;
+offsetBase = -offsetBase;
 //qreal offsetBase = (size - 4) / 4 + qMinqreal(size, 4) + 1;
 // qDebug(offset = %f, offsetBase);
 
commit 4ca743dfb8e09f9fa525061c7f1144d55f72effb
Author: Behdad Esfahbod beh...@behdad.org
Date:   Wed Aug 1 00:03:41 2012 -0400

[old] Implement fontMetrics

diff --git a/src/hb-old.cc b/src/hb-old.cc
index 84a431c..1f6bf7f 100644
--- a/src/hb-old.cc
+++ b/src/hb-old.cc
@@ -161,7 +161,16 @@ static HB_Fixed
 hb_old_getFontMetric (HB_Font old_font,
  HB_FontMetric metric)
 {
-  return 0; // TODO
+  hb_font_t *font = (hb_font_t *) old_font-userData;
+
+  switch (metric)
+  {
+case HB_FontAscent:
+   return font-y_scale; /* XXX We don't have ascent data yet. */
+
+default:
+  return 0;
+  }
 }
 
 static const HB_FontClass hb_old_font_class = {
commit 1e7d860613032e40a3f90e2caa2ee5ac44ab8c8c
Author: Behdad Esfahbod beh...@behdad.org
Date:   Tue Jul 31 23:41:06 2012 -0400

[GPOS] Adjust mark advance-width zeroing logic

If there is no GPOS, zero mark advances.

If there *is* GPOS and the shaper requests so, zero mark advances for
attached marks.

Fixes regression with Tibetan, where the font has GPOS, and marks a
glyph as mark where it shouldn't get zero advance.

diff --git a/src/hb-ot-layout-gpos-table.hh b/src/hb-ot-layout-gpos-table.hh
index 339749e..2e8a389 100644
--- a/src/hb-ot-layout-gpos-table.hh
+++ b/src/hb-ot-layout-gpos-table.hh
@@ -1587,7 +1587,7 @@ struct GPOS : GSUBGPOS
   { return get_lookup (lookup_index).apply_string (c); }
 
   static inline void position_start (hb_font_t *font, hb_buffer_t *buffer);
-  static inline void position_finish (hb_font_t *font, hb_buffer_t *buffer);
+  static inline void position_finish (hb_font_t *font, hb_buffer_t *buffer, 
hb_bool_t zero_width_attahced_marks);
 
   inline bool sanitize (hb_sanitize_context_t *c) {
 TRACE_SANITIZE ();
@@ -1620,15 +1620,17 @@ fix_cursive_minor_offset (hb_glyph_position_t *pos, 
unsigned int i, hb_direction
 }
 
 static void
-fix_mark_attachment (hb_glyph_position_t *pos, unsigned int i, hb_direction_t 
direction)
+fix_mark_attachment (hb_glyph_position_t *pos, unsigned int i, hb_direction_t 
direction, hb_bool_t zero_width_attached_marks)
 {
   if (likely (!(pos[i].attach_lookback(
 return;
 
   unsigned int j = i - pos[i].attach_lookback();
 
-//  pos[i].x_advance = 0;
-//  pos[i].y_advance = 0;
+  if (zero_width_attached_marks) {
+pos[i].x_advance = 0;
+pos[i].y_advance = 0;
+  }
   pos[i].x_offset += pos[j].x_offset;
   pos[i].y_offset += pos[j].y_offset;
 
@@ -1655,7 +1657,7 @@ GPOS::position_start (hb_font_t *font HB_UNUSED, 
hb_buffer_t *buffer)
 }
 
 void
-GPOS::position_finish (hb_font_t *font HB_UNUSED, hb_buffer_t *buffer)
+GPOS::position_finish (hb_font_t *font HB_UNUSED, hb_buffer_t *buffer, 
hb_bool_t