Giter Club home page Giter Club logo

adafruitgfx-chinesefont-addon's Introduction

AdafruitGFX-ChineseFont-Addon

A modified version of Adafruit GFX for 正體中文字型檔案

How it works

由於中文字體對於嵌入式硬體(MCU)來說,算是有點大。對於點陣字型來說通常都要個~1Mb,除非用外掛Flash的方式儲存。所以要使用這個軟體必須先定義需要的字,再算出來hash function(UTF-8 to array index),同時從字型檔案當中取出點陣圖。
另外因為目前Arduino常見的一個Graphic library是Adafruit GFX,所以再將Hash function與點陣圖檔都輸出成Adafruit GFX font的格式方便使用,不過還是需要修改Adafruit GFX才能支援直接對UTF-8的輸出
字型檔案格式是倚天中文系統的字型檔,但是是由國喬中文系統點陣字型檔轉檔過來的,連結如下: http://ftp.isu.edu.tw/pub/Windows/Chinese/font/bmp_font/kc_to_eten/

目前預設的點陣大小是24x24,不過也可以選擇16x15的字形。
而(Minimal) Perfect Hash Functions Generator的範例是來自於 http://iswsa.acm.org/mphf/mphf.py

Usage

以weather.txt作為範例,這是從CWB Opendata下載下來的說明檔案的中文字
首先是將weather.txt當中取出獨立的中文字

python .\discrete_utf8.py .\weather.txt

再來就是計算MPH與輸出字型檔案

python .\hash.py
預設是全形24x24,半形12x24,如果需要16x15與8x15的話,後面加 -s就可以了
python .\hash.py -s
如果想看點陣字型的話,後面加上 -p
python .\hash.py -p

輸出的檔案是 userfont.h,搬移到Adafruit GFX library底下的\Fonts
然後再Arduino code裡面使用方式如下:

  #include <Fonts/userfont.h>
  display.begin();
  display.clearDisplay();
  display.setFont(&user_fontGFXfon);
  display.set_lookup(lookup);
  display.setTextColor(BLACK);

   for(int i=0x20; i<0x7F; i++){
       display.write(i);
   }
   display.println();
   display.println("多雲時陰陣雨或雷雨有霧陰時多雲短暫陣雨或雷雨");
   display.print("臺北ABCabc\nABCDEFG");
   display.println("臺中\n臺南");
   display.refresh();

然後大概長這樣:   alt tag

Change list

2017-02-05 增加了16x15 與 8x15的字形,修復println與print的bug

adafruitgfx-chinesefont-addon's People

Contributors

will127534 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

adafruitgfx-chinesefont-addon's Issues

打印错位

打印晴这个字的时候,屏幕上显示英园这两个字

MPH撞到

我發現有些時候,計算出來的MPH會造成兩個字撞到同一個Hash值
不太確定問題是在哪裡,先記錄一下有這狀況

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.