#region MIT License /*Copyright (c) 2012 Robert Rouhani SharpFont based on Tao.FreeType, Copyright (c) 2003-2007 Tao Framework Team Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ #endregion using System; using System.Runtime.InteropServices; using SharpFont.Internal; namespace SharpFont { /// /// A function pointer type used to describe the signature of a ‘move to’ function during outline /// walking/decomposition. /// /// A ‘move to’ is emitted to start a new contour in an outline. /// /// A pointer to the target point of the ‘move to’. /// A typeless pointer which is passed from the caller of the decomposition function. /// Error code. 0 means success. [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate int MoveToFunc(FTVector to, IntPtr user); /// /// A function pointer type used to describe the signature of a ‘line to’ function during outline /// walking/decomposition. /// /// A ‘line to’ is emitted to indicate a segment in the outline. /// /// A pointer to the target point of the ‘line to’. /// A typeless pointer which is passed from the caller of the decomposition function. /// Error code. 0 means success. [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate int LineToFunc(FTVector to, IntPtr user); /// /// A function pointer type used to describe the signature of a ‘conic to’ function during outline walking or /// decomposition. /// /// A ‘conic to’ is emitted to indicate a second-order Bézier arc in the outline. /// /// /// An intermediate control point between the last position and the new target in ‘to’. /// /// A pointer to the target end point of the conic arc. /// A typeless pointer which is passed from the caller of the decomposition function. /// Error code. 0 means success. [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate int ConicToFunc(FTVector control, FTVector to, IntPtr user); /// /// A function pointer type used to describe the signature of a ‘cubic to’ function during outline walking or /// decomposition. /// /// A ‘cubic to’ is emitted to indicate a third-order Bézier arc. /// /// A pointer to the first Bézier control point. /// A pointer to the second Bézier control point. /// A pointer to the target end point. /// A typeless pointer which is passed from the caller of the decomposition function. /// Error code. 0 means success. [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate int CubicToFunc(FTVector control1, FTVector control2, FTVector to, IntPtr user); /// /// A structure to hold various function pointers used during outline decomposition in order to emit segments, /// conic, and cubic Béziers. /// /// /// The point coordinates sent to the emitters are the transformed version of the original coordinates (this is /// important for high accuracy during scan-conversion). The transformation is simple: /// /// x' = (x << shift) - delta /// y' = (x << shift) - delta /// /// Set the values of ‘shift’ and ‘delta’ to 0 to get the original point coordinates. /// public class OutlineFuncs { private OutlineFuncsRec rec; /// /// Initializes a new instance of the OutlineFuncs class. /// public OutlineFuncs() { } /// /// Initializes a new instance of the OutlineFuncs class. /// /// The move to delegate. /// The line to delegate. /// The conic to delegate. /// The cubic to delegate. /// A value to shift by. /// A delta to transform by. public OutlineFuncs(MoveToFunc moveTo, LineToFunc lineTo, ConicToFunc conicTo, CubicToFunc cubicTo, int shift, int delta) { rec.moveTo = moveTo; rec.lineTo = lineTo; rec.conicTo = conicTo; rec.cubicTo = cubicTo; rec.shift = shift; #if WIN64 rec.delta = delta; #else rec.delta = (IntPtr)delta; #endif } /// /// Gets or sets the ‘move to’ emitter. /// public MoveToFunc MoveFunction { get { return rec.moveTo; } set { rec.moveTo = value; } } /// /// Gets or sets the segment emitter. /// public LineToFunc LineFuction { get { return rec.lineTo; } set { rec.lineTo = value; } } /// /// Gets or sets the second-order Bézier arc emitter. /// public ConicToFunc ConicFunction { get { return rec.conicTo; } set { rec.conicTo = value; } } /// /// Gets or sets the third-order Bézier arc emitter. /// public CubicToFunc CubicFunction { get { return rec.cubicTo; } set { rec.cubicTo = value; } } /// /// Gets or sets the shift that is applied to coordinates before they are sent to the emitter. /// public int Shift { get { return rec.shift; } set { rec.shift = value; } } /// /// Gets the delta that is applied to coordinates before they are sent to the emitter, but after the /// shift. /// public int Delta { get { return (int)rec.delta; } /*set { funcsInt.delta = (IntPtr)value; }*/ } } }