コード例 #1
0
ファイル: Nuklear.cs プロジェクト: raizam/NuklearSharp
        public float text_width(NkHandle h, float height, char *s, int length)
        {
            char  unicode;
            int   textLen;
            float textWidth = 0;

            if (s == null || length == 0)
            {
                return(0);
            }
            var scale    = height / Info.height;
            var glyphLen = textLen = Nk.nk_utf_decode(s, &unicode, length);

            if (glyphLen == 0)
            {
                return(0);
            }
            while (textLen <= length && glyphLen != 0)
            {
                if (unicode == 0xFFFD)
                {
                    break;
                }
                var g = Nk.nk_font_find_glyph(this, unicode);
                textWidth += g->xadvance * scale;
                glyphLen   = Nk.nk_utf_decode(s + textLen, &unicode, length - textLen);
                textLen   += glyphLen;
            }
            return(textWidth);
        }
コード例 #2
0
        public static NkImage nk_image_handle(NkHandle handle)
        {
            NkImage s = new NkImage();

            s.handle    = (NkHandle)(handle);
            s.w         = (ushort)(0);
            s.h         = (ushort)(0);
            s.region[0] = (ushort)(0);
            s.region[1] = (ushort)(0);
            s.region[2] = (ushort)(0);
            s.region[3] = (ushort)(0);
            return((NkImage)(s));
        }
コード例 #3
0
        public static NkImage nk_subimage_handle(NkHandle handle, ushort w, ushort h, NkRect r)
        {
            NkImage s = new NkImage();

            s.handle    = (NkHandle)(handle);
            s.w         = (ushort)(w);
            s.h         = (ushort)(h);
            s.region[0] = ((ushort)(r.x));
            s.region[1] = ((ushort)(r.y));
            s.region[2] = ((ushort)(r.w));
            s.region[3] = ((ushort)(r.h));
            return((NkImage)(s));
        }
コード例 #4
0
 public static void nk_mfree(NkHandle unused, void *ptr)
 {
     CRuntime.Free(ptr);
 }
コード例 #5
0
 public static void *nk_malloc(NkHandle unused, void *old, ulong size)
 {
     return(CRuntime.Malloc((ulong)(size)));
 }
コード例 #6
0
ファイル: Nuklear.cs プロジェクト: raizam/NuklearSharp
 public void query_font_glyph(NkHandle h, float height, NkUserFontGlyph *glyph, char codepoint,
                              char nextCodepoint)
 {
     Nk.nk_font_query_font_glyph(this, height, glyph, codepoint, nextCodepoint);
 }