Skip to content

feat: Include individual text values for each font#149

Open
jakubkoje wants to merge 4 commits into
nuxt-modules:mainfrom
jakubkoje:feature/text
Open

feat: Include individual text values for each font#149
jakubkoje wants to merge 4 commits into
nuxt-modules:mainfrom
jakubkoje:feature/text

Conversation

@jakubkoje

Copy link
Copy Markdown

Current Situation:
Currently, as reported in #106, it is not possible to include only the requested text for each individual font. The current implementation fetches the entire font data in one call, and there is no way to specify separate text values for each font using the Google API.

Proposed Solution:
To enable this feature, we need to modify the font fetching process and split it into separate calls. By doing so, we can include only the requested text for each font. This adjustment will ensure that the Google API can handle separate text values for individual fonts.

I would love to someone who is more experienced with Nuxt modules to check if the downloading still works as expected.

@jakubkoje

jakubkoje commented Aug 5, 2023

Copy link
Copy Markdown
Author

I just realized that this could also be implemented in google-fonts-helper. Not sure which way would be better.

@ricardogobbosouza ricardogobbosouza left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @jakubkoje
Thanks for the PR, I made some observations
You also need to add tests 😄

Comment thread src/module.ts
}
})

logger.start('Downloading fonts...')

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add outside for

Comment thread src/module.ts

logger.start('Downloading fonts...')
await downloader.execute()
logger.success('Download fonts completed.')

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add outside for

Comment thread src/module.ts
Comment on lines +221 to +227
// Disable sanitazions
// @ts-ignore
head.__dangerouslyDisableSanitizersByTagID = head.__dangerouslyDisableSanitizersByTagID || {}
// @ts-ignore
head.__dangerouslyDisableSanitizersByTagID['gf-script'] = ['innerHTML']
// @ts-ignore
head.__dangerouslyDisableSanitizersByTagID['gf-noscript'] = ['innerHTML']

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add outside for

Comment thread src/module.ts
for (const url of urls) {
head.script.push({
key: 'gf-script',
innerHTML: `(function(){var l=document.createElement('link');l.rel="stylesheet";l.href="${url}";document.querySelector("head").appendChild(l);})();`

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe create a script to create the stylesheet.
In case of several url this script will be duplicated.

Comment thread src/module.ts
Comment on lines +236 to +242
children: `(function(){
var h=document.querySelector("head");
var m=h.querySelector('meta[name="head:count"]');
if(m){m.setAttribute('content',Number(m.getAttribute('content'))+1);}
else{m=document.createElement('meta');m.setAttribute('name','head:count');m.setAttribute('content','1');h.append(m);}
var l=document.createElement('link');l.rel='stylesheet';l.href='${url}';h.appendChild(l);
})();`

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe create a script to create the stylesheet.
In case of several url this script will be duplicated.

@sergefy13

Copy link
Copy Markdown

so is it possible rn?

@jakubkoje

Copy link
Copy Markdown
Author

so is it possible rn?

Not yet. I don't have much time right now to continue with this pull request, help would be appreciated.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants