As discussed in the forum topic "TFontText" [discussion:214f1787], it would be nice to have a simple way to set the font for a control. OWLNext currently requires that the parent (dialog) manages the lifetime of the font, which requires additional class members (e.g. TFont objects). What we need is the ability to pass a TFont to TWindow::SetWindowFont and forget about it.
Bugs: #507
Commit: [r8608]
Discussion: Selecting and restoring objects in TDC
Discussion: How to change the FONT attributes after TDalog has been created ?
Discussion: 214f1787
Discussion: TFontText
Discussion: TWindow::Create fails for TTooltip after port to OWLNext 7
Discussion: Font size on TEdit
Discussion: Font size on TEdit
Discussion: Example
News: 2026/08/owlet---gdi-overhaul-and-new-shared-pointer-semantics
Wiki: Frequently_Asked_Questions
Anonymous
This feature was implemented in Owlet in [r3731] and merged into the trunk in [r3739]. A new example, "examples/classes/static", was added in [r3744] to demonstrate the new feature.
Note that a TFont object can be an owner or a non-owner of the underlying font handle. A copy of a TFont object does not create a new font. Both objects will share the underlying handle, and reference-counting is used to ensure that the handle is deleted when the last owner is destructed.
The solution exploits these semantics. If a TFont is created as a temporary object at the point of call to SetWindowFont, the TFont copy constructor will share the handle with the callee. The reference count will be 2, then decremented to 1 as the temporary object is destructed after the call. The result is that the callee is now the owner of the font.
However, note that a TFont can be a non-owner as well. In this case, there is no ownership transfer in the call, and the caller is responsible for ensuring that the font handle outlives the window:
Please review.
Related
Commit: [r3731]
Commit: [r3739]
Commit: [r3744]
Last edit: Vidar Hasfjord 2018-05-03
A regression, causing a crash while dispatching WM_SETFONT for a premature window, was fixed in [r4177], and the fix was merged into Owlet in [r4178].
See https://sourceforge.net/p/owlnext/discussion/97177/thread/071b2a02/#f2d6
Related
Commit: [r4177]
Commit: [r4178]
Last edit: Vidar Hasfjord 2021-12-03
Unfortunately the fix implemented in [r4177] for the crash in the dispatch of WM_SETFONT causes a regression.
See [bugs:#507] "Font change in SetupWindow is ignored (regression in 7.0)".
Related
Bugs:
#507Commit: [r4177]