Skip to content

Commit

Permalink
Merge pull request #41100 from bruvzg/ctl_text_server_interface
Browse files Browse the repository at this point in the history
[Complex Text Layouts] Implement TextServer interface.
  • Loading branch information
akien-mga committed Nov 28, 2020
2 parents bd84600 + 7e2c0ff commit a6751e6
Show file tree
Hide file tree
Showing 980 changed files with 386,533 additions and 4,912 deletions.
119 changes: 119 additions & 0 deletions COPYRIGHT.txt
Expand Up @@ -157,6 +157,11 @@ Copyright: 2018, Source Foundry Authors
2003, Bitstream Inc.
License: Expat and Bitstream Vera Fonts Copyright

Files: ./thirdparty/fonts/Tamsyn*.png
Comment: Tamsyn font
Copyright: 2015, Scott Fial
License: Tamsyn

Files: ./thirdparty/freetype/
Comment: The FreeType Project
Copyright: 1996-2020, David Turner, Robert Wilhelm, and Werner Lemberg.
Expand All @@ -169,6 +174,33 @@ Copyright: 2015-2020 Google, Inc.
2002, NVIDIA Corporation.
License: glslang

Files: ./thirdparty/graphite/
Comment: Graphite engine
Copyright: 2010, SIL International
License: MPL-2.0

Files: ./thirdparty/harfbuzz/
Comment: HarfBuzz text shaping library
Copyright: 2010,2011,2012,2013,2014,2015,2016,2017,2018,2019,2020 Google, Inc.
2018,2019,2020 Ebrahim Byagowi
2019,2020 Facebook, Inc.
2012 Mozilla Foundation
2011 Codethink Limited
2008,2010 Nokia Corporation and/or its subsidiary(-ies)
2009 Keith Stribley
2009 Martin Hosken and SIL International
2007 Chris Wilson
2006 Behdad Esfahbod
2005 David Turner
2004,2007,2008,2009,2010 Red Hat, Inc.
1998-2004 David Turner and Werner Lemberg
License: HarfBuzz

Files: ./thirdparty/icu4c/
Comment: International Components for Unicode
Copyright: 1991-2020, Unicode
License: Unicode

Files: ./thirdparty/jpeg_compressor/
Comment: jpeg-compressor
Copyright: 2012, Rich Geldreich
Expand Down Expand Up @@ -1175,6 +1207,46 @@ License: FTL
Robert Wilhelm <robert.wilhelm@freetype.org>
Werner Lemberg <werner.lemberg@freetype.org>

License: HarfBuzz
HarfBuzz is licensed under the so-called "Old MIT" license. Details follow.
For parts of HarfBuzz that are licensed under different licenses see individual
files names COPYING in subdirectories where applicable.
.
Copyright (C) 2010,2011,2012,2013,2014,2015,2016,2017,2018,2019,2020 Google, Inc.
Copyright (C) 2018,2019,2020 Ebrahim Byagowi
Copyright (C) 2019,2020 Facebook, Inc.
Copyright (C) 2012 Mozilla Foundation
Copyright (C) 2011 Codethink Limited
Copyright (C) 2008,2010 Nokia Corporation and/or its subsidiary(-ies)
Copyright (C) 2009 Keith Stribley
Copyright (C) 2009 Martin Hosken and SIL International
Copyright (C) 2007 Chris Wilson
Copyright (C) 2006 Behdad Esfahbod
Copyright (C) 2005 David Turner
Copyright (C) 2004,2007,2008,2009,2010 Red Hat, Inc.
Copyright (C) 1998-2004 David Turner and Werner Lemberg
.
For full copyright notices consult the individual files in the package.
.
.
Permission is hereby granted, without written agreement and without
license or royalty fees, to use, copy, modify, and distribute this
software and its documentation for any purpose, provided that the
above copyright notice and the following two paragraphs appear in
all copies of this software.
.
IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
.
THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.

License: MPL-2.0
Mozilla Public License Version 2.0
==================================
Expand Down Expand Up @@ -1633,6 +1705,53 @@ License: OFL-1.1
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE.

License: Tamsyn
Tamsyn font is free. You are hereby granted permission to use, copy, modify,
and distribute it as you see fit.
.
Tamsyn font is provided "as is" without any express or implied warranty.
.
The author makes no representations about the suitability of this font for
a particular purpose.
.
In no event will the author be held liable for damages arising from the use
of this font.

License: Unicode
COPYRIGHT AND PERMISSION NOTICE (ICU 58 and later)
.
Copyright (C) 1991-2020 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.

License: Zlib
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
Expand Down
3 changes: 3 additions & 0 deletions SConstruct
Expand Up @@ -144,6 +144,9 @@ opts.Add(BoolVariable("builtin_certs", "Use the built-in SSL certificates bundle
opts.Add(BoolVariable("builtin_enet", "Use the built-in ENet library", True))
opts.Add(BoolVariable("builtin_freetype", "Use the built-in FreeType library", True))
opts.Add(BoolVariable("builtin_glslang", "Use the built-in glslang library", True))
opts.Add(BoolVariable("builtin_graphite", "Use the built-in Graphite library", True))
opts.Add(BoolVariable("builtin_harfbuzz", "Use the built-in HarfBuzz library", True))
opts.Add(BoolVariable("builtin_icu", "Use the built-in ICU library", True))
opts.Add(BoolVariable("builtin_libogg", "Use the built-in libogg library", True))
opts.Add(BoolVariable("builtin_libpng", "Use the built-in libpng library", True))
opts.Add(BoolVariable("builtin_libtheora", "Use the built-in libtheora library", True))
Expand Down
1 change: 1 addition & 0 deletions core/core_constants.cpp
Expand Up @@ -128,6 +128,7 @@ void register_global_constants() {
BIND_CORE_ENUM_CONSTANT(HALIGN_LEFT);
BIND_CORE_ENUM_CONSTANT(HALIGN_CENTER);
BIND_CORE_ENUM_CONSTANT(HALIGN_RIGHT);
BIND_CORE_ENUM_CONSTANT(HALIGN_FILL);

BIND_CORE_ENUM_CONSTANT(VALIGN_TOP);
BIND_CORE_ENUM_CONSTANT(VALIGN_CENTER);
Expand Down
3 changes: 2 additions & 1 deletion core/math/math_defs.h
Expand Up @@ -73,7 +73,8 @@ enum Orientation {
enum HAlign {
HALIGN_LEFT,
HALIGN_CENTER,
HALIGN_RIGHT
HALIGN_RIGHT,
HALIGN_FILL,
};

enum VAlign {
Expand Down
1 change: 1 addition & 0 deletions core/os/main_loop.cpp
Expand Up @@ -47,6 +47,7 @@ void MainLoop::_bind_methods() {
BIND_CONSTANT(NOTIFICATION_APPLICATION_PAUSED);
BIND_CONSTANT(NOTIFICATION_APPLICATION_FOCUS_IN);
BIND_CONSTANT(NOTIFICATION_APPLICATION_FOCUS_OUT);
BIND_CONSTANT(NOTIFICATION_TEXT_SERVER_CHANGED);

ADD_SIGNAL(MethodInfo("on_request_permissions_result", PropertyInfo(Variant::STRING, "permission"), PropertyInfo(Variant::BOOL, "granted")));
};
Expand Down
1 change: 1 addition & 0 deletions core/os/main_loop.h
Expand Up @@ -56,6 +56,7 @@ class MainLoop : public Object {
NOTIFICATION_APPLICATION_PAUSED = 2015,
NOTIFICATION_APPLICATION_FOCUS_IN = 2016,
NOTIFICATION_APPLICATION_FOCUS_OUT = 2017,
NOTIFICATION_TEXT_SERVER_CHANGED = 2018,
};

virtual void init();
Expand Down
21 changes: 21 additions & 0 deletions core/string/translation.cpp
Expand Up @@ -34,6 +34,11 @@
#include "core/io/resource_loader.h"
#include "core/os/os.h"

#ifdef TOOLS_ENABLED
#include "editor/editor_settings.h"
#include "main/main.h"
#endif

// ISO 639-1 language codes, with the addition of glibc locales with their
// regional identifiers. This list must match the language names (in English)
// of locale_names.
Expand Down Expand Up @@ -1214,6 +1219,22 @@ void TranslationServer::set_tool_translation(const Ref<Translation> &p_translati
tool_translation = p_translation;
}

Ref<Translation> TranslationServer::get_tool_translation() const {
return tool_translation;
}

String TranslationServer::get_tool_locale() {
#ifdef TOOLS_ENABLED
if (TranslationServer::get_singleton()->get_tool_translation().is_valid() && (Engine::get_singleton()->is_editor_hint() || Main::is_project_manager())) {
return tool_translation->get_locale();
} else {
#else
{
#endif
return get_locale();
}
}

StringName TranslationServer::tool_translate(const StringName &p_message, const StringName &p_context) const {
if (tool_translation.is_valid()) {
StringName r = tool_translation->get_message(p_message, p_context);
Expand Down
2 changes: 2 additions & 0 deletions core/string/translation.h
Expand Up @@ -110,7 +110,9 @@ class TranslationServer : public Object {
static String standardize_locale(const String &p_locale);
static String get_language_code(const String &p_locale);

String get_tool_locale();
void set_tool_translation(const Ref<Translation> &p_translation);
Ref<Translation> get_tool_translation() const;
StringName tool_translate(const StringName &p_message, const StringName &p_context = "") const;
StringName tool_translate_plural(const StringName &p_message, const StringName &p_message_plural, int p_n, const StringName &p_context = "") const;
void set_doc_translation(const Ref<Translation> &p_translation);
Expand Down
5 changes: 2 additions & 3 deletions core/string/ustring.cpp
Expand Up @@ -209,7 +209,6 @@ void CharString::copy_from(const char *p_cstr) {
/* String */
/*************************************************************************/

//TODO: move to TextServer
//kind of poor should be rewritten properly
String String::word_wrap(int p_chars_per_line) const {
int from = 0;
Expand Down Expand Up @@ -4796,7 +4795,7 @@ Vector<uint8_t> String::to_utf16_buffer() const {
Char16String charstr = s->utf16();

Vector<uint8_t> retval;
size_t len = charstr.length() * 2;
size_t len = charstr.length() * sizeof(char16_t);
retval.resize(len);
uint8_t *w = retval.ptrw();
copymem(w, (const void *)charstr.ptr(), len);
Expand All @@ -4811,7 +4810,7 @@ Vector<uint8_t> String::to_utf32_buffer() const {
}

Vector<uint8_t> retval;
size_t len = s->length() * 4;
size_t len = s->length() * sizeof(char32_t);
retval.resize(len);
uint8_t *w = retval.ptrw();
copymem(w, (const void *)s->ptr(), len);
Expand Down
7 changes: 4 additions & 3 deletions core/string/ustring.h
Expand Up @@ -28,8 +28,9 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/

#ifndef USTRING_H
#define USTRING_H
#ifndef USTRING_GODOT_H
#define USTRING_GODOT_H
// Note: Renamed to avoid conflict with ICU header with the same name.

#include "core/templates/cowdata.h"
#include "core/templates/vector.h"
Expand Down Expand Up @@ -555,4 +556,4 @@ _FORCE_INLINE_ Vector<String> sarray(P... p_args) {
return arr;
}

#endif // USTRING_H
#endif // USTRING_GODOT_H
18 changes: 18 additions & 0 deletions core/templates/hashfuncs.h
Expand Up @@ -114,6 +114,24 @@ static inline uint32_t make_uint32_t(T p_in) {
return _u._u32;
}

static inline uint64_t hash_djb2_one_float_64(double p_in, uint64_t p_prev = 5381) {
union {
double d;
uint64_t i;
} u;

// Normalize +/- 0.0 and NaN values so they hash the same.
if (p_in == 0.0f) {
u.d = 0.0;
} else if (Math::is_nan(p_in)) {
u.d = Math_NAN;
} else {
u.d = p_in;
}

return ((p_prev << 5) + p_prev) + u.i;
}

static inline uint64_t hash_djb2_one_64(uint64_t p_in, uint64_t p_prev = 5381) {
return ((p_prev << 5) + p_prev) + p_in;
}
Expand Down

0 comments on commit a6751e6

Please sign in to comment.