|
@@ -202,25 +202,23 @@ Page({
|
|
|
|
|
|
},
|
|
|
getCombFont(that,i,_static) {
|
|
|
- let fontTouch = null,dataPositionObj = null;
|
|
|
+ let fontTouch = null, dataPositionObj = null, simulationFont=null;
|
|
|
if (wx.getStorageSync('madeCupFontData' + i)) {
|
|
|
fontTouch = wx.getStorageSync('madeCupFontData' + i);
|
|
|
+ simulationFont = wx.getStorageSync('simulationFont' + i);
|
|
|
dataPositionObj = util.changeCup(i.toString()).dataPositionObj;
|
|
|
const ctx = wx.createCanvasContext('comb-font'+i);
|
|
|
+ ctx.textBaseline = 'top';
|
|
|
ctx.setFontSize(fontTouch.fontSize);
|
|
|
ctx.setFillStyle(fontTouch.isColor);
|
|
|
- // ctx.translate(0, fontTouch.height / 5 * 4);
|
|
|
- // ctx.save();
|
|
|
- let movex = fontTouch.x + fontTouch.width / 2;
|
|
|
- let movey = fontTouch.y +fontTouch.height / 2;
|
|
|
+ const metrics = ctx.measureText(fontTouch.fontContent)
|
|
|
+ let movex = fontTouch.x + metrics.width / 2;
|
|
|
+ let movey = fontTouch.y + simulationFont.height / 2;
|
|
|
ctx.translate(movex, movey);
|
|
|
ctx.rotate(fontTouch.angle * Math.PI / 180);
|
|
|
- ctx.translate(-movex, -movey);
|
|
|
- // ctx.rotate(fontTouch.angle * Math.PI / 180);
|
|
|
- // ctx.fillText(fontTouch.fontContent, 0, 0);
|
|
|
- // ctx.translate(fontTouch.x, fontTouch.y + fontTouch.height / 5 * 4);
|
|
|
- ctx.fillText(fontTouch.fontContent, fontTouch.x, fontTouch.y +fontTouch.height / 5 * 4);
|
|
|
-
|
|
|
+ ctx.fillText(fontTouch.fontContent, -metrics.width / 2, -simulationFont.height / 2);
|
|
|
+
|
|
|
+ console.log(metrics,"文本的宽度")
|
|
|
ctx.draw(false,function () {
|
|
|
wx.canvasToTempFilePath({
|
|
|
canvasId: 'comb-font'+i,
|