【问题标题】:how to underline the text in jcanvas jquery, when we click on underline checkbox当我们单击下划线复选框时,如何在 jcanvas jquery 中为文本添加下划线
【发布时间】:2015-05-06 10:11:45
【问题描述】:

我正在创建一种编辑器,当用户在文本区域中输入文本并单击添加文本时,他/她的文本会添加到画布中。 所以,我需要一个选项,如果用户想为特定文本加下划线,他也可以这样做。这里我为下划线选项添加了复选框。我已经使用 Jcanvas jquery 完成了这项工作。

我的html代码是:

<input type="checkbox" id="Underline"  name="Underline" value="">Underline Add text<textarea id="add_text" ></textarea>   
<button onclick="addText()">add text</button>
<canvas id="maincanvas" width="500" height="400" style="background-color: #FFF;"> </canvas>

JavaScript 代码:

function addText(){
    var textvalue=document.getElementById("add_text");
    var $canvas = $("#maincanvas");

    $canvas.drawText({
      draggable: true,
      name: "demo",
      layer: true,
      fillStyle: "#000",
      x: 90,
      y: 10,
      text: textvalue,
    });
}

【问题讨论】:

标签: javascript jquery jcanvas


【解决方案1】:

HTML Canvas 上下文的文本方法中没有“文本装饰”或类似的可用。您可以将其设为粗体或倾斜(通过 fontStyle 属性),但下划线不可用。

但它们存在一种解决方法,explained here

【讨论】:

    猜你喜欢
    • 2021-09-24
    • 2013-02-21
    • 2012-09-07
    • 2012-04-18
    • 2011-04-13
    • 1970-01-01
    • 1970-01-01
    • 2015-05-29
    • 1970-01-01
    相关资源
    最近更新 更多