Skip to content

Commit

Permalink
Removed workaround for bidirectional isolation in GL JS
Browse files Browse the repository at this point in the history
  • Loading branch information
1ec5 committed Aug 21, 2024
1 parent c009403 commit c17e100
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 23 deletions.
15 changes: 2 additions & 13 deletions src/constants/label.js
Original file line number Diff line number Diff line change
Expand Up @@ -471,25 +471,14 @@ export const localizedNameWithLocalGloss = [
"format",
["var", "localizedNameList"],
"\n",
"(\u200B",
"(\u2068",
{ "font-scale": 0.8 },
// GL JS lacks support for bidirectional isolating characters, so use a
// character from the localized name to insulate the parentheses from the
// embedded text's writing direction. Make it so small that GL JS doesn't
// bother rendering it.
["concat", ["slice", ["var", "localizedName"], 0, 1], " "],
{ "font-scale": 0.001 },
listValuesExpression(["get", "name"], inlineSeparator, [
"var",
"localizedName",
]),
{ "font-scale": 0.8 },
["concat", " ", ["slice", ["var", "localizedName"], 0, 1]],
{ "font-scale": 0.001 },
// A ZWSP prevents GL JS from combining this component with the preceding
// one, which would cause it to vanish along with the faux isolating
// character.
"\u200B)",
"\u2069)",
{ "font-scale": 0.8 },
],
],
Expand Down
16 changes: 6 additions & 10 deletions test/spec/label.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ describe("label", function () {
if (typeof evaluated === "string") {
return [evaluated];
}
return [evaluated.sections[0].text, evaluated.sections[4]?.text];
return [evaluated.sections[0].text, evaluated.sections[3]?.text];
};

let expectGloss = (
Expand Down Expand Up @@ -336,18 +336,14 @@ describe("label", function () {
name: "Insula Nullius",
});

expect(evaluated.sections.length).to.be.eql(7);
expect(evaluated.sections.length).to.be.eql(5);
expect(evaluated.sections[0].text).to.be.eql("Null Island");
expect(evaluated.sections[1].text).to.be.eql("\n");
expect(evaluated.sections[2].text).to.be.eql("(\u200B");
expect(evaluated.sections[3].text).to.be.eql("Null Island"[0] + " ");
expect(evaluated.sections[4].text).to.be.eql("Insula Nullius");
expect(evaluated.sections[5].text).to.be.eql(" " + "Null Island"[0]);
expect(evaluated.sections[6].text).to.be.eql("\u200B)");
expect(evaluated.sections[2].text).to.be.eql("(\u2068");
expect(evaluated.sections[3].text).to.be.eql("Insula Nullius");
expect(evaluated.sections[4].text).to.be.eql("\u2069)");

expect(evaluated.sections[3].scale).to.be.below(0.1);
expect(evaluated.sections[4].scale).to.be.below(1);
expect(evaluated.sections[5].scale).to.be.below(0.1);
expect(evaluated.sections[3].scale).to.be.below(1);
});
it("deduplicates matching anglicized and local names", function () {
expectGloss("en", "Null Island", "Null Island", "Null Island");
Expand Down

0 comments on commit c17e100

Please sign in to comment.