Print character from bootstrap hexadecimal icon

I found out how to get the value of the boot icon.

Example (with glyphicon-trash symbol):

HTML:

<div id="icon" class="glyphicon glyphicon-trash"></div>

JS:

var iconSymbol = window.getComputedStyle($('#icon')[0], ':before').content;
var result = iconSymbol.charCodeAt(1).toString(16);
console.log(result);

After that resultthere is e020.

But after that I need to draw this symbol in canvas.

Assuming that value- e020, I am using the following code:

var label = String.fromCharCode(parseInt(value, 16));
var ctx = canvas.getContext("2d");
ctx.font = "52px Helvetica"
ctx.textAlign = "center"
ctx.fillStyle = "white"
ctx.fillText(label, pt.x, pt.y+4)

But after that I only have the rectangle symbol.

What do I need to correctly output the source character? Maybe the problem is in setting the font, or do I need to try some encoding options?

+4
source share
1 answer

, , . Helvetica , sans-serif , Helvetica.

:

glyphicons-halflings-regular.*

/. , . , DOM.

+2

All Articles