Skip to content

Commit

Permalink
Update for nanoemoji 0.4.1 and picosvg 0.7.2
Browse files Browse the repository at this point in the history
- Itʼs suggested in googlefonts/nanoemoji#157 that we donʼt apply scaling by transforming the root `svg` element, but rather by enclosing the body of the SVG in an element that applies the transform.
- Recent nanoemoji versions are configured with a file rather than on the command line.
  • Loading branch information
mavit authored and JeppeKlitgaard committed Nov 16, 2022
1 parent df26cb6 commit 30cc065
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 17 deletions.
Binary file modified font/glyf/OpenMoji-Black.ttf
Binary file not shown.
Binary file modified font/glyf_colr_0/OpenMoji-Color.ttf
Binary file not shown.
Binary file modified font/picosvgz/OpenMoji-Color.ttf
Binary file not shown.
Binary file modified font/untouchedsvgz/OpenMoji-Color.ttf
Binary file not shown.
42 changes: 25 additions & 17 deletions helpers/generate-ttf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,31 @@ name=OpenMoji-${saturation^}

mkdir -p "$build_dir"
rsync -ru "/mnt/$saturation/svg/" "$build_dir/scale/"
grep -FL 'transform="scale(1.3)"' "$build_dir"/scale/*.svg \
| xargs --no-run-if-empty \
xmlstarlet edit \
--inplace \
--omit-decl \
-N svg=http://www.w3.org/2000/svg \
--delete '/svg:svg/@transform' \
--insert '/svg:svg' \
--type attr \
--name transform \
--value 'translate(36 0) scale(1.3) translate(-36 0)'

nanoemoji \
--color_format="$format" \
--build_dir="$build_dir" \
--output_file="$build_dir/$name.$format.ttf" \
"$build_dir"/scale/*.svg
grep -FL '<g transform="translate(36 0) scale(1.3) translate(-36 0)">' \
"$build_dir"/scale/*.svg \
| xargs --no-run-if-empty \
sed -E -i \
-e 's/(<svg .*>)/\1\n<g transform="translate(36 0) scale(1.3) translate(-36 0)">/;' \
-e 's/(<\/svg>)/<\/g>\n\1/;'

cat >"$build_dir/$name.toml" <<-EOF
output_file = "$build_dir/$name.$format.ttf"
color_format = "$format"
[axis.wght]
name = "Weight"
default = 400
[master.regular]
style_name = "Regular"
srcs = ["$build_dir/scale/*.svg"]
[master.regular.position]
wght = 400
EOF

nanoemoji --build_dir="$build_dir" \
--config="$build_dir/$name.toml"

sed "s/Color/${saturation^}/;" \
/mnt/font/OpenMoji-Color.ttx \
Expand Down

0 comments on commit 30cc065

Please sign in to comment.