Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overwrites options.canvas with default peramiters #6

Open
iceblu3710 opened this issue Feb 17, 2017 · 0 comments
Open

Overwrites options.canvas with default peramiters #6

iceblu3710 opened this issue Feb 17, 2017 · 0 comments

Comments

@iceblu3710
Copy link

In vtext.js#L192-L201 any passed information in the canvas is overwritten.

I need to pass my specific font information before calling vectorizeText as I work in called mm instead of px. so It would be nice to have the function check if a context was given and use that explicitly, else create the default canvas.

if(typeof document !== 'undefined') {
  defaultCanvas = document.createElement('canvas')
  defaultCanvas.width = 8192
  defaultCanvas.height = 1024
  defaultCanvas.id = "default"
  defaultContext = defaultCanvas.getContext("2d")
}




function vectorizeText(str, canvas, context, options) {
  if(canvas.id == "default") {
    var size = options.size || 64
    context.font = [
      options.fontStyle,
      options.fontVariant,
      options.fontWeight,
      size + "px",
      options.font
    ].filter(function(d) {return d}).join(" ")
    context.textAlign = "start"
    context.textBaseline = "alphabetic"
    context.direction = "ltr"
  }

  var pixels = getPixels(canvas, context, str, size)

  return processPixels(pixels, options, size)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant