use SharpFont instead of custom Tao.FreeType
This commit is contained in:
8
.gitignore
vendored
8
.gitignore
vendored
@@ -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
|
||||
*.html
|
||||
|
||||
6
Makefile
6
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
|
||||
|
||||
@@ -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<Pair<char, Color>, GlyphInfo>(CreateGlyph,
|
||||
Pair<char,Color>.EqualityComparer);
|
||||
glyphs = new Cache<Pair<char, Color>, GlyphInfo>(CreateGlyph,
|
||||
Pair<char,Color>.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<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);
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -66,9 +66,9 @@
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Tao.FreeType, Version=2.3.5.0, Culture=neutral, PublicKeyToken=e499629dc69cd531">
|
||||
<Reference Include="SharpFont">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\thirdparty\Tao\Tao.FreeType.dll</HintPath>
|
||||
<HintPath>..\thirdparty\SharpFont.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Tao.OpenAl, Version=1.1.0.1, Culture=neutral, PublicKeyToken=a7579dda88828311">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
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