Skip to content

Commit

Permalink
WCAG. Fix symbol ends calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximPlusov committed Sep 2, 2024
1 parent 4b17b01 commit b482020
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -684,14 +683,17 @@ private void putChunk(Long mcid, IChunk chunk) {
}

private List<Double> parseTextShowArgument(COSBase argument, StringBuilder unicodeValue, Matrix textRenderingMatrix) {
List<Double> symbolEnds = new ArrayList<>();
if (argument.getType() == COSObjType.COS_STRING) {
List<Double> 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) {
Expand All @@ -715,12 +717,9 @@ private List<Double> 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<Double> symbolEnds) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public void setCurrentX(double currentX) {

public List<Double> getSymbolEnds() {
List<Double> 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);
Expand Down

0 comments on commit b482020

Please sign in to comment.