| 1 |
<html dir="rtl"> |
| 2 |
<head> |
| 3 |
<title>Testing textpath</title> |
| 4 |
<style type="text/css"> |
| 5 |
@import "../../../../../dojo/resources/dojo.css"; |
| 6 |
@import "../../../../../dijit/tests/css/dijitTests.css"; |
| 7 |
</style> |
| 8 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| 9 |
|
| 10 |
<meta name="svg.render.forceflash" content="true"/> |
| 11 |
<script src="../../svgweb/svgweb/src/svg.js" data-path="../../svgweb/svgweb/src"></script> |
| 12 |
<script src="../../../../../dojo/dojo.js" data-dojo-config="isDebug:true,forceGfxRenderer:'svg'" type="text/javascript"></script> |
| 13 |
|
| 14 |
<script type="text/javascript"> |
| 15 |
|
| 16 |
dojo.require("dojox.gfx"); |
| 17 |
dojo.require("dojox.gfx._gfxBidiSupport"); |
| 18 |
dojo.require("doh.runner"); |
| 19 |
|
| 20 |
var CPD = 30, tp1, tp2, tp3, tp4, tp5, tp6, t1, t2, t3, t4, t5, t6; |
| 21 |
var g1 = null, g2 = null, g3, g4; |
| 22 |
|
| 23 |
var surfaceLTR = null, surfaceRTL = null, surfaceAUTO = null; |
| 24 |
|
| 25 |
var placeAnchor = function(surface, x, y){ |
| 26 |
surface.createLine({x1: x - 2, y1: y, x2: x + 2, y2: y}); |
| 27 |
surface.createLine({x1: x, y1: y - 2, x2: x, y2: y + 2}); |
| 28 |
}; |
| 29 |
|
| 30 |
var makeText = function(surface, text, font, fill, stroke){ |
| 31 |
var t = surface.createText(text); |
| 32 |
if(font) t.setFont(font); |
| 33 |
if(fill) t.setFill(fill); |
| 34 |
if(stroke) t.setStroke(stroke); |
| 35 |
placeAnchor(surface, text.x, text.y); |
| 36 |
return t; |
| 37 |
}; |
| 38 |
|
| 39 |
var makeShapes = function(){ |
| 40 |
var m = dojox.gfx.matrix; |
| 41 |
surfaceLTR = dojox.gfx.createSurface("testLTR", 500, 170, "ltr"); |
| 42 |
console.debug("surfaceLTR created"); |
| 43 |
|
| 44 |
surfaceLTR.whenLoaded(function() { |
| 45 |
var p = surfaceLTR.createPath({}) |
| 46 |
.moveTo(0, 15) |
| 47 |
.setAbsoluteMode(false) |
| 48 |
.curveTo(CPD, 0, 0, 0, 50, 0) |
| 49 |
; |
| 50 |
console.debug("p created"); |
| 51 |
tp1 = surfaceLTR.createTextPath({ |
| 52 |
text: "\u05d4\u05ea\u05d7\u05dc\u05d4 end." |
| 53 |
, align: "start" |
| 54 |
}) |
| 55 |
.moveTo(0, 15) |
| 56 |
.setAbsoluteMode(false) |
| 57 |
.curveTo(CPD, 0, 0, 0, 100, 0) |
| 58 |
.setFont({family: "times", size: "12pt"}) |
| 59 |
.setFill("blue") |
| 60 |
; |
| 61 |
console.debug("tp1 created"); |
| 62 |
tp2 = surfaceLTR.createTextPath({ |
| 63 |
text: "Beginning \u05e1\u05d5\u05e3." |
| 64 |
, align: "start" |
| 65 |
|
| 66 |
}) |
| 67 |
.moveTo(0, 50) |
| 68 |
.setAbsoluteMode(false) |
| 69 |
.curveTo(CPD, 0, 0, 0, 100, 0) |
| 70 |
.setFont({family: "times", size: "12pt"}) |
| 71 |
.setFill("blue") |
| 72 |
; |
| 73 |
console.debug("tp2 created"); |
| 74 |
|
| 75 |
g1 = surfaceLTR.createGroup(); |
| 76 |
g1.setTextDir("rtl"); |
| 77 |
|
| 78 |
t1 = makeText(g1, {id: "t1",x: 0, y: 100, text: "\u05d4\u05ea\u05d7\u05dc\u05d4 end."}, |
| 79 |
{family: "Times", size: "18pt"}, "black", "blue") |
| 80 |
.setTransform(m.rotategAt(0, 250, 150)); |
| 81 |
|
| 82 |
t2 = makeText(surfaceLTR, {x: 0, y: 140, text: "Beginning \u05e1\u05d5\u05e3."}, |
| 83 |
{family: "Times", size: "18pt"}, "black", "blue") |
| 84 |
.setTransform(m.rotategAt(0, 250, 100)); |
| 85 |
|
| 86 |
surfaceRTL = dojox.gfx.createSurface("testRTL", 500, 170); |
| 87 |
console.debug("surfaceRTL created"); |
| 88 |
|
| 89 |
surfaceRTL.whenLoaded(function(){ |
| 90 |
var p2 = surfaceRTL.createPath({}) |
| 91 |
.moveTo(0, 15) |
| 92 |
.setAbsoluteMode(false) |
| 93 |
.curveTo(CPD, 0, 0, 0, 100, 0) |
| 94 |
; |
| 95 |
console.debug("p2 created"); |
| 96 |
tp3 = surfaceRTL.createTextPath({ |
| 97 |
text: "\u05d4\u05ea\u05d7\u05dc\u05d4 end. " |
| 98 |
, align: "start" |
| 99 |
//, rotated: true |
| 100 |
}) |
| 101 |
.moveTo(0, 15) |
| 102 |
.setAbsoluteMode(false) |
| 103 |
.curveTo(CPD, 0, 100 - CPD, 0, 100, 0) |
| 104 |
.setFont({family: "times", size: "12pt"}) |
| 105 |
.setFill("red") |
| 106 |
; |
| 107 |
g2 = surfaceRTL.createGroup(); |
| 108 |
g2.add(tp3); |
| 109 |
g2.setTextDir("ltr"); |
| 110 |
|
| 111 |
g3 = g2.createGroup("rtl"); |
| 112 |
|
| 113 |
g4 = surfaceRTL.createGroup("auto"); |
| 114 |
console.debug("tp3 created"); |
| 115 |
tp4 = surfaceRTL.createTextPath({ |
| 116 |
text: "Beginning \u05e1\u05d5\u05e3." |
| 117 |
, align: "start" |
| 118 |
|
| 119 |
//, rotated: true |
| 120 |
}) |
| 121 |
//.setShape(p.shape) |
| 122 |
.moveTo(0, 50) |
| 123 |
.setAbsoluteMode(false) |
| 124 |
.curveTo(CPD, 0, 100 - CPD, 0, 100, 0) |
| 125 |
.setFont({family: "times", size: "12pt"}) |
| 126 |
.setFill("red") |
| 127 |
; |
| 128 |
console.debug("tp4 created"); |
| 129 |
|
| 130 |
t3 = makeText(g3, {id: "t1",x: 0, y: 100, text: "\u05d4\u05ea\u05d7\u05dc\u05d4 end."}, |
| 131 |
{family: "Times", size: "18pt"}, "black", "red") |
| 132 |
.setTransform(m.rotategAt(0, 250, 150)); |
| 133 |
|
| 134 |
t4 = makeText(surfaceRTL, {x: 0, y: 140, text: "Beginning \u05e1\u05d5\u05e3."}, |
| 135 |
{family: "Times", size: "18pt"}, "black", "red") |
| 136 |
.setTransform(m.rotategAt(0, 250, 100)); |
| 137 |
|
| 138 |
surfaceAUTO = dojox.gfx.createSurface("testAUTO", 500, 170,"auto"); |
| 139 |
console.debug("surfaceAUTO created"); |
| 140 |
|
| 141 |
surfaceAUTO.whenLoaded(function() { |
| 142 |
var p3 = surfaceAUTO.createPath({}) |
| 143 |
.moveTo(0, 15) |
| 144 |
.setAbsoluteMode(false) |
| 145 |
.curveTo(CPD, 0, 0, 0, 100, 0) |
| 146 |
; |
| 147 |
console.debug("p3 created"); |
| 148 |
|
| 149 |
tp5 = surfaceAUTO.createTextPath({ |
| 150 |
text: "\u05d4\u05ea\u05d7\u05dc\u05d4 end. " |
| 151 |
, align: "start" |
| 152 |
|
| 153 |
//, rotated: true |
| 154 |
}) |
| 155 |
//.setShape(p.shape) |
| 156 |
.moveTo(0, 15) |
| 157 |
.setAbsoluteMode(false) |
| 158 |
.curveTo(CPD, 0, 100 - CPD, 0, 100, 0) |
| 159 |
|
| 160 |
.setFont({family: "times", size: "12pt"}) |
| 161 |
.setFill("red") |
| 162 |
; |
| 163 |
console.debug("tp5 created"); |
| 164 |
tp6 = surfaceAUTO.createTextPath({ |
| 165 |
text: "Beginning \u05e1\u05d5\u05e3." |
| 166 |
, align: "start" |
| 167 |
|
| 168 |
//, rotated: true |
| 169 |
}) |
| 170 |
//.setShape(p.shape) |
| 171 |
.moveTo(0, 50) |
| 172 |
.setAbsoluteMode(false) |
| 173 |
.curveTo(CPD, 0, 100 - CPD, 0, 100, 0) |
| 174 |
.setFont({family: "times", size: "12pt"}) |
| 175 |
.setFill("blue") |
| 176 |
; |
| 177 |
console.debug("tp6 created"); |
| 178 |
|
| 179 |
t5 = makeText(surfaceAUTO, {id: "t1",x: 0, y: 100, text: "\u05d4\u05ea\u05d7\u05dc\u05d4 end."}, |
| 180 |
{family: "Times", size: "18pt"}, "black", "red") |
| 181 |
.setTransform(m.rotategAt(0, 250, 150)); |
| 182 |
|
| 183 |
t6 = makeText(surfaceAUTO, {x: 0, y: 140, text: "Beginning \u05e1\u05d5\u05e3."}, |
| 184 |
{family: "Times", size: "18pt"}, "black", "blue") |
| 185 |
.setTransform(m.rotategAt(0, 250, 100)); |
| 186 |
|
| 187 |
runTests(); |
| 188 |
}); |
| 189 |
}); |
| 190 |
}); |
| 191 |
}; |
| 192 |
|
| 193 |
function runTests(){ |
| 194 |
doh.register("Test inheritance", [ |
| 195 |
function surfaces_TextDir(){ |
| 196 |
doh.is("ltr", surfaceLTR.getTextDir(), "surfaceLTR.getTextDir"); |
| 197 |
doh.is("rtl", surfaceRTL.getTextDir(), "surfaceRTL.getTextDir"); |
| 198 |
doh.is("auto", surfaceAUTO.getTextDir(), "surfaceAUTO.getTextDir"); |
| 199 |
}, |
| 200 |
function groups_TextDir(){ |
| 201 |
doh.is("rtl", g1.getTextDir(), "g1.getTextDir"); |
| 202 |
doh.is("ltr", g2.getTextDir(), "g2.getTextDir"); |
| 203 |
doh.is("rtl", g3.getTextDir(), "g3.getTextDir"); |
| 204 |
doh.is("auto", g4.getTextDir(), "g4.getTextDir"); |
| 205 |
}, |
| 206 |
function gfxText_TextDir(){ |
| 207 |
doh.is("rtl", t1.textDir, "t1.getTextDir"); |
| 208 |
doh.is("ltr", t2.textDir, "t2.getTextDir"); |
| 209 |
doh.is("rtl", t3.textDir, "t3.getTextDir"); |
| 210 |
doh.is("rtl", t4.textDir, "t4.getTextDir"); |
| 211 |
doh.is("auto", t5.textDir, "t5.getTextDir"); |
| 212 |
doh.is("auto", t6.textDir, "t6h.getTextDir"); |
| 213 |
}, |
| 214 |
function gfxTextPath_TextDir(){ |
| 215 |
doh.is("ltr", tp1.textDir, "tp1.getTextDir"); |
| 216 |
doh.is("ltr", tp2.textDir, "tp2.getTextDir"); |
| 217 |
doh.is("ltr", tp3.textDir, "tp3.getTextDir"); |
| 218 |
doh.is("rtl", tp4.textDir, "tp4.getTextDir"); |
| 219 |
doh.is("auto", tp5.textDir, "tp5.getTextDir"); |
| 220 |
doh.is("auto", tp6.textDir, "tp6.getTextDir"); |
| 221 |
}, |
| 222 |
function changeSurfaceRTLextDir(){ |
| 223 |
surfaceRTL.setTextDir("ltr"); |
| 224 |
|
| 225 |
doh.is("ltr", surfaceRTL.getTextDir(), "surfaceRTL.getTextDir"); |
| 226 |
|
| 227 |
doh.is("ltr", g2.getTextDir(), "g2.getTextDir"); |
| 228 |
doh.is("ltr", g3.getTextDir(), "g3.getTextDir"); |
| 229 |
doh.is("ltr", g4.getTextDir(), "g4.getTextDir"); |
| 230 |
|
| 231 |
|
| 232 |
doh.is("ltr", t3.textDir, "t3.getTextDir"); |
| 233 |
doh.is("ltr", t4.textDir, "t4.getTextDir"); |
| 234 |
|
| 235 |
doh.is("ltr", tp3.textDir, "tp3.getTextDir"); |
| 236 |
doh.is("ltr", tp4.textDir, "tp4.getTextDir"); |
| 237 |
}, |
| 238 |
function changeGroupTextDir(){ |
| 239 |
|
| 240 |
g3.add(tp5); |
| 241 |
g3.add(t2); |
| 242 |
|
| 243 |
g2.setTextDir("rtl"); |
| 244 |
|
| 245 |
doh.is("rtl", g2.getTextDir(), "g2.getTextDir"); |
| 246 |
// son of g2 |
| 247 |
doh.is("rtl", g3.getTextDir(), "g3.getTextDir"); |
| 248 |
|
| 249 |
doh.is("rtl", t2.textDir, "t2.getTextDir"); |
| 250 |
doh.is("rtl", t3.textDir, "t3.getTextDir"); |
| 251 |
|
| 252 |
doh.is("rtl", tp5.textDir, "tp3.getTextDir"); |
| 253 |
} |
| 254 |
]); |
| 255 |
|
| 256 |
doh.run(); |
| 257 |
} |
| 258 |
|
| 259 |
dojo.addOnLoad(makeShapes); |
| 260 |
|
| 261 |
</script> |
| 262 |
</head> |
| 263 |
<body> |
| 264 |
<h1>dojox.gfx Text on a Path test</h1> |
| 265 |
<h2>LTR TextPath and Text first two are TextPath and two others are Text</h2> |
| 266 |
<div id="testLTR" style="width: 500px;"></div> |
| 267 |
<h2>RTL Text Path and Text first two are TextPath and two others are Text</h2> |
| 268 |
<div id="testRTL" style="width: 500px;"></div> |
| 269 |
<h2>AUTO Text Path and Text first two are TextPath and two others are Text</h2> |
| 270 |
<div id="testAUTO" style="width: 500px;"></div> |
| 271 |
|
| 272 |
<p>That's all Folks!</p> |
| 273 |
</body> |
| 274 |
</html> |