PDF Font Subsetting Principle: Why It Reduces 90% of File Size

Bottom line: PDF font subsetting can reduce file size by 90%, fundamentally because Chinese fonts are typically 15-20MB, yet documents only use one to two thousand characters. The core principle of subsetting involves three steps — scanning the document for actually used character sets, reconstructing the CMap mapping table, and remapping glyph indices to discard unused glyphs. Source Han Serif's complete file is 18MB, but after subsetting it is only 0.4MB — a 97.7% reduction. Below, we start from the font file structure, detail the technical principles of subsetting, and include benchmark comparison data for three fonts.

If you're not yet familiar with overall PDF compression methods, we recommend reading PDF Compression Principles and Methods Explained first.

1. Font File Structure: Why Are Embedded Chinese Fonts So Large

To understand why subsetting is effective, we first need to understand what's inside a font file. TrueType (.ttf) and OpenType (.otf) font files consist of multiple data tables, each responsible for different functions. When embedded in PDF, these tables are packaged in their entirety, regardless of how many characters the document uses.

Data TableFunctionTypical ProportionCan Be Trimmed by Subsetting
cmapCharacter code to glyph index mapping1%–3%Needs reconstruction
glyfTrueType glyph outline data70%–85%Can be significantly trimmed
CFFOpenType CFF glyph outlines (PostScript)60%–80%Can be significantly trimmed
locaGlyph data position index1%–2%Needs reconstruction
hmtxHorizontal metrics (character width/advance)2%–5%Needs reconstruction
nameFont name, copyright, and other metadata0.5%–1%Preserved
postPostScript name mapping1%–3%Partially trimmed

As the table above shows, glyph outline data (glyf or CFF tables) accounts for 60%–85% of the font file size. A Chinese font contains 20,000 to 70,000 glyphs, with each character's vector outline data averaging 300–600 bytes, totaling 10–20MB. However, a 50-page PDF document typically uses only 800–2000 distinct characters, meaning over 95% of the glyph data is wasted — this is exactly where subsetting provides compression gains.

2. Subsetting Principle: Three Steps to Trim Unused Glyphs

The core idea of font subsetting is: keep only the glyphs the document actually uses, and discard the rest. The implementation involves three key steps, each involving precise operations on the font table structure.

StepOperationPrincipleTables Processed
1. Character Usage ScanTraverse all page content streams in the PDF, extract displayed character codesCollect Unicode code points by parsing text operators (Tj/TJ)None (generates character set)
2. CMap Table ReconstructionRebuild character code to glyph index mapping based on used charactersKeep only mapping entries for used characters, delete the restcmap
3. Glyph Index RemappingContinuously rearrange used glyphs, update all reference indicesOriginal indices may be non-contiguous; after rearrangement, indices 0 to N are contiguousglyf/CFF, loca, hmtx

1. Character Usage Scan

The first step is to scan the PDF document to find all actually displayed characters. Text in PDF is written to content streams via text operators (Tj for strings, TJ for arrays), with each character corresponding to a code. The subsetting tool traverses all page content streams, extracts these codes, converts them to Unicode code points via the font's current CMap table, and ultimately obtains a "used character set."

Scanning also needs to handle special cases: ToUnicode CMap (reverse mapping), multi-byte encoding (common in CJK fonts), and embedded font subsetting prefixes (six-character + number format). A 50-page Chinese PDF typically scans 800–2000 distinct Unicode characters; with punctuation and digits, approximately 1000–2500 glyphs need to be retained.

2. CMap Table Reconstruction

The CMap table is the font's "directory," recording the glyph index (GID) for each character code. An original Chinese font's CMap table contains 20,000 to 70,000 mapping entries; after subsetting, only entries for used characters are retained. Reconstruction also needs to handle multiple encoding subtable formats.

CMap Subtable FormatEncoding RangePurposeSubsetting Processing
Format 00–255Single-byte ASCII/LatinTrim unused entries
Format 4BMP Basic Multilingual PlaneCommon CJK charactersRebuild segment table
Format 12Full UnicodeCovers all charactersTrim unused segments

3. Glyph Index Remapping

This is the most critical and complex step. In the original font, glyph indices (GIDs) are arranged consecutively from 0 to N, but the glyphs that need to be retained may be scattered throughout. Remapping rearranges the retained glyphs in a new consecutive order: original GID 0 (.notdef) stays unchanged, original GID 1523 might become new GID 1, original GID 8944 becomes new GID 2, and so on.

After remapping, all tables referencing GIDs need to be updated synchronously: the glyf table (or CFF table) keeps only the corresponding glyph data arranged by new indices, the loca table rebuilds position indices, the hmtx table rebuilds horizontal metrics data, and the post table updates PostScript name mappings. Mishandling this step can corrupt the font, so strict adherence to the OpenType specification is required.

3. Benchmark Data: Three Fonts Before and After Subsetting

We selected three commonly used fonts for subsetting benchmarks, representing Chinese fonts (Source Han Serif, Microsoft YaHei) and English fonts (Arial). The test document was a 50-page Chinese tender document using 1,342 characters.

FontOriginal FileGlyph Count (Original)Glyph Count (Subset)After SubsettingReduction
Source Han Serif Regular18.2MB6553513420.42MB97.7%
Microsoft YaHei Regular15.6MB2862213420.35MB97.8%
Arial Regular0.82MB3257960.06MB92.7%

