Skip to content

Commit

Permalink
设置字体
Browse files Browse the repository at this point in the history
  • Loading branch information
amanisky committed Nov 28, 2018
1 parent f854902 commit 525af28
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions 04.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>04、设置字体</title>
</head>
<body>
<div>
<label><input type="radio" name="family" value="SimSun">宋体</label>
<label><input type="radio" name="family" value="SimHei">黑体</label>
<label><input type="radio" name="family" value="Microsoft Yahei">微软雅黑</label>
<label><input type="radio" name="family" value="STLiti">华文隶书</label>
</div>
<canvas id="c"></canvas>
<script src="./bower_components/jQuery/dist/jquery.js"></script>
<script src="./bower_components/fabric.js/dist/fabric.js"></script>
<script>
var canvas = new fabric.Canvas('c', { width: 500, height: 300, backgroundColor: '#ccc' });
var textbox = new fabric.Textbox('常见内置中文字体 常见内置中文字体', { left: 50, top: 50, fontSize: 20 });
canvas
.add(textbox)
.setActiveObject(textbox);

$('input').change(function () {
textbox.set("fontFamily", $(this).val());
canvas.requestRenderAll();
});
</script>
</body>
</html>

0 comments on commit 525af28

Please sign in to comment.