示例#1
0
        public FreeTypeSource(byte[] data)
        {
            Error err;

            if (_libraryHandle == IntPtr.Zero)
            {
                IntPtr libraryRef;
                err = FTNative.FT_Init_FreeType(out libraryRef);

                if (err != Error.Ok)
                {
                    throw new FreeTypeException(err);
                }

                _libraryHandle = libraryRef;
            }

            _memoryHandle = GCHandle.Alloc(data, GCHandleType.Pinned);

            IntPtr faceRef;

            err = FTNative.FT_New_Memory_Face(_libraryHandle, _memoryHandle.AddrOfPinnedObject(), data.Length, 0, out faceRef);

            if (err != Error.Ok)
            {
                throw new FreeTypeException(err);
            }

            _faceHandle = faceRef;
            _rec        = PInvokeHelper.PtrToStructure <FaceRec>(_faceHandle);
        }
示例#2
0
        public void GetMetricsForSize(int fontSize, out int ascent, out int descent, out int lineHeight)
        {
            SetPixelSizes(0, fontSize);
            var sizeRec = PInvokeHelper.PtrToStructure <SizeRec>(_rec.size);

            ascent     = (int)sizeRec.metrics.ascender >> 6;
            descent    = (int)sizeRec.metrics.descender >> 6;
            lineHeight = (int)sizeRec.metrics.height >> 6;
        }
示例#3
0
 private void GetCurrentGlyph(out GlyphSlotRec glyph)
 {
     glyph = PInvokeHelper.PtrToStructure <GlyphSlotRec>(_rec.glyph);
 }