Google Sans font in review Docs

2,381 views
Skip to first unread message

Brett Grear

unread,
Apr 27, 2021, 10:21:48 AM4/27/21
to Google Apps Script Community
Has anyone noticed this before?

I have an add-on out for marketplace review and I received the usual Doc that has any comments that need to be addressed.  But I noticed that the font used on the doc is Google Sans.  As I understand it, this is the font used by Google for their branding and isn't accessible in Docs.

Is this just something Google is able to enable on their own domain or am I missing something?

Screenshot attached

Kind regards,
Screenshot 2021-04-27 15.15.41.png

Alan Wells

unread,
Apr 27, 2021, 10:42:05 AM4/27/21
to Google Apps Script Community
I just opened a Google Doc and I can't find Google Sans as an available font.

Brett Grear

unread,
Apr 27, 2021, 11:11:56 AM4/27/21
to Google Apps Script Community
Yeh, it's not available usually.  It was a Doc shared with me from one of the Marketplace reviewers that used it as the font.  I was able to copy and paste the text from that Doc into a new Doc of my own and now I'm able to use it as a font and it appears in the fonts list, but only for that Doc.

I tried setting the paragraph style to use it as the default but it wouldn't allow that, it came up with an error message.

Tanaike

unread,
Apr 27, 2021, 9:39:54 PM4/27/21
to Google Apps Script Community
Can you provide the sample Google Document including the sample text using the font you want to use?

Brett Grear

unread,
Apr 28, 2021, 2:10:10 AM4/28/21
to Google Apps Script Community

Kim Nilsson

unread,
Apr 28, 2021, 2:13:41 AM4/28/21
to Google Apps Script Community
Google has done this a few times.
The company Netflix also has their own font.
It's very uncommon, and the only way to be able to use it is to copy from a document that has the font.

Brett Grear

unread,
Apr 28, 2021, 2:59:00 AM4/28/21
to Google Apps Script Community
Yeh, this is what I thought. I knew about the Google Sans font but didn't know it was compatible with Docs.  I guess, maybe, Google has an in-house add-on that allows it to be used or something?  It is interesting that it can be copied and pasted across to a new Doc that contains the font and Google Docs picks up the name but if you try to set it as a default style it fails. 

Tanaike

unread,
Apr 28, 2021, 5:08:50 AM4/28/21
to Google Apps Script Community
Thank you for adding more information. From your provided Google Document, I could know the font name. By this, I tested to change the font family to Google Sans for new created Google Document using Google Apps Script, I confirmed that the font can be changed to Google Sans. It seems that when the font name is directly set to the method of "setFontFamily", Google Sans can be used.

For this, I prepared the sample script to my blog by adding the demonstration video. Could you please confirm it? If that was not the direction you expect, I apologize.

Brett Grear

unread,
Apr 28, 2021, 6:46:11 AM4/28/21
to Google Apps Script Community
Yes, I can confirm this works.
I might create a quick internal add-on to make this easier to do.

Shreyan EMR

unread,
May 13, 2022, 2:20:25 PM5/13/22
to Google Apps Script Community
OMG this is the best thing I've ever seen! Thanks a lot!

Samuel Alake

unread,
Sep 19, 2022, 4:56:22 AM9/19/22
to Google Apps Script Community
Hi Tanaike, please is it possible to upload a custom font to Google Doc using this logic and font uploaded to Google drive (https://stackoverflow.com/questions/72590081/adding-customize-font-to-google-script-app)?

Kim Nilsson

unread,
Sep 19, 2022, 5:01:18 AM9/19/22
to google-apps-sc...@googlegroups.com
No, Samuel.

It is not possible to upload custom fonts to Google Docs.
There are thousands to choose from, but you can't add your own.

You can petition Google to add fonts, but there are very few that have managed to do so.

The Australian government has had a few fonts added, as they are used to teach children how to read according to the Australian curriculum.

Kim

Andrew Cao

unread,
Dec 9, 2022, 8:32:50 PM12/9/22
to Google Apps Script Community
Did you end up writing the add-on? Would love to use it.

Brett Grear

unread,
Dec 9, 2022, 8:40:42 PM12/9/22
to google-apps-sc...@googlegroups.com
I only ever published it for internal usage. Not sure If it would pass verification from Google's end.

--
You received this message because you are subscribed to a topic in the Google Groups "Google Apps Script Community" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-apps-script-community/ehC7C95W5t0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/122ebf07-7fda-43d6-b84e-6b24791a0a3an%40googlegroups.com.

Andrew Cao

unread,
Dec 9, 2022, 8:56:14 PM12/9/22
to Google Apps Script Community
You could send me the source code, and I can build the add-on myself, if you're okay with that.

Brett Grear

unread,
Dec 10, 2022, 4:36:53 AM12/10/22
to Google Apps Script Community
Again, this was super basic and I was a lot less experienced with add-ons than I am now so it's not the most user friendly.  I seem to have made it to work with Docs, Sheets and Slides but I've only ever used it with Docs so I can't even remember if it worked with the others or not.


function onInstall(e) {
onOpen();
}

function onOpen(e) {
try {
var ui = DocumentApp.getUi();
var menu = ui.createAddonMenu();
menu.addItem('Google Sans','setFontDocs');
menu.addToUi();
} catch(e) {
try {
var ui = SlidesApp.getUi();
var menu = ui.createAddonMenu();
menu.addItem('Google Sans','setFontSlides');
menu.addToUi();
} catch(e) {
var ui = SpreadsheetApp.getUi();
var menu = ui.createAddonMenu();
menu.addItem('Google Sans','setFontSheets');
menu.addToUi();
}
}
}


function setFontDocs() {
try {
const selection = DocumentApp.getActiveDocument().getSelection();
const element = selection.getRangeElements()[0];
element
.getElement()
.asText()
.setFontFamily(
element.getStartOffset(),
element.getEndOffsetInclusive(),
"Google Sans"
);
} catch(e) {
console.log(e);
}
}

function setFontSlides() {
try {
const selection = SlidesApp.getActivePresentation().getSelection();
selection.getTextRange().getTextStyle().setFontFamily('Google Sans');
} catch(e) {
console.log(e);
}
}

function setFontSheets() {
try {
var cell = SpreadsheetApp.getActive().getSelection().getActiveRange().setFontFamily('Google Sans');
} catch(e) {
console.log(e);
}
}

Reply all
Reply to author
Forward
0 new messages