Created
October 16, 2023 10:44
-
-
Save digiguru/79eaac3720494188d183debcaadf9283 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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