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

How to get url from @font-face directives? #1

Open
zoeleu opened this issue Nov 16, 2021 · 2 comments
Open

How to get url from @font-face directives? #1

zoeleu opened this issue Nov 16, 2021 · 2 comments

Comments

@zoeleu
Copy link

zoeleu commented Nov 16, 2021

No description provided.

@zoeleu
Copy link
Author

zoeleu commented Nov 16, 2021

I'm trying to parse a google font, and I need to get all the @font-face directives, and the url() inside of the src.

Example: https://fonts.googleapis.com/css2?family=Product+Sans

@zoeleu zoeleu changed the title How to get @font-face directives? How to get url from @font-face directives? Nov 16, 2021
@sebbekarlsson
Copy link
Owner

I'm trying to parse a google font, and I need to get all the @font-face directives, and the url() inside of the src.

Example: https://fonts.googleapis.com/css2?family=Product+Sans

Sorry for the late reply here, there's no public functionality to do this yet,
however, this data exists within CSSAST->args (it's a List).

So you would do something like:

CSSAST* rule = css_get_rule(parsed, "some-selector");
CSSAST* url_node = (CSSAST*) rule->args->items[0]; // make sure this list isn't empty first.

char* url = url_node->value_str;


printf("%s\n", url);

I will add a public function for doing this though.

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

No branches or pull requests

2 participants