From b482020401b7c001ac68a614ca7f36be31c2df01 Mon Sep 17 00:00:00 2001 From: Maxim Date: Mon, 2 Sep 2024 18:57:52 +0300 Subject: [PATCH] WCAG. Fix symbol ends calculation --- .../gf/model/factory/chunks/ChunkParser.java | 15 +++++++-------- .../gf/model/factory/chunks/TextPieces.java | 1 + 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/wcag-validation/src/main/java/org/verapdf/gf/model/factory/chunks/ChunkParser.java b/wcag-validation/src/main/java/org/verapdf/gf/model/factory/chunks/ChunkParser.java index 1c953b76f..29c1971a8 100644 --- a/wcag-validation/src/main/java/org/verapdf/gf/model/factory/chunks/ChunkParser.java +++ b/wcag-validation/src/main/java/org/verapdf/gf/model/factory/chunks/ChunkParser.java @@ -45,7 +45,6 @@ import java.util.*; import java.util.logging.Level; import java.util.logging.Logger; -import java.util.stream.Collectors; /** * @author Maxim Plushchov @@ -684,14 +683,17 @@ private void putChunk(Long mcid, IChunk chunk) { } private List parseTextShowArgument(COSBase argument, StringBuilder unicodeValue, Matrix textRenderingMatrix) { - List symbolEnds = new ArrayList<>(); if (argument.getType() == COSObjType.COS_STRING) { + List symbolEnds = new ArrayList<>(); + symbolEnds.add(0.0); textRenderingMatrix.concatenate(calculateTextRenderingMatrix()); parseString((COSString) argument.getDirectBase(), unicodeValue, null, symbolEnds); if (!symbolEnds.isEmpty()) { textMatrix.concatenate(Matrix.getTranslateInstance(symbolEnds.get(symbolEnds.size() - 1), 0)); } - } else if (argument.getType() == COSObjType.COS_ARRAY) { + return symbolEnds; + } + if (argument.getType() == COSObjType.COS_ARRAY) { COSArray array = (COSArray) argument; TextPieces textPieces = new TextPieces(); for (COSObject obj : array) { @@ -715,12 +717,9 @@ private List parseTextShowArgument(COSBase argument, StringBuilder unico } else { textMatrix.concatenate(Matrix.getTranslateInstance(textPieces.getCurrentX(), 0)); } - symbolEnds = textPieces.getSymbolEnds(); + return textPieces.getSymbolEnds(); } - symbolEnds.add(0, 0.0); - double multiplier = Math.sqrt(textMatrix.getScaleX() * textMatrix.getScaleX() + - textMatrix.getShearY() * textMatrix.getShearY()); - return symbolEnds.stream().map(e -> e * multiplier).collect(Collectors.toList()); + return Collections.emptyList(); } private void parseString(COSString string, StringBuilder unicodeValue, TextPieces textPieces, List symbolEnds) { diff --git a/wcag-validation/src/main/java/org/verapdf/gf/model/factory/chunks/TextPieces.java b/wcag-validation/src/main/java/org/verapdf/gf/model/factory/chunks/TextPieces.java index 557097378..63c1afb28 100644 --- a/wcag-validation/src/main/java/org/verapdf/gf/model/factory/chunks/TextPieces.java +++ b/wcag-validation/src/main/java/org/verapdf/gf/model/factory/chunks/TextPieces.java @@ -69,6 +69,7 @@ public void setCurrentX(double currentX) { public List getSymbolEnds() { List ends = new ArrayList<>(); + ends.add(0.0); for (TextPiece textPiece : textPieces) { TextChunksHelper.updateSymbolEnds(ends, textPiece.endX - textPiece.startX, textPiece.startX, textPiece.value != null ? textPiece.value.length() : 0);