Пример #1
0
        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
 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);
 }