SharpFont + ScalableFont implementation
https://github.com/Robmaister/SharpFont TODO: replace Code Bold.otf with the full version, fix any bugs, build on Linux, possibly move ToolBox string wrapping and limiting logic to ScalableFont class for better results.
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
#region MIT License
|
||||
/*Copyright (c) 2012-2015 Robert Rouhani <robert.rouhani@gmail.com>
|
||||
|
||||
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 FT_Long = System.IntPtr;
|
||||
using FT_ULong = System.UIntPtr;
|
||||
|
||||
namespace SharpFont.MultipleMasters.Internal
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct MMAxisRec
|
||||
{
|
||||
[MarshalAs(UnmanagedType.LPStr)]
|
||||
internal string name;
|
||||
|
||||
internal FT_Long minimum;
|
||||
internal FT_Long maximum;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
#region MIT License
|
||||
/*Copyright (c) 2012-2013 Robert Rouhani <robert.rouhani@gmail.com>
|
||||
|
||||
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;
|
||||
|
||||
namespace SharpFont.MultipleMasters.Internal
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct MMVarRec
|
||||
{
|
||||
internal uint num_axis;
|
||||
internal uint num_designs;
|
||||
internal uint num_namedstyles;
|
||||
internal IntPtr axis;
|
||||
internal IntPtr namedstyle;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
#region MIT License
|
||||
/*Copyright (c) 2012-2013 Robert Rouhani <robert.rouhani@gmail.com>
|
||||
|
||||
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;
|
||||
|
||||
namespace SharpFont.MultipleMasters.Internal
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct MultiMasterRec
|
||||
{
|
||||
internal uint num_axis;
|
||||
internal uint num_designs;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
internal MMAxisRec[] axis;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
#region MIT License
|
||||
/*Copyright (c) 2012-2015 Robert Rouhani <robert.rouhani@gmail.com>
|
||||
|
||||
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 FT_Long = System.IntPtr;
|
||||
using FT_ULong = System.UIntPtr;
|
||||
|
||||
namespace SharpFont.MultipleMasters.Internal
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct VarAxisRec
|
||||
{
|
||||
[MarshalAs(UnmanagedType.LPStr)]
|
||||
internal string name;
|
||||
|
||||
internal FT_Long minimum;
|
||||
internal FT_Long def;
|
||||
internal FT_Long maximum;
|
||||
|
||||
internal FT_ULong tag;
|
||||
internal uint strid;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
#region MIT License
|
||||
/*Copyright (c) 2012-2013 Robert Rouhani <robert.rouhani@gmail.com>
|
||||
|
||||
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;
|
||||
|
||||
namespace SharpFont.MultipleMasters.Internal
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct VarNamedStyleRec
|
||||
{
|
||||
internal IntPtr coords;
|
||||
internal uint strid;
|
||||
}
|
||||
}
|
||||
111
SharpFont/Source/SharpFontShared/MultipleMasters/MMAxis.cs
Normal file
111
SharpFont/Source/SharpFontShared/MultipleMasters/MMAxis.cs
Normal file
@@ -0,0 +1,111 @@
|
||||
#region MIT License
|
||||
/*Copyright (c) 2012-2013 Robert Rouhani <robert.rouhani@gmail.com>
|
||||
|
||||
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.MultipleMasters.Internal;
|
||||
|
||||
namespace SharpFont.MultipleMasters
|
||||
{
|
||||
/// <summary><para>
|
||||
/// A simple structure used to model a given axis in design space for Multiple Masters fonts.
|
||||
/// </para><para>
|
||||
/// This structure can't be used for GX var fonts.
|
||||
/// </para></summary>
|
||||
public class MMAxis
|
||||
{
|
||||
#region Fields
|
||||
|
||||
private IntPtr reference;
|
||||
private MMAxisRec rec;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
internal MMAxis(IntPtr reference)
|
||||
{
|
||||
Reference = reference;
|
||||
}
|
||||
|
||||
internal MMAxis(MMAxisRec axisInternal)
|
||||
{
|
||||
this.rec = axisInternal;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets the axis's name.
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return rec.name;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the axis's minimum design coordinate.
|
||||
/// </summary>
|
||||
public int Minimum
|
||||
{
|
||||
get
|
||||
{
|
||||
return (int)rec.minimum;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the axis's maximum design coordinate.
|
||||
/// </summary>
|
||||
public int Maximum
|
||||
{
|
||||
get
|
||||
{
|
||||
return (int)rec.maximum;
|
||||
}
|
||||
}
|
||||
|
||||
internal IntPtr Reference
|
||||
{
|
||||
get
|
||||
{
|
||||
return reference;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
reference = value;
|
||||
rec = PInvokeHelper.PtrToStructure<MMAxisRec>(reference);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
134
SharpFont/Source/SharpFontShared/MultipleMasters/MMVar.cs
Normal file
134
SharpFont/Source/SharpFontShared/MultipleMasters/MMVar.cs
Normal file
@@ -0,0 +1,134 @@
|
||||
#region MIT License
|
||||
/*Copyright (c) 2012-2013 Robert Rouhani <robert.rouhani@gmail.com>
|
||||
|
||||
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.MultipleMasters.Internal;
|
||||
|
||||
namespace SharpFont.MultipleMasters
|
||||
{
|
||||
/// <summary><para>
|
||||
/// A structure used to model the axes and space of a Multiple Masters or GX var distortable font.
|
||||
/// </para><para>
|
||||
/// Some fields are specific to one format and not to the other.
|
||||
/// </para></summary>
|
||||
public class MMVar
|
||||
{
|
||||
#region Fields
|
||||
|
||||
private IntPtr reference;
|
||||
private MMVarRec rec;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
internal MMVar(IntPtr reference)
|
||||
{
|
||||
Reference = reference;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of axes. The maximum value is 4 for MM; no limit in GX.
|
||||
/// </summary>
|
||||
[CLSCompliant(false)]
|
||||
public uint AxisCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return rec.num_axis;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of designs; should be normally 2^num_axis for MM fonts. Not meaningful for GX (where every
|
||||
/// glyph could have a different number of designs).
|
||||
/// </summary>
|
||||
[CLSCompliant(false)]
|
||||
public uint DesignsCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return rec.num_designs;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of named styles; only meaningful for GX which allows certain design coordinates to have a
|
||||
/// string ID (in the ‘name’ table) associated with them. The font can tell the user that, for example,
|
||||
/// Weight=1.5 is ‘Bold’.
|
||||
/// </summary>
|
||||
[CLSCompliant(false)]
|
||||
public uint NamedStylesCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return rec.num_namedstyles;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a table of axis descriptors. GX fonts contain slightly more data than MM.
|
||||
/// </summary>
|
||||
public VarAxis Axis
|
||||
{
|
||||
get
|
||||
{
|
||||
return new VarAxis(rec.axis);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a table of named styles. Only meaningful with GX.
|
||||
/// </summary>
|
||||
public VarNamedStyle NamedStyle
|
||||
{
|
||||
get
|
||||
{
|
||||
return new VarNamedStyle(rec.namedstyle);
|
||||
}
|
||||
}
|
||||
|
||||
internal IntPtr Reference
|
||||
{
|
||||
get
|
||||
{
|
||||
return reference;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
reference = value;
|
||||
rec = PInvokeHelper.PtrToStructure<MMVarRec>(reference);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
114
SharpFont/Source/SharpFontShared/MultipleMasters/MultiMaster.cs
Normal file
114
SharpFont/Source/SharpFontShared/MultipleMasters/MultiMaster.cs
Normal file
@@ -0,0 +1,114 @@
|
||||
#region MIT License
|
||||
/*Copyright (c) 2012-2013 Robert Rouhani <robert.rouhani@gmail.com>
|
||||
|
||||
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.MultipleMasters.Internal;
|
||||
|
||||
namespace SharpFont.MultipleMasters
|
||||
{
|
||||
/// <summary><para>
|
||||
/// A structure used to model the axes and space of a Multiple Masters font.
|
||||
/// </para><para>
|
||||
/// This structure can't be used for GX var fonts.
|
||||
/// </para></summary>
|
||||
public class MultiMaster
|
||||
{
|
||||
#region Fields
|
||||
|
||||
private IntPtr reference;
|
||||
private MultiMasterRec rec;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
internal MultiMaster(IntPtr reference)
|
||||
{
|
||||
Reference = reference;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of axes. Cannot exceed 4.
|
||||
/// </summary>
|
||||
[CLSCompliant(false)]
|
||||
public uint AxisCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return rec.num_axis;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of designs; should be normally 2^num_axis even though the Type 1 specification strangely
|
||||
/// allows for intermediate designs to be present. This number cannot exceed 16.
|
||||
/// </summary>
|
||||
[CLSCompliant(false)]
|
||||
public uint DesignsCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return rec.num_designs;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a table of axis descriptors.
|
||||
/// </summary>
|
||||
public MMAxis[] Axis
|
||||
{
|
||||
get
|
||||
{
|
||||
MMAxis[] axis = new MMAxis[rec.num_axis];
|
||||
|
||||
for (int i = 0; i < rec.num_axis; i++)
|
||||
axis[i] = new MMAxis(rec.axis[i]);
|
||||
|
||||
return axis;
|
||||
}
|
||||
}
|
||||
|
||||
internal IntPtr Reference
|
||||
{
|
||||
get
|
||||
{
|
||||
return reference;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
reference = value;
|
||||
rec = PInvokeHelper.PtrToStructure<MultiMasterRec>(reference);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
140
SharpFont/Source/SharpFontShared/MultipleMasters/VarAxis.cs
Normal file
140
SharpFont/Source/SharpFontShared/MultipleMasters/VarAxis.cs
Normal file
@@ -0,0 +1,140 @@
|
||||
#region MIT License
|
||||
/*Copyright (c) 2012-2013 Robert Rouhani <robert.rouhani@gmail.com>
|
||||
|
||||
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.MultipleMasters.Internal;
|
||||
|
||||
namespace SharpFont.MultipleMasters
|
||||
{
|
||||
/// <summary>
|
||||
/// A simple structure used to model a given axis in design space for Multiple Masters and GX var fonts.
|
||||
/// </summary>
|
||||
public class VarAxis
|
||||
{
|
||||
#region Fields
|
||||
|
||||
private IntPtr reference;
|
||||
private VarAxisRec rec;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
internal VarAxis(IntPtr reference)
|
||||
{
|
||||
Reference = reference;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets the axis's name. Not always meaningful for GX.
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return rec.name;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the axis's minimum design coordinate.
|
||||
/// </summary>
|
||||
public int Minimum
|
||||
{
|
||||
get
|
||||
{
|
||||
return (int)rec.minimum;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the axis's default design coordinate. FreeType computes meaningful default values for MM; it is then
|
||||
/// an integer value, not in 16.16 format.
|
||||
/// </summary>
|
||||
public int Default
|
||||
{
|
||||
get
|
||||
{
|
||||
return (int)rec.def;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the axis's maximum design coordinate.
|
||||
/// </summary>
|
||||
public int Maximum
|
||||
{
|
||||
get
|
||||
{
|
||||
return (int)rec.maximum;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the axis's tag (the GX equivalent to ‘name’). FreeType provides default values for MM if possible.
|
||||
/// </summary>
|
||||
[CLSCompliant(false)]
|
||||
public uint Tag
|
||||
{
|
||||
get
|
||||
{
|
||||
return (uint)rec.tag;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the entry in ‘name’ table (another GX version of ‘name’). Not meaningful for MM.
|
||||
/// </summary>
|
||||
[CLSCompliant(false)]
|
||||
public uint StrId
|
||||
{
|
||||
get
|
||||
{
|
||||
return rec.strid;
|
||||
}
|
||||
}
|
||||
|
||||
internal IntPtr Reference
|
||||
{
|
||||
get
|
||||
{
|
||||
return reference;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
reference = value;
|
||||
rec = PInvokeHelper.PtrToStructure<VarAxisRec>(reference);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
#region MIT License
|
||||
/*Copyright (c) 2012-2013 Robert Rouhani <robert.rouhani@gmail.com>
|
||||
|
||||
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.MultipleMasters.Internal;
|
||||
|
||||
namespace SharpFont.MultipleMasters
|
||||
{
|
||||
/// <summary><para>
|
||||
/// A simple structure used to model a named style in a GX var font.
|
||||
/// </para><para>
|
||||
/// This structure can't be used for MM fonts.
|
||||
/// </para></summary>
|
||||
public class VarNamedStyle
|
||||
{
|
||||
#region Fields
|
||||
|
||||
private IntPtr reference;
|
||||
private VarNamedStyleRec rec;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
internal VarNamedStyle(IntPtr reference)
|
||||
{
|
||||
Reference = reference;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets the design coordinates for this style. This is an array with one entry for each axis.
|
||||
/// </summary>
|
||||
public IntPtr Coordinates
|
||||
{
|
||||
get
|
||||
{
|
||||
return rec.coords;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the entry in ‘name’ table identifying this style.
|
||||
/// </summary>
|
||||
[CLSCompliant(false)]
|
||||
public uint StrId
|
||||
{
|
||||
get
|
||||
{
|
||||
return rec.strid;
|
||||
}
|
||||
}
|
||||
|
||||
internal IntPtr Reference
|
||||
{
|
||||
get
|
||||
{
|
||||
return reference;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
reference = value;
|
||||
rec = PInvokeHelper.PtrToStructure<VarNamedStyleRec>(reference);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user