fix(cli): measure Greek and Lithuanian painted casing

This commit is contained in:
Miguel Ángel
2026-10-07 03:30:53 -04:00
parent 1e0593b6c8
commit 3431153a22
2 changed files with 21 additions and 3 deletions
@@ -486,11 +486,11 @@
if (!context) return null;
context.font = `${style.fontStyle} ${style.fontWeight} ${style.fontSize} ${style.fontFamily}`;
let text = textContentFor(element, true);
const turkic = element.matches(":lang(tr), :lang(az)");
const casing = ["tr", "az", "el", "lt"].find((lang) => element.matches(`:lang(${lang})`));
if (style.textTransform === "uppercase")
text = turkic ? text.toLocaleUpperCase("tr") : text.toUpperCase();
text = casing ? text.toLocaleUpperCase(casing) : text.toUpperCase();
if (style.textTransform === "lowercase")
text = turkic ? text.toLocaleLowerCase("tr") : text.toLowerCase();
text = casing ? text.toLocaleLowerCase(casing) : text.toLowerCase();
if (style.textTransform === "capitalize") text = capitalizeWords(text);
const metrics = context.measureText(text);
return metrics.fontBoundingBoxAscent + metrics.fontBoundingBoxDescent > 0 ? metrics : null;
@@ -92,6 +92,24 @@ describe.runIf(executablePath)("layout audit in Chromium", () => {
expect(codes.includes("text_box_overflow")).toBe(error);
});
it.each([
{
name: "inherited Greek uppercase with dialytika",
parentLang: "el",
ownLang: null,
transform: "uppercase",
text: "ήί",
gap: 80,
overlap: true,
},
{
name: "inherited Lithuanian lowercase with dot",
parentLang: "lt",
ownLang: null,
transform: "lowercase",
text: "Ì",
gap: 76,
overlap: true,
},
{
name: "inherited Turkish uppercase",
parentLang: "tr",