{1} Edit: Since we've established that you're not the one creating the original meta after this answer has been posted, please refer to section Retrieving records from an existing MetaFile.
{2} Edit: Per your second problem with identifying font settings, please refer to second update section Retrieving font structure record.
ClearType is quite a pickle. Anyone can change the intensity of the blending color as they wish, thanks to the integrated ClearType tuner. With Images in mind you therefor cannot rely on the ClearType settings of each individual system.
AFAIK the only real solution is to ignore the custom ClearType rendering and use a pre-configured one.
Edit 1 : Retrieving records from an existing MetaFile
You can modify an existing Metafile through Enhanced Metafile Operations more specifically through EnumEnhMetaFile function which has a callback function EnhMetaFileProc that you can use to process the records.
Use the PlayEnhMetaFileRecord function to parse through and examine each record at a time. More on how to edit & modify a specific record, see here.
At some point down the line you will have to use the code below to modify the existing font rendering.
Edit 2 : Retrieving font structure record
Just like you can retrieve the position and text via EMREXTTEXTOUTA structure, you can also retrieve the Font settings used via the EMREXTCREATEFONTINDIRECTW structure. This structure will allow you to get the font record of LOGFONT defined type which contains most info regarding the font, except for the brush used.
If you look at my original answer code you can see that the color of the font is defined by the brush used. so equally you have to use a different structure to obtain that info, the EMRCREATEBRUSHINDIRECT structure. The LOGBRUSH32 typed member contains info about the color and style of the brush used.
Original Answer
In order to accomplish this you have to resort to using GDI+ since the delphi encapsulation of the Win32 Enhanced metafile is not complete. Use the Delphi GDI+ library.
uses
GDIPlus,GDIPlusHelpers
const
Deftext = 'Lorem ipsum dolor sit amet,'
+sLineBreak+'consectetur adipisicing elit, sed do eiusmod tempor incididunt'
+sLineBreak+'ut labore et dolore magna aliqua.';
procedure CreateEmF(const EmfFileName : TFileName);
var
Graphics : IGPGraphics;
xBrush: IGPBrush;
xFontFamily: IGPFontFamily;
xFont: IGPFont;
DC: HDC;
Metafile: IGPMetafile;
begin
xBrush := TGPSolidBrush.Create(TGPColor.Create(0, 0, 0));
xFontFamily := TGPFontFamily.Create('Segoe UI');
xFont := TGPFont.Create(xFontFamily, 12, FontStyleRegular, UnitPoint{UnitPixel});
DC := GetDC(0);
try
Metafile := TGPMetafile.Create(EmfFileName, DC);
Graphics := TGPGraphics.Create(Metafile);
{
Use Presets instead of the DefaultSystemRendering
TextRenderingHintAntiAliasGridFit - Preset ClearType Rendering
TextRenderingHintSingleBitPerPixelGridFit - Preset Normal Rendering
}
Graphics.TextRenderingHint := TextRenderingHintAntiAliasGridFit;
Graphics.DrawString(Deftext, xFont, TGPPointF.Create(50, 50), xBrush);
Graphics := nil;
finally
ReleaseDC(0, DC);
end;
end;
procedure ConvertEmf2Bmp(const EMFFileName, BMPFileName: TFileName) ;
var
MetaFile : TMetafile;
Bitmap : TBitmap;
begin
Metafile := TMetaFile.Create;
Bitmap := TBitmap.Create;
try
MetaFile.LoadFromFile(EMFFileName);
with Bitmap do
begin
SetSize(MetaFile.Width,MetaFile.Height);
Canvas.Draw(0, 0, MetaFile) ;
SaveToFile(BMPFileName) ;
end;
finally
Bitmap.Free;
MetaFile.Free;
end;
end;