Skip to content

Commit d73c491

Browse files
author
David Khuu
committed
Adjustments to font to fit the canvas
Changing the values of the font size to make it fit within the signature pad and look the same before the resolution changes. rpmsoftware#10
1 parent 51870ca commit d73c491

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

injectedJavaScript/application.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,14 @@ var content = (penColor, backgroundColor, dataURL, penMinWidth, penMaxWidth, use
6868
canvasElement.width = oldWidth * 2;
6969
canvasElement.height = oldHeight * 2;
7070
71-
var ratio = (bodyWidth/bodyHeight);
72-
var fontSize = 45 * ratio;
73-
var textHeight = 12 * ratio;
71+
var fontSize = 70;
72+
var textHeight = 18;
7473
var textWidth = -1;
7574
do {
7675
context.font = fontSize + "px SignatureFont";
7776
textWidth = context.measureText("${name}").width;
7877
fontSize = 7 * fontSize / 8;
79-
} while (textWidth > w);
78+
} while (textWidth + (w * 0.05) > w);
8079
8180
var textPosition = {
8281
x: ((w - textWidth) / 2),

0 commit comments

Comments
 (0)