Benchmark data shows that Chinese font subsetting is most effective — Source Han Serif went from 18.2MB to 0.42MB, a 97.7% reduction. This is because Chinese fonts have many glyphs (60,000+) but documents use few (1,000+), providing enormous trimming potential. English font Arial was only 0.82MB originally, and after subsetting 0.06MB — a 92.7% reduction. The absolute size is small, but the ratio is equally impressive.

Looking at subsetting effects at different character usage levels, using Source Han Serif as an example:

Document TypeCharacters UsedSize After SubsettingReductionNotes
Short notice (1 page)~2000.08MB99.6%Very few characters, very small subset
Meeting minutes (10 pages)~6000.19MB99.0%Daily office document
Tender document (50 pages)~13420.42MB97.7%Professional document with broad character coverage
Technical manual (200 pages)~28000.85MB95.3%Large character usage
Encyclopedia (1000 pages)~65001.92MB89.5%Near maximum coverage rate

4. Subsetting Tool Comparison and Scenario Recommendations

Various tools are available for font subsetting, from open-source command-line tools to commercial compression engines, each with its strengths and weaknesses. The table below compares mainstream solutions.

ToolSubsetting CapabilityCFF SupportBatch ProcessingIntegration Difficulty
SmartSlim★★★★★YesSupportedSDK/API/Desktop
fonttools (Python)★★★★☆YesRequires scriptingMedium
Adobe Acrobat★★★★☆YesLimitedGUI operation
Ghostscript★★★☆☆PartialSupportedCommand line
Online Tool★★☆☆☆PartialNot supportedLow (privacy risk)

SmartSlim is based on a self-developed Rust compression engine that automatically handles both TrueType and OpenType CFF glyph formats during subsetting, supporting batch drag-and-drop processing of hundreds of PDFs. More importantly, the entire subsetting process is completed locally — font data and document content never pass through any external server, which is critical for classified documents and enterprise-sensitive files.

Subsetting strategy recommendations for different scenarios:

ScenarioSubsetting RecommendedNotesRecommended Tool
Final draft archiving and distributionStrongly recommendedCannot edit new characters after subsettingSmartSlim
Enterprise batch archivingStrongly recommendedUse API for automated batch processingSmartSlim Server Edition
Online publishing/previewRecommendedReduce download size to improve loading speedfonttools script
Drafts still needing editingNot recommendedKeep full font for editingDo not subset yet
Classified/confidential documentsRecommendedMust process locally, online tools prohibitedSmartSlim

For more PDF optimization tips, see PDF Linearization Optimization Guide and Word Document Compression Methods.

5. FAQ

Q1: Does PDF font subsetting affect display quality?

No. Font subsetting only discards characters and glyph data that are not used in the document; the retained characters are completely identical to the original font, with zero impact on display quality. After subsetting, the font remains vector outlines — scaling up or down causes no distortion, and attributes like color and weight remain unchanged. The only limitation is that the subsetted font can only be used in that document and cannot be reused in other documents.

Q2: How much size can font subsetting reduce?

It depends on the ratio of character usage to original font size. Chinese fonts (e.g., Source Han Serif at 18MB) typically use only 1,000-2,000 characters; after subsetting, the size drops to 0.3-0.8MB, a reduction of over 95%. English fonts (e.g., Arial at 0.8MB) use even fewer characters; after subsetting, 0.05-0.1MB, a reduction of about 90%. The larger the font and the fewer characters used, the more significant the subsetting effect.

Q3: Can I still edit text in a subsetted PDF?

With limitations. Subsetting only retains characters already used in the document; if you enter a new character during editing (one not present in the original document), that character cannot be displayed and will appear as a box or blank. Therefore, subsetting is suitable for final draft archiving and distribution, not for documents that still require extensive editing. If editing is needed, we recommend keeping the full font or re-embedding a subset.

Q4: How can I check if a PDF has already been font-subsetted?

Open the PDF with Adobe Acrobat, click File > Properties > Fonts, and check the embedded font list. If the font name has a six-character prefix (e.g., ABCDEO+SourceHanSerif), it has been subsetted. You can also open the PDF with SmartSlim — the engine automatically analyzes the font embedding status and indicates whether subsetting is needed, along with an estimated compression size.

Summary

PDF font subsetting is one of the most effective ways to reduce PDF file size, especially for documents with embedded Chinese fonts. The core principle involves three steps: scanning used characters, reconstructing the CMap mapping table, and remapping glyph indices to discard unused glyphs. Benchmark data shows Source Han Serif going from 18MB to just 0.4MB after subsetting — a 97.7% reduction — with zero impact on display quality.

Practical recommendation: Always perform font subsetting before distributing final drafts, and use local tools for classified documents. If you need to batch process PDF files, SmartSlim supports 10 categories and 40+ formats including PDF, images, video, Office, and OFD, and automatically performs font subsetting based on its self-developed Rust compression engine, with data staying on-premises.

Need to Compress Files? Try SmartSlim

Built on a self-developed Rust compression engine, supporting 10 categories and 40+ formats including PDF, images, video, Office, and OFD, with local compression that keeps your data on-premises.