|
@@ -380,7 +380,7 @@ export class SCanvasPaintEngine extends SPaintEngine {
|
|
|
* @param font 字体
|
|
|
*/
|
|
|
changeFont(font: SFont): void {
|
|
|
- this._canvas.font = `${font.size}px ${font.name}`;
|
|
|
+ this._canvas.font = `${font.weight} ${font.size}px ${font.name}`;
|
|
|
this.setTextAlign(font.textAlign);
|
|
|
this.setBaseLine(font.textBaseLine);
|
|
|
this.setTextDirection(font.textDirection);
|
|
@@ -534,7 +534,7 @@ export class SCanvasPaintEngine extends SPaintEngine {
|
|
|
* 设置字体
|
|
|
*/
|
|
|
private setFont(): void {
|
|
|
- this._canvas.font = `${this.state.font.size}px ${this.state.font.name}`;
|
|
|
+ this._canvas.font = `${this.state.font.weight} ${this.state.font.size}px ${this.state.font.name}`;
|
|
|
this.setTextAlign(this.state.font.textAlign);
|
|
|
this.setBaseLine(this.state.font.textBaseLine);
|
|
|
this.setTextDirection(this.state.font.textDirection);
|
|
@@ -574,20 +574,28 @@ export class SCanvasPaintEngine extends SPaintEngine {
|
|
|
* @param value 对齐方式
|
|
|
*/
|
|
|
private setBaseLine(value: STextBaseLine): void {
|
|
|
+ // 没有传入类型
|
|
|
if (value == undefined) {
|
|
|
return;
|
|
|
}
|
|
|
+
|
|
|
+ // 类型为文本基线是普通的字母基线
|
|
|
if (value == STextBaseLine.Alphabetic) {
|
|
|
this._canvas.textBaseline = "alphabetic";
|
|
|
} else if (value == STextBaseLine.Top) {
|
|
|
+ // 文本基线是 em 方框的顶端
|
|
|
this._canvas.textBaseline = "top";
|
|
|
} else if (value == STextBaseLine.Hanging) {
|
|
|
+ // 文本基线是悬挂基线
|
|
|
this._canvas.textBaseline = "hanging";
|
|
|
} else if (value == STextBaseLine.Middle) {
|
|
|
+ // 文本基线是 em 方框的正中
|
|
|
this._canvas.textBaseline = "middle";
|
|
|
} else if (value == STextBaseLine.Ideographic) {
|
|
|
+ // 文本基线是表意基线
|
|
|
this._canvas.textBaseline = "ideographic";
|
|
|
} else {
|
|
|
+ // 文本基线是 em 方框的底端
|
|
|
this._canvas.textBaseline = "bottom";
|
|
|
}
|
|
|
}
|
|
@@ -598,14 +606,18 @@ export class SCanvasPaintEngine extends SPaintEngine {
|
|
|
* @param value 文本方向
|
|
|
*/
|
|
|
private setTextDirection(value: STextDirection): void {
|
|
|
+ // 没有传入类型
|
|
|
if (value == undefined) {
|
|
|
return;
|
|
|
}
|
|
|
+ // 默认
|
|
|
if (value == STextDirection.Inherit) {
|
|
|
this._canvas.direction = "inherit";
|
|
|
} else if (value == STextDirection.LTR) {
|
|
|
+ // 文本方向从左向右
|
|
|
this._canvas.direction = "ltr";
|
|
|
} else {
|
|
|
+ // 文本方向从右向左
|
|
|
this._canvas.direction = "rtl";
|
|
|
}
|
|
|
}
|
|
@@ -629,6 +641,7 @@ export class SCanvasPaintEngine extends SPaintEngine {
|
|
|
*
|
|
|
*/
|
|
|
setClip(): void {
|
|
|
+ // 存有裁剪路劲
|
|
|
if (this.state.clip) {
|
|
|
this.drawWay(this.state.clip);
|
|
|
this._canvas.clip();
|