Files
openlayers/master/examples/textBidiSvgWeb.html
Éric Lemoine 5d14b9e2d4 Updated
2013-02-20 10:38:25 +01:00

81 lines
3.0 KiB
HTML

<html>
<head>
<title>Testing text</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
@import "../../../../../dojo/resources/dojo.css";
@import "../../../../../dijit/tests/css/dijitTests.css";
</style>
<!-- SVGWEB { -->
<meta name="svg.render.forceflash" content="true"/>
<script src="../../svgweb/svgweb/src/svg.js" data-path="../../svgweb/svgweb/src"></script>
<script src="../../../../../dojo/dojo.js" djConfig="isDebug:true,forceGfxRenderer:'svg'" type="text/javascript"></script>
<!-- } -->
<script type="text/javascript">
dojo.require("dojox.gfx");
dojo.require("dojox.gfx._gfxBidiSupport");
var surface = null, t1, t2, t3, t4, t5;
var placeAnchor = function(surface, x, y){
surface.createLine({x1: x - 2, y1: y, x2: x + 2, y2: y});
surface.createLine({x1: x, y1: y - 2, x2: x, y2: y + 2});
};
var makeText = function(surface, text, font, fill, stroke){
var t = surface.createText(text);
if(font) t.setFont(font);
if(fill) t.setFill(fill);
if(stroke) t.setStroke(stroke);
placeAnchor(surface, text.x, text.y);
return t;
};
makeShapes = function(){
surface = dojox.gfx.createSurface("test", 500, 500);
surface.whenLoaded(function() {
var m = dojox.gfx.matrix;
//surface.createLine({x1: 250, y1: 0, x2: 250, y2: 500}).setStroke("green");
t1 = makeText(surface, {id: "t1",x: 250, y: 50, text: "@ \u05e9\u05dc\u05d5\u05dd world LTR!", textDir:"ltr"},
{family: "Times", size: "24pt"}, "black", "red")
.setTransform(m.rotategAt(0, 250, 50));
t2 = makeText(surface, {x: 250, y: 100, text: "@ Hello \u05e2\u05d5\u05dc\u05dd LTR!", textDir:"ltr"},
{family: "Times", size: "24pt"}, "black", "red")
.setTransform(m.rotategAt(0, 250, 100));
t3 = makeText(surface, {x: 250, y: 150, text: "@ \u05e9\u05dc\u05d5\u05dd world RTL!", textDir:"rtl"},
{family: "Times", size: "24pt"}, "red", "black")
.setTransform(m.rotategAt(0, 250, 150));
t4 = makeText(surface, {x: 250, y: 200, text: "@ Hello \u05e2\u05d5\u05dc\u05dd RTL!", kerning: true,textDir:"rtl"},
{family: "Times", size: "24pt"}, "red", "black")
.setTransform(m.rotategAt(0, 250, 200));
t5 = makeText(surface, {x: 250, y: 250, text: "@ \u05e9\u05dc\u05d5\u05dd world AUTO!", kerning: false,textDir:"auto"},
{family: "Times", size: "24pt"}, "red", "black")
.setTransform(m.rotategAt(0, 250, 250));
t6 = makeText(surface, {x: 250, y: 300, text: "@ Hello \u05e2\u05d5\u05dc\u05dd AUTO!", kerning: false,textDir:"auto"},
{family: "Times", size: "24pt"}, "black", "red")
.setTransform(m.rotategAt(0, 250, 300));
});
};
dojo.addOnLoad(makeShapes);
</script>
</head>
<body>
<h1>dojox.gfx Text test</h1>
<h2>The black colored sentences should be in LTR layout</h2>
<h2>The red colored sentences should be in RTL layout</h2>
<div id="test" style="width: 700px; height: 500px;"></div>
</body>
</html>