change TrueTypeSharp to a .NET 4.0 PCL
Ripped out serialization support for now since the "Serializable" attribute is not supported in PCLs currently.
This commit is contained in:
parent
ff7492a26c
commit
8babb25399
|
@ -24,7 +24,6 @@ using System;
|
|||
|
||||
namespace TrueTypeSharp
|
||||
{
|
||||
[Serializable]
|
||||
public struct BakedChar
|
||||
{
|
||||
public static BakedChar Empty
|
||||
|
|
|
@ -22,12 +22,10 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace TrueTypeSharp
|
||||
{
|
||||
[Serializable]
|
||||
public class BakedCharCollection : ISerializable
|
||||
public class BakedCharCollection
|
||||
{
|
||||
Dictionary<char, BakedChar> _characters;
|
||||
int _bakeWidth, _bakeHeight;
|
||||
|
@ -51,13 +49,6 @@ namespace TrueTypeSharp
|
|||
Create(dictionary, bakeWidth, bakeHeight);
|
||||
}
|
||||
|
||||
protected BakedCharCollection(SerializationInfo info, StreamingContext context)
|
||||
{
|
||||
Create((Dictionary<char, BakedChar>)
|
||||
info.GetValue("Characters", typeof(Dictionary<char, BakedChar>)),
|
||||
info.GetInt32("BakeWidth"), info.GetInt32("BakeHeight"));
|
||||
}
|
||||
|
||||
void Create(Dictionary<char, BakedChar> characters, int bakeWidth, int bakeHeight)
|
||||
{
|
||||
if (characters == null) { throw new ArgumentNullException("characters"); }
|
||||
|
@ -109,13 +100,6 @@ namespace TrueTypeSharp
|
|||
}
|
||||
}
|
||||
|
||||
public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
|
||||
{
|
||||
info.AddValue("Characters", Characters);
|
||||
info.AddValue("BakeWidth", BakeWidth);
|
||||
info.AddValue("BakeHeight", BakeHeight);
|
||||
}
|
||||
|
||||
public BakedQuad GetBakedQuad(char character,
|
||||
ref float xPosition, ref float yPosition)
|
||||
{
|
||||
|
|
|
@ -24,7 +24,6 @@ using System;
|
|||
|
||||
namespace TrueTypeSharp
|
||||
{
|
||||
[Serializable]
|
||||
public struct BakedQuad
|
||||
{
|
||||
public static BakedQuad Empty
|
||||
|
|
|
@ -24,7 +24,6 @@ using System;
|
|||
|
||||
namespace TrueTypeSharp
|
||||
{
|
||||
[Serializable]
|
||||
public struct ContourPoint
|
||||
{
|
||||
public float X, Y;
|
||||
|
|
|
@ -21,12 +21,10 @@
|
|||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace TrueTypeSharp
|
||||
{
|
||||
[Serializable]
|
||||
public struct FontBitmap : ISerializable
|
||||
public struct FontBitmap
|
||||
{
|
||||
public delegate T PixelConversionFunc<T>(byte opacity);
|
||||
|
||||
|
@ -42,28 +40,6 @@ namespace TrueTypeSharp
|
|||
Stride = Width = width; Height = height;
|
||||
}
|
||||
|
||||
FontBitmap(SerializationInfo info, StreamingContext context) : this()
|
||||
{
|
||||
Buffer = (byte[])info.GetValue("Buffer", typeof(byte[]));
|
||||
BufferOffset = info.GetInt32("BufferOffset");
|
||||
XOffset = info.GetInt32("XOffset");
|
||||
YOffset = info.GetInt32("YOffset");
|
||||
Width = info.GetInt32("Width");
|
||||
Height = info.GetInt32("Height");
|
||||
Stride = info.GetInt32("Stride");
|
||||
}
|
||||
|
||||
public void GetObjectData(SerializationInfo info, StreamingContext context)
|
||||
{
|
||||
info.AddValue("Buffer", Buffer);
|
||||
info.AddValue("BufferOffset", BufferOffset);
|
||||
info.AddValue("XOffset", XOffset);
|
||||
info.AddValue("YOffset", YOffset);
|
||||
info.AddValue("Width", Width);
|
||||
info.AddValue("Height", Height);
|
||||
info.AddValue("Stride", Stride);
|
||||
}
|
||||
|
||||
public FontBitmap GetResizedBitmap(int width, int height)
|
||||
{
|
||||
var bitmap = new FontBitmap(width, height);
|
||||
|
|
|
@ -24,7 +24,6 @@ using System;
|
|||
|
||||
namespace TrueTypeSharp
|
||||
{
|
||||
[Serializable]
|
||||
public struct GlyphVertex
|
||||
{
|
||||
public short X, Y, CX, CY;
|
||||
|
|
|
@ -32,20 +32,28 @@ namespace TrueTypeSharp
|
|||
|
||||
public TrueTypeFont(byte[] data, int offset)
|
||||
{
|
||||
CheckFontData(data, offset);
|
||||
|
||||
if (0 == stb_truetype.stbtt_InitFont(ref _info,
|
||||
new FakePtr<byte>() { Array = data }, offset))
|
||||
{
|
||||
throw new BadImageFormatException("Couldn't load TrueType file.");
|
||||
}
|
||||
InitFontData(data, offset);
|
||||
}
|
||||
|
||||
public TrueTypeFont(string filename)
|
||||
: this(File.ReadAllBytes(filename), 0)
|
||||
{
|
||||
public TrueTypeFont(Stream stream)
|
||||
{
|
||||
using (var memoryStream = new MemoryStream())
|
||||
{
|
||||
stream.CopyTo(memoryStream);
|
||||
InitFontData(memoryStream.ToArray(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
private void InitFontData(byte[] data, int offset)
|
||||
{
|
||||
CheckFontData(data, offset);
|
||||
|
||||
if (0 == stb_truetype.stbtt_InitFont(ref _info,
|
||||
new FakePtr<byte>() { Array = data }, offset))
|
||||
{
|
||||
throw new BadImageFormatException("Couldn't load TrueType file.");
|
||||
}
|
||||
}
|
||||
|
||||
static void CheckFontData(byte[] data, int offset)
|
||||
{
|
||||
|
|
|
@ -1,98 +1,57 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.30729</ProductVersion>
|
||||
<ProductVersion>10.0.0</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{B722113F-1252-4BE1-9D43-6BC82B3E37D1}</ProjectGuid>
|
||||
<ProjectGuid>{1651CC69-D1D5-4770-9C93-45CB91579130}</ProjectGuid>
|
||||
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>TrueTypeSharp</RootNamespace>
|
||||
<AssemblyName>TrueTypeSharp</AssemblyName>
|
||||
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<StartupObject>
|
||||
</StartupObject>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<UpgradeBackupLocation>
|
||||
</UpgradeBackupLocation>
|
||||
<OldToolsVersion>3.5</OldToolsVersion>
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
<UpdateEnabled>false</UpdateEnabled>
|
||||
<UpdateMode>Foreground</UpdateMode>
|
||||
<UpdateInterval>7</UpdateInterval>
|
||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
<TargetFrameworkProfile>Profile14</TargetFrameworkProfile>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\bin\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<OutputPath>..\bin</OutputPath>
|
||||
<DefineConstants>DEBUG;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\bin\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<OutputPath>..\bin</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Core" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="stb_truetype.h" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="BakedChar.cs" />
|
||||
<Compile Include="BakedCharCollection.cs" />
|
||||
<Compile Include="BakedQuad.cs" />
|
||||
<Compile Include="ContourPoint.cs" />
|
||||
<Compile Include="FakePtr.cs" />
|
||||
<Compile Include="FontBitmap.cs" />
|
||||
<Compile Include="GlyphVertex.cs" />
|
||||
<Compile Include="GlyphVertexType.cs" />
|
||||
<Compile Include="ContourPoint.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="stb_truetype.cs" />
|
||||
<Compile Include="TrueTypeFont.Codepoints.cs" />
|
||||
<Compile Include="TrueTypeFont.cs" />
|
||||
<Compile Include="stb_truetype.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>Windows Installer 3.1</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
<None Include="stb_truetype.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
Reference in a new issue