var FONTFACE_PATTERN = /(?:^|)(?:(?<=(?:font-family[:] ?))['"](.+?)['"]|(?<=(?:font-weight[:])) ?(.+?)|(?<=(?:font-style[:])) ?(.+?)|(?<=src: ?url[(])(?:['"]?data:(.+?)[;,](base64)[,])(.+?)(?:['"]?[)])(?:[\n\s ]?format[(]['"](\S+)['"][)])?)(?:[;][\n])(?:|$)/mdg
Rudimentary pattern for matching base64-embedded webfonts in CSS stylesheets, including:
font-family
font-style
font-weight
Also matches the various parts of the datauri
sequence:
mime-type
charset
format(...)
Includes the multi-line and global modifier flags to match multiple @font-face
rules in a single document.
MIT © Nicholas Berlette