Browse Source

更新包

haojianlong 5 years ago
parent
commit
9f4157048b

+ 2 - 2
saga-web-big/package.json

@@ -1,6 +1,6 @@
 {
     "name": "@saga-web/big",
-    "version": "1.0.48",
+    "version": "1.0.49",
     "description": "上格云建筑信息化库",
     "main": "lib/index.js",
     "types": "lib/index.d.js",
@@ -42,6 +42,6 @@
         "typescript": "^3.9.3"
     },
     "dependencies": {
-        "@saga-web/graph": "2.1.91"
+        "@saga-web/graph": "2.1.92"
     }
 }

+ 1 - 1
saga-web-draw/package.json

@@ -1,6 +1,6 @@
 {
     "name": "@saga-web/draw",
-    "version": "2.1.98",
+    "version": "2.1.99",
     "description": "上格云绘制引擎。",
     "main": "lib/index.js",
     "types": "lib/index.d.js",

+ 1 - 0
saga-web-draw/src/SPainter.ts

@@ -50,6 +50,7 @@ export class SPainter extends SObject {
     } // Get font
     set font(value: SFont) {
         this.engine.state.font = value;
+        this.engine.changeFont(value);
     } // Set font
 
     /** 融合属性    */

+ 13 - 0
saga-web-draw/src/engines/SCanvasPaintEngine.ts

@@ -1,6 +1,7 @@
 import { SPaintEngine } from "./SPaintEngine";
 import {
     SBrushType,
+    SFont,
     SGradientStop,
     SLine,
     SLinearGradient,
@@ -397,6 +398,18 @@ export class SCanvasPaintEngine extends SPaintEngine {
     //     this.canvas.stroke();
     // } // Function drawRoundedRect()
 
+    /**
+     * 设置字体
+     *
+     * @param   font    字体
+     */
+    changeFont(font: SFont): void {
+        this._canvas.font = `${font.size}px ${font.name}`;
+        this.setTextAlign(font.textAlign);
+        this.setBaseLine(font.textBaseLine);
+        this.setTextDirection(font.textDirection);
+    } // Function changeFont()
+
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     // 私有函数
     /**

+ 8 - 1
saga-web-draw/src/engines/SPaintEngine.ts

@@ -1,4 +1,4 @@
-import { SLine, SPaintEngineType, SPath2D, SPoint, SRect } from "..";
+import { SFont, SLine, SPaintEngineType, SPath2D, SPoint, SRect } from "..";
 import { SPaintState } from "./SPaintState";
 
 /**
@@ -280,4 +280,11 @@ export abstract class SPaintEngine {
      * @param   text    预测的文本
      * */
     abstract textWidth(text: string): number;
+
+    /**
+     * 修改字体
+     *
+     * @param   font    字体
+     * */
+    abstract changeFont(font: SFont): void;
 } // class SPaintEngine

+ 8 - 0
saga-web-draw/src/engines/SSvgPaintEngine.ts

@@ -2,6 +2,7 @@ import { SStringBuilder } from "@saga-web/base/lib";
 import { SPath2D } from "../SPath2D";
 import {
     SBrushType,
+    SFont,
     SGradientStop,
     SLine,
     SLinearGradient,
@@ -328,6 +329,13 @@ export class SSvgPaintEngine extends SPaintEngine {
     } // Function textWidth()
 
     /**
+     * 设置字体
+     *
+     * @param   font    字体
+     */
+    changeFont(font: SFont): void {} // Function changeFont()
+
+    /**
      * 获得svg需要的变形信息
      *
      * @return  变换信息

+ 2 - 2
saga-web-graph/package.json

@@ -1,6 +1,6 @@
 {
     "name": "@saga-web/graph",
-    "version": "2.1.91",
+    "version": "2.1.92",
     "description": "上格云二维图形引擎。",
     "main": "lib/index.js",
     "types": "lib/index.d.js",
@@ -41,6 +41,6 @@
         "typescript": "^3.5.3"
     },
     "dependencies": {
-        "@saga-web/draw": "2.1.98"
+        "@saga-web/draw": "2.1.99"
     }
 }