aboutsummaryrefslogtreecommitdiffstatsci
diff options
context:
space:
mode:
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>2021-02-01 14:56:00 +0100
committerj-p <jp_bruyere@hotmail.com>2021-02-06 20:28:02 +0100
commit3d09f3bd6062d9a0f36693541192bc014376fa76 (patch)
tree969d94777f39317fbd7bafac9b0487fce854244d
parenta6373abaaae947ea87a8f037a5fb81ba32f311a6 (diff)
dont fix utf8 ref char, it's fixed by marshaler
-rw-r--r--Crow/src/Mono.Cairo/Context.cs29
1 files changed, 7 insertions, 22 deletions
diff --git a/Crow/src/Mono.Cairo/Context.cs b/Crow/src/Mono.Cairo/Context.cs
index 45600929..9253424e 100644
--- a/Crow/src/Mono.Cairo/Context.cs
+++ b/Crow/src/Mono.Cairo/Context.cs
@@ -884,17 +884,10 @@ namespace Crow.Cairo {
Span<byte> bytes = size > 512 ? new byte[size] : stackalloc byte[size];
int encodedBytes = Crow.Text.Encoding.ToUtf8 (s, bytes, tabSize);
bytes[encodedBytes] = 0;
-
- NativeMethods.cairo_show_text (handle, ref bytes.Slice (0, encodedBytes + 1).GetPinnableReference ());
+ ShowText (bytes.Slice (0, encodedBytes + 1));
}
public TextExtents TextExtents (ReadOnlySpan<char> s, int tabSize) {
- TextExtents extents;
- int size = s.Length * 4 + 1;
- Span<byte> bytes = size > 512 ? new byte[size] : stackalloc byte[size];
- int encodedBytes = Crow.Text.Encoding.ToUtf8 (s, bytes, tabSize);
- bytes[encodedBytes] = 0;
-
- NativeMethods.cairo_text_extents (handle, ref bytes.Slice (0, encodedBytes + 1).GetPinnableReference (), out extents);
+ TextExtents (s, tabSize, out TextExtents extents);
return extents;
}
public void TextExtents (ReadOnlySpan<char> s, int tabSize, out TextExtents extents) {
@@ -902,22 +895,14 @@ namespace Crow.Cairo {
Span<byte> bytes = size > 512 ? new byte[size] : stackalloc byte[size];
int encodedBytes = Crow.Text.Encoding.ToUtf8 (s, bytes, tabSize);
bytes[encodedBytes] = 0;
-
- NativeMethods.cairo_text_extents (handle, ref bytes.Slice (0, encodedBytes + 1).GetPinnableReference (), out extents);
+ TextExtents (bytes.Slice (0, encodedBytes + 1), out extents);
}
- public void TextExtents (ReadOnlySpan<char> s, out TextExtents extents) {
- int size = s.Length * 4 + 1;
- Span<byte> bytes = size > 512 ? new byte[size] : stackalloc byte[size];
- int encodedBytes = Crow.Text.Encoding.ToUtf8 (s, bytes);
- bytes[encodedBytes] = 0;
-
- NativeMethods.cairo_text_extents (handle, ref bytes.Slice (0, encodedBytes + 1).GetPinnableReference (), out extents);
+ public void ShowText (Span<byte> bytes) {
+ NativeMethods.cairo_show_text (handle, ref bytes.GetPinnableReference());
}
- public void ShowText (Span<byte> bytes) =>
- NativeMethods.cairo_show_text (handle, ref bytes.GetPinnableReference ());
- public void TextExtents (Span<byte> bytes, out TextExtents extents) =>
+ public void TextExtents (Span<byte> bytes, out TextExtents extents) {
NativeMethods.cairo_text_extents (handle, ref bytes.GetPinnableReference (), out extents);
-
+ }
public TextExtents GlyphExtents (Glyph[] glyphs)
{