如何在微信小程式中使用字型圖示

單眼皮的小熊發表於2020-10-14

 方法一:將字型url轉換為base64的格式後使用

  第一步,下載需要的字型圖:

  開啟阿里巴巴向量圖示庫,選擇自己需要的圖示新增到購物車,然後點選購物車下載程式碼:

  第二步,轉換iconfont.ttf檔案為base64格式:

  然後將下載的包解壓,你會看到一個格式為ttf的檔案,注意,我們轉換的就是這個檔案,此處我們將解壓的資料夾叫“原始資料夾”,開啟Transfonter網站,按如下步驟操作:點選add fonts按鈕新增我們之前提到的ttf檔案 ——> 開啟以及勾選下圖中框紅框的選項 ——> 點選Convert轉換按鈕(稍等片刻)——> 下載轉換好的檔案(會有個Download選擇,點就行了),到這裡,我們就可以拿到轉換完的檔案了。

  第三步,在微信小程式中使用字型圖示:

  開啟微信小程式,預設我們讓index頁面顯示剛剛下載的圖示,所以要先開啟index.wxss檔案,然後將剛才轉換後下載的資料夾解壓,找到stylesheet.css檔案,開啟檔案,複製所有樣式到index.wxss檔案中:

/**index.wxss**/
@font-face {
    font-family: 'iconfont';
    src: url(data:font/truetype;charset=utf-8;base64,AAEAAAANAIAAAwBQRkZUTYcD80UAAB8AAAAAHEdERUYAKQAMAAAe4AAAAB5PUy8yPG9H+QAAAVgAAABWY21hcOYh6bsAAAHEAAABSmdhc3D//wADAAAe2AAAAAhnbHlmoQ/4zQAAAyAAABjkaGVhZBU0EFwAAADcAAAANmhoZWEIfwNaAAABFAAAACRobXR4DKwAbQAAAbAAAAAUbG9jYQ3UCCIAAAMQAAAADm1heHABvAR7AAABOAAAACBuYW1lKeYRVQAAHAQAAAKIcG9zdP06GuMAAB6MAAAASQABAAAAAQAAWPAGv18PPPUACwQAAAAAANiv5h4AAAAA2K/mHgAV/70EoANmAAAACAACAAAAAAAAAAEAAAOA/4AAXAQAAAD/1QSgAAEAAAAAAAAAAAAAAAAAAAAEAAEAAAAGBG8ArAAAAAAAAgAAAAoACgAAAP8AAAAAAAAAAQQAAZAABQAAAokCzAAAAI8CiQLMAAAB6wAyAQgAAA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AaQBjAG8AbgBmAG8AbgB0AABpY29uZm9udAAAVgBlAHIAcwBpAG8AbgAgADEALgAwAABWZXJzaW9uIDEuMAAAaQBjAG8AbgBmAG8AbgB0AABpY29uZm9udAAARwBlAG4AZQByAGEAdABlAGQAIABiAHkAIABzAHYAZwAyAHQAdABmACAAZgByAG8AbQAgAEYAbwBuAHQAZQBsAGwAbwAgAHAAcgBvAGoAZQBjAHQALgAAR2VuZXJhdGVkIGJ5IHN2ZzJ0dGYgZnJvbSBGb250ZWxsbyBwcm9qZWN0LgAAaAB0AHQAcAA6AC8ALwBmAG8AbgB0AGUAbABsAG8ALgBjAG8AbQAAaHR0cDovL2ZvbnRlbGxvLmNvbQAAAgAAAAAAAAAKAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAGAAAAAQACAQIBAwEECnNoZW5nbnZndW8IYmFvbWlodWEGZGFuZ2FvAAAAAAAAAf//AAIAAQAAAAwAAAAWAAAAAgABAAMABQABAAQAAAACAAAAAAAAAAEAAAAA1aQnCAAAAADYr+YeAAAAANiv5h4=) format('truetype');
    font-weight: normal;
    font-style: normal;
}

  之後,開啟我們轉換之前的那個原始資料夾,找到其中的iconfont.css檔案,複製檔案中除了@font-face這部分內容以外的其他樣式到index.wxss檔案中:

/**index.wxss**/
@font-face {
    font-family: 'iconfont';
    src: url(data:font/truetype;charset=utf-8;base64,AAEAAAANAIAAAwBQRkZUTYcD80UAAB8AAAAAHEdERUYAKQAMAAAe4AAAAB5PUy8yPG9H+QAAAVgAAABWY21hcOYh6bsAAAHEAAABSmdhc3D//wADAAAe2AAAAAhnbHlmoQ/4zQAAAyAAABjkaGVhZBU0EFwAAADcAAAANmhoZWEIfwNaAAABFAAAACRobXR4DKwAbQAAAbAAAAAUbG9jYQ3UCCIAAAMQAAAADm1heHABvAR7AAABOAAAACBuYW1lKeYRVQAAHAQAAAKIcG9zdP06GuMAAB6MAAAASQABAAAAAQAAWPAGv18PPPUACwQAAAAAANiv5h4AAAAA2K/mHgAV/70Eo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QBjAG8AbgBmAG8AbgB0AAoAAApDcmVhdGVkIGJ5IGljb25mb250CgAAaQBjAG8AbgBmAG8AbgB0AABpY29uZm9udAAAUgBlAGcAdQBsAGEAcgAAUmVndWxhcgAAaQBjAG8AbgBmAG8AbgB0AABpY29uZm9udAAAaQBjAG8AbgBmAG8AbgB0AABpY29uZm9udAAAVgBlAHIAcwBpAG8AbgAgADEALgAwAABWZXJzaW9uIDEuMAAAaQBjAG8AbgBmAG8AbgB0AABpY29uZm9udAAARwBlAG4AZQByAGEAdABlAGQAIABiAHkAIABzAHYAZwAyAHQAdABmACAAZgByAG8AbQAgAEYAbwBuAHQAZQBsAGwAbwAgAHAAcgBvAGoAZQBjAHQALgAAR2VuZXJhdGVkIGJ5IHN2ZzJ0dGYgZnJvbSBGb250ZWxsbyBwcm9qZWN0LgAAaAB0AHQAcAA6AC8ALwBmAG8AbgB0AGUAbABsAG8ALgBjAG8AbQAAaHR0cDovL2ZvbnRlbGxvLmNvbQAAAgAAAAAAAAAKAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAGAAAAAQACAQIBAwEECnNoZW5nbnZndW8IYmFvbWlodWEGZGFuZ2FvAAAAAAAAAf//AAIAAQAAAAwAAAAWAAAAAgABAAMABQABAAQAAAACAAAAAAAAAAEAAAAA1aQnCAAAAADYr+YeAAAAANiv5h4=) format('truetype');
    font-weight: normal;
    font-style: normal;
}

.iconfont {
  font-family: "iconfont" !important;
  font-size: 16px;
  font-style: normal;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.icon-shengnvguo:before {
  content: "\e601";
}

.icon-baomihua:before {
  content: "\e606";
}

.icon-dangao:before {
  content: "\e607";
}

  上面就是index.wxss檔案新增完字型後的程式碼。最後,我們只需要開啟index.wxml檔案,將字型樣式應用上就可以看到效果啦~

<!--index.wxml-->
<text class="iconfont icon-shengnvguo">聖女果</text>
<text class="iconfont icon-baomihua">爆米花</text>
<text class="iconfont icon-dangao">蛋糕</text>

  因為我沒有給它們新增別的樣式。所以圖示是醜了點,其實字型圖示跟字型一樣,小夥伴兒們可以根據具體的需求做美化哦~

   方法二:線上生成字型url的地址後再使用

  第一步,獲取字型圖示的url線上地址:

  開啟阿里巴巴向量相簿,選擇需要使用到的圖示(這次我們換個跟上面不一樣的~ ^-^),新增到購物車,然後我們選擇“新增至專案”按鈕:

  這裡我之前沒有專案,所以要先新建一個專案:

  新建完專案點選確定按鈕後,會進入到下圖中的頁面,我們要點“擊暫無程式碼,點此生成”:

  下面是生成後的截圖:

  第二步,在微信小程式中使用字型圖示:

  這裡,小夥伴需要先複製程式碼,然後點選“下載至本地”按鈕,將下載的資料夾解壓,找到其中的iconfont.css檔案,將上面複製的程式碼替換iconfont.css檔案中@font-face的內容,其他不動,然後整體複製到需要使用的微信小程式檔案中,這裡我為了區別上面的方法一,新建了一個頁面page2,看下我調整好的page2.wxss檔案:

/* pages/page2/page2.wxss */
@font-face {
  font-family: 'iconfont';  /* project id 1087511 */
  src: url('//at.alicdn.com/t/font_1087511_r1ypk0yf47.eot');
  src: url('//at.alicdn.com/t/font_1087511_r1ypk0yf47.eot?#iefix') format('embedded-opentype'),
  url('//at.alicdn.com/t/font_1087511_r1ypk0yf47.woff2') format('woff2'),
  url('//at.alicdn.com/t/font_1087511_r1ypk0yf47.woff') format('woff'),
  url('//at.alicdn.com/t/font_1087511_r1ypk0yf47.ttf') format('truetype'),
  url('//at.alicdn.com/t/font_1087511_r1ypk0yf47.svg#iconfont') format('svg');
}

.iconfont {
  font-family: "iconfont" !important;
  font-size: 16px;
  font-style: normal;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.icon-shouye:before {
  content: "\e73d";
}

.icon-yaopin:before {
  content: "\e73f";
}

.icon-xiaoxi:before {
  content: "\e740";
}

  之後開啟page2.wxml檔案,將圖示引入使用即可:

<text class="iconfont icon-shouye">首頁</text>
<text class="iconfont icon-yaopin">藥品</text>
<text class="iconfont icon-xiaoxi">訊息</text>

  兩個方法,達到的效果是一樣的,圖示字型的樣式,跟字型一樣設定就行的,如果需要使用圖示的檔案比較多,可以將圖示相關的公用樣式放到app.wxss中,這樣可以當做公用樣式來呼叫。

相關文章