示例#1
0
        public override string ToString()
        {
            var cstr = SkiaApi.sk_string_get_c_str(Handle);
            var clen = SkiaApi.sk_string_get_size(Handle);

            return(StringUtilities.GetString(cstr, (int)clen, SKTextEncoding.Utf8));
        }
示例#2
0
        public long BreakText(string text, float maxWidth, out float measuredWidth, out string measuredText)
        {
            if (text == null)
            {
                throw new ArgumentNullException(nameof(text));
            }
            var bytes      = StringUtilities.GetEncodedText(text, TextEncoding);
            var byteLength = (int)SkiaApi.sk_paint_break_text(Handle, bytes, (IntPtr)bytes.Length, maxWidth, out measuredWidth);

            if (byteLength == 0)
            {
                measuredText = String.Empty;
                return(0);
            }
            if (byteLength == bytes.Length)
            {
                measuredText = text;
                return(text.Length);
            }
            measuredText = StringUtilities.GetString(bytes, 0, byteLength, TextEncoding);
            return(measuredText.Length);
        }