mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
Draw, CtrlLib, ide: Fixed problem with GetAveWidth being unreliable
git-svn-id: svn://ultimatepp.org/upp/trunk@15842 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
c19b5b1421
commit
95fb7897ec
5 changed files with 24 additions and 11 deletions
|
|
@ -71,8 +71,7 @@ LineEdit& LineEdit::SetFont(Font f) {
|
|||
}
|
||||
|
||||
Size LineEdit::GetFontSize() const {
|
||||
FontInfo fi = font.Info();
|
||||
return Size(max(fi['M'], fi['W']), fi.GetHeight());
|
||||
return Size(font.GetMonoWidth(), font.GetHeight());
|
||||
}
|
||||
|
||||
void LineEdit::SetRectSelection(int64 anchor, int64 cursor)
|
||||
|
|
|
|||
|
|
@ -162,6 +162,7 @@ public:
|
|||
int GetOverhang() const { return Fi().overhang; }
|
||||
int GetAveWidth() const { return Fi().avewidth; }
|
||||
int GetMaxWidth() const { return Fi().maxwidth; }
|
||||
int GetMonoWidth() const { return max(GetWidth('M'), GetWidth('W')); }
|
||||
bool IsNormal(int ch) const;
|
||||
bool IsComposed(int ch) const;
|
||||
bool IsReplaced(int ch) const;
|
||||
|
|
|
|||
|
|
@ -276,11 +276,26 @@ of text.&]
|
|||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:Font`:`:GetAveWidth`(`)const: [@(0.0.255) int]_[* GetAveWidth]()_[@(0.0.255) const]&]
|
||||
[s2;%% Returns the average width of character.&]
|
||||
[s2;%% Returns the average width of character. Depends on information
|
||||
from the font provider, which is not always reliable `- it is
|
||||
better the obtain the spacing info from the width of individual
|
||||
glyphs.&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:Font`:`:GetMaxWidth`(`)const: [@(0.0.255) int]_[* GetMaxWidth]()_[@(0.0.255) const]&]
|
||||
[s2;%% Returns the maximal width of character.&]
|
||||
[s2;%% Returns the maximal width of character. Depends on information
|
||||
from the font provider, which is not always reliable `- it is
|
||||
better the obtain the spacing info from the width of individual
|
||||
glyphs.&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:Upp`:`:Font`:`:GetMonoWidth`(`)const: [@(0.0.255) int]_[* GetMonoWidth]()_[@(0.0.255) c
|
||||
onst]&]
|
||||
[s2;%% Returns supposed width of character cell if the font is (or
|
||||
is considered) monospace. This is the method used in LineEdit
|
||||
to determine cell width. Currently, max(GetWidth(`'M`'), GetWidth(`'W`'))
|
||||
value is used as GetAveWidth and GetMaxWidth using the information
|
||||
from the font metadata is unreliable.&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:Font`:`:IsNormal`(int`)const: [@(0.0.255) bool]_[* IsNormal]([@(0.0.255) int]_[@3 ch])_[@(0.0.255) c
|
||||
|
|
|
|||
|
|
@ -391,12 +391,10 @@ void TextCompareCtrl::SetFont(Font f, Font nf)
|
|||
{
|
||||
font = f;
|
||||
number_font = nf;
|
||||
FontInfo fi = f.Info();
|
||||
FontInfo ni = nf.Info();
|
||||
letter.cy = fi.GetHeight();
|
||||
letter.cx = fi.GetAveWidth();
|
||||
number_width = 5 * ni.GetAveWidth();
|
||||
number_yshift = (fi.GetHeight() - ni.GetHeight() + 2) >> 1;
|
||||
letter.cy = f.GetHeight();
|
||||
letter.cx = f.GetMonoWidth();
|
||||
number_width = 5 * nf.GetMonoWidth();
|
||||
number_yshift = (f.GetHeight() - nf.GetHeight() + 2) >> 1;
|
||||
Layout();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ void Console::Append(const String& s) {
|
|||
SetEditable();
|
||||
MoveTextEnd();
|
||||
WString t = Filter(s, sAppf).ToWString();
|
||||
int mg = max(40, sb.GetReducedViewSize().cx / GetFont().GetAveWidth());
|
||||
int mg = max(40, sb.GetReducedViewSize().cx / GetFontSize().cx);
|
||||
if(wrap_text && mg > 4) {
|
||||
int x = GetColumnLine(GetCursor32()).x;
|
||||
WStringBuffer tt;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue