Home | History | Annotate | Download | only in core
      1 ###############################################################################
      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.
     11 sdk_font_rename_script := frameworks/base/tools/layoutlib/rename_font/build_font_single.py
     12 
     13 # Location of the fonttools library that the above script depends on.
     14 fonttools_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.
     18 SDK_FONT_TEMP := $(call intermediates-dir-for,PACKAGING,sdk-fonts,HOST,COMMON)
     19 
     20 # The font configuration files - system_fonts.xml, fallback_fonts.xml etc.
     21 sdk_font_config := $(sort $(wildcard frameworks/base/data/fonts/*.xml))
     22 sdk_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.
     30 sdk_fonts_device := $(filter $(TARGET_OUT)/fonts/%.ttf, $(INTERNAL_SYSTEMIMAGE_FILES))
     31 sdk_fonts_device := $(addprefix $(SDK_FONT_TEMP)/, $(notdir $(sdk_fonts_device)))
     32 
     33 # Macro to rename the font.
     34 sdk_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 
     44 # List of all dependencies - all fonts and configuration files.
     45 SDK_FONT_DEPS := $(sdk_fonts_device) $(sdk_font_config)
     46 
     47 # 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
     51 define sdk-extra-font-rule
     52 fontfullname := $$(SDK_FONT_TEMP)/$1
     53 ifeq ($$(filter $$(fontfullname),$$(sdk_fonts_device)),)
     54 SDK_FONT_DEPS += $$(fontfullname)
     55 $$(fontfullname): $2 $$(sdk_font_rename_script)
     56 	$$(hide) mkdir -p $$(dir $$@)
     57 	$$(hide) $$(call sdk_rename_font,$$<,$$@)
     58 endif
     59 fontfullname :=
     60 endef
     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 
     66 sdk-extra-font-rule :=
     67