Showing posts from May, 2017

Text styling of HTML5 Canvas using fabricjs

In previous post I have shared code to add text to HTML5 canvas using fabricjs. refer

Here in this post below is the code to change text style to italic, making text bold and underline the text using fabricjs on html5 canvas.

This code will work when text object is selected.

<canvasid="c"width="600"height="600"></canvas><inputtype="text"class="add-text"><buttonclass="add-text-btn">Add Text</button><buttonclass="bold-text-btn">Bold</button><buttonclass="underline-text-btn">Underline</button><buttonclass="italic-text-btn">Italic</button>
javascript code:
// initialize fabric canvas and assign to global windows object for debugvar canvas =window._canvas =new fabric.Canvas('c'); fabric.Image.fromURL('', fun…