use SharpFont instead of custom Tao.FreeType
This commit is contained in:
6
.gitignore
vendored
6
.gitignore
vendored
@@ -15,6 +15,7 @@ _ReSharper.*/
|
|||||||
|
|
||||||
#binary stuff
|
#binary stuff
|
||||||
/*.dll
|
/*.dll
|
||||||
|
/*.dll.config
|
||||||
*.pdb
|
*.pdb
|
||||||
*.mdb
|
*.mdb
|
||||||
*.exe
|
*.exe
|
||||||
@@ -24,9 +25,13 @@ _ReSharper.*/
|
|||||||
*.orig
|
*.orig
|
||||||
\#*
|
\#*
|
||||||
.*.sw?
|
.*.sw?
|
||||||
|
|
||||||
# dependency DLLs (different for every platform!)
|
# dependency DLLs (different for every platform!)
|
||||||
cg.dll
|
cg.dll
|
||||||
cgGL.dll
|
cgGL.dll
|
||||||
|
freetype6.dll
|
||||||
|
zlib1.dll
|
||||||
|
SDL.dll
|
||||||
|
|
||||||
/OpenRa.Gl.dll
|
/OpenRa.Gl.dll
|
||||||
|
|
||||||
@@ -49,7 +54,6 @@ OpenRA.Launcher.Mac/build/
|
|||||||
OpenRA.Launcher.Mac/OpenRA.xcodeproj/*.pbxuser
|
OpenRA.Launcher.Mac/OpenRA.xcodeproj/*.pbxuser
|
||||||
OpenRA.Launcher.Mac/OpenRA.xcodeproj/*.perspectivev3
|
OpenRA.Launcher.Mac/OpenRA.xcodeproj/*.perspectivev3
|
||||||
OpenRA.Launcher.Mac/OpenRA.xcodeproj/*.mode1v3
|
OpenRA.Launcher.Mac/OpenRA.xcodeproj/*.mode1v3
|
||||||
*.config
|
|
||||||
*.resources
|
*.resources
|
||||||
|
|
||||||
# KDE crap
|
# KDE crap
|
||||||
|
|||||||
6
Makefile
6
Makefile
@@ -14,7 +14,7 @@ clean:
|
|||||||
@-rm -f *.exe *.dll *.mdb mods/**/*.dll mods/**/*.mdb *.resources
|
@-rm -f *.exe *.dll *.mdb mods/**/*.dll mods/**/*.mdb *.resources
|
||||||
distclean: clean
|
distclean: clean
|
||||||
dependencies:
|
dependencies:
|
||||||
@ cp -r thirdparty/*.dll .
|
@ cp -r thirdparty/*.dl* .
|
||||||
@ cp -r thirdparty/Tao/* .
|
@ cp -r thirdparty/Tao/* .
|
||||||
default: dependencies core
|
default: dependencies core
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ game_TARGET = OpenRA.Game.exe
|
|||||||
game_KIND = winexe
|
game_KIND = winexe
|
||||||
game_DEPS = $(fileformats_TARGET)
|
game_DEPS = $(fileformats_TARGET)
|
||||||
game_LIBS = $(COMMON_LIBS) System.Windows.Forms.dll $(game_DEPS) \
|
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
|
game_FLAGS = -win32icon:OpenRA.Game/OpenRA.ico
|
||||||
PROGRAMS += game
|
PROGRAMS += game
|
||||||
game: $(game_TARGET)
|
game: $(game_TARGET)
|
||||||
@@ -256,6 +256,8 @@ install: all
|
|||||||
@cp thirdparty/Tao/* $(INSTALL_DIR)
|
@cp thirdparty/Tao/* $(INSTALL_DIR)
|
||||||
@$(INSTALL_PROGRAM) thirdparty/ICSharpCode.SharpZipLib.dll $(INSTALL_DIR)
|
@$(INSTALL_PROGRAM) thirdparty/ICSharpCode.SharpZipLib.dll $(INSTALL_DIR)
|
||||||
@$(INSTALL_PROGRAM) thirdparty/FuzzyLogicLibrary.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 "#!/bin/sh" > openra
|
||||||
@echo 'BINDIR=$$(dirname $$(readlink -f $$0))' >> openra
|
@echo 'BINDIR=$$(dirname $$(readlink -f $$0))' >> openra
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#region Copyright & License Information
|
#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
|
* 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
|
* available to you under the terms of the GNU General Public License
|
||||||
* as published by the Free Software Foundation. For more information,
|
* as published by the Free Software Foundation. For more information,
|
||||||
@@ -13,7 +13,7 @@ using System.Drawing;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using OpenRA.FileFormats;
|
using OpenRA.FileFormats;
|
||||||
using Tao.FreeType;
|
using SharpFont;
|
||||||
|
|
||||||
namespace OpenRA.Graphics
|
namespace OpenRA.Graphics
|
||||||
{
|
{
|
||||||
@@ -25,10 +25,9 @@ namespace OpenRA.Graphics
|
|||||||
{
|
{
|
||||||
this.size = size;
|
this.size = size;
|
||||||
|
|
||||||
if (0 != FT.FT_New_Face(library, name, 0, out face))
|
face = library.NewFace(name, 0);
|
||||||
throw new InvalidOperationException("FT_New_Face failed");
|
face.SetPixelSizes((uint)size, (uint)size);
|
||||||
|
|
||||||
FT.FT_Set_Pixel_Sizes(face, 0, (uint)size);
|
|
||||||
glyphs = new Cache<Pair<char, Color>, GlyphInfo>(CreateGlyph,
|
glyphs = new Cache<Pair<char, Color>, GlyphInfo>(CreateGlyph,
|
||||||
Pair<char,Color>.EqualityComparer);
|
Pair<char,Color>.EqualityComparer);
|
||||||
|
|
||||||
@@ -47,7 +46,7 @@ namespace OpenRA.Graphics
|
|||||||
throw new InvalidOperationException();
|
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
|
location.Y += size; // baseline vs top
|
||||||
|
|
||||||
@@ -89,31 +88,28 @@ namespace OpenRA.Graphics
|
|||||||
}
|
}
|
||||||
|
|
||||||
Cache<Pair<char,Color>, GlyphInfo> glyphs;
|
Cache<Pair<char,Color>, GlyphInfo> glyphs;
|
||||||
IntPtr face;
|
Face face;
|
||||||
|
|
||||||
GlyphInfo CreateGlyph(Pair<char,Color> c)
|
GlyphInfo CreateGlyph(Pair<char, Color> c)
|
||||||
{
|
{
|
||||||
var index = FT.FT_Get_Char_Index(face, (uint)c.First);
|
uint index = face.GetCharIndex(c.First);
|
||||||
if (0 != FT.FT_Load_Glyph(face, index, FT.FT_LOAD_RENDER))
|
face.LoadGlyph(index, LoadFlags.Default, LoadTarget.Normal);
|
||||||
throw new InvalidOperationException( "FT_Load_Glyph failed." );
|
face.Glyph.RenderGlyph(RenderMode.Normal);
|
||||||
|
|
||||||
var _face = (FT_FaceRec)Marshal.PtrToStructure(face, typeof(FT_FaceRec));
|
|
||||||
var _glyph = (FT_GlyphSlotRec)Marshal.PtrToStructure(_face.glyph, typeof(FT_GlyphSlotRec));
|
|
||||||
|
|
||||||
var s = builder.Allocate(
|
var s = builder.Allocate(
|
||||||
new Size(_glyph.metrics.width.ToInt32() >> 6,
|
new Size((int)face.Glyph.Metrics.Width >> 6,
|
||||||
_glyph.metrics.height.ToInt32() >> 6));
|
(int)face.Glyph.Metrics.Height >> 6));
|
||||||
|
|
||||||
var g = new GlyphInfo
|
var g = new GlyphInfo
|
||||||
{
|
{
|
||||||
Sprite = s,
|
Sprite = s,
|
||||||
Advance = _glyph.metrics.horiAdvance.ToInt32() / 64f,
|
Advance = (int)face.Glyph.Metrics.HorizontalAdvance / 64f,
|
||||||
Offset = { X = _glyph.bitmap_left, Y = -_glyph.bitmap_top }
|
Offset = { X = face.Glyph.BitmapLeft, Y = -face.Glyph.BitmapTop }
|
||||||
};
|
};
|
||||||
|
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
var p = (byte*)_glyph.bitmap.buffer;
|
var p = (byte*)face.Glyph.Bitmap.Buffer;
|
||||||
var dest = s.sheet.Data;
|
var dest = s.sheet.Data;
|
||||||
var destStride = s.sheet.Size.Width * 4;
|
var destStride = s.sheet.Size.Width * 4;
|
||||||
|
|
||||||
@@ -129,19 +125,18 @@ namespace OpenRA.Graphics
|
|||||||
dest[q + 3] = p[i];
|
dest[q + 3] = p[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
p += _glyph.bitmap.pitch;
|
p += face.Glyph.Bitmap.Pitch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return g;
|
return g;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SpriteFont()
|
static SpriteFont()
|
||||||
{
|
{
|
||||||
FT.FT_Init_FreeType(out library);
|
library = new Library();
|
||||||
}
|
}
|
||||||
|
|
||||||
static IntPtr library;
|
static Library library;
|
||||||
static SheetBuilder builder;
|
static SheetBuilder builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -66,9 +66,9 @@
|
|||||||
<Reference Include="System.Drawing" />
|
<Reference Include="System.Drawing" />
|
||||||
<Reference Include="System.Windows.Forms" />
|
<Reference Include="System.Windows.Forms" />
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
<Reference Include="Tao.FreeType, Version=2.3.5.0, Culture=neutral, PublicKeyToken=e499629dc69cd531">
|
<Reference Include="SharpFont">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\thirdparty\Tao\Tao.FreeType.dll</HintPath>
|
<HintPath>..\thirdparty\SharpFont.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Tao.OpenAl, Version=1.1.0.1, Culture=neutral, PublicKeyToken=a7579dda88828311">
|
<Reference Include="Tao.OpenAl, Version=1.1.0.1, Culture=neutral, PublicKeyToken=a7579dda88828311">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
|||||||
@@ -47,6 +47,9 @@ cp thirdparty/ICSharpCode.SharpZipLib.dll packaging/built
|
|||||||
# FuzzyLogicLibrary for improved AI
|
# FuzzyLogicLibrary for improved AI
|
||||||
cp thirdparty/FuzzyLogicLibrary.dll packaging/built
|
cp thirdparty/FuzzyLogicLibrary.dll packaging/built
|
||||||
|
|
||||||
|
# SharpFont for FreeType support
|
||||||
|
cp thirdparty/SharpFont* packaging/built
|
||||||
|
|
||||||
# Copy game icon for windows package
|
# Copy game icon for windows package
|
||||||
cp OpenRA.Game/OpenRA.ico packaging/built
|
cp OpenRA.Game/OpenRA.ico packaging/built
|
||||||
|
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ Section "Client" Client
|
|||||||
File "${SRCDIR}\*.ttf"
|
File "${SRCDIR}\*.ttf"
|
||||||
File "${SRCDIR}\OpenRA.ico"
|
File "${SRCDIR}\OpenRA.ico"
|
||||||
File "${SRCDIR}\Tao.*.dll"
|
File "${SRCDIR}\Tao.*.dll"
|
||||||
|
File "${SRCDIR}\SharpFont.*.dll"
|
||||||
|
|
||||||
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
|
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
|
||||||
CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
|
CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
|
||||||
@@ -263,6 +264,7 @@ Function ${UN}Clean
|
|||||||
Delete $INSTDIR\ICSharpCode.SharpZipLib.dll
|
Delete $INSTDIR\ICSharpCode.SharpZipLib.dll
|
||||||
Delete $INSTDIR\FuzzyLogicLibrary.dll
|
Delete $INSTDIR\FuzzyLogicLibrary.dll
|
||||||
Delete $INSTDIR\Tao.*.dll
|
Delete $INSTDIR\Tao.*.dll
|
||||||
|
Delete $INSTDIR\SharpFont.*.dll
|
||||||
Delete $INSTDIR\COPYING
|
Delete $INSTDIR\COPYING
|
||||||
Delete $INSTDIR\HACKING
|
Delete $INSTDIR\HACKING
|
||||||
Delete $INSTDIR\INSTALL
|
Delete $INSTDIR\INSTALL
|
||||||
|
|||||||
BIN
thirdparty/SharpFont.dll
vendored
Executable file
BIN
thirdparty/SharpFont.dll
vendored
Executable file
Binary file not shown.
6
thirdparty/SharpFont.dll.config
vendored
Normal file
6
thirdparty/SharpFont.dll.config
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<configuration>
|
||||||
|
<dllmap os="linux" dll="freetype.dll" target="libfreetype.so" />
|
||||||
|
<dllmap os="osx" dll="freetype.dll" target="libfreetype.6.dylib" />
|
||||||
|
<dllmap os="windows" dll="freetype.dll" target="freetype6.dll" />
|
||||||
|
</configuration>
|
||||||
BIN
thirdparty/Tao/Tao.FreeType.dll
vendored
BIN
thirdparty/Tao/Tao.FreeType.dll
vendored
Binary file not shown.
7
thirdparty/Tao/Tao.FreeType.dll.config
vendored
7
thirdparty/Tao/Tao.FreeType.dll.config
vendored
@@ -1,7 +0,0 @@
|
|||||||
<configuration>
|
|
||||||
<dllmap dll="freetype6.dll">
|
|
||||||
<dllentry os="linux" dll="libfreetype.so.6" />
|
|
||||||
<dllentry os="windows" dll="freetype6.dll" />
|
|
||||||
<dllentry os="osx" dll="/usr/X11/lib/libfreetype.6.dylib" />
|
|
||||||
</dllmap>
|
|
||||||
</configuration>
|
|
||||||
Reference in New Issue
Block a user