Merge pull request #399 from googlefonts/generate-colrv1-configs

add script to generate colrv1 configs by globbing the relevant *.svg files
emoji_u1f44f_SourceFile
Cosimo Lupo 2022-07-21 17:41:21 +01:00 committed by GitHub
commit 86c19b00b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 3518 additions and 3414 deletions

View File

@ -5,6 +5,16 @@ contains emojicompat metadata.
## Build Steps
1. Check the list of sources in the config files is in sync with the current sources
```shell
# running from the noto-emoji repository root directory
python colrv1_generate_configs.py
git diff colrv1/*.toml
```
If configs are in sync, the `colrv1/*.toml` files should contain no diffs.
1. Compile the COLRv1 fonts
```shell
@ -18,4 +28,4 @@ contains emojicompat metadata.
# Assumed to be in a python3 environment with requirements.txt fulfilled
python colrv1_postproc.py colrv1/build/NotoColorEmoji-noflags.ttf \
PATH_TO/NotoColorEmojiCompat.ttf
```
```

View File

@ -3472,6 +3472,7 @@ srcs = [
"../third_party/region-flags/waved-svg/emoji_u1f1e7_1f1f7.svg",
"../third_party/region-flags/waved-svg/emoji_u1f1e7_1f1f8.svg",
"../third_party/region-flags/waved-svg/emoji_u1f1e7_1f1f9.svg",
"../third_party/region-flags/waved-svg/emoji_u1f1e7_1f1fb.svg",
"../third_party/region-flags/waved-svg/emoji_u1f1e7_1f1fc.svg",
"../third_party/region-flags/waved-svg/emoji_u1f1e7_1f1fe.svg",
"../third_party/region-flags/waved-svg/emoji_u1f1e7_1f1ff.svg",
@ -3487,6 +3488,7 @@ srcs = [
"../third_party/region-flags/waved-svg/emoji_u1f1e8_1f1f2.svg",
"../third_party/region-flags/waved-svg/emoji_u1f1e8_1f1f3.svg",
"../third_party/region-flags/waved-svg/emoji_u1f1e8_1f1f4.svg",
"../third_party/region-flags/waved-svg/emoji_u1f1e8_1f1f5.svg",
"../third_party/region-flags/waved-svg/emoji_u1f1e8_1f1f7.svg",
"../third_party/region-flags/waved-svg/emoji_u1f1e8_1f1fa.svg",
"../third_party/region-flags/waved-svg/emoji_u1f1e8_1f1fb.svg",
@ -3495,11 +3497,13 @@ srcs = [
"../third_party/region-flags/waved-svg/emoji_u1f1e8_1f1fe.svg",
"../third_party/region-flags/waved-svg/emoji_u1f1e8_1f1ff.svg",
"../third_party/region-flags/waved-svg/emoji_u1f1e9_1f1ea.svg",
"../third_party/region-flags/waved-svg/emoji_u1f1e9_1f1ec.svg",
"../third_party/region-flags/waved-svg/emoji_u1f1e9_1f1ef.svg",
"../third_party/region-flags/waved-svg/emoji_u1f1e9_1f1f0.svg",
"../third_party/region-flags/waved-svg/emoji_u1f1e9_1f1f2.svg",
"../third_party/region-flags/waved-svg/emoji_u1f1e9_1f1f4.svg",
"../third_party/region-flags/waved-svg/emoji_u1f1e9_1f1ff.svg",
"../third_party/region-flags/waved-svg/emoji_u1f1ea_1f1e6.svg",
"../third_party/region-flags/waved-svg/emoji_u1f1ea_1f1e8.svg",
"../third_party/region-flags/waved-svg/emoji_u1f1ea_1f1ea.svg",
"../third_party/region-flags/waved-svg/emoji_u1f1ea_1f1ec.svg",
@ -3534,6 +3538,7 @@ srcs = [
"../third_party/region-flags/waved-svg/emoji_u1f1ec_1f1fc.svg",
"../third_party/region-flags/waved-svg/emoji_u1f1ec_1f1fe.svg",
"../third_party/region-flags/waved-svg/emoji_u1f1ed_1f1f0.svg",
"../third_party/region-flags/waved-svg/emoji_u1f1ed_1f1f2.svg",
"../third_party/region-flags/waved-svg/emoji_u1f1ed_1f1f3.svg",
"../third_party/region-flags/waved-svg/emoji_u1f1ed_1f1f7.svg",
"../third_party/region-flags/waved-svg/emoji_u1f1ed_1f1f9.svg",
@ -3579,6 +3584,7 @@ srcs = [
"../third_party/region-flags/waved-svg/emoji_u1f1f2_1f1e8.svg",
"../third_party/region-flags/waved-svg/emoji_u1f1f2_1f1e9.svg",
"../third_party/region-flags/waved-svg/emoji_u1f1f2_1f1ea.svg",
"../third_party/region-flags/waved-svg/emoji_u1f1f2_1f1eb.svg",
"../third_party/region-flags/waved-svg/emoji_u1f1f2_1f1ec.svg",
"../third_party/region-flags/waved-svg/emoji_u1f1f2_1f1ed.svg",
"../third_party/region-flags/waved-svg/emoji_u1f1f2_1f1f0.svg",
@ -3638,6 +3644,7 @@ srcs = [
"../third_party/region-flags/waved-svg/emoji_u1f1f8_1f1ec.svg",
"../third_party/region-flags/waved-svg/emoji_u1f1f8_1f1ed.svg",
"../third_party/region-flags/waved-svg/emoji_u1f1f8_1f1ee.svg",
"../third_party/region-flags/waved-svg/emoji_u1f1f8_1f1ef.svg",
"../third_party/region-flags/waved-svg/emoji_u1f1f8_1f1f0.svg",
"../third_party/region-flags/waved-svg/emoji_u1f1f8_1f1f1.svg",
"../third_party/region-flags/waved-svg/emoji_u1f1f8_1f1f2.svg",
@ -3669,6 +3676,7 @@ srcs = [
"../third_party/region-flags/waved-svg/emoji_u1f1f9_1f1ff.svg",
"../third_party/region-flags/waved-svg/emoji_u1f1fa_1f1e6.svg",
"../third_party/region-flags/waved-svg/emoji_u1f1fa_1f1ec.svg",
"../third_party/region-flags/waved-svg/emoji_u1f1fa_1f1f2.svg",
"../third_party/region-flags/waved-svg/emoji_u1f1fa_1f1f3.svg",
"../third_party/region-flags/waved-svg/emoji_u1f1fa_1f1f8.svg",
"../third_party/region-flags/waved-svg/emoji_u1f1fa_1f1fe.svg",
@ -3691,14 +3699,6 @@ srcs = [
"../third_party/region-flags/waved-svg/emoji_u1f3f4_e0067_e0062_e0065_e006e_e0067_e007f.svg",
"../third_party/region-flags/waved-svg/emoji_u1f3f4_e0067_e0062_e0073_e0063_e0074_e007f.svg",
"../third_party/region-flags/waved-svg/emoji_u1f3f4_e0067_e0062_e0077_e006c_e0073_e007f.svg",
"../third_party/region-flags/waved-svg/emoji_u1f1e7_1f1fb.svg",
"../third_party/region-flags/waved-svg/emoji_u1f1e8_1f1f5.svg",
"../third_party/region-flags/waved-svg/emoji_u1f1e9_1f1ec.svg",
"../third_party/region-flags/waved-svg/emoji_u1f1ea_1f1e6.svg",
"../third_party/region-flags/waved-svg/emoji_u1f1ed_1f1f2.svg",
"../third_party/region-flags/waved-svg/emoji_u1f1f2_1f1eb.svg",
"../third_party/region-flags/waved-svg/emoji_u1f1f8_1f1ef.svg",
"../third_party/region-flags/waved-svg/emoji_u1f1fa_1f1f2.svg",
]
[master.regular.position]

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,94 @@
# Copyright 2020 Google LLC
#
# 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.
# Generate config files for Noto-COLRv1
from nanoemoji.util import rel
from pathlib import Path
_NOTO_FAMILY_NAME = "Noto Color Emoji"
_NOTO_SVG_DIR = Path("svg")
_REGIONAL_INDICATORS = {
Path(_NOTO_SVG_DIR / f"emoji_u{i:x}.svg") for i in range(0x1F1E6, 0x1F1FF + 1)
}
_NOTO_WAVED_FLAG_SVG_DIR = Path("third_party/region-flags/waved-svg")
_NOTO_SUBDIVISION_FLAGS = (
_NOTO_WAVED_FLAG_SVG_DIR / "emoji_u1f3f4_e0067_e0062_e0065_e006e_e0067_e007f.svg",
_NOTO_WAVED_FLAG_SVG_DIR / "emoji_u1f3f4_e0067_e0062_e0073_e0063_e0074_e007f.svg",
_NOTO_WAVED_FLAG_SVG_DIR / "emoji_u1f3f4_e0067_e0062_e0077_e006c_e0073_e007f.svg",
)
_CONFIG_DIR = Path("colrv1")
def _write_config(config_name, output_file, svg_files):
svg_files = [rel(_CONFIG_DIR, Path(f)) for f in svg_files]
config_file = f"{config_name}.toml"
for svg_file in svg_files:
assert _CONFIG_DIR.joinpath(
svg_file
).is_file(), f"{svg_file} not found relative to {_CONFIG_DIR}"
svg_list = ",\n ".join(f'"{f}"' for f in sorted(svg_files)).rstrip()
with open(_CONFIG_DIR / config_file, "w") as f:
f.write(
f"""
family = "{_NOTO_FAMILY_NAME}"
output_file = "{output_file}"
color_format = "glyf_colr_1"
clipbox_quantization = 32
[axis.wght]
name = "Weight"
default = 400
[master.regular]
style_name = "Regular"
srcs = [
{svg_list},
]
[master.regular.position]
wght = 400
"""
)
def _write_all_noto_configs():
# includes all of noto-emoji svgs plus all the waved region flags
svgs = tuple(_NOTO_SVG_DIR.glob("*.svg")) + tuple(
_NOTO_WAVED_FLAG_SVG_DIR.glob("*.svg")
)
_write_config("all", "NotoColorEmoji.ttf", svgs)
def _write_noto_noflag_configs():
# Does not contain regional indicators and the region flags that are
# composed with them. It still includes the England, Scotland and Wales
# 'subdivision' flags, as those are not composed with Unicode regional
# indicators, but use sequences of Unicode Tag letters prefixed with
# the Black Flag and ending with a Cancel Tag.
svgs = (
tuple(p for p in _NOTO_SVG_DIR.glob("*.svg") if p not in _REGIONAL_INDICATORS)
+ _NOTO_SUBDIVISION_FLAGS
)
_write_config("noflags", "NotoColorEmoji-noflags.ttf", svgs)
def main():
_write_all_noto_configs()
_write_noto_noflag_configs()
if __name__ == "__main__":
main()