Skip to content

Python script to scan an office file (pptx, docx, xlsx) and check if all the fonts are available on the local computer, if not you have the option to replace said fonts. Can be distributed as a standalone executable for Windows computers.

Notifications You must be signed in to change notification settings

gwizit/Office-File-Font-Scanner

Repository files navigation

Office File Font Scanner

A tool that scans Microsoft Office files (Word, PowerPoint, Excel) to detect which fonts are used and checks if they are available on your local system. Available as both a command-line tool and a graphical application.

⚠️ Important: Best Practice for Font Compatibility

Before using this tool, the ideal solution is to have the document creator embed custom fonts directly into the Office file. This ensures the document displays correctly on any computer without requiring font installation.

How to Embed Fonts (For Document Creators):

  1. In Microsoft Office (Word, PowerPoint, Excel), go to File → Options → Save
  2. Check "Embed fonts in the file"
  3. Choose embedding options:
    • Embed only characters used (smaller file size)
    • Embed all characters (allows editing with the font)

Benefits of embedding fonts:

Use this scanner when:

  • The original computer where the file was created is not available
  • The original author cannot be contacted to re-save with embedded fonts
  • You receive a file without embedded fonts
  • You need to identify which fonts are missing
  • You want to replace missing fonts with available alternatives

Features

  • ✅ Scans modern Office formats: .docx, .pptx, .xlsx
  • ✅ Scans legacy Office formats: .doc, .ppt, .xls
  • ✅ Checks system fonts for availability
  • Intelligent font matching - automatically detects font families regardless of style (Bold, Italic, etc.)
  • Replace missing fonts with available alternatives
  • Refresh system fonts - detect newly installed fonts without restarting
  • Graphical User Interface (GUI) for easy use
  • Standalone executable - no Python installation required
  • ✅ Cross-platform support (Windows, macOS, Linux)
  • ✅ Automatic file backup before font replacement

Quick Start (Windows Executable)

For users without Python:

  1. Download OfficeFontScanner.exe from the releases
  2. Double-click to launch the GUI application
  3. Click "Browse..." to select your Office file
  4. Click "Scan Fonts" to analyze the document
  5. Replace missing fonts if needed

No Python installation required!

Installation (For Developers)

1. Install Python

Make sure you have Python 3.6 or higher installed on your system.

2. Install Requirements

Open PowerShell or Command Prompt in this folder and run:

pip install -r requirements.txt

This will install the olefile library needed for legacy Office file support.

Usage

GUI Version (Recommended)

Launch the graphical interface:

python font_scanner_gui.py

Features:

  • Browse and select files visually
  • View scan results in a formatted window
  • Replace missing fonts with a dropdown selector
  • Refresh system fonts button - detect newly installed fonts instantly
  • Automatic font refresh - updates font list before replacement
  • Real-time font count display
  • Automatic backup creation

Command-Line Version

python font_scanner.py <path_to_office_file>

Examples

Scan a PowerPoint presentation:

python font_scanner.py C:\Documents\presentation.pptx

Scan a Word document:

python font_scanner.py "C:\My Documents\report.docx"

Scan an Excel spreadsheet:

python font_scanner.py data.xlsx

Scan a legacy PowerPoint file:

python font_scanner.py old_presentation.ppt

Output

The script will display:

  • Total number of fonts found in the file
  • List of fonts that are available on your system (marked with ✓)
  • List of fonts that are missing from your system (marked with ✗)
  • Option to replace missing fonts with available alternatives

Example Output

Scanning: presentation.pptx
======================================================================

Checking system fonts...

Total fonts found: 4
Available on system: 3
Missing from system: 1

✓ AVAILABLE FONTS:
  • Arial
  • Calibri
  • Times New Roman

✗ MISSING FONTS:
  • CustomFont Pro

======================================================================
Would you like to replace missing fonts? (y/n): y

For each missing font, enter a replacement (or press Enter to skip):

Replace 'CustomFont Pro' with: Arial

======================================================================
Font Replacement Summary:
  CustomFont Pro → Arial

Proceed with replacement? (y/n): y

Backup created: presentation.pptx.backup
✓ Font replacement complete! Modified 3 file(s) within the document.
  Original backed up as: presentation.pptx.backup

Supported File Types

Modern Formats (Office 2007+)

  • .docx - Microsoft Word
  • .pptx - Microsoft PowerPoint
  • .xlsx - Microsoft Excel

Legacy Formats (Office 97-2003)

  • .doc - Microsoft Word (requires olefile)
  • .ppt - Microsoft PowerPoint (requires olefile)
  • .xls - Microsoft Excel (requires olefile)

Troubleshooting

"olefile library is required"

If you see this error when scanning legacy files, install the requirements:

pip install -r requirements.txt

"File not found"

Make sure to provide the full path to the file or run the script from the same directory as your Office file.

Newly installed fonts not showing up

After installing new fonts on your system:

  1. Click the "Refresh System Fonts" button in the GUI
  2. Or simply click "Replace Missing Fonts" - it automatically refreshes
  3. The newly installed fonts should now appear in the dropdown

Note: The app reads fonts from the Windows registry. If fonts still don't appear:

  • Make sure fonts are installed "for all users" (not just current user)
  • Try restarting the application
  • Verify fonts are properly installed in Windows Settings → Fonts

Font still showing as missing after installation

If you installed a font like "Montserrat Bold" but the document requires "Montserrat":

  • This is now automatically handled - the app detects font families regardless of style variants
  • Click "Refresh System Fonts" to reload the font list
  • Any style of a font family (Regular, Bold, Italic, etc.) will match the family name

No fonts detected

This can happen if:

  • The file uses only default/embedded fonts
  • The file is corrupted
  • The file format is not supported

Platform Support

  • Windows: Reads fonts from Windows Registry
  • macOS: Reads fonts from system font directories
  • Linux: Reads fonts from common font directories

Building the Standalone Executable

To create a standalone Windows executable that users can run without Python installed:

Prerequisites

  1. Install all requirements:
pip install -r requirements.txt

This installs:

  • olefile - for legacy Office file support
  • pyinstaller - for building executables

Build Steps

Option 1: Using the spec file (Recommended)

pyinstaller font_scanner_gui.spec

Option 2: Direct command

pyinstaller --onefile --windowed --name OfficeFontScanner --hidden-import olefile font_scanner_gui.py

Output

  • The executable will be created in the dist folder
  • File: dist/OfficeFontScanner.exe
  • Size: Approximately 15-20MB (includes Python runtime and all dependencies)

Distribution

Simply distribute the OfficeFontScanner.exe file from the dist folder. Users can:

  • Run it directly without installing Python
  • Copy it to any location on their computer
  • Create a desktop shortcut for easy access

Adding a Custom Icon (Optional)

  1. Get or create a .ico file (256x256 or 128x128 recommended)
  2. Save it as icon.ico in the project folder
  3. Edit font_scanner_gui.spec and change:
    icon=None,
    to:
    icon='icon.ico',
  4. Rebuild: pyinstaller font_scanner_gui.spec

Notes

  • First launch may be slower (Windows security scanning)
  • Antivirus software may flag PyInstaller executables initially (this is normal)
  • For production distribution, consider code signing the executable
  • See BUILD.md for more detailed instructions

Requirements

  • Python 3.6+
  • tkinter (included with Python)
  • olefile 0.46+ (for legacy Office file support)
  • pyinstaller 5.0+ (for building executables)

License

Free to use and modify.

About

Python script to scan an office file (pptx, docx, xlsx) and check if all the fonts are available on the local computer, if not you have the option to replace said fonts. Can be distributed as a standalone executable for Windows computers.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published