S
S
Seryoga2015-02-24 13:32:48
Canvas
Seryoga, 2015-02-24 13:32:48

How to embed custom font in canvas?

There is a certain panel, drawn on canvas. The panel displays data, updated by ajax, the data is given by the php script. You need to embed a non-standard font.
For example, if I do this, then the variable on the canvas is displayed:

ctx.fillText( <script language="php"> 
               echo $sensor_data['ts']; 
       </script> , 40, 45);

And if so:
$HTML = '
<head>
        <link rel="stylesheet" href="font.css">
        <style type="text/css">
        h1 {
        font-family: "DSDIGI";
        }
    </style>
    </head>
  <body>
    	<h1>'.$ts.'</h1>
    </body>

';

and try to connect in canvas
ctx.fillText( <script language="php"> 
               print $HTML; 
       </script> , 40, 45);

then the whole canvas is not displayed, nothing is displayed.
If not in the canvas print $HTML; it is displayed without problems with the desired font.
What can be done to include the font in the canvas?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
SagePtr, 2015-02-25
@SagePtr

canvas can't draw html code

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question