Server Settings - Font Management

Manage fonts for PDF and charting operations

Overview

The Font Management page allows you to register and manage fonts used by ColdFusion for PDF generation, charting operations, and image manipulation. Proper font configuration is essential for creating professional-looking PDFs with consistent typography, internationalization support, and accurate text rendering across different platforms.

ColdFusion includes a default set of system fonts, but you can register additional TrueType (TTF) and OpenType (OTF) fonts to meet your application's specific design and language requirements.

Font Registry

System Fonts

ColdFusion automatically detects and registers fonts from standard system locations:

  • Windows: C:\Windows\Fonts
  • Linux: /usr/share/fonts, /usr/local/share/fonts
  • macOS: /Library/Fonts, /System/Library/Fonts

Registered Fonts List

The Font Management page displays all fonts currently registered with ColdFusion:

  • Font Name: The font family name used in CFML code
  • Font Path: Location of the font file on disk
  • Font Type: TrueType (TTF) or OpenType (OTF)
  • Status: Available or unavailable (missing file)
  • Actions: Remove custom fonts (system fonts cannot be removed)

Font Properties

Each font registration includes information about:

  • Font family name
  • Font style (Regular, Bold, Italic, Bold Italic)
  • Character sets supported
  • Embedding permissions
  • Unicode ranges covered

Adding Custom Fonts

Single Font Registration

