diff --git a/TrueTypeSharp.Demo/Program.cs b/TrueTypeSharp.Demo/Program.cs index fbb47c9..852f1b6 100644 --- a/TrueTypeSharp.Demo/Program.cs +++ b/TrueTypeSharp.Demo/Program.cs @@ -23,8 +23,6 @@ using System; using System.Drawing; using System.IO; -using System.Runtime.Serialization; -using System.Runtime.Serialization.Formatters.Binary; namespace TrueTypeSharp.Demo { @@ -47,7 +45,7 @@ namespace TrueTypeSharp.Demo static void Main(string[] args) { - var font = new TrueTypeFont(@"Anonymous/Anonymous Pro.ttf"); + var font = new TrueTypeFont(new FileStream(@"Anonymous/Anonymous Pro.ttf", FileMode.Open)); // Render some characters... for (char ch = 'A'; ch <= 'Z'; ch++) @@ -65,38 +63,8 @@ namespace TrueTypeSharp.Demo var bitmap = font.BakeFontBitmap(pixelHeight, out characters, true); SaveBitmap(bitmap.Buffer, 0, 0, bitmap.Width, bitmap.Height, bitmap.Width, "BakeResult1.png"); - - // Now, let's give serialization a go. - using (var file = File.OpenWrite("BakeResult2.temp")) - { - var bitmapSaver = new BinaryFormatter(); - bitmapSaver.Serialize(file, bitmap); - bitmapSaver.Serialize(file, characters); - int ascent, descent, lineGap; - float scale = font.GetScaleForPixelHeight(pixelHeight); - font.GetFontVMetrics(out ascent, out descent, out lineGap); - bitmapSaver.Serialize(file, (float)ascent * scale); - bitmapSaver.Serialize(file, (float)descent * scale); - bitmapSaver.Serialize(file, (float)lineGap * scale); - } - - using (var file = File.OpenRead("BakeResult2.temp")) - { - var bitmapLoader = new BinaryFormatter(); - var bitmapAgain = (FontBitmap)bitmapLoader.Deserialize(file); - var charactersAgain = (BakedCharCollection)bitmapLoader.Deserialize(file); - - SaveBitmap(bitmapAgain.Buffer, 0, 0, bitmapAgain.Width, bitmapAgain.Height, bitmap.Width, "BakeResult2.png"); - for (char ch = 'A'; ch <= 'Z'; ch++) - { - BakedChar bakedChar = charactersAgain[ch]; - if (bakedChar.IsEmpty) { continue; } - SaveBitmap(bitmapAgain.Buffer, - bakedChar.X0, bakedChar.Y0, bakedChar.X1, bakedChar.Y1, - bitmapAgain.Stride, "SmallChar-" + ch.ToString() + ".png"); - } - } + // TODO: implement serialization equivalent that is compatible with a Portable Class Library ... } } } diff --git a/TrueTypeSharp.Demo/TrueTypeSharp.Demo.csproj b/TrueTypeSharp.Demo/TrueTypeSharp.Demo.csproj index 2773c12..ad1d483 100644 --- a/TrueTypeSharp.Demo/TrueTypeSharp.Demo.csproj +++ b/TrueTypeSharp.Demo/TrueTypeSharp.Demo.csproj @@ -10,7 +10,6 @@ Properties TrueTypeSharp.Demo TrueTypeSharp.Demo - v2.0 512 @@ -58,12 +57,6 @@ - - - {B722113F-1252-4BE1-9D43-6BC82B3E37D1} - TrueTypeSharp - - False @@ -89,4 +82,10 @@ --> + + + {1651CC69-D1D5-4770-9C93-45CB91579130} + TrueTypeSharp + + \ No newline at end of file diff --git a/TrueTypeSharp.sln b/TrueTypeSharp.sln index 842eea5..2d93797 100644 --- a/TrueTypeSharp.sln +++ b/TrueTypeSharp.sln @@ -1,25 +1,28 @@  Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TrueTypeSharp", "TrueTypeSharp\TrueTypeSharp.csproj", "{B722113F-1252-4BE1-9D43-6BC82B3E37D1}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TrueTypeSharp.Demo", "TrueTypeSharp.Demo\TrueTypeSharp.Demo.csproj", "{B067AB58-D823-4A46-97E1-43BC75F7FF35}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TrueTypeSharp", "TrueTypeSharp\TrueTypeSharp.csproj", "{1651CC69-D1D5-4770-9C93-45CB91579130}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B722113F-1252-4BE1-9D43-6BC82B3E37D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B722113F-1252-4BE1-9D43-6BC82B3E37D1}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B722113F-1252-4BE1-9D43-6BC82B3E37D1}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B722113F-1252-4BE1-9D43-6BC82B3E37D1}.Release|Any CPU.Build.0 = Release|Any CPU + {1651CC69-D1D5-4770-9C93-45CB91579130}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1651CC69-D1D5-4770-9C93-45CB91579130}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1651CC69-D1D5-4770-9C93-45CB91579130}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1651CC69-D1D5-4770-9C93-45CB91579130}.Release|Any CPU.Build.0 = Release|Any CPU {B067AB58-D823-4A46-97E1-43BC75F7FF35}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B067AB58-D823-4A46-97E1-43BC75F7FF35}.Debug|Any CPU.Build.0 = Debug|Any CPU {B067AB58-D823-4A46-97E1-43BC75F7FF35}.Release|Any CPU.ActiveCfg = Release|Any CPU {B067AB58-D823-4A46-97E1-43BC75F7FF35}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection + GlobalSection(MonoDevelopProperties) = preSolution + StartupItem = TrueTypeSharp.Demo\TrueTypeSharp.Demo.csproj + EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection