Kaynağa Gözat

修改文字

wangyong 6 yıl önce
ebeveyn
işleme
04c0c15710

+ 12 - 2
customized/pages/made/comb/comb.js

@@ -229,14 +229,24 @@ Page({
       // ctx.textBaseline = 'top';
       ctx.setFontSize(fontTouch.fontSize);
       ctx.setFillStyle(fontTouch.isColor);
-      ctx.font = `'bold' ${fontTouch.fontSize} ${fontTouch.isColor} 'sans-serif'`;
+      if(fontTouch.bold){
+        ctx.fillText(fontTouch.fontContent, -1, simulationFont.height / 5 * 4)
+        ctx.fillText(fontTouch.fontContent, 0, simulationFont.height / 5 * 4 -1)
+      }
+      ctx.fillText(fontTouch.fontContent, 0, simulationFont.height / 5 * 4)
+      if (fontTouch.bold) {
+        ctx.fillText(fontTouch.fontContent, 1, simulationFont.height / 5 * 4)
+        ctx.fillText(fontTouch.fontContent, 0, simulationFont.height / 5 * 4 + 1)
+      }
+      ctx.restore()
+      // ctx.font = `'bold' ${fontTouch.fontSize} ${fontTouch.isColor} 'sans-serif'`;
       // 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.fillText(fontTouch.fontContent, -metrics.width / 2, -simulationFont.height / 2 + simulationFont.height / 5 * 4);
-      ctx.fillText(fontTouch.fontContent, 0, simulationFont.height / 5 * 4)
+      // ctx.fillText(fontTouch.fontContent, 0, simulationFont.height / 5 * 4)
       ctx.draw(false,function () {
         wx.canvasToTempFilePath({
           canvasId: 'comb-font'+i,

+ 7 - 3
customized/pages/made/madeFont/madeFont.js

@@ -47,7 +47,7 @@ Page({
       clientY: 0, // 默认初始值
       width: 0,
       height: 0,
-      bold:100,
+      bold:true,
     },
     imgFont:{}, // 图片对象
     animationData: {}, //旋转动画
@@ -301,12 +301,16 @@ Page({
         imgAnimationData: that.imgAnimation.export(),
         imgTouch: madeTouchImg ? madeTouchImg : {}, //存储图片数据
       })
-
-
     } 
 
     
   },
+  weightBtn(){
+    let that = this;
+    that.setData({
+      'fontTouch.bold':!that.data.fontTouch.bold
+    })
+  }
   
 
 })

+ 1 - 4
customized/pages/made/madeFont/madeFont.wxml

@@ -82,12 +82,9 @@
   </view>
 
   <view class='font-color f-box f-justify-content-around'>
+    <view class='select-weight' bindtap='weightBtn' style='color:{{fontTouch.bold ? "#333":""}};background:{{fontTouch.bold ? "#fff":""}}'>粗</view>
     <view wx:for="{{fontColorArray}}" class='{{fontTouch.isColor === item ? "isColor" : ""}}' data-color="{{item}}" bindtap='selectColor'>
       <view style='background:{{item}}' class='font-item'></view>
     </view>
   </view>
-  <!-- 加粗 -->
-  <view>
-    <!-- <view class='c-white f-weight' style='color:{{fontTouch.bold? "#22ad38":""}}' bindtap='weightBtn'>B</view> -->
-  </view>
 </view>

+ 11 - 4
customized/pages/made/madeFont/madeFont.wxss

@@ -123,8 +123,15 @@ page{
   width:5555555555555rpx;
   z-index:40;
 }
-.f-weight{
-  font-size:40rpx;
-  width:600rpx;
-  margin:30rpx auto;
+
+.select-weight{
+  font-size:32rpx;
+  font-weight: bold;
+  /* background:#fff; */
+  color:#fff;
+  width:50rpx;
+  height:50rpx;
+  text-align: center;
+  line-height:50rpx;
+  border-radius:5rpx;
 }