summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@behdad.org>2010-06-15 10:54:36 -0400
committerBehdad Esfahbod <behdad@behdad.org>2010-06-15 10:54:36 -0400
commit7dc0bb2b5aab78d8d7a299b54351bb0e9a4e888d (patch)
treec31624dce33d214a55d4d999146d6c80645c5a2b
parenta4ebb72cfb8814a4d3aee9fd0a02a56e998fe6c6 (diff)
parentcf1022c02c89d50a64743b1cf8d989817e4e1fd1 (diff)
downloadpango-7dc0bb2b5aab78d8d7a299b54351bb0e9a4e888d.tar.gz
Merge branch 'master' into 1.28
Conflicts: pango/Makefile.am
-rw-r--r--pango-view/Makefile.am2
-rw-r--r--pango-view/viewer-render.c41
-rw-r--r--pango/opentype/hb-open-file-private.hh3
-rw-r--r--pango/opentype/hb-open-type-private.hh69
-rw-r--r--pango/opentype/hb-ot-layout-common-private.hh18
-rw-r--r--pango/opentype/hb-ot-layout-gdef-private.hh4
-rw-r--r--pango/opentype/hb-ot-layout-gpos-private.hh183
-rw-r--r--pango/opentype/hb-ot-layout-gsub-private.hh12
-rw-r--r--pango/opentype/hb-ot-layout-gsubgpos-private.hh8
-rw-r--r--pango/opentype/hb-private.h2
-rw-r--r--pango/pango-gravity.c2
-rw-r--r--pango/pango-ot-info.c4
-rw-r--r--pango/pangocairo-atsuifont.c31
-rw-r--r--pango/pangocairo-fcfont.c8
-rw-r--r--pango/pangocairo-font.c83
-rw-r--r--pango/pangocairo-private.h6
-rw-r--r--pango/pangocairo-win32font.c31
-rw-r--r--pango/pangofc-font.c51
-rw-r--r--pango/pangofc-private.h4
-rw-r--r--pango/pangoft2.def2
20 files changed, 335 insertions, 229 deletions
diff --git a/pango-view/Makefile.am b/pango-view/Makefile.am
index 2721f970..dbfd81a0 100644
--- a/pango-view/Makefile.am
+++ b/pango-view/Makefile.am
@@ -93,7 +93,7 @@ nodist_man_MANS = pango-view.1
# The indirection through pango-view.1.in is to make parallel build work.
# See bug 587768.
$(srcdir)/pango-view.1.in: ../configure.in $(pango_view_SOURCES)
- $(AM_V_GEN) $(top_builddir)/missing --run \
+ $(AM_V_GEN) $(top_srcdir)/missing --run \
help2man --no-info --section=1 \
--help-option="--help-all" --output="$@.tmp" \
--name 'Pango text viewer' ./pango-view \
diff --git a/pango-view/viewer-render.c b/pango-view/viewer-render.c
index e672dcd4..8e3cc7f8 100644
--- a/pango-view/viewer-render.c
+++ b/pango-view/viewer-render.c
@@ -38,7 +38,10 @@ gboolean opt_pixels = FALSE;
const char *opt_font = "";
gboolean opt_header = FALSE;
const char *opt_output = NULL;
-int opt_margin = 10;
+int opt_margin_t = 10;
+int opt_margin_r = 10;
+int opt_margin_b = 10;
+int opt_margin_l = 10;
int opt_markup = FALSE;
gboolean opt_rtl = FALSE;
double opt_rotate = 0;
@@ -248,8 +251,8 @@ do_output (PangoContext *context,
PangoMatrix *orig_matrix;
gboolean supports_matrix;
int rotated_width, rotated_height;
- int x = opt_margin;
- int y = opt_margin;
+ int x = opt_margin_l;
+ int y = opt_margin_t;
int width, height;
width = 0;
@@ -331,8 +334,8 @@ do_output (PangoContext *context,
width = MAX (width, rect.width);
height += rect.height;
- width += 2 * opt_margin;
- height += 2 * opt_margin;
+ width += opt_margin_l + opt_margin_r;
+ height += opt_margin_t + opt_margin_b;
if (width_out)
*width_out = width;
@@ -543,6 +546,30 @@ parse_background (const char *name,
name, arg, data, error);
}
+static gboolean
+parse_margin (const char *name G_GNUC_UNUSED,
+ const char *arg,
+ gpointer data G_GNUC_UNUSED,
+ GError **error)
+{
+ switch (sscanf (arg, "%d %d %d %d", &opt_margin_t, &opt_margin_r, &opt_margin_b, &opt_margin_l))
+ {
+ case 0:
+ {
+ g_set_error(error,
+ G_OPTION_ERROR,
+ G_OPTION_ERROR_BAD_VALUE,
+ "Argument for --margin must be one to four space-separated numbers");
+ return FALSE;
+ }
+ case 1: opt_margin_r = opt_margin_t;
+ case 2: opt_margin_b = opt_margin_t;
+ case 3: opt_margin_l = opt_margin_r;
+ }
+ return TRUE;
+}
+
+
static gchar *
backends_to_string (void)
{
@@ -680,8 +707,8 @@ parse_options (int argc, char *argv[])
"Align paragraph lines to be justified", NULL},
{"language", 0, 0, G_OPTION_ARG_STRING, &opt_language,
"Language to use for font selection", "en_US/etc"},
- {"margin", 0, 0, G_OPTION_ARG_INT, &opt_margin,
- "Set the margin on the output in pixels", "pixels"},
+ {"margin", 0, 0, G_OPTION_ARG_CALLBACK, &parse_margin,
+ "Set the margin on the output in pixels", "CSS-style numbers in pixels"},
{"markup", 0, 0, G_OPTION_ARG_NONE, &opt_markup,
"Interpret text as Pango markup", NULL},
{"output", 'o', 0, G_OPTION_ARG_STRING, &opt_output,
diff --git a/pango/opentype/hb-open-file-private.hh b/pango/opentype/hb-open-file-private.hh
index 0947747d..080975b7 100644
--- a/pango/opentype/hb-open-file-private.hh
+++ b/pango/opentype/hb-open-file-private.hh
@@ -84,7 +84,8 @@ typedef struct OffsetTable
}
inline bool find_table_index (hb_tag_t tag, unsigned int *table_index) const
{
- const Tag t = tag;
+ Tag t;
+ t.set (tag);
// TODO bsearch
unsigned int count = numTables;
for (unsigned int i = 0; i < count; i++)
diff --git a/pango/opentype/hb-open-type-private.hh b/pango/opentype/hb-open-type-private.hh
index 06324ee3..9e99175a 100644
--- a/pango/opentype/hb-open-type-private.hh
+++ b/pango/opentype/hb-open-type-private.hh
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2007,2008,2009 Red Hat, Inc.
+ * Copyright (C) 2007,2008,2009,2010 Red Hat, Inc.
*
* This is part of HarfBuzz, an OpenType Layout engine library.
*
@@ -61,33 +61,27 @@
/* Null objects */
/* Global nul-content Null pool. Enlarge as necessary. */
-static const void *NullPool[32 / sizeof (void *)];
+static const void *_NullPool[32 / sizeof (void *)];
/* Generic template for nul-content sizeof-sized Null objects. */
template <typename Type>
-struct Null
-{
- ASSERT_STATIC (sizeof (Type) <= sizeof (NullPool));
- static inline const Type &get () { return CONST_CAST (Type, *NullPool, 0); }
-};
+static inline const Type& Null () {
+ ASSERT_STATIC (sizeof (Type) <= sizeof (_NullPool));
+ return CONST_CAST (Type, *_NullPool, 0);
+}
/* Specializaiton for arbitrary-content arbitrary-sized Null objects. */
#define DEFINE_NULL_DATA(Type, size, data) \
-static const char _Null##Type[size] = data; \
+static const char _Null##Type[size + 1] = data; \
template <> \
-struct Null <Type> \
-{ \
- static inline const Type &get () { return CONST_CAST (Type, *_Null##Type, 0); } \
+inline const Type& Null<Type> () { \
+ return CONST_CAST (Type, *_Null##Type, 0); \
}
/* Accessor macro. */
-#define Null(Type) (Null<Type>::get())
+#define Null(Type) Null<Type>()
-#define ASSERT_SIZE_DATA(Type, size, data) \
- ASSERT_SIZE (Type, size); \
- DEFINE_NULL_DATA (Type, size, data)
-
/* get_for_data() is a static class method returning a reference to an
* instance of Type located at the input data location. It's just a
* fancy, NULL-safe, cast! */
@@ -117,14 +111,14 @@ struct Null <Type> \
#endif
#if HB_DEBUG_SANITIZE
-#define TRACE_SANITIZE_ARG_DEF , unsigned int sanitize_depth
+#define TRACE_SANITIZE_ARG_DEF , unsigned int sanitize_depth HB_GNUC_UNUSED
#define TRACE_SANITIZE_ARG , sanitize_depth + 1
#define TRACE_SANITIZE_ARG_INIT , 1
#define TRACE_SANITIZE() \
HB_STMT_START { \
if (sanitize_depth < HB_DEBUG_SANITIZE) \
fprintf (stderr, "SANITIZE(%p) %-*d-> %s\n", \
- (CONST_CHARP (this) == NullPool) ? 0 : this, \
+ (CONST_CHARP (this) == CONST_CHARP (&NullPool)) ? 0 : this, \
sanitize_depth, sanitize_depth, \
__PRETTY_FUNCTION__); \
} HB_STMT_END
@@ -253,7 +247,6 @@ _hb_sanitize_edit (SANITIZE_ARG_DEF,
#define SANITIZE_OBJ(X) SANITIZE_MEM(&(X), sizeof (X))
#define SANITIZE_GET_SIZE() SANITIZE_SELF() && SANITIZE_MEM (this, this->get_size ())
-/* TODO Optimize this if L is fixed (gcc magic) */
#define SANITIZE_MEM(B,L) HB_LIKELY (_hb_sanitize_check (SANITIZE_ARG, CONST_CHARP(B), (L)))
#define SANITIZE_ARRAY(A,S,L) HB_LIKELY (_hb_sanitize_array (SANITIZE_ARG, CONST_CHARP(A), S, L))
@@ -350,7 +343,7 @@ struct Sanitizer
{ \
inline NAME& set (TYPE i) { (TYPE&) v = BIG_ENDIAN (i); return *this; } \
inline operator TYPE(void) const { return BIG_ENDIAN ((TYPE&) v); } \
- inline bool operator== (NAME o) const { return (TYPE&) v == (TYPE&) o.v; } \
+ inline bool operator == (const NAME &o) const { return (TYPE&) v == (TYPE&) o.v; } \
inline bool sanitize (SANITIZE_ARG_DEF) { \
TRACE_SANITIZE (); \
return SANITIZE_SELF (); \
@@ -363,9 +356,9 @@ struct Sanitizer
struct NAME \
{ \
static inline unsigned int get_size () { return BYTES; } \
- inline NAME& set (TYPE i) { BIG_ENDIAN##_put_unaligned(v, i); return *this; } \
+ inline void set (TYPE i) { BIG_ENDIAN##_put_unaligned(v, i); } \
inline operator TYPE(void) const { return BIG_ENDIAN##_get_unaligned (v); } \
- inline bool operator== (NAME o) const { return BIG_ENDIAN##_cmp_unaligned (v, o.v); } \
+ inline bool operator == (const NAME &o) const { return BIG_ENDIAN##_cmp_unaligned (v, o.v); } \
inline bool sanitize (SANITIZE_ARG_DEF) { \
TRACE_SANITIZE (); \
return SANITIZE_SELF (); \
@@ -387,10 +380,6 @@ DEFINE_INT_TYPE (LONG, , 32); /* 32-bit signed integer. */
* system, feature, or baseline */
struct Tag : ULONG
{
- inline Tag (const Tag &o) { *(ULONG*)this = (ULONG&) o; }
- inline Tag (uint32_t i) { (*(ULONG*)this).set (i); }
- inline Tag (const char *c) { *(ULONG*)this = *(ULONG*)c; }
- inline bool operator== (const char *c) const { return *(ULONG*)this == *(ULONG*)c; }
/* What the char* converters return is NOT nul-terminated. Print using "%.4s" */
inline operator const char* (void) const { return CONST_CHARP(this); }
inline operator char* (void) { return CHARP(this); }
@@ -405,9 +394,7 @@ struct Tag : ULONG
}
};
ASSERT_SIZE (Tag, 4);
-#define _NULL_TAG_INIT {' ', ' ', ' ', ' '}
-DEFINE_NULL_DATA (Tag, 4, _NULL_TAG_INIT);
-#undef _NULL_TAG_INIT
+DEFINE_NULL_DATA (Tag, 4, " ");
/* Glyph index number, same as uint16 (length = 16 bits) */
typedef USHORT GlyphID;
@@ -463,7 +450,7 @@ ASSERT_SIZE (FixedVersion, 4);
template <typename OffsetType, typename Type>
struct GenericOffsetTo : OffsetType
{
- inline const Type& operator() (const void *base) const
+ inline const Type& operator () (const void *base) const
{
unsigned int offset = *this;
if (HB_UNLIKELY (!offset)) return Null(Type);
@@ -523,11 +510,14 @@ struct GenericArrayOf
inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE ();
if (!SANITIZE_GET_SIZE()) return false;
- /* Note:
- * for non-recursive types, this is not much needed.
- * But we keep the code to make sure the objects pointed to
- * do have a simple sanitize(). */
+ /* Note: for structs that do not reference other structs,
+ * we do not need to call their sanitize() as we already did
+ * a bound check on the aggregate array size, hence the return.
+ */
return true;
+ /* We do keep this code though to make sure the structs pointed
+ * to do have a simple sanitize(), ie. they do not reference
+ * other structs. */
unsigned int count = len;
for (unsigned int i = 0; i < count; i++)
if (!SANITIZE (array()[i]))
@@ -626,11 +616,14 @@ struct HeadlessArrayOf
inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE ();
if (!SANITIZE_GET_SIZE()) return false;
- /* Note:
- * for non-recursive types, this is not much needed.
- * But we keep the code to make sure the objects pointed to
- * do have a simple sanitize(). */
+ /* Note: for structs that do not reference other structs,
+ * we do not need to call their sanitize() as we already did
+ * a bound check on the aggregate array size, hence the return.
+ */
return true;
+ /* We do keep this code though to make sure the structs pointed
+ * to do have a simple sanitize(), ie. they do not reference
+ * other structs. */
unsigned int count = len ? len - 1 : 0;
Type *a = array();
for (unsigned int i = 0; i < count; i++)
diff --git a/pango/opentype/hb-ot-layout-common-private.hh b/pango/opentype/hb-ot-layout-common-private.hh
index aff14689..1f6cf4a2 100644
--- a/pango/opentype/hb-ot-layout-common-private.hh
+++ b/pango/opentype/hb-ot-layout-common-private.hh
@@ -84,7 +84,8 @@ struct RecordArrayOf : ArrayOf<Record<Type> > {
}
inline bool find_index (hb_tag_t tag, unsigned int *index) const
{
- const Tag t = tag;
+ Tag t;
+ t.set (tag);
// TODO bsearch
const Record<Type> *a = this->const_array();
unsigned int count = this->len;
@@ -171,7 +172,8 @@ struct LangSys
* = 0xFFFF */
IndexArray featureIndex; /* Array of indices into the FeatureList */
};
-ASSERT_SIZE_DATA (LangSys, 6, "\0\0\xFF\xFF");
+ASSERT_SIZE (LangSys, 6);
+DEFINE_NULL_DATA (LangSys, 6, "\0\0\xFF\xFF");
struct Script
@@ -372,7 +374,8 @@ struct CoverageRangeRecord
USHORT startCoverageIndex; /* Coverage Index of first GlyphID in
* range */
};
-ASSERT_SIZE_DATA (CoverageRangeRecord, 6, "\000\001");
+ASSERT_SIZE (CoverageRangeRecord, 6);
+DEFINE_NULL_DATA (CoverageRangeRecord, 6, "\000\001");
struct CoverageFormat2
{
@@ -408,7 +411,7 @@ ASSERT_SIZE (CoverageFormat2, 4);
struct Coverage
{
- inline unsigned int operator() (hb_codepoint_t glyph_id) const { return get_coverage (glyph_id); }
+ inline unsigned int operator () (hb_codepoint_t glyph_id) const { return get_coverage (glyph_id); }
inline unsigned int get_coverage (hb_codepoint_t glyph_id) const
{
@@ -491,7 +494,8 @@ struct ClassRangeRecord
GlyphID end; /* Last GlyphID in the range */
USHORT classValue; /* Applied to all glyphs in the range */
};
-ASSERT_SIZE_DATA (ClassRangeRecord, 6, "\000\001");
+ASSERT_SIZE (ClassRangeRecord, 6);
+DEFINE_NULL_DATA (ClassRangeRecord, 6, "\000\001");
struct ClassDefFormat2
{
@@ -525,7 +529,7 @@ ASSERT_SIZE (ClassDefFormat2, 4);
struct ClassDef
{
- inline unsigned int operator() (hb_codepoint_t glyph_id) const { return get_class (glyph_id); }
+ inline hb_ot_layout_class_t operator () (hb_codepoint_t glyph_id) const { return get_class (glyph_id); }
inline hb_ot_layout_class_t get_class (hb_codepoint_t glyph_id) const
{
@@ -561,7 +565,7 @@ struct ClassDef
struct Device
{
- inline int operator() (unsigned int ppem_size) const { return get_delta (ppem_size); }
+ inline int operator () (unsigned int ppem_size) const { return get_delta (ppem_size); }
inline int get_delta (unsigned int ppem_size) const
{
diff --git a/pango/opentype/hb-ot-layout-gdef-private.hh b/pango/opentype/hb-ot-layout-gdef-private.hh
index 69f90fec..f6480542 100644
--- a/pango/opentype/hb-ot-layout-gdef-private.hh
+++ b/pango/opentype/hb-ot-layout-gdef-private.hh
@@ -87,7 +87,7 @@ struct CaretValueFormat1
friend struct CaretValue;
private:
- inline int get_caret_value (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id) const
+ inline int get_caret_value (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id HB_GNUC_UNUSED) const
{
/* TODO vertical */
return context->font->x_scale * coordinate / 0x10000;
@@ -129,7 +129,7 @@ struct CaretValueFormat3
{
friend struct CaretValue;
- inline int get_caret_value (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id) const
+ inline int get_caret_value (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id HB_GNUC_UNUSED) const
{
/* TODO vertical */
return context->font->x_scale * coordinate / 0x10000 +
diff --git a/pango/opentype/hb-ot-layout-gpos-private.hh b/pango/opentype/hb-ot-layout-gpos-private.hh
index be7b5a5c..e68739ed 100644
--- a/pango/opentype/hb-ot-layout-gpos-private.hh
+++ b/pango/opentype/hb-ot-layout-gpos-private.hh
@@ -51,30 +51,13 @@ struct ValueFormat : USHORT
xAdvDevice = 0x0040, /* Includes horizontal Device table for advance */
yAdvDevice = 0x0080, /* Includes vertical Device table for advance */
ignored = 0x0F00, /* Was used in TrueType Open for MM fonts */
- reserved = 0xF000 /* For future use */
- };
-
- inline unsigned int get_len () const
- { return _hb_popcount32 ((unsigned int) *this); }
- inline unsigned int get_size () const
- { return get_len () * Value::get_size (); }
+ reserved = 0xF000, /* For future use */
- void apply_value (hb_ot_layout_context_t *context,
- const char *base,
- const Value *values,
- hb_internal_glyph_position_t *glyph_pos) const
- {
- unsigned int x_ppem, y_ppem;
- hb_16dot16_t x_scale, y_scale;
- unsigned int format = *this;
-
- if (!format)
- return;
+ devices = 0x00F0 /* Mask for having any Device table */
+ };
- /* All fields are options. Only those available advance the value
- * pointer. */
+/* All fields are options. Only those available advance the value pointer. */
#if 0
-struct ValueRecord {
SHORT xPlacement; /* Horizontal adjustment for
* placement--in design units */
SHORT yPlacement; /* Vertical adjustment for
@@ -97,20 +80,35 @@ struct ValueRecord {
Offset yAdvDevice; /* Offset to Device table for vertical
* advance--measured from beginning of
* PosTable (may be NULL) */
-};
#endif
+ inline unsigned int get_len () const
+ { return _hb_popcount32 ((unsigned int) *this); }
+ inline unsigned int get_size () const
+ { return get_len () * Value::get_size (); }
+
+ void apply_value (hb_ot_layout_context_t *context,
+ const char *base,
+ const Value *values,
+ hb_internal_glyph_position_t *glyph_pos) const
+ {
+ unsigned int x_ppem, y_ppem;
+ hb_16dot16_t x_scale, y_scale;
+ unsigned int format = *this;
+
+ if (!format) return;
+
x_scale = context->font->x_scale;
y_scale = context->font->y_scale;
/* design units -> fractional pixel */
if (format & xPlacement)
- glyph_pos->x_pos += _hb_16dot16_mul_trunc (x_scale, *(SHORT*)values++);
+ glyph_pos->x_pos += _hb_16dot16_mul_round (x_scale, *(SHORT*)values++);
if (format & yPlacement)
- glyph_pos->y_pos += _hb_16dot16_mul_trunc (y_scale, *(SHORT*)values++);
+ glyph_pos->y_pos += _hb_16dot16_mul_round (y_scale, *(SHORT*)values++);
if (format & xAdvance)
- glyph_pos->x_advance += _hb_16dot16_mul_trunc (x_scale, *(SHORT*)values++);
+ glyph_pos->x_advance += _hb_16dot16_mul_round (x_scale, *(SHORT*)values++);
if (format & yAdvance)
- glyph_pos->y_advance += _hb_16dot16_mul_trunc (y_scale, *(SHORT*)values++);
+ glyph_pos->y_advance += _hb_16dot16_mul_round (y_scale, *(SHORT*)values++);
x_ppem = context->font->x_ppem;
y_ppem = context->font->y_ppem;
@@ -140,6 +138,68 @@ struct ValueRecord {
values++;
}
}
+
+ private:
+ inline bool sanitize_value_devices (SANITIZE_ARG_DEF, void *base, const Value *values) {
+ unsigned int format = *this;
+
+ if (format & xPlacement) values++;
+ if (format & yPlacement) values++;
+ if (format & xAdvance) values++;
+ if (format & yAdvance) values++;
+
+ if ((format & xPlaDevice) && !SANITIZE_BASE (*(OffsetTo<Device>*)values++, base)) return false;
+ if ((format & yPlaDevice) && !SANITIZE_BASE (*(OffsetTo<Device>*)values++, base)) return false;
+ if ((format & xAdvDevice) && !SANITIZE_BASE (*(OffsetTo<Device>*)values++, base)) return false;
+ if ((format & yAdvDevice) && !SANITIZE_BASE (*(OffsetTo<Device>*)values++, base)) return false;
+
+ return true;
+ }
+
+ public:
+
+ inline bool has_device () {
+ unsigned int format = *this;
+ return (format & devices) != 0;
+ }
+
+ inline bool sanitize_value (SANITIZE_ARG_DEF, void *base, const Value *values) {
+ TRACE_SANITIZE ();
+
+ return SANITIZE_MEM (values, get_size ()) &&
+ (!has_device () || sanitize_value_devices (SANITIZE_ARG, base, values));
+ }
+
+ inline bool sanitize_values (SANITIZE_ARG_DEF, void *base, const Value *values, unsigned int count) {
+ TRACE_SANITIZE ();
+ unsigned int len = get_len ();
+
+ if (!SANITIZE_ARRAY (values, get_size (), count)) return false;
+
+ if (!has_device ()) return true;
+
+ for (unsigned int i = 0; i < count; i++) {
+ if (!sanitize_value_devices (SANITIZE_ARG, base, values))
+ return false;
+ values += len;
+ }
+
+ return true;
+ }
+
+ inline bool sanitize_values_stride_unsafe (SANITIZE_ARG_DEF, void *base, const Value *values, unsigned int count, unsigned int stride) {
+ TRACE_SANITIZE ();
+
+ if (!has_device ()) return true;
+
+ for (unsigned int i = 0; i < count; i++) {
+ if (!sanitize_value_devices (SANITIZE_ARG, base, values))
+ return false;
+ values += stride;
+ }
+
+ return true;
+ }
};
ASSERT_SIZE (ValueFormat, 2);
@@ -149,11 +209,11 @@ struct AnchorFormat1
friend struct Anchor;
private:
- inline void get_anchor (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id,
+ inline void get_anchor (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id HB_GNUC_UNUSED,
hb_position_t *x, hb_position_t *y) const
{
- *x = _hb_16dot16_mul_trunc (context->font->x_scale, xCoordinate);
- *y = _hb_16dot16_mul_trunc (context->font->y_scale, yCoordinate);
+ *x = _hb_16dot16_mul_round (context->font->x_scale, xCoordinate);
+ *y = _hb_16dot16_mul_round (context->font->y_scale, yCoordinate);
}
inline bool sanitize (SANITIZE_ARG_DEF) {
@@ -177,8 +237,8 @@ struct AnchorFormat2
hb_position_t *x, hb_position_t *y) const
{
/* TODO Contour */
- *x = _hb_16dot16_mul_trunc (context->font->x_scale, xCoordinate);
- *y = _hb_16dot16_mul_trunc (context->font->y_scale, yCoordinate);
+ *x = _hb_16dot16_mul_round (context->font->x_scale, xCoordinate);
+ *y = _hb_16dot16_mul_round (context->font->y_scale, yCoordinate);
}
inline bool sanitize (SANITIZE_ARG_DEF) {
@@ -199,11 +259,11 @@ struct AnchorFormat3
friend struct Anchor;
private:
- inline void get_anchor (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id,
+ inline void get_anchor (hb_ot_layout_context_t *context, hb_codepoint_t glyph_id HB_GNUC_UNUSED,
hb_position_t *x, hb_position_t *y) const
{
- *x = _hb_16dot16_mul_trunc (context->font->x_scale, xCoordinate);
- *y = _hb_16dot16_mul_trunc (context->font->y_scale, yCoordinate);
+ *x = _hb_16dot16_mul_round (context->font->x_scale, xCoordinate);
+ *y = _hb_16dot16_mul_round (context->font->y_scale, yCoordinate);
/* pixel -> fractional pixel */
if (context->font->x_ppem)
@@ -377,7 +437,7 @@ struct SinglePosFormat1
inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE ();
return SANITIZE_SELF () && SANITIZE_THIS (coverage) &&
- SANITIZE_MEM (values, valueFormat.get_size ());
+ valueFormat.sanitize_value (SANITIZE_ARG, CHARP(this), values);
}
private:
@@ -419,7 +479,7 @@ struct SinglePosFormat2
inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE ();
return SANITIZE_SELF () && SANITIZE_THIS (coverage) &&
- SANITIZE_MEM (values, valueFormat.get_size () * valueCount);
+ valueFormat.sanitize_values (SANITIZE_ARG, CHARP(this), values, valueCount);
}
private:
@@ -486,6 +546,7 @@ struct PairSet
{
friend struct PairPosFormat1;
+ /* Note: Doesn't sanitize the Device entries in the ValueRecord */
inline bool sanitize (SANITIZE_ARG_DEF, unsigned int format_len) {
TRACE_SANITIZE ();
if (!SANITIZE_SELF ()) return false;
@@ -525,12 +586,11 @@ struct PairPosFormat1
j++;
}
- const PairSet &pair_set = this+pairSet[index];
-
unsigned int len1 = valueFormat1.get_len ();
unsigned int len2 = valueFormat2.get_len ();
unsigned int record_size = USHORT::get_size () * (1 + len1 + len2);
+ const PairSet &pair_set = this+pairSet[index];
unsigned int count = pair_set.len;
const PairValueRecord *record = pair_set.array;
for (unsigned int i = 0; i < count; i++)
@@ -552,9 +612,29 @@ struct PairPosFormat1
inline bool sanitize (SANITIZE_ARG_DEF) {
TRACE_SANITIZE ();
- return SANITIZE_SELF () && SANITIZE_THIS (coverage) &&
- pairSet.sanitize (SANITIZE_ARG, CONST_CHARP(this),
- valueFormat1.get_len () + valueFormat2.get_len ());
+
+ unsigned int len1 = valueFormat1.get_len ();
+ unsigned int len2 = valueFormat2.get_len ();
+
+ if (!(SANITIZE_SELF () && SANITIZE_THIS (coverage) &&
+ pairSet.sanitize (SANITIZE_ARG, CONST_CHARP(this), len1 + len2))) return false;
+
+ if (!(valueFormat1.has_device () || valueFormat2.has_device ())) return true;
+
+ unsigned int stride = 1 + len1 + len2;
+ unsigned int count1 = pairSet.len;
+ for (unsigned int i = 0; i < count1; i++)
+ {
+ const PairSet &pair_set = this+pairSet[i];
+
+ unsigned int count2 = pair_set.len;
+ const PairValueRecord *record = pair_set.array;
+ if (!(valueFormat1.sanitize_values_stride_unsafe (SANITIZE_ARG, CHARP(this), &record->values[0], count2, stride) &&
+ valueFormat2.sanitize_values_stride_unsafe (SANITIZE_ARG, CHARP(this), &record->values[len1], count2, stride)))
+ return false;
+ }
+
+ return true;
}
private:
@@ -623,9 +703,14 @@ struct PairPosFormat2
if (!(SANITIZE_SELF () && SANITIZE_THIS (coverage) &&
SANITIZE_THIS2 (classDef1, classDef2))) return false;
+ unsigned int len1 = valueFormat1.get_len ();
+ unsigned int len2 = valueFormat2.get_len ();
+ unsigned int stride = len1 + len2;
unsigned int record_size = valueFormat1.get_size () + valueFormat2.get_size ();
- unsigned int len = class1Count * class2Count;
- return SANITIZE_ARRAY (values, record_size, len);
+ unsigned int count = (unsigned int) class1Count * (unsigned int) class2Count;
+ return SANITIZE_ARRAY (values, record_size, count) &&
+ valueFormat1.sanitize_values_stride_unsafe (SANITIZE_ARG, CHARP(this), &values[0], count, stride) &&
+ valueFormat2.sanitize_values_stride_unsafe (SANITIZE_ARG, CHARP(this), &values[len1], count, stride);
}
private:
@@ -1334,10 +1419,10 @@ struct PosLookupSubTable
}
}
- inline bool sanitize (SANITIZE_ARG_DEF) {
+ inline bool sanitize (SANITIZE_ARG_DEF, unsigned int lookup_type) {
TRACE_SANITIZE ();
- if (!SANITIZE (u.format)) return false;
- switch (u.format) {
+ if (!SANITIZE (u.sub_format)) return false;
+ switch (lookup_type) {
case Single: return u.single->sanitize (SANITIZE_ARG);
case Pair: return u.pair->sanitize (SANITIZE_ARG);
case Cursive: return u.cursive->sanitize (SANITIZE_ARG);
@@ -1353,7 +1438,7 @@ struct PosLookupSubTable
private:
union {
- USHORT format;
+ USHORT sub_format;
SinglePos single[VAR];
PairPos pair[VAR];
CursivePos cursive[VAR];
@@ -1450,7 +1535,7 @@ struct PosLookup : Lookup
TRACE_SANITIZE ();
if (!Lookup::sanitize (SANITIZE_ARG)) return false;
OffsetArrayOf<PosLookupSubTable> &list = (OffsetArrayOf<PosLookupSubTable> &) subTable;
- return SANITIZE_THIS (list);
+ return list.sanitize (SANITIZE_ARG, this, get_type ());
}
};
@@ -1506,7 +1591,7 @@ inline bool ExtensionPos::sanitize (SANITIZE_ARG_DEF)
return Extension::sanitize (SANITIZE_ARG) &&
(&(Extension::get_subtable ()) == &Null(LookupSubTable) ||
get_type () == PosLookupSubTable::Extension ||
- DECONST_CAST (PosLookupSubTable, get_subtable (), 0).sanitize (SANITIZE_ARG));
+ DECONST_CAST (PosLookupSubTable, get_subtable (), 0).sanitize (SANITIZE_ARG, get_type ()));
}
static inline bool position_lookup (APPLY_ARG_DEF, unsigned int lookup_index)
diff --git a/pango/opentype/hb-ot-layout-gsub-private.hh b/pango/opentype/hb-ot-layout-gsub-private.hh
index d35aaff1..a9f78c24 100644
--- a/pango/opentype/hb-ot-layout-gsub-private.hh
+++ b/pango/opentype/hb-ot-layout-gsub-private.hh
@@ -702,10 +702,10 @@ struct SubstLookupSubTable
}
}
- inline bool sanitize (SANITIZE_ARG_DEF) {
+ inline bool sanitize (SANITIZE_ARG_DEF, unsigned int lookup_type) {
TRACE_SANITIZE ();
- if (!SANITIZE (u.format)) return false;
- switch (u.format) {
+ if (!SANITIZE (u.sub_format)) return false;
+ switch (lookup_type) {
case Single: return u.single->sanitize (SANITIZE_ARG);
case Multiple: return u.multiple->sanitize (SANITIZE_ARG);
case Alternate: return u.alternate->sanitize (SANITIZE_ARG);
@@ -720,7 +720,7 @@ struct SubstLookupSubTable
private:
union {
- USHORT format;
+ USHORT sub_format;
SingleSubst single[VAR];
MultipleSubst multiple[VAR];
AlternateSubst alternate[VAR];
@@ -830,7 +830,7 @@ struct SubstLookup : Lookup
TRACE_SANITIZE ();
if (!Lookup::sanitize (SANITIZE_ARG)) return false;
OffsetArrayOf<SubstLookupSubTable> &list = (OffsetArrayOf<SubstLookupSubTable> &) subTable;
- return SANITIZE_THIS (list);
+ return list.sanitize (SANITIZE_ARG, this, get_type ());
}
};
@@ -887,7 +887,7 @@ inline bool ExtensionSubst::sanitize (SANITIZE_ARG_DEF)
return Extension::sanitize (SANITIZE_ARG) &&
(&(Extension::get_subtable ()) == &Null(LookupSubTable) ||
get_type () == SubstLookupSubTable::Extension ||
- DECONST_CAST (SubstLookupSubTable, get_subtable (), 0).sanitize (SANITIZE_ARG));
+ DECONST_CAST (SubstLookupSubTable, get_subtable (), 0).sanitize (SANITIZE_ARG, get_type ()));
}
static inline bool substitute_lookup (APPLY_ARG_DEF, unsigned int lookup_index)
diff --git a/pango/opentype/hb-ot-layout-gsubgpos-private.hh b/pango/opentype/hb-ot-layout-gsubgpos-private.hh
index 0e15cf60..0bb96a41 100644
--- a/pango/opentype/hb-ot-layout-gsubgpos-private.hh
+++ b/pango/opentype/hb-ot-layout-gsubgpos-private.hh
@@ -36,14 +36,14 @@
#endif
#if HB_DEBUG_APPLY
-#define TRACE_APPLY_ARG_DEF , unsigned int apply_depth
+#define TRACE_APPLY_ARG_DEF , unsigned int apply_depth HB_GNUC_UNUSED
#define TRACE_APPLY_ARG , apply_depth + 1
#define TRACE_APPLY_ARG_INIT , 1
#define TRACE_APPLY() \
HB_STMT_START { \
if (apply_depth < HB_DEBUG_APPLY) \
fprintf (stderr, "APPLY(%p) %-*d-> %s\n", \
- (CONST_CHARP (this) == NullPool) ? 0 : this, \
+ (CONST_CHARP (this) == CONST_CHARP (&NullPool)) ? 0 : this, \
apply_depth, apply_depth, \
__PRETTY_FUNCTION__); \
} HB_STMT_END
@@ -59,7 +59,7 @@
hb_buffer_t *buffer, \
unsigned int context_length HB_GNUC_UNUSED, \
unsigned int nesting_level_left HB_GNUC_UNUSED, \
- unsigned int lookup_flag, \
+ unsigned int lookup_flag HB_GNUC_UNUSED, \
unsigned int property HB_GNUC_UNUSED /* propety of first glyph */ \
TRACE_APPLY_ARG_DEF
#define APPLY_ARG \
@@ -90,7 +90,7 @@ struct ContextFuncs
};
-static inline bool match_glyph (hb_codepoint_t glyph_id, const USHORT &value, char *data)
+static inline bool match_glyph (hb_codepoint_t glyph_id, const USHORT &value, char *data HB_GNUC_UNUSED)
{
return glyph_id == value;
}
diff --git a/pango/opentype/hb-private.h b/pango/opentype/hb-private.h
index b17b24a0..92e514f7 100644
--- a/pango/opentype/hb-private.h
+++ b/pango/opentype/hb-private.h
@@ -207,7 +207,7 @@ _hb_popcount32 (uint32_t mask)
/* Multiplies a 16dot16 value by another value, then truncates the result */
-#define _hb_16dot16_mul_trunc(A,B) ((int64_t) (A) * (B) / 0x10000)
+#define _hb_16dot16_mul_round(A,B) (((int64_t) (A) * (B) + 0x8000) / 0x10000)
#include "hb-object-private.h"
diff --git a/pango/pango-gravity.c b/pango/pango-gravity.c
index 297199a5..7553a07e 100644
--- a/pango/pango-gravity.c
+++ b/pango/pango-gravity.c
@@ -182,7 +182,7 @@ const PangoScriptProperties script_properties[] =
/* Unicode-4.0 additions */
{LTR, NONE, S, FALSE}, /* Brai */
- {LTR, NONE, S, FALSE}, /* Cprt */
+ {RTL, NONE, S, FALSE}, /* Cprt */
{LTR, NONE, S, FALSE}, /* Limb */
{LTR, NONE, S, FALSE}, /* Osma */
{LTR, NONE, S, FALSE}, /* Shaw */
diff --git a/pango/pango-ot-info.c b/pango/pango-ot-info.c
index 4216611a..f98229a4 100644
--- a/pango/pango-ot-info.c
+++ b/pango/pango-ot-info.c
@@ -211,14 +211,14 @@ get_glyph_class (gunichar charcode,
case G_UNICODE_COMBINING_MARK:
case G_UNICODE_ENCLOSING_MARK:
case G_UNICODE_NON_SPACING_MARK:
- *class = 3; /* Mark glyph (non-spacing combining glyph) */
+ *class = HB_OT_LAYOUT_GLYPH_CLASS_MARK; /* Mark glyph (non-spacing combining glyph) */
return TRUE;
case G_UNICODE_UNASSIGNED:
case G_UNICODE_PRIVATE_USE:
return FALSE; /* Unknown, don't assign a class; classes get
* propagated during GSUB application */
default:
- *class = 1; /* Base glyph (single character, spacing glyph) */
+ *class = HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH; /* Base glyph (single character, spacing glyph) */
return TRUE;
}
}
diff --git a/pango/pangocairo-atsuifont.c b/pango/pangocairo-atsuifont.c
index 3abaffff..1c1ba550 100644
--- a/pango/pangocairo-atsuifont.c
+++ b/pango/pangocairo-atsuifont.c
@@ -46,15 +46,15 @@ struct _PangoCairoATSUIFontClass
-static cairo_font_face_t *pango_cairo_atsui_font_create_font_face (PangoCairoFont *font);
-static PangoFontMetrics *pango_cairo_atsui_font_create_metrics_for_context (PangoCairoFont *font,
- PangoContext *context);
+static cairo_font_face_t *pango_cairo_atsui_font_create_font_face (PangoCairoFont *font);
+static PangoFontMetrics *pango_cairo_atsui_font_create_base_metrics_for_context (PangoCairoFont *font,
+ PangoContext *context);
static void
cairo_font_iface_init (PangoCairoFontIface *iface)
{
iface->create_font_face = pango_cairo_atsui_font_create_font_face;
- iface->create_metrics_for_context = pango_cairo_atsui_font_create_metrics_for_context;
+ iface->create_base_metrics_for_context = pango_cairo_atsui_font_create_base_metrics_for_context;
iface->cf_priv_offset = G_STRUCT_OFFSET (PangoCairoATSUIFont, cf_priv);
}
@@ -113,19 +113,14 @@ max_glyph_width (PangoLayout *layout)
}
static PangoFontMetrics *
-pango_cairo_atsui_font_create_metrics_for_context (PangoCairoFont *font,
- PangoContext *context)
+pango_cairo_atsui_font_create_base_metrics_for_context (PangoCairoFont *font,
+ PangoContext *context)
{
PangoCairoATSUIFont *cafont = (PangoCairoATSUIFont *) font;
PangoATSUIFont *afont = (PangoATSUIFont *) font;
ATSFontRef ats_font;
ATSFontMetrics ats_metrics;
PangoFontMetrics *metrics;
- PangoFontDescription *font_desc;
- PangoLayout *layout;
- PangoRectangle extents;
- PangoLanguage *language = pango_context_get_language (context);
- const char *sample_str = pango_language_get_sample_string (language);
metrics = pango_font_metrics_new ();
@@ -141,20 +136,6 @@ pango_cairo_atsui_font_create_metrics_for_context (PangoCairoFont *font,
metrics->strikethrough_position = metrics->ascent / 3;
metrics->strikethrough_thickness = ats_metrics.underlineThickness * cafont->size * PANGO_SCALE;
- layout = pango_layout_new (context);
- font_desc = pango_font_describe_with_absolute_size ((PangoFont *) font);
- pango_layout_set_font_description (layout, font_desc);
- pango_layout_set_text (layout, sample_str, -1);
- pango_layout_get_extents (layout, NULL, &extents);
-
- metrics->approximate_char_width = extents.width / pango_utf8_strwidth (sample_str);
-
- pango_layout_set_text (layout, "0123456789", -1);
- metrics->approximate_digit_width = max_glyph_width (layout);
-
- pango_font_description_free (font_desc);
- g_object_unref (layout);
-
return metrics;
}
diff --git a/pango/pangocairo-fcfont.c b/pango/pangocairo-fcfont.c
index 8401ed8d..1393ce8e 100644
--- a/pango/pangocairo-fcfont.c
+++ b/pango/pangocairo-fcfont.c
@@ -64,19 +64,19 @@ pango_cairo_fc_font_create_font_face (PangoCairoFont *cfont)
}
static PangoFontMetrics *
-pango_cairo_fc_font_create_metrics_for_context (PangoCairoFont *cfont,
- PangoContext *context)
+pango_cairo_fc_font_create_base_metrics_for_context (PangoCairoFont *cfont,
+ PangoContext *context)
{
PangoFcFont *fcfont = (PangoFcFont *) (cfont);
- return pango_fc_font_create_metrics_for_context (fcfont, context);
+ return pango_fc_font_create_base_metrics_for_context (fcfont, context);
}
static void
cairo_font_iface_init (PangoCairoFontIface *iface)
{
iface->create_font_face = pango_cairo_fc_font_create_font_face;
- iface->create_metrics_for_context = pango_cairo_fc_font_create_metrics_for_context;
+ iface->create_base_metrics_for_context = pango_cairo_fc_font_create_base_metrics_for_context;
iface->cf_priv_offset = G_STRUCT_OFFSET (PangoCairoFcFont, cf_priv);
}
diff --git a/pango/pangocairo-font.c b/pango/pangocairo-font.c
index 35da71ce..1f6382b8 100644
--- a/pango/pangocairo-font.c
+++ b/pango/pangocairo-font.c
@@ -22,6 +22,7 @@
#include "config.h"
#include <math.h>
+#include <string.h>
#include "pangocairo.h"
#include "pangocairo-private.h"
@@ -206,6 +207,30 @@ _pango_cairo_font_install (PangoFont *font,
}
+static int
+max_glyph_width (PangoLayout *layout)
+{
+ int max_width = 0;
+ GSList *l, *r;
+
+ for (l = pango_layout_get_lines_readonly (layout); l; l = l->next)
+ {
+ PangoLayoutLine *line = l->data;
+
+ for (r = line->runs; r; r = r->next)
+ {
+ PangoGlyphString *glyphs = ((PangoGlyphItem *)r->data)->glyphs;
+ int i;
+
+ for (i = 0; i < glyphs->num_glyphs; i++)
+ if (glyphs->glyphs[i].geometry.width > max_width)
+ max_width = glyphs->glyphs[i].geometry.width;
+ }
+ }
+
+ return max_width;
+}
+
typedef struct _PangoCairoFontMetricsInfo
{
const char *sample_str;
@@ -239,6 +264,14 @@ _pango_cairo_font_get_metrics (PangoFont *font,
PangoFontMap *fontmap;
PangoContext *context;
cairo_font_options_t *font_options;
+ PangoLayout *layout;
+ PangoRectangle extents;
+ PangoFontDescription *desc;
+ cairo_scaled_font_t *scaled_font;
+ cairo_matrix_t cairo_matrix;
+ PangoMatrix pango_matrix;
+ PangoMatrix identity = PANGO_MATRIX_INIT;
+
int height, shift;
/* XXX this is racy. need a ref'ing getter... */
@@ -253,14 +286,60 @@ _pango_cairo_font_get_metrics (PangoFont *font,
info->sample_str = sample_str;
+ scaled_font = _pango_cairo_font_private_get_scaled_font (cf_priv);
+
context = pango_font_map_create_context (fontmap);
pango_context_set_language (context, language);
+
font_options = cairo_font_options_create ();
- cairo_scaled_font_get_font_options (_pango_cairo_font_private_get_scaled_font (cf_priv), font_options);
+ cairo_scaled_font_get_font_options (scaled_font, font_options);
pango_cairo_context_set_font_options (context, font_options);
cairo_font_options_destroy (font_options);
- info->metrics = (* PANGO_CAIRO_FONT_GET_IFACE (font)->create_metrics_for_context) (cfont, context);
+ info->metrics = (* PANGO_CAIRO_FONT_GET_IFACE (font)->create_base_metrics_for_context) (cfont, context);
+
+ /* We now need to adjust the base metrics for ctm */
+ cairo_scaled_font_get_ctm (scaled_font, &cairo_matrix);
+ pango_matrix.xx = cairo_matrix.xx;
+ pango_matrix.yx = cairo_matrix.yx;
+ pango_matrix.xy = cairo_matrix.xy;
+ pango_matrix.yy = cairo_matrix.yy;
+ pango_matrix.x0 = 0;
+ pango_matrix.y0 = 0;
+ if (G_UNLIKELY (0 != memcmp (&identity, &pango_matrix, 4 * sizeof (double))))
+ {
+ double xscale = pango_matrix_get_font_scale_factor (&pango_matrix);
+ if (xscale) xscale = 1 / xscale;
+
+ info->metrics->ascent *= xscale;
+ info->metrics->descent *= xscale;
+ info->metrics->underline_position *= xscale;
+ info->metrics->underline_thickness *= xscale;
+ info->metrics->strikethrough_position *= xscale;
+ info->metrics->strikethrough_thickness *= xscale;
+ }
+
+
+ /* Set the matrix on the context so we don't have to adjust the derived
+ * metrics. */
+ pango_context_set_matrix (context, &pango_matrix);
+
+ /* Update approximate_*_width now */
+ layout = pango_layout_new (context);
+ desc = pango_font_describe_with_absolute_size (font);
+ pango_layout_set_font_description (layout, desc);
+ pango_font_description_free (desc);
+
+ pango_layout_set_text (layout, sample_str, -1);
+ pango_layout_get_extents (layout, NULL, &extents);
+
+ info->metrics->approximate_char_width = extents.width / pango_utf8_strwidth (sample_str);
+
+ pango_layout_set_text (layout, "0123456789", -1);
+ info->metrics->approximate_digit_width = max_glyph_width (layout);
+
+ g_object_unref (layout);
+
/* We may actually reuse ascent/descent we got from cairo here. that's
* in cf_priv->font_extents.
diff --git a/pango/pangocairo-private.h b/pango/pangocairo-private.h
index 3a4a9d0e..52a8b2f4 100644
--- a/pango/pangocairo-private.h
+++ b/pango/pangocairo-private.h
@@ -75,7 +75,7 @@ struct _PangoCairoFontPrivateScaledFontData
struct _PangoCairoFontPrivate
{
PangoCairoFont *cfont;
-
+
PangoCairoFontPrivateScaledFontData *data;
cairo_scaled_font_t *scaled_font;
@@ -95,8 +95,8 @@ struct _PangoCairoFontIface
GTypeInterface g_iface;
cairo_font_face_t *(*create_font_face) (PangoCairoFont *cfont);
- PangoFontMetrics *(*create_metrics_for_context) (PangoCairoFont *cfont,
- PangoContext *context);
+ PangoFontMetrics *(*create_base_metrics_for_context) (PangoCairoFont *cfont,
+ PangoContext *context);
gssize cf_priv_offset;
};
diff --git a/pango/pangocairo-win32font.c b/pango/pangocairo-win32font.c
index 3493d582..59f7c0f6 100644
--- a/pango/pangocairo-win32font.c
+++ b/pango/pangocairo-win32font.c
@@ -54,16 +54,16 @@ struct _PangoCairoWin32FontClass
GType pango_cairo_win32_font_get_type (void);
-static cairo_font_face_t *pango_cairo_win32_font_create_font_face (PangoCairoFont *font);
-static PangoFontMetrics *pango_cairo_win32_font_create_metrics_for_context (PangoCairoFont *font,
- PangoContext *context);
+static cairo_font_face_t *pango_cairo_win32_font_create_font_face (PangoCairoFont *font);
+static PangoFontMetrics *pango_cairo_win32_font_create_base_metrics_for_context (PangoCairoFont *font,
+ PangoContext *context);
static void
cairo_font_iface_init (PangoCairoFontIface *iface)
{
iface->create_font_face = pango_cairo_win32_font_create_font_face;
- iface->create_metrics_for_context = pango_cairo_win32_font_create_metrics_for_context;
+ iface->create_base_metrics_for_context = pango_cairo_win32_font_create_base_metrics_for_context;
iface->cf_priv_offset = G_STRUCT_OFFSET (PangoCairoWin32Font, cf_priv);
}
@@ -104,15 +104,10 @@ max_glyph_width (PangoLayout *layout)
}
static PangoFontMetrics *
-pango_cairo_win32_font_create_metrics_for_context (PangoCairoFont *font,
- PangoContext *context)
+pango_cairo_win32_font_create_base_metrics_for_context (PangoCairoFont *font,
+ PangoContext *context)
{
PangoFontMetrics *metrics;
- PangoFontDescription *font_desc;
- PangoLayout *layout;
- PangoRectangle extents;
- PangoLanguage *language = pango_context_get_language (context);
- const char *sample_str = pango_language_get_sample_string (language);
cairo_scaled_font_t *scaled_font;
cairo_font_extents_t font_extents;
double height;
@@ -144,20 +139,6 @@ pango_cairo_win32_font_create_metrics_for_context (PangoCairoFont *font,
if (metrics->underline_position == 0)
metrics->underline_position = - metrics->underline_thickness;
- layout = pango_layout_new (context);
- font_desc = pango_font_describe_with_absolute_size ((PangoFont *) font);
- pango_layout_set_font_description (layout, font_desc);
- pango_layout_set_text (layout, sample_str, -1);
- pango_layout_get_extents (layout, NULL, &extents);
-
- metrics->approximate_char_width = extents.width / pango_utf8_strwidth (sample_str);
-
- pango_layout_set_text (layout, "0123456789", -1);
- metrics->approximate_digit_width = max_glyph_width (layout);
-
- pango_font_description_free (font_desc);
- g_object_unref (layout);
-
return metrics;
}
diff --git a/pango/pangofc-font.c b/pango/pangofc-font.c
index ad234beb..7c38ab76 100644
--- a/pango/pangofc-font.c
+++ b/pango/pangofc-font.c
@@ -479,60 +479,15 @@ get_face_metrics (PangoFcFont *fcfont,
PANGO_FC_FONT_UNLOCK_FACE (fcfont);
}
-static int
-max_glyph_width (PangoLayout *layout)
-{
- int max_width = 0;
- GSList *l, *r;
-
- for (l = pango_layout_get_lines_readonly (layout); l; l = l->next)
- {
- PangoLayoutLine *line = l->data;
-
- for (r = line->runs; r; r = r->next)
- {
- PangoGlyphString *glyphs = ((PangoGlyphItem *)r->data)->glyphs;
- int i;
-
- for (i = 0; i < glyphs->num_glyphs; i++)
- if (glyphs->glyphs[i].geometry.width > max_width)
- max_width = glyphs->glyphs[i].geometry.width;
- }
- }
-
- return max_width;
-}
-
PangoFontMetrics *
-pango_fc_font_create_metrics_for_context (PangoFcFont *fcfont,
- PangoContext *context)
+pango_fc_font_create_base_metrics_for_context (PangoFcFont *fcfont,
+ PangoContext *context)
{
PangoFontMetrics *metrics;
- PangoLayout *layout;
- PangoRectangle extents;
- PangoLanguage *language = pango_context_get_language (context);
- const char *sample_str = pango_language_get_sample_string (language);
- PangoFontDescription *desc = pango_font_describe_with_absolute_size (PANGO_FONT (fcfont));
-
metrics = pango_font_metrics_new ();
get_face_metrics (fcfont, metrics);
- layout = pango_layout_new (context);
- pango_layout_set_font_description (layout, desc);
- pango_font_description_free (desc);
-
- pango_layout_set_text (layout, sample_str, -1);
- pango_layout_get_extents (layout, NULL, &extents);
-
- metrics->approximate_char_width =
- extents.width / pango_utf8_strwidth (sample_str);
-
- pango_layout_set_text (layout, "0123456789", -1);
- metrics->approximate_digit_width = max_glyph_width (layout);
-
- g_object_unref (layout);
-
return metrics;
}
@@ -581,7 +536,7 @@ pango_fc_font_get_metrics (PangoFont *font,
context = pango_font_map_create_context (fontmap);
pango_context_set_language (context, language);
- info->metrics = pango_fc_font_create_metrics_for_context (fcfont, context);
+ info->metrics = pango_fc_font_create_base_metrics_for_context (fcfont, context);
g_object_unref (context);
g_object_unref (fontmap);
diff --git a/pango/pangofc-private.h b/pango/pangofc-private.h
index e7c08bff..f200c8c0 100644
--- a/pango/pangofc-private.h
+++ b/pango/pangofc-private.h
@@ -90,8 +90,8 @@ void pango_fc_font_get_raw_extents (PangoFcFont *font,
PangoRectangle *ink_rect,
PangoRectangle *logical_rect);
-PangoFontMetrics *pango_fc_font_create_metrics_for_context (PangoFcFont *font,
- PangoContext *context);
+PangoFontMetrics *pango_fc_font_create_base_metrics_for_context (PangoFcFont *font,
+ PangoContext *context);
diff --git a/pango/pangoft2.def b/pango/pangoft2.def
index 57294318..f2082ccb 100644
--- a/pango/pangoft2.def
+++ b/pango/pangoft2.def
@@ -2,7 +2,7 @@ EXPORTS
pango_fc_decoder_get_charset
pango_fc_decoder_get_glyph
pango_fc_decoder_get_type
- pango_fc_font_create_metrics_for_context
+ pango_fc_font_create_base_metrics_for_context
pango_fc_font_description_from_pattern
pango_fc_font_get_glyph
pango_fc_font_get_raw_extents