146b20e7f41ded340596b732aaf08cc2d05a8e842Ying Wang# Copyright (C) 2011 The Android Open Source Project
246b20e7f41ded340596b732aaf08cc2d05a8e842Ying Wang#
346b20e7f41ded340596b732aaf08cc2d05a8e842Ying Wang# Licensed under the Apache License, Version 2.0 (the "License");
446b20e7f41ded340596b732aaf08cc2d05a8e842Ying Wang# you may not use this file except in compliance with the License.
546b20e7f41ded340596b732aaf08cc2d05a8e842Ying Wang# You may obtain a copy of the License at
646b20e7f41ded340596b732aaf08cc2d05a8e842Ying Wang#
746b20e7f41ded340596b732aaf08cc2d05a8e842Ying Wang#      http://www.apache.org/licenses/LICENSE-2.0
846b20e7f41ded340596b732aaf08cc2d05a8e842Ying Wang#
946b20e7f41ded340596b732aaf08cc2d05a8e842Ying Wang# Unless required by applicable law or agreed to in writing, software
1046b20e7f41ded340596b732aaf08cc2d05a8e842Ying Wang# distributed under the License is distributed on an "AS IS" BASIS,
1146b20e7f41ded340596b732aaf08cc2d05a8e842Ying Wang# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1246b20e7f41ded340596b732aaf08cc2d05a8e842Ying Wang# See the License for the specific language governing permissions and
1346b20e7f41ded340596b732aaf08cc2d05a8e842Ying Wang# limitations under the License.
1446b20e7f41ded340596b732aaf08cc2d05a8e842Ying Wang
1546b20e7f41ded340596b732aaf08cc2d05a8e842Ying Wang# We have to use BUILD_PREBUILT instead of PRODUCT_COPY_FIES,
16aba60b542e5e60288262429fbec5a5a8724c313fRoozbeh Pournader# because MINIMAL_FONT_FOOTPRINT is only available in Android.mks.
1746b20e7f41ded340596b732aaf08cc2d05a8e842Ying Wang
1846b20e7f41ded340596b732aaf08cc2d05a8e842Ying WangLOCAL_PATH := $(call my-dir)
1946b20e7f41ded340596b732aaf08cc2d05a8e842Ying Wang
208e359817da14f6a4ffcf3bf4f7a59bc4fef8c211Ying Wang##########################################
21087610198e82bc5537b2a8e9c07ed6a20829a16dKeun young Park# create symlink for given font
22087610198e82bc5537b2a8e9c07ed6a20829a16dKeun young Park# $(1): new font $(2): link target
23087610198e82bc5537b2a8e9c07ed6a20829a16dKeun young Park# should be used with eval: $(eval $(call ...))
24087610198e82bc5537b2a8e9c07ed6a20829a16dKeun young Parkdefine create-font-symlink
25087610198e82bc5537b2a8e9c07ed6a20829a16dKeun young Park$(PRODUCT_OUT)/system/fonts/$(1) : $(PRODUCT_OUT)/system/fonts/$(2)
26087610198e82bc5537b2a8e9c07ed6a20829a16dKeun young Park	@echo "Symlink: $$@ -> $$<"
27087610198e82bc5537b2a8e9c07ed6a20829a16dKeun young Park	@mkdir -p $$(dir $$@)
28087610198e82bc5537b2a8e9c07ed6a20829a16dKeun young Park	@rm -rf $$@
29087610198e82bc5537b2a8e9c07ed6a20829a16dKeun young Park	$(hide) ln -sf $$(notdir $$<) $$@
308e359817da14f6a4ffcf3bf4f7a59bc4fef8c211Ying Wang# this magic makes LOCAL_REQUIRED_MODULES work
31087610198e82bc5537b2a8e9c07ed6a20829a16dKeun young ParkALL_MODULES.$(1).INSTALLED := \
32087610198e82bc5537b2a8e9c07ed6a20829a16dKeun young Park    $(ALL_MODULES.$(1).INSTALLED) $(PRODUCT_OUT)/system/fonts/$(1)
33087610198e82bc5537b2a8e9c07ed6a20829a16dKeun young Parkendef
348e359817da14f6a4ffcf3bf4f7a59bc4fef8c211Ying Wang
35087610198e82bc5537b2a8e9c07ed6a20829a16dKeun young Park##########################################
365225620508a5a0d39de4f508cec5cecec60f527dRoozbeh Pournader# The following fonts are just symlinks, for backward compatibility.
37087610198e82bc5537b2a8e9c07ed6a20829a16dKeun young Park##########################################
38087610198e82bc5537b2a8e9c07ed6a20829a16dKeun young Park$(eval $(call create-font-symlink,DroidSans.ttf,Roboto-Regular.ttf))
39087610198e82bc5537b2a8e9c07ed6a20829a16dKeun young Park$(eval $(call create-font-symlink,DroidSans-Bold.ttf,Roboto-Bold.ttf))
40a08f0f8f453bb192dd0c4cd25a5aeb05986805fcVictoria Lease$(eval $(call create-font-symlink,DroidSerif-Regular.ttf,NotoSerif-Regular.ttf))
41a08f0f8f453bb192dd0c4cd25a5aeb05986805fcVictoria Lease$(eval $(call create-font-symlink,DroidSerif-Bold.ttf,NotoSerif-Bold.ttf))
42a08f0f8f453bb192dd0c4cd25a5aeb05986805fcVictoria Lease$(eval $(call create-font-symlink,DroidSerif-Italic.ttf,NotoSerif-Italic.ttf))
43a08f0f8f453bb192dd0c4cd25a5aeb05986805fcVictoria Lease$(eval $(call create-font-symlink,DroidSerif-BoldItalic.ttf,NotoSerif-BoldItalic.ttf))
4446b20e7f41ded340596b732aaf08cc2d05a8e842Ying Wang
45f99c12cee55bae44bbac0a943a18b5121c007101Victoria Leaseextra_font_files := \
46f99c12cee55bae44bbac0a943a18b5121c007101Victoria Lease    DroidSans.ttf \
47f99c12cee55bae44bbac0a943a18b5121c007101Victoria Lease    DroidSans-Bold.ttf
48f99c12cee55bae44bbac0a943a18b5121c007101Victoria Lease
498e359817da14f6a4ffcf3bf4f7a59bc4fef8c211Ying Wang################################
5032a65c7ddd6bebe30af668274757599d5a47cc60Roozbeh Pournader# Use DroidSansMono to hang extra_font_files on
5146b20e7f41ded340596b732aaf08cc2d05a8e842Ying Wanginclude $(CLEAR_VARS)
5232a65c7ddd6bebe30af668274757599d5a47cc60Roozbeh PournaderLOCAL_MODULE := DroidSansMono.ttf
5332a65c7ddd6bebe30af668274757599d5a47cc60Roozbeh PournaderLOCAL_SRC_FILES := $(LOCAL_MODULE)
5446b20e7f41ded340596b732aaf08cc2d05a8e842Ying WangLOCAL_MODULE_CLASS := ETC
5546b20e7f41ded340596b732aaf08cc2d05a8e842Ying WangLOCAL_MODULE_TAGS := optional
5646b20e7f41ded340596b732aaf08cc2d05a8e842Ying WangLOCAL_MODULE_PATH := $(TARGET_OUT)/fonts
571c097a9c21096a0d677f336081bfdeb4cfc96063Russell BrennerLOCAL_REQUIRED_MODULES := $(extra_font_files)
5846b20e7f41ded340596b732aaf08cc2d05a8e842Ying Wanginclude $(BUILD_PREBUILT)
5932a65c7ddd6bebe30af668274757599d5a47cc60Roozbeh Pournaderextra_font_files :=
6032a65c7ddd6bebe30af668274757599d5a47cc60Roozbeh Pournader
6132a65c7ddd6bebe30af668274757599d5a47cc60Roozbeh Pournader################################
6232a65c7ddd6bebe30af668274757599d5a47cc60Roozbeh Pournader# Build the rest of font files as prebuilt.
63193ec66214ecf4cdb43702655a4a571ae0c7e6ceYing Wang
64193ec66214ecf4cdb43702655a4a571ae0c7e6ceYing Wang# $(1): The source file name in LOCAL_PATH.
65193ec66214ecf4cdb43702655a4a571ae0c7e6ceYing Wang#       It also serves as the module name and the dest file name.
66193ec66214ecf4cdb43702655a4a571ae0c7e6ceYing Wangdefine build-one-font-module
67193ec66214ecf4cdb43702655a4a571ae0c7e6ceYing Wang$(eval include $(CLEAR_VARS))\
68193ec66214ecf4cdb43702655a4a571ae0c7e6ceYing Wang$(eval LOCAL_MODULE := $(1))\
69193ec66214ecf4cdb43702655a4a571ae0c7e6ceYing Wang$(eval LOCAL_SRC_FILES := $(1))\
70193ec66214ecf4cdb43702655a4a571ae0c7e6ceYing Wang$(eval LOCAL_MODULE_CLASS := ETC)\
71193ec66214ecf4cdb43702655a4a571ae0c7e6ceYing Wang$(eval LOCAL_MODULE_TAGS := optional)\
72193ec66214ecf4cdb43702655a4a571ae0c7e6ceYing Wang$(eval LOCAL_MODULE_PATH := $(TARGET_OUT)/fonts)\
73193ec66214ecf4cdb43702655a4a571ae0c7e6ceYing Wang$(eval include $(BUILD_PREBUILT))
74193ec66214ecf4cdb43702655a4a571ae0c7e6ceYing Wangendef
75193ec66214ecf4cdb43702655a4a571ae0c7e6ceYing Wang
76193ec66214ecf4cdb43702655a4a571ae0c7e6ceYing Wangfont_src_files := \
77cee5f2023b4e33c8f499e94a3d3cdb5e99d3a325Ben Wagner    AndroidClock.ttf
78087610198e82bc5537b2a8e9c07ed6a20829a16dKeun young Park
79193ec66214ecf4cdb43702655a4a571ae0c7e6ceYing Wang$(foreach f, $(font_src_files), $(call build-one-font-module, $(f)))
80193ec66214ecf4cdb43702655a4a571ae0c7e6ceYing Wang
81193ec66214ecf4cdb43702655a4a571ae0c7e6ceYing Wangbuild-one-font-module :=
82193ec66214ecf4cdb43702655a4a571ae0c7e6ceYing Wangfont_src_files :=
830e969e2c0ba9ad863c7fcfc3973a16b1b599e50aRoozbeh Pournader
847459bc49b043e0770b6bda090b2b2e6a6326e2abAndrew Sapperstein################################
857459bc49b043e0770b6bda090b2b2e6a6326e2abAndrew Sapperstein# Copies the font configuration file into system/etc for the product as fonts.xml.
867459bc49b043e0770b6bda090b2b2e6a6326e2abAndrew Sapperstein# In the case where $(ADDITIONAL_FONTS_FILE) is defined, the content of $(ADDITIONAL_FONTS_FILE)
877459bc49b043e0770b6bda090b2b2e6a6326e2abAndrew Sapperstein# is added to the $(AOSP_FONTS_FILE).
887459bc49b043e0770b6bda090b2b2e6a6326e2abAndrew Sappersteininclude $(CLEAR_VARS)
897459bc49b043e0770b6bda090b2b2e6a6326e2abAndrew Sapperstein
907459bc49b043e0770b6bda090b2b2e6a6326e2abAndrew SappersteinLOCAL_MODULE := fonts.xml
917459bc49b043e0770b6bda090b2b2e6a6326e2abAndrew SappersteinLOCAL_MODULE_CLASS := ETC
927459bc49b043e0770b6bda090b2b2e6a6326e2abAndrew Sapperstein
937459bc49b043e0770b6bda090b2b2e6a6326e2abAndrew SappersteinAOSP_FONTS_FILE := frameworks/base/data/fonts/fonts.xml
947459bc49b043e0770b6bda090b2b2e6a6326e2abAndrew Sapperstein
957459bc49b043e0770b6bda090b2b2e6a6326e2abAndrew Sappersteinifdef ADDITIONAL_FONTS_FILE
967459bc49b043e0770b6bda090b2b2e6a6326e2abAndrew SappersteinADDITIONAL_FONTS_SCRIPT := frameworks/base/tools/fonts/add_additional_fonts.py
977459bc49b043e0770b6bda090b2b2e6a6326e2abAndrew SappersteinADD_ADDITIONAL_FONTS := $(local-generated-sources-dir)/fonts.xml
987459bc49b043e0770b6bda090b2b2e6a6326e2abAndrew Sapperstein
997459bc49b043e0770b6bda090b2b2e6a6326e2abAndrew Sapperstein$(ADD_ADDITIONAL_FONTS): PRIVATE_SCRIPT := $(ADDITIONAL_FONTS_SCRIPT)
1007459bc49b043e0770b6bda090b2b2e6a6326e2abAndrew Sapperstein$(ADD_ADDITIONAL_FONTS): PRIVATE_ADDITIONAL_FONTS_FILE := $(ADDITIONAL_FONTS_FILE)
1017459bc49b043e0770b6bda090b2b2e6a6326e2abAndrew Sapperstein$(ADD_ADDITIONAL_FONTS): $(ADDITIONAL_FONTS_SCRIPT) $(AOSP_FONTS_FILE) $(ADDITIONAL_FONTS_FILE)
1027459bc49b043e0770b6bda090b2b2e6a6326e2abAndrew Sapperstein	rm -f $@
1037459bc49b043e0770b6bda090b2b2e6a6326e2abAndrew Sapperstein	python $(PRIVATE_SCRIPT) $@ $(PRIVATE_ADDITIONAL_FONTS_FILE)
1047459bc49b043e0770b6bda090b2b2e6a6326e2abAndrew Sappersteinelse
1057459bc49b043e0770b6bda090b2b2e6a6326e2abAndrew SappersteinADD_ADDITIONAL_FONTS := $(AOSP_FONTS_FILE)
1067459bc49b043e0770b6bda090b2b2e6a6326e2abAndrew Sappersteinendif
1077459bc49b043e0770b6bda090b2b2e6a6326e2abAndrew Sapperstein
1087459bc49b043e0770b6bda090b2b2e6a6326e2abAndrew SappersteinLOCAL_PREBUILT_MODULE_FILE := $(ADD_ADDITIONAL_FONTS)
1097459bc49b043e0770b6bda090b2b2e6a6326e2abAndrew Sapperstein
1107459bc49b043e0770b6bda090b2b2e6a6326e2abAndrew Sappersteininclude $(BUILD_PREBUILT)
1110e969e2c0ba9ad863c7fcfc3973a16b1b599e50aRoozbeh Pournader
1120e969e2c0ba9ad863c7fcfc3973a16b1b599e50aRoozbeh Pournader# Run sanity tests on fonts on checkbuild
1130e969e2c0ba9ad863c7fcfc3973a16b1b599e50aRoozbeh Pournadercheckbuild: fontchain_lint
1140e969e2c0ba9ad863c7fcfc3973a16b1b599e50aRoozbeh Pournader
1152db709de30688a5761b45116639bada335aae3b7Nan ZhangFONTCHAIN_LINTER := $(HOST_OUT_EXECUTABLES)/fontchain_linter
116aba60b542e5e60288262429fbec5a5a8724c313fRoozbeh Pournaderifeq ($(MINIMAL_FONT_FOOTPRINT),true)
11727ec3ace18e329eb9654f297dedf667f94baaf81Roozbeh PournaderCHECK_EMOJI := false
11827ec3ace18e329eb9654f297dedf667f94baaf81Roozbeh Pournaderelse
11927ec3ace18e329eb9654f297dedf667f94baaf81Roozbeh PournaderCHECK_EMOJI := true
12027ec3ace18e329eb9654f297dedf667f94baaf81Roozbeh Pournaderendif
1210e969e2c0ba9ad863c7fcfc3973a16b1b599e50aRoozbeh Pournader
122f5de525ee3547b8a69a21aec1e1a3175bc06f442Colin Crossfontchain_lint_timestamp := $(call intermediates-dir-for,PACKAGING,fontchain_lint)/stamp
123f5de525ee3547b8a69a21aec1e1a3175bc06f442Colin Cross
1240e969e2c0ba9ad863c7fcfc3973a16b1b599e50aRoozbeh Pournader.PHONY: fontchain_lint
125f5de525ee3547b8a69a21aec1e1a3175bc06f442Colin Crossfontchain_lint: $(fontchain_lint_timestamp)
126f5de525ee3547b8a69a21aec1e1a3175bc06f442Colin Cross
127f5de525ee3547b8a69a21aec1e1a3175bc06f442Colin Crossfontchain_lint_deps := \
128f5de525ee3547b8a69a21aec1e1a3175bc06f442Colin Cross    external/unicode/DerivedAge.txt \
129f5de525ee3547b8a69a21aec1e1a3175bc06f442Colin Cross    external/unicode/emoji-data.txt \
130f5de525ee3547b8a69a21aec1e1a3175bc06f442Colin Cross    external/unicode/emoji-sequences.txt \
131f5de525ee3547b8a69a21aec1e1a3175bc06f442Colin Cross    external/unicode/emoji-variation-sequences.txt \
132f5de525ee3547b8a69a21aec1e1a3175bc06f442Colin Cross    external/unicode/emoji-zwj-sequences.txt \
133f5de525ee3547b8a69a21aec1e1a3175bc06f442Colin Cross    external/unicode/additions/emoji-data.txt \
134f5de525ee3547b8a69a21aec1e1a3175bc06f442Colin Cross    external/unicode/additions/emoji-sequences.txt \
135f5de525ee3547b8a69a21aec1e1a3175bc06f442Colin Cross    external/unicode/additions/emoji-zwj-sequences.txt \
136f5de525ee3547b8a69a21aec1e1a3175bc06f442Colin Cross
137f5de525ee3547b8a69a21aec1e1a3175bc06f442Colin Cross$(fontchain_lint_timestamp): $(FONTCHAIN_LINTER) $(TARGET_OUT)/etc/fonts.xml $(PRODUCT_OUT)/system.img $(fontchain_lint_deps)
138f5de525ee3547b8a69a21aec1e1a3175bc06f442Colin Cross	@echo Running fontchain lint
1392db709de30688a5761b45116639bada335aae3b7Nan Zhang	$(FONTCHAIN_LINTER) $(TARGET_OUT) $(CHECK_EMOJI) external/unicode
140f5de525ee3547b8a69a21aec1e1a3175bc06f442Colin Cross	touch $@
141