Wizcorp / Ejecta-X

A Fast, Open Source JavaScript, Canvas & Audio Implementation
http://wizcorp.github.io/Ejecta-X
185 stars 50 forks source link

Text not rendering on Canvas #52

Closed gopalpradhan closed 10 years ago

gopalpradhan commented 10 years ago

Hi,

I'm trying the following code. All drawing ops like fillRect, beizerCurveTo, quadraticCurveTo etc works fine. But unable to render any text on the canvas. Am I missing something ?

var context =canvas.getContext("2d"); context.fillStyle = "blue"; context.font = "16px LiberationMono-Regular.ttf"; context.fillRect(25,25,100,100); context.clearRect(45,45,60,60); context.strokeRect(50,50,50,50); context.fillStyle = "cyan";

context.fillText("Hello World", 45, 45);

come commented 10 years ago

i have the same problem, i understand that we need to manually add the desired ttf file, but where ? and how to load it ?

thx for your great job anyway

come commented 10 years ago

tried to correct it with my last commit (PR #55 )

aogilvie commented 10 years ago

@gopalpradhan

56 is currently waiting review, once it is merged you can add arial file to the assets/www/arial for example then use for example:

ctx.fillStyle = "#ff00ff"; ctx.font = "50pt arial"; ctx.fillText("hello", 100, 100);

@come Thanks again for your PR!

aogilvie commented 10 years ago

Fixed in #56