function printText(text, positionX, positionY, alignment = 'left', baseline = 'alphabetic', style = 'normal', weight = 'normal', size = '10', font = 'Arial', colour = '#000', strokeStyle = false, lineWidth = false, strokeOnly = false){ // Save the styling, and content already on the canvas ctx.save(); // Do the alterations and print the text context.textAlign = alignment; context.textBaseline = baseline; // Set the font styling ctx.font = style+' '+weight+' '+size+'pt'+' '+font; //ctx.font-style = fontStyle; // normal, italic, oblique ctx.fillStyle = colour; if(strokeStyle && lineWidth){ // Set the stroke styling ctx.strokeStyle = strokeStyle; ctx.lineWidth = lineWidth; // Add the stroke (first, before fill) as it looks better ctx.strokeText(text, positionX, positionY); } if(!strokeOnly){ // Actually add the text ctx.fillText(text, positionX, positionY); } // Restore the prior existing canvas content ctx.restore(); }