字体样式斜体有时在Firefox中不起作用

时间:2014-07-11 03:45:22

标签: css .htaccess fonts

我在这里有一个画布,用户可以在其中输入自己的消息..并且能够更改字体,字体样式和大小。 。一切都在safari,opera,chrome中运行良好,但是当涉及到firefox时,它根本不起作用。除非我禁用斜体时间的“用户硬件加速时间”,否则它什么都不做。

顺便说一句,我使用(fonts.googleapis.com)来使用来自谷歌的现有Css。

我已经使用.htaccess的技巧来解决问题但仍然无法正常工作。

我怎么能解决这个问题?

1 个答案:

答案 0 :(得分:0)

我尝试过它

var canvas = document.getElementById("check");
var ctx = canvas.getContext('2d');
ctx.font = "italic 40px Arial";
ctx.fillText("Impact", 0, 40);

小提琴

Fiddle

尝试更新

var userinputstr='';
var italic=0;
function draw(){
var canvas = document.getElementById("check");
var ctx = canvas.getContext('2d');
ctx.clearRect(0,0,300,50);
if(italic==0)
{
ctx.font = "40px Lato";
ctx.fillText(userinputstr, 0, 40);
}
else
{
ctx.font = "Italic 40px Lato";
ctx.fillText(userinputstr, 0, 40);
}
}
userinputstr=$("#userinput").val();
draw();
$("#userinput").keyup(function(){
userinputstr=$("#userinput").val();
draw();
});
$("#clickbut").click(function(){
italic=1;
draw();
});

updated Fiddle