When I try to change Canvas.Font.Name before sending text to it I get:
Project proj_rawdisplay raised exception class 'External: SIGSEGV'...
Actually I get this error whenever I change the Name of any font. All the examples I've looked at online use the
Font.Name property for changing the font. Is there some reason this wouldn't work?
The code is pretty long but here's the test code I've been using to work the problem:
function THexDisplay.DetectMonospace(fontStr: string) : boolean;
var
w1,w2 : integer;
HFont : TFont;
begin
HFont.Create;
with HRawDisplay do
with Rimg do
begin
HFont.Assign(Canvas.Font);
HFont.Name:='Monospace';
Canvas.Font.Assign(HFont);
w1 := Canvas.TextWidth('M');
w2 := Canvas.TextWidth('i');
DetectMonoSpace := (w1 = w2);
end;
end;
I've tried with and without
HFont.Create. I've tried using
Assign or just
HFont := Canvas.Font, etc.
HRawDisplay is a TGraphicControl class in another unit. I've tried creating a local bitmap for this unit but it fails just as well.
Essentially what I'm trying to do is make certain that a Monospace font is selected for the control just in case the default font is NOT monospace. Using "
IsMonospace" doesn't return useful results so I'm checking TextWidth which seems to work fine... At least until I try to change the Font.Name.
In this case "Monospace" is a font that's available on my Linux system but it's not available on my Windows system. So I want to find the next best usable monospace font and use that instead.
Thanks in advance,
Jeff