Пример #1
0
        public unsafe bool TryGetGlyphName(uint glyph, out string name)
        {
            var buffer = ArrayPool <char> .Shared.Rent(NameBufferLength);

            try
            {
                fixed(char *first = buffer)
                {
                    if (!HarfBuzzApi.hb_font_get_glyph_name(Handle, glyph, first, buffer.Length))
                    {
                        name = string.Empty;
                        return(false);
                    }
                    name = new string (first);
                    return(true);
                }
            } finally {
                ArrayPool <char> .Shared.Return(buffer);
            }
        }
Пример #2
0
        public unsafe bool TryGetGlyphName(uint glyph, out string name)
        {
            var buffer = ArrayPool <byte> .Shared.Rent(NameBufferLength);

            try
            {
                fixed(byte *first = buffer)
                {
                    if (!HarfBuzzApi.hb_font_get_glyph_name(Handle, glyph, first, buffer.Length))
                    {
                        name = string.Empty;
                        return(false);
                    }
                    name = Marshal.PtrToStringAnsi((IntPtr)first);
                    return(true);
                }
            } finally {
                ArrayPool <byte> .Shared.Return(buffer);
            }
        }