Skip to content

Commit

Permalink
Seperate common fonts from butano.
Browse files Browse the repository at this point in the history
- to avoid increasing butano's repo size
- independent maintain and update from butano main engine
- to support more game engines or GBA projects besides butano

GValiente/butano#18.
  • Loading branch information
laqieer committed Feb 11, 2022
1 parent ff4ebb9 commit 12e3416
Show file tree
Hide file tree
Showing 43 changed files with 31,077 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
build/
*.gba
*.elf
*.sav
5,053 changes: 5,053 additions & 0 deletions common/fonts/Japanese/common_jp_variable_16x16.fnt

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3,151 changes: 3,151 additions & 0 deletions common/fonts/Korean/common_kr_variable_16x16.fnt

Large diffs are not rendered by default.

Binary file added common/fonts/Korean/common_kr_variable_16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions common/fonts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
The common fonts are based on [Source Han Serif](https://github.com/adobe-fonts/source-han-serif) under [OFL-1.1 License](../../licenses/source-han-serif.txt).

![Source Han Sans Version 2 Specimen](https://upload.wikimedia.org/wikipedia/commons/0/0f/Source_Han_Sans_Version_2_Specimen.svg)

Include a font in your project's Makefile to use it.

2 choices to do that:

- include BMFonts

You need to install [Pillow](https://pillow.readthedocs.io/en/stable/installation.html) for BMFont support.

[Example](../../examples/text/Makefile)

- include graphics and headers

They are already converted for direct use in your project, so you needn't install anything.

[Example](https://github.com/laqieer/gba-dev-best-practice/blob/main/source/common-text/Makefile)

4,541 changes: 4,541 additions & 0 deletions common/fonts/SimplifiedChinese/common_sc_variable_16x16.fnt

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11,933 changes: 11,933 additions & 0 deletions common/fonts/TraditionalChinese/common_tc_variable_16x16.fnt

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5,597 changes: 5,597 additions & 0 deletions common/fonts/TraditionalChineseHK/common_hc_variable_16x16.fnt

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
4 changes: 4 additions & 0 deletions common/graphics/Japanese/common_jp_variable_16x16.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "sprite",
"height": 16
}
Binary file not shown.
4 changes: 4 additions & 0 deletions common/graphics/Korean/common_kr_variable_16x16.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "sprite",
"height": 16
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "sprite",
"height": 16
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "sprite",
"height": 16
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "sprite",
"height": 16
}
38 changes: 38 additions & 0 deletions common/include/common_hc_variable_16x16_sprite_font.h

Large diffs are not rendered by default.

38 changes: 38 additions & 0 deletions common/include/common_jp_variable_16x16_sprite_font.h

Large diffs are not rendered by default.

38 changes: 38 additions & 0 deletions common/include/common_kr_variable_16x16_sprite_font.h

Large diffs are not rendered by default.

38 changes: 38 additions & 0 deletions common/include/common_sc_variable_16x16_sprite_font.h

Large diffs are not rendered by default.

38 changes: 38 additions & 0 deletions common/include/common_tc_variable_16x16_sprite_font.h

Large diffs are not rendered by default.

61 changes: 61 additions & 0 deletions examples/text/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#---------------------------------------------------------------------------------------------------------------------
# TARGET is the name of the output.
# BUILD is the directory where object files & intermediate files will be placed.
# LIBBUTANO is the main directory of butano library (https://github.com/GValiente/butano).
# PYTHON is the path to the python interpreter.
# SOURCES is a list of directories containing source code.
# INCLUDES is a list of directories containing extra header files.
# DATA is a list of directories containing binary data.
# GRAPHICS is a list of directories containing files to be processed by grit.
# AUDIO is a list of directories containing files to be processed by mmutil.
# FONTS is a list of directories containing font files.
# ROMTITLE is a uppercase ASCII, max 12 characters text string containing the output ROM title.
# ROMCODE is a uppercase ASCII, max 4 characters text string containing the output ROM code.
# USERFLAGS is a list of additional compiler flags:
# Pass -flto to enable link-time optimization.
# Pass -O0 to improve debugging.
# USERLIBDIRS is a list of additional directories containing libraries.
# Each libraries directory must contains include and lib subdirectories.
# USERLIBS is a list of additional libraries to link with the project.
# USERBUILD is a list of additional directories to remove when cleaning the project.
# EXTTOOL is an optional command executed before processing audio, graphics and code files.
#
# All directories are specified relative to the project directory where the makefile is found.
#---------------------------------------------------------------------------------------------------------------------
TARGET := $(notdir $(CURDIR))
BUILD := build
LIBBUTANO := ../../../butano/butano
COMMON := ../../../butano/common
PYTHON := python
SOURCES := src $(COMMON)/src
INCLUDES := include $(BUILD) $(COMMON)/include
DATA :=
GRAPHICS := graphics $(COMMON)/graphics
AUDIO := audio
FONTS := fonts ../../common/fonts/SimplifiedChinese ../../common/fonts/Japanese ../../common/fonts/Korean ../../common/fonts/TraditionalChinese ../../common/fonts/TraditionalChineseHK
ROMTITLE := BUTANO TEXT
ROMCODE := SBTP
USERFLAGS :=
USERLIBDIRS :=
USERLIBS :=
USERBUILD :=
EXTTOOL :=

#---------------------------------------------------------------------------------------------------------------------
# Install Pillow to handle fonts:
#---------------------------------------------------------------------------------------------------------------------
ifneq ($(strip $(FONTS)),)
EXTTOOL +=
endif

#---------------------------------------------------------------------------------------------------------------------
# Export absolute butano path:
#---------------------------------------------------------------------------------------------------------------------
ifndef LIBBUTANOABS
export LIBBUTANOABS := $(realpath $(LIBBUTANO))
endif

#---------------------------------------------------------------------------------------------------------------------
# Include main makefile:
#---------------------------------------------------------------------------------------------------------------------
include $(LIBBUTANOABS)/butano.mak
Empty file added examples/text/audio/.gitignore
Empty file.
40 changes: 40 additions & 0 deletions examples/text/fonts/user_variable_32x32.fnt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
info face="SourceHanSansSCVF-ExtraLight" size=30 bold=0 italic=0 charset="" unicode=1 stretchH=100 smooth=1 aa=1 padding=1,1,1,1 spacing=1,1
common lineHeight=30 base=30 scaleW=152 scaleH=149 pages=1 packed=0
page id=0 file="user_variable_32x32.png"
chars count=22
char id=32 x=0 y=0 width=0 height=0 xoffset=0 yoffset=0 xadvance=7 page=0 chnl=15
char id=12290 x=0 y=135 width=14 height=14 xoffset=-0.08800000000000008 yoffset=20.96 xadvance=30 page=0 chnl=15
char id=12377 x=69 y=32 width=31 height=30 xoffset=1.024 yoffset=4.932 xadvance=30 page=0 chnl=15
char id=12391 x=69 y=63 width=31 height=28 xoffset=0.9279999999999999 yoffset=7.018000000000001 xadvance=30 page=0 chnl=15
char id=12398 x=101 y=0 width=30 height=27 xoffset=1.072 yoffset=7.042 xadvance=30 page=0 chnl=15
char id=12457 x=101 y=117 width=26 height=25 xoffset=4 yoffset=9.994000000000002 xadvance=30 page=0 chnl=15
char id=12470 x=35 y=102 width=32 height=31 xoffset=-0.05800000000000005 yoffset=4.938000000000001 xadvance=30 page=0 chnl=15
char id=12488 x=132 y=0 width=20 height=30 xoffset=8.93 yoffset=5.058 xadvance=30 page=0 chnl=15
char id=12501 x=101 y=90 width=26 height=26 xoffset=2.96 yoffset=7.914 xadvance=30 page=0 chnl=15
char id=12518 x=69 y=92 width=31 height=23 xoffset=0.9220000000000002 yoffset=8.912 xadvance=30 page=0 chnl=15
char id=12531 x=101 y=28 width=28 height=27 xoffset=3.002 yoffset=6.970000000000001 xadvance=30 page=0 chnl=15
char id=12540 x=35 y=134 width=30 height=7 xoffset=1.072 yoffset=15.982 xadvance=30 page=0 chnl=15
char id=20041 x=35 y=0 width=33 height=33 xoffset=-0.9359999999999999 yoffset=2.984 xadvance=30 page=0 chnl=15
char id=20307 x=0 y=34 width=34 height=33 xoffset=-0.9180000000000001 yoffset=3.026 xadvance=30 page=0 chnl=15
char id=23383 x=35 y=68 width=32 height=33 xoffset=0.04999999999999982 yoffset=2.9779999999999998 xadvance=30 page=0 chnl=15
char id=23450 x=0 y=0 width=34 height=33 xoffset=-0.9180000000000001 yoffset=3.002 xadvance=30 page=0 chnl=15
char id=25143 x=69 y=116 width=30 height=33 xoffset=-0.948 yoffset=2.9899999999999993 xadvance=30 page=0 chnl=15
char id=26159 x=0 y=68 width=34 height=32 xoffset=-0.9119999999999999 yoffset=4.908 xadvance=30 page=0 chnl=15
char id=29992 x=69 y=0 width=31 height=31 xoffset=-0.954 yoffset=5.058 xadvance=30 page=0 chnl=15
char id=33258 x=101 y=56 width=26 height=33 xoffset=3.0919999999999996 yoffset=3.002 xadvance=30 page=0 chnl=15
char id=35373 x=35 y=34 width=33 height=33 xoffset=-0.06400000000000006 yoffset=2.9959999999999996 xadvance=30 page=0 chnl=15
char id=36825 x=0 y=101 width=33 height=33 xoffset=-0.10000000000000009 yoffset=2.9959999999999996 xadvance=30 page=0 chnl=15
kernings count=13
kerning first=12540 second=12470 amount=-1
kerning first=12540 second=12501 amount=-2
kerning first=12540 second=12531 amount=-1
kerning first=12540 second=12391 amount=-2
kerning first=12470 second=12290 amount=-2
kerning first=12501 second=12290 amount=-1
kerning first=12501 second=12531 amount=1
kerning first=12457 second=12290 amount=-1
kerning first=12531 second=12290 amount=-2
kerning first=12531 second=12501 amount=-1
kerning first=12488 second=12290 amount=-1
kerning first=12391 second=12290 amount=-1
kerning first=12377 second=12290 amount=-3
Binary file added examples/text/fonts/user_variable_32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/text/graphics/fixed_32x64_font.bmp
Binary file not shown.
4 changes: 4 additions & 0 deletions examples/text/graphics/fixed_32x64_font.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "sprite",
"height": 64
}
Binary file added examples/text/graphics/variable_8x16_font_blue.bmp
Binary file not shown.
4 changes: 4 additions & 0 deletions examples/text/graphics/variable_8x16_font_blue.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "sprite",
"height": 16
}
Binary file added examples/text/graphics/variable_8x16_font_red.bmp
Binary file not shown.
4 changes: 4 additions & 0 deletions examples/text/graphics/variable_8x16_font_red.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "sprite",
"height": 16
}
Binary file added examples/text/graphics/variable_8x16_font_yellow.bmp
Binary file not shown.
4 changes: 4 additions & 0 deletions examples/text/graphics/variable_8x16_font_yellow.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "sprite",
"height": 16
}
Empty file.
26 changes: 26 additions & 0 deletions examples/text/include/fixed_32x64_sprite_font.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright (c) 2020-2022 Gustavo Valiente gustavo.valiente@protonmail.com
* zlib License, see LICENSE file.
*/

#ifndef FIXED_32x64_SPRITE_FONT_H
#define FIXED_32x64_SPRITE_FONT_H

#include "bn_sprite_font.h"
#include "bn_utf8_characters_map.h"
#include "bn_sprite_items_fixed_32x64_font.h"

constexpr bn::utf8_character fixed_32x64_sprite_font_utf8_characters[] = {
"Á", "É", "Í", "Ó", "Ú", "Ü", "Ñ", "á", "é", "í", "ó", "ú", "ü", "ñ", "¡", "¿"
};

constexpr bn::span<const bn::utf8_character> fixed_32x64_sprite_font_utf8_characters_span(
fixed_32x64_sprite_font_utf8_characters);

constexpr auto fixed_32x64_sprite_font_utf8_characters_map =
bn::utf8_characters_map<fixed_32x64_sprite_font_utf8_characters_span>();

constexpr bn::sprite_font fixed_32x64_sprite_font(
bn::sprite_items::fixed_32x64_font, fixed_32x64_sprite_font_utf8_characters_map.reference());

#endif
Loading

0 comments on commit 12e3416

Please sign in to comment.