曉郁
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # libGdx 中文字 由於 lbgdx 沒有原生支援中文,所以在做hana 引擎的時候花了滿多時間在處理顯示中文字這塊。 但是網路上大家做法又都不一樣,剛好我發現我字型的部分忘記處理全形標點符號,所以順便做個教學,這應該會是最簡單的做法了。 那我們開始吧~~~~~ ## Hiero 由於 libgdx 無法直接使用 windows 的字形,所以我們需要一個工具幫忙打包。 先到這個連結去下載工具: https://github.com/libgdx/libgdx/wiki/Hiero 如果找不到的話仔細看一下Running Hiero章節,應該找的到的。 下載完成之後用命令提示字元下 ```java -jar [剛剛下載的檔名]``` 應該會看到下面的東西: ![](https://i.imgur.com/rT79jyz.png) 先簡單介紹一下畫面內的東西,我們主要會用到的是 Font 跟 Simple Text 還有 Rendering 區塊。 * Font:用來選擇字型或匯入字型的區塊 * Sample Text 用來放入你會需要用到的文字,要注意的是如果沒有把要用到的字放進去的話在 Libgdx 裡面會顯示不出來 * Rendering 是一個預覽的地方。 了解這些東西之後呢,我們先繼續準備其他食材。 ## 下載免費且可商用的字形 相信在開啟 Hiero 就會看到微軟正黑體等字體吧。要注意這些字體有的需要商業授權才可以使用,簡單來說如果今天用那些字體發遊戲出去的話有可能會被要求授權金之類的。 所以最簡單的方式就是找一些免費可商用的字形。 這邊示範的部分會用 google 的 Noto Sans 字體。 當然也可以用其他字體。 接下來先把字體下載下來後放在剛剛下載的 Hiero 旁邊吧。 (記得解壓縮喔) ## 取得幾乎全部的中文字(非必要) 剛剛提到: > 沒有把要用到的字放進去的話在 Libgdx 裡面會顯示不出來 此時可能會有人想要一口氣把所有中文字都導入,這樣就可以一勞永逸了。 但又不可能自己把所有中文都打出來該怎麼辦呢? 這個我也找滿久的,後來在"教育部 成果網" 發現有提供4808個常用字。而且還提供 ods 下載,我看到的時候都感動到快哭了,第一次這麼感謝國家的網路資源。 那個網站的網址在這裡: https://language.moe.gov.tw/result.aspx?classify_sn=23&subclassify_sn=437&content_sn=46 點開前往結果後的跳出的 pdf 檔中點ods檔就可以下載了。 打開下載下來後的檔案把所有中文複製下來,自己想辦法把換行的部分都去掉就準備好第二項食材了。 ## 產生字型檔 接下來把文字複製到複製到 Hiero 的 sample Text,複製之後別急著離開,把常用到的標點符號也打上去吧。 再來在 Font 區塊點 File 選擇剛剛下載的字型檔吧。以剛剛的範例來看的話是NotoSansTC-Black.otf檔。 下面是都處理好的圖: ![](https://i.imgur.com/RYD3b2F.png) 再來選擇 File -> Save as BMFont Files 就會生出一堆圖檔跟一個 fnt 檔。 ## 如何在 libgdx 使用 最後要怎麼在 libgdx 使用,這點相當簡單。我們先直接看程式碼 ```java= private SpriteBatch batch; private BitmapFont bitmapFont; @Override public void create() { batch = new SpriteBatch(); bitmapFont = new BitmapFont(new FileHandle(new File( PathUtils.generateFontPath("NotoSansTC-Black.fnt"))), false); //讀取檔案,也可以用Gdx.files.internal去讀檔案 bitmapFont.setColor(Color.WHITE); //設定字體顏色 bitmapFont.getData().setScale(2); //字體大小比例 } @Override public void render() { //do some logic bitmapFont.draw(batch, "Hello world", 100, 250); //寫字上去啦,100是x的位置,250是 y 的位置 } ``` 這樣一來就大功告成啦

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully