Add freetype dependency.

We are going to use freetype instead of the old custom TTF parser,
since the old parser has many annoying bugs when handling non-Latin
fonts and fixing it is not really worth the time.

On Windows, Freetype is built from a submodule.
On Linux and OS X, Freetype is provided together with the desktop,
though development files have to be installed separately.
pull/4/head
whitequark 2016-02-09 15:57:30 +00:00
parent f82767ae79
commit e5294eef9d
6 changed files with 43 additions and 14 deletions

3
.gitmodules vendored
View File

@ -5,3 +5,6 @@
[submodule "extlib/libpng"]
path = extlib/libpng
url = https://github.com/glennrp/libpng
[submodule "extlib/libfreetype"]
path = extlib/libfreetype
url = http://git.sv.nongnu.org/r/freetype/freetype2.git

View File

@ -3,7 +3,7 @@ os:
- linux
- osx
install:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo add-apt-repository -y ppa:smspillaz/cmake-master; sudo add-apt-repository -y ppa:ondrej/php5; sudo apt-get update -qq; sudo apt-get install -q -y cmake cmake-data libpng12-dev zlib1g-dev libjson0-dev libfontconfig1-dev libgtkmm-2.4-dev libpangomm-1.4-dev libgl1-mesa-dev libglu-dev libglew-dev dpkg-dev; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo add-apt-repository -y ppa:smspillaz/cmake-master; sudo add-apt-repository -y ppa:ondrej/php5; sudo apt-get update -qq; sudo apt-get install -q -y cmake cmake-data libpng12-dev zlib1g-dev libjson0-dev libfontconfig1-dev libgtkmm-2.4-dev libpangomm-1.4-dev libgl1-mesa-dev libglu-dev libglew-dev libfreetype6-dev dpkg-dev; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; brew upgrade cmake libpng; fi
script:
- mkdir cbuild

View File

@ -67,6 +67,32 @@ CHECK_INCLUDE_FILE("stdint.h" HAVE_STDINT_H)
find_package(OpenGL REQUIRED)
if(WIN32)
# We don't want any of the subprojects to install anything.
# We don't actually install anything on Windows (so overriding
# this is OK), but the combination of freetype's and png/zlib's
# CMakeLists.txt produces harmless but annoying CMake errors.
macro(install)
endmacro()
# Configure Freetype first. If done later, it will notice that
# zlib is available, try to use it and promptly break on MSVC
# in a very obscure way. Given that the only use of zlib, bzip2
# and png support is in support for extremely obsolete Unix fonts,
# we don't care.
find_package(Freetype)
if(NOT FREETYPE_FOUND)
message(STATUS "Using in-tree libfreetype")
add_subdirectory(extlib/libfreetype)
set(FREETYPE_LIBRARY
freetype)
set(FREETYPE_INCLUDE_DIRS
"${CMAKE_SOURCE_DIR}/extlib/libfreetype/include")
find_package(Freetype REQUIRED)
endif()
find_package(ZLIB)
if(NOT ZLIB_FOUND)
@ -109,6 +135,7 @@ if(WIN32)
endif()
elseif(APPLE)
find_package(PNG REQUIRED)
find_package(Freetype REQUIRED)
find_library(APPKIT_LIBRARY AppKit REQUIRED)
else() # Linux and compatible systems
find_package(SpaceWare)
@ -120,6 +147,7 @@ else() # Linux and compatible systems
pkg_check_modules(FONTCONFIG REQUIRED fontconfig)
pkg_check_modules(JSONC REQUIRED json-c)
pkg_check_modules(GLEW REQUIRED glew)
pkg_check_modules(FREETYPE REQUIRED freetype2)
set(HAVE_GTK TRUE)
if(GUI STREQUAL "gtk3")

View File

@ -24,13 +24,13 @@ Building on Linux
### Building for Linux
You will need CMake, libpng, zlib, json-c, fontconfig, gtkmm 2.4, pangomm 1.4,
OpenGL and OpenGL GLU.
You will need CMake, libpng, zlib, json-c, fontconfig, freetype, gtkmm 2.4,
pangomm 1.4, OpenGL and OpenGL GLU.
On a Debian derivative (e.g. Ubuntu) these can be installed with:
apt-get install libpng12-dev libjson-c-dev libfontconfig1-dev \
libgtkmm-2.4-dev libpangomm-1.4-dev libgl-dev libglu-dev \
libglew-dev cmake
apt-get install libpng12-dev libjson-c-dev libfreetype6-dev \
libfontconfig1-dev libgtkmm-2.4-dev libpangomm-1.4-dev \
libgl-dev libglu-dev libglew-dev cmake
After that, build SolveSpace as following:

1
extlib/libfreetype Submodule

@ -0,0 +1 @@
Subproject commit 44accb9e2e5b00696cf50a869b68afa2ce3dd389

View File

@ -2,16 +2,12 @@
include_directories(
${OPENGL_INCLUDE_DIR}
${PNG_INCLUDE_DIRS})
${PNG_INCLUDE_DIRS}
${FREETYPE_INCLUDE_DIRS})
link_directories(
${PNG_LIBRARY_DIRS})
add_definitions(
${PNG_CFLAGS_OTHER})
link_directories(
${PNG_LIBRARY_DIRS})
${PNG_LIBRARY_DIRS}
${FREETYPE_LIBRARY_DIRS})
add_definitions(
${PNG_CFLAGS_OTHER})
@ -307,6 +303,7 @@ target_link_libraries(solvespace
"${OPENGL_LIBRARIES}"
"${PNG_LIBRARIES}"
"${ZLIB_LIBRARIES}"
"${FREETYPE_LIBRARIES}"
"${platform_LIBRARIES}")
if(WIN32 AND NOT MINGW)