Skip to content

How to include Custom Fonts? #472

@Hankyin

Description

@Hankyin

I just want to use a new ttf Font, because the default font do not support CJK.
but I do not find any API to load a new font, so How to include Custom Fonts?

in NanoGUI document, I find something.

# Including Custom Fonts

NanoGUI uses the [Roboto](https://fonts.google.com/specimen/Roboto) font for text, and [Entypo](http://www.entypo.com/) font for icons. If you wish to add your own custom font, all you need is a True Type file (a .ttf extension). NanoGUI will glob all fonts found in resources by expanding resources/*.ttf. So if you had the directory structure

myproject/
    CMakeLists.txt      <- where this code is
    fonts/
        superfont.ttf
    ext/
        nanogui/
            resources/

You simply need to copy the superfont.ttf to NanoGUI’s resources directory:

file(
  COPY ${CMAKE_CURRENT_SOURCE_DIR}/fonts/superfont.ttf
  DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/ext/nanogui/resources/superfont.ttf
)

When you build the code, there should be a file nanogui_resources.h generated. If everything worked, your new font should have been included.

Does this mean I have to recomplie NanoGUI?
but I don't want to recomplie this library, who can help me please。 /(ㄒoㄒ)/~~

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions