Browse Source

Added build files for mcufont on Windows, using Visual Studio 2015.
Corrected opening .ttf/.bdf files in BINARY mode (which has an effect on Win32, no change on other platforms).
Added progress report to import_ttf as with a large font file, it may take several minutes.

dongie 3 years ago
parent
commit
c9b616014f

BIN
tools/mcufontencoder/binaries/windows/freetype6.dll


BIN
tools/mcufontencoder/binaries/windows/libgcc_s_dw2-1.dll


BIN
tools/mcufontencoder/binaries/windows/mcufont.exe


BIN
tools/mcufontencoder/binaries/windows/zlib1.dll


+ 12 - 4
tools/mcufontencoder/src/freetype_import.cc

@@ -163,14 +163,22 @@ std::unique_ptr<DataFile> LoadFreetype(std::istream &file, int size, bool bw)
163 163
         glyphtable.push_back(glyph);
164 164
         
165 165
         charcode = FT_Get_Next_Char(face, charcode, &gindex);
166
+		if (gindex % 1000 == 0)
167
+			std::cout << ".";
166 168
     }
167
-    
169
+
170
+	std::cout << "\nEliminating duplicates (this may take a while)...";
171
+   
168 172
     eliminate_duplicates(glyphtable);
169
-    crop_glyphs(glyphtable, fontinfo);
170
-    detect_flags(glyphtable, fontinfo);
173
+	std::cout << "\nCropping glyphs...";
174
+	crop_glyphs(glyphtable, fontinfo);
175
+	std::cout << "\nDetecting flags...";
176
+	detect_flags(glyphtable, fontinfo);
171 177
     
172
-    std::unique_ptr<DataFile> result(new DataFile(
178
+	std::cout << "\nGenerating datafile...";
179
+	std::unique_ptr<DataFile> result(new DataFile(
173 180
         dictionary, glyphtable, fontinfo));
181
+	std::cout << "\n";
174 182
     return result;
175 183
 }
176 184
 

+ 2 - 2
tools/mcufontencoder/src/main.cc

@@ -90,7 +90,7 @@ static status_t cmd_import_ttf(const std::vector<std::string> &args)
90 90
     int size = std::stoi(args.at(2));
91 91
     bool bw = (args.size() == 4 && args.at(3) == "bw");
92 92
     std::string dest = strip_extension(src) + std::to_string(size) + (bw ? "bw" : "") + ".dat";
93
-    std::ifstream infile(src);
93
+    std::ifstream infile(src, std::ios::binary);
94 94
     
95 95
     if (!infile.good())
96 96
     {
@@ -118,7 +118,7 @@ static status_t cmd_import_bdf(const std::vector<std::string> &args)
118 118
     
119 119
     std::string src = args.at(1);
120 120
     std::string dest = strip_extension(args.at(1)) + ".dat";
121
-    std::ifstream infile(src);
121
+    std::ifstream infile(src, std::ios::binary);
122 122
     
123 123
     if (!infile.good())
124 124
     {

BIN
tools/mcufontencoder/src/mcufont.ico


BIN
tools/mcufontencoder/src/mcufont.rc


+ 22 - 0
tools/mcufontencoder/src/mcufont.sln

@@ -0,0 +1,22 @@
1
+
2
+Microsoft Visual Studio Solution File, Format Version 12.00
3
+# Visual Studio 14
4
+VisualStudioVersion = 14.0.25420.1
5
+MinimumVisualStudioVersion = 10.0.40219.1
6
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mcufont", "mcufont.vcxproj", "{387183DE-A542-4506-8BB1-1A240036E4F4}"
7
+EndProject
8
+Global
9
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
10
+		Debug|x86 = Debug|x86
11
+		Release|x86 = Release|x86
12
+	EndGlobalSection
13
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
14
+		{387183DE-A542-4506-8BB1-1A240036E4F4}.Debug|x86.ActiveCfg = Debug|Win32
15
+		{387183DE-A542-4506-8BB1-1A240036E4F4}.Debug|x86.Build.0 = Debug|Win32
16
+		{387183DE-A542-4506-8BB1-1A240036E4F4}.Release|x86.ActiveCfg = Release|Win32
17
+		{387183DE-A542-4506-8BB1-1A240036E4F4}.Release|x86.Build.0 = Release|Win32
18
+	EndGlobalSection
19
+	GlobalSection(SolutionProperties) = preSolution
20
+		HideSolutionNode = FALSE
21
+	EndGlobalSection
22
+EndGlobal

+ 177 - 0
tools/mcufontencoder/src/mcufont.vcxproj

@@ -0,0 +1,177 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3
+  <ItemGroup Label="ProjectConfigurations">
4
+    <ProjectConfiguration Include="Debug|Win32">
5
+      <Configuration>Debug</Configuration>
6
+      <Platform>Win32</Platform>
7
+    </ProjectConfiguration>
8
+    <ProjectConfiguration Include="Release|Win32">
9
+      <Configuration>Release</Configuration>
10
+      <Platform>Win32</Platform>
11
+    </ProjectConfiguration>
12
+    <ProjectConfiguration Include="Debug|x64">
13
+      <Configuration>Debug</Configuration>
14
+      <Platform>x64</Platform>
15
+    </ProjectConfiguration>
16
+    <ProjectConfiguration Include="Release|x64">
17
+      <Configuration>Release</Configuration>
18
+      <Platform>x64</Platform>
19
+    </ProjectConfiguration>
20
+  </ItemGroup>
21
+  <PropertyGroup Label="Globals">
22
+    <ProjectGuid>{387183DE-A542-4506-8BB1-1A240036E4F4}</ProjectGuid>
23
+    <Keyword>Win32Proj</Keyword>
24
+    <RootNamespace>mcufont</RootNamespace>
25
+    <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
26
+  </PropertyGroup>
27
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
28
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
29
+    <ConfigurationType>Application</ConfigurationType>
30
+    <UseDebugLibraries>true</UseDebugLibraries>
31
+    <PlatformToolset>v140</PlatformToolset>
32
+    <CharacterSet>Unicode</CharacterSet>
33
+  </PropertyGroup>
34
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
35
+    <ConfigurationType>Application</ConfigurationType>
36
+    <UseDebugLibraries>false</UseDebugLibraries>
37
+    <PlatformToolset>v140</PlatformToolset>
38
+    <WholeProgramOptimization>true</WholeProgramOptimization>
39
+    <CharacterSet>Unicode</CharacterSet>
40
+  </PropertyGroup>
41
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
42
+    <ConfigurationType>Application</ConfigurationType>
43
+    <UseDebugLibraries>true</UseDebugLibraries>
44
+    <PlatformToolset>v140</PlatformToolset>
45
+    <CharacterSet>Unicode</CharacterSet>
46
+  </PropertyGroup>
47
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
48
+    <ConfigurationType>Application</ConfigurationType>
49
+    <UseDebugLibraries>false</UseDebugLibraries>
50
+    <PlatformToolset>v140</PlatformToolset>
51
+    <WholeProgramOptimization>true</WholeProgramOptimization>
52
+    <CharacterSet>Unicode</CharacterSet>
53
+  </PropertyGroup>
54
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
55
+  <ImportGroup Label="ExtensionSettings">
56
+  </ImportGroup>
57
+  <ImportGroup Label="Shared">
58
+  </ImportGroup>
59
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
60
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
61
+  </ImportGroup>
62
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
63
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
64
+  </ImportGroup>
65
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
66
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
67
+  </ImportGroup>
68
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
69
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
70
+  </ImportGroup>
71
+  <PropertyGroup Label="UserMacros" />
72
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
73
+    <LinkIncremental>true</LinkIncremental>
74
+  </PropertyGroup>
75
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
76
+    <LinkIncremental>true</LinkIncremental>
77
+  </PropertyGroup>
78
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
79
+    <LinkIncremental>false</LinkIncremental>
80
+    <EmbedManifest>false</EmbedManifest>
81
+    <GenerateManifest>false</GenerateManifest>
82
+  </PropertyGroup>
83
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
84
+    <LinkIncremental>false</LinkIncremental>
85
+  </PropertyGroup>
86
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
87
+    <ClCompile>
88
+      <PrecompiledHeader>
89
+      </PrecompiledHeader>
90
+      <WarningLevel>Level3</WarningLevel>
91
+      <Optimization>Disabled</Optimization>
92
+      <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
93
+      <AdditionalIncludeDirectories>freetype-2.7\include</AdditionalIncludeDirectories>
94
+      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
95
+    </ClCompile>
96
+    <Link>
97
+      <SubSystem>Console</SubSystem>
98
+      <GenerateDebugInformation>true</GenerateDebugInformation>
99
+      <AdditionalDependencies>freetype-2.7\objs\vc2010\Win32\freetype27MTd.lib;%(AdditionalDependencies)</AdditionalDependencies>
100
+    </Link>
101
+  </ItemDefinitionGroup>
102
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
103
+    <ClCompile>
104
+      <PrecompiledHeader>
105
+      </PrecompiledHeader>
106
+      <WarningLevel>Level3</WarningLevel>
107
+      <Optimization>Disabled</Optimization>
108
+      <PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
109
+    </ClCompile>
110
+    <Link>
111
+      <SubSystem>Console</SubSystem>
112
+      <GenerateDebugInformation>true</GenerateDebugInformation>
113
+    </Link>
114
+  </ItemDefinitionGroup>
115
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
116
+    <ClCompile>
117
+      <WarningLevel>Level3</WarningLevel>
118
+      <PrecompiledHeader>
119
+      </PrecompiledHeader>
120
+      <Optimization>MaxSpeed</Optimization>
121
+      <FunctionLevelLinking>true</FunctionLevelLinking>
122
+      <IntrinsicFunctions>true</IntrinsicFunctions>
123
+      <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
124
+      <AdditionalIncludeDirectories>freetype-2.7\include</AdditionalIncludeDirectories>
125
+      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
126
+      <DebugInformationFormat>None</DebugInformationFormat>
127
+    </ClCompile>
128
+    <Link>
129
+      <SubSystem>Console</SubSystem>
130
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
131
+      <OptimizeReferences>true</OptimizeReferences>
132
+      <AdditionalDependencies>freetype-2.7\objs\vc2010\Win32\freetype27MT.lib;%(AdditionalDependencies)</AdditionalDependencies>
133
+      <GenerateDebugInformation>false</GenerateDebugInformation>
134
+    </Link>
135
+  </ItemDefinitionGroup>
136
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
137
+    <ClCompile>
138
+      <WarningLevel>Level3</WarningLevel>
139
+      <PrecompiledHeader>
140
+      </PrecompiledHeader>
141
+      <Optimization>MaxSpeed</Optimization>
142
+      <FunctionLevelLinking>true</FunctionLevelLinking>
143
+      <IntrinsicFunctions>true</IntrinsicFunctions>
144
+      <PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
145
+    </ClCompile>
146
+    <Link>
147
+      <SubSystem>Console</SubSystem>
148
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
149
+      <OptimizeReferences>true</OptimizeReferences>
150
+      <GenerateDebugInformation>true</GenerateDebugInformation>
151
+    </Link>
152
+  </ItemDefinitionGroup>
153
+  <ItemGroup>
154
+    <ClCompile Include="bdf_import.cc" />
155
+    <ClCompile Include="datafile.cc" />
156
+    <ClCompile Include="encode_rlefont.cc" />
157
+    <ClCompile Include="exporttools.cc" />
158
+    <ClCompile Include="export_bwfont.cc" />
159
+    <ClCompile Include="export_rlefont.cc" />
160
+    <ClCompile Include="freetype_import.cc" />
161
+    <ClCompile Include="importtools.cc" />
162
+    <ClCompile Include="main.cc" />
163
+    <ClCompile Include="optimize_rlefont.cc" />
164
+  </ItemGroup>
165
+  <ItemGroup>
166
+    <ClInclude Include="resource.h" />
167
+  </ItemGroup>
168
+  <ItemGroup>
169
+    <ResourceCompile Include="mcufont.rc" />
170
+  </ItemGroup>
171
+  <ItemGroup>
172
+    <Image Include="mcufont.ico" />
173
+  </ItemGroup>
174
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
175
+  <ImportGroup Label="ExtensionTargets">
176
+  </ImportGroup>
177
+</Project>

+ 9 - 0
tools/mcufontencoder/src/readme_win32.txt

@@ -0,0 +1,9 @@
1
+How to build on Windows using Visual Studio 2015
2
+
3
+* Download freetype-2.7 and extract to mcufont dir. result will contain freetype-2.7\src, freetype-2.7\include, etc.
4
+* Go to freetype-2.7\builds\windows\vc2010 and open freetype.sln
5
+* Select "Debug Multithreaded" and build. Select "Release Multithreaded" and build. Close Visual Studio.
6
+* Open mcufont.sln
7
+* Select Debug or Release, and build
8
+* Resulting mcufont.exe is in Release\ or Debug\ folder and needs no further dependencies.
9
+