Text layout plugins are expected to return failure as `false` from their
`textlayout` function. The Pango plugin considered failure to be anything that
resulted in a horizontal layout width of 0. However, this is not a failure in
the case where the text being laid out is the empty string; its horizontal width
is expected to be 0.
The effect of this was that HTML-like strings like `<<br/>1>` were judged to
fail during text layout and a (redundant) estimation of their text width was
performed. This seems to have been a latent bug present since commit
ad82ef8613b0731806b81f9c0047d0cbf6745470 (~July 2007). This recently became more
visible due to commit
7aa0dcc03ea20b544b2463d97fe4a78af699589c that introduced
warnings during text width estimation if a fallback metric needed to be used.
Users were now presented with “Warning: no hard-coded metrics” when using fonts
that Pango knew of and should not have needed estimation in the first place.
This fix makes the Pango plugin consider 0 width for the layout of an empty
string to be successful. To be clear, this commit is both a functional fix and a
performance improvement.
Gitlab: fixes #2179
functions without corrupting their content. Some cases of this were a
regression in Graphviz 2.46.0. Other cases have existed since the first
release of `gvpr`. #2185
+- spurious "no hard-coded metrics" warnings on labels with empty lines #2179
## [3.0.0] – 2022-02-26
/* The distance below midline for y centering of text strings */
span->yoffset_centerline = 0.2 * span->font->size;
- return logical_rect.width != 0;
+ return logical_rect.width != 0 || strcmp(text, "") == 0;
}
static gvtextlayout_engine_t pango_textlayout_engine = {
assert "// tok[7] >>012<< should NOT include trailing spaces or " \
"junk chars" in result, "token 012 not found or has trailing garbage"
-@pytest.mark.xfail(strict=True) # FIXME
def test_2179():
"""
processing a label with an empty line should not yield a warning