function runTest() { var doc = $("svg").contentWindow.document; var text1 = doc.getElementById("text1"); var text2 = doc.getElementById("text2");
var charWidth = text1.getSubStringLength(0, 1);
if (navigator.userAgent.indexOf("Linux") > -1 && charWidth == 241) {
// Workaround for a slight difference in 'charWidth' (i.e. the width of
// the 'a' char) on Linux build machines after bug 1342951. The issue
// doesn't reproduce locally on Ubuntu 17.04 so is particularly tricky to
// debug.
charWidth = 240;
}
var epsilon = 0.001;
function isClose(a, b, str) {
ok(Math.abs(a - b) < epsilon, str + " - " + b + " should be close to " + a);
}
function isPointCloseX(pt1, x, y, str) {
isClose(pt1.x, x, str + " x");
is(pt1.y, y, str + " y");
}
// character 12 should be on the bottom side
is(text2.getStartPositionOfChar(12).y, 860, "text2 char 12 start offset");
isfuzzy(text2.getEndPositionOfChar(12).y, 860, 0.001, "text2 char 12 end offset");
ok(text2.getExtentOfChar(12).y < 860, "text2 char 12 extent y");
ok(ymost(text2.getExtentOfChar(12)) > 860, "text2 char 12 extent height");
isfuzzy(text2.getRotationOfChar(12), 180, 0.001, "text2 char 12 rotation");
p.x = text2.getExtentOfChar(12).x + 0.1;
p.y = ymost(text2.getExtentOfChar(12)) - 0.1;
is(text2.getCharNumAtPosition(p), 12, "text2 finding char 12");
// This next test is tricky. The glyph for character 3 may overlap from the above
// but character 12 wins because it's the last to render
p.y = text2.getExtentOfChar(12).y + 0.1;
is(text2.getCharNumAtPosition(p), 12, "text2 finding last rendered char");
}
function runTests() {
runTest();
var doc = $("svg").contentWindow.document;
doc.getElementById("g").setAttribute("transform", "rotate(90 200 200)");
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.