From: JP Bruyère Date: Sun, 24 Jul 2016 03:51:46 +0000 (+0200) Subject: Removed Utf16->Utf8 conversion on Win os, so Mono framework, which use X-Git-Tag: v0.4~38 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=572eb59e01e61f597485b21c2dc06ccbd10fa719;p=jp%2Fcrow.git Removed Utf16->Utf8 conversion on Win os, so Mono framework, which use Utf8 for string encoding on every os becomes mandatory. modified: src/GraphicObjects/Label.cs modified: src/GraphicObjects/TextRun.cs --- diff --git a/src/GraphicObjects/Label.cs b/src/GraphicObjects/Label.cs index 22a60aa0..6831a9cc 100644 --- a/src/GraphicObjects/Label.cs +++ b/src/GraphicObjects/Label.cs @@ -364,11 +364,8 @@ namespace Crow foreach (string s in lines) { string l = s.Replace("\t", new String (' ', Interface.TabSize)); -#if _WIN32 || _WIN64 - TextExtents tmp = gr.TextExtents(str.ToUtf8()); -#elif __linux__ TextExtents tmp = gr.TextExtents (l); -#endif + if (tmp.XAdvance > te.XAdvance) te = tmp; } @@ -562,12 +559,7 @@ namespace Crow Foreground.SetAsSource (gr); gr.MoveTo (lineRect.X, rText.Y + fe.Ascent + fe.Height * i); - - #if _WIN32 || _WIN64 - gr.ShowText(l.ToUtf8()); - #elif __linux__ gr.ShowText (l); - #endif gr.Fill (); } } @@ -656,12 +648,8 @@ namespace Crow if (c == "\t") c = new string (' ', Interface.TabSize); - #if _WIN32 || _WIN64 - byte[] c = System.Text.UTF8Encoding.UTF8.GetBytes(Text.Substring(i, 1)); te = gr.TextExtents(c); - #elif __linux__ - te = gr.TextExtents(c); - #endif + double halfWidth = te.XAdvance / 2; if (mouseLocalPos.X <= cPos + halfWidth) diff --git a/src/GraphicObjects/TextRun.cs b/src/GraphicObjects/TextRun.cs index 103f2fcf..6af22025 100644 --- a/src/GraphicObjects/TextRun.cs +++ b/src/GraphicObjects/TextRun.cs @@ -155,12 +155,7 @@ namespace Crow foreach (string s in lines) { string l = s.Replace("\t", new String (' ', Interface.TabSize)); - - #if _WIN32 || _WIN64 - TextExtents tmp = gr.TextExtents(str.ToUtf8()); - #elif __linux__ TextExtents tmp = gr.TextExtents (l); - #endif if (tmp.XAdvance > te.XAdvance) te = tmp; } @@ -287,15 +282,10 @@ namespace Crow Foreground.SetAsSource (gr); gr.MoveTo (rText.X, rText.Y + fe.Ascent + fe.Height * curLineCount); - #if _WIN32 || _WIN64 - gr.ShowText(ll.ToUtf8()); - #elif __linux__ gr.ShowText (ll); - #endif gr.Fill (); curLineCount++; - } } }