-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
amanisky
committed
Nov 28, 2018
1 parent
f854902
commit 525af28
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |