[SCM] Packaging for cube2font branch, master-svn, updated. debian/1.2-2-18-gf985b09
Martin Erik Werner
martinerikwerner at gmail.com
Sat Sep 1 19:24:49 UTC 2012
The following commit has been merged in the master-svn branch:
commit 1d174342a7d7dc434b48f6d30791b6586fb3195b
Author: Martin Erik Werner <martinerikwerner at gmail.com>
Date: Sat Sep 1 19:18:54 2012 +0200
Imported Upstream version 1.3.1
diff --git a/src/install/nix/cube2font.1 b/doc/man/cube2font.1
similarity index 98%
rename from src/install/nix/cube2font.1
rename to doc/man/cube2font.1
index b93d919..7745381 100644
--- a/src/install/nix/cube2font.1
+++ b/doc/man/cube2font.1
@@ -1,4 +1,4 @@
-.TH CUBE2FONT 1 "2011-12-26" "" "cube2font Manual"
+.TH CUBE2FONT 1 2012-07-16 "cube2font 1.3" "cube2font Manual"
.SH NAME
cube2font \- Utility program designed to create font bitmaps for Cube Engine games
.SH SYNOPSIS
diff --git a/license.txt b/license.txt
deleted file mode 100644
index 84ac890..0000000
--- a/license.txt
+++ /dev/null
@@ -1,43 +0,0 @@
-THE RED ECLIPSE LICENSE
-
-Red Eclipse is based on Cube Engine 2, both of which are covered under the ZLIB
-license, you may use the source code so long as you obey this license.
-
- Red Eclipse, Copyright (C) 2009-2012 Quinton Reeves, Lee Salzman
- Cube Engine 2, Copyright (C) 2001-2012 Wouter van Oortmerssen, Lee Salzman,
- Mike Dysart, Robert Pointon, and Quinton Reeves
- http://www.opensource.org/licenses/zlib-license.php
-
-This software is provided 'as-is', without any express or implied warranty.
-In no event will the authors be held liable for any damages arising from
-the use of this software. Permission is granted to anyone to use this
-software for any purpose, including commercial applications, and to alter
-it and redistribute it freely, subject to the following restrictions:
-
- * The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- * Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- * This notice may not be removed or altered from any source distribution.
-
-The license covers the source code, shells scripts, and related config files.
-The included enet network library is covered by an MIT-style license, which
-is however compatible with the above license for all practical purposes.
-
-Content included in the game (maps, textures, sounds, models etc.) is NOT
-covered by this license, and may have individual copyrights and distribution
-restrictions (see individual readmes), note that all content in Red Eclipse
-is intended to be "open source" friendly.
-
-In the absence of an explicit license, content is considered to be covered by
-the CC-BY-SA license, you may use the content in Red Eclipse so long as you
-obey individual licensing criteria.
-
- Red Eclipse, Copyright (C) 2009-2012 Red Eclipse Team
- Creative Commons Attribution ShareAlike 3.0 License (CC-BY-SA)
- See cc-by-sa.txt or http://creativecommons.org/licenses/by-sa/3.0/
-
-The use of trademarks unique to the Red Eclipse project are in addition
-governed by the Red Eclipse Mark Policy (see trademark.txt).
diff --git a/src/Makefile b/src/Makefile
index 1817794..2bff658 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -21,18 +21,27 @@ endif
MV=mv
ifneq (,$(findstring MINGW,$(PLATFORM)))
+WINDRES= windres
ifneq (,$(findstring 64,$(PLATFORM)))
WINLIB=lib64
WINBIN=../bin64
+override CXX+= -m64
+override WINDRES+= -F pe-x86-64
else
WINLIB=lib
WINBIN=../bin
+override CXX+= -m32
+override WINDRES+= -F pe-i386
endif
-WINDRES= windres
-CLIENT_INCLUDES= -DINTERFACE -DIRC $(INCLUDES) -Iinclude
-CLIENT_LIBS= -mwindows -static-libgcc -static-libstdc++ -L$(WINBIN) -L$(WINLIB) -lSDL -lSDL_image -lSDL_mixer -lzlib1 -lopengl32 -lenet -lws2_32 -lwinmm
+ifneq (,$(findstring TDM,$(PLATFORM)))
+STD_LIBS=
+else
+STD_LIBS= -static-libgcc -static-libstdc++
+endif
+CLIENT_INCLUDES= $(INCLUDES) -Iinclude
+CLIENT_LIBS= -mwindows $(STD_LIBS) -L$(WINBIN) -L$(WINLIB) -lSDL -lSDL_image -lSDL_mixer -lzlib1 -lopengl32 -lenet -lws2_32 -lwinmm
else
-CLIENT_INCLUDES= -DINTERFACE -DIRC $(INCLUDES) -I/usr/X11R6/include `sdl-config --cflags`
+CLIENT_INCLUDES= $(INCLUDES) -I/usr/X11R6/include `sdl-config --cflags`
CLIENT_LIBS= -Lenet/.libs -lenet -L/usr/X11R6/lib -lX11 `sdl-config --libs` -lSDL_image -lSDL_mixer -lz -lGL
endif
ifeq ($(PLATFORM),Linux)
@@ -97,13 +106,13 @@ CLIENT_OBJS= \
game/waypoint.o \
game/weapons.o
-CLIENT_PCH= shared/cube.h.gch engine/engine.h.gch game/game.h.gch
+CLIENT_PCH= shared/cube.h.gch engine/engine.h.gch
ifneq (,$(findstring MINGW,$(PLATFORM)))
-SERVER_INCLUDES= -DSTANDALONE -DMASTERSERVER -DIRC $(INCLUDES) -Iinclude
-SERVER_LIBS= -mwindows -static-libgcc -static-libstdc++ -L$(WINBIN) -L$(WINLIB) -lzlib1 -lenet -lws2_32 -lwinmm
+SERVER_INCLUDES= -DSTANDALONE $(INCLUDES) -Iinclude
+SERVER_LIBS= -mwindows $(STD_LIBS) -L$(WINBIN) -L$(WINLIB) -lzlib1 -lenet -lws2_32 -lwinmm
else
-SERVER_INCLUDES= -DSTANDALONE -DMASTERSERVER -DIRC $(INCLUDES)
+SERVER_INCLUDES= -DSTANDALONE $(INCLUDES)
SERVER_LIBS= -Lenet/.libs -lenet -lz
endif
SERVER_OBJS= \
@@ -161,22 +170,22 @@ server: $(SERVER_OBJS)
install-client: client
ifneq (,$(STRIP))
- $(STRIP) ../bin/$(APPCLIENT).exe
+ $(STRIP) $(WINBIN)/$(APPCLIENT).exe
endif
install-server: server
ifneq (,$(STRIP))
- $(STRIP) ../bin/$(APPSERVER).exe
+ $(STRIP) $(WINBIN)/$(APPSERVER).exe
endif
else
client: libenet $(CLIENT_OBJS)
- $(CXX) $(CXXFLAGS) -o $(APPCLIENT) $(CLIENT_OBJS) $(CLIENT_LIBS)
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $(APPCLIENT) $(CLIENT_OBJS) $(CLIENT_LIBS)
ifneq (,$(STRIP))
$(STRIP) $(APPCLIENT)
endif
server: libenet $(SERVER_OBJS)
- $(CXX) $(CXXFLAGS) -o $(APPSERVER) $(SERVER_OBJS) $(SERVER_LIBS)
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $(APPSERVER) $(SERVER_OBJS) $(SERVER_LIBS)
ifneq (,$(STRIP))
$(STRIP) $(APPSERVER)
endif
@@ -193,7 +202,7 @@ shared/cube2font.o: shared/cube2font.c
$(CXX) $(CXXFLAGS) -c -o $@ $< `freetype-config --cflags`
cube2font: shared/cube2font.o
- $(CXX) $(CXXFLAGS) -o cube2font shared/cube2font.o `freetype-config --libs` -lz
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) -o cube2font shared/cube2font.o `freetype-config --libs` -lz
install-cube2font: cube2font
install -d ../bin
@@ -203,16 +212,16 @@ endif
install: install-client install-server
depend:
- makedepend -Y -Ishared -Iengine -Igame -DINTERFACE -DIRC -DMASTERSERVER $(subst .o,.cpp,$(CLIENT_OBJS))
- makedepend -a -o-standalone.o -Y -Ishared -Iengine -Igame -DSTANDALONE -DINTERFACE -DIRC -DMASTERSERVER $(subst -standalone.o,.cpp,$(SERVER_OBJS))
- makedepend -a -o.h.gch -Y -Ishared -Iengine -Igame -DINTERFACE -DIRC -DMASTERSERVER $(subst .h.gch,.h,$(CLIENT_PCH))
+ makedepend -Y -Ishared -Iengine -Igame $(subst .o,.cpp,$(CLIENT_OBJS))
+ makedepend -a -o-standalone.o -Y -Ishared -Iengine -Igame -DSTANDALONE $(subst -standalone.o,.cpp,$(SERVER_OBJS))
+ makedepend -a -o.h.gch -Y -Ishared -Iengine -Igame $(subst .h.gch,.h,$(CLIENT_PCH))
all: client server
include system-install.mk
+include dist.mk
engine/engine.h.gch: shared/cube.h.gch
-game/game.h.gch: shared/cube.h.gch engine/engine.h.gch
# DO NOT DELETE
@@ -584,10 +593,3 @@ engine/engine.h.gch: shared/igame.h engine/irc.h engine/sound.h
engine/engine.h.gch: engine/world.h engine/octa.h engine/lightmap.h
engine/engine.h.gch: engine/bih.h engine/texture.h engine/model.h
engine/engine.h.gch: engine/varray.h
-game/game.h.gch: engine/engine.h shared/cube.h shared/tools.h
-game/game.h.gch: shared/command.h shared/geom.h shared/ents.h
-game/game.h.gch: shared/iengine.h shared/igame.h engine/irc.h engine/sound.h
-game/game.h.gch: engine/world.h engine/octa.h engine/lightmap.h engine/bih.h
-game/game.h.gch: engine/texture.h engine/model.h engine/varray.h
-game/game.h.gch: game/weapons.h game/gamemode.h game/team.h game/ai.h
-game/game.h.gch: game/vars.h game/capture.h game/defend.h game/bomber.h
diff --git a/src/redeclipse.cbp b/src/redeclipse.cbp
index f9c616c..05b5c0c 100644
--- a/src/redeclipse.cbp
+++ b/src/redeclipse.cbp
@@ -4,8 +4,6 @@
<Project>
<Option title="redeclipse" />
<Option platforms="Windows;" />
- <Option pch_mode="2" />
- <Option default_target="client" />
<Option compiler="gcc" />
<Build>
<Target title="client32">
@@ -15,7 +13,7 @@
<Option deps_output=".deps\client" />
<Option type="0" />
<Option compiler="gcc" />
- <Option parameters="-hhome -r -df0 -dw800 -dh600" />
+ <Option parameters="-hhome -r -df0 -dw800 -dh600 -glog.txt" />
<Option projectCompilerOptionsRelation="1" />
<Option projectLinkerOptionsRelation="1" />
<Option projectIncludeDirsRelation="1" />
@@ -23,15 +21,13 @@
<Option projectLibDirsRelation="1" />
<Compiler>
<Add option="-fomit-frame-pointer" />
- <Add option="-O2" />
+ <Add option="-O3" />
<Add option="-Wall" />
+ <Add option="-m32" />
+ <Add option="-mwindows" />
<Add option="-fsigned-char" />
<Add option="-fno-exceptions" />
<Add option="-fno-rtti" />
- <Add option="-mwindows" />
- <Add option="-m32" />
- <Add option="-DINTERFACE" />
- <Add option="-DIRC" />
<Add directory="shared" />
<Add directory="engine" />
<Add directory="game" />
@@ -40,8 +36,8 @@
</Compiler>
<Linker>
<Add option="-s" />
- <Add option="-mwindows" />
<Add option="-m32" />
+ <Add option="-mwindows" />
<Add library="SDL" />
<Add library="SDL_image" />
<Add library="SDL_mixer" />
@@ -53,6 +49,9 @@
<Add directory="..\bin" />
<Add directory="lib" />
</Linker>
+ <Environment>
+ <Variable name="WINDRES_TARGET" value="pe-i386" />
+ </Environment>
</Target>
<Target title="client32-dbg">
<Option output="..\bin\reclient-dbg.exe" prefix_auto="0" extension_auto="0" />
@@ -61,21 +60,19 @@
<Option deps_output=".deps\debug" />
<Option type="0" />
<Option compiler="gcc" />
- <Option parameters="-hhome -r -df0 -dw800 -dh600" />
+ <Option parameters="-hhome -r -df0 -dw800 -dh600 -glog.txt" />
<Option projectCompilerOptionsRelation="1" />
<Option projectLinkerOptionsRelation="1" />
<Option projectIncludeDirsRelation="1" />
<Option projectResourceIncludeDirsRelation="1" />
<Option projectLibDirsRelation="1" />
<Compiler>
- <Add option="-O2" />
+ <Add option="-O3" />
<Add option="-Wall" />
<Add option="-g" />
- <Add option="-fsigned-char" />
- <Add option="-mwindows" />
<Add option="-m32" />
- <Add option="-DINTERFACE" />
- <Add option="-DIRC" />
+ <Add option="-mwindows" />
+ <Add option="-fsigned-char" />
<Add directory="shared" />
<Add directory="engine" />
<Add directory="game" />
@@ -83,8 +80,8 @@
<Add directory="include" />
</Compiler>
<Linker>
- <Add option="-mwindows" />
<Add option="-m32" />
+ <Add option="-mwindows" />
<Add library="SDL" />
<Add library="SDL_image" />
<Add library="SDL_mixer" />
@@ -96,6 +93,9 @@
<Add directory="..\bin" />
<Add directory="lib" />
</Linker>
+ <Environment>
+ <Variable name="WINDRES_TARGET" value="pe-i386" />
+ </Environment>
</Target>
<Target title="client32-prof">
<Option output="..\bin\reclient.exe" prefix_auto="0" extension_auto="0" />
@@ -104,7 +104,7 @@
<Option deps_output=".deps\debug" />
<Option type="0" />
<Option compiler="gcc" />
- <Option parameters="-hhome -rinit.cfg -du0 -df0 -dw640 -dh600" />
+ <Option parameters="-hhome -r -df0 -dw800 -dh600 -glog.txt" />
<Option projectCompilerOptionsRelation="1" />
<Option projectLinkerOptionsRelation="1" />
<Option projectIncludeDirsRelation="1" />
@@ -113,12 +113,10 @@
<Compiler>
<Add option="-Wall" />
<Add option="-pg" />
+ <Add option="-m32" />
+ <Add option="-mwindows" />
<Add option="-fsigned-char" />
<Add option="-finline-functions" />
- <Add option="-mwindows" />
- <Add option="-m32" />
- <Add option="-DINTERFACE" />
- <Add option="-DIRC" />
<Add directory="shared" />
<Add directory="engine" />
<Add directory="game" />
@@ -127,8 +125,8 @@
</Compiler>
<Linker>
<Add option="-pg -lgmon" />
- <Add option="-mwindows" />
<Add option="-m32" />
+ <Add option="-mwindows" />
<Add library="SDL" />
<Add library="SDL_image" />
<Add library="SDL_mixer" />
@@ -140,6 +138,9 @@
<Add directory="..\bin" />
<Add directory="lib" />
</Linker>
+ <Environment>
+ <Variable name="WINDRES_TARGET" value="pe-i386" />
+ </Environment>
</Target>
<Target title="server32">
<Option output="..\bin\reserver.exe" prefix_auto="0" extension_auto="0" />
@@ -155,16 +156,14 @@
<Option projectLibDirsRelation="1" />
<Compiler>
<Add option="-fomit-frame-pointer" />
- <Add option="-O2" />
+ <Add option="-O3" />
<Add option="-Wall" />
+ <Add option="-m32" />
+ <Add option="-mwindows" />
<Add option="-fsigned-char" />
<Add option="-fno-exceptions" />
<Add option="-fno-rtti" />
- <Add option="-mwindows" />
- <Add option="-m32" />
<Add option="-DSTANDALONE" />
- <Add option="-DMASTERSERVER" />
- <Add option="-DIRC" />
<Add directory="shared" />
<Add directory="engine" />
<Add directory="game" />
@@ -173,8 +172,8 @@
</Compiler>
<Linker>
<Add option="-s" />
- <Add option="-mwindows" />
<Add option="-m32" />
+ <Add option="-mwindows" />
<Add library="zlib1" />
<Add library="enet" />
<Add library="ws2_32" />
@@ -182,6 +181,9 @@
<Add directory="..\bin" />
<Add directory="lib" />
</Linker>
+ <Environment>
+ <Variable name="WINDRES_TARGET" value="pe-i386" />
+ </Environment>
</Target>
<Target title="server32-dbg">
<Option output="..\bin\reserver-dbg.exe" prefix_auto="0" extension_auto="0" />
@@ -198,12 +200,10 @@
<Compiler>
<Add option="-Wall" />
<Add option="-g" />
- <Add option="-fsigned-char" />
- <Add option="-mwindows" />
<Add option="-m32" />
+ <Add option="-mwindows" />
+ <Add option="-fsigned-char" />
<Add option="-DSTANDALONE" />
- <Add option="-DMASTERSERVER" />
- <Add option="-DIRC" />
<Add directory="shared" />
<Add directory="engine" />
<Add directory="game" />
@@ -211,8 +211,8 @@
<Add directory="include" />
</Compiler>
<Linker>
- <Add option="-mwindows" />
<Add option="-m32" />
+ <Add option="-mwindows" />
<Add library="zlib1" />
<Add library="enet" />
<Add library="ws2_32" />
@@ -220,6 +220,9 @@
<Add directory="..\bin" />
<Add directory="lib" />
</Linker>
+ <Environment>
+ <Variable name="WINDRES_TARGET" value="pe-i386" />
+ </Environment>
</Target>
<Target title="client64">
<Option output="..\bin64\reclient.exe" prefix_auto="0" extension_auto="0" />
@@ -227,8 +230,8 @@
<Option object_output=".objs\client64" />
<Option deps_output=".deps\client" />
<Option type="0" />
- <Option compiler="gnu_gcc_compiler_for_64bit" />
- <Option parameters="-hhome -r -df0 -dw800 -dh600" />
+ <Option compiler="gcc" />
+ <Option parameters="-hhome -r -df0 -dw800 -dh600 -glog.txt" />
<Option projectCompilerOptionsRelation="1" />
<Option projectLinkerOptionsRelation="1" />
<Option projectIncludeDirsRelation="1" />
@@ -236,15 +239,13 @@
<Option projectLibDirsRelation="1" />
<Compiler>
<Add option="-fomit-frame-pointer" />
- <Add option="-O2" />
+ <Add option="-O3" />
<Add option="-Wall" />
+ <Add option="-m64" />
+ <Add option="-mwindows" />
<Add option="-fsigned-char" />
<Add option="-fno-exceptions" />
<Add option="-fno-rtti" />
- <Add option="-mwindows" />
- <Add option="-m64" />
- <Add option="-DINTERFACE" />
- <Add option="-DIRC" />
<Add directory="shared" />
<Add directory="engine" />
<Add directory="game" />
@@ -253,8 +254,8 @@
</Compiler>
<Linker>
<Add option="-s" />
- <Add option="-mwindows" />
<Add option="-m64" />
+ <Add option="-mwindows" />
<Add library="SDL" />
<Add library="SDL_image" />
<Add library="SDL_mixer" />
@@ -266,6 +267,9 @@
<Add directory="..\bin64" />
<Add directory="lib64" />
</Linker>
+ <Environment>
+ <Variable name="WINDRES_TARGET" value="pe-x86-64" />
+ </Environment>
</Target>
<Target title="client64-prof">
<Option output="..\bin64\reclient.exe" prefix_auto="0" extension_auto="0" />
@@ -273,8 +277,8 @@
<Option object_output=".objs\client64-prof" />
<Option deps_output=".deps\debug" />
<Option type="0" />
- <Option compiler="gnu_gcc_compiler_for_64bit" />
- <Option parameters="-hhome -rinit.cfg -du0 -df0 -dw640 -dh600" />
+ <Option compiler="gcc" />
+ <Option parameters="-hhome -r -df0 -dw800 -dh600 -glog.txt" />
<Option projectCompilerOptionsRelation="1" />
<Option projectLinkerOptionsRelation="1" />
<Option projectIncludeDirsRelation="1" />
@@ -283,12 +287,10 @@
<Compiler>
<Add option="-Wall" />
<Add option="-pg" />
+ <Add option="-m64" />
+ <Add option="-mwindows" />
<Add option="-fsigned-char" />
<Add option="-finline-functions" />
- <Add option="-mwindows" />
- <Add option="-m64" />
- <Add option="-DINTERFACE" />
- <Add option="-DIRC" />
<Add directory="shared" />
<Add directory="engine" />
<Add directory="game" />
@@ -297,8 +299,8 @@
</Compiler>
<Linker>
<Add option="-pg -lgmon" />
- <Add option="-mwindows" />
<Add option="-m64" />
+ <Add option="-mwindows" />
<Add library="SDL" />
<Add library="SDL_image" />
<Add library="SDL_mixer" />
@@ -310,6 +312,9 @@
<Add directory="..\bin64" />
<Add directory="lib64" />
</Linker>
+ <Environment>
+ <Variable name="WINDRES_TARGET" value="pe-x86-64" />
+ </Environment>
</Target>
<Target title="client64-dbg">
<Option output="..\bin64\reclient-dbg.exe" prefix_auto="0" extension_auto="0" />
@@ -317,22 +322,20 @@
<Option object_output=".objs\client64-dbg" />
<Option deps_output=".deps\debug" />
<Option type="0" />
- <Option compiler="gnu_gcc_compiler_for_64bit" />
- <Option parameters="-hhome -r -df0 -dw800 -dh600" />
+ <Option compiler="gcc" />
+ <Option parameters="-hhome -r -df0 -dw800 -dh600 -glog.txt" />
<Option projectCompilerOptionsRelation="1" />
<Option projectLinkerOptionsRelation="1" />
<Option projectIncludeDirsRelation="1" />
<Option projectResourceIncludeDirsRelation="1" />
<Option projectLibDirsRelation="1" />
<Compiler>
- <Add option="-O2" />
+ <Add option="-O3" />
<Add option="-Wall" />
<Add option="-g" />
- <Add option="-fsigned-char" />
- <Add option="-mwindows" />
<Add option="-m64" />
- <Add option="-DINTERFACE" />
- <Add option="-DIRC" />
+ <Add option="-mwindows" />
+ <Add option="-fsigned-char" />
<Add directory="shared" />
<Add directory="engine" />
<Add directory="game" />
@@ -340,8 +343,8 @@
<Add directory="include" />
</Compiler>
<Linker>
- <Add option="-mwindows" />
<Add option="-m64" />
+ <Add option="-mwindows" />
<Add library="SDL" />
<Add library="SDL_image" />
<Add library="SDL_mixer" />
@@ -353,6 +356,9 @@
<Add directory="..\bin64" />
<Add directory="lib64" />
</Linker>
+ <Environment>
+ <Variable name="WINDRES_TARGET" value="pe-x86-64" />
+ </Environment>
</Target>
<Target title="server64">
<Option output="..\bin64\reserver.exe" prefix_auto="0" extension_auto="0" />
@@ -360,7 +366,7 @@
<Option object_output=".objs\server64" />
<Option deps_output=".deps\server" />
<Option type="0" />
- <Option compiler="gnu_gcc_compiler_for_64bit" />
+ <Option compiler="gcc" />
<Option projectCompilerOptionsRelation="1" />
<Option projectLinkerOptionsRelation="1" />
<Option projectIncludeDirsRelation="1" />
@@ -368,16 +374,14 @@
<Option projectLibDirsRelation="1" />
<Compiler>
<Add option="-fomit-frame-pointer" />
- <Add option="-O2" />
+ <Add option="-O3" />
<Add option="-Wall" />
+ <Add option="-m64" />
+ <Add option="-mwindows" />
<Add option="-fsigned-char" />
<Add option="-fno-exceptions" />
<Add option="-fno-rtti" />
- <Add option="-mwindows" />
- <Add option="-m64" />
<Add option="-DSTANDALONE" />
- <Add option="-DMASTERSERVER" />
- <Add option="-DIRC" />
<Add directory="shared" />
<Add directory="engine" />
<Add directory="game" />
@@ -386,8 +390,8 @@
</Compiler>
<Linker>
<Add option="-s" />
- <Add option="-mwindows" />
<Add option="-m64" />
+ <Add option="-mwindows" />
<Add library="zlib1" />
<Add library="enet" />
<Add library="ws2_32" />
@@ -395,6 +399,9 @@
<Add directory="..\bin64" />
<Add directory="lib64" />
</Linker>
+ <Environment>
+ <Variable name="WINDRES_TARGET" value="pe-x86-64" />
+ </Environment>
</Target>
<Target title="server64-dbg">
<Option output="..\bin64\reserver-dbg.exe" prefix_auto="0" extension_auto="0" />
@@ -402,7 +409,7 @@
<Option object_output=".objs\server64-dbg" />
<Option deps_output=".deps\server" />
<Option type="0" />
- <Option compiler="gnu_gcc_compiler_for_64bit" />
+ <Option compiler="gcc" />
<Option projectCompilerOptionsRelation="1" />
<Option projectLinkerOptionsRelation="1" />
<Option projectIncludeDirsRelation="1" />
@@ -411,12 +418,10 @@
<Compiler>
<Add option="-Wall" />
<Add option="-g" />
- <Add option="-fsigned-char" />
- <Add option="-mwindows" />
<Add option="-m64" />
+ <Add option="-mwindows" />
+ <Add option="-fsigned-char" />
<Add option="-DSTANDALONE" />
- <Add option="-DMASTERSERVER" />
- <Add option="-DIRC" />
<Add directory="shared" />
<Add directory="engine" />
<Add directory="game" />
@@ -424,8 +429,8 @@
<Add directory="include" />
</Compiler>
<Linker>
- <Add option="-mwindows" />
<Add option="-m64" />
+ <Add option="-mwindows" />
<Add library="zlib1" />
<Add library="enet" />
<Add library="ws2_32" />
@@ -433,19 +438,9 @@
<Add directory="..\bin64" />
<Add directory="lib64" />
</Linker>
- </Target>
- <Target title="data">
- <Option output="." prefix_auto="0" extension_auto="0" />
- <Option type="1" />
- <Option compiler="gcc" />
- <Option use_console_runner="0" />
- <Option projectResourceIncludeDirsRelation="1" />
- <Compiler>
- <Add option="-fsigned-char" />
- <Add option="-fomit-frame-pointer" />
- <Add option="-fno-exceptions" />
- <Add option="-fno-rtti" />
- </Compiler>
+ <Environment>
+ <Variable name="WINDRES_TARGET" value="pe-x86-64" />
+ </Environment>
</Target>
<Target title="genkey">
<Option output="..\bin\genkey.exe" prefix_auto="0" extension_auto="0" />
@@ -462,7 +457,7 @@
<Option projectLibDirsRelation="1" />
<Compiler>
<Add option="-fomit-frame-pointer" />
- <Add option="-O2" />
+ <Add option="-O3" />
<Add option="-Wall" />
<Add option="-fsigned-char" />
<Add option="-fno-exceptions" />
@@ -470,7 +465,6 @@
<Add option="-mwindows" />
<Add option="-m32" />
<Add option="-DSTANDALONE" />
- <Add option="-DGENKEY" />
<Add directory="shared" />
<Add directory="engine" />
<Add directory="game" />
@@ -479,12 +473,15 @@
</Compiler>
<Linker>
<Add option="-s" />
- <Add option="-mwindows" />
<Add option="-m32" />
+ <Add option="-mwindows" />
<Add library="zlib1" />
<Add directory="..\bin" />
<Add directory="lib" />
</Linker>
+ <Environment>
+ <Variable name="WINDRES_TARGET" value="pe-i386" />
+ </Environment>
</Target>
<Target title="cube2font">
<Option output="..\bin\cube2font.exe" prefix_auto="0" extension_auto="0" />
@@ -501,14 +498,13 @@
<Option projectLibDirsRelation="1" />
<Compiler>
<Add option="-fomit-frame-pointer" />
- <Add option="-O2" />
+ <Add option="-O3" />
<Add option="-Wall" />
<Add option="-fsigned-char" />
<Add option="-fno-exceptions" />
<Add option="-mwindows" />
<Add option="-m32" />
<Add option="-DSTANDALONE" />
- <Add option="-DGENKEY" />
<Add directory="shared" />
<Add directory="engine" />
<Add directory="game" />
@@ -517,20 +513,23 @@
</Compiler>
<Linker>
<Add option="-s" />
- <Add option="-mwindows" />
<Add option="-m32" />
+ <Add option="-mwindows" />
<Add library="freetype" />
<Add library="zlib1" />
<Add directory="..\bin" />
<Add directory="lib" />
</Linker>
+ <Environment>
+ <Variable name="WINDRES_TARGET" value="pe-i386" />
+ </Environment>
</Target>
</Build>
<VirtualTargets>
<Add alias="All" targets="client32;server32;client64;server64;" />
- <Add alias="32 bit" targets="client32;server32;" />
- <Add alias="64 bit" targets="client64;server64;" />
<Add alias="Tools" targets="cube2font;genkey;" />
+ <Add alias="x32" targets="client32;server32;" />
+ <Add alias="x64" targets="client64;server64;" />
</VirtualTargets>
<Unit filename="engine\animmodel.h">
<Option target="client32" />
@@ -543,14 +542,12 @@
<Unit filename="engine\bih.cpp">
<Option target="client32" />
<Option target="client32-dbg" />
- <Option target="data" />
<Option target="client32-prof" />
<Option target="client64" />
<Option target="client64-prof" />
<Option target="client64-dbg" />
</Unit>
<Unit filename="engine\bih.h">
- <Option target="data" />
<Option target="client32" />
<Option target="client32-dbg" />
<Option target="client32-prof" />
@@ -561,7 +558,6 @@
<Unit filename="engine\blend.cpp">
<Option target="client32" />
<Option target="client32-dbg" />
- <Option target="data" />
<Option target="client32-prof" />
<Option target="client64" />
<Option target="client64-prof" />
@@ -570,7 +566,6 @@
<Unit filename="engine\blob.cpp">
<Option target="client32" />
<Option target="client32-dbg" />
- <Option target="data" />
<Option target="client32-prof" />
<Option target="client64" />
<Option target="client64-prof" />
@@ -579,7 +574,6 @@
<Unit filename="engine\client.cpp">
<Option target="client32" />
<Option target="client32-dbg" />
- <Option target="data" />
<Option target="client32-prof" />
<Option target="client64" />
<Option target="client64-prof" />
@@ -600,7 +594,6 @@
<Unit filename="engine\console.cpp">
<Option target="client32" />
<Option target="client32-dbg" />
- <Option target="data" />
<Option target="client32-prof" />
<Option target="client64" />
<Option target="client64-prof" />
@@ -633,7 +626,6 @@
<Unit filename="engine\engine.h">
<Option compile="1" />
<Option weight="0" />
- <Option target="data" />
<Option target="client32" />
<Option target="client32-dbg" />
<Option target="client32-prof" />
@@ -711,14 +703,12 @@
<Unit filename="engine\lightmap.cpp">
<Option target="client32" />
<Option target="client32-dbg" />
- <Option target="data" />
<Option target="client32-prof" />
<Option target="client64" />
<Option target="client64-prof" />
<Option target="client64-dbg" />
</Unit>
<Unit filename="engine\lightmap.h">
- <Option target="data" />
<Option target="client32" />
<Option target="client32-dbg" />
<Option target="client32-prof" />
@@ -737,7 +727,6 @@
<Unit filename="engine\main.cpp">
<Option target="client32" />
<Option target="client32-dbg" />
- <Option target="data" />
<Option target="client32-prof" />
<Option target="client64" />
<Option target="client64-prof" />
@@ -758,14 +747,12 @@
<Unit filename="engine\material.cpp">
<Option target="client32" />
<Option target="client32-dbg" />
- <Option target="data" />
<Option target="client32-prof" />
<Option target="client64" />
<Option target="client64-prof" />
<Option target="client64-dbg" />
</Unit>
<Unit filename="engine\md2.h">
- <Option target="data" />
<Option target="client32" />
<Option target="client32-dbg" />
<Option target="client32-prof" />
@@ -774,7 +761,6 @@
<Option target="client64-dbg" />
</Unit>
<Unit filename="engine\md3.h">
- <Option target="data" />
<Option target="client32" />
<Option target="client32-dbg" />
<Option target="client32-prof" />
@@ -793,14 +779,12 @@
<Unit filename="engine\menus.cpp">
<Option target="client32" />
<Option target="client32-dbg" />
- <Option target="data" />
<Option target="client32-prof" />
<Option target="client64" />
<Option target="client64-prof" />
<Option target="client64-dbg" />
</Unit>
<Unit filename="engine\model.h">
- <Option target="data" />
<Option target="client32" />
<Option target="client32-dbg" />
<Option target="client32-prof" />
@@ -827,7 +811,6 @@
<Unit filename="engine\normal.cpp">
<Option target="client32" />
<Option target="client32-dbg" />
- <Option target="data" />
<Option target="client32-prof" />
<Option target="client64" />
<Option target="client64-prof" />
@@ -844,14 +827,12 @@
<Unit filename="engine\octa.cpp">
<Option target="client32" />
<Option target="client32-dbg" />
- <Option target="data" />
<Option target="client32-prof" />
<Option target="client64" />
<Option target="client64-prof" />
<Option target="client64-dbg" />
</Unit>
<Unit filename="engine\octa.h">
- <Option target="data" />
<Option target="client32" />
<Option target="client32-dbg" />
<Option target="client32-prof" />
@@ -862,7 +843,6 @@
<Unit filename="engine\octaedit.cpp">
<Option target="client32" />
<Option target="client32-dbg" />
- <Option target="data" />
<Option target="client32-prof" />
<Option target="client64" />
<Option target="client64-prof" />
@@ -871,7 +851,6 @@
<Unit filename="engine\octarender.cpp">
<Option target="client32" />
<Option target="client32-dbg" />
- <Option target="data" />
<Option target="client32-prof" />
<Option target="client64" />
<Option target="client64-prof" />
@@ -880,7 +859,6 @@
<Unit filename="engine\physics.cpp">
<Option target="client32" />
<Option target="client32-dbg" />
- <Option target="data" />
<Option target="client32-prof" />
<Option target="client64" />
<Option target="client64-prof" />
@@ -905,7 +883,6 @@
<Unit filename="engine\rendergl.cpp">
<Option target="client32" />
<Option target="client32-dbg" />
- <Option target="data" />
<Option target="client32-prof" />
<Option target="client64" />
<Option target="client64-prof" />
@@ -914,7 +891,6 @@
<Unit filename="engine\rendermodel.cpp">
<Option target="client32" />
<Option target="client32-dbg" />
- <Option target="data" />
<Option target="client32-prof" />
<Option target="client64" />
<Option target="client64-prof" />
@@ -923,7 +899,6 @@
<Unit filename="engine\renderparticles.cpp">
<Option target="client32" />
<Option target="client32-dbg" />
- <Option target="data" />
<Option target="client32-prof" />
<Option target="client64" />
<Option target="client64-prof" />
@@ -932,7 +907,6 @@
<Unit filename="engine\rendersky.cpp">
<Option target="client32" />
<Option target="client32-dbg" />
- <Option target="data" />
<Option target="client32-prof" />
<Option target="client64" />
<Option target="client64-prof" />
@@ -949,7 +923,6 @@
<Unit filename="engine\rendertext.cpp">
<Option target="client32" />
<Option target="client32-dbg" />
- <Option target="data" />
<Option target="client32-prof" />
<Option target="client64" />
<Option target="client64-prof" />
@@ -958,7 +931,6 @@
<Unit filename="engine\renderva.cpp">
<Option target="client32" />
<Option target="client32-dbg" />
- <Option target="data" />
<Option target="client32-prof" />
<Option target="client64" />
<Option target="client64-prof" />
@@ -976,7 +948,6 @@
<Option target="client32" />
<Option target="client32-dbg" />
<Option target="server32" />
- <Option target="data" />
<Option target="client32-prof" />
<Option target="server32-dbg" />
<Option target="client64" />
@@ -988,7 +959,6 @@
<Unit filename="engine\serverbrowser.cpp">
<Option target="client32" />
<Option target="client32-dbg" />
- <Option target="data" />
<Option target="client32-prof" />
<Option target="client64" />
<Option target="client64-prof" />
@@ -997,7 +967,6 @@
<Unit filename="engine\shader.cpp">
<Option target="client32" />
<Option target="client32-dbg" />
- <Option target="data" />
<Option target="client32-prof" />
<Option target="client64" />
<Option target="client64-prof" />
@@ -1030,7 +999,6 @@
<Unit filename="engine\sound.cpp">
<Option target="client32" />
<Option target="client32-dbg" />
- <Option target="data" />
<Option target="client32-prof" />
<Option target="client64" />
<Option target="client64-prof" />
@@ -1055,14 +1023,12 @@
<Unit filename="engine\texture.cpp">
<Option target="client32" />
<Option target="client32-dbg" />
- <Option target="data" />
<Option target="client32-prof" />
<Option target="client64" />
<Option target="client64-prof" />
<Option target="client64-dbg" />
</Unit>
<Unit filename="engine\texture.h">
- <Option target="data" />
<Option target="client32" />
<Option target="client32-dbg" />
<Option target="client32-prof" />
@@ -1073,14 +1039,12 @@
<Unit filename="engine\ui.cpp">
<Option target="client32" />
<Option target="client32-dbg" />
- <Option target="data" />
<Option target="client32-prof" />
<Option target="client64" />
<Option target="client64-prof" />
<Option target="client64-dbg" />
</Unit>
<Unit filename="engine\varray.h">
- <Option target="data" />
<Option target="client32" />
<Option target="client32-dbg" />
<Option target="client32-prof" />
@@ -1089,7 +1053,6 @@
<Option target="client64-dbg" />
</Unit>
<Unit filename="engine\vertmodel.h">
- <Option target="data" />
<Option target="client32" />
<Option target="client32-dbg" />
<Option target="client32-prof" />
@@ -1100,7 +1063,6 @@
<Unit filename="engine\water.cpp">
<Option target="client32" />
<Option target="client32-dbg" />
- <Option target="data" />
<Option target="client32-prof" />
<Option target="client64" />
<Option target="client64-prof" />
@@ -1109,14 +1071,12 @@
<Unit filename="engine\world.cpp">
<Option target="client32" />
<Option target="client32-dbg" />
- <Option target="data" />
<Option target="client32-prof" />
<Option target="client64" />
<Option target="client64-prof" />
<Option target="client64-dbg" />
</Unit>
<Unit filename="engine\world.h">
- <Option target="data" />
<Option target="client32" />
<Option target="client32-dbg" />
<Option target="client32-prof" />
@@ -1127,7 +1087,6 @@
<Unit filename="engine\worldio.cpp">
<Option target="client32" />
<Option target="client32-dbg" />
- <Option target="data" />
<Option target="client32-prof" />
<Option target="client64" />
<Option target="client64-prof" />
@@ -1330,12 +1289,11 @@
<Option target="client64-dbg" />
</Unit>
<Unit filename="game\game.h">
- <Option compile="1" />
<Option weight="0" />
<Option target="client32" />
<Option target="client32-dbg" />
- <Option target="server32" />
<Option target="client32-prof" />
+ <Option target="server32" />
<Option target="server32-dbg" />
<Option target="client64" />
<Option target="client64-prof" />
@@ -1781,6 +1739,7 @@
</Unit>
<Unit filename="redeclipse.rc">
<Option compilerVar="WINDRES" />
+ <Option compiler="gcc" use="1" buildCommand="$rescomp -F $WINDRES_TARGET -i $file -J rc -o $resource_output -O coff $res_includes" />
<Option target="client32" />
<Option target="client32-dbg" />
<Option target="server32" />
@@ -1824,7 +1783,6 @@
<Option target="client32" />
<Option target="client32-dbg" />
<Option target="client32-prof" />
- <Option target="data" />
<Option target="client64" />
<Option target="client64-prof" />
<Option target="client64-dbg" />
@@ -1834,7 +1792,6 @@
<Option target="cube2font" />
</Unit>
<Unit filename="shared\ents.h">
- <Option target="data" />
<Option target="client32" />
<Option target="client32-dbg" />
<Option target="client32-prof" />
@@ -1846,7 +1803,6 @@
<Option target="client32" />
<Option target="client32-dbg" />
<Option target="server32" />
- <Option target="data" />
<Option target="client32-prof" />
<Option target="server32-dbg" />
<Option target="client64" />
@@ -1856,7 +1812,6 @@
<Option target="server64-dbg" />
</Unit>
<Unit filename="shared\geom.h">
- <Option target="data" />
<Option target="client32" />
<Option target="client32-dbg" />
<Option target="client32-prof" />
@@ -1865,7 +1820,6 @@
<Option target="client64-dbg" />
</Unit>
<Unit filename="shared\iengine.h">
- <Option target="data" />
<Option target="client32" />
<Option target="client32-dbg" />
<Option target="client32-prof" />
@@ -1874,7 +1828,6 @@
<Option target="client64-dbg" />
</Unit>
<Unit filename="shared\igame.h">
- <Option target="data" />
<Option target="client32" />
<Option target="client32-dbg" />
<Option target="client32-prof" />
@@ -1914,7 +1867,6 @@
<Option target="client32-prof" />
<Option target="server32" />
<Option target="server32-dbg" />
- <Option target="data" />
<Option target="genkey" />
<Option target="client64" />
<Option target="client64-prof" />
diff --git a/src/shared/cube2font.c b/src/shared/cube2font.c
index b6f00ed..cb62df2 100644
--- a/src/shared/cube2font.c
+++ b/src/shared/cube2font.c
@@ -1,555 +1,555 @@
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <limits.h>
-#include <zlib.h>
-#include <ft2build.h>
-#include FT_FREETYPE_H
-#include FT_STROKER_H
-#include FT_GLYPH_H
-
-typedef unsigned char uchar;
-typedef unsigned short ushort;
-typedef unsigned int uint;
-
-int imin(int a, int b) { return a < b ? a : b; }
-int imax(int a, int b) { return a > b ? a : b; }
-
-void fatal(const char *fmt, ...)
-{
- va_list v;
- va_start(v, fmt);
- vfprintf(stderr, fmt, v);
- va_end(v);
- fputc('\n', stderr);
-
- exit(EXIT_FAILURE);
-}
-
-uint bigswap(uint n)
-{
- const int islittleendian = 1;
- return *(const uchar *)&islittleendian ? (n<<24) | (n>>24) | ((n>>8)&0xFF00) | ((n<<8)&0xFF0000) : n;
-}
-
-size_t writebig(FILE *f, uint n)
-{
- n = bigswap(n);
- return fwrite(&n, 1, sizeof(n), f);
-}
-
-void writepngchunk(FILE *f, const char *type, uchar *data, uint len)
-{
- uint crc;
- writebig(f, len);
- fwrite(type, 1, 4, f);
- fwrite(data, 1, len, f);
-
- crc = crc32(0, Z_NULL, 0);
- crc = crc32(crc, (const Bytef *)type, 4);
- if(data) crc = crc32(crc, data, len);
- writebig(f, crc);
-}
-
-struct pngihdr
-{
- uint width, height;
- uchar bitdepth, colortype, compress, filter, interlace;
-};
-
-void savepng(const char *filename, uchar *data, int w, int h, int bpp, int flip)
-{
- const uchar signature[] = { 137, 80, 78, 71, 13, 10, 26, 10 };
- struct pngihdr ihdr;
- FILE *f;
- long idat;
- uint len, crc;
- z_stream z;
- uchar buf[1<<12];
- int i, j;
-
- memset(&ihdr, 0, sizeof(ihdr));
- ihdr.width = bigswap(w);
- ihdr.height = bigswap(h);
- ihdr.bitdepth = 8;
- switch(bpp)
- {
- case 1: ihdr.colortype = 0; break;
- case 2: ihdr.colortype = 4; break;
- case 3: ihdr.colortype = 2; break;
- case 4: ihdr.colortype = 6; break;
- default: fatal("cube2font: invalid PNG bpp"); return;
- }
- f = fopen(filename, "wb");
- if(!f) { fatal("cube2font: could not write to %s", filename); return; }
-
- fwrite(signature, 1, sizeof(signature), f);
-
- writepngchunk(f, "IHDR", (uchar *)&ihdr, 13);
-
- idat = ftell(f);
- len = 0;
- fwrite("\0\0\0\0IDAT", 1, 8, f);
- crc = crc32(0, Z_NULL, 0);
- crc = crc32(crc, (const Bytef *)"IDAT", 4);
-
- z.zalloc = NULL;
- z.zfree = NULL;
- z.opaque = NULL;
-
- if(deflateInit(&z, Z_BEST_COMPRESSION) != Z_OK)
- goto error;
-
- z.next_out = (Bytef *)buf;
- z.avail_out = sizeof(buf);
-
- for(i = 0; i < h; i++)
- {
- uchar filter = 0;
- for(j = 0; j < 2; j++)
- {
- z.next_in = j ? (Bytef *)data + (flip ? h-i-1 : i)*w*bpp : (Bytef *)&filter;
- z.avail_in = j ? w*bpp : 1;
- while(z.avail_in > 0)
- {
- if(deflate(&z, Z_NO_FLUSH) != Z_OK) goto cleanuperror;
- #define FLUSHZ do { \
- int flush = sizeof(buf) - z.avail_out; \
- crc = crc32(crc, buf, flush); \
- len += flush; \
- fwrite(buf, 1, flush, f); \
- z.next_out = (Bytef *)buf; \
- z.avail_out = sizeof(buf); \
- } while(0)
- FLUSHZ;
- }
- }
- }
-
- for(;;)
- {
- int err = deflate(&z, Z_FINISH);
- if(err != Z_OK && err != Z_STREAM_END) goto cleanuperror;
- FLUSHZ;
- if(err == Z_STREAM_END) break;
- }
-
- deflateEnd(&z);
-
- fseek(f, idat, SEEK_SET);
- writebig(f, len);
- fseek(f, 0, SEEK_END);
- writebig(f, crc);
-
- writepngchunk(f, "IEND", NULL, 0);
-
- fclose(f);
- return;
-
-cleanuperror:
- deflateEnd(&z);
-
-error:
- fclose(f);
-
- fatal("cube2font: failed saving PNG to %s", filename);
-}
-
-enum
-{
- CT_PRINT = 1<<0,
- CT_SPACE = 1<<1,
- CT_DIGIT = 1<<2,
- CT_ALPHA = 1<<3,
- CT_LOWER = 1<<4,
- CT_UPPER = 1<<5,
- CT_UNICODE = 1<<6
-};
-#define CUBECTYPE(s, p, d, a, A, u, U) \
- 0, U, U, U, U, U, U, U, U, s, s, s, s, s, U, U, \
- U, U, U, U, U, U, U, U, U, U, U, U, U, U, U, U, \
- s, p, p, p, p, p, p, p, p, p, p, p, p, p, p, p, \
- d, d, d, d, d, d, d, d, d, d, p, p, p, p, p, p, \
- p, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, \
- A, A, A, A, A, A, A, A, A, A, A, p, p, p, p, p, \
- p, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, \
- a, a, a, a, a, a, a, a, a, a, a, p, p, p, p, U, \
- U, u, u, u, u, u, u, u, u, u, u, u, u, u, u, u, \
- u, u, u, u, u, u, u, u, u, u, u, u, u, u, u, U, \
- u, U, u, U, u, U, u, U, u, U, u, U, u, U, u, U, \
- u, U, u, U, u, U, u, U, u, U, u, U, u, U, u, U, \
- u, U, u, U, u, U, u, U, U, u, U, u, U, u, U, U, \
- U, U, U, U, U, U, U, U, U, U, U, U, U, U, U, U, \
- U, U, U, U, u, u, u, u, u, u, u, u, u, u, u, u, \
- u, u, u, u, u, u, u, u, u, u, u, u, u, u, U, u
-const uchar cubectype[256] =
-{
- CUBECTYPE(CT_SPACE,
- CT_PRINT,
- CT_PRINT|CT_DIGIT,
- CT_PRINT|CT_ALPHA|CT_LOWER,
- CT_PRINT|CT_ALPHA|CT_UPPER,
- CT_PRINT|CT_UNICODE|CT_ALPHA|CT_LOWER,
- CT_PRINT|CT_UNICODE|CT_ALPHA|CT_UPPER)
-};
-int iscubeprint(uchar c) { return cubectype[c]&CT_PRINT; }
-int iscubespace(uchar c) { return cubectype[c]&CT_SPACE; }
-int iscubealpha(uchar c) { return cubectype[c]&CT_ALPHA; }
-int iscubealnum(uchar c) { return cubectype[c]&(CT_ALPHA|CT_DIGIT); }
-int iscubelower(uchar c) { return cubectype[c]&CT_LOWER; }
-int iscubeupper(uchar c) { return cubectype[c]&CT_UPPER; }
-const int cube2unichars[256] =
-{
- 0, 192, 193, 194, 195, 196, 197, 198, 199, 9, 10, 11, 12, 13, 200, 201,
- 202, 203, 204, 205, 206, 207, 209, 210, 211, 212, 213, 214, 216, 217, 218, 219,
- 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
- 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
- 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
- 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
- 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
- 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 220,
- 221, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237,
- 238, 239, 241, 242, 243, 244, 245, 246, 248, 249, 250, 251, 252, 253, 255, 0x104,
- 0x105, 0x106, 0x107, 0x10C, 0x10D, 0x10E, 0x10F, 0x118, 0x119, 0x11A, 0x11B, 0x11E, 0x11F, 0x130, 0x131, 0x141,
- 0x142, 0x143, 0x144, 0x147, 0x148, 0x150, 0x151, 0x152, 0x153, 0x158, 0x159, 0x15A, 0x15B, 0x15E, 0x15F, 0x160,
- 0x161, 0x164, 0x165, 0x16E, 0x16F, 0x170, 0x171, 0x178, 0x179, 0x17A, 0x17B, 0x17C, 0x17D, 0x17E, 0x404, 0x411,
- 0x413, 0x414, 0x416, 0x417, 0x418, 0x419, 0x41B, 0x41F, 0x423, 0x424, 0x426, 0x427, 0x428, 0x429, 0x42A, 0x42B,
- 0x42C, 0x42D, 0x42E, 0x42F, 0x431, 0x432, 0x433, 0x434, 0x436, 0x437, 0x438, 0x439, 0x43A, 0x43B, 0x43C, 0x43D,
- 0x43F, 0x442, 0x444, 0x446, 0x447, 0x448, 0x449, 0x44A, 0x44B, 0x44C, 0x44D, 0x44E, 0x44F, 0x454, 0x490, 0x491
-};
-int cube2uni(uchar c)
-{
- return cube2unichars[c];
-}
-
-const char *encodeutf8(int uni)
-{
- static char buf[7];
- char *dst = buf;
- if(uni <= 0x7F) { *dst++ = uni; goto uni1; }
- else if(uni <= 0x7FF) { *dst++ = 0xC0 | (uni>>6); goto uni2; }
- else if(uni <= 0xFFFF) { *dst++ = 0xE0 | (uni>>12); goto uni3; }
- else if(uni <= 0x1FFFFF) { *dst++ = 0xF0 | (uni>>18); goto uni4; }
- else if(uni <= 0x3FFFFFF) { *dst++ = 0xF8 | (uni>>24); goto uni5; }
- else if(uni <= 0x7FFFFFFF) { *dst++ = 0xFC | (uni>>30); goto uni6; }
- else goto uni1;
-uni6: *dst++ = 0x80 | ((uni>>24)&0x3F);
-uni5: *dst++ = 0x80 | ((uni>>18)&0x3F);
-uni4: *dst++ = 0x80 | ((uni>>12)&0x3F);
-uni3: *dst++ = 0x80 | ((uni>>6)&0x3F);
-uni2: *dst++ = 0x80 | (uni&0x3F);
-uni1: *dst++ = '\0';
- return buf;
-}
-
-struct fontchar { int code, uni, tex, x, y, w, h, offx, offy, offset, advance; FT_BitmapGlyph color, alpha; };
-
-const char *texdir = "";
-
-const char *texfilename(const char *name, int texnum)
-{
- static char file[256];
- snprintf(file, sizeof(file), "%s%d.png", name, texnum);
- return file;
-}
-
-const char *texname(const char *name, int texnum)
-{
- static char file[512];
- snprintf(file, sizeof(file), "<grey>%s%s", texdir, texfilename(name, texnum));
- return file;
-}
-
-void writetexs(const char *name, struct fontchar *chars, int numchars, int numtexs, int tw, int th)
-{
- int tex;
- uchar *pixels = (uchar *)malloc(tw*th*2);
- if(!pixels) fatal("cube2font: failed allocating textures");
- for(tex = 0; tex < numtexs; tex++)
- {
- const char *file = texfilename(name, tex);
- int texchars = 0, i;
- uchar *dst, *src;
- memset(pixels, 0, tw*th*2);
- for(i = 0; i < numchars; i++)
- {
- struct fontchar *c = &chars[i];
- int x, y;
- if(c->tex != tex) continue;
- texchars++;
- dst = &pixels[2*((c->y + c->offy - c->color->top)*tw + c->x + c->color->left - c->offx)];
- src = (uchar *)c->color->bitmap.buffer;
- for(y = 0; y < c->color->bitmap.rows; y++)
- {
- for(x = 0; x < c->color->bitmap.width; x++)
- dst[2*x] = src[x];
- src += c->color->bitmap.pitch;
- dst += 2*tw;
- }
- dst = &pixels[2*((c->y + c->offy - c->alpha->top)*tw + c->x + c->alpha->left - c->offx)];
- src = (uchar *)c->alpha->bitmap.buffer;
- for(y = 0; y < c->alpha->bitmap.rows; y++)
- {
- for(x = 0; x < c->alpha->bitmap.width; x++)
- dst[2*x+1] = src[x];
- src += c->alpha->bitmap.pitch;
- dst += 2*tw;
- }
- }
- printf("cube2font: writing %d chars to %s\n", texchars, file);
- savepng(file, pixels, tw, th, 2, 0);
- }
- free(pixels);
-}
-
-void writecfg(const char *name, struct fontchar *chars, int numchars, int x1, int y1, int x2, int y2, int sw, int sh, int argc, char **argv)
-{
- FILE *f;
- char file[256];
- int i, lastcode = 0, lasttex = 0;
- snprintf(file, sizeof(file), "%s.cfg", name);
- f = fopen(file, "w");
- if(!f) fatal("cube2font: failed writing %s", file);
- printf("cube2font: writing %d chars to %s\n", numchars, file);
- fprintf(f, "//");
- for(i = 1; i < argc; i++)
- fprintf(f, " %s", argv[i]);
- fprintf(f, "\n");
- fprintf(f, "font \"%s\" \"%s\" %d %d\n", name, texname(name, 0), sw, sh);
- for(i = 0; i < numchars; i++)
- {
- struct fontchar *c = &chars[i];
- if(!lastcode && lastcode < c->code)
- {
- fprintf(f, "fontoffset \"%s\"\n", encodeutf8(c->uni));
- lastcode = c->code;
- }
- else if(lastcode < c->code)
- {
- if(lastcode + 1 == c->code)
- fprintf(f, "fontskip // %d\n", lastcode);
- else
- fprintf(f, "fontskip %d // %d .. %d\n", c->code - lastcode, lastcode, c->code-1);
- lastcode = c->code;
- }
- if(lasttex != c->tex)
- {
- fprintf(f, "\nfonttex \"%s\"\n", texname(name, c->tex));
- lasttex = c->tex;
- }
- if(c->code != c->uni)
- fprintf(f, "fontchar %d %d %d %d %d %d %d // %s (%d -> 0x%X)\n", c->x, c->y, c->w, c->h, c->offx+c->offset, y2-c->offy, c->advance, encodeutf8(c->uni), c->code, c->uni);
- else
- fprintf(f, "fontchar %d %d %d %d %d %d %d // %s (%d)\n", c->x, c->y, c->w, c->h, c->offx+c->offset, y2-c->offy, c->advance, encodeutf8(c->uni), c->code);
- lastcode++;
- }
- fclose(f);
-}
-
-int groupchar(int c)
-{
- switch(c)
- {
- case 0x152: case 0x153: case 0x178: return 1;
- }
- if(c < 127 || c >= 0x2000) return 0;
- if(c < 0x100) return 1;
- if(c < 0x400) return 2;
- return 3;
-}
-
-int sortchars(const void *x, const void *y)
-{
- const struct fontchar *xc = *(const struct fontchar **)x, *yc = *(const struct fontchar **)y;
- int xg = groupchar(xc->uni), yg = groupchar(yc->uni);
- if(xg < yg) return -1;
- if(xg > yg) return 1;
- if(xc->h != yc->h) return yc->h - xc->h;
- if(xc->w != yc->w) return yc->w - xc->w;
- return yc->uni - xc->uni;
-}
-
-int scorechar(struct fontchar *f, int pad, int tw, int th, int rw, int rh, int ry)
-{
- int score = 0;
- if(rw + f->w > tw) { ry += rh + pad; score = 1; }
- if(ry + f->h > th) score = 2;
- return score;
-}
-
-int main(int argc, char **argv)
-{
- FT_Library l;
- FT_Face f;
- FT_Stroker s, s2;
- int i, pad, offset, advance, w, h, tw, th, c, trial = -2, rw = 0, rh = 0, ry = 0, x1 = INT_MAX, x2 = INT_MIN, y1 = INT_MAX, y2 = INT_MIN, w2 = 0, h2 = 0, sw = 0, sh = 0;
- float outborder = 0, inborder = 0;
- struct fontchar chars[256];
- struct fontchar *order[256];
- int numchars = 0, numtex = 0;
- if(argc < 11)
- fatal("Usage: cube2font infile outfile outborder[:inborder] pad offset advance charwidth charheight texwidth texheight [spacewidth spaceheight texdir]");
- sscanf(argv[3], "%f:%f", &outborder, &inborder);
- pad = atoi(argv[4]);
- offset = atoi(argv[5]);
- advance = atoi(argv[6]);
- w = atoi(argv[7]);
- h = atoi(argv[8]);
- tw = atoi(argv[9]);
- th = atoi(argv[10]);
- if(argc > 11) sw = atoi(argv[11]);
- if(argc > 12) sh = atoi(argv[12]);
- if(argc > 13) texdir = argv[13];
- if(FT_Init_FreeType(&l))
- fatal("cube2font: failed initing freetype");
- if(FT_New_Face(l, argv[1], 0, &f) ||
- FT_Set_Charmap(f, f->charmaps[0]) ||
- FT_Set_Pixel_Sizes(f, w, h) ||
- FT_Stroker_New(l, &s) ||
- FT_Stroker_New(l, &s2))
- fatal("cube2font: failed loading font %s", argv[1]);
- if(outborder > 0) FT_Stroker_Set(s, (FT_Fixed)(outborder * 64), FT_STROKER_LINECAP_ROUND, FT_STROKER_LINEJOIN_ROUND, 0);
- if(inborder > 0) FT_Stroker_Set(s2, (FT_Fixed)(inborder * 64), FT_STROKER_LINECAP_ROUND, FT_STROKER_LINEJOIN_ROUND, 0);
- for(c = 0; c < 256; c++) if(iscubeprint(c))
- {
- FT_Glyph p, p2;
- FT_BitmapGlyph b, b2;
- struct fontchar *dst = &chars[numchars];
- dst->code = c;
- dst->uni = cube2uni(c);
- if(FT_Load_Char(f, dst->uni, FT_LOAD_DEFAULT))
- fatal("cube2font: failed loading character %s", encodeutf8(dst->uni));
- FT_Get_Glyph(f->glyph, &p);
- p2 = p;
- if(outborder > 0) FT_Glyph_StrokeBorder(&p, s, 0, 0);
- if(inborder > 0) FT_Glyph_StrokeBorder(&p2, s2, 1, 0);
- FT_Glyph_To_Bitmap(&p, FT_RENDER_MODE_NORMAL, 0, 1);
- FT_Glyph_To_Bitmap(&p2, FT_RENDER_MODE_NORMAL, 0, 1);
- b = (FT_BitmapGlyph)p;
- b2 = (FT_BitmapGlyph)p2;
- dst->tex = -1;
- dst->x = INT_MIN;
- dst->y = INT_MIN;
- dst->offx = imin(b->left, b2->left);
- dst->offy = imax(b->top, b2->top);
- dst->offset = offset;
- dst->advance = offset + ((p->advance.x+0xFFFF)>>16) + advance;
- dst->w = imax(b->left + b->bitmap.width, b2->left + b2->bitmap.width) - dst->offx;
- dst->h = dst->offy - imin(b->top - b->bitmap.rows, b2->top - b2->bitmap.rows);
- dst->alpha = b;
- dst->color = b2;
- order[numchars++] = dst;
- }
- qsort(order, numchars, sizeof(order[0]), sortchars);
- for(i = 0; i < numchars;)
- {
- struct fontchar *dst;
- int j, k, trial0, prevscore, dstscore, fitscore;
- for(trial0 = trial, prevscore = -1; (trial -= 2) >= trial0-512;)
- {
- int g, fw = rw, fh = rh, fy = ry, curscore = 0, reused = 0;
- for(j = i; j < numchars; j++)
- {
- dst = order[j];
- if(dst->tex >= 0 || dst->tex <= trial) continue;
- g = groupchar(dst->uni);
- dstscore = scorechar(dst, pad, tw, th, fw, fh, fy);
- for(k = j; k < numchars; k++)
- {
- struct fontchar *fit = order[k];
- if(fit->tex >= 0 || fit->tex <= trial) continue;
- if(fit->tex >= trial0 && groupchar(fit->uni) != g) break;
- fitscore = scorechar(fit, pad, tw, th, fw, fh, fy);
- if(fitscore < dstscore || (fitscore == dstscore && fit->h > dst->h))
- {
- dst = fit;
- dstscore = fitscore;
- }
- }
- if(fw + dst->w > tw)
- {
- fy += fh + pad;
- fw = fh = 0;
- }
- if(fy + dst->h > th)
- {
- fy = fw = fh = 0;
- if(curscore > 0) break;
- }
- if(dst->tex >= trial+1 && dst->tex <= trial+2) { dst->tex = trial; reused++; }
- else dst->tex = trial;
- fw += dst->w + pad;
- fh = imax(fh, dst->h);
- if(dst != order[j]) --j;
- curscore++;
- }
- if(reused < prevscore || curscore <= prevscore) break;
- prevscore = curscore;
- }
- for(; i < numchars; i++)
- {
- dst = order[i];
- if(dst->tex >= 0) continue;
- dstscore = scorechar(dst, pad, tw, th, rw, rh, ry);
- for(j = i; j < numchars; j++)
- {
- struct fontchar *fit = order[j];
- if(fit->tex < trial || fit->tex > trial+2) continue;
- fitscore = scorechar(fit, pad, tw, th, rw, rh, ry);
- if(fitscore < dstscore || (fitscore == dstscore && fit->h > dst->h))
- {
- dst = fit;
- dstscore = fitscore;
- }
- }
- if(dst->tex < trial || dst->tex > trial+2) break;
- if(rw + dst->w > tw)
- {
- ry += rh + pad;
- rw = rh = 0;
- }
- if(ry + dst->h > th)
- {
- ry = rw = rh = 0;
- numtex++;
- }
- dst->tex = numtex;
- dst->x = rw;
- dst->y = ry;
- rw += dst->w + pad;
- rh = imax(rh, dst->h);
- y1 = imin(y1, dst->offy - dst->h);
- y2 = imax(y2, dst->offy);
- x1 = imin(x1, dst->offx);
- x2 = imax(x2, dst->offx + dst->w);
- w2 = imax(w2, dst->w);
- h2 = imax(h2, dst->h);
- if(dst != order[i]) --i;
- }
- }
- if(rh > 0) numtex++;
-#if 0
- if(sw <= 0)
- {
- if(FT_Load_Char(f, ' ', FT_LOAD_DEFAULT))
- fatal("cube2font: failed loading space character");
- sw = (f->glyph->advance.x+0x3F)>>6;
- }
-#endif
- if(sh <= 0) sh = y2 - y1;
- if(sw <= 0) sw = sh/3;
- writetexs(argv[2], chars, numchars, numtex, tw, th);
- writecfg(argv[2], chars, numchars, x1, y1, x2, y2, sw, sh, argc, argv);
- for(i = 0; i < numchars; i++)
- {
- FT_Done_Glyph((FT_Glyph)chars[i].alpha);
- FT_Done_Glyph((FT_Glyph)chars[i].color);
- }
- FT_Stroker_Done(s);
- FT_Stroker_Done(s2);
- FT_Done_FreeType(l);
- printf("cube2font: (%d, %d) .. (%d, %d) = (%d, %d) / (%d, %d), %d texs\n", x1, y1, x2, y2, x2 - x1, y2 - y1, w2, h2, numtex);
- return EXIT_SUCCESS;
-}
-
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <limits.h>
+#include <zlib.h>
+#include <ft2build.h>
+#include FT_FREETYPE_H
+#include FT_STROKER_H
+#include FT_GLYPH_H
+
+typedef unsigned char uchar;
+typedef unsigned short ushort;
+typedef unsigned int uint;
+
+int imin(int a, int b) { return a < b ? a : b; }
+int imax(int a, int b) { return a > b ? a : b; }
+
+void fatal(const char *fmt, ...)
+{
+ va_list v;
+ va_start(v, fmt);
+ vfprintf(stderr, fmt, v);
+ va_end(v);
+ fputc('\n', stderr);
+
+ exit(EXIT_FAILURE);
+}
+
+uint bigswap(uint n)
+{
+ const int islittleendian = 1;
+ return *(const uchar *)&islittleendian ? (n<<24) | (n>>24) | ((n>>8)&0xFF00) | ((n<<8)&0xFF0000) : n;
+}
+
+size_t writebig(FILE *f, uint n)
+{
+ n = bigswap(n);
+ return fwrite(&n, 1, sizeof(n), f);
+}
+
+void writepngchunk(FILE *f, const char *type, uchar *data, uint len)
+{
+ uint crc;
+ writebig(f, len);
+ fwrite(type, 1, 4, f);
+ fwrite(data, 1, len, f);
+
+ crc = crc32(0, Z_NULL, 0);
+ crc = crc32(crc, (const Bytef *)type, 4);
+ if(data) crc = crc32(crc, data, len);
+ writebig(f, crc);
+}
+
+struct pngihdr
+{
+ uint width, height;
+ uchar bitdepth, colortype, compress, filter, interlace;
+};
+
+void savepng(const char *filename, uchar *data, int w, int h, int bpp, int flip)
+{
+ const uchar signature[] = { 137, 80, 78, 71, 13, 10, 26, 10 };
+ struct pngihdr ihdr;
+ FILE *f;
+ long idat;
+ uint len, crc;
+ z_stream z;
+ uchar buf[1<<12];
+ int i, j;
+
+ memset(&ihdr, 0, sizeof(ihdr));
+ ihdr.width = bigswap(w);
+ ihdr.height = bigswap(h);
+ ihdr.bitdepth = 8;
+ switch(bpp)
+ {
+ case 1: ihdr.colortype = 0; break;
+ case 2: ihdr.colortype = 4; break;
+ case 3: ihdr.colortype = 2; break;
+ case 4: ihdr.colortype = 6; break;
+ default: fatal("cube2font: invalid PNG bpp"); return;
+ }
+ f = fopen(filename, "wb");
+ if(!f) { fatal("cube2font: could not write to %s", filename); return; }
+
+ fwrite(signature, 1, sizeof(signature), f);
+
+ writepngchunk(f, "IHDR", (uchar *)&ihdr, 13);
+
+ idat = ftell(f);
+ len = 0;
+ fwrite("\0\0\0\0IDAT", 1, 8, f);
+ crc = crc32(0, Z_NULL, 0);
+ crc = crc32(crc, (const Bytef *)"IDAT", 4);
+
+ z.zalloc = NULL;
+ z.zfree = NULL;
+ z.opaque = NULL;
+
+ if(deflateInit(&z, Z_BEST_COMPRESSION) != Z_OK)
+ goto error;
+
+ z.next_out = (Bytef *)buf;
+ z.avail_out = sizeof(buf);
+
+ for(i = 0; i < h; i++)
+ {
+ uchar filter = 0;
+ for(j = 0; j < 2; j++)
+ {
+ z.next_in = j ? (Bytef *)data + (flip ? h-i-1 : i)*w*bpp : (Bytef *)&filter;
+ z.avail_in = j ? w*bpp : 1;
+ while(z.avail_in > 0)
+ {
+ if(deflate(&z, Z_NO_FLUSH) != Z_OK) goto cleanuperror;
+ #define FLUSHZ do { \
+ int flush = sizeof(buf) - z.avail_out; \
+ crc = crc32(crc, buf, flush); \
+ len += flush; \
+ fwrite(buf, 1, flush, f); \
+ z.next_out = (Bytef *)buf; \
+ z.avail_out = sizeof(buf); \
+ } while(0)
+ FLUSHZ;
+ }
+ }
+ }
+
+ for(;;)
+ {
+ int err = deflate(&z, Z_FINISH);
+ if(err != Z_OK && err != Z_STREAM_END) goto cleanuperror;
+ FLUSHZ;
+ if(err == Z_STREAM_END) break;
+ }
+
+ deflateEnd(&z);
+
+ fseek(f, idat, SEEK_SET);
+ writebig(f, len);
+ fseek(f, 0, SEEK_END);
+ writebig(f, crc);
+
+ writepngchunk(f, "IEND", NULL, 0);
+
+ fclose(f);
+ return;
+
+cleanuperror:
+ deflateEnd(&z);
+
+error:
+ fclose(f);
+
+ fatal("cube2font: failed saving PNG to %s", filename);
+}
+
+enum
+{
+ CT_PRINT = 1<<0,
+ CT_SPACE = 1<<1,
+ CT_DIGIT = 1<<2,
+ CT_ALPHA = 1<<3,
+ CT_LOWER = 1<<4,
+ CT_UPPER = 1<<5,
+ CT_UNICODE = 1<<6
+};
+#define CUBECTYPE(s, p, d, a, A, u, U) \
+ 0, U, U, U, U, U, U, U, U, s, s, s, s, s, U, U, \
+ U, U, U, U, U, U, U, U, U, U, U, U, U, U, U, U, \
+ s, p, p, p, p, p, p, p, p, p, p, p, p, p, p, p, \
+ d, d, d, d, d, d, d, d, d, d, p, p, p, p, p, p, \
+ p, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, \
+ A, A, A, A, A, A, A, A, A, A, A, p, p, p, p, p, \
+ p, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, \
+ a, a, a, a, a, a, a, a, a, a, a, p, p, p, p, U, \
+ U, u, u, u, u, u, u, u, u, u, u, u, u, u, u, u, \
+ u, u, u, u, u, u, u, u, u, u, u, u, u, u, u, U, \
+ u, U, u, U, u, U, u, U, u, U, u, U, u, U, u, U, \
+ u, U, u, U, u, U, u, U, u, U, u, U, u, U, u, U, \
+ u, U, u, U, u, U, u, U, U, u, U, u, U, u, U, U, \
+ U, U, U, U, U, U, U, U, U, U, U, U, U, U, U, U, \
+ U, U, U, U, u, u, u, u, u, u, u, u, u, u, u, u, \
+ u, u, u, u, u, u, u, u, u, u, u, u, u, u, U, u
+const uchar cubectype[256] =
+{
+ CUBECTYPE(CT_SPACE,
+ CT_PRINT,
+ CT_PRINT|CT_DIGIT,
+ CT_PRINT|CT_ALPHA|CT_LOWER,
+ CT_PRINT|CT_ALPHA|CT_UPPER,
+ CT_PRINT|CT_UNICODE|CT_ALPHA|CT_LOWER,
+ CT_PRINT|CT_UNICODE|CT_ALPHA|CT_UPPER)
+};
+int iscubeprint(uchar c) { return cubectype[c]&CT_PRINT; }
+int iscubespace(uchar c) { return cubectype[c]&CT_SPACE; }
+int iscubealpha(uchar c) { return cubectype[c]&CT_ALPHA; }
+int iscubealnum(uchar c) { return cubectype[c]&(CT_ALPHA|CT_DIGIT); }
+int iscubelower(uchar c) { return cubectype[c]&CT_LOWER; }
+int iscubeupper(uchar c) { return cubectype[c]&CT_UPPER; }
+const int cube2unichars[256] =
+{
+ 0, 192, 193, 194, 195, 196, 197, 198, 199, 9, 10, 11, 12, 13, 200, 201,
+ 202, 203, 204, 205, 206, 207, 209, 210, 211, 212, 213, 214, 216, 217, 218, 219,
+ 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
+ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
+ 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
+ 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
+ 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
+ 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 220,
+ 221, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237,
+ 238, 239, 241, 242, 243, 244, 245, 246, 248, 249, 250, 251, 252, 253, 255, 0x104,
+ 0x105, 0x106, 0x107, 0x10C, 0x10D, 0x10E, 0x10F, 0x118, 0x119, 0x11A, 0x11B, 0x11E, 0x11F, 0x130, 0x131, 0x141,
+ 0x142, 0x143, 0x144, 0x147, 0x148, 0x150, 0x151, 0x152, 0x153, 0x158, 0x159, 0x15A, 0x15B, 0x15E, 0x15F, 0x160,
+ 0x161, 0x164, 0x165, 0x16E, 0x16F, 0x170, 0x171, 0x178, 0x179, 0x17A, 0x17B, 0x17C, 0x17D, 0x17E, 0x404, 0x411,
+ 0x413, 0x414, 0x416, 0x417, 0x418, 0x419, 0x41B, 0x41F, 0x423, 0x424, 0x426, 0x427, 0x428, 0x429, 0x42A, 0x42B,
+ 0x42C, 0x42D, 0x42E, 0x42F, 0x431, 0x432, 0x433, 0x434, 0x436, 0x437, 0x438, 0x439, 0x43A, 0x43B, 0x43C, 0x43D,
+ 0x43F, 0x442, 0x444, 0x446, 0x447, 0x448, 0x449, 0x44A, 0x44B, 0x44C, 0x44D, 0x44E, 0x44F, 0x454, 0x490, 0x491
+};
+int cube2uni(uchar c)
+{
+ return cube2unichars[c];
+}
+
+const char *encodeutf8(int uni)
+{
+ static char buf[7];
+ char *dst = buf;
+ if(uni <= 0x7F) { *dst++ = uni; goto uni1; }
+ else if(uni <= 0x7FF) { *dst++ = 0xC0 | (uni>>6); goto uni2; }
+ else if(uni <= 0xFFFF) { *dst++ = 0xE0 | (uni>>12); goto uni3; }
+ else if(uni <= 0x1FFFFF) { *dst++ = 0xF0 | (uni>>18); goto uni4; }
+ else if(uni <= 0x3FFFFFF) { *dst++ = 0xF8 | (uni>>24); goto uni5; }
+ else if(uni <= 0x7FFFFFFF) { *dst++ = 0xFC | (uni>>30); goto uni6; }
+ else goto uni1;
+uni6: *dst++ = 0x80 | ((uni>>24)&0x3F);
+uni5: *dst++ = 0x80 | ((uni>>18)&0x3F);
+uni4: *dst++ = 0x80 | ((uni>>12)&0x3F);
+uni3: *dst++ = 0x80 | ((uni>>6)&0x3F);
+uni2: *dst++ = 0x80 | (uni&0x3F);
+uni1: *dst++ = '\0';
+ return buf;
+}
+
+struct fontchar { int code, uni, tex, x, y, w, h, offx, offy, offset, advance; FT_BitmapGlyph color, alpha; };
+
+const char *texdir = "";
+
+const char *texfilename(const char *name, int texnum)
+{
+ static char file[256];
+ snprintf(file, sizeof(file), "%s%d.png", name, texnum);
+ return file;
+}
+
+const char *texname(const char *name, int texnum)
+{
+ static char file[512];
+ snprintf(file, sizeof(file), "<grey>%s%s", texdir, texfilename(name, texnum));
+ return file;
+}
+
+void writetexs(const char *name, struct fontchar *chars, int numchars, int numtexs, int tw, int th)
+{
+ int tex;
+ uchar *pixels = (uchar *)malloc(tw*th*2);
+ if(!pixels) fatal("cube2font: failed allocating textures");
+ for(tex = 0; tex < numtexs; tex++)
+ {
+ const char *file = texfilename(name, tex);
+ int texchars = 0, i;
+ uchar *dst, *src;
+ memset(pixels, 0, tw*th*2);
+ for(i = 0; i < numchars; i++)
+ {
+ struct fontchar *c = &chars[i];
+ int x, y;
+ if(c->tex != tex) continue;
+ texchars++;
+ dst = &pixels[2*((c->y + c->offy - c->color->top)*tw + c->x + c->color->left - c->offx)];
+ src = (uchar *)c->color->bitmap.buffer;
+ for(y = 0; y < c->color->bitmap.rows; y++)
+ {
+ for(x = 0; x < c->color->bitmap.width; x++)
+ dst[2*x] = src[x];
+ src += c->color->bitmap.pitch;
+ dst += 2*tw;
+ }
+ dst = &pixels[2*((c->y + c->offy - c->alpha->top)*tw + c->x + c->alpha->left - c->offx)];
+ src = (uchar *)c->alpha->bitmap.buffer;
+ for(y = 0; y < c->alpha->bitmap.rows; y++)
+ {
+ for(x = 0; x < c->alpha->bitmap.width; x++)
+ dst[2*x+1] = src[x];
+ src += c->alpha->bitmap.pitch;
+ dst += 2*tw;
+ }
+ }
+ printf("cube2font: writing %d chars to %s\n", texchars, file);
+ savepng(file, pixels, tw, th, 2, 0);
+ }
+ free(pixels);
+}
+
+void writecfg(const char *name, struct fontchar *chars, int numchars, int x1, int y1, int x2, int y2, int sw, int sh, int argc, char **argv)
+{
+ FILE *f;
+ char file[256];
+ int i, lastcode = 0, lasttex = 0;
+ snprintf(file, sizeof(file), "%s.cfg", name);
+ f = fopen(file, "w");
+ if(!f) fatal("cube2font: failed writing %s", file);
+ printf("cube2font: writing %d chars to %s\n", numchars, file);
+ fprintf(f, "//");
+ for(i = 1; i < argc; i++)
+ fprintf(f, " %s", argv[i]);
+ fprintf(f, "\n");
+ fprintf(f, "font \"%s\" \"%s\" %d %d\n", name, texname(name, 0), sw, sh);
+ for(i = 0; i < numchars; i++)
+ {
+ struct fontchar *c = &chars[i];
+ if(!lastcode && lastcode < c->code)
+ {
+ fprintf(f, "fontoffset \"%s\"\n", encodeutf8(c->uni));
+ lastcode = c->code;
+ }
+ else if(lastcode < c->code)
+ {
+ if(lastcode + 1 == c->code)
+ fprintf(f, "fontskip // %d\n", lastcode);
+ else
+ fprintf(f, "fontskip %d // %d .. %d\n", c->code - lastcode, lastcode, c->code-1);
+ lastcode = c->code;
+ }
+ if(lasttex != c->tex)
+ {
+ fprintf(f, "\nfonttex \"%s\"\n", texname(name, c->tex));
+ lasttex = c->tex;
+ }
+ if(c->code != c->uni)
+ fprintf(f, "fontchar %d %d %d %d %d %d %d // %s (%d -> 0x%X)\n", c->x, c->y, c->w, c->h, c->offx+c->offset, y2-c->offy, c->advance, encodeutf8(c->uni), c->code, c->uni);
+ else
+ fprintf(f, "fontchar %d %d %d %d %d %d %d // %s (%d)\n", c->x, c->y, c->w, c->h, c->offx+c->offset, y2-c->offy, c->advance, encodeutf8(c->uni), c->code);
+ lastcode++;
+ }
+ fclose(f);
+}
+
+int groupchar(int c)
+{
+ switch(c)
+ {
+ case 0x152: case 0x153: case 0x178: return 1;
+ }
+ if(c < 127 || c >= 0x2000) return 0;
+ if(c < 0x100) return 1;
+ if(c < 0x400) return 2;
+ return 3;
+}
+
+int sortchars(const void *x, const void *y)
+{
+ const struct fontchar *xc = *(const struct fontchar **)x, *yc = *(const struct fontchar **)y;
+ int xg = groupchar(xc->uni), yg = groupchar(yc->uni);
+ if(xg < yg) return -1;
+ if(xg > yg) return 1;
+ if(xc->h != yc->h) return yc->h - xc->h;
+ if(xc->w != yc->w) return yc->w - xc->w;
+ return yc->uni - xc->uni;
+}
+
+int scorechar(struct fontchar *f, int pad, int tw, int th, int rw, int rh, int ry)
+{
+ int score = 0;
+ if(rw + f->w > tw) { ry += rh + pad; score = 1; }
+ if(ry + f->h > th) score = 2;
+ return score;
+}
+
+int main(int argc, char **argv)
+{
+ FT_Library l;
+ FT_Face f;
+ FT_Stroker s, s2;
+ int i, pad, offset, advance, w, h, tw, th, c, trial = -2, rw = 0, rh = 0, ry = 0, x1 = INT_MAX, x2 = INT_MIN, y1 = INT_MAX, y2 = INT_MIN, w2 = 0, h2 = 0, sw = 0, sh = 0;
+ float outborder = 0, inborder = 0;
+ struct fontchar chars[256];
+ struct fontchar *order[256];
+ int numchars = 0, numtex = 0;
+ if(argc < 11)
+ fatal("Usage: cube2font infile outfile outborder[:inborder] pad offset advance charwidth charheight texwidth texheight [spacewidth spaceheight texdir]");
+ sscanf(argv[3], "%f:%f", &outborder, &inborder);
+ pad = atoi(argv[4]);
+ offset = atoi(argv[5]);
+ advance = atoi(argv[6]);
+ w = atoi(argv[7]);
+ h = atoi(argv[8]);
+ tw = atoi(argv[9]);
+ th = atoi(argv[10]);
+ if(argc > 11) sw = atoi(argv[11]);
+ if(argc > 12) sh = atoi(argv[12]);
+ if(argc > 13) texdir = argv[13];
+ if(FT_Init_FreeType(&l))
+ fatal("cube2font: failed initing freetype");
+ if(FT_New_Face(l, argv[1], 0, &f) ||
+ FT_Set_Charmap(f, f->charmaps[0]) ||
+ FT_Set_Pixel_Sizes(f, w, h) ||
+ FT_Stroker_New(l, &s) ||
+ FT_Stroker_New(l, &s2))
+ fatal("cube2font: failed loading font %s", argv[1]);
+ if(outborder > 0) FT_Stroker_Set(s, (FT_Fixed)(outborder * 64), FT_STROKER_LINECAP_ROUND, FT_STROKER_LINEJOIN_ROUND, 0);
+ if(inborder > 0) FT_Stroker_Set(s2, (FT_Fixed)(inborder * 64), FT_STROKER_LINECAP_ROUND, FT_STROKER_LINEJOIN_ROUND, 0);
+ for(c = 0; c < 256; c++) if(iscubeprint(c))
+ {
+ FT_Glyph p, p2;
+ FT_BitmapGlyph b, b2;
+ struct fontchar *dst = &chars[numchars];
+ dst->code = c;
+ dst->uni = cube2uni(c);
+ if(FT_Load_Char(f, dst->uni, FT_LOAD_DEFAULT))
+ fatal("cube2font: failed loading character %s", encodeutf8(dst->uni));
+ FT_Get_Glyph(f->glyph, &p);
+ p2 = p;
+ if(outborder > 0) FT_Glyph_StrokeBorder(&p, s, 0, 0);
+ if(inborder > 0) FT_Glyph_StrokeBorder(&p2, s2, 1, 0);
+ FT_Glyph_To_Bitmap(&p, FT_RENDER_MODE_NORMAL, 0, 1);
+ FT_Glyph_To_Bitmap(&p2, FT_RENDER_MODE_NORMAL, 0, 1);
+ b = (FT_BitmapGlyph)p;
+ b2 = (FT_BitmapGlyph)p2;
+ dst->tex = -1;
+ dst->x = INT_MIN;
+ dst->y = INT_MIN;
+ dst->offx = imin(b->left, b2->left);
+ dst->offy = imax(b->top, b2->top);
+ dst->offset = offset;
+ dst->advance = offset + ((p->advance.x+0xFFFF)>>16) + advance;
+ dst->w = imax(b->left + b->bitmap.width, b2->left + b2->bitmap.width) - dst->offx;
+ dst->h = dst->offy - imin(b->top - b->bitmap.rows, b2->top - b2->bitmap.rows);
+ dst->alpha = b;
+ dst->color = b2;
+ order[numchars++] = dst;
+ }
+ qsort(order, numchars, sizeof(order[0]), sortchars);
+ for(i = 0; i < numchars;)
+ {
+ struct fontchar *dst;
+ int j, k, trial0, prevscore, dstscore, fitscore;
+ for(trial0 = trial, prevscore = -1; (trial -= 2) >= trial0-512;)
+ {
+ int g, fw = rw, fh = rh, fy = ry, curscore = 0, reused = 0;
+ for(j = i; j < numchars; j++)
+ {
+ dst = order[j];
+ if(dst->tex >= 0 || dst->tex <= trial) continue;
+ g = groupchar(dst->uni);
+ dstscore = scorechar(dst, pad, tw, th, fw, fh, fy);
+ for(k = j; k < numchars; k++)
+ {
+ struct fontchar *fit = order[k];
+ if(fit->tex >= 0 || fit->tex <= trial) continue;
+ if(fit->tex >= trial0 && groupchar(fit->uni) != g) break;
+ fitscore = scorechar(fit, pad, tw, th, fw, fh, fy);
+ if(fitscore < dstscore || (fitscore == dstscore && fit->h > dst->h))
+ {
+ dst = fit;
+ dstscore = fitscore;
+ }
+ }
+ if(fw + dst->w > tw)
+ {
+ fy += fh + pad;
+ fw = fh = 0;
+ }
+ if(fy + dst->h > th)
+ {
+ fy = fw = fh = 0;
+ if(curscore > 0) break;
+ }
+ if(dst->tex >= trial+1 && dst->tex <= trial+2) { dst->tex = trial; reused++; }
+ else dst->tex = trial;
+ fw += dst->w + pad;
+ fh = imax(fh, dst->h);
+ if(dst != order[j]) --j;
+ curscore++;
+ }
+ if(reused < prevscore || curscore <= prevscore) break;
+ prevscore = curscore;
+ }
+ for(; i < numchars; i++)
+ {
+ dst = order[i];
+ if(dst->tex >= 0) continue;
+ dstscore = scorechar(dst, pad, tw, th, rw, rh, ry);
+ for(j = i; j < numchars; j++)
+ {
+ struct fontchar *fit = order[j];
+ if(fit->tex < trial || fit->tex > trial+2) continue;
+ fitscore = scorechar(fit, pad, tw, th, rw, rh, ry);
+ if(fitscore < dstscore || (fitscore == dstscore && fit->h > dst->h))
+ {
+ dst = fit;
+ dstscore = fitscore;
+ }
+ }
+ if(dst->tex < trial || dst->tex > trial+2) break;
+ if(rw + dst->w > tw)
+ {
+ ry += rh + pad;
+ rw = rh = 0;
+ }
+ if(ry + dst->h > th)
+ {
+ ry = rw = rh = 0;
+ numtex++;
+ }
+ dst->tex = numtex;
+ dst->x = rw;
+ dst->y = ry;
+ rw += dst->w + pad;
+ rh = imax(rh, dst->h);
+ y1 = imin(y1, dst->offy - dst->h);
+ y2 = imax(y2, dst->offy);
+ x1 = imin(x1, dst->offx);
+ x2 = imax(x2, dst->offx + dst->w);
+ w2 = imax(w2, dst->w);
+ h2 = imax(h2, dst->h);
+ if(dst != order[i]) --i;
+ }
+ }
+ if(rh > 0) numtex++;
+#if 0
+ if(sw <= 0)
+ {
+ if(FT_Load_Char(f, ' ', FT_LOAD_DEFAULT))
+ fatal("cube2font: failed loading space character");
+ sw = (f->glyph->advance.x+0x3F)>>6;
+ }
+#endif
+ if(sh <= 0) sh = y2 - y1;
+ if(sw <= 0) sw = sh/3;
+ writetexs(argv[2], chars, numchars, numtex, tw, th);
+ writecfg(argv[2], chars, numchars, x1, y1, x2, y2, sw, sh, argc, argv);
+ for(i = 0; i < numchars; i++)
+ {
+ FT_Done_Glyph((FT_Glyph)chars[i].alpha);
+ FT_Done_Glyph((FT_Glyph)chars[i].color);
+ }
+ FT_Stroker_Done(s);
+ FT_Stroker_Done(s2);
+ FT_Done_FreeType(l);
+ printf("cube2font: (%d, %d) .. (%d, %d) = (%d, %d) / (%d, %d), %d texs\n", x1, y1, x2, y2, x2 - x1, y2 - y1, w2, h2, numtex);
+ return EXIT_SUCCESS;
+}
+
diff --git a/src/system-install.mk b/src/system-install.mk
index dec8fd6..cded863 100644
--- a/src/system-install.mk
+++ b/src/system-install.mk
@@ -14,15 +14,15 @@ docdir=$(DESTDIR)$(prefix)/share/doc
mandir=$(DESTDIR)$(prefix)/share/man
menudir=$(DESTDIR)$(prefix)/share/applications
icondir=$(DESTDIR)$(prefix)/share/icons/hicolor
-
-GZIPPER=gzip
+pixmapdir=$(DESTDIR)$(prefix)/share/pixmaps
ICONS= \
install/nix/$(appsrcname)_x16.png \
install/nix/$(appsrcname)_x32.png \
install/nix/$(appsrcname)_x48.png \
install/nix/$(appsrcname)_x64.png \
- install/nix/$(appsrcname)_x128.png
+ install/nix/$(appsrcname)_x128.png \
+ install/nix/$(appsrcname)_x32.xpm
install/nix/$(appsrcname)_x16.png: $(appsrcname).ico
convert '$(appsrcname).ico[0]' $@
@@ -39,6 +39,9 @@ install/nix/$(appsrcname)_x64.png: $(appsrcname).ico
install/nix/$(appsrcname)_x128.png: $(appsrcname).ico
convert '$(appsrcname).ico[3]' $@
+install/nix/$(appsrcname)_x32.xpm: $(appsrcname).ico
+ convert '$(appsrcname).ico[1]' $@
+
icons: $(ICONS)
system-install-client: client
@@ -71,7 +74,6 @@ system-install-server: server
system-install-data:
install -d $(datadir)/$(appname)
cp -r ../data $(datadir)/$(appname)/data
- @rm -rv $(datadir)/$(appname)/data/examples
system-install-docs: $(MANPAGES)
install -d $(mandir)/man6
@@ -81,17 +83,17 @@ system-install-docs: $(MANPAGES)
-e 's, at DOCDIR@,$(patsubst $(DESTDIR)%,%,$(docdir)),g' \
-e 's, at APPNAME@,$(appname),g' \
-e 's, at CAPPNAME@,$(cappname),g' \
- install/nix/$(appsrcname).6.am | \
- $(GZIPPER) -9 -n -c > $(mandir)/man6/$(appname).6.gz
+ ../doc/man/$(appsrcname).6.am | \
+ gzip -9 -n -c > $(mandir)/man6/$(appname).6.gz
sed -e 's, at LIBEXECDIR@,$(patsubst $(DESTDIR)%,%,$(libexecdir)),g' \
-e 's, at DATADIR@,$(patsubst $(DESTDIR)%,%,$(datadir)),g' \
-e 's, at DOCDIR@,$(patsubst $(DESTDIR)%,%,$(docdir)),g' \
-e 's, at APPNAME@,$(appname),g' \
-e 's, at CAPPNAME@,$(cappname),g' \
- install/nix/$(appsrcname)-server.6.am | \
- $(GZIPPER) -9 -n -c > $(mandir)/man6/$(appname)-server.6.gz
- cp -r ../data/examples $(docdir)/$(appname)/examples
- cp ../guidelines.txt $(docdir)/$(appname)/guidelines.txt
+ ../doc/man/$(appsrcname)-server.6.am | \
+ gzip -9 -n -c > $(mandir)/man6/$(appname)-server.6.gz
+ cp -r ../doc/examples $(docdir)/$(appname)/examples
+ cp ../doc/guidelines.txt $(docdir)/$(appname)/guidelines.txt
system-install-menus: icons
install -d $(menudir)
@@ -100,6 +102,7 @@ system-install-menus: icons
install -d $(icondir)/48x48/apps
install -d $(icondir)/64x64/apps
install -d $(icondir)/128x128/apps
+ install -d $(pixmapdir)
sed -e 's, at LIBEXECDIR@,$(patsubst $(DESTDIR)%,%,$(libexecdir)),g' \
-e 's, at DATADIR@,$(patsubst $(DESTDIR)%,%,$(datadir)),g' \
-e 's, at DOCDIR@,$(patsubst $(DESTDIR)%,%,$(docdir)),g' \
@@ -116,6 +119,8 @@ system-install-menus: icons
$(icondir)/64x64/apps/$(appname).png
install -m644 install/nix/$(appsrcname)_x128.png \
$(icondir)/128x128/apps/$(appname).png
+ install -m644 install/nix/$(appsrcname)_x32.xpm \
+ $(pixmapdir)/$(appname).xpm
system-install-cube2font: system-install-cube2font-docs
install -d $(bindir)
@@ -123,7 +128,7 @@ system-install-cube2font: system-install-cube2font-docs
system-install-cube2font-docs: install/nix/cube2font.1
install -d $(mandir)/man1
- $(GZIPPER) -9 -n -c < install/nix/cube2font.1 \
+ gzip -9 -n -c < ../doc/man/cube2font.1 \
> $(mandir)/man1/cube2font.1.gz
system-install: system-install-client system-install-server system-install-data system-install-docs system-install-menus
--
Packaging for cube2font
More information about the Pkg-games-commits
mailing list