1
1
forked from 0ad/0ad

Slightly nicer font renderer and some other minor changes

This was SVN commit r764.
This commit is contained in:
Ykkrosh 2004-07-16 15:33:15 +00:00
parent 8684287360
commit 5960ab2599
9 changed files with 79 additions and 28 deletions

View File

@ -94,7 +94,7 @@
BufferSecurityCheck="FALSE"
EnableEnhancedInstructionSet="0"
ForceConformanceInForLoopScope="TRUE"
UsePrecompiledHeader="3"
UsePrecompiledHeader="0"
WarningLevel="4"
Detect64BitPortabilityProblems="FALSE"
DebugInformationFormat="3"/>
@ -177,7 +177,7 @@
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"/>
UsePrecompiledHeader="0"/>
</FileConfiguration>
</File>
<File
@ -212,7 +212,8 @@
ObjectFile="$(IntDir)/$(InputName)1.obj"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
Name="Release|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"
ObjectFile="$(IntDir)/$(InputName)1.obj"/>

View File

@ -1,13 +1,14 @@
// $Id: font.cpp,v 1.2 2004/06/19 12:56:09 philip Exp $
// $Id: font.cpp,v 1.3 2004/07/16 15:32:34 philip Exp $
#include "stdafx.h"
#include "wx/wx.h"
#include "font.h"
#include "freetype/ttunpat.h"
#include <math.h>
FontRenderer::FontRenderer(const char* filename0, const char* filename1, int ptsize)
FontRenderer::FontRenderer(const char* filename0, const char* filename1, int ptsize, bool unpatented_hinting)
{
int error;
@ -24,12 +25,36 @@ FontRenderer::FontRenderer(const char* filename0, const char* filename1, int pts
throw "Error initialising FreeType";
}
FT_Parameter openparam = { FT_PARAM_TAG_UNPATENTED_HINTING, NULL };
FT_Open_Args args0 = {
FT_OPEN_PATHNAME | (unpatented_hinting ? FT_OPEN_PARAMS : 0),
NULL, NULL,
(FT_String*)filename0,
NULL, NULL,
1, &openparam
};
FT_Open_Args args1 = {
FT_OPEN_PATHNAME | (unpatented_hinting ? FT_OPEN_PARAMS : 0),
NULL, NULL,
(FT_String*)filename1,
NULL, NULL,
1, &openparam
};
/*
error = FT_New_Face(
FontLibrary0,
filename0,
0, // index of face inside font file
&FontFace0
);
*/
error = FT_Open_Face(
FontLibrary0,
&args0,
0, // index of face inside font file
&FontFace0
);
if (error)
{
FT_Done_FreeType(FontLibrary0);
@ -37,12 +62,20 @@ FontRenderer::FontRenderer(const char* filename0, const char* filename1, int pts
throw "Error loading primary font";
}
/*
error = FT_New_Face(
FontLibrary1,
filename1,
0, // index of face inside font file
&FontFace1
);
*/
error = FT_Open_Face(
FontLibrary1,
&args1,
0, // index of face inside font file
&FontFace1
);
if (error)
{
FT_Done_Face(FontFace0);

View File

@ -1,4 +1,4 @@
// $Id: font.h,v 1.1 2004/06/17 19:32:04 philip Exp $
// $Id: font.h,v 1.2 2004/07/16 15:32:34 philip Exp $
#ifndef _FONT_H_
#define _FONT_H_
@ -32,7 +32,7 @@ public:
// Two fonts are required - a primary (0) font which will be used first,
// and a secondary (1) font for filling in missing glyphs.
// (The secondary font should usually be Arial Unicode MS).
FontRenderer(const char* filename0, const char* filename1, int ptsize);
FontRenderer(const char* filename0, const char* filename1, int ptsize, bool unpatented_hinting);
~FontRenderer();

View File

@ -36,7 +36,7 @@
RuntimeLibrary="2"
BufferSecurityCheck="0"
ForceConformanceInForLoopScope="1"
OpenMPDirectives="1"/>
OpenMPDirectives="0"/>
</Tool>
</Configuration>
</Configurations>
@ -163,6 +163,13 @@
<FileConfiguration
Name="Release|Win32"/>
</File>
<File
RelativePath=".\version.h">
<FileConfiguration
Name="Debug|Win32"/>
<FileConfiguration
Name="Release|Win32"/>
</File>
<File
RelativePath=".\wxconfig.h">
<FileConfiguration
@ -191,13 +198,6 @@
<FileConfiguration
Name="Release|Win32"/>
</File>
<File
RelativePath=".\version.h">
<FileConfiguration
Name="Debug|Win32"/>
<FileConfiguration
Name="Release|Win32"/>
</File>
<File
RelativePath=".\FontBuilder.ico">
<FileConfiguration

View File

@ -1,4 +1,4 @@
// $Id: fontselect.cpp,v 1.3 2004/06/19 12:56:09 philip Exp $
// $Id: fontselect.cpp,v 1.4 2004/07/16 15:32:34 philip Exp $
/************
@ -8,7 +8,7 @@
************/
#include "stdafx.h"
#include "../../stdafx.h"
#include "../fontselect.h"

View File

@ -1,6 +1,8 @@
// $Id: fontselect.cpp,v 1.2 2004/06/19 12:56:09 philip Exp $
// $Id: fontselect.cpp,v 1.3 2004/07/16 15:32:34 philip Exp $
#include "stdafx.h"
// Switch as appropriate, because MSVC's PCH support doesn't like me
#include "../../stdafx.h"
//#include "stdafx.h"
#include "../fontselect.h"

View File

@ -1,9 +1,11 @@
// $Id: stdafx.h,v 1.5 2004/06/19 13:46:11 philip Exp $
// $Id: stdafx.h,v 1.6 2004/07/16 15:32:34 philip Exp $
// Precompiled headers
#ifdef _WIN32
# define HAVE_PCH
# ifndef NDEBUG
# define HAVE_PCH
# endif
#endif
#ifdef HAVE_PCH
@ -57,11 +59,11 @@
// Don't care about copy constructors / assignment operators
#pragma warning (disable: 4511 4512)
#endif // HAVE_PCH
#ifdef __INTEL_COMPILER
// Disable some of the excessively pedantic warnings again
#pragma warning (disable: 193 373 444 981 383 1418)
#endif
#endif // HAVE_PCH
#include "wx/defs.h"

View File

@ -1 +1 @@
const wxString version = L"v0.9";
const wxString version = L"v1.0";

View File

@ -1,4 +1,4 @@
// $Id: wxframe.cpp,v 1.5 2004/06/19 13:46:11 philip Exp $
// $Id: wxframe.cpp,v 1.6 2004/07/16 15:32:34 philip Exp $
#include "stdafx.h"
@ -16,6 +16,7 @@
#include "wx/filename.h"
#include "wx/progdlg.h"
#include "wx/dcbuffer.h"
#include "wx/checkbox.h"
#include "wxframe.h"
#include "wxconfig.h"
@ -54,7 +55,8 @@ enum
ID_Style_Boldness,
ID_Style_Italicness,
ID_Style_Tracking,
ID_Style_Leading
ID_Style_Leading,
ID_Style_Hinting
};
BEGIN_EVENT_TABLE(MainFrame, wxFrame)
@ -160,6 +162,9 @@ MainFrame::MainFrame(const wxString& title, const wxPoint& pos, const wxSize& si
StyleSizer->Add(new wxStaticText(Panel, -1, wxT("Leading:")), 0, wxALIGN_RIGHT | wxLEFT | wxRIGHT, 2);
StyleSizer->Add(new StyleSpinCtrl(Panel, ID_Style_Leading, -256, 256, 0), 0, wxGROW | wxLEFT | wxRIGHT, 2);
StyleSizer->Add(new wxStaticText(Panel, -1, wxT("Alt. hinting:")), 0, wxALIGN_RIGHT | wxLEFT | wxRIGHT, 2);
StyleSizer->Add(new wxCheckBox(Panel, ID_Style_Hinting, wxT("")), 0, wxGROW | wxLEFT | wxRIGHT, 2);
ControlSizer->Add(StyleSizer, 0, wxLEFT | wxRIGHT | wxALIGN_CENTER, 8);
wxBoxSizer* GenerateSizer = new wxBoxSizer(wxVERTICAL);
@ -239,6 +244,7 @@ void MainFrame::LoadSettings(wxString& filename)
StyleSpinCtrl* SizeCtrl = (StyleSpinCtrl*)wxWindow::FindWindowById(ID_Style_Size);
StyleSpinCtrl* TrackingCtrl = (StyleSpinCtrl*)wxWindow::FindWindowById(ID_Style_Tracking);
StyleSpinCtrl* LeadingCtrl = (StyleSpinCtrl*)wxWindow::FindWindowById(ID_Style_Leading);
wxCheckBox* HintingCtrl = (wxCheckBox*)wxWindow::FindWindowById(ID_Style_Hinting);
wxButton* FontSelect0 = (wxButton*)wxWindow::FindWindowById(ID_FontSelect0);
wxButton* FontSelect1 = (wxButton*)wxWindow::FindWindowById(ID_FontSelect1);
wxButton* CharSelect = (wxButton*)wxWindow::FindWindowById(ID_CharSelect);
@ -263,6 +269,7 @@ void MainFrame::LoadSettings(wxString& filename)
Settings->GetAttributeValue(wxT("Size"), t); SizeCtrl->SetValue(t);
Settings->GetAttributeValue(wxT("Tracking"), t); TrackingCtrl->SetValue(t);
Settings->GetAttributeValue(wxT("Leading"), t); LeadingCtrl->SetValue(t);
Settings->GetAttributeValue(wxT("Hinting"), t); HintingCtrl->SetValue(t);
// Convert back to UTF16 from hex, because wxExpr doesn't like non-ASCII
@ -294,6 +301,7 @@ void MainFrame::SaveSettings(wxString& filename)
StyleSpinCtrl* SizeCtrl = (StyleSpinCtrl*)wxWindow::FindWindowById(ID_Style_Size);
StyleSpinCtrl* TrackingCtrl = (StyleSpinCtrl*)wxWindow::FindWindowById(ID_Style_Tracking);
StyleSpinCtrl* LeadingCtrl = (StyleSpinCtrl*)wxWindow::FindWindowById(ID_Style_Leading);
wxCheckBox* HintingCtrl = (wxCheckBox*)wxWindow::FindWindowById(ID_Style_Hinting);
wxExpr *Settings = new wxExpr(wxT("Settings"));
Settings->AddAttributeValueString(wxT("FontName0"), FontName0);
@ -307,6 +315,7 @@ void MainFrame::SaveSettings(wxString& filename)
Settings->AddAttributeValue(wxT("Size"), (long)SizeCtrl->GetValidValue());
Settings->AddAttributeValue(wxT("Tracking"), (long)TrackingCtrl->GetValidValue());
Settings->AddAttributeValue(wxT("Leading"), (long)LeadingCtrl->GetValidValue());
Settings->AddAttributeValue(wxT("Hinting"), (long)HintingCtrl->GetValue());
// Convert UTF16 to hex, because wxExpr doesn't like non-ASCII
wxString PreviewText = PreviewTextCtrl->GetValue();
@ -397,6 +406,7 @@ void MainFrame::GeneratePreview()
StyleSpinCtrl* SizeCtrl = (StyleSpinCtrl*)wxWindow::FindWindowById(ID_Style_Size);
StyleSpinCtrl* TrackingCtrl = (StyleSpinCtrl*)wxWindow::FindWindowById(ID_Style_Tracking);
StyleSpinCtrl* LeadingCtrl = (StyleSpinCtrl*)wxWindow::FindWindowById(ID_Style_Leading);
wxCheckBox* HintingCtrl = (wxCheckBox*)wxWindow::FindWindowById(ID_Style_Hinting);
try
{
@ -404,7 +414,8 @@ void MainFrame::GeneratePreview()
FontRenderer Font(
FontFilename0.ToAscii(),
FontFilename1.ToAscii(),
SizeCtrl->GetValidValue() );
SizeCtrl->GetValidValue(),
HintingCtrl->GetValue() );
Font.Boldness = BoldnessCtrl->GetValidValue();
Font.Italicness = 5 * ItalicnessCtrl->GetValidValue();
@ -473,6 +484,7 @@ void MainFrame::GenerateTexture(wxString TextureFilename, wxString FontDefnFilen
StyleSpinCtrl* SizeCtrl = (StyleSpinCtrl*)wxWindow::FindWindowById(ID_Style_Size);
StyleSpinCtrl* TrackingCtrl = (StyleSpinCtrl*)wxWindow::FindWindowById(ID_Style_Tracking);
StyleSpinCtrl* LeadingCtrl = (StyleSpinCtrl*)wxWindow::FindWindowById(ID_Style_Leading);
wxCheckBox* HintingCtrl = (wxCheckBox*)wxWindow::FindWindowById(ID_Style_Hinting);
// Work out what characters need to be included in the texture
@ -503,7 +515,8 @@ void MainFrame::GenerateTexture(wxString TextureFilename, wxString FontDefnFilen
FontRenderer Font(
FontFilename0.ToAscii(),
FontFilename1.ToAscii(),
SizeCtrl->GetValidValue() );
SizeCtrl->GetValidValue(),
HintingCtrl->GetValue() );
Font.Boldness = BoldnessCtrl->GetValidValue();
Font.Italicness = 5 * ItalicnessCtrl->GetValidValue();