Commit f37d293b authored by Matthias Clasen's avatar Matthias Clasen
Browse files

Merge branch 'serialization-improvements' into 'main'

Rename the serialize errors

See merge request !520
parents 55efd092 553eac2b
Pipeline #336602 passed with stages
in 8 minutes and 6 seconds
......@@ -1751,6 +1751,13 @@ pango_font_default_get_face (PangoFont *font)
return PANGO_FONT_MAP_GET_CLASS (map)->get_face (map,font);
}
static void
pango_font_default_get_matrix (PangoFont *font,
PangoMatrix *matrix)
{
*matrix = (PangoMatrix) PANGO_MATRIX_INIT;
}
static void
pango_font_class_init (PangoFontClass *class G_GNUC_UNUSED)
{
......@@ -1766,6 +1773,7 @@ pango_font_class_init (PangoFontClass *class G_GNUC_UNUSED)
pclass->get_scale_factors = pango_font_default_get_scale_factors;
pclass->has_char = pango_font_default_has_char;
pclass->get_face = pango_font_default_get_face;
pclass->get_matrix = pango_font_default_get_matrix;
}
static void
......@@ -2717,6 +2725,15 @@ pango_font_get_languages (PangoFont *font)
return pclass->get_languages (font);
}
void
pango_font_get_matrix (PangoFont *font,
PangoMatrix *matrix)
{
PangoFontClassPrivate *pclass = PANGO_FONT_GET_CLASS_PRIVATE (font);
pclass->get_matrix (font, matrix);
}
gboolean
pango_font_is_hinted (PangoFont *font)
{
......
......@@ -45,12 +45,17 @@ typedef struct {
gboolean (* has_char) (PangoFont *font,
gunichar wc);
PangoFontFace * (* get_face) (PangoFont *font);
void (* get_matrix) (PangoFont *font,
PangoMatrix *matrix);
} PangoFontClassPrivate;
gboolean pango_font_is_hinted (PangoFont *font);
void pango_font_get_scale_factors (PangoFont *font,
double *x_scale,
double *y_scale);
void pango_font_get_matrix (PangoFont *font,
PangoMatrix *matrix);
G_END_DECLS
......
......@@ -634,6 +634,9 @@ hb_font_t * pango_font_get_hb_font (PangoFont *font);
PANGO_AVAILABLE_IN_1_50
PangoLanguage ** pango_font_get_languages (PangoFont *font);
PANGO_AVAILABLE_IN_1_50
GBytes * pango_font_serialize (PangoFont *font);
/**
* PANGO_GLYPH_EMPTY:
*
......
......@@ -351,30 +351,78 @@ GSList * pango_layout_get_lines (PangoLayout *layout);
PANGO_AVAILABLE_IN_1_16
GSList * pango_layout_get_lines_readonly (PangoLayout *layout);
#define PANGO_LAYOUT_SERIALIZE_ERROR (pango_layout_serialize_error_quark ())
/**
* PangoLayoutSerializeFlags:
* @PANGO_LAYOUT_SERIALIZE_DEFAULT: Default behavior
* @PANGO_LAYOUT_SERIALIZE_CONTEXT: Include context information
* @PANGO_LAYOUT_SERIALIZE_OUTPUT: Include information about the formatted output
*
* Flags that influence the behavior of [method@Pango.Layout.serialize].
*
* New members may be added to this enumeration over time.
*/
typedef enum {
PANGO_LAYOUT_SERIALIZE_INVALID,
PANGO_LAYOUT_SERIALIZE_INVALID_SYNTAX,
PANGO_LAYOUT_SERIALIZE_INVALID_VALUE,
PANGO_LAYOUT_SERIALIZE_MISSING_VALUE,
} PangoLayoutSerializeError;
PANGO_LAYOUT_SERIALIZE_DEFAULT = 0,
PANGO_LAYOUT_SERIALIZE_CONTEXT = 1 << 0,
PANGO_LAYOUT_SERIALIZE_OUTPUT = 1 << 1,
} PangoLayoutSerializeFlags;
PANGO_AVAILABLE_IN_1_50
GQuark pango_layout_serialize_error_quark (void);
GBytes * pango_layout_serialize (PangoLayout *layout,
PangoLayoutSerializeFlags flags);
PANGO_AVAILABLE_IN_1_50
GBytes * pango_layout_serialize (PangoLayout *layout);
gboolean pango_layout_write_to_file (PangoLayout *layout,
PangoLayoutSerializeFlags flags,
const char *filename,
GError **error);
#define PANGO_LAYOUT_DESERIALIZE_ERROR (pango_layout_deserialize_error_quark ())
/**
* PangoLayoutDeserializeError:
* @PANGO_LAYOUT_SERIALIZE_INVALID: Unspecified error
* @PANGO_LAYOUT_SERIALIZE_INVALID_SYNTAX: The serialized data had
* the wrong structure (e.g. a member was expected to be a JSon object,
* but was an array)
* @PANGO_LAYOUT_SERIALIZE_INVALID_VALUE: A JSon value could not be
* interpreted
* @PANGO_LAYOUT_SERIALIZE_MISSING_VALUE: A required JSon member was
* not found
*
* Errors that can be returned by [func@Pango.Layout.deserialize].
*/
typedef enum {
PANGO_LAYOUT_DESERIALIZE_INVALID,
PANGO_LAYOUT_DESERIALIZE_INVALID_SYNTAX,
PANGO_LAYOUT_DESERIALIZE_INVALID_VALUE,
PANGO_LAYOUT_DESERIALIZE_MISSING_VALUE,
} PangoLayoutDeserializeError;
PANGO_AVAILABLE_IN_1_50
PangoLayout * pango_layout_deserialize (PangoContext *context,
GBytes *bytes,
GError **error);
GQuark pango_layout_deserialize_error_quark (void);
/**
* PangoLayoutDeserializeFlags:
* @PANGO_LAYOUT_DESERIALIZE_DEFAULT: Default behavior
* @PANGO_LAYOUT_DESERIALIZE_CONTEXT: Apply context information
* from the serialization to the `PangoContext`
*
* Flags that influence the behavior of [method@Pango.Layout.deserialize].
*
* New members may be added to this enumeration over time.
*/
typedef enum {
PANGO_LAYOUT_DESERIALIZE_DEFAULT = 0,
PANGO_LAYOUT_DESERIALIZE_CONTEXT = 1 << 0,
} PangoLayoutDeserializeFlags;
PANGO_AVAILABLE_IN_1_50
gboolean pango_layout_write_to_file (PangoLayout *layout,
const char *filename,
GError **error);
PangoLayout * pango_layout_deserialize (PangoContext *context,
GBytes *bytes,
PangoLayoutDeserializeFlags flags,
GError **error);
#define PANGO_TYPE_LAYOUT_LINE (pango_layout_line_get_type ())
......
......@@ -75,6 +75,8 @@ static gboolean _pango_fc_font_is_hinted (PangoFont *fon
static void _pango_fc_font_get_scale_factors (PangoFont *font,
double *x_scale,
double *y_scale);
static void pango_fc_font_get_matrix (PangoFont *font,
PangoMatrix *matrix);
#define PANGO_FC_FONT_LOCK_FACE(font) (PANGO_FC_FONT_GET_CLASS (font)->lock_face (font))
#define PANGO_FC_FONT_UNLOCK_FACE(font) (PANGO_FC_FONT_GET_CLASS (font)->unlock_face (font))
......@@ -109,6 +111,7 @@ pango_fc_font_class_init (PangoFcFontClass *class)
pclass->get_languages = _pango_fc_font_get_languages;
pclass->is_hinted = _pango_fc_font_is_hinted;
pclass->get_scale_factors = _pango_fc_font_get_scale_factors;
pclass->get_matrix = pango_fc_font_get_matrix;
/**
* PangoFcFont:pattern:
......@@ -1110,3 +1113,22 @@ _pango_fc_font_get_scale_factors (PangoFont *font,
pango_matrix_get_font_scale_factors (&fcfont->matrix, x_scale, y_scale);
}
static void
pango_fc_font_get_matrix (PangoFont *font,
PangoMatrix *matrix)
{
PangoFcFont *fcfont = PANGO_FC_FONT (font);
FcMatrix fc_matrix, *fc_matrix_val;
FcMatrixInit (&fc_matrix);
for (int i = 0; FcPatternGetMatrix (fcfont->font_pattern, FC_MATRIX, i, &fc_matrix_val) == FcResultMatch; i++)
FcMatrixMultiply (&fc_matrix, &fc_matrix, fc_matrix_val);
matrix->xx = fc_matrix.xx;
matrix->xy = - fc_matrix.xy;
matrix->yx = - fc_matrix.yx;
matrix->yy = fc_matrix.yy;
matrix->x0 = 0.;
matrix->y0 = 0.;
}
This diff is collapsed.
......@@ -102,10 +102,12 @@ pango_hb_font_get_nominal_glyph (hb_font_t *font,
* don't draw a hex box for 0x20
*/
if (unicode == 0x20)
*glyph = PANGO_GET_UNKNOWN_GLYPH (0x2423);
unicode = 0x2423;
else
*glyph = PANGO_GET_UNKNOWN_GLYPH (unicode);
return TRUE;
{
*glyph = PANGO_GET_UNKNOWN_GLYPH (unicode);
return TRUE;
}
}
if ((context->show_flags & PANGO_SHOW_IGNORABLES) != 0 &&
......
The fonts in this directory are available to test-layout tests.
emoji-subset.ttf is a subset of Noto Color Emoji that is just
big enough to provide the Emoji that are present in our test
cases.
Bratwurst
--- parameters
wrapped: 0
ellipsized: 0
lines: 1
width: 102400
--- attributes
range 0 4
range 4 2147483647
4 4294967295 style italic
range 2147483647 2147483647
--- directions
0 0 0 0 0 0 0 0 0
--- cursor positions
0(0) 1(0) 2(0) 3(0) 4(0) 5(0) 6(0) 7(0) 8(0) 8(1)
--- lines
i=1, index=0, paragraph-start=1, dir=ltr 'Bratwurst'
--- runs
i=1, index=0, chars=4, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'Brat'
i=2, index=4, chars=5, level=0, gravity=south, flags=0, font=OMITTED, script=latin, language=en-us, 'wurst'
i=3, index=9, no run, line end
{
"context" : {
"font" : "serif 12",
"language" : "en-us",
"base-gravity" : "south",
"gravity-hint" : "natural",
"base-dir" : "weak-ltr",
"round-glyph-positions" : true,
"transform" : [
1.0,
0.0,
0.0,
1.0,
0.0,
0.0
]
},
"comment" : [
"A case with a single word made up of two items,",
"expected to produce a single overlong line."
],
"text" : "Bratwurst",
"attributes" : [
{
......@@ -7,15 +27,199 @@
"value" : "italic"
}
],
"font" : "Sans Bold 32",
"tabs" : {
"positions-in-pixels" : true,
"positions" : [
0,
50,
100
"font" : "Cantarell Bold 32",
"width" : 87040,
"output" : {
"is-wrapped" : false,
"is-ellipsized" : false,
"unknown-glyphs" : 0,
"width" : 202752,
"height" : 53248,
"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
},
{
"char-break" : true,
"cursor-position" : true,
"break-inserts-hyphen" : true
},
{
"char-break" : true,
"cursor-position" : true,
"break-inserts-hyphen" : true
},
{
"char-break" : true,
"cursor-position" : true,
"break-inserts-hyphen" : true
},
{
"char-break" : true,
"cursor-position" : true,
"break-inserts-hyphen" : 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" : 9,
"paragraph-start" : true,
"direction" : "ltr",
"runs" : [
{
"offset" : 0,
"length" : 4,
"text" : "Brat",
"bidi-level" : 0,
"gravity" : "south",
"language" : "en-us",
"script" : "latin",
"font" : {
"description" : "Cantarell Bold 32",
"checksum" : "5bcb6ee14ee9d210b2e91d643de1fe456e9d1aea770983fdb05951545efebbe2",
"variations" : {
"wght" : 8374
},
"matrix" : [
1.0,
-0.0,
-0.0,
1.0,
0.0,
0.0
]
},
"flags" : 0,
"y-offset" : 0,
"start-x-offset" : 0,
"end-x-offset" : 0,
"glyphs" : [
{
"glyph" : 29,
"width" : 28672,
"is-cluster-start" : true,
"log-cluster" : 0
},
{
"glyph" : 409,
"width" : 18432,
"is-cluster-start" : true,
"log-cluster" : 1
},
{
"glyph" : 244,
"width" : 23552,
"is-cluster-start" : true,
"log-cluster" : 2
},
{
"glyph" : 430,
"width" : 16384,
"is-cluster-start" : true,
"log-cluster" : 3
}
]
},
{
"offset" : 4,
"length" : 5,
"text" : "wurst",
"bidi-level" : 0,
"gravity" : "south",
"language" : "en-us",
"script" : "latin",
"font" : {
"description" : "Cantarell Bold 32",
"checksum" : "5bcb6ee14ee9d210b2e91d643de1fe456e9d1aea770983fdb05951545efebbe2",
"variations" : {
"wght" : 8374
},
"matrix" : [
1.0,
-0.0,
-0.0,
1.0,
0.0,
0.0
]
},
"flags" : 0,
"y-offset" : 0,
"start-x-offset" : 0,
"end-x-offset" : 0,
"glyphs" : [
{
"glyph" : 467,
"width" : 35840,
"is-cluster-start" : true,
"log-cluster" : 0
},
{
"glyph" : 438,
"width" : 24576,
"is-cluster-start" : true,
"log-cluster" : 1
},
{
"glyph" : 409,
"width" : 18432,
"is-cluster-start" : true,
"log-cluster" : 2
},
{
"glyph" : 417,
"width" : 20480,
"is-cluster-start" : true,
"log-cluster" : 3
},
{
"glyph" : 430,
"width" : 16384,
"is-cluster-start" : true,
"log-cluster" : 4
}
]
}
]
}
]
},
"width" : 102400,
"line-spacing" : 1.2999999523162842
}
\ No newline at end of file
}
}
{
"context" : {
"font" : "serif 12",
"language" : "en-us",
"base-gravity" : "south",
"gravity-hint" : "natural",
"base-dir" : "weak-ltr",
"round-glyph-positions" : true,
"transform" : [
1.0,
0.0,
0.0,
1.0,
0.0,
0.0
]
},
"comment" : [
"A single word, expected to produce a single",
"overlong line."
],
"text" : "Bratwurst",
"font" : "Cantarell Bold 32",
"width" : 87040,
"output" : {
"is-wrapped" : false,
"is-ellipsized" : false,
"unknown-glyphs" : 0,
"width" : 202752,
"height" : 53248,
"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
},
{
"char-break" : true,
"cursor-position" : true,
"break-inserts-hyphen" : true
},
{
"char-break" : true,
"cursor-position" : true,
"break-inserts-hyphen" : true
},
{
"char-break" : true,
"cursor-position" : true,
"break-inserts-hyphen" : true
},
{
"char-break" : true,
"cursor-position" : true,
"break-inserts-hyphen" : 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" : 9,
"paragraph-start" : true,
"direction" : "ltr",
"runs" : [
{
"offset" : 0,
"length" : 9,
"text" : "Bratwurst",
"bidi-level" : 0,
"gravity" : "south",
"language" : "en-us",
"script" : "latin",
"font" : {
"description" : "Cantarell Bold 32",
"checksum" : "5bcb6ee14ee9d210b2e91d643de1fe456e9d1aea770983fdb05951545efebbe2",
"variations" : {
"wght" : 8374
},
"matrix" : [
1.0,
-0.0,
-0.0,
1.0,
0.0,
0.0
]
},
"flags" : 0,
"y-offset" : 0,
"start-x-offset" : 0,
"end-x-offset" : 0,
"glyphs" : [
{
"glyph" : 29,
"width" : 28672,
"is-cluster-start" : true,
"log-cluster" : 0
},
{
"glyph" : 409,
"width" : 18432,
"is-cluster-start" : true,