Skip to content

Commit

Permalink
Fix text scaling
Browse files Browse the repository at this point in the history
  • Loading branch information
gpeal committed Nov 26, 2022
1 parent b2582c4 commit 1b06fd6
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ private void drawTextWithGlyphs(
for (int i = 0; i < textLineCount; i++) {
String textLine = textLines.get(i);
float boxWidth = documentData.boxSize == null ? 0f : documentData.boxSize.x;
List<TextSubLine> lines = splitGlyphTextIntoLines(textLine, boxWidth, font, fontScale, tracking, parentScale, true);
List<TextSubLine> lines = splitGlyphTextIntoLines(textLine, boxWidth, font, fontScale, tracking, true);
for (int j = 0; j < lines.size(); j++) {
TextSubLine line = lines.get(j);
lineIndex++;
Expand All @@ -223,7 +223,7 @@ private void drawGlyphTextLine(String text, DocumentData documentData,
continue;
}
drawCharacterAsGlyph(character, fontScale, documentData, canvas);
float tx = (float) character.getWidth() * fontScale * Utils.dpScale() * parentScale + tracking * parentScale;
float tx = (float) character.getWidth() * fontScale * Utils.dpScale() + tracking;
canvas.translate(tx, 0);
}
}
Expand Down Expand Up @@ -265,7 +265,7 @@ private void drawTextWithFont(DocumentData documentData, Font font, Canvas canva
for (int i = 0; i < textLineCount; i++) {
String textLine = textLines.get(i);
float boxWidth = documentData.boxSize == null ? 0f : documentData.boxSize.x;
List<TextSubLine> lines = splitGlyphTextIntoLines(textLine, boxWidth, font, 0f, tracking, 0f, false);
List<TextSubLine> lines = splitGlyphTextIntoLines(textLine, boxWidth, font, 0f, tracking, false);
for (int j = 0; j < lines.size(); j++) {
TextSubLine line = lines.get(j);
lineIndex++;
Expand Down Expand Up @@ -334,8 +334,7 @@ private void drawFontTextLine(String text, DocumentData documentData, Canvas can
}
}

private List<TextSubLine> splitGlyphTextIntoLines(
String textLine, float boxWidth, Font font, float fontScale, float tracking, float parentScale, boolean usingGlyphs) {
private List<TextSubLine> splitGlyphTextIntoLines(String textLine, float boxWidth, Font font, float fontScale, float tracking, boolean usingGlyphs) {
int lineCount = 0;

float currentLineWidth = 0;
Expand All @@ -357,7 +356,7 @@ private List<TextSubLine> splitGlyphTextIntoLines(
if (character == null) {
continue;
}
currentCharWidth = (float) character.getWidth() * fontScale * Utils.dpScale() * parentScale + tracking * parentScale;
currentCharWidth = (float) character.getWidth() * fontScale * Utils.dpScale() + tracking;
} else {
currentCharWidth = fillPaint.measureText(textLine.substring(i, i + 1)) + tracking;
}
Expand Down

0 comments on commit 1b06fd6

Please sign in to comment.