diff --git a/aegisub/font_file_lister.cpp b/aegisub/font_file_lister.cpp index 8b3652200..646c50812 100644 --- a/aegisub/font_file_lister.cpp +++ b/aegisub/font_file_lister.cpp @@ -40,14 +40,16 @@ //////////// // Includes #include -#include #ifdef WIN32 -#include -#endif -#include "font_file_lister.h" +#include #include FT_FREETYPE_H #include FT_GLYPH_H #include FT_SFNT_NAMES_H +#include +#endif +#include "font_file_lister.h" +#include "text_file_writer.h" +#include "text_file_reader.h" //////////////////// @@ -58,8 +60,10 @@ FontFileLister *FontFileLister::instance = NULL; /////////////// // Constructor FontFileLister::FontFileLister() { +#ifdef WIN32 // Initialize freetype2 FT_Init_FreeType(&ft2lib); +#endif } @@ -105,17 +109,16 @@ void FontFileLister::DoClearData() { /////////////////////////// // Gather data from system void FontFileLister::DoGatherData() { +#ifdef WIN32 + // Get fonts folder wxString source; - #ifdef WIN32 TCHAR szPath[MAX_PATH]; if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_FONTS,NULL,0,szPath))) { source = wxString(szPath); } else source = wxGetOSDirectory() + _T("\\fonts"); source += _T("\\"); - #endif - if (source == _T("")) return; // Get the list of fonts in the fonts folder wxArrayString fontfiles; @@ -139,6 +142,13 @@ void FontFileLister::DoGatherData() { FT_Done_Face(face); } } + +#else + + // TODO: implement fconfig + return; + +#endif } diff --git a/aegisub/font_file_lister.h b/aegisub/font_file_lister.h index d0e4186bb..600bfa628 100644 --- a/aegisub/font_file_lister.h +++ b/aegisub/font_file_lister.h @@ -45,7 +45,9 @@ //////////// // Typedefs +#ifdef WIN32 typedef struct FT_LibraryRec_ *FT_Library; +#endif typedef std::map FontMap; @@ -53,9 +55,11 @@ typedef std::map FontMap; // Font file lister class FontFileLister { private: - static FontFileLister *instance; +#ifdef WIN32 FT_Library ft2lib; +#endif + static FontFileLister *instance; FontMap fontTable; wxArrayString fontFiles; diff --git a/aegisub/standard_paths.cpp b/aegisub/standard_paths.cpp new file mode 100644 index 000000000..ee08f15b4 --- /dev/null +++ b/aegisub/standard_paths.cpp @@ -0,0 +1,92 @@ +// Copyright (c) 2007, Rodrigo Braz Monteiro +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// * Neither the name of the Aegisub Group nor the names of its contributors +// may be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// +// ----------------------------------------------------------------------------- +// +// AEGISUB +// +// Website: http://aegisub.cellosoft.com +// Contact: mailto:zeratul@cellosoft.com +// + + +/////////// +// Headers +#include +#include "standard_paths.h" + + +//////////////// +// Get instance +StandardPaths *StandardPaths::GetInstance() { + if (!instance) instance = new StandardPaths(); + return instance; +} + + +/////////////// +// Constructor +StandardPaths::StandardPaths() { + wxFileName aegiPath(wxStandardPaths::Get().GetExecutablePath()); + SetPathValue(_T("?install"),aegiPath.GetPath()); + SetPathValue(_T("?user"),wxStandardPaths::Get().GetUserDataDir()); + SetPathValue(_T("?temp"),wxStandardPaths::Get().GetTempDir()); +} + + +/////////////// +// Decode path +wxString StandardPaths::DoDecodePath(wxString path) { + // Decode + if (path[0] == _T('?')) { + // TODO + return path; + } + + // Nothing to decode + else return path; +} + + +/////////////// +// Encode path +wxString StandardPaths::DoEncodePath(wxString path) { + // TODO + return path; +} + + +///////////////////////// +// Set value of a ? path +void StandardPaths::DoSetPathValue(wxString path,wxString value) { + paths[path] = value; +} + + +/////////////////// +// Static instance +StandardPaths *StandardPaths::instance = NULL; diff --git a/aegisub/standard_paths.h b/aegisub/standard_paths.h new file mode 100644 index 000000000..3429d2dfe --- /dev/null +++ b/aegisub/standard_paths.h @@ -0,0 +1,65 @@ +// Copyright (c) 2007, Rodrigo Braz Monteiro +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// * Neither the name of the Aegisub Group nor the names of its contributors +// may be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// +// ----------------------------------------------------------------------------- +// +// AEGISUB +// +// Website: http://aegisub.cellosoft.com +// Contact: mailto:zeratul@cellosoft.com +// + + +#pragma once + + +/////////// +// Headers +#include +#include + + +////////////////////////////////// +// Standard path conversion class +class StandardPaths { +private: + static StandardPaths *instance; + static StandardPaths *GetInstance(); + + std::map paths; + + StandardPaths(); + + wxString DoDecodePath(wxString path); + wxString DoEncodePath(wxString path); + void DoSetPathValue(wxString path,wxString value); + +public: + static wxString DecodePath(wxString path) { return GetInstance()->DoDecodePath(path); } + static wxString EncodePath(wxString path) { return GetInstance()->DoEncodePath(path); } + static void SetPathValue(wxString path,wxString value) { GetInstance()->DoSetPathValue(path,value); } +};