diff --git a/.gitignore b/.gitignore index 397a2aca95..812a3e0fce 100644 --- a/.gitignore +++ b/.gitignore @@ -32,7 +32,6 @@ CMakeCache.txt .cache/ auto_renamed_to_cpp Testing -version.h config.h install_manifest.txt doxygen/out diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 7593b15759..77a1a98771 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -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 ) diff --git a/common/build_version.cpp b/common/build_version.cpp index 21ddf6487c..af691143ce 100644 --- a/common/build_version.cpp +++ b/common/build_version.cpp @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include @@ -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; diff --git a/common/font/outline_font.cpp b/common/font/outline_font.cpp index 40c380d03c..dd051b9567 100644 --- a/common/font/outline_font.cpp +++ b/common/font/outline_font.cpp @@ -55,40 +55,6 @@ OUTLINE_FONT::OUTLINE_FONT() : } -wxString OUTLINE_FONT::FreeTypeVersion() -{ - std::lock_guard 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 font = std::make_unique(); diff --git a/common/font/version_info.cpp b/common/font/version_info.cpp new file mode 100644 index 0000000000..9bf32495c7 --- /dev/null +++ b/common/font/version_info.cpp @@ -0,0 +1,67 @@ +/* + * 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. + * + * 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 +#include +#include +#ifdef _MSC_VER +#include +#else +#include +#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() ); +} \ No newline at end of file diff --git a/include/font/fontconfig.h b/include/font/fontconfig.h index d0a4f13074..6f12bdb4e8 100644 --- a/include/font/fontconfig.h +++ b/include/font/fontconfig.h @@ -23,6 +23,7 @@ #include +#include #include #include #include @@ -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 diff --git a/include/font/outline_font.h b/include/font/outline_font.h index 42784b46a6..03b1a4a729 100644 --- a/include/font/outline_font.h +++ b/include/font/outline_font.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 diff --git a/include/font/version_info.h b/include/font/version_info.h new file mode 100644 index 0000000000..78400a76a1 --- /dev/null +++ b/include/font/version_info.h @@ -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 +#include +#include + +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_