I'm developing a web app that requires a certain type of font used by my company. Since I'm using Google Apps Script, I uploaded the font files to a google drive folder. But it's not working. In the script, the https://drive.google.com/file/d/XXX
is the shareable link. I tried to use https://drive.google.com/uc?export=view&id=
but it didn't work too.
I'll be very grateful if anyone can help. Thanks!
@font-face {
font-family: 'specials';
src: url('https://drive.google.com/file/d/XXX/specials.eot');
src: url('https://drive.google.com/file/d/XXX/specials.eot') format("embedded-opentype"),
url("https://drive.google.com/file/d/XXX/specials.otf") format("opentype"),
url('https://drive.google.com/file/d/XXX/specials.woff') format("woff"),
url('https://drive.google.com/file/d/XXX/specials.woff2') format("woff2"),
url('https://drive.google.com/file/d/XXX/specials.ttf') format("truetype"),
url('https://drive.google.com/file/d/XXX/specials.svg') format("svg");
font-weight: normal;
font-style: normal;
}
h1{
font-family: 'specials', Georgia,'Times New Roman', Times, serif;
}
Update
It is as @Tanaike suggested, the right way to do it is to use this link https://www.googleapis.com/drive/v3/files/###fileId###?alt=media&key=###your API key###
for all the different formats of the font files. It appeared to not be working at first because I missed out two.
Here's the corrected CSS:
@font-face {
font-family: 'specials';
src: url('https://www.googleapis.com/drive/v3/files/###fileId###?alt=media&key=###your API key###');
src: url('https://www.googleapis.com/drive/v3/files/###fileId###?alt=media&key=###your API key###') format("embedded-opentype"),
url("https://www.googleapis.com/drive/v3/files/###fileId###?alt=media&key=###your API key###") format("opentype"),
url('https://www.googleapis.com/drive/v3/files/###fileId###?alt=media&key=###your API key###') format("woff"),
url('https://www.googleapis.com/drive/v3/files/###fileId###?alt=media&key=###your API key###') format("woff2"),
url('https://www.googleapis.com/drive/v3/files/###fileId###?alt=media&key=###your API key###') format("truetype"),
url('https://www.googleapis.com/drive/v3/files/###fileId###?alt=media&key=###your API key###') format("svg");
font-weight: normal;
font-style: normal;
}
CodePudding user response:
I thought that in your script, it is required to modify the URL. So, how about the following URL?
From:
https://drive.google.com/file/d/XXX/###
- From your this URL, I guessed that
XXX
might be the file ID of the file.
To:
https://drive.google.com/uc?export=download&id=###fileId###
or, if the above URL cannot be used, please use the following URL.
https://www.googleapis.com/drive/v3/files/###fileId###?alt=media&key=###your API key###
In this case, please use your API key. Ref
Please replace
###fileId###
with your file ID.Please replace
###your API key###
with your API key.
Note:
- In this modification, it supposes that your files on Google Drive have already been publicly shared. Please be careful about this.