MCPcopy Create free account
hub / github.com/simstudioai/sim / loadGoogleFont

Function loadGoogleFont

apps/sim/app/(landing)/og-utils.tsx:21–42  ·  view source on GitHub ↗
(
  font: string,
  weights: string,
  text: string
)

Source from the content-addressed store, hash-verified

19}
20
21async function loadGoogleFont(
22 font: string,
23 weights: string,
24 text: string
25): Promise<ArrayBuffer | null> {
26 try {
27 const url = `https://fonts.googleapis.com/css2?family=${font}:wght@${weights}&text=${encodeURIComponent(text)}`
28 const css = await (await fetch(url)).text()
29 const resource = css.match(/src: url\(([^)]+)\) format\('(opentype|truetype|woff2?)'\)/)
30
31 if (resource) {
32 const response = await fetch(resource[1])
33 if (response.status === 200) {
34 return await response.arrayBuffer()
35 }
36 }
37 } catch {
38 return null
39 }
40
41 return null
42}
43
44interface LandingOgImageProps {
45 eyebrow: string

Callers 1

createLandingOgImageFunction · 0.70

Calls 1

textMethod · 0.80

Tested by

no test coverage detected