Skip to content

Commit

Permalink
fix test on linux, based on reference hb-shape output
Browse files Browse the repository at this point in the history
  • Loading branch information
aramperes committed Aug 21, 2023
1 parent af2bded commit c839e54
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions src/test/java/dev/poire/buzz4j/HarfBuzzTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,33 @@ public void testShapeString() throws Exception {
public void testShapeArabic() throws Exception {
String input = "العربية";
ShapeGlyph[] outputCombined = HarfBuzz.shapeString(font(), input);
int sumCombined = Arrays.stream(outputCombined).mapToInt(ShapeGlyph::effectiveWidth).sum();
int sumSplit = Arrays.stream(input.split("")).flatMap(c -> {

Assertions.assertArrayEquals(new ShapeGlyph[]{
new ShapeGlyph(5157, 486, 0, 0, 0),
new ShapeGlyph(5380, 373, 0, 0, 0),
new ShapeGlyph(3977, 269, 0, 0, 0),
new ShapeGlyph(4860, 396, 0, 0, 0),
new ShapeGlyph(3887, 521, 0, 0, 0),
new ShapeGlyph(4543, 260, 0, 0, 0),
new ShapeGlyph(3921, 238, 0, 0, 0)
}, outputCombined);

ShapeGlyph[] outputSplit = Arrays.stream(input.split("")).flatMap(c -> {
try {
return Arrays.stream(HarfBuzz.shapeString(font(), c));
} catch (Exception e) {
throw new RuntimeException(e);
}
}).mapToInt(ShapeGlyph::effectiveWidth).sum();
}).toArray(ShapeGlyph[]::new);

Assertions.assertNotEquals(sumCombined, sumSplit, "Shaping Arabic word should result in narrower shape");
Assertions.assertEquals(9109, sumCombined);
Assertions.assertEquals(9179, sumSplit);
Assertions.assertArrayEquals(new ShapeGlyph[]{
new ShapeGlyph(3921, 238, 0, 0, 0),
new ShapeGlyph(4541, 695, 0, 0, 0),
new ShapeGlyph(3883, 507, 0, 0, 0),
new ShapeGlyph(4859, 367, 0, 0, 0),
new ShapeGlyph(3975, 993, 0, 0, 0),
new ShapeGlyph(5376, 760, 0, 0, 0),
new ShapeGlyph(5156, 405, 0, 0, 0)
}, outputSplit);
}
}

0 comments on commit c839e54

Please sign in to comment.