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 Table | Function | Typical Proportion | Can Be Trimmed by Subsetting |
|---|---|---|---|
| cmap | Character code to glyph index mapping | 1%–3% | Needs reconstruction |
| glyf | TrueType glyph outline data | 70%–85% | Can be significantly trimmed |
| CFF | OpenType CFF glyph outlines (PostScript) | 60%–80% | Can be significantly trimmed |
| loca | Glyph data position index | 1%–2% | Needs reconstruction |
| hmtx | Horizontal metrics (character width/advance) | 2%–5% | Needs reconstruction |
| name | Font name, copyright, and other metadata | 0.5%–1% | Preserved |
| post | PostScript name mapping | 1%–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.
| Step | Operation | Principle | Tables Processed |
|---|---|---|---|
| 1. Character Usage Scan | Traverse all page content streams in the PDF, extract displayed character codes | Collect Unicode code points by parsing text operators (Tj/TJ) | None (generates character set) |
| 2. CMap Table Reconstruction | Rebuild character code to glyph index mapping based on used characters | Keep only mapping entries for used characters, delete the rest | cmap |
| 3. Glyph Index Remapping | Continuously rearrange used glyphs, update all reference indices | Original indices may be non-contiguous; after rearrangement, indices 0 to N are contiguous | glyf/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 Format | Encoding Range | Purpose | Subsetting Processing |
|---|---|---|---|
| Format 0 | 0–255 | Single-byte ASCII/Latin | Trim unused entries |
| Format 4 | BMP Basic Multilingual Plane | Common CJK characters | Rebuild segment table |
| Format 12 | Full Unicode | Covers all characters | Trim 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.
| Font | Original File | Glyph Count (Original) | Glyph Count (Subset) | After Subsetting | Reduction |
|---|---|---|---|---|---|
| Source Han Serif Regular | 18.2MB | 65535 | 1342 | 0.42MB | 97.7% |
| Microsoft YaHei Regular | 15.6MB | 28622 | 1342 | 0.35MB | 97.8% |
| Arial Regular | 0.82MB | 3257 | 96 | 0.06MB | 92.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 Type | Characters Used | Size After Subsetting | Reduction | Notes |
|---|---|---|---|---|
| Short notice (1 page) | ~200 | 0.08MB | 99.6% | Very few characters, very small subset |
| Meeting minutes (10 pages) | ~600 | 0.19MB | 99.0% | Daily office document |
| Tender document (50 pages) | ~1342 | 0.42MB | 97.7% | Professional document with broad character coverage |
| Technical manual (200 pages) | ~2800 | 0.85MB | 95.3% | Large character usage |
| Encyclopedia (1000 pages) | ~6500 | 1.92MB | 89.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.
| Tool | Subsetting Capability | CFF Support | Batch Processing | Integration Difficulty |
|---|---|---|---|---|
| SmartSlim | ★★★★★ | Yes | Supported | SDK/API/Desktop |
| fonttools (Python) | ★★★★☆ | Yes | Requires scripting | Medium |
| Adobe Acrobat | ★★★★☆ | Yes | Limited | GUI operation |
| Ghostscript | ★★★☆☆ | Partial | Supported | Command line |
| Online Tool | ★★☆☆☆ | Partial | Not supported | Low (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:
| Scenario | Subsetting Recommended | Notes | Recommended Tool |
|---|---|---|---|
| Final draft archiving and distribution | Strongly recommended | Cannot edit new characters after subsetting | SmartSlim |
| Enterprise batch archiving | Strongly recommended | Use API for automated batch processing | SmartSlim Server Edition |
| Online publishing/preview | Recommended | Reduce download size to improve loading speed | fonttools script |
| Drafts still needing editing | Not recommended | Keep full font for editing | Do not subset yet |
| Classified/confidential documents | Recommended | Must process locally, online tools prohibited | SmartSlim |
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.
Related Articles
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.