Skip to content

Commit

Permalink
Add support for bidirectional text using fribidi
Browse files Browse the repository at this point in the history
  • Loading branch information
mt3d authored and past-due committed Jun 10, 2022
1 parent 31c5524 commit a89e395
Show file tree
Hide file tree
Showing 9 changed files with 298 additions and 70 deletions.
2 changes: 1 addition & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ freebsd_build_task:
install_script:
- pkg update -f
- pkg clean -a -y
- pkg install -y git cmake ninja p7zip gettext pkgconf png sdl2 openal-soft physfs libvorbis libogg opus libtheora freetype2 harfbuzz curl libsodium sqlite3 rubygem-asciidoctor
- pkg install -y git cmake ninja p7zip gettext pkgconf png sdl2 openal-soft physfs libvorbis libogg opus libtheora freetype2 fribidi harfbuzz curl libsodium sqlite3 rubygem-asciidoctor

init_git_submodules_script: git submodule update --init --recursive

Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ Do **not** use GitHub's "Download Zip" option, as it does not contain submodules
* [opus](https://github.com/xiph/opus)
* [Freetype](https://www.freetype.org/)
* [Harfbuzz](https://github.com/harfbuzz/harfbuzz) ≥ 1.0
* [fribidi] (https://github.com/fribidi/fribidi)
* [OpenAL-Soft](https://openal-soft.org)
* [libcurl](https://curl.haxx.se/libcurl/) _(strongly recommended: ≥ 7.58.0)_
* [libsodium](https://github.com/jedisct1/libsodium) ≥ 1.0.14
Expand All @@ -336,13 +337,13 @@ Do **not** use GitHub's "Download Zip" option, as it does not contain submodules
```shell
sudo apt-get -u update
sudo apt-get -y install git gcc g++ clang cmake libc-dev dpkg-dev ninja-build zip unzip pkg-config gettext asciidoctor
sudo apt-get -y install libpng-dev libsdl2-dev libopenal-dev libphysfs-dev libvorbis-dev libtheora-dev libxrandr-dev libfribidi-dev libfreetype6-dev libharfbuzz-dev libfontconfig1-dev libcurl4-gnutls-dev gnutls-dev libsodium-dev libsqlite3-dev
sudo apt-get -y install libpng-dev libsdl2-dev libopenal-dev libphysfs-dev libvorbis-dev libtheora-dev libxrandr-dev libfribidi-dev libfreetype6-dev libfribidi-dev libharfbuzz-dev libfontconfig1-dev libcurl4-gnutls-dev gnutls-dev libsodium-dev libsqlite3-dev
```
* Manually (Fedora):
```shell
sudo dnf -y update && dnf clean all
sudo dnf -y install git gcc gcc-c++ cmake ninja-build p7zip gettext rubygem-asciidoctor
sudo dnf -y install libpng-devel SDL2-devel openal-soft-devel physfs-devel libogg-devel libvorbis-devel libtheora-devel freetype-devel harfbuzz-devel libcurl-devel openssl-devel libsodium-devel sqlite-devel
sudo dnf -y install libpng-devel SDL2-devel openal-soft-devel physfs-devel libogg-devel libvorbis-devel libtheora-devel freetype-devel fribidi harfbuzz-devel libcurl-devel openssl-devel libsodium-devel sqlite-devel
```
* **Building from the command-line:**
1. Starting from the _parent_ directory of the warzone2100 source code (which is assumed to be in a folder named `warzone2100`), create a **sibling** build directory:
Expand Down
45 changes: 45 additions & 0 deletions cmake/FindFribidi.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Locate fribidi
# This module defines:
#
# FRIBIDI_INCLUDE_DIRS
# FRIBIDI_LIBRARIS
# FRIBIDI_FOUND
# FRIBIDI_VERSION_STRING
#

find_package(PkgConfig)
# If PkgConfig is available, attempt to find Fribidi paths using PkgConfig
if(PkgConfig_FOUND)
if(Fribidi_FIND_VERSION)
if(Fribidi_FIND_VERSION_EXACT)
set(_pkgConfig_version_match "==${Fribidi_FIND_VERSION}")
else()
set(_pkgConfig_version_match ">=${Fribidi_FIND_VERSION}")
endif()
endif()

pkg_search_module(PCFG_FRIBIDI QUIET fribidi${_pkgConfig_version_match})

if(PCFG_FRIBIDI_FOUND)
# Found Fribidi with PkgConfig
message(STATUS "Detected Fribidi with PkgConfig: FRIBIDI_INCLUDE_DIRS (${PCFG_FRIBIDI_INCLUDE_DIRS}); FRIBIDI_LIBRARY_DIRS (${PCFG_FRIBIDI_LIBRARY_DIRS})")
endif()
endif()

# Attempt to find Fribidi

find_path(
FRIBIDI_INCLUDE_DIRS fribidi.h
HINTS ${PCFG_FRIBIDI_INCLUDE_DIRS} ${PCFG_FRIBIDI_INCLUDEDIR}
)

find_library(
FRIBIDI_LIBRARIES NAMES fribidi
HINTS ${PCFG_FRIBIDI_LIBRARY_DIRS} ${PCFG_FRIBIDI_LIBDIR}
)

include(FindPackageHandleStandardArgs)

find_package_handle_standard_args(Fribidi REQUIRED_VARS FRIBIDI_INCLUDE_DIRS FRIBIDI_LIBRARIES VERSION_VAR FRIBIDI_VERSION_STRING)

mark_as_advanced(FRIBIDI_INCLUDE_DIRS FRIBIDI_LIBRARIES)
2 changes: 1 addition & 1 deletion docker/fedora-latest-m32/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ RUN dnf -y update && dnf -y install git gcc gcc-c++ cmake ninja-build p7zip gett

# Install WZ dependencies - 32-bit (i686, for cross-compile)
RUN dnf -y update && dnf -y install glibc-devel.i686 \
&& dnf -y install libpng-devel.i686 SDL2-devel.i686 openal-soft-devel.i686 physfs-devel.i686 libogg-devel.i686 libvorbis-devel.i686 opus-devel.i686 libtheora-devel.i686 freetype-devel.i686 harfbuzz-devel.i686 libcurl-devel.i686 openssl-devel.i686 libsodium-devel.i686 sqlite-devel.i686 \
&& dnf -y install libpng-devel.i686 SDL2-devel.i686 openal-soft-devel.i686 physfs-devel.i686 libogg-devel.i686 libvorbis-devel.i686 opus-devel.i686 libtheora-devel.i686 fribidi-devel.i686 freetype-devel.i686 harfbuzz-devel.i686 libcurl-devel.i686 openssl-devel.i686 libsodium-devel.i686 sqlite-devel.i686 \
&& dnf clean all

# Defines arguments which can be passed during build time.
Expand Down
12 changes: 6 additions & 6 deletions get-dependencies_linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ if [ "${DISTRO}" == "ubuntu" ]; then

if [ "${VERSION_PARTS[0]}" -eq "18" ]; then
echo "Installing build-dependencies for Ubuntu 18.x"
DEBIAN_FRONTEND=noninteractive apt-get -y install cmake git zip unzip gettext asciidoctor libsdl2-dev libphysfs-dev libpng-dev libopenal-dev libvorbis-dev libogg-dev libopus-dev libtheora-dev libxrandr-dev libfreetype6-dev libharfbuzz-dev libcurl4-gnutls-dev gnutls-dev libsodium-dev libsqlite3-dev
DEBIAN_FRONTEND=noninteractive apt-get -y install cmake git zip unzip gettext asciidoctor libsdl2-dev libphysfs-dev libpng-dev libopenal-dev libvorbis-dev libogg-dev libopus-dev libtheora-dev libxrandr-dev libfreetype6-dev libfribidi-dev libharfbuzz-dev libcurl4-gnutls-dev gnutls-dev libsodium-dev libsqlite3-dev
elif [ "${VERSION_PARTS[0]}" -ge "20" ]; then
echo "Installing build-dependencies for Ubuntu 20.x+"
DEBIAN_FRONTEND=noninteractive apt-get -y install cmake git zip unzip gettext asciidoctor libsdl2-dev libphysfs-dev libpng-dev libopenal-dev libvorbis-dev libogg-dev libopus-dev libtheora-dev libxrandr-dev libfreetype-dev libharfbuzz-dev libcurl4-gnutls-dev gnutls-dev libsodium-dev libsqlite3-dev
DEBIAN_FRONTEND=noninteractive apt-get -y install cmake git zip unzip gettext asciidoctor libsdl2-dev libphysfs-dev libpng-dev libopenal-dev libvorbis-dev libogg-dev libopus-dev libtheora-dev libxrandr-dev libfreetype-dev libfribidi-dev libharfbuzz-dev libcurl4-gnutls-dev gnutls-dev libsodium-dev libsqlite3-dev
else
echo "Script does not currently support Ubuntu ${VERSION_PARTS[0]} (${VERSION})"
exit 1
Expand All @@ -78,7 +78,7 @@ if [ "${DISTRO}" == "fedora" ]; then
fi

echo "Installing build-dependencies for Fedora"
dnf -y install cmake git p7zip gettext rubygem-asciidoctor SDL2-devel physfs-devel libpng-devel openal-soft-devel libvorbis-devel libogg-devel opus-devel libtheora-devel freetype-devel harfbuzz-devel libcurl-devel openssl-devel libsodium-devel sqlite-devel
dnf -y install cmake git p7zip gettext rubygem-asciidoctor SDL2-devel physfs-devel libpng-devel openal-soft-devel libvorbis-devel libogg-devel opus-devel libtheora-devel freetype-devel fribidi-devel harfbuzz-devel libcurl-devel openssl-devel libsodium-devel sqlite-devel
dnf -y install vulkan-devel glslc
fi

Expand All @@ -95,7 +95,7 @@ if [ "${DISTRO}" == "alpine" ]; then
fi

echo "Installing build-dependencies for Alpine"
apk add --no-cache cmake git p7zip gettext asciidoctor sdl2-dev physfs-dev libpng-dev openal-soft-dev libvorbis-dev libogg-dev opus-dev libtheora-dev freetype-dev harfbuzz-dev curl-dev libsodium-dev sqlite-dev
apk add --no-cache cmake git p7zip gettext asciidoctor sdl2-dev physfs-dev libpng-dev openal-soft-dev libvorbis-dev libogg-dev opus-dev libtheora-dev freetype-dev fribidi-dev harfbuzz-dev curl-dev libsodium-dev sqlite-dev
fi

##################
Expand All @@ -111,7 +111,7 @@ if [ "${DISTRO}" == "archlinux" ]; then
fi

echo "Installing build-dependencies for ArchLinux"
pacman -S --noconfirm cmake git p7zip gettext asciidoctor sdl2 physfs libpng openal libvorbis libogg opus libtheora xorg-xrandr freetype2 harfbuzz curl libsodium sqlite
pacman -S --noconfirm cmake git p7zip gettext asciidoctor sdl2 physfs libpng openal libvorbis libogg opus libtheora xorg-xrandr freetype2 fribidi harfbuzz curl libsodium sqlite
fi

##################
Expand All @@ -127,7 +127,7 @@ if [ "${DISTRO}" == "opensuse-tumbleweed" ]; then
fi

echo "Installing build-dependencies for OpenSUSE Tumbleweed"
zypper install -y libSDL2-devel libphysfs-devel libpng16-devel libtheora-devel libvorbis-devel libogg-devel libopus-devel freetype-devel harfbuzz-devel openal-soft-devel libsodium-devel sqlite3-devel libtinygettext0 ruby3.0-rubygem-asciidoctor vulkan-devel
zypper install -y libSDL2-devel libphysfs-devel libpng16-devel libtheora-devel libvorbis-devel libogg-devel libopus-devel freetype-devel fribidi-devel harfbuzz-devel openal-soft-devel libsodium-devel sqlite3-devel libtinygettext0 ruby3.0-rubygem-asciidoctor vulkan-devel
fi
##################

Expand Down
7 changes: 5 additions & 2 deletions lib/ivis_opengl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,20 @@ file(GLOB SRC
find_package(PNG 1.2 REQUIRED)
find_package(Freetype REQUIRED)
find_package(Harfbuzz 1.0 REQUIRED)
find_package(Fribidi REQUIRED)

include(CheckCXXCompilerFlag)

add_library(ivis-opengl STATIC ${HEADERS} ${SRC})
set_property(TARGET ivis-opengl PROPERTY FOLDER "lib")
include(WZTargetConfiguration)
WZ_TARGET_CONFIGURATION(ivis-opengl)
target_include_directories(ivis-opengl PRIVATE ${HARFBUZZ_INCLUDE_DIRS} ${FREETYPE_INCLUDE_DIR_ft2build})
target_link_libraries(ivis-opengl PRIVATE framework PNG::PNG ${HARFBUZZ_LIBRARIES} ${FREETYPE_LIBRARIES})

target_include_directories(ivis-opengl PRIVATE ${HARFBUZZ_INCLUDE_DIRS} ${FREETYPE_INCLUDE_DIR_ft2build} ${FRIBIDI_INCLUDE_DIRS})
target_link_libraries(ivis-opengl PRIVATE framework PNG::PNG ${HARFBUZZ_LIBRARIES} ${FREETYPE_LIBRARIES} ${FRIBIDI_LIBRARIES})
target_link_libraries(ivis-opengl PUBLIC glad)
target_link_libraries(ivis-opengl PUBLIC optional-lite)

if(WZ_ENABLE_BACKEND_VULKAN)
find_package(VulkanHeaders 148) # minimum supported version of the Vulkan headers is 148
set(_vulkanheaders_dl_gittag "sdk-1.2.198.0")
Expand Down
Loading

0 comments on commit a89e395

Please sign in to comment.