issues with font metrics in X11

git-svn-id: svn://ultimatepp.org/upp/trunk@6574 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2013-11-18 19:23:42 +00:00
parent bd9522418b
commit ff04f27147
7 changed files with 45 additions and 29 deletions

View file

@ -6,16 +6,11 @@ GUI_APP_MAIN
{
EditString es;
TopWindow win;
<<<<<<< .mine
String h;
h << "CCCCCCCC";
es <<= h;
=======
es <<= "CCCCCCCCCCCCCCC";
>>>>>>> .r5593
es <<= "devout eeeev";
es.AlignRight();
win.Add(es.HSizePos().TopPos(0, Ctrl::STDSIZE));
win.Run();
DDUMP(StoreAsXML(es));
DDUMP(StoreAsJson(es, true));
DUMP(StoreAsXML(es));
DUMP(StoreAsJson(es, true));
}

View file

@ -228,20 +228,22 @@ void SystemDraw::DrawTextOp(int x, int y, int angle, const wchar *text, Font fon
}
}
else {
if(dx) {
// if(dx) {
DLOG("------------");
int xpos = ox;
Buffer<XftCharSpec> ch(n);
for(int i = 0; i < n; i++) {
ch[i].ucs4 = text[i];
ch[i].x = xpos;
ch[i].y = oy + ascent;
xpos += dx[i];
DLOG((char)text[i] << ", " << font[text[i]] << ", " << xpos);
xpos += dx ? dx[i] : font[text[i]];
}
XftDrawCharSpec(xftdraw, &c, xftfont, ch, n);
}
else
XftDrawString16(xftdraw, &c, xftfont, ox, oy + ascent,
(FcChar16 *)text, n);
// }
// else
// XftDrawString16(xftdraw, &c, xftfont, ox, oy + ascent,
// (FcChar16 *)text, n);
LLOG("XftColor: r=" << c.color.red << ", g=" << c.color.green << ", b=" << c.color.blue
<< ", alpha=" << c.color.alpha << ", pixel=" << FormatIntHex(c.pixel));
if(font.IsUnderline() || font.IsStrikeout()) {

View file

@ -81,7 +81,7 @@ struct FontDataSysMaker : LRUCache<FontSysData, Tuple2<Font, int> >::Maker {
virtual int Make(FontSysData& object) const { object.Init(font, angle); return 1; }
};
int gtk_antialias = -1;
int gtk_antialias = -1; // These are not really used with GTK backed.....
int gtk_hinting = -1;
String gtk_hintstyle;
String gtk_rgba;
@ -100,8 +100,8 @@ void SystemDraw::DrawTextOp(int x, int y, int angle, const wchar *text, Font fon
for(int i = 0; i < n; i++) {
cairo_glyph_t& g = gs[i];
g.index = GetGlyphInfo(font, text[i]).glyphi;
g.x = fround(x + cosa * xpos + sina * ascent);
g.y = fround(y + cosa * ascent - sina * xpos);
g.x = int(x + cosa * xpos + sina * ascent);
g.y = int(y + cosa * ascent - sina * xpos);
xpos += dx ? dx[i] : font[text[i]];
}

View file

@ -320,6 +320,7 @@ void EditField::Paint(Draw& w)
}
int x = -sc;
bool ar = alignright && !HasFocus();
w.DrawRect(x, 0, sz.cx, fcy, paper);
if(IsNull(text) && (!IsNull(nulltext) || !IsNull(nullicon))) {
const wchar *txt = nulltext;
if(!IsNull(nullicon)) {
@ -361,8 +362,6 @@ void EditField::Paint(Draw& w)
b = i;
}
}
if(!ar)
w.DrawRect(x, 0, sz.cx - x, fcy, paper);
if(!no_internal_margin)
w.End();
DrawTiles(w, dropcaret, CtrlImg::checkers());

View file

@ -214,12 +214,12 @@ int TreeCtrl::Insert(int parentid, int i, const Image& img, Value v, Value t,
int TreeCtrl::Insert(int parentid, int i, const Image& img, Value key, const String& value, bool withopen)
{
return Insert(parentid, i, img, key, value, withopen);
return Insert(parentid, i, img, key, (Value)value, withopen);
}
int TreeCtrl::Insert(int parentid, int i, const Image& img, Value key, const char *value, bool withopen)
{
return Insert(parentid, i, img, key, value, withopen);
return Insert(parentid, i, img, key, (Value)value, withopen);
}
int TreeCtrl::Add(int parentid, const Image& img, Value v, bool withopen)
@ -234,12 +234,12 @@ int TreeCtrl::Add(int parentid, const Image& img, Value v, Value t, bool with
int TreeCtrl::Add(int parentid, const Image& img, Value key, const String& value, bool withopen)
{
return Add(parentid, img, key, value, withopen);
return Add(parentid, img, key, (Value)value, withopen);
}
int TreeCtrl::Add(int parentid, const Image& img, Value key, const char *value, bool withopen)
{
return Add(parentid, img, key, value, withopen);
return Add(parentid, img, key, (Value)value, withopen);
}
int TreeCtrl::Insert(int parentid, int i, const Image& img, Ctrl& ctrl, int cx, int cy, bool withopen)

View file

@ -170,10 +170,21 @@ nt]_[* Insert]([@(0.0.255) int]_[*@3 parentid], [@(0.0.255) int]_[*@3 i],
[@(0.0.255) const]_[_^Image^ Image][@(0.0.255) `&]_[*@3 img], [_^Ctrl^ Ctrl][@(0.0.255) `&]_[*@3 c
], [@(0.0.255) int]_[*@3 cx]_`=_[@3 0], [@(0.0.255) int]_[*@3 cy]_`=_[@3 0],
[@(0.0.255) bool]_[*@3 wo]_`=_[@(0.0.255) false])&]
[s5;:TreeCtrl`:`:Insert`(int`,int`,const Image`&`,Value`,const String`&`,bool`): [@(0.0.255) i
nt]_[* Insert]([@(0.0.255) int]_[*@3 parentid], [@(0.0.255) int]_[*@3 i],
[@(0.0.255) const]_[_^Image^ Image][@(0.0.255) `&]_[*@3 img], [_^Value^ Value]_[*@3 key],
[@(0.0.255) const]_[_^String^ String][@(0.0.255) `&]_[*@3 value], [@(0.0.255) bool]_[*@3 with
open]_`=_[@(0.0.255) false])&]
[s5;:TreeCtrl`:`:Insert`(int`,int`,const Image`&`,Value`,const char`*`,bool`): [@(0.0.255) i
nt]_[* Insert]([@(0.0.255) int]_[*@3 parentid], [@(0.0.255) int]_[*@3 i],
[@(0.0.255) const]_[_^Image^ Image][@(0.0.255) `&]_[*@3 img], [_^Value^ Value]_[*@3 key],
[@(0.0.255) const]_[@(0.0.255) char]_`*[*@3 value], [@(0.0.255) bool]_[*@3 withopen]_`=_[@(0.0.255) f
alse])&]
[s2; Inserts child item to parent specified by id. Distinct variants
set various attributes to TreeCtrl`::Node of insterted item. Returns
id of new item.&]
[s3; &]
id of new item. Note: Last two overloads are to avoid overloading
ambiguity.&]
[s3;%% &]
[s4; &]
[s5;:TreeCtrl`:`:Add`(int`,const TreeCtrl`:`:Node`&`): [@(0.0.255) int]_[* Add]([@(0.0.255) i
nt]_[*@3 parentid], [@(0.0.255) const]_[_^TreeCtrl`:`:Node^ TreeCtrl`::Node][@(0.0.255) `&
@ -190,9 +201,18 @@ _[@(0.0.255) false])&]
dd]([@(0.0.255) int]_[*@3 parentid], [@(0.0.255) const]_[_^Image^ Image][@(0.0.255) `&]_[*@3 i
mg], [_^Ctrl^ Ctrl][@(0.0.255) `&]_[*@3 ctrl], [@(0.0.255) int]_[*@3 cx]_`=_[@3 0],
[@(0.0.255) int]_[*@3 cy]_`=_[@3 0], [@(0.0.255) bool]_[*@3 withopen]_`=_[@(0.0.255) false])&]
[s5;:TreeCtrl`:`:Add`(int`,const Image`&`,Value`,const String`&`,bool`): [@(0.0.255) in
t]_[* Add]([@(0.0.255) int]_[*@3 parentid], [@(0.0.255) const]_[_^Image^ Image][@(0.0.255) `&
]_[*@3 img], [_^Value^ Value]_[*@3 key], [@(0.0.255) const]_[_^String^ String][@(0.0.255) `&]_
[*@3 value], [@(0.0.255) bool]_[*@3 withopen]_`=_[@(0.0.255) false])&]
[s5;:TreeCtrl`:`:Add`(int`,const Image`&`,Value`,const char`*`,bool`): [@(0.0.255) int]_
[* Add]([@(0.0.255) int]_[*@3 parentid], [@(0.0.255) const]_[_^Image^ Image][@(0.0.255) `&]_[*@3 i
mg], [_^Value^ Value]_[*@3 key], [@(0.0.255) const]_[@(0.0.255) char]_`*[*@3 value],
[@(0.0.255) bool]_[*@3 withopen]_`=_[@(0.0.255) false])&]
[s2; Inserts child item at the end of list of parent`'s child items.
Parent is specified by id. Distinct variants set various attributes
to TreeCtrl`::Node of insterted item. Returns id of new item.&]
to TreeCtrl`::Node of insterted item. Returns id of new item.
Note: Last two overloads are to avoid overloading ambiguity.&]
[s3; &]
[s4; &]
[s5;:TreeCtrl`:`:Remove`(int`): [@(0.0.255) void]_[* Remove]([@(0.0.255) int]_[*@3 id])&]

View file

@ -206,8 +206,8 @@ GlyphInfo GetGlyphInfoSys(Font font, int chr)
LTIMING("GetGlyphInfoSys 2");
int glyph_index = FT_Get_Char_Index(face, chr);
if(glyph_index) {
if(GetGlyphInfoSysXft)
return (*GetGlyphInfoSysXft)(font, chr);
// if(GetGlyphInfoSysXft)
// return (*GetGlyphInfoSysXft)(font, chr);
if(FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT|FT_LOAD_NO_BITMAP) == 0 ||
FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT) == 0) {
FT_Glyph_Metrics& m = face->glyph->metrics;