예제 #1
0
        fd_Outline fd_outline_convert(FT_Outline outline, char c)
        {
            if (c == '&')
            {
                Console.WriteLine("");
            }

            var o = fd_outline_decompose(outline);
            //fd_outline_fix_corners(o);
            //fd_outline_subdivide(o);
            var dst = fd_OutlineExtensions.fd_outline_fix_thin_lines(o);

            dst = fd_OutlineExtensions.fd_outline_make_cells(dst);
            //}

            return(dst);
            //printf("  %d ms\n", clock() - t);
        }
예제 #2
0
        fd_Outline fd_outline_decompose(FT_Outline src)
        {
            var o = new fd_Outline();

            if (Form == LongForm.Long4)
            {
                var bbox4 = new FT_BBox4();
                var err   = FT_Outline_Get_BBox_4(ref src, ref bbox4);
                if (err != FT_Error.Ok)
                {
                    throw new InvalidOperationException("FT_Outline_Get_BBox_4 failed");
                }

                o.bbox = new fd_Rect
                {
                    min_x = (float)bbox4.xMin / 64.0f,
                    min_y = (float)bbox4.yMin / 64.0f,
                    max_x = (float)bbox4.xMax / 64.0f,
                    max_y = (float)bbox4.yMax / 64.0f,
                };

                var funcs = new FT_Outline_Funcs_4
                {
                    move_to  = Marshal.GetFunctionPointerForDelegate <MoveToFunc_4>(o.MoveTo_4),
                    line_to  = Marshal.GetFunctionPointerForDelegate <LineToFunc_4>(o.LineTo_4),
                    conic_to = Marshal.GetFunctionPointerForDelegate <ConicToFunc_4>(o.ConicTo_4),
                    cubic_to = Marshal.GetFunctionPointerForDelegate <CubicToFunc_4>(o.CubicTo_4),
                };

                err = FT_Outline_Decompose_4(ref src, ref funcs, IntPtr.Zero);
                if (err != FT_Error.Ok)
                {
                    throw new InvalidOperationException("FT_Outline_Decompose_4 failed");
                }
            }
            else
            {
                var bbox8 = new FT_BBox8();
                var err   = FT_Outline_Get_BBox_8(ref src, ref bbox8);
                if (err != FT_Error.Ok)
                {
                    throw new InvalidOperationException("FT_Outline_Get_BBox_8 failed");
                }

                o.bbox = new fd_Rect
                {
                    min_x = (float)bbox8.xMin / 64.0f,
                    min_y = (float)bbox8.yMin / 64.0f,
                    max_x = (float)bbox8.xMax / 64.0f,
                    max_y = (float)bbox8.yMax / 64.0f,
                };

                var funcs = new FT_Outline_Funcs_8
                {
                    move_to  = Marshal.GetFunctionPointerForDelegate <MoveToFunc_8>(o.MoveTo_8),
                    line_to  = Marshal.GetFunctionPointerForDelegate <LineToFunc_8>(o.LineTo_8),
                    conic_to = Marshal.GetFunctionPointerForDelegate <ConicToFunc_8>(o.ConicTo_8),
                    cubic_to = Marshal.GetFunctionPointerForDelegate <CubicToFunc_8>(o.CubicTo_8),
                };

                err = FT_Outline_Decompose_8(ref src, ref funcs, IntPtr.Zero);

                if (err != FT_Error.Ok)
                {
                    throw new InvalidOperationException("FT_Outline_Decompose_4 failed");
                }
            }

            if (o.contours.Count > 0)
            {
                o.contours[o.contours.Count - 1].end = (uint)o.points.Count - 1;
            }

            return(o);
        }
예제 #3
0
 static extern FT_Error FT_Outline_Decompose_8(
     ref FT_Outline face,
     ref FT_Outline_Funcs_8 func_interface,
     IntPtr user);
예제 #4
0
 static extern FT_Error FT_Outline_Get_BBox_8(ref FT_Outline face, ref FT_BBox8 bbox);