Search code examples
delphifontsidedelphi-xe2embedded-resource

Why won't Delphi XE2 let me embed a font resource as RCDATA?


I would like to embed a .ttf font resource into my EXE and dynamically load it. This particular method expects the resource to be of type RCDATA. So, I go to Project > Resources and Images... press Add..., and pick my .ttf file. The resource type FONT is automatically selected with an identifier of just 1. I change the type to to RCDATA and type in my own resource name.

Problem: When I press Ok I get an error that the identifier of a FONT resource must be a numeric value. But it wasn't FONT type anymore, I had changed it to RCDATA.

How do I get past this problem?


Solution

  • (asking and answering together because I'm sure others have seen this problem)

    It seems to be just a small bug in the IDE. When you first select your .ttf file in this resource screen, change the type, press Ok without changing the identifier (leave it 1). Then, open the same screen back up, change the identifier to your own, and press Ok. It only works if you close and re-open the Resources and Images screen.

    You could of course also write your own .rc file and do everything manually without this screen.