1# Copyright (C) 2015 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#      http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15# We have to use BUILD_PREBUILT instead of PRODUCT_COPY_FIES,
16# because MINIMAL_FONT_FOOTPRINT is only available in Android.mks.
17
18LOCAL_PATH := $(call my-dir)
19
20##########################################
21# create symlink for given font
22# $(1): new font $(2): link target
23# should be used with eval: $(eval $(call ...))
24define create-font-symlink
25$(PRODUCT_OUT)/system/fonts/$(1) : $(PRODUCT_OUT)/system/fonts/$(2)
26	@echo "Symlink: $$@ -> $$<"
27	@mkdir -p $$(dir $$@)
28	@rm -rf $$@
29	$(hide) ln -sf $$(notdir $$<) $$@
30# this magic makes LOCAL_REQUIRED_MODULES work
31ALL_MODULES.$(1).INSTALLED := \
32    $(ALL_MODULES.$(1).INSTALLED) $(PRODUCT_OUT)/system/fonts/$(1)
33endef
34
35# Build the rest of font files as prebuilt.
36# $(1): The source file name in LOCAL_PATH.
37#       It also serves as the module name and the dest file name.
38define build-one-font-module
39$(eval include $(CLEAR_VARS))\
40$(eval LOCAL_MODULE := $(1))\
41$(eval LOCAL_SRC_FILES := $(1))\
42$(eval LOCAL_MODULE_CLASS := ETC)\
43$(eval LOCAL_MODULE_TAGS := optional)\
44$(eval LOCAL_MODULE_PATH := $(TARGET_OUT)/fonts)\
45$(eval include $(BUILD_PREBUILT))
46endef
47
48font_src_files := \
49    Roboto-Regular.ttf \
50    Roboto-Bold.ttf \
51    Roboto-Italic.ttf \
52    Roboto-BoldItalic.ttf
53
54ifeq ($(MINIMAL_FONT_FOOTPRINT),true)
55
56$(eval $(call create-font-symlink,Roboto-Black.ttf,Roboto-Bold.ttf))
57$(eval $(call create-font-symlink,Roboto-BlackItalic.ttf,Roboto-BoldItalic.ttf))
58$(eval $(call create-font-symlink,Roboto-Light.ttf,Roboto-Regular.ttf))
59$(eval $(call create-font-symlink,Roboto-LightItalic.ttf,Roboto-Italic.ttf))
60$(eval $(call create-font-symlink,Roboto-Medium.ttf,Roboto-Regular.ttf))
61$(eval $(call create-font-symlink,Roboto-MediumItalic.ttf,Roboto-Italic.ttf))
62$(eval $(call create-font-symlink,Roboto-Thin.ttf,Roboto-Regular.ttf))
63$(eval $(call create-font-symlink,Roboto-ThinItalic.ttf,Roboto-Italic.ttf))
64$(eval $(call create-font-symlink,RobotoCondensed-Regular.ttf,Roboto-Regular.ttf))
65$(eval $(call create-font-symlink,RobotoCondensed-Bold.ttf,Roboto-Bold.ttf))
66$(eval $(call create-font-symlink,RobotoCondensed-Italic.ttf,Roboto-Italic.ttf))
67$(eval $(call create-font-symlink,RobotoCondensed-BoldItalic.ttf,Roboto-BoldItalic.ttf))
68$(eval $(call create-font-symlink,RobotoCondensed-Light.ttf,Roboto-Regular.ttf))
69$(eval $(call create-font-symlink,RobotoCondensed-LightItalic.ttf,Roboto-Italic.ttf))
70$(eval $(call create-font-symlink,RobotoCondensed-Medium.ttf,Roboto-Regular.ttf))
71$(eval $(call create-font-symlink,RobotoCondensed-MediumItalic.ttf,Roboto-Italic.ttf))
72
73else # !MINIMAL_FONT
74font_src_files += \
75    Roboto-Black.ttf \
76    Roboto-BlackItalic.ttf \
77    Roboto-Light.ttf \
78    Roboto-LightItalic.ttf \
79    Roboto-Medium.ttf \
80    Roboto-MediumItalic.ttf \
81    Roboto-Thin.ttf \
82    Roboto-ThinItalic.ttf \
83    RobotoCondensed-Regular.ttf \
84    RobotoCondensed-Bold.ttf \
85    RobotoCondensed-Italic.ttf \
86    RobotoCondensed-BoldItalic.ttf \
87    RobotoCondensed-Light.ttf \
88    RobotoCondensed-LightItalic.ttf \
89    RobotoCondensed-Medium.ttf \
90    RobotoCondensed-MediumItalic.ttf
91
92endif # !MINIMAL_FONT
93
94$(foreach f, $(font_src_files), $(call build-one-font-module, $(f)))
95
96build-one-font-module :=
97font_src_files :=
98