To register an individual font file:

  1. Click "Register New Font" button
  2. Specify the absolute path to the font file (.ttf or .otf)
  3. Enter the font family name (how you'll reference it in code)
  4. Select the font style (Regular, Bold, Italic, Bold Italic)
  5. Click "Submit" to register the font

Font Directory Registration

To register all fonts in a directory:

  1. Click "Add Font Directory" button
  2. Enter the absolute path to the directory containing fonts
  3. Choose whether to scan subdirectories recursively
  4. Click "Submit" to scan and register all fonts
  5. Review the list of newly registered fonts

Font File Requirements

Fonts must meet these requirements:

  • File format: TrueType (.ttf) or OpenType (.otf)
  • Valid font structure and metadata
  • Read permissions for ColdFusion process user
  • Not corrupted or password-protected
  • Embedding permissions allow PDF embedding

Using Fonts in CFML

PDF Generation

Use registered fonts in cfdocument and cfpdf:

PDF Generation with Custom Fonts
// cfdocument is primarily tag-based, wrap in cfscript
cfdocument(format="pdf") {
  writeOutput('
    <style>
      body { font-family: "Arial", sans-serif; }
      h1 { font-family: "Custom Font Name", serif; }
    </style>
    <h1>This uses your custom font</h1>
    <p>This uses Arial</p>
  ');
}
<cfdocument format="pdf">
  <style>
    body { font-family: 'Arial', sans-serif; }
    h1 { font-family: 'Custom Font Name', serif; }
  </style>
  <h1>This uses your custom font</h1>
  <p>This uses Arial</p>
</cfdocument>

Charting Operations

Specify fonts in cfchart and cfchartseries:

Chart Font Configuration
// cfchart is primarily tag-based, wrap in cfscript
cfchart(format="png", font="Arial", fontSize="12") {
  cfchartseries(type="bar") {
    cfchartdata(item="Q1", value="100");
    cfchartdata(item="Q2", value="150");
  }
}
<cfchart format="png" font="Arial" fontSize="12">
  <cfchartseries type="bar">
    <cfchartdata item="Q1" value="100">
    <cfchartdata item="Q2" value="150">
  </cfchartseries>
</cfchart>

Image Manipulation

Use fonts when adding text to images:

Image Text with Custom Fonts
myImage = imageNew("", 400, 300, "rgb", "white");
attr = {
  font: "Arial",
  size: 24,
  style: "bold"
};
imageDrawText(myImage, "Hello World", 50, 100, attr);
<cfset myImage = imageNew("", 400, 300, "rgb", "white")>
<cfset attr = {
  font: "Arial",
  size: 24,
  style: "bold"
}>
<cfset imageDrawText(myImage, "Hello World", 50, 100, attr)>

Font Configuration Settings

Font Directories

Custom Font Directories

Purpose
Additional directories to scan for fonts
Default
None
Recommendation
Store custom fonts in dedicated directory (e.g., /opt/fonts)

Specify absolute paths to directories containing custom font files. ColdFusion will scan these on startup.

Recursive Scanning

Purpose
Scan subdirectories for fonts
Default
Enabled
Recommendation
Enable for organized font directory structures

When enabled, ColdFusion will search all subdirectories within font directories for font files.

Auto-Registration

Purpose
Automatically register new fonts on startup
Default
Enabled
Recommendation
Enable for automatic font discovery

ColdFusion will automatically detect and register new fonts added to configured directories on server restart.

Font Caching

Font Cache

Purpose
Cache font metrics for performance
Default
Enabled
Recommendation
Always enable for better performance

Caching font metrics significantly improves PDF generation and charting performance by avoiding repeated font file parsing.

Cache Size

Purpose
Maximum number of cached fonts
Default
1000
Recommendation
Set based on number of registered fonts

Higher values use more memory but improve performance when using many different fonts.

Cache Location

Purpose
Directory for font cache files
Default
{cf-root}/lib/fonts
Recommendation
Use default location

ColdFusion stores cached font metrics in this directory. Ensure ColdFusion has write permissions.

PDF Font Embedding

Embed Fonts

PurposeEmbed fonts in generated PDFs
DefaultEnabled
RecommendationEnable for consistency across viewing platforms
ImpactEnsures PDFs display correctly on systems without the fonts installed
Best Practice: Always embed fonts in production PDFs to ensure consistent appearance across all viewing platforms and devices.

Subset Fonts

PurposeEmbed only characters actually used in the PDF
DefaultEnabled
RecommendationEnable to reduce file size significantly
ImpactReduces PDF file size by 50-90% when using custom fonts
How it Works: Instead of embedding entire font files (which can be several MB), subsetting includes only the specific glyphs (characters) actually used in your PDF document.

Validate Permissions

PurposeCheck font embedding permissions before including in PDF
DefaultEnabled
RecommendationEnable for licensing compliance
ImpactPrevents legal issues from embedding fonts that prohibit distribution
Legal Compliance: Some font licenses prohibit embedding in PDFs. Validation prevents embedding fonts with restrictive licenses.

International Font Support

Unicode Fonts

For international character support:

  • Register fonts that include required Unicode ranges
  • Use fonts like Arial Unicode MS for broad coverage
  • Test with actual international content
  • Verify character rendering in PDFs
  • Check for missing glyph fallbacks

Common International Fonts

  • Chinese: SimSun, Microsoft YaHei, WenQuanYi
  • Japanese: MS Gothic, MS Mincho, IPAGothic
  • Korean: Malgun Gothic, Batang, Dotum
  • Arabic: Arial Unicode MS, Tahoma, Traditional Arabic
  • Cyrillic: Arial, Times New Roman, DejaVu Sans

Right-to-Left Languages

When working with RTL languages (Arabic, Hebrew):

  • Use fonts specifically designed for RTL scripts
  • Test text direction in PDFs
  • Verify proper glyph shaping and ligatures
  • Consider using Unicode BIDI control characters

Best Practices

Font Selection

  • Use web-safe fonts when possible for maximum compatibility
  • Choose fonts with broad Unicode coverage for international content
  • Select fonts with full family support (Regular, Bold, Italic, Bold Italic)
  • Verify font licensing allows PDF embedding
  • Test fonts thoroughly before production deployment
  • Maintain a standard font library across environments

Font Organization

  • Store custom fonts in dedicated directory (e.g., /opt/fonts)
  • Use consistent naming conventions for font files
  • Document font licensing and usage rights
  • Maintain font version control and updates
  • Keep backup copies of all custom fonts

Performance

  • Register only fonts actually used by applications
  • Enable font subsetting to reduce PDF file sizes
  • Use font caching for improved performance
  • Limit the number of different fonts in PDFs
  • Consider using standard fonts when possible

Production Deployment

  • Install identical fonts across all servers in cluster
  • Verify file permissions allow ColdFusion to read fonts
  • Test PDF generation with all custom fonts
  • Document font dependencies for applications
  • Include fonts in deployment automation
  • Monitor for missing font warnings in logs

Troubleshooting Font Issues

Font Not Found Errors

If ColdFusion reports font not found:

  • Verify font is registered in Font Management page
  • Check font file exists at registered path
  • Confirm font name matches exactly (case-sensitive)
  • Restart ColdFusion after adding new fonts
  • Check ColdFusion process has read permissions
  • Review application.log for font loading errors

Incorrect Font Rendering

If PDFs show wrong font or fallback font:

  • Verify font name is spelled correctly in code
  • Check font style (Regular/Bold/Italic) is registered
  • Ensure font supports required characters
  • Test with simpler font name without special characters
  • Clear ColdFusion font cache and restart

Missing Characters or Squares

If characters appear as boxes or squares:

  • Font doesn't contain glyphs for those characters
  • Use font with broader Unicode coverage
  • Register fallback font that includes characters
  • Check character encoding in source data
  • Verify font file isn't corrupted

Large PDF File Sizes

If PDFs with custom fonts are too large:

  • Enable font subsetting to embed only used characters
  • Reduce number of different fonts used
  • Consider using standard PDF fonts (Times, Helvetica, Courier)
  • Compress PDFs after generation
  • Use fonts with smaller file sizes

Font Registration Fails

If unable to register a font:

  • Verify font file format (must be TTF or OTF)
  • Check font file isn't corrupted (open in font viewer)
  • Ensure absolute path is correct
  • Verify ColdFusion has read permissions
  • Check font doesn't have restrictions preventing embedding
  • Review coldfusion-error.log for specific error messages

Fonts Work Locally But Not On Server

If fonts work in development but fail in production:

  • Verify fonts are installed on production server
  • Check font paths match between environments
  • Confirm font registration on production server
  • Verify file permissions on production
  • Check for operating system differences (Windows vs Linux)
  • Review case sensitivity of font paths and names

Font Licensing Considerations

Embedding Permissions

Font licenses often include restrictions on embedding:

  • Review font license agreement for embedding rights
  • Check font embedding permissions in font properties
  • Some fonts prohibit PDF embedding entirely
  • Commercial fonts may require additional licensing for server use
  • Free fonts often have fewer restrictions

Server Licensing

Consider licensing for server deployment:

  • Desktop licenses may not cover server use
  • Server licenses often cost more than desktop licenses
  • Check if license covers all servers in cluster
  • Document licensing for compliance audits
  • Keep license agreements with font files

Free Font Alternatives

Consider these free, open-source fonts:

  • Google Fonts: Large collection of free fonts
  • DejaVu Fonts: Excellent Unicode coverage
  • Liberation Fonts: Metric-compatible with common fonts
  • Noto Fonts: Comprehensive international coverage
  • Open Sans, Roboto: Modern, professional appearance

Security Considerations

Font File Security

  • Store font files in protected directories
  • Set appropriate file permissions (read-only for CF process)
  • Validate font files before registration
  • Monitor for unauthorized font file modifications
  • Use virus scanning on uploaded font files

Path Validation

  • Use absolute paths for font registration
  • Validate font directory paths to prevent path traversal
  • Restrict font directories to approved locations
  • Don't allow user input to specify font paths

Related Resources