summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoozbeh Pournader <roozbeh@google.com>2016-08-19 21:43:01 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2016-08-19 21:43:01 +0000
commit599bd2666e266cbaa10e2e2271008bff2a003102 (patch)
tree1279454c57601c2f029cb9503a523a0f19b3db5a
parent7d9f678d09d8b98b7a30cbfe09f1bb15bb239675 (diff)
parent51f0831a09eb82c35e17e95d22fdcf0db4020606 (diff)
downloadnoto-fonts-599bd2666e266cbaa10e2e2271008bff2a003102.tar.gz
Merge "Remove default-emoji characters from Noto CJK [DO NOT MERGE]" into nyc-mr1-devandroid-cts_7.1_r1android-cts-7.1_r9android-cts-7.1_r8android-cts-7.1_r7android-cts-7.1_r6android-cts-7.1_r5android-cts-7.1_r4android-cts-7.1_r3android-cts-7.1_r29android-cts-7.1_r28android-cts-7.1_r27android-cts-7.1_r26android-cts-7.1_r25android-cts-7.1_r24android-cts-7.1_r23android-cts-7.1_r22android-cts-7.1_r21android-cts-7.1_r20android-cts-7.1_r2android-cts-7.1_r19android-cts-7.1_r18android-cts-7.1_r17android-cts-7.1_r16android-cts-7.1_r15android-cts-7.1_r14android-cts-7.1_r13android-cts-7.1_r12android-cts-7.1_r11android-cts-7.1_r10android-cts-7.1_r1android-7.1.1_r9android-7.1.1_r8android-7.1.1_r7android-7.1.1_r61android-7.1.1_r60android-7.1.1_r6android-7.1.1_r59android-7.1.1_r58android-7.1.1_r57android-7.1.1_r56android-7.1.1_r55android-7.1.1_r54android-7.1.1_r53android-7.1.1_r52android-7.1.1_r51android-7.1.1_r50android-7.1.1_r49android-7.1.1_r48android-7.1.1_r47android-7.1.1_r46android-7.1.1_r45android-7.1.1_r44android-7.1.1_r43android-7.1.1_r42android-7.1.1_r41android-7.1.1_r40android-7.1.1_r4android-7.1.1_r39android-7.1.1_r38android-7.1.1_r35android-7.1.1_r33android-7.1.1_r32android-7.1.1_r31android-7.1.1_r3android-7.1.1_r28android-7.1.1_r27android-7.1.1_r26android-7.1.1_r25android-7.1.1_r24android-7.1.1_r23android-7.1.1_r22android-7.1.1_r21android-7.1.1_r20android-7.1.1_r2android-7.1.1_r17android-7.1.1_r16android-7.1.1_r15android-7.1.1_r14android-7.1.1_r13android-7.1.1_r12android-7.1.1_r11android-7.1.1_r10android-7.1.1_r1nougat-mr1.8-releasenougat-mr1.7-releasenougat-mr1.6-releasenougat-mr1.5-releasenougat-mr1.4-releasenougat-mr1.3-releasenougat-mr1.2-releasenougat-mr1.1-releasenougat-mr1-volantis-releasenougat-mr1-security-releasenougat-mr1-releasenougat-mr1-flounder-releasenougat-mr1-devnougat-mr1-cts-release
-rw-r--r--cjk/NotoSansCJK-Regular.ttcbin18677220 -> 18677700 bytes
-rw-r--r--cjk/README.android3
-rwxr-xr-xcjk/subset_noto_cjk.py102
3 files changed, 104 insertions, 1 deletions
diff --git a/cjk/NotoSansCJK-Regular.ttc b/cjk/NotoSansCJK-Regular.ttc
index 2dd4a60..d9a2262 100644
--- a/cjk/NotoSansCJK-Regular.ttc
+++ b/cjk/NotoSansCJK-Regular.ttc
Binary files differ
diff --git a/cjk/README.android b/cjk/README.android
index 5671de2..e5d0f79 100644
--- a/cjk/README.android
+++ b/cjk/README.android
@@ -7,4 +7,5 @@ Description:
Noto CJK fonts, for supporting Chinese, Japanese, and Korean.
Local Modifications:
-No modifications.
+The fonts have been modified to remove cmap entries for characters
+that should default to emoji style in Android.
diff --git a/cjk/subset_noto_cjk.py b/cjk/subset_noto_cjk.py
new file mode 100755
index 0000000..8167267
--- /dev/null
+++ b/cjk/subset_noto_cjk.py
@@ -0,0 +1,102 @@
+#!/usr/bin/python
+# coding=UTF-8
+#
+# Copyright 2016 Google Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""Create a curated subset of Noto CJK for Android."""
+
+import os
+
+from fontTools import ttLib
+from nototools import font_data
+from nototools import ttc_utils
+
+# Characters supported in Noto CJK fonts that UTR #51 recommends default to
+# emoji-style.
+EMOJI_IN_CJK = {
+ 0x26BD, # ⚽ SOCCER BALL
+ 0x26BE, # ⚾ BASEBALL
+ 0x1F18E, # 🆎 NEGATIVE SQUARED AB
+ 0x1F191, # 🆑 SQUARED CL
+ 0x1F192, # 🆒 SQUARED COOL
+ 0x1F193, # 🆓 SQUARED FREE
+ 0x1F194, # 🆔 SQUARED ID
+ 0x1F195, # 🆕 SQUARED NEW
+ 0x1F196, # 🆖 SQUARED NG
+ 0x1F197, # 🆗 SQUARED OK
+ 0x1F198, # 🆘 SQUARED SOS
+ 0x1F199, # 🆙 SQUARED UP WITH EXCLAMATION MARK
+ 0x1F19A, # 🆚 SQUARED VS
+ 0x1F201, # 🈁 SQUARED KATAKANA KOKO
+ 0x1F21A, # 🈚 SQUARED CJK UNIFIED IDEOGRAPH-7121
+ 0x1F22F, # 🈯 SQUARED CJK UNIFIED IDEOGRAPH-6307
+ 0x1F232, # 🈲 SQUARED CJK UNIFIED IDEOGRAPH-7981
+ 0x1F233, # 🈳 SQUARED CJK UNIFIED IDEOGRAPH-7A7A
+ 0x1F234, # 🈴 SQUARED CJK UNIFIED IDEOGRAPH-5408
+ 0x1F235, # 🈵 SQUARED CJK UNIFIED IDEOGRAPH-6E80
+ 0x1F236, # 🈶 SQUARED CJK UNIFIED IDEOGRAPH-6709
+ 0x1F238, # 🈸 SQUARED CJK UNIFIED IDEOGRAPH-7533
+ 0x1F239, # 🈹 SQUARED CJK UNIFIED IDEOGRAPH-5272
+ 0x1F23A, # 🈺 SQUARED CJK UNIFIED IDEOGRAPH-55B6
+ 0x1F250, # 🉐 CIRCLED IDEOGRAPH ADVANTAGE
+ 0x1F251, # 🉑 CIRCLED IDEOGRAPH ACCEPT
+}
+
+# Characters we have decided we are doing as emoji-style in Android,
+# despite UTR #51's recommendation
+ANDROID_EMOJI = {
+ 0x2600, # ☀ BLACK SUN WITH RAYS
+ 0x2601, # ☁ CLOUD
+ 0X260E, # ☎ BLACK TELEPHONE
+ 0x261D, # ☝ WHITE UP POINTING INDEX
+ 0x263A, # ☺ WHITE SMILING FACE
+ 0x2660, # ♠ BLACK SPADE SUIT
+ 0x2663, # ♣ BLACK CLUB SUIT
+ 0x2665, # ♥ BLACK HEART SUIT
+ 0x2666, # ♦ BLACK DIAMOND SUIT
+ 0x270C, # ✌ VICTORY HAND
+ 0x2744, # ❄ SNOWFLAKE
+ 0x2764, # ❤ HEAVY BLACK HEART
+}
+
+
+def remove_from_cmap(infile, outfile, exclude=frozenset()):
+ """Removes a set of characters from a font file's cmap table."""
+ font = ttLib.TTFont(infile)
+ font_data.delete_from_cmap(font, exclude)
+ font.save(outfile)
+
+
+TTC_NAME = 'NotoSansCJK-Regular.ttc'
+OTF_NAMES = ['NotoSans%sCJK%s-Regular.otf' % (mono, variant)
+ for mono in ['', 'Mono']
+ for variant in ['jp', 'kr', 'sc', 'tc']]
+TEMP_DIR = 'no-emoji'
+
+
+if not os.path.exists(TEMP_DIR):
+ os.mkdir(TEMP_DIR)
+
+for index, otf_name in enumerate(OTF_NAMES):
+ print 'Subsetting %s...' % otf_name
+ font = ttLib.TTFont(TTC_NAME, fontNumber=index)
+ font.save(otf_name)
+ remove_from_cmap(
+ otf_name,
+ os.path.join(TEMP_DIR, otf_name),
+ exclude=sorted(EMOJI_IN_CJK | ANDROID_EMOJI))
+
+os.chdir(TEMP_DIR)
+ttc_utils.build_ttc(TTC_NAME, OTF_NAMES)