blob: 0259a9ce507cde634f2a525b1b0a32bad6ca5349 [file] [log] [blame]
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -07001###############################################################################
2# Fonts shipped with the SDK need to be renamed for Java to handle them
3# properly. Hence, a special script is used to rename the fonts. We bundle all
4# the fonts that are shipped on a newer non-space-constrained device. However,
5# OpenType fonts used on these devices are not supported by Java. Their
6# replacements are added separately.
7###############################################################################
8
9
10# The script that renames the font.
Diego Pereza820b5a2017-04-21 14:21:55 +010011sdk_font_rename_script := frameworks/layoutlib/rename_font/build_font_single.py
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -070012
13# Location of the fonttools library that the above script depends on.
14fonttools_lib := external/fonttools/Lib
15
16# A temporary location to store the renamed fonts. atree picks all files in
17# this directory and bundles it with the SDK.
18SDK_FONT_TEMP := $(call intermediates-dir-for,PACKAGING,sdk-fonts,HOST,COMMON)
19
20# The font configuration files - system_fonts.xml, fallback_fonts.xml etc.
Dan Willemsen7c3e3f82015-09-29 16:30:21 -070021sdk_font_config := $(sort $(wildcard frameworks/base/data/fonts/*.xml))
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -070022sdk_font_config := $(addprefix $(SDK_FONT_TEMP)/, $(notdir $(sdk_font_config)))
23
24$(sdk_font_config): $(SDK_FONT_TEMP)/%.xml: \
25 frameworks/base/data/fonts/%.xml
26 $(hide) mkdir -p $(dir $@)
27 $(hide) cp -vf $< $@
28
29# List of fonts on the device that we want to ship. This is all .ttf fonts.
30sdk_fonts_device := $(filter $(TARGET_OUT)/fonts/%.ttf, $(INTERNAL_SYSTEMIMAGE_FILES))
31sdk_fonts_device := $(addprefix $(SDK_FONT_TEMP)/, $(notdir $(sdk_fonts_device)))
32
33# Macro to rename the font.
34sdk_rename_font = PYTHONPATH=$$PYTHONPATH:$(fonttools_lib) $(sdk_font_rename_script) \
35 $1 $2
36
37# TODO: If the font file is a symlink, reuse the font renamed from the symlink
38# target.
39$(sdk_fonts_device): $(SDK_FONT_TEMP)/%.ttf: $(TARGET_OUT)/fonts/%.ttf \
40 $(sdk_font_rename_script)
41 $(hide) mkdir -p $(dir $@)
42 $(hide) $(call sdk_rename_font,$<,$@)
43
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -070044# List of all dependencies - all fonts and configuration files.
Deepanshu Guptaf0adf872014-08-13 11:39:51 -070045SDK_FONT_DEPS := $(sdk_fonts_device) $(sdk_font_config)
Deepanshu Gupta7a864ea2014-08-11 15:20:02 -070046
Deepanshu Guptaf0adf872014-08-13 11:39:51 -070047# Define a macro to create rule for addititional fonts that we want to include
48# in the SDK.
49# $1 Output font name
50# $2 Source font path
51define sdk-extra-font-rule
52fontfullname := $$(SDK_FONT_TEMP)/$1
Deepanshu Gupta56355ba2014-09-04 18:59:05 -070053ifeq ($$(filter $$(fontfullname),$$(sdk_fonts_device)),)
Deepanshu Guptaf0adf872014-08-13 11:39:51 -070054SDK_FONT_DEPS += $$(fontfullname)
Deepanshu Gupta56355ba2014-09-04 18:59:05 -070055$$(fontfullname): $2 $$(sdk_font_rename_script)
Deepanshu Guptaf0adf872014-08-13 11:39:51 -070056 $$(hide) mkdir -p $$(dir $$@)
57 $$(hide) $$(call sdk_rename_font,$$<,$$@)
58endif
59fontfullname :=
60endef
61
62# These extra fonts are used as a replacement for OpenType fonts.
63$(eval $(call sdk-extra-font-rule,NanumGothic.ttf,external/naver-fonts/NanumGothic.ttf))
64$(eval $(call sdk-extra-font-rule,DroidSansFallback.ttf,frameworks/base/data/fonts/DroidSansFallbackFull.ttf))
65
66sdk-extra-font-rule :=