How to use TTF Font Without Installing

CK CK 3788 
Created at
Updated at  
1,116 0 0

Here's how to use a TTF (true type font) in your Delphi application without having to install it in Windows:

1. In the OnCreate event for the main form in your Delphi application call the AddFontResource API function. The AddFontResource function adds the font resource from the specified file to the system font table.
2. When an application no longer needs a font resource that it loaded by calling the AddFontResource function, it must remove that resource by calling the RemoveFontResource function. Do this in the OnDestroy event for the main form.

 

procedure TForm1.FormCreate(Sender: TObject) ;
begin
  AddFontResource('c:FONTSMyFont.TTF') ;
  SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0) ;
end;

{Before application terminates we must remove our font:}
procedure TForm1.FormDestroy(Sender: TObject; var Action: TCloseAction) ;
begin
  RemoveFontResource('C:FONTSMyFont.TTF') ;
  SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0) ;
end;
Tags FlashWindow RemoveFontResource TCloseAction True Type Font Display chkdsk Facebook X
Comments 0
Similar posts
  1. Window flashing
    379
  2. How to show window contents while dragging
    453
  3. How to save text from Clipboard to a file
    568
  4. How to send char as message to another application
    543
  5. How to restrict mouse movement
    408
  6. List Devices (LPT, COM ports, ...)
    478
  7. How to know whether the font is TrueTypeFont or not
    375
  8. How to track a user's idle time
    588
  9. How to remove your application from TaskBar
    655
  10. How to play sounds on the PC Speaker ?
    525
  11. How to install an INF file using Delphi ?
    462
  12. How to determine the output of a console application ?
    450
  13. Get text from the control at pos x,y on screen
    467
  14. Get dimensions of usable space on monitor (work area)
    489
  15. Get system info (free memory, etc)
    405
  16. How to Get Filenames from Clipboard ?
    1,502
  17. How to Get Windows OS Version ?
    428
  18. Get Windows Temp directory
    658
  19. Disable ALT+TAB, CTRL+ESC, CTRL+ALT+DEL
    1,826
  20. Display Standard Windows Properties dialog
    1,129
  21. Disable Mouse and Keyboard from Delphi Code
    793
  22. Detecting Drive Types
    467
  23. Detecting and preventing Windows shut down
    438
  24. Copying Group of Files using Delphi with Standard Animation Dialog (SHFileOperation)
    413
  25. Controling sound volume from code
    422
  26. How to Close Another Application by Windows Caption
    389
  27. How to Change the Windows Start button bitmap
    427
  28. How to capture the output from a DOS (command/console) Window
    964
  29. How to Activate/Deactivate the Screen Saver
    861
  1. Base64 Encoding/Decoding function for Delphi
    1,153
  2. How to send email by TIdSMTP VCL ?
    1,018
  3. How to return exit code such as exit() function in C/C++ ?
    662
  4. How to get parameter string ?
    1,237
  5. Save TBitmap image to Jpeg format image in Delphi
    712
  6. How to get screen resolution in case of using multiple monitors ?
    450
  7. How to turn off monitor ?
    427
  8. Find File at certain directory in Delphi
    437
  9. Sending email messages in .Net
    1,032
  10. Delphi for .Net Code Folding keyboard shortcuts
    527
  11. How to encrypt a string
    465
  12. Creating thumbnail images
    861
  13. Technology sharing related with software development. Specially content will be focused to programming language, and embedded systems.
    850
  14. How to speed up access to the RichTextBox Lines property
    830
  15. Window flashing
    379
  16. How to show window contents while dragging
    453
  17. How to save text from Clipboard to a file
    568
  18. How to send char as message to another application
    543
  19. How to restrict mouse movement
    408
  20. List Devices (LPT, COM ports, ...)
    478
  21. How to know whether the font is TrueTypeFont or not
    375
  22. How to track a user's idle time
    588
  23. How to remove your application from TaskBar
    655
  24. How to play sounds on the PC Speaker ?
    525
  25. How to install an INF file using Delphi ?
    462
  26. How to determine the output of a console application ?
    450
  27. Get text from the control at pos x,y on screen
    467
  28. Get dimensions of usable space on monitor (work area)
    489
  29. Get system info (free memory, etc)
    405
  30. How to Get Filenames from Clipboard ?
    1,502
Recently updated
  1. Why 100% SEO Guarantees Better User Engagement and How to Achieve It in Your Service
    39
  2. Why SPF and DKIM Are Essential for Linux Email Servers?
    34
  3. How do I create animated background for Google Meet?
    20,611
  4. MaxMind GeoLite2 vs. DB-IP Lite vs. ip-api.com: Choosing the Right Free IP Geolocation Solution
    244
  5. Meet Valkey: Why Redis Changed Its License, Why Valkey is Better, and How to Use It as a Drop-in Replacement
    94
  6. How Rogue Web Scrapers Are Stealing My Content and Destroying My Server
    156
  7. Array of arguments passed to script in PHP
    90
  8. Invalid Auction Storms in Ad Tech
    98
  9. Building MRC-Compliant Instrumentation in Ad Tech: Implementation Steps and Key Challenges
    202
  10. The Two Clocks of Ad Server Architecture
    69
  11. Frequency Cap Architecture Overview
    513
  12. Collecting Proof-of-Play from 100,000 Screens
    145
  13. Vector Search in Relational Databases (RDBs): Trends & Usage Environments
    287
  14. What is RedisVL?
    108
  15. Designing a Skill Registry Architecture: Minimize Token Usage and Maximize AI Performance
    229
  16. TPU & GPU Cluster Management Tools
    243
  17. The Concept of Scaffolding in AI Agents
    232
  18. Beyond Static Pipelines: Architecting LLM Multi-Agent Systems for Autonomous Workflow Orchestration
    582
  19. AI-DLC vs. AI-SDLC: Model-Centric vs. System-Centric AI Development
    258
  20. Fine-Tuning Open-Weight LLMs: Training, Licensing, and Deploying Custom Models with Ollama
    337
  21. Inside the Next-Generation Streaming Architecture: Ultra-Low Latency, SGAI, and AI Codecs
    202
  22. Machine Learning: Training vs. Ranking
    221
  23. The Continuous Learning Machine: Designing a Loop That Actually Turns
    222
  24. The Next-Gen Low-Latency Standards: LL-HLS & MoQ
    195
  25. Designing a Data Curation System Around a Vector Database
    220
  26. Extracting Context from Live Video: The Architecture Got Simpler When We Stopped Building Features
    256
  27. The New Ad Stack Behind Live Sports Streaming: Inside SGAI, EABN, and the Standards Race to Fix Live Monetization
    655
  28. Designing MLOps Architectures to Handle Seasonal Data Drift in EV Fleet Models
    194
  29. From 15 to 40+ FPS: Accelerating PyTorch Object Detection on Automotive ECUs
    216
  30. Understanding Data Lineage
    259