From ff04f27147b177e8ea41eda96d35fb22d48619e2 Mon Sep 17 00:00:00 2001 From: cxl Date: Mon, 18 Nov 2013 19:23:42 +0000 Subject: [PATCH] issues with font metrics in X11 git-svn-id: svn://ultimatepp.org/upp/trunk@6574 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppdev/EditString/main.cpp | 13 ++++-------- uppsrc/CtrlCore/DrawTextX11.cpp | 14 ++++++------ uppsrc/CtrlCore/GtkDrawText.cpp | 6 +++--- uppsrc/CtrlLib/EditField.cpp | 3 +-- uppsrc/CtrlLib/TreeCtrl.cpp | 8 +++---- uppsrc/CtrlLib/src.tpp/TreeCtrl$en-us.tpp | 26 ++++++++++++++++++++--- uppsrc/Draw/FontFc.cpp | 4 ++-- 7 files changed, 45 insertions(+), 29 deletions(-) diff --git a/uppdev/EditString/main.cpp b/uppdev/EditString/main.cpp index 1c7dd17d6..f8da29d9b 100644 --- a/uppdev/EditString/main.cpp +++ b/uppdev/EditString/main.cpp @@ -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)); } diff --git a/uppsrc/CtrlCore/DrawTextX11.cpp b/uppsrc/CtrlCore/DrawTextX11.cpp index f4869b46c..453af563f 100644 --- a/uppsrc/CtrlCore/DrawTextX11.cpp +++ b/uppsrc/CtrlCore/DrawTextX11.cpp @@ -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 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()) { diff --git a/uppsrc/CtrlCore/GtkDrawText.cpp b/uppsrc/CtrlCore/GtkDrawText.cpp index 414dfd38d..158852185 100644 --- a/uppsrc/CtrlCore/GtkDrawText.cpp +++ b/uppsrc/CtrlCore/GtkDrawText.cpp @@ -81,7 +81,7 @@ struct FontDataSysMaker : LRUCache >::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]]; } diff --git a/uppsrc/CtrlLib/EditField.cpp b/uppsrc/CtrlLib/EditField.cpp index 53acff934..51a891d38 100644 --- a/uppsrc/CtrlLib/EditField.cpp +++ b/uppsrc/CtrlLib/EditField.cpp @@ -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()); diff --git a/uppsrc/CtrlLib/TreeCtrl.cpp b/uppsrc/CtrlLib/TreeCtrl.cpp index 2cbffa49b..54011bf1d 100644 --- a/uppsrc/CtrlLib/TreeCtrl.cpp +++ b/uppsrc/CtrlLib/TreeCtrl.cpp @@ -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) diff --git a/uppsrc/CtrlLib/src.tpp/TreeCtrl$en-us.tpp b/uppsrc/CtrlLib/src.tpp/TreeCtrl$en-us.tpp index 741113fea..9a77517d3 100644 --- a/uppsrc/CtrlLib/src.tpp/TreeCtrl$en-us.tpp +++ b/uppsrc/CtrlLib/src.tpp/TreeCtrl$en-us.tpp @@ -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])&] diff --git a/uppsrc/Draw/FontFc.cpp b/uppsrc/Draw/FontFc.cpp index 4a29f587d..935a2faaf 100644 --- a/uppsrc/Draw/FontFc.cpp +++ b/uppsrc/Draw/FontFc.cpp @@ -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;