Skip to content

Instantly share code, notes, and snippets.

@digiguru
Created October 16, 2023 10:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save digiguru/79eaac3720494188d183debcaadf9283 to your computer and use it in GitHub Desktop.
Save digiguru/79eaac3720494188d183debcaadf9283 to your computer and use it in GitHub Desktop.
const desiredFonts = ["Quattrocento Sans","Proxima Nova"];
function checkFontUsage() {
// Access the active presentation
var presentation = SlidesApp.getActivePresentation();
var slides = presentation.getSlides();
// Define the desired font
// Iterate through all slides
for (var i = 0; i < slides.length; i++) {
var shapes = slides[i].getShapes();
// Iterate through all shapes on the slide
for (var j = 0; j < shapes.length; j++) {
try {
// Check if the shape contains text
let shape = shapes[j];
let shapeText = shape.toString();
let slide = (i + 1);
let type = shape.getPageElementType().toString();
let textRange = shape.getText();
let text = textRange.asString();
let hasNoText = /^\s+$/.test(text);
if (textRange && !hasNoText) {
var textStyle = textRange.getTextStyle();
var actualFont = textStyle.getFontFamily();
// Check the font of the text
if (actualFont && !(desiredFonts.includes(actualFont))) {
Logger.log('Slide ' + (i + 1) + ': uses :' + actualFont + ' for text "' + textRange.asString() + + '",' + type);
}
}
} catch (ex) {
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment