Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: [Linux] RTL support with modern versions of ICU #10747

Merged
merged 2 commits into from May 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci-build.yml
Expand Up @@ -113,6 +113,7 @@ jobs:
liballegro4-dev \
libcurl4-openssl-dev \
libfontconfig-dev \
libharfbuzz-dev \
libicu-dev \
liblzma-dev \
liblzo2-dev \
Expand Down
15 changes: 11 additions & 4 deletions .github/workflows/release-linux.yml
Expand Up @@ -34,15 +34,20 @@ jobs:
- name: Install dependencies
run: |
echo "::group::Install system dependencies"
# ICU is used as vcpkg fails to install ICU. Other dependencies
# are needed either for vcpkg or for the packages installed with
# vcpkg.
# perl-IPC-Cmd, wget, and zip are needed to run vcpkg.
# autoconf-archive is needed to build ICU.
yum install -y \
libicu-devel \
autoconf-archive \
perl-IPC-Cmd \
wget \
zip \
# EOF

# aclocal looks first in /usr/local/share/aclocal, and if that doesn't
# exist only looks in /usr/share/aclocal. We have files in both that
# are important. So copy the latter to the first, and we are good to
# go.
cp /usr/share/aclocal/* /usr/local/share/aclocal/
echo "::endgroup::"

# We use vcpkg for our dependencies, to get more up-to-date version.
Expand All @@ -69,6 +74,8 @@ jobs:
curl[http2] \
fontconfig \
freetype \
harfbuzz \
icu \
liblzma \
libpng \
lzo \
Expand Down
11 changes: 9 additions & 2 deletions CMakeLists.txt
Expand Up @@ -143,7 +143,8 @@ if(NOT OPTION_DEDICATED)
endif()
find_package(Fluidsynth)
find_package(Fontconfig)
find_package(ICU OPTIONAL_COMPONENTS i18n lx)
find_package(Harfbuzz)
find_package(ICU OPTIONAL_COMPONENTS i18n)
endif()
endif()
endif()
Expand Down Expand Up @@ -178,6 +179,12 @@ if(UNIX AND NOT APPLE AND NOT OPTION_DEDICATED)
if(NOT SDL_FOUND AND NOT SDL2_FOUND AND NOT ALLEGRO_FOUND)
message(FATAL_ERROR "SDL, SDL2 or Allegro is required for this platform")
endif()
if(HARFBUZZ_FOUND AND NOT ICU_i18n_FOUND)
message(WARNING "HarfBuzz depends on ICU i18n to function; HarfBuzz will be disabled")
endif()
if(NOT HARFBUZZ_FOUND)
message(WARNING "Without HarfBuzz and ICU i18n the game will not be able to render right-to-left languages correctly")
endif()
endif()
if(APPLE)
if(NOT AUDIOTOOLBOX_LIBRARY)
Expand Down Expand Up @@ -289,7 +296,7 @@ if(NOT OPTION_DEDICATED)
link_package(Allegro)
link_package(FREETYPE TARGET Freetype::Freetype)
link_package(Fontconfig TARGET Fontconfig::Fontconfig)
link_package(ICU_lx)
link_package(Harfbuzz TARGET harfbuzz::harfbuzz)
link_package(ICU_i18n)

if(SDL2_FOUND AND OPENGL_FOUND AND UNIX)
Expand Down
1 change: 1 addition & 0 deletions COMPILING.md
Expand Up @@ -16,6 +16,7 @@ For Linux, the following additional libraries are used:
- libSDL2: hardware access (video, sound, mouse)
- libfreetype: loading generic fonts and rendering them
- libfontconfig: searching for fonts, resolving font names to actual fonts
- harfbuzz: handling of right-to-left scripts (e.g. Arabic and Persian) (required libicu)
- libicu: handling of right-to-left scripts (e.g. Arabic and Persian) and
natural sorting of strings

Expand Down
2 changes: 1 addition & 1 deletion Doxyfile.in
Expand Up @@ -292,8 +292,8 @@ PREDEFINED = WITH_ZLIB \
WITH_PNG \
WITH_FONTCONFIG \
WITH_FREETYPE \
WITH_HARFBUZZ \
WITH_ICU_I18N \
WITH_ICU_LX \
UNICODE \
_UNICODE \
_GNU_SOURCE \
Expand Down
3 changes: 3 additions & 0 deletions README.md
Expand Up @@ -183,6 +183,9 @@ See `src/3rdparty/fmt/LICENSE.rst` for the complete license text.
The catch2 implementation in `src/3rdparty/catch2` is licensed under the Boost Software License, Version 1.0.
See `src/3rdparty/catch2/LICENSE.txt` for the complete license text.

The icu scriptrun implementation in `src/3rdparty/icu` is licensed under the Unicode license.
See `src/3rdparty/icu/LICENSE` for the complete license text.

## 4.0 Credits

See [CREDITS.md](./CREDITS.md)
65 changes: 65 additions & 0 deletions cmake/FindHarfbuzz.cmake
@@ -0,0 +1,65 @@
#[=======================================================================[.rst:
FindHarfBuzz
-------

Finds the harfbuzz library.

Result Variables
^^^^^^^^^^^^^^^^

This will define the following variables:

``Harfbuzz_FOUND``
True if the system has the harfbuzz library.
``Harfbuzz_INCLUDE_DIRS``
Include directories needed to use harfbuzz.
``Harfbuzz_LIBRARIES``
Libraries needed to link to harfbuzz.
``Harfbuzz_VERSION``
The version of the harfbuzz library which was found.

Cache Variables
^^^^^^^^^^^^^^^

The following cache variables may also be set:

``Harfbuzz_INCLUDE_DIR``
The directory containing ``hb.h``.
``Harfbuzz_LIBRARY``
The path to the harfbuzz library.

#]=======================================================================]

find_package(PkgConfig QUIET)
pkg_check_modules(PC_Harfbuzz QUIET harfbuzz)

find_path(Harfbuzz_INCLUDE_DIR
NAMES hb.h
PATHS ${PC_Harfbuzz_INCLUDE_DIRS}
)

find_library(Harfbuzz_LIBRARY
NAMES harfbuzz
PATHS ${PC_Harfbuzz_LIBRARY_DIRS}
)

set(Harfbuzz_VERSION ${PC_Harfbuzz_VERSION})

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Harfbuzz
FOUND_VAR Harfbuzz_FOUND
REQUIRED_VARS
Harfbuzz_LIBRARY
Harfbuzz_INCLUDE_DIR
VERSION_VAR Harfbuzz_VERSION
)

if(Harfbuzz_FOUND)
set(Harfbuzz_LIBRARIES ${Harfbuzz_LIBRARY})
set(Harfbuzz_INCLUDE_DIRS ${Harfbuzz_INCLUDE_DIR})
endif()

mark_as_advanced(
Harfbuzz_INCLUDE_DIR
Harfbuzz_LIBRARY
)
4 changes: 2 additions & 2 deletions cmake/FindICU.cmake
Expand Up @@ -9,7 +9,7 @@ FindICU

Finds components of the ICU library.

Accepted components are: uc, i18n, le, lx, io
Accepted components are: uc, i18n, le, lx, io, data

Result Variables
^^^^^^^^^^^^^^^^
Expand All @@ -31,7 +31,7 @@ This will define the following variables:

find_package(PkgConfig QUIET)

set(ICU_KNOWN_COMPONENTS "uc" "i18n" "le" "lx" "io")
set(ICU_KNOWN_COMPONENTS "uc" "i18n" "le" "lx" "io" "data")

foreach(MOD_NAME IN LISTS ICU_FIND_COMPONENTS)
if(NOT MOD_NAME IN_LIST ICU_KNOWN_COMPONENTS)
Expand Down
1 change: 1 addition & 0 deletions src/3rdparty/CMakeLists.txt
@@ -1,5 +1,6 @@
add_subdirectory(catch2)
add_subdirectory(fmt)
add_subdirectory(icu)
add_subdirectory(md5)
add_subdirectory(squirrel)
add_subdirectory(opengl)
Expand Down
5 changes: 5 additions & 0 deletions src/3rdparty/icu/CMakeLists.txt
@@ -0,0 +1,5 @@
add_files(
scriptrun.cpp
scriptrun.h
CONDITION ICU_i18n_FOUND
)
46 changes: 46 additions & 0 deletions src/3rdparty/icu/LICENSE
@@ -0,0 +1,46 @@
UNICODE, INC. LICENSE AGREEMENT - DATA FILES AND SOFTWARE

See Terms of Use <https://www.unicode.org/copyright.html>
for definitions of Unicode Inc.’s Data Files and Software.

NOTICE TO USER: Carefully read the following legal agreement.
BY DOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING UNICODE INC.'S
DATA FILES ("DATA FILES"), AND/OR SOFTWARE ("SOFTWARE"),
YOU UNEQUIVOCALLY ACCEPT, AND AGREE TO BE BOUND BY, ALL OF THE
TERMS AND CONDITIONS OF THIS AGREEMENT.
IF YOU DO NOT AGREE, DO NOT DOWNLOAD, INSTALL, COPY, DISTRIBUTE OR USE
THE DATA FILES OR SOFTWARE.

COPYRIGHT AND PERMISSION NOTICE

Copyright © 1991-2023 Unicode, Inc. All rights reserved.
Distributed under the Terms of Use in https://www.unicode.org/copyright.html.

Permission is hereby granted, free of charge, to any person obtaining
a copy of the Unicode data files and any associated documentation
(the "Data Files") or Unicode software and any associated documentation
(the "Software") to deal in the Data Files or Software
without restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, and/or sell copies of
the Data Files or Software, and to permit persons to whom the Data Files
or Software are furnished to do so, provided that either
(a) this copyright and permission notice appear with all copies
of the Data Files or Software, or
(b) this copyright and permission notice appear in associated
Documentation.

THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT OF THIRD PARTY RIGHTS.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS
NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL
DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THE DATA FILES OR SOFTWARE.

Except as contained in this notice, the name of a copyright holder
shall not be used in advertising or otherwise to promote the sale,
use or other dealings in these Data Files or Software without prior
written authorization of the copyright holder.