summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pango/shape.c45
-rw-r--r--tests/fonts/README1
-rw-r--r--tests/fonts/noto-sans-cjk.ttfbin0 -> 3708 bytes
-rw-r--r--tests/layouts/bratwurst.layout8
-rw-r--r--tests/layouts/bratwurst2.layout8
-rw-r--r--tests/layouts/bratwurst3.layout4
-rw-r--r--tests/layouts/bratwurst4.layout8
-rw-r--r--tests/layouts/effigy.layout8
-rw-r--r--tests/layouts/kebab.layout2
-rw-r--r--tests/layouts/tabs.layout4
-rw-r--r--tests/layouts/valid-10.layout6
-rw-r--r--tests/layouts/valid-14.layout6
-rw-r--r--tests/layouts/valid-19.layout6
-rw-r--r--tests/layouts/valid-20.layout10
-rw-r--r--tests/layouts/valid-8.layout8
-rw-r--r--tests/layouts/valid-9.layout4
-rw-r--r--tests/layouts/vertical.layout260
17 files changed, 331 insertions, 57 deletions
diff --git a/pango/shape.c b/pango/shape.c
index d0140d5e..90334cc1 100644
--- a/pango/shape.c
+++ b/pango/shape.c
@@ -162,11 +162,16 @@ pango_hb_font_get_glyph_h_advance (hb_font_t *font,
void *user_data G_GNUC_UNUSED)
{
PangoHbShapeContext *context = (PangoHbShapeContext *) font_data;
- PangoRectangle logical;
- pango_font_get_glyph_extents (context->font, glyph, NULL, &logical);
+ if (glyph & PANGO_GLYPH_UNKNOWN_FLAG)
+ {
+ PangoRectangle logical;
+
+ pango_font_get_glyph_extents (context->font, glyph, NULL, &logical);
+ return logical.width;
+ }
- return logical.width;
+ return hb_font_get_glyph_h_advance (context->parent, glyph);
}
static hb_position_t
@@ -176,14 +181,16 @@ pango_hb_font_get_glyph_v_advance (hb_font_t *font,
void *user_data G_GNUC_UNUSED)
{
PangoHbShapeContext *context = (PangoHbShapeContext *) font_data;
- PangoRectangle logical;
- pango_font_get_glyph_extents (context->font, glyph, NULL, &logical);
+ if (glyph & PANGO_GLYPH_UNKNOWN_FLAG)
+ {
+ PangoRectangle logical;
- if (hb_font_get_glyph_v_advance (context->parent, glyph) < 0)
- return - logical.height;
- else
- return logical.height;
+ pango_font_get_glyph_extents (context->font, glyph, NULL, &logical);
+ return logical.height;
+ }
+
+ return hb_font_get_glyph_v_advance (context->parent, glyph);
}
static hb_bool_t
@@ -194,16 +201,22 @@ pango_hb_font_get_glyph_extents (hb_font_t *font,
void *user_data G_GNUC_UNUSED)
{
PangoHbShapeContext *context = (PangoHbShapeContext *) font_data;
- PangoRectangle ink;
- pango_font_get_glyph_extents (context->font, glyph, &ink, NULL);
+ if (glyph & PANGO_GLYPH_UNKNOWN_FLAG)
+ {
+ PangoRectangle ink;
+
+ pango_font_get_glyph_extents (context->font, glyph, &ink, NULL);
- extents->x_bearing = ink.x;
- extents->y_bearing = ink.y;
- extents->width = ink.width;
- extents->height = ink.height;
+ extents->x_bearing = ink.x;
+ extents->y_bearing = ink.y;
+ extents->width = ink.width;
+ extents->height = ink.height;
+
+ return TRUE;
+ }
- return TRUE;
+ return hb_font_get_glyph_extents (context->parent, glyph, extents);
}
static hb_font_t *
diff --git a/tests/fonts/README b/tests/fonts/README
index ca56ca40..5faba25d 100644
--- a/tests/fonts/README
+++ b/tests/fonts/README
@@ -8,3 +8,4 @@ emoji-subset.ttf: subset of Noto Color Emoji
droid-sans-subset.ttf: subset of Droid Sans Japanese
amiri-06dd.ttf: subset of Amiri containing U+06dd
fa-regular-f2db.ttf, fa-solid-f2db.ttf: subset of FontAwesome containing U+f2db
+noto-sans-cjk.ttf: subset of Noto Sans CJK
diff --git a/tests/fonts/noto-sans-cjk.ttf b/tests/fonts/noto-sans-cjk.ttf
new file mode 100644
index 00000000..7f636815
--- /dev/null
+++ b/tests/fonts/noto-sans-cjk.ttf
Binary files differ
diff --git a/tests/layouts/bratwurst.layout b/tests/layouts/bratwurst.layout
index 18a02eca..14979a1a 100644
--- a/tests/layouts/bratwurst.layout
+++ b/tests/layouts/bratwurst.layout
@@ -30,8 +30,8 @@
"is-wrapped" : false,
"is-ellipsized" : false,
"unknown-glyphs" : 0,
- "width" : 202752,
- "height" : 202752,
+ "width" : 200704,
+ "height" : 200704,
"log-attrs" : [
{
"char-break" : true,
@@ -137,7 +137,7 @@
},
{
"glyph" : 409,
- "width" : 18432,
+ "width" : 17408,
"is-cluster-start" : true,
"log-cluster" : 1
},
@@ -197,7 +197,7 @@
},
{
"glyph" : 409,
- "width" : 18432,
+ "width" : 17408,
"is-cluster-start" : true,
"log-cluster" : 2
},
diff --git a/tests/layouts/bratwurst2.layout b/tests/layouts/bratwurst2.layout
index 34d83ec8..311a2994 100644
--- a/tests/layouts/bratwurst2.layout
+++ b/tests/layouts/bratwurst2.layout
@@ -23,8 +23,8 @@
"is-wrapped" : false,
"is-ellipsized" : false,
"unknown-glyphs" : 0,
- "width" : 202752,
- "height" : 202752,
+ "width" : 200704,
+ "height" : 200704,
"log-attrs" : [
{
"char-break" : true,
@@ -130,7 +130,7 @@
},
{
"glyph" : 409,
- "width" : 18432,
+ "width" : 17408,
"is-cluster-start" : true,
"log-cluster" : 1
},
@@ -160,7 +160,7 @@
},
{
"glyph" : 409,
- "width" : 18432,
+ "width" : 17408,
"is-cluster-start" : true,
"log-cluster" : 6
},
diff --git a/tests/layouts/bratwurst3.layout b/tests/layouts/bratwurst3.layout
index 04914992..6ce03c16 100644
--- a/tests/layouts/bratwurst3.layout
+++ b/tests/layouts/bratwurst3.layout
@@ -131,7 +131,7 @@
},
{
"glyph" : 409,
- "width" : 18432,
+ "width" : 17408,
"is-cluster-start" : true,
"log-cluster" : 1
},
@@ -290,7 +290,7 @@
"glyphs" : [
{
"glyph" : 409,
- "width" : 18432,
+ "width" : 17408,
"is-cluster-start" : true,
"log-cluster" : 0
},
diff --git a/tests/layouts/bratwurst4.layout b/tests/layouts/bratwurst4.layout
index 7b63ab46..d3628c6c 100644
--- a/tests/layouts/bratwurst4.layout
+++ b/tests/layouts/bratwurst4.layout
@@ -23,8 +23,8 @@
"is-wrapped" : true,
"is-ellipsized" : false,
"unknown-glyphs" : 0,
- "width" : 115712,
- "height" : 115712,
+ "width" : 114688,
+ "height" : 114688,
"log-attrs" : [
{
"char-break" : true,
@@ -136,7 +136,7 @@
},
{
"glyph" : 409,
- "width" : 18432,
+ "width" : 17408,
"is-cluster-start" : true,
"log-cluster" : 1
},
@@ -215,7 +215,7 @@
},
{
"glyph" : 409,
- "width" : 18432,
+ "width" : 17408,
"is-cluster-start" : true,
"log-cluster" : 2
},
diff --git a/tests/layouts/effigy.layout b/tests/layouts/effigy.layout
index b5b67d85..2c621083 100644
--- a/tests/layouts/effigy.layout
+++ b/tests/layouts/effigy.layout
@@ -25,8 +25,8 @@
"is-wrapped" : true,
"is-ellipsized" : false,
"unknown-glyphs" : 0,
- "width" : 73728,
- "height" : 73728,
+ "width" : 71680,
+ "height" : 71680,
"log-attrs" : [
{
"char-break" : true,
@@ -114,13 +114,13 @@
},
{
"glyph" : 5041,
- "width" : 30720,
+ "width" : 29696,
"is-cluster-start" : true,
"log-cluster" : 1
},
{
"glyph" : 2803,
- "width" : 16384,
+ "width" : 15360,
"log-cluster" : 1
}
]
diff --git a/tests/layouts/kebab.layout b/tests/layouts/kebab.layout
index a54b5c8b..fbf7e37e 100644
--- a/tests/layouts/kebab.layout
+++ b/tests/layouts/kebab.layout
@@ -163,7 +163,7 @@
},
{
"glyph" : 409,
- "width" : 18432,
+ "width" : 17408,
"is-cluster-start" : true,
"log-cluster" : 5
},
diff --git a/tests/layouts/tabs.layout b/tests/layouts/tabs.layout
index ee022a9b..ab70fab3 100644
--- a/tests/layouts/tabs.layout
+++ b/tests/layouts/tabs.layout
@@ -1481,7 +1481,7 @@
},
{
"glyph" : 967,
- "width" : 11264,
+ "width" : 10240,
"is-cluster-start" : true,
"log-cluster" : 4
}
@@ -1517,7 +1517,7 @@
"glyphs" : [
{
"glyph" : 268435455,
- "width" : 55296,
+ "width" : 56320,
"is-cluster-start" : true,
"log-cluster" : 0
}
diff --git a/tests/layouts/valid-10.layout b/tests/layouts/valid-10.layout
index bec277e7..df15efe0 100644
--- a/tests/layouts/valid-10.layout
+++ b/tests/layouts/valid-10.layout
@@ -270,13 +270,13 @@
},
{
"glyph" : 1331,
- "width" : 9216,
+ "width" : 8192,
"is-cluster-start" : true,
"log-cluster" : 2
},
{
"glyph" : 1344,
- "width" : 11264,
+ "width" : 10240,
"is-cluster-start" : true,
"log-cluster" : 0
}
@@ -391,7 +391,7 @@
"glyphs" : [
{
"glyph" : 1062,
- "width" : 17408,
+ "width" : 19456,
"is-cluster-start" : true,
"log-cluster" : 0
}
diff --git a/tests/layouts/valid-14.layout b/tests/layouts/valid-14.layout
index 8cfa62d9..9bfd7723 100644
--- a/tests/layouts/valid-14.layout
+++ b/tests/layouts/valid-14.layout
@@ -235,7 +235,7 @@
},
{
"glyph" : 1058,
- "width" : 4096,
+ "width" : 6144,
"log-cluster" : 0
}
]
@@ -378,13 +378,13 @@
},
{
"glyph" : 1331,
- "width" : 9216,
+ "width" : 8192,
"is-cluster-start" : true,
"log-cluster" : 2
},
{
"glyph" : 1344,
- "width" : 11264,
+ "width" : 10240,
"is-cluster-start" : true,
"log-cluster" : 0
}
diff --git a/tests/layouts/valid-19.layout b/tests/layouts/valid-19.layout
index 4f478f67..7456bc7e 100644
--- a/tests/layouts/valid-19.layout
+++ b/tests/layouts/valid-19.layout
@@ -22,8 +22,8 @@
"is-wrapped" : false,
"is-ellipsized" : false,
"unknown-glyphs" : 0,
- "width" : 167936,
- "height" : 167936,
+ "width" : 166912,
+ "height" : 166912,
"log-attrs" : [
{
"char-break" : true,
@@ -194,7 +194,7 @@
"glyphs" : [
{
"glyph" : 5867,
- "width" : 16384,
+ "width" : 15360,
"is-cluster-start" : true,
"log-cluster" : 0
},
diff --git a/tests/layouts/valid-20.layout b/tests/layouts/valid-20.layout
index 8217b28b..950be74b 100644
--- a/tests/layouts/valid-20.layout
+++ b/tests/layouts/valid-20.layout
@@ -40,8 +40,8 @@
"is-wrapped" : false,
"is-ellipsized" : false,
"unknown-glyphs" : 0,
- "width" : 79872,
- "height" : 79872,
+ "width" : 67584,
+ "height" : 67584,
"log-attrs" : [
{
"char-break" : true,
@@ -138,7 +138,7 @@
"glyphs" : [
{
"glyph" : 244,
- "width" : 19456,
+ "width" : 15360,
"x-offset" : 14764,
"y-offset" : 3844,
"is-cluster-start" : true,
@@ -146,7 +146,7 @@
},
{
"glyph" : 272,
- "width" : 19456,
+ "width" : 15360,
"x-offset" : 14764,
"y-offset" : 4280,
"is-cluster-start" : true,
@@ -154,7 +154,7 @@
},
{
"glyph" : 273,
- "width" : 19456,
+ "width" : 15360,
"x-offset" : 14764,
"y-offset" : 3506,
"is-cluster-start" : true,
diff --git a/tests/layouts/valid-8.layout b/tests/layouts/valid-8.layout
index fdaeee93..3b2a88ae 100644
--- a/tests/layouts/valid-8.layout
+++ b/tests/layouts/valid-8.layout
@@ -25,8 +25,8 @@
"is-wrapped" : false,
"is-ellipsized" : false,
"unknown-glyphs" : 0,
- "width" : 134144,
- "height" : 134144,
+ "width" : 132096,
+ "height" : 132096,
"log-attrs" : [
{
"char-break" : true,
@@ -270,13 +270,13 @@
},
{
"glyph" : 1331,
- "width" : 9216,
+ "width" : 8192,
"is-cluster-start" : true,
"log-cluster" : 2
},
{
"glyph" : 1344,
- "width" : 11264,
+ "width" : 10240,
"is-cluster-start" : true,
"log-cluster" : 0
}
diff --git a/tests/layouts/valid-9.layout b/tests/layouts/valid-9.layout
index 71a146ff..1b5b2a23 100644
--- a/tests/layouts/valid-9.layout
+++ b/tests/layouts/valid-9.layout
@@ -303,14 +303,14 @@
},
{
"glyph" : 1331,
- "width" : 18104,
+ "width" : 17080,
"x-offset" : 4444,
"is-cluster-start" : true,
"log-cluster" : 2
},
{
"glyph" : 1344,
- "width" : 20152,
+ "width" : 19128,
"x-offset" : 4444,
"is-cluster-start" : true,
"log-cluster" : 0
diff --git a/tests/layouts/vertical.layout b/tests/layouts/vertical.layout
new file mode 100644
index 00000000..ec9b93df
--- /dev/null
+++ b/tests/layouts/vertical.layout
@@ -0,0 +1,260 @@
+{
+ "context" : {
+ "font" : "serif 12",
+ "language" : "en-us",
+ "base-gravity" : "east",
+ "gravity-hint" : "strong",
+ "base-dir" : "ltr",
+ "round-glyph-positions" : true,
+ "transform" : [
+ -1.8369701987210297e-16,
+ -1,
+ 1,
+ -1.8369701987210297e-16,
+ 0,
+ 0
+ ]
+ },
+ "text" : "ABC日本語ABC",
+ "font" : "Noto Sans CJK JP 24",
+ "wrap" : "word-char",
+ "output" : {
+ "is-wrapped" : false,
+ "is-ellipsized" : false,
+ "unknown-glyphs" : 0,
+ "width" : 294912,
+ "height" : 294912,
+ "log-attrs" : [
+ {
+ "char-break" : true,
+ "cursor-position" : true,
+ "word-start" : true,
+ "sentence-boundary" : true,
+ "sentence-start" : true,
+ "backspace-deletes-character" : true,
+ "word-boundary" : true
+ },
+ {
+ "char-break" : true,
+ "cursor-position" : true,
+ "break-inserts-hyphen" : true
+ },
+ {
+ "char-break" : true,
+ "cursor-position" : true,
+ "break-inserts-hyphen" : true
+ },
+ {
+ "line-break" : true,
+ "char-break" : true,
+ "cursor-position" : true,
+ "word-boundary" : true
+ },
+ {
+ "line-break" : true,
+ "char-break" : true,
+ "cursor-position" : true,
+ "backspace-deletes-character" : true,
+ "word-boundary" : true
+ },
+ {
+ "line-break" : true,
+ "char-break" : true,
+ "cursor-position" : true,
+ "backspace-deletes-character" : true,
+ "word-boundary" : true
+ },
+ {
+ "line-break" : true,
+ "char-break" : true,
+ "cursor-position" : true,
+ "backspace-deletes-character" : true,
+ "word-boundary" : true
+ },
+ {
+ "char-break" : true,
+ "cursor-position" : true,
+ "break-inserts-hyphen" : true
+ },
+ {
+ "char-break" : true,
+ "cursor-position" : true,
+ "break-inserts-hyphen" : true
+ },
+ {
+ "line-break" : true,
+ "mandatory-break" : true,
+ "char-break" : true,
+ "white" : true,
+ "cursor-position" : true,
+ "word-end" : true,
+ "sentence-boundary" : true,
+ "sentence-end" : true,
+ "word-boundary" : true
+ }
+ ],
+ "lines" : [
+ {
+ "start-index" : 0,
+ "length" : 15,
+ "paragraph-start" : true,
+ "direction" : "ltr",
+ "runs" : [
+ {
+ "offset" : 0,
+ "length" : 3,
+ "text" : "ABC",
+ "bidi-level" : 0,
+ "gravity" : "east",
+ "language" : "en-us",
+ "script" : "latin",
+ "font" : {
+ "description" : "Noto Sans CJK JP Rotated-Left 24",
+ "checksum" : "3b50ae56f1fb5637c82d785945531f718f40b78a26bea3d137e58808bd774399",
+ "matrix" : [
+ 1,
+ -0,
+ -0,
+ 1,
+ 0,
+ 0
+ ]
+ },
+ "flags" : 1,
+ "y-offset" : 0,
+ "start-x-offset" : 0,
+ "end-x-offset" : 0,
+ "glyphs" : [
+ {
+ "glyph" : 1,
+ "width" : 32768,
+ "x-offset" : 28835,
+ "y-offset" : 9945,
+ "is-cluster-start" : true,
+ "log-cluster" : 0
+ },
+ {
+ "glyph" : 2,
+ "width" : 32768,
+ "x-offset" : 28835,
+ "y-offset" : 10764,
+ "is-cluster-start" : true,
+ "log-cluster" : 1
+ },
+ {
+ "glyph" : 3,
+ "width" : 32768,
+ "x-offset" : 28835,
+ "y-offset" : 10452,
+ "is-cluster-start" : true,
+ "log-cluster" : 2
+ }
+ ]
+ },
+ {
+ "offset" : 3,
+ "length" : 9,
+ "text" : "日本語",
+ "bidi-level" : 0,
+ "gravity" : "east",
+ "language" : "xx",
+ "script" : "han",
+ "font" : {
+ "description" : "Noto Sans CJK JP Rotated-Left 24",
+ "checksum" : "3b50ae56f1fb5637c82d785945531f718f40b78a26bea3d137e58808bd774399",
+ "matrix" : [
+ 1,
+ -0,
+ -0,
+ 1,
+ 0,
+ 0
+ ]
+ },
+ "flags" : 1,
+ "y-offset" : 0,
+ "start-x-offset" : 0,
+ "end-x-offset" : 0,
+ "glyphs" : [
+ {
+ "glyph" : 4,
+ "width" : 32768,
+ "x-offset" : 28835,
+ "y-offset" : 16383,
+ "is-cluster-start" : true,
+ "log-cluster" : 0
+ },
+ {
+ "glyph" : 5,
+ "width" : 32768,
+ "x-offset" : 28835,
+ "y-offset" : 16383,
+ "is-cluster-start" : true,
+ "log-cluster" : 3
+ },
+ {
+ "glyph" : 7,
+ "width" : 32768,
+ "x-offset" : 28835,
+ "y-offset" : 16383,
+ "is-cluster-start" : true,
+ "log-cluster" : 6
+ }
+ ]
+ },
+ {
+ "offset" : 12,
+ "length" : 3,
+ "text" : "ABC",
+ "bidi-level" : 0,
+ "gravity" : "east",
+ "language" : "en-us",
+ "script" : "latin",
+ "font" : {
+ "description" : "Noto Sans CJK JP Rotated-Left 24",
+ "checksum" : "3b50ae56f1fb5637c82d785945531f718f40b78a26bea3d137e58808bd774399",
+ "matrix" : [
+ 1,
+ -0,
+ -0,
+ 1,
+ 0,
+ 0
+ ]
+ },
+ "flags" : 1,
+ "y-offset" : 0,
+ "start-x-offset" : 0,
+ "end-x-offset" : 0,
+ "glyphs" : [
+ {
+ "glyph" : 1,
+ "width" : 32768,
+ "x-offset" : 28835,
+ "y-offset" : 9945,
+ "is-cluster-start" : true,
+ "log-cluster" : 0
+ },
+ {
+ "glyph" : 2,
+ "width" : 32768,
+ "x-offset" : 28835,
+ "y-offset" : 10764,
+ "is-cluster-start" : true,
+ "log-cluster" : 1
+ },
+ {
+ "glyph" : 3,
+ "width" : 32768,
+ "x-offset" : 28835,
+ "y-offset" : 10452,
+ "is-cluster-start" : true,
+ "log-cluster" : 2
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+}