Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

font-format | font-tech etc #189

Open
Thorin-Oakenpants opened this issue Aug 26, 2022 · 3 comments
Open

font-format | font-tech etc #189

Thorin-Oakenpants opened this issue Aug 26, 2022 · 3 comments
Labels

Comments

@Thorin-Oakenpants
Copy link
Contributor

Thorin-Oakenpants commented Aug 26, 2022

font types: e.g. woff, woff2, svg opentype, graphite, COLRv1, etc

accumulated links


CSS

/* if font-tech is not supported, we end up with "not font-tech" */
/* so we only have two choices: n/a or supported */
#cssCOLRv0:after{content:"n/a";}
@supports font-tech(color-COLRv0){#cssCOLRv0:after{content:"supported";}}
/*@supports not font-tech(color-COLRv0){#cssCOLRv0:after{content:"not supported";}} */

#cssCOLRv1:after{content:"n/a";}
@supports font-tech(color-COLRv1){#cssCOLRv1:after{content:"supported";}}

#cssOpenType:after{content:"n/a";}
@supports font-tech(feature-opentype){#cssOpenType:after{content:"supported";}}

/* if font-format is not supported, it doesn't fire "not font-format" */
/* so we only have two choices: n/a or supported: i.e we can't return not supported by default */
#cssWoff2:after{content:"n/a";}
@supports font-format(woff2){#cssWoff2:after{content:"supported";}}

CSS.supports

edit: 71c5470

FONT FACE

see example for woff2: lightening fast -

TZP/js/fonts.js

Line 968 in 98431ac

const font = new FontFace('t', 'url("data:font/woff2;base64,d09GMgABAAAAAADwAAoAAAAAAiQAAACoAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAABmAALAogOAE2AiQDBgsGAAQgBSAHIBuDAciO1EZ3I/mL5/+5/rfPnTt9/9Qa8H4cUUZxaRbh36LiKJoVh61XGzw6ufkpoeZBW4KphwFYIJGHB4LAY4hby++gW+6N1EN94I49v86yCpUdYgqeZrOWN34CMQg2tAmthdli0eePIwAKNIIRS4AGZFzdX9lbBUAQlm//f262/61o8PlYO/D1/X4FrWFFgdCQD9DpGJSxmFyjOAGUU4P0qigcNb82GAAA") format("woff2")', {});

graphite causes errors

function get_graphite() {
	// current: uncaught errors
	// downloadable font: post: Failed to read table header...
	// downloadable font: post: Failed to parse table...
	// downloadable font: rejected by sanitizer...
	// downloadable font: font load failed...
	// Uncaught (in promise) DOMException: A network error occurred
	return new Promise(resolve => {
		try {
			if (!("FontFace" in window)) {
				return resolve("blocked")
			}
			const supportsGraphite = (function(){
				// graphite
				const font = new FontFace('g', 'url(data:font/truetype;base64,AAEAAAAKAIAAAwAgT1MvMgAAAAAAAAEoAAAAVmNtYXAAAAAAAAABiAAAACxnbHlmAAAAAAAAAbwAAAAkaGVhZAAAAAAAAACsAAAAOGhoZWEAAAAAAAAA5AAAACRobXR4AAAAAAAAAYAAAAAGbG9jYQAAAAAAAAG0AAAABm1heHAAAAAAAAABCAAAACBuYW1lAAAAAAAAAeAAAAAgcG9zdAAAAAAAAAIAAAAAEAABAAAAAQAAAkgTY18PPPUACwAgAAAAALSRooAAAAAAyld0xgAAAAAAAQABAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEAAAACAAIAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACMAIwAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAMAAQAAAAwABAAgAAAABAAEAAEAAABB//8AAABB////wAABAAAAAAAAAAgAEgAAAAEAAAAAAAAAAAAAAAAxAAABAAAAAAABAAEAAQAAMTcBAQAAAAAAAgAeAAMAAQQJAAEAAAAAAAMAAQQJAAIAAgAAAAAAAQAAAAAAAAAAAAAAAAAA) format("truetype")', {});

				font.load()
				return font.status == "loaded" || font.status == "loading"
			})()
			let value = (supportsGraphite ? "enabled" : "blocked: check your console")
			return resolve(value)
		} catch(e) {
			return resolve("error")
		}
	})
}
get_graphite()
@Thorin-Oakenpants
Copy link
Contributor Author

Thorin-Oakenpants commented Aug 27, 2022

71c5470 for starters

edit: bit miffed SVG didn't mean SVG opentype

I might have to revisit this, not sure if I got it all correctly

@Thorin-Oakenpants
Copy link
Contributor Author

https://bugzilla.mozilla.org/show_bug.cgi?id=1788036 Pluralize feature-* to features-* in font-tech keywords

@Thorin-Oakenpants
Copy link
Contributor Author

https://bugzilla.mozilla.org/show_bug.cgi?id=1786804 - layout.css.font-tech.enabled FF105+

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

1 participant