The presence of wxWidgets-specific code in the (supposedly) cross-platform parts of Scintilla has been an ongoing maintenance problem. This could be solved properly by removing the ascent member of Font and bundling it with the font inside the wxWidgets platform code. Other platforms also have extra data associated with each font but they have not exposed this outside the platform layers.
To do this, create a two member struct or class (call it XFont for now) that contains both the wxWidgets font pointer and the ascent. Then when Font::Create is called, an XFont is allocated and a pointer to it is used for Font::fid. When Font::Release is called, the XFont is deleted and its destructor deletes the platform font. Each method that takes a Font (such as Surface::WidthText) then has to unwrap the XFont to reach the platform font and ascent (when needed).
All of this can be implemented completely within the Scintilla platform layer for wxWidgets with no changes needed to the standard Scintilla distribution. Once the changes have been made and have been successful, then ascent can be removed from Font in the Scintilla distribution.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Under what circumstances is this change needed? The issues with ascent on wxWidgets were addressed in [bugs:#1154].
Related
Bugs:
#1154Indeed, the situation on wxWidgets had been OK before revision 5151, but the change in revision 5151 [16c0de] seems to have broken it.
So the proposed patch.
Related
Commit: [16c0de]
The presence of wxWidgets-specific code in the (supposedly) cross-platform parts of Scintilla has been an ongoing maintenance problem. This could be solved properly by removing the ascent member of Font and bundling it with the font inside the wxWidgets platform code. Other platforms also have extra data associated with each font but they have not exposed this outside the platform layers.
To do this, create a two member struct or class (call it XFont for now) that contains both the wxWidgets font pointer and the ascent. Then when Font::Create is called, an XFont is allocated and a pointer to it is used for Font::fid. When Font::Release is called, the XFont is deleted and its destructor deletes the platform font. Each method that takes a Font (such as Surface::WidthText) then has to unwrap the XFont to reach the platform font and ascent (when needed).
All of this can be implemented completely within the Scintilla platform layer for wxWidgets with no changes needed to the standard Scintilla distribution. Once the changes have been made and have been successful, then ascent can be removed from Font in the Scintilla distribution.
OK, I think I've managed to get rid of wxWidgets-specific code from Scintilla.
If this patch (attached to wxWidgets Trac ticket) is accepted into wxWidgets, the wx-specific code in Scintilla can be removed.
That looks good.
Are there any problems with this change? I would like to remove the wx-specific code from Scintilla soon.
The wxWidgets-specific code has now been removed from Scintilla with change set [dbe7a5].
This means that wxStyledTextCtrl will have to be altered to avoid use of Font::ascent.
Related
Commit: [dbe7a5]
The wxWidgets repository has been updated to be compatible with this change.