Getting rid of something can be a bit tricky when you need to maintain your code also with older versions. The basic idea is to introduce that new property with an empty default value matching the current behavior. This will keep the DFM clean and ParentFont functioning as before.
These are the parts for a possible implementation:
type
TFontElement = (pfeCharset, pfeColor, pfeHeight, pfeName, pfeOrientation, pfePitch, pfeSize, pfeStyle, pfeQuality);
TFontElements = set of TFontElement;
The new property ParentFontElements would be initialized with an empty set, which would be omitted when writing the DFM.
property ParentFontElements: TParentFontElements read FParentFontElements write SetParentFontElements default [];
The implementation would not affect any rendering at all. It can be implemented completely inside TControl.CMParentFontChanged without any impact to any other place.
procedure TControl.CMParentFontChanged(var Message: TCMParentFontChanged);
begin
if FParentFont then
begin
if Message.WParam <> 0 then
SetFont(Message.Font)
else
SetFont(FParent.FFont);
FParentFont := True;
end
else if FParent <> nil then
begin
{ TODO : order might be relevant }
if pfeCharset in ParentFontElements then
Font.Charset := FParent.Font.Charset;
if pfeColor in ParentFontElements then
Font.Color := FParent.Font.Color;
if pfeHeight in ParentFontElements then
Font.Height := FParent.Font.Height;
if pfeName in ParentFontElements then
Font.Name := FParent.Font.Name;
if pfeOrientation in ParentFontElements then
Font.Orientation := FParent.Font.Orientation;
if pfePitch in ParentFontElements then
Font.Pitch := FParent.Font.Pitch;
if pfeSize in ParentFontElements then
Font.Size := FParent.Font.Size;
if pfeStyle in ParentFontElements then
Font.Style := FParent.Font.Style;
if pfeQuality in ParentFontElements then
Font.Quality := FParent.Font.Quality;
end;
end;
The ParentFontElements are only used when ParentFont is False, which is automatically set when changing some Font properties. Thus setting ParentFontElements must internally set ParentFont to False and trigger CM_PARENTFONTCHANGED:
procedure TControl.SetParentFontElements(const Value: TParentFontElements);
begin
if FParentFontElements <> Value then
begin
FParentFontElements := Value;
FParentFont := False;
if (FParent <> nil) and not (csReading in ComponentState) then
Perform(CM_PARENTFONTCHANGED, 0, 0);
end;
end;
Apart from some real world testing and adjusting this is probably all that is needed for an implementation.