(TODO)Fonts
check the available device font names using native.getFontNames().
custom fonts TrueType (.ttf) and OpenType (.otf) fonts are theoretically supported
You can download the Roboto font files directly from Google Fonts. This is the official and most reliable source for the font. It’s a free-to-use font under the Apache License v2.0, so you can use it in your commercial or personal projects without any issue.
How to Get and Use the Font
- Download the Font: Visit the Google Fonts page for Roboto. Click the “Download family” button in the top right corner. This will download a
.zip
file containing all the font weights and styles (Thin, Light, Regular, Medium, Bold, etc.) in.ttf
or.otf
format. - Extract the Files: Unzip the downloaded file. You’ll find a folder containing the individual font files (e.g.,
Roboto-Regular.ttf
,Roboto-Bold.ttf
, etc.). - Add to Your Solar2D Project: Copy the specific
.ttf
or.otf
font files you need into your Solar2D project directory. It’s a good practice to place them in a dedicatedfonts
subfolder. - Reference in Code: In your
main.lua
or other code files, you can now reference the font by its filename. For example:local myText = display.newText( "Hello World!", 100, 100, "Roboto-Regular.ttf", 24 )
- Test: Run your project in the Solar2D simulator. Since you are using a custom font file that is part of your project, it will render correctly on the simulator and on all devices, ensuring a consistent look and feel across platforms.
Apple’s license agreement for the San Francisco font is very strict. It states that the font is to be used solely for creating user interfaces for software products that run on Apple’s operating systems (iOS, macOS, etc.).
Japanese fonts
As Japanese fonts are much larger and more complex than Latin-based fonts, due to the number of characters (kanji, hiragana, katakana).
1. Font Squirrel
Font Squirrel has a section dedicated to fonts tagged as “Japanese.” You can find some free Japanese fonts there, such as Soukou Mincho. However, the collection is limited, and you should always double-check the license for each specific font, as not all fonts on the site are under the same open-source license.
2. Bunny Fonts
Bunny Fonts is an excellent option for finding open-source Japanese fonts. As a proxy for Google Fonts, it includes popular Japanese font families like Noto Sans JP and Noto Serif JP, which are designed to cover a wide range of CJK (Chinese, Japanese, Korean) characters and are licensed under the SIL Open Font License, making them perfect for your use case.
3. Google Fonts (Still the Best Option)
Even though you asked for alternatives, it’s worth noting that Google Fonts has the most extensive and well-maintained collection of open-source Japanese fonts. They are meticulously designed and have broad character set support. The most well-known are:
- Noto Sans JP: A clean, modern sans-serif font family.
- Noto Serif JP: A traditional serif font family that pairs well with Noto Sans JP.
- Other options like M Plus 1p, Kosugi Maru, and Sawarabi Mincho are also available.
Other Great Resources for Japanese Fonts:
- Free Japanese Fonts: This site specializes in free-to-use Japanese fonts, many of which are under commercial-friendly licenses. You can find a variety of styles, from traditional Mincho and Gothic to more unique, handwritten-style fonts.
- Fontesk: This site curates a collection of fonts from various sources, including some open-source Japanese ones. It’s a good place to discover new fonts and check their licenses before use.
When you download a Japanese font, be aware that the file size will be significantly larger than a Latin-based font like Roboto due to the large number of characters. This is normal and something to consider for your app’s final size.