Skip to content

Commit

Permalink
fix firefox bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Soare-Robert-Daniel committed Mar 23, 2021
1 parent da27591 commit f9857b1
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion plugin_build/logo-maker.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'react-dom'), 'version' => '3e63f244d75252778e7269ca7092b12d');
<?php return array('dependencies' => array('react', 'react-dom'), 'version' => '42468e3f7249b847b516c0bcb82753e5');
2 changes: 1 addition & 1 deletion plugin_build/logo-maker.js

Large diffs are not rendered by default.

15 changes: 10 additions & 5 deletions src/Application.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,18 @@ export const Application: React.FunctionComponent<unknown> = () => {
const fontSet = new Set<string>()

document.fonts.forEach((f) => {
if (isFontFromGoogle(f.family)) {
fontSet.add(f.family)
const fileURL = buildFontSourceFileURL(f.family)
const cleanedFontFamily = f.family.replace(/"/g, '')
// console.log(cleanedFontFamily)
if (isFontFromGoogle(cleanedFontFamily)) {
fontSet.add(cleanedFontFamily)
const fileURL = buildFontSourceFileURL(cleanedFontFamily)
if (fileURL) {
fetch(fileURL, {
method: "HEAD",
mode: "cors",
}).then((resp) => {
if (resp.ok) {
return f.family
return cleanedFontFamily
}
return null
})
Expand All @@ -56,9 +58,12 @@ export const Application: React.FunctionComponent<unknown> = () => {
}
})

// console.log(fontPaths)

const fontRequets = fontPaths
.filter((fontPath) => fontPath.path)
.map(async (font) => {
// console.log(font.path)
const renderer = await opentype.load(font.path || "")
return {
font: font.font,
Expand All @@ -67,7 +72,7 @@ export const Application: React.FunctionComponent<unknown> = () => {
})

Promise.all(fontRequets).then((fontRenderers) => {
console.log(fontRenderers)
// console.log(fontRenderers)
// transformTextToSVG(fontRenderers[0].renderer, 'Hey', 52)
AssetsStore.update((s) => {
s.fonts.fontRenderers = fontRenderers.reduce(
Expand Down
1 change: 0 additions & 1 deletion src/assets/fonts/google-fonts.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import fonts from './fonts.json'
console.log(fonts)
// const fonts = [
// "Helvetica",
// "Open Sans",
Expand Down

0 comments on commit f9857b1

Please sign in to comment.