diff --git a/.gitignore b/.gitignore index ed74130130..2f52ce6544 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,7 @@ _ReSharper.*/ #binary stuff /*.dll +/*.dll.config *.pdb *.mdb *.exe @@ -24,9 +25,13 @@ _ReSharper.*/ *.orig \#* .*.sw? + # dependency DLLs (different for every platform!) cg.dll cgGL.dll +freetype6.dll +zlib1.dll +SDL.dll /OpenRa.Gl.dll @@ -49,7 +54,6 @@ OpenRA.Launcher.Mac/build/ OpenRA.Launcher.Mac/OpenRA.xcodeproj/*.pbxuser OpenRA.Launcher.Mac/OpenRA.xcodeproj/*.perspectivev3 OpenRA.Launcher.Mac/OpenRA.xcodeproj/*.mode1v3 -*.config *.resources # KDE crap @@ -58,4 +62,4 @@ OpenRA.Launcher.Mac/OpenRA.xcodeproj/*.mode1v3 # auto-generated documentation DOCUMENTATION.md -*.html \ No newline at end of file +*.html diff --git a/Makefile b/Makefile index 479aa7627f..bedb634378 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ clean: @-rm -f *.exe *.dll *.mdb mods/**/*.dll mods/**/*.mdb *.resources distclean: clean dependencies: - @ cp -r thirdparty/*.dll . + @ cp -r thirdparty/*.dl* . @ cp -r thirdparty/Tao/* . default: dependencies core @@ -35,7 +35,7 @@ game_TARGET = OpenRA.Game.exe game_KIND = winexe game_DEPS = $(fileformats_TARGET) game_LIBS = $(COMMON_LIBS) System.Windows.Forms.dll $(game_DEPS) \ - thirdparty/Tao/Tao.OpenAl.dll thirdparty/Tao/Tao.FreeType.dll + thirdparty/Tao/Tao.OpenAl.dll thirdparty/SharpFont.dll game_FLAGS = -win32icon:OpenRA.Game/OpenRA.ico PROGRAMS += game game: $(game_TARGET) @@ -256,6 +256,8 @@ install: all @cp thirdparty/Tao/* $(INSTALL_DIR) @$(INSTALL_PROGRAM) thirdparty/ICSharpCode.SharpZipLib.dll $(INSTALL_DIR) @$(INSTALL_PROGRAM) thirdparty/FuzzyLogicLibrary.dll $(INSTALL_DIR) + @$(INSTALL_PROGRAM) thirdparty/SharpFont.dll $(INSTALL_DIR) + @cp thirdparty/SharpFont.config.dll $(INSTALL_DIR) @echo "#!/bin/sh" > openra @echo 'BINDIR=$$(dirname $$(readlink -f $$0))' >> openra diff --git a/OpenRA.Game/Graphics/SpriteFont.cs b/OpenRA.Game/Graphics/SpriteFont.cs index 60b8655963..974792d5dc 100644 --- a/OpenRA.Game/Graphics/SpriteFont.cs +++ b/OpenRA.Game/Graphics/SpriteFont.cs @@ -1,6 +1,6 @@ #region Copyright & License Information /* - * Copyright 2007-2011 The OpenRA Developers (see AUTHORS) + * Copyright 2007-2012 The OpenRA Developers (see AUTHORS) * This file is part of OpenRA, which is free software. It is made * available to you under the terms of the GNU General Public License * as published by the Free Software Foundation. For more information, @@ -13,7 +13,7 @@ using System.Drawing; using System.Linq; using System.Runtime.InteropServices; using OpenRA.FileFormats; -using Tao.FreeType; +using SharpFont; namespace OpenRA.Graphics { @@ -25,12 +25,11 @@ namespace OpenRA.Graphics { this.size = size; - if (0 != FT.FT_New_Face(library, name, 0, out face)) - throw new InvalidOperationException("FT_New_Face failed"); + face = library.NewFace(name, 0); + face.SetPixelSizes((uint)size, (uint)size); - FT.FT_Set_Pixel_Sizes(face, 0, (uint)size); - glyphs = new Cache, GlyphInfo>(CreateGlyph, - Pair.EqualityComparer); + glyphs = new Cache, GlyphInfo>(CreateGlyph, + Pair.EqualityComparer); // setup a 1-channel SheetBuilder for our private use if (builder == null) builder = new SheetBuilder(TextureChannel.Alpha); @@ -47,7 +46,7 @@ namespace OpenRA.Graphics throw new InvalidOperationException(); } - public void DrawText( string text, float2 location, Color c ) + public void DrawText (string text, float2 location, Color c) { location.Y += size; // baseline vs top @@ -89,31 +88,28 @@ namespace OpenRA.Graphics } Cache, GlyphInfo> glyphs; - IntPtr face; + Face face; - GlyphInfo CreateGlyph(Pair c) + GlyphInfo CreateGlyph(Pair c) { - var index = FT.FT_Get_Char_Index(face, (uint)c.First); - if (0 != FT.FT_Load_Glyph(face, index, FT.FT_LOAD_RENDER)) - throw new InvalidOperationException( "FT_Load_Glyph failed." ); - - var _face = (FT_FaceRec)Marshal.PtrToStructure(face, typeof(FT_FaceRec)); - var _glyph = (FT_GlyphSlotRec)Marshal.PtrToStructure(_face.glyph, typeof(FT_GlyphSlotRec)); + uint index = face.GetCharIndex(c.First); + face.LoadGlyph(index, LoadFlags.Default, LoadTarget.Normal); + face.Glyph.RenderGlyph(RenderMode.Normal); var s = builder.Allocate( - new Size(_glyph.metrics.width.ToInt32() >> 6, - _glyph.metrics.height.ToInt32() >> 6)); + new Size((int)face.Glyph.Metrics.Width >> 6, + (int)face.Glyph.Metrics.Height >> 6)); var g = new GlyphInfo { Sprite = s, - Advance = _glyph.metrics.horiAdvance.ToInt32() / 64f, - Offset = { X = _glyph.bitmap_left, Y = -_glyph.bitmap_top } + Advance = (int)face.Glyph.Metrics.HorizontalAdvance / 64f, + Offset = { X = face.Glyph.BitmapLeft, Y = -face.Glyph.BitmapTop } }; unsafe { - var p = (byte*)_glyph.bitmap.buffer; + var p = (byte*)face.Glyph.Bitmap.Buffer; var dest = s.sheet.Data; var destStride = s.sheet.Size.Width * 4; @@ -129,19 +125,18 @@ namespace OpenRA.Graphics dest[q + 3] = p[i]; } - p += _glyph.bitmap.pitch; + p += face.Glyph.Bitmap.Pitch; } } - return g; } static SpriteFont() { - FT.FT_Init_FreeType(out library); + library = new Library(); } - static IntPtr library; + static Library library; static SheetBuilder builder; } diff --git a/OpenRA.Game/OpenRA.Game.csproj b/OpenRA.Game/OpenRA.Game.csproj index ac7aae5bb2..6f7b5cbd0c 100644 --- a/OpenRA.Game/OpenRA.Game.csproj +++ b/OpenRA.Game/OpenRA.Game.csproj @@ -66,9 +66,9 @@ - + False - ..\thirdparty\Tao\Tao.FreeType.dll + ..\thirdparty\SharpFont.dll False diff --git a/packaging/package-all.sh b/packaging/package-all.sh index 59f3218e24..b3c48d64ad 100755 --- a/packaging/package-all.sh +++ b/packaging/package-all.sh @@ -47,6 +47,9 @@ cp thirdparty/ICSharpCode.SharpZipLib.dll packaging/built # FuzzyLogicLibrary for improved AI cp thirdparty/FuzzyLogicLibrary.dll packaging/built +# SharpFont for FreeType support +cp thirdparty/SharpFont* packaging/built + # Copy game icon for windows package cp OpenRA.Game/OpenRA.ico packaging/built diff --git a/packaging/windows/OpenRA.nsi b/packaging/windows/OpenRA.nsi index 5292b7c5cb..bc1d82df90 100644 --- a/packaging/windows/OpenRA.nsi +++ b/packaging/windows/OpenRA.nsi @@ -90,6 +90,7 @@ Section "Client" Client File "${SRCDIR}\*.ttf" File "${SRCDIR}\OpenRA.ico" File "${SRCDIR}\Tao.*.dll" + File "${SRCDIR}\SharpFont.*.dll" !insertmacro MUI_STARTMENU_WRITE_BEGIN Application CreateDirectory "$SMPROGRAMS\$StartMenuFolder" @@ -263,6 +264,7 @@ Function ${UN}Clean Delete $INSTDIR\ICSharpCode.SharpZipLib.dll Delete $INSTDIR\FuzzyLogicLibrary.dll Delete $INSTDIR\Tao.*.dll + Delete $INSTDIR\SharpFont.*.dll Delete $INSTDIR\COPYING Delete $INSTDIR\HACKING Delete $INSTDIR\INSTALL diff --git a/thirdparty/SharpFont.dll b/thirdparty/SharpFont.dll new file mode 100755 index 0000000000..11f00fba41 Binary files /dev/null and b/thirdparty/SharpFont.dll differ diff --git a/thirdparty/SharpFont.dll.config b/thirdparty/SharpFont.dll.config new file mode 100644 index 0000000000..543bb2415f --- /dev/null +++ b/thirdparty/SharpFont.dll.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/thirdparty/Tao/Tao.FreeType.dll b/thirdparty/Tao/Tao.FreeType.dll deleted file mode 100644 index a07e35673b..0000000000 Binary files a/thirdparty/Tao/Tao.FreeType.dll and /dev/null differ diff --git a/thirdparty/Tao/Tao.FreeType.dll.config b/thirdparty/Tao/Tao.FreeType.dll.config deleted file mode 100644 index 6817cd6ed8..0000000000 --- a/thirdparty/Tao/Tao.FreeType.dll.config +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - -