Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWolfgang Steffens <WolfgangSteff@gmail.com>2011-02-21 11:58:46 +0300
committerXTZGZoReX <xtzgzorex@gmail.com>2011-04-23 19:29:37 +0400
commit4cb5ea5759900408245b61d2472e50c9dbab2330 (patch)
tree114e799513d023e439af31ca3654947b9f2d131f /mcs/class/Mono.Cairo
parent247d3b7f6d38a64dd8523b8fa57f1a7174442d80 (diff)
added less overhead version of TerminateUtf8 for string versions
Signed-off-by: XTZGZoReX <xtzgzorex@gmail.com>
Diffstat (limited to 'mcs/class/Mono.Cairo')
-rw-r--r--mcs/class/Mono.Cairo/Mono.Cairo/Context.cs17
1 files changed, 14 insertions, 3 deletions
diff --git a/mcs/class/Mono.Cairo/Mono.Cairo/Context.cs b/mcs/class/Mono.Cairo/Mono.Cairo/Context.cs
index d908c275c93..5d6b7679aac 100644
--- a/mcs/class/Mono.Cairo/Mono.Cairo/Context.cs
+++ b/mcs/class/Mono.Cairo/Mono.Cairo/Context.cs
@@ -880,9 +880,18 @@ namespace Cairo {
return termedArray;
}
+ private static byte[] TerminateUtf8(string s)
+ {
+ // compute the byte count including the trailing \0
+ var byteCount = Encoding.UTF8.GetMaxByteCount(s.Length + 1);
+ var bytes = new byte[byteCount];
+ Encoding.UTF8.GetBytes(s, 0, s.Length, bytes, 0);
+ return bytes;
+ }
+
public void ShowText(string str)
{
- ShowText(Encoding.UTF8.GetBytes(str));
+ NativeMethods.cairo_show_text(state, TerminateUtf8(str));
}
public void ShowText(byte[] utf8)
@@ -892,7 +901,7 @@ namespace Cairo {
public void TextPath(string str)
{
- TextPath(Encoding.UTF8.GetBytes(str));
+ NativeMethods.cairo_text_path(state, TerminateUtf8(str));
}
public void TextPath(byte[] utf8)
@@ -902,7 +911,9 @@ namespace Cairo {
public TextExtents TextExtents(string s)
{
- return TextExtents(Encoding.UTF8.GetBytes(s));
+ TextExtents extents;
+ NativeMethods.cairo_text_extents(state, TerminateUtf8(s), out extents);
+ return extents;
}
public TextExtents TextExtents(byte[] utf8)