Mercurial > MadButterfly
comparison nodejs/svg.js @ 902:e86b4d56ddea
Parse font-style and font-weight of SVG text
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Fri, 01 Oct 2010 12:20:26 +0800 |
parents | ec94dd788332 |
children | e4474cac20da |
comparison
equal
deleted
inserted
replaced
901:74e3ba4d3fa1 | 902:e86b4d56ddea |
---|---|
203 var x = getInteger(n,'x'); | 203 var x = getInteger(n,'x'); |
204 var y = getInteger(n,'y'); | 204 var y = getInteger(n,'y'); |
205 var tcoord = this.mb_rt.coord_new(coord); | 205 var tcoord = this.mb_rt.coord_new(coord); |
206 var style; | 206 var style; |
207 var family = "Courier"; | 207 var family = "Courier"; |
208 var weight = 80; | |
209 var slant = 0; | |
208 var sz = 10; | 210 var sz = 10; |
209 var face; | 211 var face; |
210 var k; | 212 var k; |
211 var obj = this.mb_rt.stext_new(n.text(),x,y); | 213 var obj = this.mb_rt.stext_new(n.text(),x,y); |
212 | 214 |
219 | 221 |
220 if("font-family" in style) | 222 if("font-family" in style) |
221 family = style["font-family"]; | 223 family = style["font-family"]; |
222 if("font-size" in style) | 224 if("font-size" in style) |
223 sz = _parse_font_size(style["font-size"]); | 225 sz = _parse_font_size(style["font-size"]); |
224 | 226 if("font-weight" in style) { |
225 face = this.mb_rt.font_face_query(family, 100, 210); | 227 if(style["font-weight"] == "bold") |
228 weight = 200; | |
229 } | |
230 if("font-style" in style) { | |
231 if(style["font-style"] == "oblique") | |
232 slant = 110; | |
233 } | |
234 | |
235 face = this.mb_rt.font_face_query(family, slant, weight); | |
226 obj.set_style([[n.text().length, face, sz]]); | 236 obj.set_style([[n.text().length, face, sz]]); |
227 | 237 |
228 tcoord.add_shape(obj); | 238 tcoord.add_shape(obj); |
229 tcoord.set_text = tspan_set_text; | 239 tcoord.set_text = tspan_set_text; |
230 tcoord.text = obj; | 240 tcoord.text = obj; |