Skip to content

Commit fd8c69d

Browse files
schodetlaurensvalk
authored andcommitted
pbio/image/fonts: Generate font source files at build.
1 parent 6032a55 commit fd8c69d

12 files changed

Lines changed: 71 additions & 762 deletions

File tree

bricks/_common/common.mk

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ PYDFU = $(TOP)/tools/pydfu.py
163163
PYBRICKSDEV = pybricksdev
164164
METADATA = $(PBTOP)/tools/metadata.py
165165
MEDIA_CONVERT = $(PBTOP)/lib/pbio/src/image/media.py
166+
FONT_CONVERT = $(PBTOP)/lib/pbio/src/image/fontconvert.py
166167
CREDITS_CONVERT = $(PBTOP)/bricks/ev3/make_credits.py
167168
OPENOCD ?= openocd
168169
OPENOCD_CONFIG ?= openocd_stm32$(PB_MCU_SERIES_LCASE).cfg
@@ -557,6 +558,12 @@ PBIO_SRC_C += $(BUILD)/pbio_image_media.c
557558
PBIO_SRC_C += $(BUILD)/hmi_ev3_ui_credits.c
558559
endif
559560

561+
ifeq ($(PB_FONTS),1)
562+
PBIO_SRC_C += $(BUILD)/font_liberationsans_regular_14.c
563+
PBIO_SRC_C += $(BUILD)/font_terminus_normal_16.c
564+
PBIO_SRC_C += $(BUILD)/font_mono_8x5_8.c
565+
endif
566+
560567
OBJ = $(PY_O)
561568
OBJ += $(addprefix $(BUILD)/, $(SRC_S:.s=.o))
562569
OBJ += $(addprefix $(BUILD)/, $(PY_EXTRA_SRC_C:.c=.o))
@@ -676,6 +683,23 @@ $(BUILD)/pbio_image_media.c $(BUILD)/pb_type_image_attributes.c: $(MEDIA_CONVERT
676683
$(ECHO) "Generating image media files"
677684
$(Q)$(PYTHON) $(MEDIA_CONVERT) $(BUILD)
678685

686+
include $(PBTOP)/lib/pbio/src/image/fonts/fonts.mk
687+
688+
$(BUILD)/font_liberationsans_regular_14.c: $(PBTOP)/lib/pbio/src/image/fonts/$(FONT_LIBERATION_SANS_REGULAR) $(FONT_CONVERT)
689+
$(ECHO) "GEN $@"
690+
$(Q)$(PYTHON) $(FONT_CONVERT) $< 14 \
691+
--license $(FONT_LIBERATION_LICENSE) $(FONT_LIBERATION_COPYRIGHT) > $@
692+
693+
$(BUILD)/font_terminus_normal_16.c: $(PBTOP)/lib/pbio/src/image/fonts/$(FONT_TERMINUS_NORMAL) $(FONT_CONVERT)
694+
$(ECHO) "GEN $@"
695+
$(Q)$(PYTHON) $(FONT_CONVERT) $< 16 \
696+
--license $(FONT_TERMINUS_LICENSE) $(FONT_TERMINUS_COPYRIGHT) > $@
697+
698+
$(BUILD)/font_mono_8x5_8.c: $(PBTOP)/lib/pbio/src/image/fonts/$(FONT_NXOS) $(FONT_CONVERT)
699+
$(ECHO) "GEN $@"
700+
$(Q)$(PYTHON) $(FONT_CONVERT) --image $< 8 \
701+
--license $(FONT_NXOS_LICENSE) $(FONT_NXOS_COPYRIGHT) > $@
702+
679703
$(BUILD)/hmi_ev3_ui_credits.c: $(CREDITS_CONVERT)
680704
$(ECHO) "Generating EV3 credits file"
681705
$(Q)$(PYTHON) $(CREDITS_CONVERT) $(BUILD)
@@ -755,4 +779,6 @@ deploy-openocd: $(BUILD)/firmware-base.bin
755779
$(ECHO) "Writing $< to the board via ST-LINK using OpenOCD"
756780
$(Q)$(OPENOCD) -f $(OPENOCD_CONFIG) -c "stm_flash $< $(TEXT0_ADDR)"
757781

782+
.DELETE_ON_ERROR:
783+
758784
include $(TOP)/py/mkrules.mk

bricks/_common/sources.mk

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,6 @@ PBIO_SRC_C = $(addprefix lib/pbio/,\
214214
src/drivebase.c \
215215
src/error.c \
216216
src/geometry.c \
217-
src/image/font_liberationsans_regular_14.c \
218-
src/image/font_terminus_normal_16.c \
219-
src/image/font_mono_8x5_8.c \
220217
src/image/image.c \
221218
src/imu.c \
222219
src/int_math.c \

bricks/ev3/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ PB_FROZEN_MODULES = 1
44
PB_LIB_UMM_MALLOC = 1
55
PB_LIB_BTSTACK = 1
66
PB_MEDIA = 1
7+
PB_FONTS = 1
78

89
include ../_common/common.mk

bricks/nxt/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ PBIO_PLATFORM = nxt
55
PB_MCU_FAMILY = AT91SAM7
66

77
PB_LIB_UMM_MALLOC = 1
8+
PB_FONTS = 1
89

910
include ../_common/common.mk

bricks/virtualhub/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ MICROPY_ROM_TEXT_COMPRESSION = 1
88
PB_LIB_UMM_MALLOC = 1
99
PB_LIB_BTSTACK = 1
1010
PB_MEDIA = 1
11+
PB_FONTS = 1
1112

1213
include ../_common/common.mk

lib/pbio/src/image/Makefile

Lines changed: 0 additions & 34 deletions
This file was deleted.

lib/pbio/src/image/font_liberationsans_regular_14.c

Lines changed: 0 additions & 261 deletions
This file was deleted.

0 commit comments

Comments
 (0)