flat assembler
Message board for the users of flat assembler.

Index > Windows > How change font size without create again font ?

Author
Thread Post new topic Reply to topic
Roman



Joined: 21 Apr 2012
Posts: 1839
Roman 02 Jan 2021, 11:34
I create font Arial. Size 18.
And SendMessage,[hwnd],WM_SETFONT,eax,1

Some time i want resize font size to 22 or 14 and set again font to window.
Do somthing like Ctrl and + zoom font size.


How did resize font without recreate font again ?
Post 02 Jan 2021, 11:34
View user's profile Send private message Reply with quote
Furs



Joined: 04 Mar 2016
Posts: 2545
Furs 02 Jan 2021, 14:05
If by "creating again font" you mean CreateFont, then no, you can't. That's what CreateFont is for. Note that the font it "creates" is just a handle, it's not like it takes a massive amount of resources or anything.

Obviously it has to be recreated because a smaller font might have a different match, depending on the source.
Post 02 Jan 2021, 14:05
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1839
Roman 02 Jan 2021, 15:06
Furs wrote:
If by "creating again font" you mean CreateFont, then no, you can't.

Yes.
Post 02 Jan 2021, 15:06
View user's profile Send private message Reply with quote
Ali.Z



Joined: 08 Jan 2018
Posts: 727
Ali.Z 02 Jan 2021, 16:00
as Furs said, you cant avoid font creation functions. (CreateFont / CreateFontIndirect)

i personally would go for CreateFontIndirect, get my logfont structure populated by ChooseFont and pass it to CreateFontIndirect.

if you do so, remember to send your edit control WM_SETFONT message, delete old font (DeleteObject) and invalidate client rectangle to force redrawing.

_________________
Asm For Wise Humans
Post 02 Jan 2021, 16:00
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20430
Location: In your JS exploiting you and your system
revolution 02 Jan 2021, 23:49
Each time you use CreateFont* the OS has to find a raster representation of the characters. All modern fonts are in vector form and it is impossible to directly render them on a raster device like an LCD monitor, they have to be converted.

If the OS has some characters already in a cache somewhere and all the parameters match (i.e. size, escapement, weight, etc.) then it can reuse the old renderings. Otherwise it will create a new rendering for each new character you print. On modern hardware this isn't a big deal, and is quite fast, but if you are using older hardware there can be a perceivable delay each time new font parameters are selected.
Post 02 Jan 2021, 23:49
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.