Skip to content

Commit 1e3e9c6

Browse files
committed
new test
1 parent 7aeef38 commit 1e3e9c6

File tree

1 file changed

+66
-20
lines changed

1 file changed

+66
-20
lines changed

test/public/tests.js

Lines changed: 66 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -981,81 +981,127 @@ tests['textAlign center'] = function (ctx) {
981981
tests['textBaseline alphabetic'] = function (ctx) {
982982
ctx.strokeStyle = '#666'
983983
ctx.strokeRect(0, 0, 200, 200)
984-
ctx.lineTo(0, 100)
984+
ctx.moveTo(0, 50)
985+
ctx.lineTo(200, 50)
986+
ctx.moveTo(0, 100)
985987
ctx.lineTo(200, 100)
988+
ctx.moveTo(0, 150)
989+
ctx.lineTo(200, 150)
986990
ctx.stroke()
987991

988-
ctx.font = 'normal 30px Arial'
989992
ctx.textBaseline = 'alphabetic'
990993
ctx.textAlign = 'center'
994+
ctx.font = 'normal 30px Arial'
995+
ctx.fillText('alphabetic', 100, 50)
996+
ctx.font = 'normal 30px Verdana'
991997
ctx.fillText('alphabetic', 100, 100)
998+
ctx.font = 'normal 30px "Courier New"'
999+
ctx.fillText('alphabetic', 100, 150)
9921000
}
9931001

9941002
tests['textBaseline top'] = function (ctx) {
9951003
ctx.strokeStyle = '#666'
9961004
ctx.strokeRect(0, 0, 200, 200)
997-
ctx.lineTo(0, 100)
1005+
ctx.moveTo(0, 50)
1006+
ctx.lineTo(200, 50)
1007+
ctx.moveTo(0, 100)
9981008
ctx.lineTo(200, 100)
1009+
ctx.moveTo(0, 150)
1010+
ctx.lineTo(200, 150)
9991011
ctx.stroke()
10001012

1001-
ctx.font = 'normal 30px Arial'
10021013
ctx.textBaseline = 'top'
10031014
ctx.textAlign = 'center'
1015+
ctx.font = 'normal 30px Arial'
1016+
ctx.fillText('top', 100, 50)
1017+
ctx.font = 'normal 30px Verdana'
10041018
ctx.fillText('top', 100, 100)
1019+
ctx.font = 'normal 30px "Courier New"'
1020+
ctx.fillText('top', 100, 150)
10051021
}
10061022

10071023
tests['textBaseline hanging'] = function (ctx) {
10081024
ctx.strokeStyle = '#666'
10091025
ctx.strokeRect(0, 0, 200, 200)
1010-
ctx.lineTo(0, 100)
1026+
ctx.moveTo(0, 50)
1027+
ctx.lineTo(200, 50)
1028+
ctx.moveTo(0, 100)
10111029
ctx.lineTo(200, 100)
1030+
ctx.moveTo(0, 150)
1031+
ctx.lineTo(200, 150)
10121032
ctx.stroke()
10131033

1014-
ctx.font = 'normal 30px Arial'
10151034
ctx.textBaseline = 'hanging'
10161035
ctx.textAlign = 'center'
1036+
ctx.font = 'normal 30px Arial'
1037+
ctx.fillText('hanging', 100, 50)
1038+
ctx.font = 'normal 30px Verdana'
10171039
ctx.fillText('hanging', 100, 100)
1040+
ctx.font = 'normal 30px "Courier New"'
1041+
ctx.fillText('hanging', 100, 150)
10181042
}
10191043

10201044
tests['textBaseline middle'] = function (ctx) {
10211045
ctx.strokeStyle = '#666'
10221046
ctx.strokeRect(0, 0, 200, 200)
1023-
ctx.lineTo(0, 100)
1047+
ctx.moveTo(0, 50)
1048+
ctx.lineTo(200, 50)
1049+
ctx.moveTo(0, 100)
10241050
ctx.lineTo(200, 100)
1051+
ctx.moveTo(0, 150)
1052+
ctx.lineTo(200, 150)
10251053
ctx.stroke()
10261054

1027-
ctx.lineWidth = 30;
1028-
ctx.strokeStyle = 'red';
1029-
ctx.font = 'normal 30px Arial'
10301055
ctx.textBaseline = 'middle'
10311056
ctx.textAlign = 'center'
1057+
ctx.font = 'normal 30px Arial'
1058+
ctx.fillText('middle', 100, 50)
1059+
ctx.font = 'normal 30px Verdana'
10321060
ctx.fillText('middle', 100, 100)
1061+
ctx.font = 'normal 30px "Courier New"'
1062+
ctx.fillText('middle', 100, 150)
10331063
}
10341064

10351065
tests['textBaseline ideographic'] = function (ctx) {
10361066
ctx.strokeStyle = '#666'
10371067
ctx.strokeRect(0, 0, 200, 200)
1038-
ctx.lineTo(0, 100)
1068+
ctx.moveTo(0, 50)
1069+
ctx.lineTo(200, 50)
1070+
ctx.moveTo(0, 100)
10391071
ctx.lineTo(200, 100)
1072+
ctx.moveTo(0, 150)
1073+
ctx.lineTo(200, 150)
10401074
ctx.stroke()
10411075

1042-
ctx.font = 'normal 30px Arial'
10431076
ctx.textBaseline = 'ideographic'
10441077
ctx.textAlign = 'center'
1078+
ctx.font = 'normal 30px Arial'
1079+
ctx.fillText('ideographic', 100, 50)
1080+
ctx.font = 'normal 30px Verdana'
10451081
ctx.fillText('ideographic', 100, 100)
1082+
ctx.font = 'normal 30px "Courier New"'
1083+
ctx.fillText('ideographic', 100, 150)
10461084
}
10471085

10481086
tests['textBaseline bottom'] = function (ctx) {
10491087
ctx.strokeStyle = '#666'
10501088
ctx.strokeRect(0, 0, 200, 200)
1051-
ctx.lineTo(0, 100)
1089+
ctx.moveTo(0, 50)
1090+
ctx.lineTo(200, 50)
1091+
ctx.moveTo(0, 100)
10521092
ctx.lineTo(200, 100)
1093+
ctx.moveTo(0, 150)
1094+
ctx.lineTo(200, 150)
10531095
ctx.stroke()
10541096

1055-
ctx.font = 'normal 30px Arial'
10561097
ctx.textBaseline = 'bottom'
10571098
ctx.textAlign = 'center'
1099+
ctx.font = 'normal 30px Arial'
1100+
ctx.fillText('bottom', 100, 50)
1101+
ctx.font = 'normal 30px Verdana'
10581102
ctx.fillText('bottom', 100, 100)
1103+
ctx.font = 'normal 30px "Courier New"'
1104+
ctx.fillText('bottom', 100, 150)
10591105
}
10601106

10611107
tests['textBaseline alphabetic with scale'] = function (ctx) {
@@ -2600,10 +2646,10 @@ tests['transformed drawimage'] = function (ctx) {
26002646
}
26012647

26022648
tests['#1544 text scaling issue'] = function (ctx) {
2603-
ctx.font = '24px Verdana';
2604-
ctx.fillStyle = 'red';
2605-
ctx.textAlign = 'left';
2606-
ctx.textBaseline = 'top';
2607-
ctx.scale(1, 4);
2608-
ctx.fillText('2020', 20, 20);
2649+
ctx.font = '24px Verdana'
2650+
ctx.fillStyle = 'red'
2651+
ctx.textAlign = 'left'
2652+
ctx.textBaseline = 'top'
2653+
ctx.scale(1, 4)
2654+
ctx.fillText('2020', 20, 20)
26092655
}

0 commit comments

Comments
 (0)