Move fontconfig to kicommon for now to de-duplicate the font cache
This commit is contained in:
parent
c006482feb
commit
050f812f5e
|
@ -32,7 +32,6 @@ CMakeCache.txt
|
|||
.cache/
|
||||
auto_renamed_to_cpp
|
||||
Testing
|
||||
version.h
|
||||
config.h
|
||||
install_manifest.txt
|
||||
doxygen/out
|
||||
|
|
|
@ -68,6 +68,8 @@ add_library( singletop STATIC EXCLUDE_FROM_ALL
|
|||
set( KICOMMON_SRCS
|
||||
# Fonts
|
||||
newstroke_font.cpp
|
||||
font/fontconfig.cpp
|
||||
font/version_info.cpp
|
||||
# Gal
|
||||
gal/color4d.cpp
|
||||
# Jobs
|
||||
|
@ -124,6 +126,11 @@ target_link_libraries( kicommon
|
|||
|
||||
# needed by kiid to allow linking for Boost for the UUID against bcrypt (msys2 only)
|
||||
${EXTRA_LIBS}
|
||||
|
||||
# outline font support
|
||||
${FREETYPE_LIBRARIES}
|
||||
${HarfBuzz_LIBRARIES}
|
||||
${Fontconfig_LIBRARIES}
|
||||
)
|
||||
|
||||
include( ${KICAD_CMAKE_MODULE_PATH}/KiCadVersion.cmake )
|
||||
|
@ -373,7 +380,6 @@ set( FONT_SRCS
|
|||
font/stroke_font.cpp
|
||||
font/outline_font.cpp
|
||||
font/outline_decomposer.cpp
|
||||
font/fontconfig.cpp
|
||||
font/text_attributes.cpp
|
||||
)
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include <config.h>
|
||||
#include <boost/version.hpp>
|
||||
#include <kiplatform/app.h>
|
||||
#include <font/outline_font.h>
|
||||
#include <font/version_info.h>
|
||||
|
||||
#include <tuple>
|
||||
|
||||
|
@ -147,9 +147,9 @@ wxString GetVersionInfoData( const wxString& aTitle, bool aHtml, bool aBrief )
|
|||
|
||||
aMsg << indent4 << wxGetLibraryVersionInfo().GetVersionString() << eol;
|
||||
|
||||
aMsg << indent4 << "FreeType " << KIFONT::OUTLINE_FONT::FreeTypeVersion() << eol;
|
||||
aMsg << indent4 << "HarfBuzz " << KIFONT::OUTLINE_FONT::HarfBuzzVersion() << eol;
|
||||
aMsg << indent4 << "FontConfig " << KIFONT::OUTLINE_FONT::FontConfigVersion() << eol;
|
||||
aMsg << indent4 << "FreeType " << KIFONT::VERSION_INFO::FreeType() << eol;
|
||||
aMsg << indent4 << "HarfBuzz " << KIFONT::VERSION_INFO::HarfBuzz() << eol;
|
||||
aMsg << indent4 << "FontConfig " << KIFONT::VERSION_INFO::FontConfig() << eol;
|
||||
|
||||
if( !aBrief )
|
||||
aMsg << indent4 << GetKicadCurlVersion() << eol;
|
||||
|
@ -178,7 +178,7 @@ wxString GetVersionInfoData( const wxString& aTitle, bool aHtml, bool aBrief )
|
|||
if( wxTheApp && wxTheApp->IsGUI() )
|
||||
{
|
||||
aMsg << ", ";
|
||||
|
||||
|
||||
switch( wxGetDisplayInfo().type )
|
||||
{
|
||||
case wxDisplayX11: aMsg << "X11"; break;
|
||||
|
|
|
@ -55,40 +55,6 @@ OUTLINE_FONT::OUTLINE_FONT() :
|
|||
}
|
||||
|
||||
|
||||
wxString OUTLINE_FONT::FreeTypeVersion()
|
||||
{
|
||||
std::lock_guard<std::mutex> guard( m_freeTypeMutex );
|
||||
|
||||
if( !m_freeType )
|
||||
FT_Init_FreeType( &m_freeType );
|
||||
|
||||
FT_Int major = 0;
|
||||
FT_Int minor = 0;
|
||||
FT_Int patch = 0;
|
||||
FT_Library_Version( m_freeType, &major, &minor, &patch );
|
||||
|
||||
return wxString::Format( "%d.%d.%d", major, minor, patch );
|
||||
}
|
||||
|
||||
|
||||
wxString OUTLINE_FONT::HarfBuzzVersion()
|
||||
{
|
||||
return wxString::FromUTF8( HB_VERSION_STRING );
|
||||
}
|
||||
|
||||
|
||||
wxString OUTLINE_FONT::FontConfigVersion()
|
||||
{
|
||||
return fontconfig::FONTCONFIG::Version();
|
||||
}
|
||||
|
||||
|
||||
wxString OUTLINE_FONT::FontLibraryVersion()
|
||||
{
|
||||
return wxString::Format( "FreeType %s HarfBuzz %s", FreeTypeVersion(), HarfBuzzVersion() );
|
||||
}
|
||||
|
||||
|
||||
OUTLINE_FONT* OUTLINE_FONT::LoadFont( const wxString& aFontName, bool aBold, bool aItalic )
|
||||
{
|
||||
std::unique_ptr<OUTLINE_FONT> font = std::make_unique<OUTLINE_FONT>();
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* This program source code file is part of KICAD, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2021 Ola Rinta-Koski <gitlab@rinta-koski.net>
|
||||
* Copyright (C) 2021-2023 Kicad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you may find one here:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <font/version_info.h>
|
||||
#include <font/fontconfig.h>
|
||||
#include <harfbuzz/hb.h>
|
||||
#ifdef _MSC_VER
|
||||
#include <ft2build.h>
|
||||
#else
|
||||
#include <freetype2/ft2build.h>
|
||||
#endif
|
||||
#include FT_FREETYPE_H
|
||||
|
||||
using namespace KIFONT;
|
||||
|
||||
wxString VERSION_INFO::FreeType()
|
||||
{
|
||||
FT_Library library;
|
||||
|
||||
FT_Int major = 0;
|
||||
FT_Int minor = 0;
|
||||
FT_Int patch = 0;
|
||||
FT_Init_FreeType( &library );
|
||||
FT_Library_Version( library, &major, &minor, &patch );
|
||||
FT_Done_FreeType( library );
|
||||
|
||||
return wxString::Format( "%d.%d.%d", major, minor, patch );
|
||||
}
|
||||
|
||||
|
||||
wxString VERSION_INFO::HarfBuzz()
|
||||
{
|
||||
return wxString::FromUTF8( HB_VERSION_STRING );
|
||||
}
|
||||
|
||||
|
||||
wxString VERSION_INFO::FontConfig()
|
||||
{
|
||||
return fontconfig::FONTCONFIG::Version();
|
||||
}
|
||||
|
||||
|
||||
wxString VERSION_INFO::FontLibrary()
|
||||
{
|
||||
return wxString::Format( "FreeType %s HarfBuzz %s", FreeType(), HarfBuzz() );
|
||||
}
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
#include <fontconfig/fontconfig.h>
|
||||
|
||||
#include <kicommon.h>
|
||||
#include <wx/string.h>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
@ -34,7 +35,7 @@ namespace fontconfig
|
|||
|
||||
struct FONTCONFIG_PAT;
|
||||
|
||||
class FONTCONFIG
|
||||
class KICOMMON_API FONTCONFIG
|
||||
{
|
||||
public:
|
||||
FONTCONFIG();
|
||||
|
@ -114,7 +115,7 @@ private:
|
|||
} // namespace fontconfig
|
||||
|
||||
|
||||
fontconfig::FONTCONFIG* Fontconfig();
|
||||
KICOMMON_API fontconfig::FONTCONFIG* Fontconfig();
|
||||
|
||||
|
||||
#endif //KICAD_FONTCONFIG_H
|
||||
|
|
|
@ -52,14 +52,6 @@ class OUTLINE_FONT : public FONT
|
|||
public:
|
||||
OUTLINE_FONT();
|
||||
|
||||
static wxString FontConfigVersion();
|
||||
|
||||
static wxString FreeTypeVersion();
|
||||
|
||||
static wxString HarfBuzzVersion();
|
||||
|
||||
static wxString FontLibraryVersion();
|
||||
|
||||
bool IsOutline() const override { return true; }
|
||||
|
||||
bool IsBold() const override
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* This program source code file is part of KICAD, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2021 Ola Rinta-Koski
|
||||
* Copyright (C) 2021-2023 Kicad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* Outline font class
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you may find one here:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#ifndef VERSION_INFO_H_
|
||||
#define VERSION_INFO_H_
|
||||
|
||||
#include <kicommon.h>
|
||||
#include <mutex>
|
||||
#include <wx/string.h>
|
||||
|
||||
namespace KIFONT
|
||||
{
|
||||
/**
|
||||
* Container for library version helpers.
|
||||
*/
|
||||
class KICOMMON_API VERSION_INFO
|
||||
{
|
||||
public:
|
||||
static wxString FontConfig();
|
||||
|
||||
static wxString FreeType();
|
||||
|
||||
static wxString HarfBuzz();
|
||||
|
||||
static wxString FontLibrary();
|
||||
|
||||
private:
|
||||
// we are a static helper
|
||||
VERSION_INFO() {}
|
||||
};
|
||||
|
||||
} //namespace KIFONT
|
||||
|
||||
#endif // VERSION_INFO_H_
|
Loading…
Reference in New Issue