blob: 94b94f564f4082df1f05028a3e03686b24736f40 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
// Copyright (c) 2018-2021 Jean-Philippe Bruyère <jp_bruyere@hotmail.com>
//
// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
using System;
using Drawing2D;
namespace Crow.VkvgBackend
{
public class TextRun : IDisposable {
IntPtr handle = IntPtr.Zero;
#region CTORS & DTOR
protected TextRun(IntPtr handle) {
this.handle = handle;
}
public TextRun(string text) {
handle = NativeMethods.vkvg_text_run_create (handle, Context.TerminateUtf8(text));
}
~TextRun() {
Dispose (false);
}
#endregion
//public void AddReference () {
// NativeMethods.vkvg_pattern_reference (handle);
//}
//public uint References () => NativeMethods.vkvg_pattern_get_reference_count (handle);
public IntPtr Handle { get { return handle; } }
public Drawing2D.TextExtents Extents {
get {
NativeMethods.vkvg_text_run_get_extents (handle, out TextExtents e);
return new Drawing2D.TextExtents (e.XBearing, e.YBearing, e.Width, e.Height, e.XAdvance, e.YAdvance);
}
}
#region IDisposable implementation
public void Dispose () {
Dispose (true);
GC.SuppressFinalize (this);
}
protected virtual void Dispose (bool disposing) {
if (!disposing || handle == IntPtr.Zero)
return;
NativeMethods.vkvg_text_run_destroy (handle);
handle = IntPtr.Zero;
}
#endregion
}
}
|