Skip to content

Commit

Permalink
Export font-faces only with matching unicode
Browse files Browse the repository at this point in the history
  • Loading branch information
edemaine committed Dec 14, 2023
1 parent b1759b1 commit 53d3449
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions client/tools/download.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ export makeSVGSync = ->
font = rule.cssText
continue unless useMono or not /Roboto Mono/.test font
continue unless useBold or not /font-weight:\s*900/.test font
if (match = font.match /unicode-range:([^;}]*)/)?
regexp = match[1]
.replace /(u\+|-)([0-9a-f]{1,4})/ig, (m, prefix, hex) =>
prefix = '' unless prefix == '-'
"#{prefix}\\u#{hex.padStart 4, '0'}"
.replace /[,\s]/g, ''
regexp = "[#{regexp}]"
continue unless (new RegExp regexp).test svg
fonts.push font
fonts.push ''
"""
Expand Down

0 comments on commit 53d3449

Please sign in to comment.