label: Microoptimize width-for-height computation

We told Pango to limit width to mid pixels, and it returned a layout
size of text_width by text_height; text_width can be considerably
smaller than mid. If the layout fits, we know that it fits at
text_width, so set max to that. This lets us skip many iterations in a
typical case.
This commit is contained in:
Sergey Bugaev
2023-07-28 18:37:09 +03:00
parent 5c8bd49383
commit d27e7e0180

View File

@@ -1202,7 +1202,7 @@ my_pango_layout_get_width_for_height (PangoLayout *layout,
else if (text_height > for_height)
min = mid + 1;
else
max = mid;
max = text_width;
}
return min * PANGO_SCALE;