(str, canvas, context, options)
| 39341 | } |
| 39342 | |
| 39343 | function vectorizeText(str, canvas, context, options) { |
| 39344 | var size = 64 |
| 39345 | var lineSpacing = 1.25 |
| 39346 | var styletags = { |
| 39347 | breaklines: false, |
| 39348 | bolds: false, |
| 39349 | italics: false, |
| 39350 | subscripts: false, |
| 39351 | superscripts: false |
| 39352 | } |
| 39353 | |
| 39354 | if(options) { |
| 39355 | |
| 39356 | if(options.size && |
| 39357 | options.size > 0) size = |
| 39358 | options.size |
| 39359 | |
| 39360 | if(options.lineSpacing && |
| 39361 | options.lineSpacing > 0) lineSpacing = |
| 39362 | options.lineSpacing |
| 39363 | |
| 39364 | if(options.styletags && |
| 39365 | options.styletags.breaklines) styletags.breaklines = |
| 39366 | options.styletags.breaklines ? true : false |
| 39367 | |
| 39368 | if(options.styletags && |
| 39369 | options.styletags.bolds) styletags.bolds = |
| 39370 | options.styletags.bolds ? true : false |
| 39371 | |
| 39372 | if(options.styletags && |
| 39373 | options.styletags.italics) styletags.italics = |
| 39374 | options.styletags.italics ? true : false |
| 39375 | |
| 39376 | if(options.styletags && |
| 39377 | options.styletags.subscripts) styletags.subscripts = |
| 39378 | options.styletags.subscripts ? true : false |
| 39379 | |
| 39380 | if(options.styletags && |
| 39381 | options.styletags.superscripts) styletags.superscripts = |
| 39382 | options.styletags.superscripts ? true : false |
| 39383 | } |
| 39384 | |
| 39385 | context.font = [ |
| 39386 | options.fontStyle, |
| 39387 | options.fontVariant, |
| 39388 | options.fontWeight, |
| 39389 | size + "px", |
| 39390 | options.font |
| 39391 | ].filter(function(d) {return d}).join(" ") |
| 39392 | context.textAlign = "start" |
| 39393 | context.textBaseline = "alphabetic" |
| 39394 | context.direction = "ltr" |
| 39395 | |
| 39396 | var pixels = getPixels(canvas, context, str, size, lineSpacing, styletags) |
| 39397 | |
| 39398 | return processPixels(pixels, options, size) |
| 39399 | } |
| 39400 |
no test coverage detected
searching dependent graphs…