Don't use "ascent" field of Scintilla Font class any more.
This field will be removed in Scintilla 3.5.5. See #16776.
This commit is contained in:
@@ -75,9 +75,45 @@ wxColour wxColourFromCDandAlpha(ColourDesired& cd, int alpha) {
|
|||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
|
||||||
|
// wxFont with ascent cached, a pointer to this type is stored in Font::fid.
|
||||||
|
class wxFontWithAscent : public wxFont
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit wxFontWithAscent(const wxFont &font)
|
||||||
|
: wxFont(font),
|
||||||
|
m_ascent(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static wxFontWithAscent* FromFID(FontID fid)
|
||||||
|
{
|
||||||
|
return static_cast<wxFontWithAscent*>(fid);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetAscent(int ascent) { m_ascent = ascent; }
|
||||||
|
int GetAscent() const { return m_ascent; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
int m_ascent;
|
||||||
|
};
|
||||||
|
|
||||||
|
void SetAscent(Font& f, int ascent)
|
||||||
|
{
|
||||||
|
wxFontWithAscent::FromFID(f.GetID())->SetAscent(ascent);
|
||||||
|
}
|
||||||
|
|
||||||
|
int GetAscent(Font& f)
|
||||||
|
{
|
||||||
|
return wxFontWithAscent::FromFID(f.GetID())->GetAscent();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // anonymous namespace
|
||||||
|
|
||||||
Font::Font() {
|
Font::Font() {
|
||||||
fid = 0;
|
fid = 0;
|
||||||
ascent = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Font::~Font() {
|
Font::~Font() {
|
||||||
@@ -104,20 +140,20 @@ void Font::Create(const FontParameters &fp) {
|
|||||||
else
|
else
|
||||||
weight = wxFONTWEIGHT_NORMAL;
|
weight = wxFONTWEIGHT_NORMAL;
|
||||||
|
|
||||||
wxFont* font = new wxFont(fp.size,
|
wxFont font(fp.size,
|
||||||
wxFONTFAMILY_DEFAULT,
|
wxFONTFAMILY_DEFAULT,
|
||||||
fp.italic ? wxFONTSTYLE_ITALIC : wxFONTSTYLE_NORMAL,
|
fp.italic ? wxFONTSTYLE_ITALIC : wxFONTSTYLE_NORMAL,
|
||||||
weight,
|
weight,
|
||||||
false,
|
false,
|
||||||
stc2wx(fp.faceName),
|
stc2wx(fp.faceName),
|
||||||
encoding);
|
encoding);
|
||||||
fid = font;
|
fid = new wxFontWithAscent(font);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Font::Release() {
|
void Font::Release() {
|
||||||
if (fid)
|
if (fid)
|
||||||
delete (wxFont*)fid;
|
delete wxFontWithAscent::FromFID(fid);
|
||||||
fid = 0;
|
fid = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -478,7 +514,7 @@ void SurfaceImpl::DrawTextNoClip(PRectangle rc, Font &font, XYPOSITION ybase,
|
|||||||
|
|
||||||
// ybase is where the baseline should be, but wxWin uses the upper left
|
// ybase is where the baseline should be, but wxWin uses the upper left
|
||||||
// corner, so I need to calculate the real position for the text...
|
// corner, so I need to calculate the real position for the text...
|
||||||
hdc->DrawText(stc2wx(s, len), rc.left, ybase - font.ascent);
|
hdc->DrawText(stc2wx(s, len), rc.left, ybase - GetAscent(font));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SurfaceImpl::DrawTextClipped(PRectangle rc, Font &font, XYPOSITION ybase,
|
void SurfaceImpl::DrawTextClipped(PRectangle rc, Font &font, XYPOSITION ybase,
|
||||||
@@ -491,7 +527,7 @@ void SurfaceImpl::DrawTextClipped(PRectangle rc, Font &font, XYPOSITION ybase,
|
|||||||
hdc->SetClippingRegion(wxRectFromPRectangle(rc));
|
hdc->SetClippingRegion(wxRectFromPRectangle(rc));
|
||||||
|
|
||||||
// see comments above
|
// see comments above
|
||||||
hdc->DrawText(stc2wx(s, len), rc.left, ybase - font.ascent);
|
hdc->DrawText(stc2wx(s, len), rc.left, ybase - GetAscent(font));
|
||||||
hdc->DestroyClippingRegion();
|
hdc->DestroyClippingRegion();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -506,7 +542,7 @@ void SurfaceImpl::DrawTextTransparent(PRectangle rc, Font &font, XYPOSITION ybas
|
|||||||
|
|
||||||
// ybase is where the baseline should be, but wxWin uses the upper left
|
// ybase is where the baseline should be, but wxWin uses the upper left
|
||||||
// corner, so I need to calculate the real position for the text...
|
// corner, so I need to calculate the real position for the text...
|
||||||
hdc->DrawText(stc2wx(s, len), rc.left, ybase - font.ascent);
|
hdc->DrawText(stc2wx(s, len), rc.left, ybase - GetAscent(font));
|
||||||
|
|
||||||
hdc->SetBackgroundMode(wxBRUSHSTYLE_SOLID);
|
hdc->SetBackgroundMode(wxBRUSHSTYLE_SOLID);
|
||||||
}
|
}
|
||||||
@@ -583,8 +619,9 @@ XYPOSITION SurfaceImpl::Ascent(Font &font) {
|
|||||||
SetFont(font);
|
SetFont(font);
|
||||||
int w, h, d, e;
|
int w, h, d, e;
|
||||||
hdc->GetTextExtent(EXTENT_TEST, &w, &h, &d, &e);
|
hdc->GetTextExtent(EXTENT_TEST, &w, &h, &d, &e);
|
||||||
font.ascent = h - d;
|
const int ascent = h - d;
|
||||||
return font.ascent;
|
SetAscent(font, ascent);
|
||||||
|
return ascent;
|
||||||
}
|
}
|
||||||
|
|
||||||
XYPOSITION SurfaceImpl::Descent(Font &font) {
|
XYPOSITION SurfaceImpl::Descent(Font &font) {
|
||||||
|
@@ -255,9 +255,7 @@ struct FontParameters {
|
|||||||
class Font {
|
class Font {
|
||||||
protected:
|
protected:
|
||||||
FontID fid;
|
FontID fid;
|
||||||
#if PLAT_WX
|
|
||||||
int ascent;
|
|
||||||
#endif
|
|
||||||
// Private so Font objects can not be copied
|
// Private so Font objects can not be copied
|
||||||
Font(const Font &);
|
Font(const Font &);
|
||||||
Font &operator=(const Font &);
|
Font &operator=(const Font &);
|
||||||
@@ -271,9 +269,7 @@ public:
|
|||||||
FontID GetID() { return fid; }
|
FontID GetID() { return fid; }
|
||||||
// Alias another font - caller guarantees not to Release
|
// Alias another font - caller guarantees not to Release
|
||||||
void SetID(FontID fid_) { fid = fid_; }
|
void SetID(FontID fid_) { fid = fid_; }
|
||||||
#if PLAT_WX
|
|
||||||
void SetAscent(int ascent_) { ascent = ascent_; }
|
|
||||||
#endif
|
|
||||||
friend class Surface;
|
friend class Surface;
|
||||||
friend class SurfaceImpl;
|
friend class SurfaceImpl;
|
||||||
};
|
};
|
||||||
|
@@ -159,8 +159,5 @@ void Style::ClearTo(const Style &source) {
|
|||||||
|
|
||||||
void Style::Copy(Font &font_, const FontMeasurements &fm_) {
|
void Style::Copy(Font &font_, const FontMeasurements &fm_) {
|
||||||
font.MakeAlias(font_);
|
font.MakeAlias(font_);
|
||||||
#if PLAT_WX
|
|
||||||
font.SetAscent(fm_.ascent);
|
|
||||||
#endif
|
|
||||||
(FontMeasurements &)(*this) = fm_;
|
(FontMeasurements &)(*this) = fm_;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user