Trammell Hudson avatar Trammell Hudson committed 82d1269

Use makefile rules to change $(FONTS) into a font list and resource list

Comments (0)

Files changed (2)

 
 #
 # Generate a font resource from a given ttf.
+# The fonts are specified in the leaf makefiles in $(FONT) as
 #
+#	path-to-font:size:resource-name
+#
+# A somewhat complex make rule translates this list into the
+# targets for each font to be generated and as well as the
+# resource list to pass into the make bundle tool.
+#
+map = $(foreach f,$2,$(call $1,$f))
+
 $O/%.pfo:
 	$(PYTHON) $(PEBBLE_HOME)/tools/font/fontgen.py \
 		pfo \
 		$< \
 		$@ \
 
+mkfont_rules = \
+	$(eval F = $(word 1,$1)) \
+	$(eval S = $(word 2,$1)) \
+	$(eval R = $(word 3,$1)) \
+	$(eval $(info rules '$F' '$S' '$R')) \
+	$(eval $O/$R.$S.pfo: $F) \
+	$(eval FONT_LIST += $O/$R.$S.pfo) \
+	$(eval RESOURCE_LIST += $O/$R.$S.pfo $R) \
+
+mkfont = \
+	$(info mkfont '$(1)') \
+	$(call mkfont_rules,$(subst :, ,$1)) \
+
+$(eval $(call map,mkfont,$(FONTS)))
+
+
 #
 # Generate a resource binary from all of the fonts
 #
 	cat > $@ $^
 
 
-RESOURCES := $(addprefix $O/,$(FONTS)) $O/resource_map.json
+RESOURCES := $(FONT_LIST) $O/resource_map.json
 
 $O/app_resources.pbpack.data: $(RESOURCES)
 	cat > $@ $^
 # This header file name is forced by <pebble_app.h>
 $O/src/resource_ids.auto.h: \
 	$O/app_resources.pbpack.data \
-	$(addprefix $O/,$(FONTS)) \
+	$(FONT_LIST) \
 
 	$(PYTHON) $(PEBBLE_HOME)/tools/generate_resource_code.py \
 		resource_header \

hoelaat/src/Makefile

 TARGET := hoelaat
 
 FONTS := \
-	Arial.28.pfo \
-	Arial-Black.30.pfo \
-
-RESOURCE_LIST := \
-	../build/Arial.28.pfo FONT_ARIAL_28 \
-	../build/Arial-Black.30.pfo FONT_ARIAL_BLACK_30 \
+	fonts/Arial.ttf:28:FONT_ARIAL_28 \
+	fonts/Arial-Black.ttf:30:FONT_ARIAL_BLACK_30 \
 
 include ../../Makefile.pebble
-
-$O/Arial.30.pfo: fonts/Arial.ttf
-$O/Arial.28.pfo: fonts/Arial.ttf
-$O/Arial-Black.30.pfo: fonts/Arial-Black.ttf
-
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.