the logical font that the Windows function CreateFont() creates is not linked to an existing font until the Windows function SelectObject() is called.
Maybe the return value of the Windows function SelectObject() is a better test of TSE function SetFont()'s success?
-----Original Message-----
From:
sem...@googlegroups.com <
sem...@googlegroups.com> On Behalf Of S.E. Mitchell
Sent: Friday, February 7, 2025 3:06 AM
To:
sem...@googlegroups.com
Subject: Re: [TSE] Bug in SetFont()
SetFont(fontname, pointsize, flags)
The editor populates a LOGFONT structure, with the specified font name.
It then calls CreateFontIndirect(), and if that is able to create a
font, then the editor returns true.
If CreateFontIndirect() fails, the editor returns false.
I ran it under the debugger, and the newly created font has a
"FaceName" value of "BADXMFOPSUER", even though there is of course no
such font.
And CreateFontIndirect() returns a valid font :(
I guess I could do like your macro, check to see if the facenames
match, and if not, try to recreate the previous font, and return
false.
What do you think?
On Thu, Feb 6, 2025 at 7:20 AM Carlo Hogeveen <
t...@ecarlo.nl> wrote:
>
>
> The macro below demonstrates a bug in SetFont().
> SetFont() does not return 0 if you feed it a non-existing font.
> I can work around it by retrieving the (new?) font afterwards.
>
> Carlo
[ ... irrelevant history deleted ...]