diff options
117 files changed, 2555 insertions, 1384 deletions
diff --git a/core/array.cpp b/core/array.cpp index 30184a002e..171c11776c 100644 --- a/core/array.cpp +++ b/core/array.cpp @@ -233,9 +233,10 @@ struct _ArrayVariantSort { } }; -void Array::sort() { +Array &Array::sort() { _p->array.sort_custom<_ArrayVariantSort>(); + return *this; } struct _ArrayVariantSortCustom { @@ -253,19 +254,21 @@ struct _ArrayVariantSortCustom { return res; } }; -void Array::sort_custom(Object *p_obj, const StringName &p_function) { +Array &Array::sort_custom(Object *p_obj, const StringName &p_function) { - ERR_FAIL_NULL(p_obj); + ERR_FAIL_NULL_V(p_obj, *this); SortArray<Variant, _ArrayVariantSortCustom> avs; avs.compare.obj = p_obj; avs.compare.func = p_function; avs.sort(_p->array.ptr(), _p->array.size()); + return *this; } -void Array::invert() { +Array &Array::invert() { _p->array.invert(); + return *this; } void Array::push_front(const Variant &p_value) { diff --git a/core/array.h b/core/array.h index 8a647dd13b..2c29103108 100644 --- a/core/array.h +++ b/core/array.h @@ -68,9 +68,9 @@ public: Variant front() const; Variant back() const; - void sort(); - void sort_custom(Object *p_obj, const StringName &p_function); - void invert(); + Array &sort(); + Array &sort_custom(Object *p_obj, const StringName &p_function); + Array &invert(); int find(const Variant &p_value, int p_from = 0) const; int rfind(const Variant &p_value, int p_from = -1) const; diff --git a/core/class_db.cpp b/core/class_db.cpp index f5ddd9c761..12310f6151 100644 --- a/core/class_db.cpp +++ b/core/class_db.cpp @@ -205,6 +205,7 @@ ClassDB::ClassInfo::ClassInfo() { creation_func = NULL; inherits_ptr = NULL; disabled = false; + exposed = false; } ClassDB::ClassInfo::~ClassInfo() { } @@ -1284,6 +1285,15 @@ bool ClassDB::is_class_enabled(StringName p_class) { return !ti->disabled; } +bool ClassDB::is_class_exposed(StringName p_class) { + + OBJTYPE_RLOCK; + + ClassInfo *ti = classes.getptr(p_class); + ERR_FAIL_COND_V(!ti, false); + return ti->exposed; +} + StringName ClassDB::get_category(const StringName &p_node) { ERR_FAIL_COND_V(!classes.has(p_node), StringName()); diff --git a/core/class_db.h b/core/class_db.h index f6b97748b0..5910a2ce01 100644 --- a/core/class_db.h +++ b/core/class_db.h @@ -127,6 +127,7 @@ public: StringName inherits; StringName name; bool disabled; + bool exposed; Object *(*creation_func)(); ClassInfo(); ~ClassInfo(); @@ -168,6 +169,7 @@ public: ClassInfo *t = classes.getptr(T::get_class_static()); ERR_FAIL_COND(!t); t->creation_func = &creator<T>; + t->exposed = true; T::register_custom_data_to_otdb(); } @@ -176,6 +178,9 @@ public: GLOBAL_LOCK_FUNCTION; T::initialize_class(); + ClassInfo *t = classes.getptr(T::get_class_static()); + ERR_FAIL_COND(!t); + t->exposed = true; //nothing } @@ -193,6 +198,7 @@ public: ClassInfo *t = classes.getptr(T::get_class_static()); ERR_FAIL_COND(!t); t->creation_func = &_create_ptr_func<T>; + t->exposed = true; T::register_custom_data_to_otdb(); } @@ -347,6 +353,8 @@ public: static void set_class_enabled(StringName p_class, bool p_enable); static bool is_class_enabled(StringName p_class); + static bool is_class_exposed(StringName p_class); + static void add_resource_base_extension(const StringName &p_extension, const StringName &p_class); static void get_resource_base_extensions(List<String> *p_extensions); static void get_extensions_for_type(const StringName &p_class, List<String> *p_extensions); diff --git a/core/io/logger.cpp b/core/io/logger.cpp index b94007d316..ad6371f1e1 100644 --- a/core/io/logger.cpp +++ b/core/io/logger.cpp @@ -33,6 +33,17 @@ #include "os/os.h" #include "print_string.h" +// va_copy was defined in the C99, but not in C++ standards before C++11. +// When you compile C++ without --std=c++<XX> option, compilers still define +// va_copy, otherwise you have to use the internal version (__va_copy). +#if !defined(va_copy) +#if defined(__GNUC__) +#define va_copy(d, s) __va_copy(d, s) +#else +#define va_copy(d, s) ((d) = (s)) +#endif +#endif + bool Logger::should_log(bool p_err) { return (!p_err || _print_error_enabled) && (p_err || _print_line_enabled); } diff --git a/core/os/input.cpp b/core/os/input.cpp index a4b82299a7..848b003d5e 100644 --- a/core/os/input.cpp +++ b/core/os/input.cpp @@ -58,6 +58,7 @@ void Input::_bind_methods() { ClassDB::bind_method(D_METHOD("is_action_just_released", "action"), &Input::is_action_just_released); ClassDB::bind_method(D_METHOD("add_joy_mapping", "mapping", "update_existing"), &Input::add_joy_mapping, DEFVAL(false)); ClassDB::bind_method(D_METHOD("remove_joy_mapping", "guid"), &Input::remove_joy_mapping); + ClassDB::bind_method(D_METHOD("joy_connection_changed", "device", "connected", "name", "guid"), &Input::joy_connection_changed); ClassDB::bind_method(D_METHOD("is_joy_known", "device"), &Input::is_joy_known); ClassDB::bind_method(D_METHOD("get_joy_axis", "device", "axis"), &Input::get_joy_axis); ClassDB::bind_method(D_METHOD("get_joy_name", "device"), &Input::get_joy_name); diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp index 0e34a3eea5..c6d7cd44e8 100644 --- a/core/register_core_types.cpp +++ b/core/register_core_types.cpp @@ -40,6 +40,7 @@ #include "io/config_file.h" #include "io/http_client.h" #include "io/marshalls.h" +#include "io/networked_multiplayer_peer.h" #include "io/packet_peer.h" #include "io/packet_peer_udp.h" #include "io/pck_packer.h" @@ -109,6 +110,8 @@ void register_core_types() { ClassDB::register_class<Object>(); + ClassDB::register_virtual_class<Script>(); + ClassDB::register_class<Reference>(); ClassDB::register_class<WeakRef>(); ClassDB::register_class<Resource>(); @@ -136,6 +139,7 @@ void register_core_types() { ClassDB::register_virtual_class<IP>(); ClassDB::register_virtual_class<PacketPeer>(); ClassDB::register_class<PacketPeerStream>(); + ClassDB::register_virtual_class<NetworkedMultiplayerPeer>(); ClassDB::register_class<MainLoop>(); //ClassDB::register_type<OptimizedSaver>(); ClassDB::register_class<Translation>(); @@ -185,6 +189,20 @@ void register_core_settings() { void register_core_singletons() { + ClassDB::register_class<ProjectSettings>(); + ClassDB::register_virtual_class<IP>(); + ClassDB::register_class<_Geometry>(); + ClassDB::register_class<_ResourceLoader>(); + ClassDB::register_class<_ResourceSaver>(); + ClassDB::register_class<_OS>(); + ClassDB::register_class<_Engine>(); + ClassDB::register_class<_ClassDB>(); + ClassDB::register_class<_Marshalls>(); + ClassDB::register_class<TranslationServer>(); + ClassDB::register_virtual_class<Input>(); + ClassDB::register_class<InputMap>(); + ClassDB::register_class<_JSON>(); + ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("ProjectSettings", ProjectSettings::get_singleton())); ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("IP", IP::get_singleton())); ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("Geometry", _Geometry::get_singleton())); diff --git a/doc/classes/Array.xml b/doc/classes/Array.xml index 47100f23b8..2cfbaffe04 100644 --- a/doc/classes/Array.xml +++ b/doc/classes/Array.xml @@ -178,8 +178,10 @@ </description> </method> <method name="invert"> + <return type="Array"> + </return> <description> - Reverse the order of the elements in the array (so first element will now be the last). + Reverse the order of the elements in the array (so first element will now be the last) and return reference to the array. </description> </method> <method name="pop_back"> @@ -239,17 +241,21 @@ </description> </method> <method name="sort"> + <return type="Array"> + </return> <description> - Sort the array using natural order. + Sort the array using natural order and return reference to the array. </description> </method> <method name="sort_custom"> + <return type="Array"> + </return> <argument index="0" name="obj" type="Object"> </argument> <argument index="1" name="func" type="String"> </argument> <description> - Sort the array using a custom method. The arguments are an object that holds the method and the name of such method. The custom method receives two arguments (a pair of elements from the array) and must return true if the first argument is less than the second, and return false otherwise. Note: you cannot randomize the return value as the heapsort algorithm expects a deterministic result. Doing so will result in unexpected behavior. + Sort the array using a custom method and return reference to the array. The arguments are an object that holds the method and the name of such method. The custom method receives two arguments (a pair of elements from the array) and must return true if the first argument is less than the second, and return false otherwise. Note: you cannot randomize the return value as the heapsort algorithm expects a deterministic result. Doing so will result in unexpected behavior. </description> </method> </methods> diff --git a/doc/classes/AudioBusLayout.xml b/doc/classes/AudioBusLayout.xml index e5b17b8dfb..045c6c2bf9 100644 --- a/doc/classes/AudioBusLayout.xml +++ b/doc/classes/AudioBusLayout.xml @@ -1,8 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="AudioBusLayout" inherits="Resource" category="Core" version="3.0.alpha.custom_build"> <brief_description> + Stores information about the audiobusses. </brief_description> <description> + Stores position, muting, solo, bypass, effects, effect position, volume, and the connections between busses. See [AudioServer] for usage. </description> <tutorials> </tutorials> diff --git a/doc/classes/AudioServer.xml b/doc/classes/AudioServer.xml index 768987fd0b..0a59da5355 100644 --- a/doc/classes/AudioServer.xml +++ b/doc/classes/AudioServer.xml @@ -17,6 +17,7 @@ <argument index="0" name="at_position" type="int" default="-1"> </argument> <description> + Adds a bus at [code]at_position[/code]. </description> </method> <method name="add_bus_effect"> @@ -29,18 +30,21 @@ <argument index="2" name="at_position" type="int" default="-1"> </argument> <description> + Adds an [AudioEffect] effect to the bus [code]bus_idx[/code] at [code]at_position[/code]. </description> </method> <method name="generate_bus_layout" qualifiers="const"> <return type="AudioBusLayout"> </return> <description> + Generates an [AudioBusLayout] using the available busses and effects. </description> </method> <method name="get_bus_count" qualifiers="const"> <return type="int"> </return> <description> + Returns the number of available busses. </description> </method> <method name="get_bus_effect"> @@ -51,6 +55,7 @@ <argument index="1" name="effect_idx" type="int"> </argument> <description> + Returns the [AudioEffect] at position [code]effect_idx[/code] in bus [code]bus_idx[/code]. </description> </method> <method name="get_bus_effect_count"> @@ -59,6 +64,7 @@ <argument index="0" name="bus_idx" type="int"> </argument> <description> + Returns the number of effects on the bus at [code]bus_idx[/code]. </description> </method> <method name="get_bus_index" qualifiers="const"> @@ -67,6 +73,7 @@ <argument index="0" name="bus_name" type="String"> </argument> <description> + Returns the index of the bus with the name [code]bus_name[/code]. </description> </method> <method name="get_bus_name" qualifiers="const"> @@ -75,6 +82,7 @@ <argument index="0" name="bus_idx" type="int"> </argument> <description> + Returns the name of the bus with the index [code]bus_idx[/code]. </description> </method> <method name="get_bus_peak_volume_left_db" qualifiers="const"> @@ -85,6 +93,7 @@ <argument index="1" name="channel" type="int"> </argument> <description> + Returns the peak volume of the left speaker at bus index [code]bus_idx[/code] and channel index [code]channel[/code]. </description> </method> <method name="get_bus_peak_volume_right_db" qualifiers="const"> @@ -95,6 +104,7 @@ <argument index="1" name="channel" type="int"> </argument> <description> + Returns the peak volume of the right speaker at bus index [code]bus_idx[/code] and channel index [code]channel[/code]. </description> </method> <method name="get_bus_send" qualifiers="const"> @@ -103,6 +113,7 @@ <argument index="0" name="bus_idx" type="int"> </argument> <description> + Returns the name of the bus that the bus at index [code]bus_idx[/code] sends to. </description> </method> <method name="get_bus_volume_db" qualifiers="const"> @@ -111,18 +122,21 @@ <argument index="0" name="bus_idx" type="int"> </argument> <description> + Returns the volume of the bus at index [code]bus_idx[/code] in dB. </description> </method> <method name="get_mix_rate" qualifiers="const"> <return type="float"> </return> <description> + Returns the sample rate at the output of the audioserver. </description> </method> <method name="get_speaker_mode" qualifiers="const"> <return type="int" enum="AudioServer.SpeakerMode"> </return> <description> + Returns the speaker configuration. </description> </method> <method name="is_bus_bypassing_effects" qualifiers="const"> @@ -131,6 +145,7 @@ <argument index="0" name="bus_idx" type="int"> </argument> <description> + If [code]true[/code] the bus at index [code]bus_idx[/code] is bypassing effects. </description> </method> <method name="is_bus_effect_enabled" qualifiers="const"> @@ -141,6 +156,7 @@ <argument index="1" name="effect_idx" type="int"> </argument> <description> + If [code]true[/code] the effect at index [code]effect_idx[/code] on the bus at index [code]bus_idx[/code] is enabled. </description> </method> <method name="is_bus_mute" qualifiers="const"> @@ -149,6 +165,7 @@ <argument index="0" name="bus_idx" type="int"> </argument> <description> + If [code]true[/code] the bus at index [code]bus_idx[/code] is muted. </description> </method> <method name="is_bus_solo" qualifiers="const"> @@ -157,12 +174,14 @@ <argument index="0" name="bus_idx" type="int"> </argument> <description> + If [code]true[/code] the bus at index [code]bus_idx[/code] is in solo mode. </description> </method> <method name="lock"> <return type="void"> </return> <description> + Locks the audio drivers mainloop. Remember to unlock it afterwards. </description> </method> <method name="move_bus"> @@ -173,6 +192,7 @@ <argument index="1" name="to_index" type="int"> </argument> <description> + Moves the bus from index [code]index[/code] to index [code]to_index[/code]. </description> </method> <method name="remove_bus"> @@ -181,6 +201,7 @@ <argument index="0" name="index" type="int"> </argument> <description> + Removes the bus at index [code]index[/code]. </description> </method> <method name="remove_bus_effect"> @@ -191,6 +212,7 @@ <argument index="1" name="effect_idx" type="int"> </argument> <description> + Removes the effect at index [code]effect_idx[/code] from the bus at index [code]bus_idx[/code]. </description> </method> <method name="set_bus_bypass_effects"> @@ -201,6 +223,7 @@ <argument index="1" name="enable" type="bool"> </argument> <description> + If [code]true[/code] the bus at index [code]bus_idx[/code] is bypassing effects. </description> </method> <method name="set_bus_count"> @@ -209,6 +232,7 @@ <argument index="0" name="amount" type="int"> </argument> <description> + Adds and removes busses to make the number of busses match [code]amount[/code]. </description> </method> <method name="set_bus_effect_enabled"> @@ -221,6 +245,7 @@ <argument index="2" name="enabled" type="bool"> </argument> <description> + If [code]true[/code] the effect at index [code]effect_idx[/code] on the bus at index [code]bus_idx[/code] is enabled. </description> </method> <method name="set_bus_layout"> @@ -229,6 +254,7 @@ <argument index="0" name="bus_layout" type="AudioBusLayout"> </argument> <description> + Overwrites the currently used [AudioBusLayout]. </description> </method> <method name="set_bus_mute"> @@ -239,6 +265,7 @@ <argument index="1" name="enable" type="bool"> </argument> <description> + If [code]true[/code] the bus at index [code]bus_idx[/code] is muted. </description> </method> <method name="set_bus_name"> @@ -249,6 +276,7 @@ <argument index="1" name="name" type="String"> </argument> <description> + Sets the name of the bus at index [code]bus_idx[/code] to [code]name[/code]. </description> </method> <method name="set_bus_send"> @@ -259,6 +287,7 @@ <argument index="1" name="send" type="String"> </argument> <description> + Connects the output of the bus at [code]bus_idx[/code] to the bus named [code]send[/send]. </description> </method> <method name="set_bus_solo"> @@ -269,6 +298,7 @@ <argument index="1" name="enable" type="bool"> </argument> <description> + If [code]true[/code] the bus at index [code]bus_idx[/code] is in solo mode. </description> </method> <method name="set_bus_volume_db"> @@ -279,6 +309,7 @@ <argument index="1" name="volume_db" type="float"> </argument> <description> + Sets the volume of the bus at index [code]bus_idx[/code] to [code]volume_db[/code]. </description> </method> <method name="swap_bus_effects"> @@ -291,27 +322,33 @@ <argument index="2" name="by_effect_idx" type="int"> </argument> <description> + Swaps the position of two effects in bus [code]bus_idx[/code]. </description> </method> <method name="unlock"> <return type="void"> </return> <description> + Unlocks the audiodriver's main loop. After locking it always unlock it. </description> </method> </methods> <signals> <signal name="bus_layout_changed"> <description> + Emitted when the [AudioBusLayout] changes. </description> </signal> </signals> <constants> <constant name="SPEAKER_MODE_STEREO" value="0"> + Two or fewer speakers are detected. </constant> <constant name="SPEAKER_SURROUND_51" value="2"> + A 5.1 channel surround setup detected. </constant> <constant name="SPEAKER_SURROUND_71" value="3"> + A 7.1 channel surround setup detected. </constant> </constants> </class> diff --git a/doc/classes/AudioStreamPlayback.xml b/doc/classes/AudioStreamPlayback.xml index 30a9a8f070..f45beec42c 100644 --- a/doc/classes/AudioStreamPlayback.xml +++ b/doc/classes/AudioStreamPlayback.xml @@ -1,8 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="AudioStreamPlayback" inherits="Reference" category="Core" version="3.0.alpha.custom_build"> <brief_description> + Meta class for playing back audio. </brief_description> <description> + Can play, loop, pause a scroll through Audio. See [AudioStream] and [AudioStreamOGGVorbis] for usage. </description> <tutorials> </tutorials> diff --git a/doc/classes/AudioStreamPlayer.xml b/doc/classes/AudioStreamPlayer.xml index 9b104fe757..1a9ad85565 100644 --- a/doc/classes/AudioStreamPlayer.xml +++ b/doc/classes/AudioStreamPlayer.xml @@ -7,6 +7,7 @@ Plays background audio. </description> <tutorials> + http://docs.godotengine.org/en/latest/learning/features/audio/index.html </tutorials> <demos> </demos> @@ -27,6 +28,7 @@ <return type="float"> </return> <description> + Returns the position in the [AudioStream]. </description> </method> <method name="get_stream" qualifiers="const"> @@ -121,15 +123,16 @@ </methods> <members> <member name="autoplay" type="bool" setter="set_autoplay" getter="is_autoplay_enabled"> - If [code]true[/code], audio plays when added to scene tree. Default value: [code]false[/code]. + If [code]true[/code] audio plays when added to scene tree. Default value: [code]false[/code]. </member> <member name="bus" type="String" setter="set_bus" getter="get_bus"> Bus on which this audio is playing. </member> <member name="mix_target" type="int" setter="set_mix_target" getter="get_mix_target" enum="AudioStreamPlayer.MixTarget"> + If the audio configuration has more than two speakers, this sets the target channels. See [code]MIX_TARGET_*[/code] constants. </member> <member name="playing" type="bool" setter="_set_playing" getter="is_playing"> - If [code]true[/code], audio is playing. + If [code]true[/code] audio is playing. </member> <member name="stream" type="AudioStream" setter="set_stream" getter="get_stream"> The [AudioStream] object to be played. @@ -147,10 +150,13 @@ </signals> <constants> <constant name="MIX_TARGET_STEREO" value="0"> + The audio will be played only on the first channel. </constant> <constant name="MIX_TARGET_SURROUND" value="1"> + The audio will be played on all surround channels. </constant> <constant name="MIX_TARGET_CENTER" value="2"> + The audio will be played on the second channel, which is usually the center. </constant> </constants> </class> diff --git a/doc/classes/AudioStreamPlayer2D.xml b/doc/classes/AudioStreamPlayer2D.xml index 600e0858dd..c6fd8ff54f 100644 --- a/doc/classes/AudioStreamPlayer2D.xml +++ b/doc/classes/AudioStreamPlayer2D.xml @@ -40,6 +40,7 @@ <return type="float"> </return> <description> + Returns the position in the [AudioStream]. </description> </method> <method name="get_stream" qualifiers="const"> @@ -156,7 +157,7 @@ Dampens audio over distance with this as an exponent. </member> <member name="autoplay" type="bool" setter="set_autoplay" getter="is_autoplay_enabled"> - If [code]true[/code], audio plays when added to scene tree. Default value: [code]false[/code]. + If [code]true[/code] audio plays when added to scene tree. Default value: [code]false[/code]. </member> <member name="bus" type="String" setter="set_bus" getter="get_bus"> Bus on which this audio is playing. @@ -165,7 +166,7 @@ Maximum distance from which audio is still hearable. </member> <member name="playing" type="bool" setter="_set_playing" getter="is_playing"> - If [code]true[/code], audio is playing. + If [code]true[/code] audio is playing. </member> <member name="stream" type="AudioStream" setter="set_stream" getter="get_stream"> The [AudioStream] object to be played. diff --git a/doc/classes/AudioStreamPlayer3D.xml b/doc/classes/AudioStreamPlayer3D.xml index 886b2b975a..2085b35e2e 100644 --- a/doc/classes/AudioStreamPlayer3D.xml +++ b/doc/classes/AudioStreamPlayer3D.xml @@ -82,6 +82,7 @@ <return type="float"> </return> <description> + Returns the position in the [AudioStream]. </description> </method> <method name="get_stream" qualifiers="const"> @@ -288,7 +289,7 @@ Decides if audio should get quieter with distance linearly, quadratically or logarithmically. </member> <member name="autoplay" type="bool" setter="set_autoplay" getter="is_autoplay_enabled"> - If [code]true[/code], audio plays audio plays when added to scene tree. Default value: [code]false[/code]. + If [code]true[/code] audio plays when added to scene tree. Default value: [code]false[/code]. </member> <member name="bus" type="String" setter="set_bus" getter="get_bus"> Bus on which this audio is playing. @@ -300,7 +301,7 @@ The angle in which the audio reaches cameras undampened. </member> <member name="emission_angle_enabled" type="bool" setter="set_emission_angle_enabled" getter="is_emission_angle_enabled"> - If [code]true[/code], the audio should be dampened according to the direction of the sound. + If [code]true[/code] the audio should be dampened according to the direction of the sound. </member> <member name="emission_angle_filter_attenuation_db" type="float" setter="set_emission_angle_filter_attenuation_db" getter="get_emission_angle_filter_attenuation_db"> dampens audio if camera is outside of 'emission_angle_degrees' and 'emission_angle_enabled' is set by this factor, in dB. diff --git a/doc/classes/Engine.xml b/doc/classes/Engine.xml index 2372c619f5..5bb0810296 100644 --- a/doc/classes/Engine.xml +++ b/doc/classes/Engine.xml @@ -1,8 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="Engine" inherits="Object" category="Core" version="3.0.alpha.custom_build"> <brief_description> + Access to basic engine properties. </brief_description> <description> + The [Engine] class allows you to query and modify the game's run-time parameters, such as frames per second, time scale, and others. </description> <tutorials> </tutorials> @@ -13,7 +15,7 @@ <return type="int"> </return> <description> - Return the total amount of frames drawn. + Returns the total number of frames drawn. </description> </method> <method name="get_frames_per_second" qualifiers="const"> @@ -27,26 +29,28 @@ <return type="int"> </return> <description> - Return the amount of fixed iterations per second (for fixed process and physics). + Returns the number of fixed iterations per second (for fixed process and physics). </description> </method> <method name="get_main_loop" qualifiers="const"> <return type="MainLoop"> </return> <description> - Return the main loop object (see [MainLoop] and [SceneTree]). + Returns the main loop object (see [MainLoop] and [SceneTree]). </description> </method> <method name="get_target_fps" qualifiers="const"> <return type="float"> </return> <description> + Returns the desired frames per second. If the hardware cannot keep up, this setting may not be respected. It defaults to 0, which indicates no limit. </description> </method> <method name="get_time_scale"> <return type="float"> </return> <description> + Returns how fast or slow the in-game clock ticks versus the real life one. It defaults to 1.0. A value of 2.0 means the game moves twice as fast as real life, whilst a value of 0.5 means the game moves at half the regular speed. </description> </method> <method name="get_version_info" qualifiers="const"> @@ -67,12 +71,14 @@ <return type="bool"> </return> <description> + Returns [code]true[/code] if the editor is running. </description> </method> - <method name="is_in_fixed_frame" qualifiers="const"> + <method name="is_in_physics_frame" qualifiers="const"> <return type="bool"> </return> <description> + Returns [code]true[/code] if the game is inside the fixed process and physics phase of the game loop. </description> </method> <method name="set_editor_hint"> @@ -81,6 +87,7 @@ <argument index="0" name="enabled" type="bool"> </argument> <description> + Sets the running inside the editor hint if [code]enabled[/code] is [code]true[/code]. </description> </method> <method name="set_iterations_per_second"> @@ -89,7 +96,7 @@ <argument index="0" name="iterations_per_second" type="int"> </argument> <description> - Set the amount of fixed iterations per second (for fixed process and physics). + Sets the number of fixed iterations per second (for fixed process and physics). </description> </method> <method name="set_target_fps"> @@ -98,6 +105,7 @@ <argument index="0" name="target_fps" type="int"> </argument> <description> + Sets the target frames per second. </description> </method> <method name="set_time_scale"> @@ -106,6 +114,7 @@ <argument index="0" name="time_scale" type="float"> </argument> <description> + Sets the time scale. </description> </method> </methods> diff --git a/doc/classes/OS.xml b/doc/classes/OS.xml index d411d07979..f78821e158 100644 --- a/doc/classes/OS.xml +++ b/doc/classes/OS.xml @@ -26,14 +26,14 @@ <return type="bool"> </return> <description> - Return true if the host OS allows drawing. + Returns [code]true[/code] if the host OS allows drawing. </description> </method> <method name="can_use_threads" qualifiers="const"> <return type="bool"> </return> <description> - Returns if the current host platform is using multiple threads. + Returns [code]true[/code] if the current host platform is using multiple threads. </description> </method> <method name="delay_msec" qualifiers="const"> @@ -117,7 +117,7 @@ <return type="PoolStringArray"> </return> <description> - Return the commandline passed to the engine. + Returns the command line arguments passed to the engine. </description> </method> <method name="get_current_screen" qualifiers="const"> @@ -131,7 +131,7 @@ <return type="String"> </return> <description> - Return the absolute directory path of user data path([user://]). + Returns the absolute directory path of user data path([user://]). </description> </method> <method name="get_date" qualifiers="const"> @@ -166,7 +166,7 @@ <return type="int"> </return> <description> - Return the total amount of dynamic memory used (only works in debug). + Returns the total amount of dynamic memory used (only works in debug). </description> </method> <method name="get_environment" qualifiers="const"> @@ -175,14 +175,14 @@ <argument index="0" name="environment" type="String"> </argument> <description> - Return an environment variable. + Returns an environment variable. </description> </method> <method name="get_executable_path" qualifiers="const"> <return type="String"> </return> <description> - Return the path to the current engine executable. + Returns the path to the current engine executable. </description> </method> <method name="get_exit_code" qualifiers="const"> @@ -203,7 +203,7 @@ <return type="String"> </return> <description> - Return the host OS locale. + Returns the host OS locale. </description> </method> <method name="get_model_name" qualifiers="const"> @@ -217,25 +217,28 @@ <return type="String"> </return> <description> - Return the name of the host OS. Possible values are: "Android", "Haiku", "iOS", "HTML5", "OSX", "Server", "Windows", "UWP", "X11". + Returns the name of the host OS. Possible values are: "Android", "Haiku", "iOS", "HTML5", "OSX", "Server", "Windows", "UWP", "X11". </description> </method> <method name="get_power_percent_left"> <return type="int"> </return> <description> + Returns the amount of battery left in the device as a percentage. </description> </method> <method name="get_power_seconds_left"> <return type="int"> </return> <description> + Returns the time in seconds before the device runs out of battery. </description> </method> <method name="get_power_state"> <return type="int" enum="OS.PowerState"> </return> <description> + Returns the current state of the device regarding battery and power. See [code]POWERSTATE_*[/code] constants. </description> </method> <method name="get_process_id" qualifiers="const"> @@ -265,7 +268,7 @@ <return type="int"> </return> <description> - Returns the number of displays attached to the host machine + Returns the number of displays attached to the host machine. </description> </method> <method name="get_screen_dpi" qualifiers="const"> @@ -298,6 +301,7 @@ <argument index="0" name="screen" type="int" default="-1"> </argument> <description> + Returns the position of the specified screen by index. If no screen index is provided, the current screen will be used. </description> </method> <method name="get_screen_size" qualifiers="const"> @@ -319,7 +323,7 @@ <return type="int"> </return> <description> - Return the max amount of static memory used (only works in debug). + Returns the max amount of static memory used (only works in debug). </description> </method> <method name="get_static_memory_usage" qualifiers="const"> @@ -335,6 +339,7 @@ <argument index="0" name="dir" type="int" enum="OS.SystemDir"> </argument> <description> + Returns the actual path to commonly used folders across different platforms. Available locations are specified in [OS.SystemDir]. </description> </method> <method name="get_system_time_secs" qualifiers="const"> @@ -348,7 +353,7 @@ <return type="int"> </return> <description> - Return the amount of time passed in milliseconds since the engine started. + Returns the amount of time passed in milliseconds since the engine started. </description> </method> <method name="get_time" qualifiers="const"> @@ -357,19 +362,21 @@ <argument index="0" name="utc" type="bool" default="false"> </argument> <description> - Returns current time as a dictionary of keys: hour, minute, second + Returns current time as a dictionary of keys: hour, minute, second. </description> </method> <method name="get_time_zone_info" qualifiers="const"> <return type="Dictionary"> </return> <description> + Returns the current time zone as a dictionary with the keys: bias and name. </description> </method> <method name="get_unique_id" qualifiers="const"> <return type="String"> </return> <description> + Returns a unique string. </description> </method> <method name="get_unix_time" qualifiers="const"> @@ -410,20 +417,21 @@ <argument index="0" name="environment" type="String"> </argument> <description> - Return true if an environment variable exists. + Returns [code]true[/code] if an environment variable exists. </description> </method> <method name="has_touchscreen_ui_hint" qualifiers="const"> <return type="bool"> </return> <description> + Returns [code]true[/code] if the device has a touchscreen or emulates one. </description> </method> <method name="has_virtual_keyboard" qualifiers="const"> <return type="bool"> </return> <description> - Returns true if the platform has a virtual keyboard, false otherwise. + Returns [code]true[/code] if the platform has a virtual keyboard, [code]false[/code] otherwise. </description> </method> <method name="hide_virtual_keyboard"> @@ -446,20 +454,21 @@ <return type="bool"> </return> <description> - Return true if low cpu usage mode is enabled. + Returns [code]true[/code] if low cpu usage mode is enabled. </description> </method> <method name="is_keep_screen_on" qualifiers="const"> <return type="bool"> </return> <description> - Returns whether the screen is being kept on or not. + Returns [code]true[/code] if the screen is being kept on. </description> </method> <method name="is_ok_left_and_cancel_right" qualifiers="const"> <return type="bool"> </return> <description> + Returns [code]true[/code] if the "Okay" button should appear on the left and "Cancel" on the right. </description> </method> <method name="is_scancode_unicode" qualifiers="const"> @@ -468,13 +477,14 @@ <argument index="0" name="code" type="int"> </argument> <description> + Returns [code]true[/code] if the input code has a unicode character. </description> </method> <method name="is_stdout_verbose" qualifiers="const"> <return type="bool"> </return> <description> - Return true if the engine was executed with -v (verbose stdout). + Returns [code]true[/code] if the engine was executed with -v (verbose stdout). </description> </method> <method name="is_userfs_persistent" qualifiers="const"> @@ -495,28 +505,28 @@ <return type="bool"> </return> <description> - Returns whether the window is in fullscreen mode or not. + Returns [code]true[/code] if the window is in fullscreen mode. </description> </method> <method name="is_window_maximized" qualifiers="const"> <return type="bool"> </return> <description> - Return true if the window is maximized. + Returns [code]true[/code] if the window is maximized. </description> </method> <method name="is_window_minimized" qualifiers="const"> <return type="bool"> </return> <description> - Return true if the window is minimized. + Returns [code]true[/code] if the window is minimized. </description> </method> <method name="is_window_resizable" qualifiers="const"> <return type="bool"> </return> <description> - Returns whether the window is resizable or not. + Returns [code]true[/code] if the window is resizable. </description> </method> <method name="kill"> @@ -532,12 +542,14 @@ <return type="bool"> </return> <description> + Returns [code]true[/code] if native video is playing. </description> </method> <method name="native_video_pause"> <return type="void"> </return> <description> + Pauses native video playback. </description> </method> <method name="native_video_play"> @@ -552,18 +564,21 @@ <argument index="3" name="subtitle_track" type="String"> </argument> <description> + Plays native video from the specified path, at the given volume and with audio and subtitle tracks. </description> </method> <method name="native_video_stop"> <return type="void"> </return> <description> + Stops native video playback. </description> </method> <method name="native_video_unpause"> <return type="void"> </return> <description> + Resumes native video playback. </description> </method> <method name="print_all_resources"> @@ -572,12 +587,14 @@ <argument index="0" name="tofile" type="String" default=""""> </argument> <description> + Shows all resources in the game. Optionally the list can be written to a file. </description> </method> <method name="print_all_textures_by_size"> <return type="void"> </return> <description> + Shows the list of loaded textures sorted by size in memory. </description> </method> <method name="print_resources_by_type"> @@ -586,6 +603,7 @@ <argument index="0" name="types" type="PoolStringArray"> </argument> <description> + Shows the number of resources loaded by the game of the given types. </description> </method> <method name="print_resources_in_use"> @@ -594,6 +612,7 @@ <argument index="0" name="short" type="bool" default="false"> </argument> <description> + Shows all resources currently used by the game. </description> </method> <method name="request_attention"> @@ -609,6 +628,7 @@ <argument index="0" name="borderless" type="bool"> </argument> <description> + Removes the window frame. </description> </method> <method name="set_clipboard"> @@ -617,7 +637,7 @@ <argument index="0" name="clipboard" type="String"> </argument> <description> - Set clipboard to the OS. + Sets clipboard to the OS. </description> </method> <method name="set_current_screen"> @@ -626,6 +646,7 @@ <argument index="0" name="screen" type="int"> </argument> <description> + Sets the current screen by index. </description> </method> <method name="set_exit_code"> @@ -634,6 +655,7 @@ <argument index="0" name="code" type="int"> </argument> <description> + Sets the exit code that will be returned by the game. </description> </method> <method name="set_icon"> @@ -642,6 +664,7 @@ <argument index="0" name="icon" type="Image"> </argument> <description> + Sets the game's icon. </description> </method> <method name="set_ime_position"> @@ -658,7 +681,7 @@ <argument index="0" name="enabled" type="bool"> </argument> <description> - Set keep screen on if true, or goes to sleep by device setting if false. (for Android/iOS) + Sets keep screen on if true, or goes to sleep by device setting if false. (for Android/iOS) </description> </method> <method name="set_low_processor_usage_mode"> @@ -667,7 +690,7 @@ <argument index="0" name="enable" type="bool"> </argument> <description> - Set to true to enable the low cpu usage mode. In this mode, the screen only redraws when there are changes, and a considerable sleep time is inserted between frames. This way, editors using the engine UI only use very little cpu. + Set to [code]true[/code] to enable the low cpu usage mode. In this mode, the screen only redraws when there are changes, and a considerable sleep time is inserted between frames. Use this in tool mode to reduce CPU usage. </description> </method> <method name="set_screen_orientation"> @@ -685,6 +708,7 @@ <argument index="0" name="name" type="String"> </argument> <description> + Sets the name of the current thread. </description> </method> <method name="set_use_file_access_save_and_swap"> @@ -693,6 +717,7 @@ <argument index="0" name="enabled" type="bool"> </argument> <description> + Enables backup saves if [code]enabled[/code] is [code]true[/code]. </description> </method> <method name="set_use_vsync"> @@ -719,7 +744,7 @@ <argument index="0" name="enabled" type="bool"> </argument> <description> - Set the window size to maximized. + Set [code]true[/code] to maximize the window. </description> </method> <method name="set_window_minimized"> @@ -728,7 +753,7 @@ <argument index="0" name="enabled" type="bool"> </argument> <description> - Set whether the window is minimized. + Set [code]true[/code] to minimize the window. </description> </method> <method name="set_window_position"> @@ -746,7 +771,7 @@ <argument index="0" name="enabled" type="bool"> </argument> <description> - Set the window resizable state, if the window is not resizable it will preserve the dimensions specified in the project settings. + Sets the window resizable state, if the window is not resizable it will preserve the dimensions specified in the project settings. </description> </method> <method name="set_window_size"> @@ -773,6 +798,9 @@ <argument index="0" name="uri" type="String"> </argument> <description> + Requests the OS to open a resource with the most appropriate program. For example. + [code]OS.shell_open("C:\\Users\name\Downloads")[/code] on Windows opens the file explorer at the downloads folders of the user. + [code]OS.shell_open("http://godotengine.org")[/code] opens the default web browser on the official Godot website. </description> </method> <method name="show_virtual_keyboard"> diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp index eaf0b06664..6117c91a6a 100644 --- a/drivers/gles3/rasterizer_scene_gles3.cpp +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -379,6 +379,7 @@ bool RasterizerSceneGLES3::shadow_atlas_update_light(RID p_atlas, RID p_light_in sh->owner = p_light_intance; sh->alloc_tick = tick; sh->version = p_light_version; + li->shadow_atlases.insert(p_atlas); //make new key key = new_quadrant << ShadowAtlas::QUADRANT_SHIFT; @@ -414,6 +415,7 @@ bool RasterizerSceneGLES3::shadow_atlas_update_light(RID p_atlas, RID p_light_in sh->owner = p_light_intance; sh->alloc_tick = tick; sh->version = p_light_version; + li->shadow_atlases.insert(p_atlas); //make new key uint32_t key = new_quadrant << ShadowAtlas::QUADRANT_SHIFT; @@ -2140,7 +2142,6 @@ void RasterizerSceneGLES3::_render_list(RenderList::Element **p_elements, int p_ first = false; } - glFrontFace(GL_CW); glBindVertexArray(0); state.scene_shader.set_conditional(SceneShaderGLES3::USE_INSTANCING, false); @@ -2349,22 +2350,7 @@ void RasterizerSceneGLES3::_draw_sky(RasterizerStorageGLES3::Sky *p_sky, const C glDepthFunc(GL_LEQUAL); glColorMask(1, 1, 1, 1); - float flip_sign = p_vflip ? -1 : 1; - - Vector3 vertices[8] = { - Vector3(-1, -1 * flip_sign, 1), - Vector3(0, 1, 0), - Vector3(1, -1 * flip_sign, 1), - Vector3(1, 1, 0), - Vector3(1, 1 * flip_sign, 1), - Vector3(1, 0, 0), - Vector3(-1, 1 * flip_sign, 1), - Vector3(0, 0, 0) - - }; - - //sky uv vectors - float vw, vh, zn; + // Camera CameraMatrix camera; if (p_custom_fov) { @@ -2379,17 +2365,39 @@ void RasterizerSceneGLES3::_draw_sky(RasterizerStorageGLES3::Sky *p_sky, const C camera = p_projection; } - camera.get_viewport_size(vw, vh); - zn = p_projection.get_z_near(); + float flip_sign = p_vflip ? -1 : 1; - for (int i = 0; i < 4; i++) { + /* + If matrix[2][0] or matrix[2][1] we're dealing with an asymmetrical projection matrix. This is the case for stereoscopic rendering (i.e. VR). + To ensure the image rendered is perspective correct we need to move some logic into the shader. For this the USE_ASYM_PANO option is introduced. + It also means the uv coordinates are ignored in this mode and we don't need our loop. + */ + bool asymmetrical = ((camera.matrix[2][0] != 0.0) || (camera.matrix[2][1] != 0.0)); - Vector3 uv = vertices[i * 2 + 1]; - uv.x = (uv.x * 2.0 - 1.0) * vw; - uv.y = -(uv.y * 2.0 - 1.0) * vh; - uv.z = -zn; - vertices[i * 2 + 1] = p_transform.basis.xform(uv).normalized(); - vertices[i * 2 + 1].z = -vertices[i * 2 + 1].z; + Vector3 vertices[8] = { + Vector3(-1, -1 * flip_sign, 1), + Vector3(0, 1, 0), + Vector3(1, -1 * flip_sign, 1), + Vector3(1, 1, 0), + Vector3(1, 1 * flip_sign, 1), + Vector3(1, 0, 0), + Vector3(-1, 1 * flip_sign, 1), + Vector3(0, 0, 0) + }; + + if (!asymmetrical) { + float vw, vh, zn; + camera.get_viewport_size(vw, vh); + zn = p_projection.get_z_near(); + + for (int i = 0; i < 4; i++) { + Vector3 uv = vertices[i * 2 + 1]; + uv.x = (uv.x * 2.0 - 1.0) * vw; + uv.y = -(uv.y * 2.0 - 1.0) * vh; + uv.z = -zn; + vertices[i * 2 + 1] = p_transform.basis.xform(uv).normalized(); + vertices[i * 2 + 1].z = -vertices[i * 2 + 1].z; + } } glBindBuffer(GL_ARRAY_BUFFER, state.sky_verts); @@ -2398,16 +2406,24 @@ void RasterizerSceneGLES3::_draw_sky(RasterizerStorageGLES3::Sky *p_sky, const C glBindVertexArray(state.sky_array); - storage->shaders.copy.set_conditional(CopyShaderGLES3::USE_PANORAMA, true); + storage->shaders.copy.set_conditional(CopyShaderGLES3::USE_ASYM_PANO, asymmetrical); + storage->shaders.copy.set_conditional(CopyShaderGLES3::USE_PANORAMA, !asymmetrical); storage->shaders.copy.set_conditional(CopyShaderGLES3::USE_MULTIPLIER, true); storage->shaders.copy.bind(); storage->shaders.copy.set_uniform(CopyShaderGLES3::MULTIPLIER, p_energy); + if (asymmetrical) { + // pack the bits we need from our projection matrix + storage->shaders.copy.set_uniform(CopyShaderGLES3::ASYM_PROJ, camera.matrix[2][0], camera.matrix[0][0], camera.matrix[2][1], camera.matrix[1][1]); + ///@TODO I couldn't get mat3 + p_transform.basis to work, that would be better here. + storage->shaders.copy.set_uniform(CopyShaderGLES3::PANO_TRANSFORM, p_transform); + } glDrawArrays(GL_TRIANGLE_FAN, 0, 4); glBindVertexArray(0); glColorMask(1, 1, 1, 1); + storage->shaders.copy.set_conditional(CopyShaderGLES3::USE_ASYM_PANO, false); storage->shaders.copy.set_conditional(CopyShaderGLES3::USE_MULTIPLIER, false); storage->shaders.copy.set_conditional(CopyShaderGLES3::USE_PANORAMA, false); } @@ -5024,6 +5040,8 @@ void RasterizerSceneGLES3::initialize() { } state.debug_draw = VS::VIEWPORT_DEBUG_DRAW_DISABLED; + + glFrontFace(GL_CW); } void RasterizerSceneGLES3::iteration() { diff --git a/drivers/gles3/shaders/copy.glsl b/drivers/gles3/shaders/copy.glsl index d33193ee50..743fe122d1 100644 --- a/drivers/gles3/shaders/copy.glsl +++ b/drivers/gles3/shaders/copy.glsl @@ -27,6 +27,8 @@ void main() { #if defined(USE_CUBEMAP) || defined(USE_PANORAMA) cube_interp = cube_in; +#elif defined(USE_ASYM_PANO) + uv_interp = vertex_attrib.xy; #else uv_interp = uv_in; #ifdef V_FLIP @@ -59,6 +61,11 @@ in vec3 cube_interp; in vec2 uv_interp; #endif +#ifdef USE_ASYM_PANO +uniform highp mat4 pano_transform; +uniform highp vec4 asym_proj; +#endif + #ifdef USE_CUBEMAP uniform samplerCube source_cube; //texunit:0 #else @@ -70,7 +77,7 @@ uniform sampler2D source; //texunit:0 uniform float multiplier; #endif -#ifdef USE_PANORAMA +#if defined(USE_PANORAMA) || defined(USE_ASYM_PANO) vec4 texturePanorama(vec3 normal,sampler2D pano ) { @@ -122,6 +129,21 @@ void main() { vec4 color = texturePanorama( normalize(cube_interp), source ); +#elif defined(USE_ASYM_PANO) + + // When an assymetrical projection matrix is used (applicable for stereoscopic rendering i.e. VR) we need to do this calculation per fragment to get a perspective correct result. + // Note that we're ignoring the x-offset for IPD, with Z sufficiently in the distance it becomes neglectible, as a result we could probably just set cube_normal.z to -1. + // The Matrix[2][0] (= asym_proj.x) and Matrix[2][1] (= asym_proj.z) values are what provide the right shift in the image. + + vec3 cube_normal; + cube_normal.z = -1000000.0; + cube_normal.x = (cube_normal.z * (-uv_interp.x - asym_proj.x)) / asym_proj.y; + cube_normal.y = (cube_normal.z * (-uv_interp.y - asym_proj.z)) / asym_proj.a; + cube_normal = mat3(pano_transform) * cube_normal; + cube_normal.z = -cube_normal.z; + + vec4 color = texturePanorama( normalize(cube_normal.xyz), source ); + #elif defined(USE_CUBEMAP) vec4 color = texture( source_cube, normalize(cube_interp) ); diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl index 341a5bf2c7..b322a4c957 100644 --- a/drivers/gles3/shaders/scene.glsl +++ b/drivers/gles3/shaders/scene.glsl @@ -865,11 +865,57 @@ float contact_shadow_compute(vec3 pos, vec3 dir, float max_distance) { #endif -// GGX Specular -// Source: http://www.filmicworlds.com/images/ggx-opt/optimized-ggx.hlsl -float G1V(float dotNV, float k) -{ - return 1.0 / (dotNV * (1.0 - k) + k); + +// This returns the G_GGX function divided by 2 cos_theta_m, where in practice cos_theta_m is either N.L or N.V. +// We're dividing this factor off because the overall term we'll end up looks like +// (see, for example, the first unnumbered equation in B. Burley, "Physically Based Shading at Disney", SIGGRAPH 2012): +// +// F(L.V) D(N.H) G(N.L) G(N.V) / (4 N.L N.V) +// +// We're basically regouping this as +// +// F(L.V) D(N.H) [G(N.L)/(2 N.L)] [G(N.V) / (2 N.V)] +// +// and thus, this function implements the [G(N.m)/(2 N.m)] part with m = L or V. +// +// The contents of the D and G (G1) functions (GGX) are taken from +// E. Heitz, "Understanding the Masking-Shadowing Function in Microfacet-Based BRDFs", J. Comp. Graph. Tech. 3 (2) (2014). +// Eqns 71-72 and 85-86 (see also Eqns 43 and 80). + +float G_GGX_2cos(float cos_theta_m, float alpha) { + // Schlick's approximation + // C. Schlick, "An Inexpensive BRDF Model for Physically-based Rendering", Computer Graphics Forum. 13 (3): 233 (1994) + // Eq. (19), although see Heitz (2014) the about the problems with his derivation. + // It nevertheless approximates GGX well with k = alpha/2. + float k = 0.5*alpha; + return 0.5 / (cos_theta_m * (1.0 - k) + k); + + // float cos2 = cos_theta_m*cos_theta_m; + // float sin2 = (1.0-cos2); + // return 1.0 /( cos_theta_m + sqrt(cos2 + alpha*alpha*sin2) ); +} + +float D_GXX(float cos_theta_m, float alpha) { + float alpha2 = alpha*alpha; + float d = 1.0 + (alpha2-1.0)*cos_theta_m*cos_theta_m; + return alpha2/(M_PI * d * d); +} + +float G_GGX_anisotropic_2cos(float cos_theta_m, float alpha_x, float alpha_y, float cos_phi, float sin_phi) { + float cos2 = cos_theta_m * cos_theta_m; + float sin2 = (1.0-cos2); + float s_x = alpha_x * cos_phi; + float s_y = alpha_y * sin_phi; + return 1.0 / (cos_theta_m + sqrt(cos2 + (s_x*s_x + s_y*s_y)*sin2 )); +} + +float D_GXX_anisotropic(float cos_theta_m, float alpha_x, float alpha_y, float cos_phi, float sin_phi) { + float cos2 = cos_theta_m * cos_theta_m; + float sin2 = (1.0-cos2); + float r_x = cos_phi/alpha_x; + float r_y = sin_phi/alpha_y; + float d = cos2 + sin2*(r_x * r_x + r_y * r_y); + return 1.0 / (M_PI * alpha_x * alpha_y * d * d ); } @@ -1019,7 +1065,6 @@ LIGHT_SHADER_CODE #elif defined(SPECULAR_SCHLICK_GGX) // shlick+ggx as default - float alpha = roughness * roughness; vec3 H = normalize(V + L); @@ -1035,26 +1080,22 @@ LIGHT_SHADER_CODE float ay = ry*ry; float XdotH = dot( T, H ); float YdotH = dot( B, H ); - float denom = XdotH*XdotH / (ax*ax) + YdotH*YdotH / (ay*ay) + cNdotH*cNdotH; - float D = 1.0 / ( M_PI * ax*ay * denom*denom ); + float D = D_GXX_anisotropic(cNdotH, ax, ay, XdotH, YdotH); + float G = G_GGX_anisotropic_2cos(cNdotL, ax, ay, XdotH, YdotH) * G_GGX_anisotropic_2cos(cNdotV, ax, ay, XdotH, YdotH); #else - float alphaSqr = alpha * alpha; - float denom = cNdotH * cNdotH * (alphaSqr - 1.0) + 1.0; - float D = alphaSqr / (M_PI * denom * denom); + float alpha = roughness * roughness; + float D = D_GGX(cNdotH, alpha); + float G = G_GGX_2cos(cNdotL, alpha) * G_GGX_2cos(cNdotV, alpha); #endif // F float F0 = 1.0; // FIXME float cLdotH5 = SchlickFresnel(cLdotH); float F = mix(cLdotH5, 1.0, F0); - // V - float k = alpha / 2.0f; - float vis = G1V(cNdotL, k) * G1V(cNdotV, k); - - float speci = cNdotL * D * F * vis; + float specular_brdf_NL = cNdotL * D * F * G; - specular_light += speci * light_color * specular_blob_intensity * attenuation; + specular_light += specular_brdf_NL * light_color * specular_blob_intensity * attenuation; #endif #if defined(LIGHT_USE_CLEARCOAT) @@ -1069,7 +1110,7 @@ LIGHT_SHADER_CODE #endif float Dr = GTR1(cNdotH, mix(.1, .001, clearcoat_gloss)); float Fr = mix(.04, 1.0, cLdotH5); - float Gr = G1V(cNdotL, .25) * G1V(cNdotV, .25); + float Gr = G_GGX_2cos(cNdotL, .25) * G_GGX_2cos(cNdotV, .25); specular_light += .25*clearcoat*Gr*Fr*Dr; diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index ff415c83f1..1ca88133b8 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -373,6 +373,9 @@ void EditorNode::_fs_changed() { String err = "Preset \"" + export_defer.preset + "\" doesn't have a platform."; ERR_PRINT(err.utf8().get_data()); } else { + // ensures export_project does not loop infinitely, because notifications may + // come during the export + export_defer.preset = ""; platform->export_project(preset, export_defer.debug, export_defer.path, /*p_flags*/ 0); } } diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp index b4460c5619..a528662e0f 100644 --- a/editor/editor_plugin.cpp +++ b/editor/editor_plugin.cpp @@ -258,7 +258,7 @@ void EditorInterface::_bind_methods() { ClassDB::bind_method(D_METHOD("get_resource_previewer"), &EditorInterface::get_resource_previewer); ClassDB::bind_method(D_METHOD("get_resource_filesystem"), &EditorInterface::get_resource_file_system); ClassDB::bind_method(D_METHOD("get_editor_viewport"), &EditorInterface::get_editor_viewport); - ClassDB::bind_method(D_METHOD("make_mesh_previews"), &EditorInterface::_make_mesh_previews); + ClassDB::bind_method(D_METHOD("make_mesh_previews", "meshes", "preview_size"), &EditorInterface::_make_mesh_previews); ClassDB::bind_method(D_METHOD("save_scene"), &EditorInterface::save_scene); ClassDB::bind_method(D_METHOD("save_scene_as", "path", "with_preview"), &EditorInterface::save_scene_as, DEFVAL(true)); diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 477d440f28..d56756502d 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -467,6 +467,8 @@ void ScriptEditor::_update_recent_scripts() { recent_scripts->add_separator(); recent_scripts->add_shortcut(ED_SHORTCUT("script_editor/clear_recent", TTR("Clear Recent Files"))); + + recent_scripts->set_as_minsize(); } void ScriptEditor::_open_recent_script(int p_idx) { @@ -474,7 +476,7 @@ void ScriptEditor::_open_recent_script(int p_idx) { // clear button if (p_idx == recent_scripts->get_item_count() - 1) { previous_scripts.clear(); - _update_recent_scripts(); + call_deferred("_update_recent_scripts"); return; } @@ -2240,6 +2242,7 @@ void ScriptEditor::_bind_methods() { ClassDB::bind_method("_live_auto_reload_running_scripts", &ScriptEditor::_live_auto_reload_running_scripts); ClassDB::bind_method("_unhandled_input", &ScriptEditor::_unhandled_input); ClassDB::bind_method("_script_changed", &ScriptEditor::_script_changed); + ClassDB::bind_method("_update_recent_scripts", &ScriptEditor::_update_recent_scripts); ClassDB::bind_method(D_METHOD("get_current_script"), &ScriptEditor::_get_current_script); ClassDB::bind_method(D_METHOD("get_open_scripts"), &ScriptEditor::_get_open_scripts); diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 9f23df5c03..d1210ee26a 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -750,6 +750,9 @@ void ProjectManager::_unhandled_input(const Ref<InputEvent> &p_ev) { if (!k->is_pressed()) return; + if (tabs->get_current_tab() != 0) + return; + bool scancode_handled = true; switch (k->get_scancode()) { diff --git a/main/main.cpp b/main/main.cpp index 60a5f98a5d..6fbd906679 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -258,6 +258,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph translation_server = memnew(TranslationServer); performance = memnew(Performance); + ClassDB::register_class<Performance>(); globals->add_singleton(ProjectSettings::Singleton("Performance", performance)); GLOBAL_DEF("debug/settings/crash_handler/message", String("Please include this when reporting the bug on https://github.com/godotengine/godot/issues")); diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index fe78ce423c..b475782729 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -654,6 +654,13 @@ void *CSharpLanguage::alloc_instance_binding_data(Object *p_object) { StringName type_name = p_object->get_class_name(); + // ¯\_(ツ)_/¯ + const ClassDB::ClassInfo *classinfo = ClassDB::classes.getptr(type_name); + while (classinfo && !classinfo->exposed) + classinfo = classinfo->inherits_ptr; + ERR_FAIL_NULL_V(classinfo, NULL); + type_name = classinfo->name; + GDMonoClass *type_class = GDMonoUtils::type_get_proxy_class(type_name); ERR_FAIL_NULL_V(type_class, NULL); diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp index 123f00ea10..704910c5b9 100644 --- a/modules/mono/editor/bindings_generator.cpp +++ b/modules/mono/editor/bindings_generator.cpp @@ -133,12 +133,6 @@ static bool is_csharp_keyword(const String &p_name) { p_name == "virtual" || p_name == "volatile" || p_name == "void" || p_name == "while"; } -static bool is_singleton_black_listed(const String &p_type) { - - return p_type == "IP_Unix" || p_type == "InputDefault" || p_type == "AudioServerSW" || p_type == "PhysicsServerSW" || - p_type == "Physics2DServerSW" || p_type == "SpatialSoundServerSW" || p_type == "SpatialSound2DServerSW"; -} - inline static String escape_csharp_keyword(const String &p_name) { return is_csharp_keyword(p_name) ? "@" + p_name : p_name; @@ -247,9 +241,6 @@ void BindingsGenerator::_generate_header_icalls() { void BindingsGenerator::_generate_method_icalls(const TypeInterface &p_itype) { - if (p_itype.base_name.length() && obj_types[p_itype.base_name].is_singleton && is_singleton_black_listed(p_itype.name)) - return; - for (const List<MethodInterface>::Element *E = p_itype.methods.front(); E; E = E->next()) { const MethodInterface &imethod = E->get(); @@ -580,9 +571,6 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str bool is_derived_type = itype.base_name.length(); - if (is_derived_type && obj_types[itype.base_name].is_singleton && is_singleton_black_listed(itype.name)) - return ERR_SKIP; - List<InternalCall> &custom_icalls = itype.api_type == ClassDB::API_EDITOR ? editor_custom_icalls : core_custom_icalls; if (verbose_output) @@ -1167,9 +1155,6 @@ Error BindingsGenerator::generate_glue(const String &p_output_dir) { for (Map<String, TypeInterface>::Element *type_elem = obj_types.front(); type_elem; type_elem = type_elem->next()) { const TypeInterface &itype = type_elem->get(); - if (itype.base_name.length() && obj_types[itype.base_name].is_singleton && is_singleton_black_listed(itype.name)) - continue; - List<InternalCall> &custom_icalls = itype.api_type == ClassDB::API_EDITOR ? editor_custom_icalls : core_custom_icalls; OS::get_singleton()->print(String("Generating " + itype.name + "...\n").utf8()); @@ -1519,6 +1504,12 @@ void BindingsGenerator::_populate_object_type_interfaces() { itype.is_reference = ClassDB::is_parent_class(type_cname, refclass_name); itype.memory_own = itype.is_reference; + if (!ClassDB::is_class_exposed(type_cname)) { + WARN_PRINTS("Ignoring type " + String(type_cname) + " because it's not exposed"); + class_list.pop_front(); + continue; + } + itype.c_out = "\treturn "; itype.c_out += C_METHOD_UNMANAGED_GET_MANAGED; itype.c_out += itype.is_reference ? "(%1.ptr());\n" : "(%1);\n"; diff --git a/modules/mono/mono_gd/gd_mono_marshal.cpp b/modules/mono/mono_gd/gd_mono_marshal.cpp index 7103dcee41..9a6c8f0cd6 100644 --- a/modules/mono/mono_gd/gd_mono_marshal.cpp +++ b/modules/mono/mono_gd/gd_mono_marshal.cpp @@ -705,9 +705,9 @@ MonoArray *PoolColorArray_to_mono_array(const PoolColorArray &p_array) { real_t *raw = (real_t *)mono_array_addr_with_size(ret, sizeof(real_t) * 4, i); const Color &elem = p_array[i]; raw[0] = elem.r; - raw[4] = elem.g; - raw[8] = elem.b; - raw[12] = elem.a; + raw[1] = elem.g; + raw[2] = elem.b; + raw[3] = elem.a; #endif } @@ -737,7 +737,7 @@ MonoArray *PoolVector2Array_to_mono_array(const PoolVector2Array &p_array) { real_t *raw = (real_t *)mono_array_addr_with_size(ret, sizeof(real_t) * 2, i); const Vector2 &elem = p_array[i]; raw[0] = elem.x; - raw[4] = elem.y; + raw[1] = elem.y; #endif } @@ -767,8 +767,8 @@ MonoArray *PoolVector3Array_to_mono_array(const PoolVector3Array &p_array) { real_t *raw = (real_t *)mono_array_addr_with_size(ret, sizeof(real_t) * 3, i); const Vector3 &elem = p_array[i]; raw[0] = elem.x; - raw[4] = elem.y; - raw[8] = elem.z; + raw[1] = elem.y; + raw[2] = elem.z; #endif } diff --git a/modules/mono/register_types.cpp b/modules/mono/register_types.cpp index 2a84f0d1a6..2656de5b14 100644 --- a/modules/mono/register_types.cpp +++ b/modules/mono/register_types.cpp @@ -44,6 +44,7 @@ void register_mono_types() { _godotsharp = memnew(_GodotSharp); + ClassDB::register_class<_GodotSharp>(); ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("GodotSharp", _GodotSharp::get_singleton())); script_language_cs = memnew(CSharpLanguage); diff --git a/platform/android/java/src/org/godotengine/godot/input/GodotTextInputWrapper.java b/platform/android/java/src/org/godotengine/godot/input/GodotTextInputWrapper.java index 04669a3b0c..ac424ab9f8 100644 --- a/platform/android/java/src/org/godotengine/godot/input/GodotTextInputWrapper.java +++ b/platform/android/java/src/org/godotengine/godot/input/GodotTextInputWrapper.java @@ -88,79 +88,48 @@ public class GodotTextInputWrapper implements TextWatcher, OnEditorActionListene public void beforeTextChanged(final CharSequence pCharSequence, final int start, final int count, final int after) { //Log.d(TAG, "beforeTextChanged(" + pCharSequence + ")start: " + start + ",count: " + count + ",after: " + after); - for (int i=0;i<count;i++){ - mView.queueEvent(new Runnable() { - @Override - public void run() { + mView.queueEvent(new Runnable() { + @Override + public void run() { + for (int i = 0; i < count; ++i) { GodotLib.key(KeyEvent.KEYCODE_DEL, 0, true); GodotLib.key(KeyEvent.KEYCODE_DEL, 0, false); } - }); - } + } + }); } @Override public void onTextChanged(final CharSequence pCharSequence, final int start, final int before, final int count) { //Log.d(TAG, "onTextChanged(" + pCharSequence + ")start: " + start + ",count: " + count + ",before: " + before); - for (int i=start;i<start+count;i++){ - final int ch = pCharSequence.charAt(i); - mView.queueEvent(new Runnable() { - @Override - public void run() { + mView.queueEvent(new Runnable() { + @Override + public void run() { + for (int i = start; i < start + count; ++i) { + final int ch = pCharSequence.charAt(i); GodotLib.key(0, ch, true); GodotLib.key(0, ch, false); } - }); - } - + } + }); } @Override public boolean onEditorAction(final TextView pTextView, final int pActionID, final KeyEvent pKeyEvent) { if (this.mEdit == pTextView && this.isFullScreenEdit()) { - // user press the action button, delete all old text and insert new text - for (int i = this.mOriginText.length(); i > 0; i--) { - mView.queueEvent(new Runnable() { - @Override - public void run() { - GodotLib.key(KeyEvent.KEYCODE_DEL, 0, true); - GodotLib.key(KeyEvent.KEYCODE_DEL, 0, false); - } - }); + final String characters = pKeyEvent.getCharacters(); - /* - if (BuildConfig.DEBUG) { - Log.d(TAG, "deleteBackward"); - } - */ - } - String text = pTextView.getText().toString(); - - /* If user input nothing, translate "\n" to engine. */ - if (text.compareTo("") == 0) { - text = "\n"; - } - - if ('\n' != text.charAt(text.length() - 1)) { - text += '\n'; - } - - for(int i = 0; i < text.length(); i++) { - final int ch = text.codePointAt(i); - mView.queueEvent(new Runnable() { - @Override - public void run() { + mView.queueEvent(new Runnable() { + @Override + public void run() { + for (int i = 0; i < characters.length(); i++) { + final int ch = characters.codePointAt(i); GodotLib.key(0, ch, true); GodotLib.key(0, ch, false); } - }); - } - /* - if (BuildConfig.DEBUG) { - Log.d(TAG, "insertText(" + insertText + ")"); - } - */ + } + }); } if (pActionID == EditorInfo.IME_ACTION_DONE) { diff --git a/platform/android/java_glue.cpp b/platform/android/java_glue.cpp index 6819a7e20f..0b193f5882 100644 --- a/platform/android/java_glue.cpp +++ b/platform/android/java_glue.cpp @@ -602,21 +602,10 @@ struct TST { TST tst; -struct JAndroidPointerEvent { - - Vector<OS_Android::TouchPos> points; - int pointer; - int what; -}; - -static List<JAndroidPointerEvent> pointer_events; -static List<Ref<InputEvent> > key_events; -static List<OS_Android::JoypadEvent> joy_events; static bool initialized = false; static int step = 0; static bool resized = false; static bool resized_reload = false; -static bool go_back_request = false; static Size2 new_size; static Vector3 accelerometer; static Vector3 magnetometer; @@ -624,8 +613,6 @@ static Vector3 gyroscope; static HashMap<String, JNISingleton *> jni_singletons; static jobject godot_io; -static Vector<int> joy_device_ids; - typedef void (*GFXInitFunc)(void *ud, bool gl2); static jmethodID _on_video_init = 0; @@ -998,7 +985,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_newcontext(JNIEnv *en } JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_back(JNIEnv *env, jobject obj) { - go_back_request = true; + os_android->main_loop_request_go_back(); } JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_step(JNIEnv *env, jobject obj) { @@ -1023,36 +1010,6 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_step(JNIEnv *env, job //__android_log_print(ANDROID_LOG_INFO,"godot","**STEP EVENT! - %p-%i\n",env,Thread::get_caller_id()); - while (pointer_events.size()) { - - JAndroidPointerEvent jpe = pointer_events.front()->get(); - os_android->process_touch(jpe.what, jpe.pointer, jpe.points); - - pointer_events.pop_front(); - } - - while (key_events.size()) { - - Ref<InputEvent> event = key_events.front()->get(); - os_android->process_event(event); - - key_events.pop_front(); - }; - - while (joy_events.size()) { - - OS_Android::JoypadEvent event = joy_events.front()->get(); - os_android->process_joy_event(event); - - joy_events.pop_front(); - } - - if (go_back_request) { - - os_android->main_loop_request_go_back(); - go_back_request = false; - } - os_android->process_accelerometer(accelerometer); os_android->process_magnetometer(magnetometer); @@ -1083,12 +1040,8 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_touch(JNIEnv *env, jo points.push_back(tp); } - JAndroidPointerEvent jpe; - jpe.pointer = pointer; - jpe.points = points; - jpe.what = ev; + os_android->process_touch(ev, pointer, points); - pointer_events.push_back(jpe); /* if (os_android) os_android->process_touch(ev,pointer,points); @@ -1358,7 +1311,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joybutton(JNIEnv *env jevent.index = p_button; jevent.pressed = p_pressed; - joy_events.push_back(jevent); + os_android->process_joy_event(jevent); } JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyaxis(JNIEnv *env, jobject obj, jint p_device, jint p_axis, jfloat p_value) { @@ -1369,7 +1322,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyaxis(JNIEnv *env, jevent.index = p_axis; jevent.value = p_value; - joy_events.push_back(jevent); + os_android->process_joy_event(jevent); } JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyhat(JNIEnv *env, jobject obj, jint p_device, jint p_hat_x, jint p_hat_y) { @@ -1390,7 +1343,8 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyhat(JNIEnv *env, j hat |= InputDefault::HAT_MASK_DOWN; } jevent.hat = hat; - joy_events.push_back(jevent); + + os_android->process_joy_event(jevent); } JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyconnectionchanged(JNIEnv *env, jobject obj, jint p_device, jboolean p_connected, jstring p_name) { @@ -1403,6 +1357,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyconnectionchanged( JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_key(JNIEnv *env, jobject obj, jint p_scancode, jint p_unicode_char, jboolean p_pressed) { Ref<InputEventKey> ievent; + ievent.instance(); int val = p_unicode_char; int scancode = android_get_keysym(p_scancode); ievent->set_scancode(scancode); @@ -1421,10 +1376,10 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_key(JNIEnv *env, jobj ievent->set_unicode(KEY_ENTER); } else if (p_scancode == 4) { - go_back_request = true; + os_android->main_loop_request_go_back(); } - key_events.push_back(ievent); + os_android->process_event(ievent); } JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_accelerometer(JNIEnv *env, jobject obj, jfloat x, jfloat y, jfloat z) { diff --git a/platform/javascript/javascript_eval.cpp b/platform/javascript/javascript_eval.cpp index 74f8d80a76..1d737879f6 100644 --- a/platform/javascript/javascript_eval.cpp +++ b/platform/javascript/javascript_eval.cpp @@ -39,24 +39,41 @@ JavaScript *JavaScript::get_singleton() { return singleton; } +extern "C" EMSCRIPTEN_KEEPALIVE uint8_t *resize_poolbytearray_and_open_write(PoolByteArray *p_arr, PoolByteArray::Write *r_write, int p_len) { + + p_arr->resize(p_len); + *r_write = p_arr->write(); + return r_write->ptr(); +} + Variant JavaScript::eval(const String &p_code, bool p_use_global_exec_context) { union { - int i; + bool b; double d; char *s; } js_data[4]; + + PoolByteArray arr; + PoolByteArray::Write arr_write; + /* clang-format off */ Variant::Type return_type = static_cast<Variant::Type>(EM_ASM_INT({ + const CODE = $0; + const USE_GLOBAL_EXEC_CONTEXT = $1; + const PTR = $2; + const ELEM_LEN = $3; + const BYTEARRAY_PTR = $4; + const BYTEARRAY_WRITE_PTR = $5; var eval_ret; try { - if ($3) { // p_use_global_exec_context + if (USE_GLOBAL_EXEC_CONTEXT) { // indirect eval call grants global execution context var global_eval = eval; - eval_ret = global_eval(UTF8ToString($2)); + eval_ret = global_eval(UTF8ToString(CODE)); } else { - eval_ret = eval(UTF8ToString($2)); + eval_ret = eval(UTF8ToString(CODE)); } } catch (e) { Module.printErr(e); @@ -66,16 +83,11 @@ Variant JavaScript::eval(const String &p_code, bool p_use_global_exec_context) { switch (typeof eval_ret) { case 'boolean': - // bitwise op yields 32-bit int - setValue($0, eval_ret|0, 'i32'); + setValue(PTR, eval_ret, 'i32'); return 1; // BOOL case 'number': - if ((eval_ret|0)===eval_ret) { - setValue($0, eval_ret|0, 'i32'); - return 2; // INT - } - setValue($0, eval_ret, 'double'); + setValue(PTR, eval_ret, 'double'); return 3; // REAL case 'string': @@ -85,7 +97,7 @@ Variant JavaScript::eval(const String &p_code, bool p_use_global_exec_context) { if (array_ptr===0) { throw new Error('String allocation failed (probably out of memory)'); } - setValue($0, array_ptr|0 , '*'); + setValue(PTR, array_ptr , '*'); stringToUTF8(eval_ret, array_ptr, array_len); return 4; // STRING } catch (e) { @@ -102,41 +114,50 @@ Variant JavaScript::eval(const String &p_code, bool p_use_global_exec_context) { break; } - else if (typeof eval_ret.x==='number' && typeof eval_ret.y==='number') { - setValue($0, eval_ret.x, 'double'); - setValue($0+$1, eval_ret.y, 'double'); + if (ArrayBuffer.isView(eval_ret) && !(eval_ret instanceof Uint8Array)) { + eval_ret = new Uint8Array(eval_ret.buffer); + } + else if (eval_ret instanceof ArrayBuffer) { + eval_ret = new Uint8Array(eval_ret); + } + if (eval_ret instanceof Uint8Array) { + var bytes_ptr = ccall('resize_poolbytearray_and_open_write', 'number', ['number', 'number' ,'number'], [BYTEARRAY_PTR, BYTEARRAY_WRITE_PTR, eval_ret.length]); + HEAPU8.set(eval_ret, bytes_ptr); + return 20; // POOL_BYTE_ARRAY + } + + if (typeof eval_ret.x==='number' && typeof eval_ret.y==='number') { + setValue(PTR, eval_ret.x, 'double'); + setValue(PTR + ELEM_LEN, eval_ret.y, 'double'); if (typeof eval_ret.z==='number') { - setValue($0+$1*2, eval_ret.z, 'double'); + setValue(PTR + ELEM_LEN*2, eval_ret.z, 'double'); return 7; // VECTOR3 } else if (typeof eval_ret.width==='number' && typeof eval_ret.height==='number') { - setValue($0+$1*2, eval_ret.width, 'double'); - setValue($0+$1*3, eval_ret.height, 'double'); + setValue(PTR + ELEM_LEN*2, eval_ret.width, 'double'); + setValue(PTR + ELEM_LEN*3, eval_ret.height, 'double'); return 6; // RECT2 } return 5; // VECTOR2 } - else if (typeof eval_ret.r==='number' && typeof eval_ret.g==='number' && typeof eval_ret.b==='number') { - // assume 8-bit rgb components since we're on the web - setValue($0, eval_ret.r, 'double'); - setValue($0+$1, eval_ret.g, 'double'); - setValue($0+$1*2, eval_ret.b, 'double'); - setValue($0+$1*3, typeof eval_ret.a==='number' ? eval_ret.a : 1, 'double'); + if (typeof eval_ret.r === 'number' && typeof eval_ret.g === 'number' && typeof eval_ret.b === 'number') { + setValue(PTR, eval_ret.r, 'double'); + setValue(PTR + ELEM_LEN, eval_ret.g, 'double'); + setValue(PTR + ELEM_LEN*2, eval_ret.b, 'double'); + setValue(PTR + ELEM_LEN*3, typeof eval_ret.a === 'number' ? eval_ret.a : 1, 'double'); return 14; // COLOR } break; } return 0; // NIL - }, js_data, sizeof *js_data, p_code.utf8().get_data(), p_use_global_exec_context)); + }, p_code.utf8().get_data(), p_use_global_exec_context, js_data, sizeof *js_data, &arr, &arr_write)); /* clang-format on */ switch (return_type) { case Variant::BOOL: - return !!js_data->i; - case Variant::INT: - return js_data->i; + return js_data->b; case Variant::REAL: return js_data->d; case Variant::STRING: { @@ -153,7 +174,10 @@ Variant JavaScript::eval(const String &p_code, bool p_use_global_exec_context) { case Variant::RECT2: return Rect2(js_data[0].d, js_data[1].d, js_data[2].d, js_data[3].d); case Variant::COLOR: - return Color(js_data[0].d / 255., js_data[1].d / 255., js_data[2].d / 255., js_data[3].d); + return Color(js_data[0].d, js_data[1].d, js_data[2].d, js_data[3].d); + case Variant::POOL_BYTE_ARRAY: + arr_write = PoolByteArray::Write(); + return arr; } return Variant(); } diff --git a/scene/2d/animated_sprite.cpp b/scene/2d/animated_sprite.cpp index c2edb173d7..5982556c18 100644 --- a/scene/2d/animated_sprite.cpp +++ b/scene/2d/animated_sprite.cpp @@ -298,10 +298,8 @@ void AnimatedSprite::_validate_property(PropertyInfo &property) const { property.hint = PROPERTY_HINT_SPRITE_FRAME; - if (frames->has_animation(animation)) { + if (frames->has_animation(animation) && frames->get_frame_count(animation) > 1) { property.hint_string = "0," + itos(frames->get_frame_count(animation) - 1) + ",1"; - } else { - property.hint_string = "0,0,0"; } } } diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp index a85a0fb9f7..75268aad1f 100644 --- a/scene/register_scene_types.cpp +++ b/scene/register_scene_types.cpp @@ -266,9 +266,11 @@ void register_scene_types() { ClassDB::register_class<Control>(); ClassDB::register_class<Button>(); ClassDB::register_class<Label>(); + ClassDB::register_class<ScrollBar>(); ClassDB::register_class<HScrollBar>(); ClassDB::register_class<VScrollBar>(); ClassDB::register_class<ProgressBar>(); + ClassDB::register_class<Slider>(); ClassDB::register_class<HSlider>(); ClassDB::register_class<VSlider>(); ClassDB::register_class<Popup>(); @@ -352,6 +354,7 @@ void register_scene_types() { #ifndef _3D_DISABLED ClassDB::register_class<BoneAttachment>(); ClassDB::register_virtual_class<VisualInstance>(); + ClassDB::register_virtual_class<GeometryInstance>(); ClassDB::register_class<Camera>(); ClassDB::register_class<Listener>(); ClassDB::register_class<ARVRCamera>(); @@ -361,6 +364,7 @@ void register_scene_types() { ClassDB::register_class<InterpolatedCamera>(); ClassDB::register_class<MeshInstance>(); ClassDB::register_class<ImmediateGeometry>(); + ClassDB::register_virtual_class<SpriteBase3D>(); ClassDB::register_class<Sprite3D>(); ClassDB::register_class<AnimatedSprite3D>(); ClassDB::register_virtual_class<Light>(); @@ -380,6 +384,7 @@ void register_scene_types() { OS::get_singleton()->yield(); //may take time to init ClassDB::register_virtual_class<CollisionObject>(); + ClassDB::register_virtual_class<PhysicsBody>(); ClassDB::register_class<StaticBody>(); ClassDB::register_class<RigidBody>(); ClassDB::register_class<KinematicCollision>(); @@ -494,6 +499,7 @@ void register_scene_types() { OS::get_singleton()->yield(); //may take time to init + ClassDB::register_virtual_class<Shape>(); ClassDB::register_class<RayShape>(); ClassDB::register_class<SphereShape>(); ClassDB::register_class<BoxShape>(); @@ -531,6 +537,7 @@ void register_scene_types() { ClassDB::register_class<DynamicFontData>(); ClassDB::register_class<DynamicFont>(); + ClassDB::register_virtual_class<StyleBox>(); ClassDB::register_class<StyleBoxEmpty>(); ClassDB::register_class<StyleBoxTexture>(); ClassDB::register_class<StyleBoxFlat>(); diff --git a/scene/resources/audio_stream_sample.cpp b/scene/resources/audio_stream_sample.cpp index 1fd84a860e..fdc3b79db6 100644 --- a/scene/resources/audio_stream_sample.cpp +++ b/scene/resources/audio_stream_sample.cpp @@ -486,7 +486,8 @@ PoolVector<uint8_t> AudioStreamSample::get_data() const { { PoolVector<uint8_t>::Write w = pv.write(); - copymem(w.ptr(), data, data_bytes); + uint8_t *dataptr = (uint8_t *)data; + copymem(w.ptr(), dataptr + DATA_PAD, data_bytes); } } diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp index 923639bc79..402e06f621 100644 --- a/scene/resources/default_theme/default_theme.cpp +++ b/scene/resources/default_theme/default_theme.cpp @@ -512,6 +512,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const // HSlider theme->set_stylebox("slider", "HSlider", make_stylebox(hslider_bg_png, 4, 4, 4, 4)); + theme->set_stylebox("grabber_area", "HSlider", make_stylebox(hslider_bg_png, 4, 4, 4, 4)); theme->set_stylebox("grabber_highlight", "HSlider", make_stylebox(hslider_grabber_hl_png, 6, 6, 6, 6)); theme->set_stylebox("grabber_disabled", "HSlider", make_stylebox(hslider_grabber_disabled_png, 6, 6, 6, 6)); theme->set_stylebox("focus", "HSlider", focus); @@ -524,6 +525,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const // VSlider theme->set_stylebox("slider", "VSlider", make_stylebox(vslider_bg_png, 4, 4, 4, 4)); + theme->set_stylebox("grabber_area", "VSlider", make_stylebox(vslider_bg_png, 4, 4, 4, 4)); theme->set_stylebox("grabber_highlight", "VSlider", make_stylebox(vslider_grabber_hl_png, 6, 6, 6, 6)); theme->set_stylebox("grabber_disabled", "VSlider", make_stylebox(vslider_grabber_disabled_png, 6, 6, 6, 6)); theme->set_stylebox("focus", "VSlider", focus); diff --git a/servers/arvr_server.cpp b/servers/arvr_server.cpp index aa879f8aed..4dfc40e9e4 100644 --- a/servers/arvr_server.cpp +++ b/servers/arvr_server.cpp @@ -53,10 +53,10 @@ void ARVRServer::_bind_methods() { ClassDB::bind_method(D_METHOD("get_tracker_count"), &ARVRServer::get_tracker_count); ClassDB::bind_method(D_METHOD("get_tracker", "idx"), &ARVRServer::get_tracker); - ClassDB::bind_method(D_METHOD("set_primary_interface"), &ARVRServer::set_primary_interface); + ClassDB::bind_method(D_METHOD("set_primary_interface", "interface"), &ARVRServer::set_primary_interface); - ClassDB::bind_method(D_METHOD("add_interface"), &ARVRServer::add_interface); - ClassDB::bind_method(D_METHOD("remove_interface"), &ARVRServer::remove_interface); + ClassDB::bind_method(D_METHOD("add_interface", "interface"), &ARVRServer::add_interface); + ClassDB::bind_method(D_METHOD("remove_interface", "interface"), &ARVRServer::remove_interface); BIND_ENUM_CONSTANT(TRACKER_CONTROLLER); BIND_ENUM_CONSTANT(TRACKER_BASESTATION); diff --git a/servers/register_server_types.cpp b/servers/register_server_types.cpp index 845a3443b7..1aee2144aa 100644 --- a/servers/register_server_types.cpp +++ b/servers/register_server_types.cpp @@ -79,6 +79,12 @@ ARVRServer *arvr_server = NULL; void register_server_types() { arvr_server = memnew(ARVRServer); + ClassDB::register_virtual_class<VisualServer>(); + ClassDB::register_class<AudioServer>(); + ClassDB::register_virtual_class<PhysicsServer>(); + ClassDB::register_virtual_class<Physics2DServer>(); + ClassDB::register_class<ARVRServer>(); + ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("VisualServer", VisualServer::get_singleton())); ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("AudioServer", AudioServer::get_singleton())); ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("PhysicsServer", PhysicsServer::get_singleton())); @@ -95,6 +101,8 @@ void register_server_types() { ClassDB::register_virtual_class<AudioStreamPlayback>(); ClassDB::register_class<AudioStreamRandomPitch>(); ClassDB::register_virtual_class<AudioEffect>(); + ClassDB::register_class<AudioEffectEQ>(); + ClassDB::register_class<AudioEffectFilter>(); ClassDB::register_class<AudioBusLayout>(); { diff --git a/servers/visual_server.cpp b/servers/visual_server.cpp index 47a5f4c7f3..2b34aa0e42 100644 --- a/servers/visual_server.cpp +++ b/servers/visual_server.cpp @@ -1445,6 +1445,7 @@ Array VisualServer::mesh_surface_get_blend_shape_arrays(RID p_mesh, int p_surfac void VisualServer::_bind_methods() { + ClassDB::bind_method(D_METHOD("force_sync"), &VisualServer::sync); ClassDB::bind_method(D_METHOD("force_draw"), &VisualServer::draw); ClassDB::bind_method(D_METHOD("texture_create"), &VisualServer::texture_create); ClassDB::bind_method(D_METHOD("texture_create_from_image", "image", "flags"), &VisualServer::texture_create_from_image, DEFVAL(TEXTURE_FLAGS_DEFAULT)); diff --git a/thirdparty/README.md b/thirdparty/README.md index c081ad29b6..6e1dcb8df4 100644 --- a/thirdparty/README.md +++ b/thirdparty/README.md @@ -73,7 +73,7 @@ Use UI font if exists, because it has tight vertial metrix and good for UI. ## freetype - Upstream: https://www.freetype.org -- Version: 2.8 +- Version: 2.8.1 - License: FreeType License (BSD-like) Files extracted from upstream source: diff --git a/thirdparty/freetype/include/freetype/config/ftoption.h b/thirdparty/freetype/include/freetype/config/ftoption.h index 1bf6e8f534..2fbe80b9b4 100644 --- a/thirdparty/freetype/include/freetype/config/ftoption.h +++ b/thirdparty/freetype/include/freetype/config/ftoption.h @@ -107,20 +107,17 @@ FT_BEGIN_HEADER /*************************************************************************/ /* */ - /* Uncomment the line below if you want to activate sub-pixel rendering */ - /* (a.k.a. LCD rendering, or ClearType) in this build of the library. */ + /* Uncomment the line below if you want to activate LCD rendering */ + /* technology similar to ClearType in this build of the library. This */ + /* technology triples the resolution in the direction color subpixels. */ + /* To mitigate color fringes inherent to this technology, you also need */ + /* to explicitly set up LCD filtering. */ /* */ /* Note that this feature is covered by several Microsoft patents */ /* and should not be activated in any default build of the library. */ - /* */ - /* This macro has no impact on the FreeType API, only on its */ - /* _implementation_. For example, using FT_RENDER_MODE_LCD when calling */ - /* FT_Render_Glyph still generates a bitmap that is 3 times wider than */ - /* the original size in case this macro isn't defined; however, each */ - /* triplet of subpixels has R=G=B. */ - /* */ - /* This is done to allow FreeType clients to run unmodified, forcing */ - /* them to display normal gray-level anti-aliased glyphs. */ + /* When this macro is not defined, FreeType offers alternative LCD */ + /* rendering technology that produces excellent output without LCD */ + /* filtering. */ /* */ /* #define FT_CONFIG_OPTION_SUBPIXEL_RENDERING */ @@ -327,7 +324,7 @@ FT_BEGIN_HEADER /* */ /* - The TrueType driver will provide its own set of glyph names, */ /* if you build it to support postscript names in the TrueType */ - /* `post' table. */ + /* `post' table, but will not synthesize a missing Unicode charmap. */ /* */ /* - The Type 1 driver will not be able to synthesize a Unicode */ /* charmap out of the glyphs found in the fonts. */ diff --git a/thirdparty/freetype/include/freetype/freetype.h b/thirdparty/freetype/include/freetype/freetype.h index 2989fbb5e1..b0c261799a 100644 --- a/thirdparty/freetype/include/freetype/freetype.h +++ b/thirdparty/freetype/include/freetype/freetype.h @@ -575,7 +575,8 @@ FT_BEGIN_HEADER /* <Note> */ /* When a new face is created (either through @FT_New_Face or */ /* @FT_Open_Face), the library looks for a Unicode charmap within */ - /* the list and automatically activates it. */ + /* the list and automatically activates it. If there is no Unicode */ + /* charmap, FreeType doesn't set an `active' charmap. */ /* */ /* <Also> */ /* See @FT_CharMapRec for the publicly accessible fields of a given */ @@ -1529,7 +1530,13 @@ FT_BEGIN_HEADER /* values of the corresponding fields in @FT_FaceRec. Some values */ /* like ascender or descender are rounded for historical reasons; */ /* more precise values (for outline fonts) can be derived by scaling */ - /* the corresponding @FT_FaceRec values manually. */ + /* the corresponding @FT_FaceRec values manually, with code similar */ + /* to the following. */ + /* */ + /* { */ + /* scaled_ascender = FT_MulFix( face->root.ascender, */ + /* size_metrics->y_scale ); */ + /* } */ /* */ /* Note that due to glyph hinting and the selected rendering mode */ /* these values are usually not exact; consequently, they must be */ @@ -1774,7 +1781,7 @@ FT_BEGIN_HEADER /* and add it to `origin_x'> */ /* */ /* origin_x += slot->advance.x; */ - /* origin_x += slot->rsb_delta - slot->lsb_relta; */ + /* origin_x += slot->rsb_delta - slot->lsb_delta; */ /* endfor */ /* } */ /* */ @@ -1794,9 +1801,9 @@ FT_BEGIN_HEADER /* */ /* <load glyph with `FT_Load_Glyph'> */ /* */ - /* if ( prev_rsb_delta - slot->lsb_delta >= 32 ) */ + /* if ( prev_rsb_delta - slot->lsb_delta > 32 ) */ /* origin_x -= 64; */ - /* else if ( prev_rsb_delta - slot->lsb_delta < -32 ) */ + /* else if ( prev_rsb_delta - slot->lsb_delta < -31 ) */ /* origin_x += 64; */ /* */ /* prev_rsb_delta = slot->rsb_delta; */ @@ -3124,11 +3131,13 @@ FT_BEGIN_HEADER /* glyph outline in pixels and use the @FT_PIXEL_MODE_LCD_V mode. */ /* */ /* <Note> */ - /* The LCD-optimized glyph bitmaps produced by `FT_Render_Glyph' can */ - /* be filtered to reduce color-fringes by using */ - /* @FT_Library_SetLcdFilter (not active in the default builds). It */ - /* is up to the caller to either call `FT_Library_SetLcdFilter' (if */ - /* available) or do the filtering itself. */ + /* Should you define FT_CONFIG_OPTION_SUBPIXEL_RENDERING in your */ + /* `ftoption.h', which enables patented ClearType-style rendering, */ + /* the LCD-optimized glyph bitmaps should be filtered to reduce color */ + /* fringes inherent to this technology. You can either set up LCD */ + /* filtering with @FT_Library_SetLcdFilter or @FT_Face_Properties, */ + /* or do the filtering yourself. The default FreeType LCD rendering */ + /* technology does not require filtering. */ /* */ /* The selected render mode only affects vector glyphs of a font. */ /* Embedded bitmaps often have a different pixel mode like */ @@ -4327,6 +4336,9 @@ FT_BEGIN_HEADER /* `a' rounded to the nearest 16.16 fixed integer, halfway cases away */ /* from zero. */ /* */ + /* <Note> */ + /* The function uses wrap-around arithmetic. */ + /* */ FT_EXPORT( FT_Fixed ) FT_RoundFix( FT_Fixed a ); @@ -4345,6 +4357,9 @@ FT_BEGIN_HEADER /* <Return> */ /* `a' rounded towards plus infinity. */ /* */ + /* <Note> */ + /* The function uses wrap-around arithmetic. */ + /* */ FT_EXPORT( FT_Fixed ) FT_CeilFix( FT_Fixed a ); @@ -4442,7 +4457,7 @@ FT_BEGIN_HEADER */ #define FREETYPE_MAJOR 2 #define FREETYPE_MINOR 8 -#define FREETYPE_PATCH 0 +#define FREETYPE_PATCH 1 /*************************************************************************/ diff --git a/thirdparty/freetype/include/freetype/ftautoh.h b/thirdparty/freetype/include/freetype/ftautoh.h index abd540f0b5..2bb675ae46 100644 --- a/thirdparty/freetype/include/freetype/ftautoh.h +++ b/thirdparty/freetype/include/freetype/ftautoh.h @@ -404,12 +404,12 @@ FT_BEGIN_HEADER * activate the warp hinting code in the auto-hinter, this property * switches warping on and off. * - * Warping only works in `light' auto-hinting mode. The idea of the - * code is to slightly scale and shift a glyph along the non-hinted - * dimension (which is usually the horizontal axis) so that as much of - * its segments are aligned (more or less) to the grid. To find out a - * glyph's optimal scaling and shifting value, various parameter - * combinations are tried and scored. + * Warping only works in `normal' auto-hinting mode replacing it. + * The idea of the code is to slightly scale and shift a glyph along + * the non-hinted dimension (which is usually the horizontal axis) so + * that as much of its segments are aligned (more or less) to the grid. + * To find out a glyph's optimal scaling and shifting value, various + * parameter combinations are tried and scored. * * By default, warping is off. The example below shows how to switch on * warping (omitting the error handling). @@ -437,7 +437,7 @@ FT_BEGIN_HEADER * * Since warping is a global property of the auto-hinter it is best to * change its value before rendering any face. Otherwise, you should - * reload all faces that get auto-hinted in `light' hinting mode. + * reload all faces that get auto-hinted in `normal' hinting mode. * */ diff --git a/thirdparty/freetype/include/freetype/fterrdef.h b/thirdparty/freetype/include/freetype/fterrdef.h index cabbac8273..6a6dc85b87 100644 --- a/thirdparty/freetype/include/freetype/fterrdef.h +++ b/thirdparty/freetype/include/freetype/fterrdef.h @@ -233,6 +233,8 @@ "invalid PostScript (post) table" ) FT_ERRORDEF_( DEF_In_Glyf_Bytecode, 0x9C, "found FDEF or IDEF opcode in glyf bytecode" ) + FT_ERRORDEF_( Missing_Bitmap, 0x9D, + "missing bitmap in strike" ) /* CFF, CID, and Type 1 errors */ diff --git a/thirdparty/freetype/include/freetype/fterrors.h b/thirdparty/freetype/include/freetype/fterrors.h index 42769fa7bf..ae382c419f 100644 --- a/thirdparty/freetype/include/freetype/fterrors.h +++ b/thirdparty/freetype/include/freetype/fterrors.h @@ -38,15 +38,15 @@ /* The configuration macro FT_CONFIG_OPTION_USE_MODULE_ERRORS can be */ /* defined in `ftoption.h' in order to make the higher byte indicate */ /* the module where the error has happened (this is not compatible */ - /* with standard builds of FreeType 2, however). See the file */ + /* with standard builds of FreeType~2, however). See the file */ /* `ftmoderr.h' for more details. */ /* */ /* *Error* *Message* *Strings* */ /* */ /* Error definitions are set up with special macros that allow client */ /* applications to build a table of error message strings. The */ - /* strings are not included in a normal build of FreeType 2 to */ - /* save space (most client applications do not use them). */ + /* strings are not included in a normal build of FreeType~2 to save */ + /* space (most client applications do not use them). */ /* */ /* To do so, you have to define the following macros before including */ /* this file. */ diff --git a/thirdparty/freetype/include/freetype/ftglyph.h b/thirdparty/freetype/include/freetype/ftglyph.h index 79879a7ac7..db1a2c8ba5 100644 --- a/thirdparty/freetype/include/freetype/ftglyph.h +++ b/thirdparty/freetype/include/freetype/ftglyph.h @@ -231,6 +231,12 @@ FT_BEGIN_HEADER /* <Return> */ /* FreeType error code. 0~means success. */ /* */ + /* <Note> */ + /* Because `*aglyph->advance.x' and '*aglyph->advance.y' are 16.16 */ + /* fixed-point numbers, `slot->advance.x' and `slot->advance.y' */ + /* (which are in 26.6 fixed-point format) must be in the range */ + /* ]-32768;32768[. */ + /* */ FT_EXPORT( FT_Error ) FT_Get_Glyph( FT_GlyphSlot slot, FT_Glyph *aglyph ); @@ -566,6 +572,9 @@ FT_BEGIN_HEADER /* <Note> */ /* The result is undefined if either `a' or `b' is zero. */ /* */ + /* Since the function uses wrap-around arithmetic, results become */ + /* meaningless if the arguments are very large. */ + /* */ FT_EXPORT( void ) FT_Matrix_Multiply( const FT_Matrix* a, FT_Matrix* b ); diff --git a/thirdparty/freetype/include/freetype/ftimage.h b/thirdparty/freetype/include/freetype/ftimage.h index 1a049ef16d..1c789e5a44 100644 --- a/thirdparty/freetype/include/freetype/ftimage.h +++ b/thirdparty/freetype/include/freetype/ftimage.h @@ -1064,24 +1064,24 @@ FT_BEGIN_HEADER /* */ /* <Description> */ /* FreeType used to provide an area of memory called the `render */ - /* pool' available to all registered rasters. This was not thread */ - /* safe however and now FreeType never allocates this pool. NULL */ - /* is always passed in as pool_base. */ + /* pool' available to all registered rasterizers. This was not */ + /* thread safe, however, and now FreeType never allocates this pool. */ /* */ - /* This function is called each time the render pool changes, or just */ - /* after a new raster object is created. */ + /* This function is called after a new raster object is created. */ /* */ /* <Input> */ /* raster :: A handle to the new raster object. */ /* */ - /* pool_base :: The address in memory of the render pool. */ + /* pool_base :: Previously, the address in memory of the render pool. */ + /* Set this to NULL. */ /* */ - /* pool_size :: The size in bytes of the render pool. */ + /* pool_size :: Previously, the size in bytes of the render pool. */ + /* Set this to 0. */ /* */ /* <Note> */ - /* Rasters should ignore the render pool and rely on dynamic or stack */ - /* allocation if they want to (a handle to the memory allocator is */ - /* passed to the raster constructor). */ + /* Rasterizers should rely on dynamic or stack allocation if they */ + /* want to (a handle to the memory allocator is passed to the */ + /* rasterizer constructor). */ /* */ typedef void (*FT_Raster_ResetFunc)( FT_Raster raster, diff --git a/thirdparty/freetype/include/freetype/ftlcdfil.h b/thirdparty/freetype/include/freetype/ftlcdfil.h index 680bd90c89..bdaf9af906 100644 --- a/thirdparty/freetype/include/freetype/ftlcdfil.h +++ b/thirdparty/freetype/include/freetype/ftlcdfil.h @@ -44,9 +44,16 @@ FT_BEGIN_HEADER * Reduce color fringes of subpixel-rendered bitmaps. * * @description: - * Subpixel rendering exploits the color-striped structure of LCD - * pixels, increasing the available resolution in the direction of the - * stripe (usually horizontal RGB) by a factor of~3. Since these + * Should you #define FT_CONFIG_OPTION_SUBPIXEL_RENDERING in your + * `ftoption.h', which enables patented ClearType-style rendering, + * the LCD-optimized glyph bitmaps should be filtered to reduce color + * fringes inherent to this technology. The default FreeType LCD + * rendering uses different technology, and API described below, + * although available, does nothing. + * + * ClearType-style LCD rendering exploits the color-striped structure of + * LCD pixels, increasing the available resolution in the direction of + * the stripe (usually horizontal RGB) by a factor of~3. Since these * subpixels are color pixels, using them unfiltered creates severe * color fringes. Use the @FT_Library_SetLcdFilter API to specify a * low-pass filter, which is then applied to subpixel-rendered bitmaps @@ -54,12 +61,6 @@ FT_BEGIN_HEADER * the higher resolution to reduce color fringes, making the glyph image * slightly blurrier. Positional improvements will remain. * - * Note that no filter is active by default, and that this function is - * *not* implemented in default builds of the library. You need to - * #define FT_CONFIG_OPTION_SUBPIXEL_RENDERING in your `ftoption.h' file - * in order to activate it and explicitly call @FT_Library_SetLcdFilter - * to enable it. - * * A filter should have two properties: * * 1) It should be normalized, meaning the sum of the 5~components diff --git a/thirdparty/freetype/include/freetype/ftmac.h b/thirdparty/freetype/include/freetype/ftmac.h index ad97c6e4c3..a1656eec0e 100644 --- a/thirdparty/freetype/include/freetype/ftmac.h +++ b/thirdparty/freetype/include/freetype/ftmac.h @@ -35,11 +35,12 @@ FT_BEGIN_HEADER -/* gcc-3.4.1 and later can warn about functions tagged as deprecated */ + /* gcc-3.1 and later can warn about functions tagged as deprecated */ #ifndef FT_DEPRECATED_ATTRIBUTE -#if defined(__GNUC__) && \ - ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))) -#define FT_DEPRECATED_ATTRIBUTE __attribute__((deprecated)) +#if defined( __GNUC__ ) && \ + ( ( __GNUC__ >= 4 ) || \ + ( ( __GNUC__ == 3 ) && ( __GNUC_MINOR__ >= 1 ) ) ) +#define FT_DEPRECATED_ATTRIBUTE __attribute__(( deprecated )) #else #define FT_DEPRECATED_ATTRIBUTE #endif diff --git a/thirdparty/freetype/include/freetype/ftmm.h b/thirdparty/freetype/include/freetype/ftmm.h index c41b80ea67..80ac98d612 100644 --- a/thirdparty/freetype/include/freetype/ftmm.h +++ b/thirdparty/freetype/include/freetype/ftmm.h @@ -178,7 +178,8 @@ FT_BEGIN_HEADER /* strid :: The entry in `name' table identifying this instance. */ /* */ /* psid :: The entry in `name' table identifying a PostScript name */ - /* for this instance. */ + /* for this instance. Value 0xFFFF indicates a missing */ + /* entry. */ /* */ typedef struct FT_Var_Named_Style_ { @@ -195,7 +196,7 @@ FT_BEGIN_HEADER /* FT_MM_Var */ /* */ /* <Description> */ - /* A structure to model the axes and space of a Adobe MM, TrueType */ + /* A structure to model the axes and space of an Adobe MM, TrueType */ /* GX, or OpenType variation font. */ /* */ /* Some fields are specific to one format and not to the others. */ @@ -321,6 +322,11 @@ FT_BEGIN_HEADER /* <Return> */ /* FreeType error code. 0~means success. */ /* */ + /* <Note> */ + /* To reset all axes to the default values, call the function with */ + /* `num_coords' set to zero and `coords' set to NULL (new feature in */ + /* FreeType version 2.8.1). */ + /* */ FT_EXPORT( FT_Error ) FT_Set_MM_Design_Coordinates( FT_Face face, FT_UInt num_coords, @@ -351,6 +357,11 @@ FT_BEGIN_HEADER /* <Return> */ /* FreeType error code. 0~means success. */ /* */ + /* <Note> */ + /* To reset all axes to the default values, call the function with */ + /* `num_coords' set to zero and `coords' set to NULL (new feature in */ + /* FreeType version 2.8.1). */ + /* */ FT_EXPORT( FT_Error ) FT_Set_Var_Design_Coordinates( FT_Face face, FT_UInt num_coords, @@ -415,6 +426,11 @@ FT_BEGIN_HEADER /* <Return> */ /* FreeType error code. 0~means success. */ /* */ + /* <Note> */ + /* To reset all axes to the default values, call the function with */ + /* `num_coords' set to zero and `coords' set to NULL (new feature in */ + /* FreeType version 2.8.1). */ + /* */ FT_EXPORT( FT_Error ) FT_Set_MM_Blend_Coordinates( FT_Face face, FT_UInt num_coords, @@ -479,6 +495,50 @@ FT_BEGIN_HEADER FT_UInt num_coords, FT_Fixed* coords ); + + /*************************************************************************/ + /* */ + /* <Enum> */ + /* FT_VAR_AXIS_FLAG_XXX */ + /* */ + /* <Description> */ + /* A list of bit flags used in the return value of */ + /* @FT_Get_Var_Axis_Flags. */ + /* */ + /* <Values> */ + /* FT_VAR_AXIS_FLAG_HIDDEN :: */ + /* The variation axis should not be exposed to user interfaces. */ + /* */ +#define FT_VAR_AXIS_FLAG_HIDDEN 1 + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Get_Var_Axis_Flags */ + /* */ + /* <Description> */ + /* Get the `flags' field of an OpenType Variation Axis Record. */ + /* */ + /* Not meaningful for Adobe MM fonts (`*flags' is always zero). */ + /* */ + /* <Input> */ + /* master :: The variation descriptor. */ + /* */ + /* axis_index :: The index of the requested variation axis. */ + /* */ + /* <Output> */ + /* flags :: The `flags' field. See @FT_VAR_AXIS_FLAG_XXX for */ + /* possible values. */ + /* */ + /* <Return> */ + /* FreeType error code. 0~means success. */ + /* */ + FT_EXPORT( FT_Error ) + FT_Get_Var_Axis_Flags( FT_MM_Var* master, + FT_UInt axis_index, + FT_UInt* flags ); + /* */ diff --git a/thirdparty/freetype/include/freetype/ftoutln.h b/thirdparty/freetype/include/freetype/ftoutln.h index 07f73ebb1b..56f56a9603 100644 --- a/thirdparty/freetype/include/freetype/ftoutln.h +++ b/thirdparty/freetype/include/freetype/ftoutln.h @@ -385,6 +385,9 @@ FT_BEGIN_HEADER /* @FT_Outline_Embolden, which uses the same strength in both */ /* directions. */ /* */ + /* <Since> */ + /* 2.4.10 */ + /* */ FT_EXPORT( FT_Error ) FT_Outline_EmboldenXY( FT_Outline* outline, FT_Pos xstrength, diff --git a/thirdparty/freetype/include/freetype/internal/ftcalc.h b/thirdparty/freetype/include/freetype/internal/ftcalc.h index c9ac9d8246..8b35f03d88 100644 --- a/thirdparty/freetype/include/freetype/internal/ftcalc.h +++ b/thirdparty/freetype/include/freetype/internal/ftcalc.h @@ -399,16 +399,42 @@ FT_BEGIN_HEADER #endif /* 0 */ -#define INT_TO_F26DOT6( x ) ( (FT_Long)(x) << 6 ) -#define INT_TO_F2DOT14( x ) ( (FT_Long)(x) << 14 ) -#define INT_TO_FIXED( x ) ( (FT_Long)(x) << 16 ) -#define F2DOT14_TO_FIXED( x ) ( (FT_Long)(x) << 2 ) -#define FLOAT_TO_FIXED( x ) ( (FT_Long)( x * 65536.0 ) ) +#define INT_TO_F26DOT6( x ) ( (FT_Long)(x) * 64 ) /* << 6 */ +#define INT_TO_F2DOT14( x ) ( (FT_Long)(x) * 16384 ) /* << 14 */ +#define INT_TO_FIXED( x ) ( (FT_Long)(x) * 65536 ) /* << 16 */ +#define F2DOT14_TO_FIXED( x ) ( (FT_Long)(x) * 4 ) /* << 2 */ #define FIXED_TO_INT( x ) ( FT_RoundFix( x ) >> 16 ) #define ROUND_F26DOT6( x ) ( x >= 0 ? ( ( (x) + 32 ) & -64 ) \ : ( -( ( 32 - (x) ) & -64 ) ) ) + /* + * The following macros have two purposes. + * + * . Tag places where overflow is expected and harmless. + * + * . Avoid run-time sanitizer errors. + * + * Use with care! + */ +#define ADD_LONG( a, b ) \ + (FT_Long)( (FT_ULong)(a) + (FT_ULong)(b) ) +#define SUB_LONG( a, b ) \ + (FT_Long)( (FT_ULong)(a) - (FT_ULong)(b) ) +#define MUL_LONG( a, b ) \ + (FT_Long)( (FT_ULong)(a) * (FT_ULong)(b) ) +#define NEG_LONG( a ) \ + (FT_Long)( (FT_ULong)0 - (FT_ULong)(a) ) + +#define ADD_INT32( a, b ) \ + (FT_Int32)( (FT_UInt32)(a) + (FT_UInt32)(b) ) +#define SUB_INT32( a, b ) \ + (FT_Int32)( (FT_UInt32)(a) - (FT_UInt32)(b) ) +#define MUL_INT32( a, b ) \ + (FT_Int32)( (FT_UInt32)(a) * (FT_UInt32)(b) ) +#define NEG_INT32( a ) \ + (FT_Int32)( (FT_UInt32)0 - (FT_UInt32)(a) ) + FT_END_HEADER diff --git a/thirdparty/freetype/include/freetype/internal/ftobjs.h b/thirdparty/freetype/include/freetype/internal/ftobjs.h index 558409166d..4231be238a 100644 --- a/thirdparty/freetype/include/freetype/internal/ftobjs.h +++ b/thirdparty/freetype/include/freetype/internal/ftobjs.h @@ -36,6 +36,7 @@ #include FT_INTERNAL_AUTOHINT_H #include FT_INTERNAL_SERVICE_H #include FT_INTERNAL_PIC_H +#include FT_INTERNAL_CALC_H #ifdef FT_CONFIG_OPTION_INCREMENTAL #include FT_INCREMENTAL_H @@ -85,13 +86,29 @@ FT_BEGIN_HEADER /* we use FT_TYPEOF to suppress signedness compilation warnings */ #define FT_PAD_FLOOR( x, n ) ( (x) & ~FT_TYPEOF( x )( (n)-1 ) ) -#define FT_PAD_ROUND( x, n ) FT_PAD_FLOOR( (x) + ((n)/2), n ) -#define FT_PAD_CEIL( x, n ) FT_PAD_FLOOR( (x) + ((n)-1), n ) +#define FT_PAD_ROUND( x, n ) FT_PAD_FLOOR( (x) + (n)/2, n ) +#define FT_PAD_CEIL( x, n ) FT_PAD_FLOOR( (x) + (n)-1, n ) #define FT_PIX_FLOOR( x ) ( (x) & ~FT_TYPEOF( x )63 ) #define FT_PIX_ROUND( x ) FT_PIX_FLOOR( (x) + 32 ) #define FT_PIX_CEIL( x ) FT_PIX_FLOOR( (x) + 63 ) + /* specialized versions (for signed values) */ + /* that don't produce run-time errors due to integer overflow */ +#define FT_PAD_ROUND_LONG( x, n ) FT_PAD_FLOOR( ADD_LONG( (x), (n) / 2 ), \ + n ) +#define FT_PAD_CEIL_LONG( x, n ) FT_PAD_FLOOR( ADD_LONG( (x), (n) - 1 ), \ + n ) +#define FT_PIX_ROUND_LONG( x ) FT_PIX_FLOOR( ADD_LONG( (x), 32 ) ) +#define FT_PIX_CEIL_LONG( x ) FT_PIX_FLOOR( ADD_LONG( (x), 63 ) ) + +#define FT_PAD_ROUND_INT32( x, n ) FT_PAD_FLOOR( ADD_INT32( (x), (n) / 2 ), \ + n ) +#define FT_PAD_CEIL_INT32( x, n ) FT_PAD_FLOOR( ADD_INT32( (x), (n) - 1 ), \ + n ) +#define FT_PIX_ROUND_INT32( x ) FT_PIX_FLOOR( ADD_INT32( (x), 32 ) ) +#define FT_PIX_CEIL_INT32( x ) FT_PIX_FLOOR( ADD_INT32( (x), 63 ) ) + /* * character classification functions -- since these are used to parse @@ -856,11 +873,6 @@ FT_BEGIN_HEADER /* */ /* auto_hinter :: The auto-hinter module interface. */ /* */ - /* raster_pool :: The raster object's render pool. This can */ - /* ideally be changed dynamically at run-time. */ - /* */ - /* raster_pool_size :: The size of the render pool in bytes. */ - /* */ /* debug_hooks :: An array of four function pointers that allow */ /* debuggers to hook into a font format's */ /* interpreter. Currently, only the TrueType */ @@ -869,9 +881,6 @@ FT_BEGIN_HEADER /* lcd_filter :: If subpixel rendering is activated, the */ /* selected LCD filter mode. */ /* */ - /* lcd_extra :: If subpixel rendering is activated, the number */ - /* of extra pixels needed for the LCD filter. */ - /* */ /* lcd_weights :: If subpixel rendering is activated, the LCD */ /* filter weights, if any. */ /* */ @@ -903,15 +912,10 @@ FT_BEGIN_HEADER FT_Renderer cur_renderer; /* current outline renderer */ FT_Module auto_hinter; - FT_Byte* raster_pool; /* scan-line conversion */ - /* render pool */ - FT_ULong raster_pool_size; /* size of render pool in bytes */ - FT_DebugHook_Func debug_hooks[4]; #ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING FT_LcdFilter lcd_filter; - FT_Int lcd_extra; /* number of extra pixels */ FT_LcdFiveTapFilter lcd_weights; /* filter weights, if any */ FT_Bitmap_LcdFilterFunc lcd_filter_func; /* filtering callback */ #endif diff --git a/thirdparty/freetype/include/freetype/tttags.h b/thirdparty/freetype/include/freetype/tttags.h index 32eb2fdc26..b7d3bac0f1 100644 --- a/thirdparty/freetype/include/freetype/tttags.h +++ b/thirdparty/freetype/include/freetype/tttags.h @@ -106,6 +106,12 @@ FT_BEGIN_HEADER #define TTAG_VVAR FT_MAKE_TAG( 'V', 'V', 'A', 'R' ) #define TTAG_wOFF FT_MAKE_TAG( 'w', 'O', 'F', 'F' ) +/* used by "Keyboard.dfont" on legacy Mac OS X */ +#define TTAG_0xA5kbd FT_MAKE_TAG( 0xA5, 'k', 'b', 'd' ) + +/* used by "LastResort.dfont" on legacy Mac OS X */ +#define TTAG_0xA5lst FT_MAKE_TAG( 0xA5, 'l', 's', 't' ) + FT_END_HEADER diff --git a/thirdparty/freetype/src/autofit/afblue.c b/thirdparty/freetype/src/autofit/afblue.c index a00c3a0765..fedeacf797 100644 --- a/thirdparty/freetype/src/autofit/afblue.c +++ b/thirdparty/freetype/src/autofit/afblue.c @@ -592,9 +592,6 @@ { AF_BLUE_STRING_KAYAH_LI_DESCENDER, 0 }, { AF_BLUE_STRING_KAYAH_LI_LARGE_DESCENDER, 0 }, { AF_BLUE_STRING_MAX, 0 }, - { AF_BLUE_STRING_KANNADA_TOP, AF_BLUE_PROPERTY_LATIN_TOP }, - { AF_BLUE_STRING_KANNADA_BOTTOM, 0 }, - { AF_BLUE_STRING_MAX, 0 }, { AF_BLUE_STRING_KHMER_TOP, AF_BLUE_PROPERTY_LATIN_TOP | AF_BLUE_PROPERTY_LATIN_X_HEIGHT }, { AF_BLUE_STRING_KHMER_SUBSCRIPT_TOP, AF_BLUE_PROPERTY_LATIN_SUB_TOP }, @@ -606,6 +603,9 @@ AF_BLUE_PROPERTY_LATIN_X_HEIGHT }, { AF_BLUE_STRING_KHMER_SYMBOLS_WANING_BOTTOM, 0 }, { AF_BLUE_STRING_MAX, 0 }, + { AF_BLUE_STRING_KANNADA_TOP, AF_BLUE_PROPERTY_LATIN_TOP }, + { AF_BLUE_STRING_KANNADA_BOTTOM, 0 }, + { AF_BLUE_STRING_MAX, 0 }, { AF_BLUE_STRING_LAO_TOP, AF_BLUE_PROPERTY_LATIN_TOP | AF_BLUE_PROPERTY_LATIN_X_HEIGHT }, { AF_BLUE_STRING_LAO_BOTTOM, 0 }, @@ -701,6 +701,9 @@ { AF_BLUE_STRING_TELUGU_TOP, AF_BLUE_PROPERTY_LATIN_TOP }, { AF_BLUE_STRING_TELUGU_BOTTOM, 0 }, { AF_BLUE_STRING_MAX, 0 }, + { AF_BLUE_STRING_TIFINAGH, AF_BLUE_PROPERTY_LATIN_TOP }, + { AF_BLUE_STRING_TIFINAGH, 0 }, + { AF_BLUE_STRING_MAX, 0 }, { AF_BLUE_STRING_THAI_TOP, AF_BLUE_PROPERTY_LATIN_TOP | AF_BLUE_PROPERTY_LATIN_X_HEIGHT }, { AF_BLUE_STRING_THAI_BOTTOM, 0 }, @@ -710,9 +713,6 @@ { AF_BLUE_STRING_THAI_LARGE_DESCENDER, 0 }, { AF_BLUE_STRING_THAI_DIGIT_TOP, 0 }, { AF_BLUE_STRING_MAX, 0 }, - { AF_BLUE_STRING_TIFINAGH, AF_BLUE_PROPERTY_LATIN_TOP }, - { AF_BLUE_STRING_TIFINAGH, 0 }, - { AF_BLUE_STRING_MAX, 0 }, { AF_BLUE_STRING_VAI_TOP, AF_BLUE_PROPERTY_LATIN_TOP }, { AF_BLUE_STRING_VAI_BOTTOM, 0 }, { AF_BLUE_STRING_MAX, 0 }, diff --git a/thirdparty/freetype/src/autofit/afblue.dat b/thirdparty/freetype/src/autofit/afblue.dat index 454923e9ca..f62eb82a1a 100644 --- a/thirdparty/freetype/src/autofit/afblue.dat +++ b/thirdparty/freetype/src/autofit/afblue.dat @@ -872,11 +872,6 @@ AF_BLUE_STRINGSET_ENUM AF_BLUE_STRINGSETS_ARRAY AF_BLUE_STRINGSET_MAX_LEN: { AF_BLUE_STRING_KAYAH_LI_LARGE_DESCENDER, 0 } { AF_BLUE_STRING_MAX, 0 } - AF_BLUE_STRINGSET_KNDA - { AF_BLUE_STRING_KANNADA_TOP, AF_BLUE_PROPERTY_LATIN_TOP } - { AF_BLUE_STRING_KANNADA_BOTTOM, 0 } - { AF_BLUE_STRING_MAX, 0 } - AF_BLUE_STRINGSET_KHMR { AF_BLUE_STRING_KHMER_TOP, AF_BLUE_PROPERTY_LATIN_TOP | AF_BLUE_PROPERTY_LATIN_X_HEIGHT } @@ -892,6 +887,11 @@ AF_BLUE_STRINGSET_ENUM AF_BLUE_STRINGSETS_ARRAY AF_BLUE_STRINGSET_MAX_LEN: { AF_BLUE_STRING_KHMER_SYMBOLS_WANING_BOTTOM, 0 } { AF_BLUE_STRING_MAX, 0 } + AF_BLUE_STRINGSET_KNDA + { AF_BLUE_STRING_KANNADA_TOP, AF_BLUE_PROPERTY_LATIN_TOP } + { AF_BLUE_STRING_KANNADA_BOTTOM, 0 } + { AF_BLUE_STRING_MAX, 0 } + AF_BLUE_STRINGSET_LAO { AF_BLUE_STRING_LAO_TOP, AF_BLUE_PROPERTY_LATIN_TOP | AF_BLUE_PROPERTY_LATIN_X_HEIGHT } @@ -1027,6 +1027,11 @@ AF_BLUE_STRINGSET_ENUM AF_BLUE_STRINGSETS_ARRAY AF_BLUE_STRINGSET_MAX_LEN: { AF_BLUE_STRING_TELUGU_BOTTOM, 0 } { AF_BLUE_STRING_MAX, 0 } + AF_BLUE_STRINGSET_TFNG + { AF_BLUE_STRING_TIFINAGH, AF_BLUE_PROPERTY_LATIN_TOP } + { AF_BLUE_STRING_TIFINAGH, 0 } + { AF_BLUE_STRING_MAX, 0 } + AF_BLUE_STRINGSET_THAI { AF_BLUE_STRING_THAI_TOP, AF_BLUE_PROPERTY_LATIN_TOP | AF_BLUE_PROPERTY_LATIN_X_HEIGHT } @@ -1038,11 +1043,6 @@ AF_BLUE_STRINGSET_ENUM AF_BLUE_STRINGSETS_ARRAY AF_BLUE_STRINGSET_MAX_LEN: { AF_BLUE_STRING_THAI_DIGIT_TOP, 0 } { AF_BLUE_STRING_MAX, 0 } - AF_BLUE_STRINGSET_TFNG - { AF_BLUE_STRING_TIFINAGH, AF_BLUE_PROPERTY_LATIN_TOP } - { AF_BLUE_STRING_TIFINAGH, 0 } - { AF_BLUE_STRING_MAX, 0 } - AF_BLUE_STRINGSET_VAII { AF_BLUE_STRING_VAI_TOP, AF_BLUE_PROPERTY_LATIN_TOP } { AF_BLUE_STRING_VAI_BOTTOM, 0 } diff --git a/thirdparty/freetype/src/autofit/afblue.h b/thirdparty/freetype/src/autofit/afblue.h index e227dbf50b..99ef51cd4a 100644 --- a/thirdparty/freetype/src/autofit/afblue.h +++ b/thirdparty/freetype/src/autofit/afblue.h @@ -344,9 +344,9 @@ FT_BEGIN_HEADER AF_BLUE_STRINGSET_GURU = 116, AF_BLUE_STRINGSET_HEBR = 122, AF_BLUE_STRINGSET_KALI = 126, - AF_BLUE_STRINGSET_KNDA = 132, - AF_BLUE_STRINGSET_KHMR = 135, - AF_BLUE_STRINGSET_KHMS = 141, + AF_BLUE_STRINGSET_KHMR = 132, + AF_BLUE_STRINGSET_KHMS = 138, + AF_BLUE_STRINGSET_KNDA = 141, AF_BLUE_STRINGSET_LAO = 144, AF_BLUE_STRINGSET_LATN = 150, AF_BLUE_STRINGSET_LATB = 157, @@ -367,8 +367,8 @@ FT_BEGIN_HEADER AF_BLUE_STRINGSET_TAML = 222, AF_BLUE_STRINGSET_TAVT = 225, AF_BLUE_STRINGSET_TELU = 228, - AF_BLUE_STRINGSET_THAI = 231, - AF_BLUE_STRINGSET_TFNG = 239, + AF_BLUE_STRINGSET_TFNG = 231, + AF_BLUE_STRINGSET_THAI = 234, AF_BLUE_STRINGSET_VAII = 242, af_blue_2_1 = 245, #ifdef AF_CONFIG_OPTION_CJK diff --git a/thirdparty/freetype/src/autofit/afcjk.c b/thirdparty/freetype/src/autofit/afcjk.c index 61e29cdeda..897533d148 100644 --- a/thirdparty/freetype/src/autofit/afcjk.c +++ b/thirdparty/freetype/src/autofit/afcjk.c @@ -2272,13 +2272,7 @@ goto Exit; /* analyze glyph outline */ -#ifdef AF_CONFIG_OPTION_USE_WARPER - if ( ( metrics->root.scaler.render_mode == FT_RENDER_MODE_LIGHT && - AF_HINTS_DO_WARP( hints ) ) || - AF_HINTS_DO_HORIZONTAL( hints ) ) -#else if ( AF_HINTS_DO_HORIZONTAL( hints ) ) -#endif { error = af_cjk_hints_detect_features( hints, AF_DIMENSION_HORZ ); if ( error ) @@ -2304,9 +2298,9 @@ { #ifdef AF_CONFIG_OPTION_USE_WARPER - if ( dim == AF_DIMENSION_HORZ && - metrics->root.scaler.render_mode == FT_RENDER_MODE_LIGHT && - AF_HINTS_DO_WARP( hints ) ) + if ( dim == AF_DIMENSION_HORZ && + metrics->root.scaler.render_mode == FT_RENDER_MODE_NORMAL && + AF_HINTS_DO_WARP( hints ) ) { AF_WarperRec warper; FT_Fixed scale; diff --git a/thirdparty/freetype/src/autofit/afhints.c b/thirdparty/freetype/src/autofit/afhints.c index f1ff0baef8..1b21c06c2c 100644 --- a/thirdparty/freetype/src/autofit/afhints.c +++ b/thirdparty/freetype/src/autofit/afhints.c @@ -507,15 +507,15 @@ return FT_THROW( Invalid_Argument ); seg = &axis->segments[idx]; - *offset = ( dim == AF_DIMENSION_HORZ ) ? seg->first->ox - : seg->first->oy; + *offset = ( dim == AF_DIMENSION_HORZ ) ? seg->first->fx + : seg->first->fy; if ( seg->edge ) *is_blue = (FT_Bool)( seg->edge->blue_edge != 0 ); else *is_blue = FALSE; if ( *is_blue ) - *blue_offset = seg->edge->blue_edge->cur; + *blue_offset = seg->edge->blue_edge->org; else *blue_offset = 0; diff --git a/thirdparty/freetype/src/autofit/aflatin.c b/thirdparty/freetype/src/autofit/aflatin.c index 11fa523c83..02b3b8bbd3 100644 --- a/thirdparty/freetype/src/autofit/aflatin.c +++ b/thirdparty/freetype/src/autofit/aflatin.c @@ -1690,9 +1690,11 @@ if ( prev_max_on_coord > max_on_coord ) max_on_coord = prev_max_on_coord; - prev_segment->last = point; - prev_segment->pos = (FT_Short)( ( min_pos + - max_pos ) >> 1 ); + prev_segment->last = point; + prev_segment->pos = (FT_Short)( ( min_pos + + max_pos ) >> 1 ); + prev_segment->delta = (FT_Short)( ( max_pos - + min_pos ) >> 1 ); if ( ( min_flags | max_flags ) & AF_FLAG_CONTROL && ( max_on_coord - min_on_coord ) < flat_threshold ) @@ -1720,9 +1722,11 @@ if ( max_pos > prev_max_pos ) prev_max_pos = max_pos; - prev_segment->last = point; - prev_segment->pos = (FT_Short)( ( prev_min_pos + - prev_max_pos ) >> 1 ); + prev_segment->last = point; + prev_segment->pos = (FT_Short)( ( prev_min_pos + + prev_max_pos ) >> 1 ); + prev_segment->delta = (FT_Short)( ( prev_max_pos - + prev_min_pos ) >> 1 ); } else { @@ -1733,8 +1737,9 @@ if ( prev_max_pos > max_pos ) max_pos = prev_max_pos; - segment->last = point; - segment->pos = (FT_Short)( ( min_pos + max_pos ) >> 1 ); + segment->last = point; + segment->pos = (FT_Short)( ( min_pos + max_pos ) >> 1 ); + segment->delta = (FT_Short)( ( max_pos - min_pos ) >> 1 ); if ( ( min_flags | max_flags ) & AF_FLAG_CONTROL && ( max_on_coord - min_on_coord ) < flat_threshold ) @@ -3492,13 +3497,7 @@ goto Exit; /* analyze glyph outline */ -#ifdef AF_CONFIG_OPTION_USE_WARPER - if ( ( metrics->root.scaler.render_mode == FT_RENDER_MODE_LIGHT && - AF_HINTS_DO_WARP( hints ) ) || - AF_HINTS_DO_HORIZONTAL( hints ) ) -#else if ( AF_HINTS_DO_HORIZONTAL( hints ) ) -#endif { axis = &metrics->axis[AF_DIMENSION_HORZ]; error = af_latin_hints_detect_features( hints, @@ -3528,9 +3527,9 @@ for ( dim = 0; dim < AF_DIMENSION_MAX; dim++ ) { #ifdef AF_CONFIG_OPTION_USE_WARPER - if ( dim == AF_DIMENSION_HORZ && - metrics->root.scaler.render_mode == FT_RENDER_MODE_LIGHT && - AF_HINTS_DO_WARP( hints ) ) + if ( dim == AF_DIMENSION_HORZ && + metrics->root.scaler.render_mode == FT_RENDER_MODE_NORMAL && + AF_HINTS_DO_WARP( hints ) ) { AF_WarperRec warper; FT_Fixed scale; diff --git a/thirdparty/freetype/src/autofit/aflatin2.c b/thirdparty/freetype/src/autofit/aflatin2.c index 0607278b1e..fb42445116 100644 --- a/thirdparty/freetype/src/autofit/aflatin2.c +++ b/thirdparty/freetype/src/autofit/aflatin2.c @@ -2340,13 +2340,7 @@ goto Exit; /* analyze glyph outline */ -#ifdef AF_CONFIG_OPTION_USE_WARPER - if ( ( metrics->root.scaler.render_mode == FT_RENDER_MODE_LIGHT && - AF_HINTS_DO_WARP( hints ) ) || - AF_HINTS_DO_HORIZONTAL( hints ) ) -#else if ( AF_HINTS_DO_HORIZONTAL( hints ) ) -#endif { error = af_latin2_hints_detect_features( hints, AF_DIMENSION_HORZ ); if ( error ) @@ -2366,9 +2360,9 @@ for ( dim = 0; dim < AF_DIMENSION_MAX; dim++ ) { #ifdef AF_CONFIG_OPTION_USE_WARPER - if ( dim == AF_DIMENSION_HORZ && - metrics->root.scaler.render_mode == FT_RENDER_MODE_LIGHT && - AF_HINTS_DO_WARP( hints ) ) + if ( dim == AF_DIMENSION_HORZ && + metrics->root.scaler.render_mode == FT_RENDER_MODE_NORMAL && + AF_HINTS_DO_WARP( hints ) ) { AF_WarperRec warper; FT_Fixed scale; diff --git a/thirdparty/freetype/src/autofit/afloader.c b/thirdparty/freetype/src/autofit/afloader.c index 78c4368b61..067ebd17f6 100644 --- a/thirdparty/freetype/src/autofit/afloader.c +++ b/thirdparty/freetype/src/autofit/afloader.c @@ -483,8 +483,8 @@ FT_Pos pp2x = loader->pp2.x; - loader->pp1.x = FT_PIX_ROUND( pp1x ); - loader->pp2.x = FT_PIX_ROUND( pp2x ); + loader->pp1.x = FT_PIX_ROUND( pp1x + hints->xmin_delta ); + loader->pp2.x = FT_PIX_ROUND( pp2x + hints->xmax_delta ); slot->lsb_delta = loader->pp1.x - pp1x; slot->rsb_delta = loader->pp2.x - pp2x; @@ -498,8 +498,8 @@ FT_Pos pp2x = loader->pp2.x; - loader->pp1.x = FT_PIX_ROUND( pp1x + hints->xmin_delta ); - loader->pp2.x = FT_PIX_ROUND( pp2x + hints->xmax_delta ); + loader->pp1.x = FT_PIX_ROUND( pp1x ); + loader->pp2.x = FT_PIX_ROUND( pp2x ); slot->lsb_delta = loader->pp1.x - pp1x; slot->rsb_delta = loader->pp2.x - pp2x; diff --git a/thirdparty/freetype/src/autofit/afscript.h b/thirdparty/freetype/src/autofit/afscript.h index 7547a9e6f9..cb815dbb40 100644 --- a/thirdparty/freetype/src/autofit/afscript.h +++ b/thirdparty/freetype/src/autofit/afscript.h @@ -187,12 +187,6 @@ HINTING_BOTTOM_TO_TOP, "\xEA\xA4\x8D \xEA\xA4\x80" ) /* ꤍ ꤀ */ - SCRIPT( knda, KNDA, - "Kannada", - HB_SCRIPT_KANNADA, - HINTING_BOTTOM_TO_TOP, - "\xE0\xB3\xA6 \xE0\xB2\xAC" ) /* ೦ ಬ */ - /* only digit zero has a simple shape in the Khmer script */ SCRIPT( khmr, KHMR, "Khmer", @@ -206,6 +200,12 @@ HINTING_BOTTOM_TO_TOP, "\xE1\xA7\xA1 \xE1\xA7\xAA" ) /* ᧡ ᧪ */ + SCRIPT( knda, KNDA, + "Kannada", + HB_SCRIPT_KANNADA, + HINTING_BOTTOM_TO_TOP, + "\xE0\xB3\xA6 \xE0\xB2\xAC" ) /* ೦ ಬ */ + /* only digit zero has a simple shape in the Lao script */ SCRIPT( lao, LAO, "Lao", @@ -330,18 +330,18 @@ HINTING_BOTTOM_TO_TOP, "\xE0\xB1\xA6 \xE0\xB1\xA7" ) /* ౦ ౧ */ - SCRIPT( thai, THAI, - "Thai", - HB_SCRIPT_THAI, - HINTING_BOTTOM_TO_TOP, - "\xE0\xB8\xB2 \xE0\xB9\x85 \xE0\xB9\x90" ) /* า ๅ ๐ */ - SCRIPT( tfng, TFNG, "Tifinagh", HB_SCRIPT_TIFINAGH, HINTING_BOTTOM_TO_TOP, "\xE2\xB5\x94" ) /* ⵔ */ + SCRIPT( thai, THAI, + "Thai", + HB_SCRIPT_THAI, + HINTING_BOTTOM_TO_TOP, + "\xE0\xB8\xB2 \xE0\xB9\x85 \xE0\xB9\x90" ) /* า ๅ ๐ */ + SCRIPT( vaii, VAII, "Vai", HB_SCRIPT_VAI, diff --git a/thirdparty/freetype/src/autofit/afshaper.c b/thirdparty/freetype/src/autofit/afshaper.c index da92fad3ed..d259964217 100644 --- a/thirdparty/freetype/src/autofit/afshaper.c +++ b/thirdparty/freetype/src/autofit/afshaper.c @@ -18,6 +18,7 @@ #include <ft2build.h> #include FT_FREETYPE_H +#include FT_ADVANCES_H #include "afglobal.h" #include "aftypes.h" #include "afshaper.h" diff --git a/thirdparty/freetype/src/autofit/afstyles.h b/thirdparty/freetype/src/autofit/afstyles.h index a5e13d8944..281559eea2 100644 --- a/thirdparty/freetype/src/autofit/afstyles.h +++ b/thirdparty/freetype/src/autofit/afstyles.h @@ -255,13 +255,6 @@ AF_BLUE_STRINGSET_KALI, AF_COVERAGE_DEFAULT ) - STYLE( knda_dflt, KNDA_DFLT, - "Kannada default style", - AF_WRITING_SYSTEM_LATIN, - AF_SCRIPT_KNDA, - AF_BLUE_STRINGSET_KNDA, - AF_COVERAGE_DEFAULT ) - STYLE( khmr_dflt, KHMR_DFLT, "Khmer default style", AF_WRITING_SYSTEM_LATIN, @@ -276,6 +269,13 @@ AF_BLUE_STRINGSET_KHMS, AF_COVERAGE_DEFAULT ) + STYLE( knda_dflt, KNDA_DFLT, + "Kannada default style", + AF_WRITING_SYSTEM_LATIN, + AF_SCRIPT_KNDA, + AF_BLUE_STRINGSET_KNDA, + AF_COVERAGE_DEFAULT ) + STYLE( lao_dflt, LAO_DFLT, "Lao default style", AF_WRITING_SYSTEM_LATIN, @@ -420,13 +420,6 @@ AF_BLUE_STRINGSET_TELU, AF_COVERAGE_DEFAULT ) - STYLE( thai_dflt, THAI_DFLT, - "Thai default style", - AF_WRITING_SYSTEM_LATIN, - AF_SCRIPT_THAI, - AF_BLUE_STRINGSET_THAI, - AF_COVERAGE_DEFAULT ) - STYLE( tfng_dflt, TFNG_DFLT, "Tifinagh default style", AF_WRITING_SYSTEM_LATIN, @@ -434,6 +427,13 @@ AF_BLUE_STRINGSET_TFNG, AF_COVERAGE_DEFAULT ) + STYLE( thai_dflt, THAI_DFLT, + "Thai default style", + AF_WRITING_SYSTEM_LATIN, + AF_SCRIPT_THAI, + AF_BLUE_STRINGSET_THAI, + AF_COVERAGE_DEFAULT ) + STYLE( vaii_dflt, VAII_DFLT, "Vai default style", AF_WRITING_SYSTEM_LATIN, diff --git a/thirdparty/freetype/src/base/ftbitmap.c b/thirdparty/freetype/src/base/ftbitmap.c index 88c88c4c1b..e567a0453e 100644 --- a/thirdparty/freetype/src/base/ftbitmap.c +++ b/thirdparty/freetype/src/base/ftbitmap.c @@ -226,7 +226,7 @@ } /* otherwise allocate new buffer */ - if ( FT_QALLOC_MULT( buffer, new_pitch, bitmap->rows + ypixels ) ) + if ( FT_QALLOC_MULT( buffer, bitmap->rows + ypixels, new_pitch ) ) return error; /* new rows get added at the top of the bitmap, */ @@ -534,8 +534,7 @@ (FT_ULong)target->rows > FT_ULONG_MAX / (FT_ULong)target_pitch ) return FT_THROW( Invalid_Argument ); - if ( target->rows * (FT_ULong)target_pitch > old_size && - FT_QREALLOC( target->buffer, + if ( FT_QREALLOC( target->buffer, old_size, target->rows * (FT_UInt)target_pitch ) ) return error; diff --git a/thirdparty/freetype/src/base/ftcalc.c b/thirdparty/freetype/src/base/ftcalc.c index f0525502f3..00d63c6e6b 100644 --- a/thirdparty/freetype/src/base/ftcalc.c +++ b/thirdparty/freetype/src/base/ftcalc.c @@ -68,14 +68,15 @@ #define FT_COMPONENT trace_calc - /* transfer sign leaving a positive number */ -#define FT_MOVE_SIGN( x, s ) \ - FT_BEGIN_STMNT \ - if ( x < 0 ) \ - { \ - x = -x; \ - s = -s; \ - } \ + /* transfer sign, leaving a positive number; */ + /* we need an unsigned value to safely negate INT_MIN (or LONG_MIN) */ +#define FT_MOVE_SIGN( x, x_unsigned, s ) \ + FT_BEGIN_STMNT \ + if ( x < 0 ) \ + { \ + x_unsigned = 0U - (x_unsigned); \ + s = -s; \ + } \ FT_END_STMNT /* The following three functions are available regardless of whether */ @@ -86,7 +87,7 @@ FT_EXPORT_DEF( FT_Fixed ) FT_RoundFix( FT_Fixed a ) { - return ( a + 0x8000L - ( a < 0 ) ) & ~0xFFFFL; + return ( ADD_LONG( a, 0x8000L - ( a < 0 ) ) ) & ~0xFFFFL; } @@ -95,7 +96,7 @@ FT_EXPORT_DEF( FT_Fixed ) FT_CeilFix( FT_Fixed a ) { - return ( a + 0xFFFFL ) & ~0xFFFFL; + return ( ADD_LONG( a, 0xFFFFL ) ) & ~0xFFFFL; } @@ -179,20 +180,20 @@ FT_Long d_; - FT_MOVE_SIGN( a_, s ); - FT_MOVE_SIGN( b_, s ); - FT_MOVE_SIGN( c_, s ); - a = (FT_UInt64)a_; b = (FT_UInt64)b_; c = (FT_UInt64)c_; + FT_MOVE_SIGN( a_, a, s ); + FT_MOVE_SIGN( b_, b, s ); + FT_MOVE_SIGN( c_, c, s ); + d = c > 0 ? ( a * b + ( c >> 1 ) ) / c : 0x7FFFFFFFUL; d_ = (FT_Long)d; - return s < 0 ? -d_ : d_; + return s < 0 ? NEG_LONG( d_ ) : d_; } @@ -208,20 +209,20 @@ FT_Long d_; - FT_MOVE_SIGN( a_, s ); - FT_MOVE_SIGN( b_, s ); - FT_MOVE_SIGN( c_, s ); - a = (FT_UInt64)a_; b = (FT_UInt64)b_; c = (FT_UInt64)c_; + FT_MOVE_SIGN( a_, a, s ); + FT_MOVE_SIGN( b_, b, s ); + FT_MOVE_SIGN( c_, c, s ); + d = c > 0 ? a * b / c : 0x7FFFFFFFUL; d_ = (FT_Long)d; - return s < 0 ? -d_ : d_; + return s < 0 ? NEG_LONG( d_ ) : d_; } @@ -257,18 +258,18 @@ FT_Long q_; - FT_MOVE_SIGN( a_, s ); - FT_MOVE_SIGN( b_, s ); - a = (FT_UInt64)a_; b = (FT_UInt64)b_; + FT_MOVE_SIGN( a_, a, s ); + FT_MOVE_SIGN( b_, b, s ); + q = b > 0 ? ( ( a << 16 ) + ( b >> 1 ) ) / b : 0x7FFFFFFFUL; q_ = (FT_Long)q; - return s < 0 ? -q_ : q_; + return s < 0 ? NEG_LONG( q_ ) : q_; } @@ -422,14 +423,14 @@ /* XXX: this function does not allow 64-bit arguments */ - FT_MOVE_SIGN( a_, s ); - FT_MOVE_SIGN( b_, s ); - FT_MOVE_SIGN( c_, s ); - a = (FT_UInt32)a_; b = (FT_UInt32)b_; c = (FT_UInt32)c_; + FT_MOVE_SIGN( a_, a, s ); + FT_MOVE_SIGN( b_, b, s ); + FT_MOVE_SIGN( c_, c, s ); + if ( c == 0 ) a = 0x7FFFFFFFUL; @@ -455,7 +456,7 @@ a_ = (FT_Long)a; - return s < 0 ? -a_ : a_; + return s < 0 ? NEG_LONG( a_ ) : a_; } @@ -470,14 +471,14 @@ /* XXX: this function does not allow 64-bit arguments */ - FT_MOVE_SIGN( a_, s ); - FT_MOVE_SIGN( b_, s ); - FT_MOVE_SIGN( c_, s ); - a = (FT_UInt32)a_; b = (FT_UInt32)b_; c = (FT_UInt32)c_; + FT_MOVE_SIGN( a_, a, s ); + FT_MOVE_SIGN( b_, b, s ); + FT_MOVE_SIGN( c_, c, s ); + if ( c == 0 ) a = 0x7FFFFFFFUL; @@ -498,7 +499,7 @@ a_ = (FT_Long)a; - return s < 0 ? -a_ : a_; + return s < 0 ? NEG_LONG( a_ ) : a_; } @@ -575,12 +576,12 @@ /* XXX: this function does not allow 64-bit arguments */ - FT_MOVE_SIGN( a_, s ); - FT_MOVE_SIGN( b_, s ); - a = (FT_UInt32)a_; b = (FT_UInt32)b_; + FT_MOVE_SIGN( a_, a, s ); + FT_MOVE_SIGN( b_, b, s ); + if ( a + ( b >> 8 ) <= 8190UL ) a = ( a * b + 0x8000UL ) >> 16; else @@ -594,7 +595,7 @@ a_ = (FT_Long)a; - return s < 0 ? -a_ : a_; + return s < 0 ? NEG_LONG( a_ ) : a_; #endif /* 0 */ @@ -614,12 +615,12 @@ /* XXX: this function does not allow 64-bit arguments */ - FT_MOVE_SIGN( a_, s ); - FT_MOVE_SIGN( b_, s ); - a = (FT_UInt32)a_; b = (FT_UInt32)b_; + FT_MOVE_SIGN( a_, a, s ); + FT_MOVE_SIGN( b_, b, s ); + if ( b == 0 ) { /* check for division by 0 */ @@ -647,7 +648,7 @@ q_ = (FT_Long)q; - return s < 0 ? -q_ : q_; + return s < 0 ? NEG_LONG( q_ ) : q_; } @@ -666,13 +667,19 @@ if ( !a || !b ) return; - xx = FT_MulFix( a->xx, b->xx ) + FT_MulFix( a->xy, b->yx ); - xy = FT_MulFix( a->xx, b->xy ) + FT_MulFix( a->xy, b->yy ); - yx = FT_MulFix( a->yx, b->xx ) + FT_MulFix( a->yy, b->yx ); - yy = FT_MulFix( a->yx, b->xy ) + FT_MulFix( a->yy, b->yy ); - - b->xx = xx; b->xy = xy; - b->yx = yx; b->yy = yy; + xx = ADD_LONG( FT_MulFix( a->xx, b->xx ), + FT_MulFix( a->xy, b->yx ) ); + xy = ADD_LONG( FT_MulFix( a->xx, b->xy ), + FT_MulFix( a->xy, b->yy ) ); + yx = ADD_LONG( FT_MulFix( a->yx, b->xx ), + FT_MulFix( a->yy, b->yx ) ); + yy = ADD_LONG( FT_MulFix( a->yx, b->xy ), + FT_MulFix( a->yy, b->yy ) ); + + b->xx = xx; + b->xy = xy; + b->yx = yx; + b->yy = yy; } @@ -722,13 +729,19 @@ if ( !a || !b ) return; - xx = FT_MulDiv( a->xx, b->xx, val ) + FT_MulDiv( a->xy, b->yx, val ); - xy = FT_MulDiv( a->xx, b->xy, val ) + FT_MulDiv( a->xy, b->yy, val ); - yx = FT_MulDiv( a->yx, b->xx, val ) + FT_MulDiv( a->yy, b->yx, val ); - yy = FT_MulDiv( a->yx, b->xy, val ) + FT_MulDiv( a->yy, b->yy, val ); - - b->xx = xx; b->xy = xy; - b->yx = yx; b->yy = yy; + xx = ADD_LONG( FT_MulDiv( a->xx, b->xx, val ), + FT_MulDiv( a->xy, b->yx, val ) ); + xy = ADD_LONG( FT_MulDiv( a->xx, b->xy, val ), + FT_MulDiv( a->xy, b->yy, val ) ); + yx = ADD_LONG( FT_MulDiv( a->yx, b->xx, val ), + FT_MulDiv( a->yy, b->yx, val ) ); + yy = ADD_LONG( FT_MulDiv( a->yx, b->xy, val ), + FT_MulDiv( a->yy, b->yy, val ) ); + + b->xx = xx; + b->xy = xy; + b->yx = yx; + b->yy = yy; } @@ -747,11 +760,10 @@ if ( !vector || !matrix ) return; - xz = FT_MulDiv( vector->x, matrix->xx, val ) + - FT_MulDiv( vector->y, matrix->xy, val ); - - yz = FT_MulDiv( vector->x, matrix->yx, val ) + - FT_MulDiv( vector->y, matrix->yy, val ); + xz = ADD_LONG( FT_MulDiv( vector->x, matrix->xx, val ), + FT_MulDiv( vector->y, matrix->xy, val ) ); + yz = ADD_LONG( FT_MulDiv( vector->x, matrix->yx, val ), + FT_MulDiv( vector->y, matrix->yy, val ) ); vector->x = xz; vector->y = yz; @@ -770,12 +782,12 @@ FT_Int sx = 1, sy = 1, shift; - FT_MOVE_SIGN( x_, sx ); - FT_MOVE_SIGN( y_, sy ); - x = (FT_UInt32)x_; y = (FT_UInt32)y_; + FT_MOVE_SIGN( x_, x, sx ); + FT_MOVE_SIGN( y_, y, sy ); + /* trivial cases */ if ( x == 0 ) { @@ -913,11 +925,13 @@ FT_Int result; - if ( (FT_ULong)FT_ABS( in_x ) + (FT_ULong)FT_ABS( out_y ) <= 131071UL && - (FT_ULong)FT_ABS( in_y ) + (FT_ULong)FT_ABS( out_x ) <= 131071UL ) + /* we silently ignore overflow errors, since such large values */ + /* lead to even more (harmless) rendering errors later on */ + if ( ADD_LONG( FT_ABS( in_x ), FT_ABS( out_y ) ) <= 131071L && + ADD_LONG( FT_ABS( in_y ), FT_ABS( out_x ) ) <= 131071L ) { - FT_Long z1 = in_x * out_y; - FT_Long z2 = in_y * out_x; + FT_Long z1 = MUL_LONG( in_x, out_y ); + FT_Long z2 = MUL_LONG( in_y, out_x ); if ( z1 > z2 ) diff --git a/thirdparty/freetype/src/base/ftglyph.c b/thirdparty/freetype/src/base/ftglyph.c index 9bfb330508..3f78a8c36b 100644 --- a/thirdparty/freetype/src/base/ftglyph.c +++ b/thirdparty/freetype/src/base/ftglyph.c @@ -408,12 +408,28 @@ goto Exit; /* copy advance while converting 26.6 to 16.16 format */ + if ( slot->advance.x >= 0x8000L * 64 || + slot->advance.x <= -0x8000L * 64 ) + { + FT_ERROR(( "FT_Get_Glyph: advance width too large\n" )); + error = FT_THROW( Invalid_Argument ); + goto Exit2; + } + if ( slot->advance.y >= 0x8000L * 64 || + slot->advance.y <= -0x8000L * 64 ) + { + FT_ERROR(( "FT_Get_Glyph: advance height too large\n" )); + error = FT_THROW( Invalid_Argument ); + goto Exit2; + } + glyph->advance.x = slot->advance.x * 1024; glyph->advance.y = slot->advance.y * 1024; /* now import the image from the glyph slot */ error = clazz->glyph_init( glyph, slot ); + Exit2: /* if an error occurred, destroy the glyph */ if ( error ) FT_Done_Glyph( glyph ); diff --git a/thirdparty/freetype/src/base/ftlcdfil.c b/thirdparty/freetype/src/base/ftlcdfil.c index 611b39f570..60c813fd9e 100644 --- a/thirdparty/freetype/src/base/ftlcdfil.c +++ b/thirdparty/freetype/src/base/ftlcdfil.c @@ -29,141 +29,107 @@ /* define USE_LEGACY to implement the legacy filter */ #define USE_LEGACY +#define FT_SHIFTCLAMP( x ) ( x >>= 8, (FT_Byte)( x > 255 ? 255 : x ) ) + /* FIR filter used by the default and light filters */ FT_BASE( void ) ft_lcd_filter_fir( FT_Bitmap* bitmap, FT_Render_Mode mode, FT_LcdFiveTapFilter weights ) { - FT_UInt width = (FT_UInt)bitmap->width; - FT_UInt height = (FT_UInt)bitmap->rows; + FT_UInt width = (FT_UInt)bitmap->width; + FT_UInt height = (FT_UInt)bitmap->rows; + FT_Int pitch = bitmap->pitch; + FT_Byte* origin = bitmap->buffer; + + /* take care of bitmap flow */ + if ( pitch > 0 ) + origin += pitch * (FT_Int)( height - 1 ); /* horizontal in-place FIR filter */ - if ( mode == FT_RENDER_MODE_LCD && width >= 4 ) + if ( mode == FT_RENDER_MODE_LCD && width >= 2 ) { - FT_Byte* line = bitmap->buffer; - + FT_Byte* line = origin; - /* take care of bitmap flow */ - if ( bitmap->pitch < 0 ) - line -= bitmap->pitch * (FT_Int)( bitmap->rows - 1 ); - /* `fir' and `pix' must be at least 32 bit wide, since the sum of */ - /* the values in `weights' can exceed 0xFF */ + /* `fir' must be at least 32 bit wide, since the sum of */ + /* the values in `weights' can exceed 0xFF */ - for ( ; height > 0; height--, line += bitmap->pitch ) + for ( ; height > 0; height--, line -= pitch ) { - FT_UInt fir[4]; /* below, `pix' is used as the 5th element */ - FT_UInt val1, xx; + FT_UInt fir[5]; + FT_UInt val, xx; - val1 = line[0]; - fir[0] = weights[2] * val1; - fir[1] = weights[3] * val1; - fir[2] = weights[4] * val1; - fir[3] = 0; + val = line[0]; + fir[2] = weights[2] * val; + fir[3] = weights[3] * val; + fir[4] = weights[4] * val; - val1 = line[1]; - fir[0] += weights[1] * val1; - fir[1] += weights[2] * val1; - fir[2] += weights[3] * val1; - fir[3] += weights[4] * val1; + val = line[1]; + fir[1] = fir[2] + weights[1] * val; + fir[2] = fir[3] + weights[2] * val; + fir[3] = fir[4] + weights[3] * val; + fir[4] = weights[4] * val; for ( xx = 2; xx < width; xx++ ) { - FT_UInt val, pix; - - val = line[xx]; - pix = fir[0] + weights[0] * val; - fir[0] = fir[1] + weights[1] * val; - fir[1] = fir[2] + weights[2] * val; - fir[2] = fir[3] + weights[3] * val; - fir[3] = weights[4] * val; - - pix >>= 8; - pix |= (FT_UInt)-(FT_Int)( pix >> 8 ); - line[xx - 2] = (FT_Byte)pix; - } + fir[0] = fir[1] + weights[0] * val; + fir[1] = fir[2] + weights[1] * val; + fir[2] = fir[3] + weights[2] * val; + fir[3] = fir[4] + weights[3] * val; + fir[4] = weights[4] * val; - { - FT_UInt pix; - - - pix = fir[0] >> 8; - pix |= (FT_UInt)-(FT_Int)( pix >> 8 ); - line[xx - 2] = (FT_Byte)pix; - - pix = fir[1] >> 8; - pix |= (FT_UInt)-(FT_Int)( pix >> 8 ); - line[xx - 1] = (FT_Byte)pix; + line[xx - 2] = FT_SHIFTCLAMP( fir[0] ); } + + line[xx - 2] = FT_SHIFTCLAMP( fir[1] ); + line[xx - 1] = FT_SHIFTCLAMP( fir[2] ); } } /* vertical in-place FIR filter */ - else if ( mode == FT_RENDER_MODE_LCD_V && height >= 4 ) + else if ( mode == FT_RENDER_MODE_LCD_V && height >= 2 ) { - FT_Byte* column = bitmap->buffer; - FT_Int pitch = bitmap->pitch; - + FT_Byte* column = origin; - /* take care of bitmap flow */ - if ( bitmap->pitch < 0 ) - column -= bitmap->pitch * (FT_Int)( bitmap->rows - 1 ); for ( ; width > 0; width--, column++ ) { FT_Byte* col = column; - FT_UInt fir[4]; /* below, `pix' is used as the 5th element */ - FT_UInt val1, yy; + FT_UInt fir[5]; + FT_UInt val, yy; - val1 = col[0]; - fir[0] = weights[2] * val1; - fir[1] = weights[3] * val1; - fir[2] = weights[4] * val1; - fir[3] = 0; - col += pitch; + val = col[0]; + fir[2] = weights[2] * val; + fir[3] = weights[3] * val; + fir[4] = weights[4] * val; + col -= pitch; - val1 = col[0]; - fir[0] += weights[1] * val1; - fir[1] += weights[2] * val1; - fir[2] += weights[3] * val1; - fir[3] += weights[4] * val1; - col += pitch; + val = col[0]; + fir[1] = fir[2] + weights[1] * val; + fir[2] = fir[3] + weights[2] * val; + fir[3] = fir[4] + weights[3] * val; + fir[4] = weights[4] * val; + col -= pitch; - for ( yy = 2; yy < height; yy++ ) + for ( yy = 2; yy < height; yy++, col -= pitch ) { - FT_UInt val, pix; - - val = col[0]; - pix = fir[0] + weights[0] * val; - fir[0] = fir[1] + weights[1] * val; - fir[1] = fir[2] + weights[2] * val; - fir[2] = fir[3] + weights[3] * val; - fir[3] = weights[4] * val; - - pix >>= 8; - pix |= (FT_UInt)-(FT_Int)( pix >> 8 ); - col[-2 * pitch] = (FT_Byte)pix; - col += pitch; - } - - { - FT_UInt pix; - + fir[0] = fir[1] + weights[0] * val; + fir[1] = fir[2] + weights[1] * val; + fir[2] = fir[3] + weights[2] * val; + fir[3] = fir[4] + weights[3] * val; + fir[4] = weights[4] * val; - pix = fir[0] >> 8; - pix |= (FT_UInt)-(FT_Int)( pix >> 8 ); - col[-2 * pitch] = (FT_Byte)pix; - - pix = fir[1] >> 8; - pix |= (FT_UInt)-(FT_Int)( pix >> 8 ); - col[-pitch] = (FT_Byte)pix; + col[pitch * 2] = FT_SHIFTCLAMP( fir[0] ); } + + col[pitch * 2] = FT_SHIFTCLAMP( fir[1] ); + col[pitch] = FT_SHIFTCLAMP( fir[2] ); } } } @@ -177,9 +143,10 @@ FT_Render_Mode mode, FT_Byte* weights ) { - FT_UInt width = (FT_UInt)bitmap->width; - FT_UInt height = (FT_UInt)bitmap->rows; - FT_Int pitch = bitmap->pitch; + FT_UInt width = (FT_UInt)bitmap->width; + FT_UInt height = (FT_UInt)bitmap->rows; + FT_Int pitch = bitmap->pitch; + FT_Byte* origin = bitmap->buffer; static const unsigned int filters[3][3] = { @@ -191,33 +158,31 @@ FT_UNUSED( weights ); + /* take care of bitmap flow */ + if ( pitch > 0 ) + origin += pitch * (FT_Int)( height - 1 ); + /* horizontal in-place intra-pixel filter */ if ( mode == FT_RENDER_MODE_LCD && width >= 3 ) { - FT_Byte* line = bitmap->buffer; + FT_Byte* line = origin; - /* take care of bitmap flow */ - if ( bitmap->pitch < 0 ) - line -= bitmap->pitch * (FT_Int)( bitmap->rows - 1 ); - - for ( ; height > 0; height--, line += pitch ) + for ( ; height > 0; height--, line -= pitch ) { FT_UInt xx; for ( xx = 0; xx < width; xx += 3 ) { - FT_UInt r = 0; - FT_UInt g = 0; - FT_UInt b = 0; + FT_UInt r, g, b; FT_UInt p; p = line[xx]; - r += filters[0][0] * p; - g += filters[0][1] * p; - b += filters[0][2] * p; + r = filters[0][0] * p; + g = filters[0][1] * p; + b = filters[0][2] * p; p = line[xx + 1]; r += filters[1][0] * p; @@ -237,31 +202,24 @@ } else if ( mode == FT_RENDER_MODE_LCD_V && height >= 3 ) { - FT_Byte* column = bitmap->buffer; - + FT_Byte* column = origin; - /* take care of bitmap flow */ - if ( bitmap->pitch < 0 ) - column -= bitmap->pitch * (FT_Int)( bitmap->rows - 1 ); for ( ; width > 0; width--, column++ ) { - FT_Byte* col = column; - FT_Byte* col_end = col + (FT_Int)height * pitch; + FT_Byte* col = column - 2 * pitch; - for ( ; col < col_end; col += 3 * pitch ) + for ( ; height > 0; height -= 3, col -= 3 * pitch ) { - FT_UInt r = 0; - FT_UInt g = 0; - FT_UInt b = 0; + FT_UInt r, g, b; FT_UInt p; p = col[0]; - r += filters[0][0] * p; - g += filters[0][1] * p; - b += filters[0][2] * p; + r = filters[0][0] * p; + g = filters[0][1] * p; + b = filters[0][2] * p; p = col[pitch]; r += filters[1][0] * p; @@ -275,7 +233,7 @@ col[0] = (FT_Byte)( r / 65536 ); col[pitch] = (FT_Byte)( g / 65536 ); - col[2 * pitch] = (FT_Byte)( b / 65536 ); + col[pitch * 2] = (FT_Byte)( b / 65536 ); } } } @@ -296,7 +254,6 @@ ft_memcpy( library->lcd_weights, weights, FT_LCD_FILTER_FIVE_TAPS ); library->lcd_filter_func = ft_lcd_filter_fir; - library->lcd_extra = 2; return FT_Err_Ok; } @@ -319,7 +276,6 @@ { case FT_LCD_FILTER_NONE: library->lcd_filter_func = NULL; - library->lcd_extra = 0; break; case FT_LCD_FILTER_DEFAULT: @@ -327,7 +283,6 @@ default_weights, FT_LCD_FILTER_FIVE_TAPS ); library->lcd_filter_func = ft_lcd_filter_fir; - library->lcd_extra = 2; break; case FT_LCD_FILTER_LIGHT: @@ -335,7 +290,6 @@ light_weights, FT_LCD_FILTER_FIVE_TAPS ); library->lcd_filter_func = ft_lcd_filter_fir; - library->lcd_extra = 2; break; #ifdef USE_LEGACY @@ -343,7 +297,6 @@ case FT_LCD_FILTER_LEGACY: case FT_LCD_FILTER_LEGACY1: library->lcd_filter_func = _ft_lcd_filter_legacy; - library->lcd_extra = 0; break; #endif diff --git a/thirdparty/freetype/src/base/ftmac.c b/thirdparty/freetype/src/base/ftmac.c index 4b92066da3..4e76585e5f 100644 --- a/thirdparty/freetype/src/base/ftmac.c +++ b/thirdparty/freetype/src/base/ftmac.c @@ -1005,7 +1005,7 @@ /* accepts an FSRef instead of a path. */ /* */ /* This function is deprecated because Carbon data types (FSRef) */ - /* are not cross-platform, and thus not suitable for the freetype API. */ + /* are not cross-platform, and thus not suitable for the FreeType API. */ FT_EXPORT_DEF( FT_Error ) FT_New_Face_From_FSRef( FT_Library library, const FSRef* ref, diff --git a/thirdparty/freetype/src/base/ftmm.c b/thirdparty/freetype/src/base/ftmm.c index 2cb56a39be..43877ece45 100644 --- a/thirdparty/freetype/src/base/ftmm.c +++ b/thirdparty/freetype/src/base/ftmm.c @@ -158,7 +158,7 @@ /* check of `face' delayed to `ft_face_get_mm_service' */ - if ( !coords ) + if ( num_coords && !coords ) return FT_THROW( Invalid_Argument ); error = ft_face_get_mm_service( face, &service ); @@ -194,7 +194,7 @@ /* check of `face' delayed to `ft_face_get_mm_service' */ - if ( !coords ) + if ( num_coords && !coords ) return FT_THROW( Invalid_Argument ); error = ft_face_get_mm_service( face, &service_mm ); @@ -266,7 +266,7 @@ /* check of `face' delayed to `ft_face_get_mm_service' */ - if ( !coords ) + if ( num_coords && !coords ) return FT_THROW( Invalid_Argument ); error = ft_face_get_mm_service( face, &service_mm ); @@ -313,7 +313,7 @@ /* check of `face' delayed to `ft_face_get_mm_service' */ - if ( !coords ) + if ( num_coords && !coords ) return FT_THROW( Invalid_Argument ); error = ft_face_get_mm_service( face, &service_mm ); @@ -402,4 +402,28 @@ } + /* documentation is in ftmm.h */ + + FT_EXPORT_DEF( FT_Error ) + FT_Get_Var_Axis_Flags( FT_MM_Var* master, + FT_UInt axis_index, + FT_UInt* flags ) + { + FT_UShort* axis_flags; + + + if ( !master || !flags ) + return FT_THROW( Invalid_Argument ); + + if ( axis_index >= master->num_axis ) + return FT_THROW( Invalid_Argument ); + + /* the axis flags array immediately follows the data of `master' */ + axis_flags = (FT_UShort*)&( master[1] ); + *flags = axis_flags[axis_index]; + + return FT_Err_Ok; + } + + /* END */ diff --git a/thirdparty/freetype/src/base/ftobjs.c b/thirdparty/freetype/src/base/ftobjs.c index 539116e85c..6db8136cfc 100644 --- a/thirdparty/freetype/src/base/ftobjs.c +++ b/thirdparty/freetype/src/base/ftobjs.c @@ -579,34 +579,42 @@ if ( vertical ) { metrics->horiBearingX = FT_PIX_FLOOR( metrics->horiBearingX ); - metrics->horiBearingY = FT_PIX_CEIL ( metrics->horiBearingY ); + metrics->horiBearingY = FT_PIX_CEIL_LONG( metrics->horiBearingY ); - right = FT_PIX_CEIL( metrics->vertBearingX + metrics->width ); - bottom = FT_PIX_CEIL( metrics->vertBearingY + metrics->height ); + right = FT_PIX_CEIL_LONG( ADD_LONG( metrics->vertBearingX, + metrics->width ) ); + bottom = FT_PIX_CEIL_LONG( ADD_LONG( metrics->vertBearingY, + metrics->height ) ); metrics->vertBearingX = FT_PIX_FLOOR( metrics->vertBearingX ); metrics->vertBearingY = FT_PIX_FLOOR( metrics->vertBearingY ); - metrics->width = right - metrics->vertBearingX; - metrics->height = bottom - metrics->vertBearingY; + metrics->width = SUB_LONG( right, + metrics->vertBearingX ); + metrics->height = SUB_LONG( bottom, + metrics->vertBearingY ); } else { metrics->vertBearingX = FT_PIX_FLOOR( metrics->vertBearingX ); metrics->vertBearingY = FT_PIX_FLOOR( metrics->vertBearingY ); - right = FT_PIX_CEIL ( metrics->horiBearingX + metrics->width ); - bottom = FT_PIX_FLOOR( metrics->horiBearingY - metrics->height ); + right = FT_PIX_CEIL_LONG( ADD_LONG( metrics->horiBearingX, + metrics->width ) ); + bottom = FT_PIX_FLOOR( SUB_LONG( metrics->horiBearingY, + metrics->height ) ); metrics->horiBearingX = FT_PIX_FLOOR( metrics->horiBearingX ); - metrics->horiBearingY = FT_PIX_CEIL ( metrics->horiBearingY ); + metrics->horiBearingY = FT_PIX_CEIL_LONG( metrics->horiBearingY ); - metrics->width = right - metrics->horiBearingX; - metrics->height = metrics->horiBearingY - bottom; + metrics->width = SUB_LONG( right, + metrics->horiBearingX ); + metrics->height = SUB_LONG( metrics->horiBearingY, + bottom ); } - metrics->horiAdvance = FT_PIX_ROUND( metrics->horiAdvance ); - metrics->vertAdvance = FT_PIX_ROUND( metrics->vertAdvance ); + metrics->horiAdvance = FT_PIX_ROUND_LONG( metrics->horiAdvance ); + metrics->vertAdvance = FT_PIX_ROUND_LONG( metrics->vertAdvance ); } #endif /* GRID_FIT_METRICS */ @@ -4549,7 +4557,7 @@ if ( !clazz ) return FT_THROW( Invalid_Argument ); - /* check freetype version */ + /* check FreeType version */ if ( clazz->module_requires > FREETYPE_VER_FIXED ) return FT_THROW( Invalid_Version ); @@ -4973,10 +4981,6 @@ goto Fail; #endif - /* we don't use raster_pool anymore. */ - library->raster_pool_size = 0; - library->raster_pool = NULL; - library->version_major = FREETYPE_MAJOR; library->version_minor = FREETYPE_MINOR; library->version_patch = FREETYPE_PATCH; diff --git a/thirdparty/freetype/src/base/ftoutln.c b/thirdparty/freetype/src/base/ftoutln.c index 464a066dcc..9ceb9cf1ba 100644 --- a/thirdparty/freetype/src/base/ftoutln.c +++ b/thirdparty/freetype/src/base/ftoutln.c @@ -1088,7 +1088,8 @@ v_cur.x = points[n].x >> xshift; v_cur.y = points[n].y >> yshift; - area += ( v_cur.y - v_prev.y ) * ( v_cur.x + v_prev.x ); + area = ADD_LONG( area, + ( v_cur.y - v_prev.y ) * ( v_cur.x + v_prev.x ) ); v_prev = v_cur; } diff --git a/thirdparty/freetype/src/base/ftrfork.c b/thirdparty/freetype/src/base/ftrfork.c index f7b81375dd..f5ad2874d8 100644 --- a/thirdparty/freetype/src/base/ftrfork.c +++ b/thirdparty/freetype/src/base/ftrfork.c @@ -271,7 +271,13 @@ if ( FT_STREAM_SKIP( 4 ) ) /* mbz */ goto Exit; - if ( ref[j].res_id < 0 || temp < 0 ) + /* + * According to Inside Macintosh: More Macintosh Toolbox, + * "Resource IDs" (1-46), there are some reserved IDs. + * However, FreeType2 is not a font synthesizer, no need + * to check the acceptable resource ID. + */ + if ( temp < 0 ) { error = FT_THROW( Invalid_Table ); goto Exit; @@ -281,7 +287,7 @@ FT_TRACE3(( " [%d]:" " resource_id=0x%04x, offset=0x%08x\n", - j, ref[j].res_id, ref[j].offset )); + j, (FT_UShort)ref[j].res_id, ref[j].offset )); } if ( sort_by_res_id ) diff --git a/thirdparty/freetype/src/base/ftsynth.c b/thirdparty/freetype/src/base/ftsynth.c index 66dae6037a..5cf386f48d 100644 --- a/thirdparty/freetype/src/base/ftsynth.c +++ b/thirdparty/freetype/src/base/ftsynth.c @@ -123,7 +123,7 @@ /* * XXX: overflow check for 16-bit system, for compatibility - * with FT_GlyphSlot_Embolden() since freetype-2.1.10. + * with FT_GlyphSlot_Embolden() since FreeType 2.1.10. * unfortunately, this function return no informations * about the cause of error. */ diff --git a/thirdparty/freetype/src/base/ftutil.c b/thirdparty/freetype/src/base/ftutil.c index dccc209f4d..7bd5bee87c 100644 --- a/thirdparty/freetype/src/base/ftutil.c +++ b/thirdparty/freetype/src/base/ftutil.c @@ -135,7 +135,7 @@ ft_mem_free( memory, block ); block = NULL; } - else if ( new_count > FT_INT_MAX/item_size ) + else if ( new_count > FT_INT_MAX / item_size ) { error = FT_THROW( Array_Too_Large ); } @@ -143,13 +143,15 @@ { FT_ASSERT( !block ); - block = ft_mem_alloc( memory, new_count*item_size, &error ); + block = memory->alloc( memory, new_count * item_size ); + if ( block == NULL ) + error = FT_THROW( Out_Of_Memory ); } else { FT_Pointer block2; - FT_Long cur_size = cur_count*item_size; - FT_Long new_size = new_count*item_size; + FT_Long cur_size = cur_count * item_size; + FT_Long new_size = new_count * item_size; block2 = memory->realloc( memory, cur_size, new_size, block ); diff --git a/thirdparty/freetype/src/bdf/bdfdrivr.c b/thirdparty/freetype/src/bdf/bdfdrivr.c index a2242be014..fb77810007 100644 --- a/thirdparty/freetype/src/bdf/bdfdrivr.c +++ b/thirdparty/freetype/src/bdf/bdfdrivr.c @@ -373,7 +373,7 @@ THE SOFTWARE. /* we have a bdf font: let's construct the face object */ face->bdffont = font; - /* BDF could not have multiple face in single font file. + /* BDF cannot have multiple faces in a single font file. * XXX: non-zero face_index is already invalid argument, but * Type1, Type42 driver has a convention to return * an invalid argument error when the font could be @@ -437,46 +437,156 @@ THE SOFTWARE. { FT_Bitmap_Size* bsize = bdfface->available_sizes; FT_Short resolution_x = 0, resolution_y = 0; + long value; FT_ZERO( bsize ); + /* sanity checks */ + if ( font->font_ascent > 0x7FFF || font->font_ascent < -0x7FFF ) + { + font->font_ascent = font->font_ascent < 0 ? -0x7FFF : 0x7FFF; + FT_TRACE0(( "BDF_Face_Init: clamping font ascent to value %d\n", + font->font_ascent )); + } + if ( font->font_descent > 0x7FFF || font->font_descent < -0x7FFF ) + { + font->font_descent = font->font_descent < 0 ? -0x7FFF : 0x7FFF; + FT_TRACE0(( "BDF_Face_Init: clamping font descent to value %d\n", + font->font_descent )); + } + bsize->height = (FT_Short)( font->font_ascent + font->font_descent ); prop = bdf_get_font_property( font, "AVERAGE_WIDTH" ); if ( prop ) - bsize->width = (FT_Short)( ( prop->value.l + 5 ) / 10 ); + { +#ifdef FT_DEBUG_LEVEL_TRACE + if ( prop->value.l < 0 ) + FT_TRACE0(( "BDF_Face_Init: negative average width\n" )); +#endif + if ( prop->value.l > 0x7FFFL * 10 - 5 || + prop->value.l < -( 0x7FFFL * 10 - 5 ) ) + { + bsize->width = 0x7FFF; + FT_TRACE0(( "BDF_Face_Init: clamping average width to value %d\n", + bsize->width )); + } + else + bsize->width = FT_ABS( (FT_Short)( ( prop->value.l + 5 ) / 10 ) ); + } else - bsize->width = (FT_Short)( bsize->height * 2/3 ); + { + /* this is a heuristical value */ + bsize->width = (FT_Short)FT_MulDiv( bsize->height, 2, 3 ); + } prop = bdf_get_font_property( font, "POINT_SIZE" ); if ( prop ) + { +#ifdef FT_DEBUG_LEVEL_TRACE + if ( prop->value.l < 0 ) + FT_TRACE0(( "BDF_Face_Init: negative point size\n" )); +#endif /* convert from 722.7 decipoints to 72 points per inch */ - bsize->size = - (FT_Pos)( ( prop->value.l * 64 * 7200 + 36135L ) / 72270L ); + if ( prop->value.l > 0x504C2L || /* 0x7FFF * 72270/7200 */ + prop->value.l < -0x504C2L ) + { + bsize->size = 0x7FFF; + FT_TRACE0(( "BDF_Face_Init: clamping point size to value %d\n", + bsize->size )); + } + else + bsize->size = FT_MulDiv( FT_ABS( prop->value.l ), + 64 * 7200, + 72270L ); + } + else if ( font->point_size ) + { + if ( font->point_size > 0x7FFF ) + { + bsize->size = 0x7FFF; + FT_TRACE0(( "BDF_Face_Init: clamping point size to value %d\n", + bsize->size )); + } + else + bsize->size = (FT_Pos)font->point_size << 6; + } else - bsize->size = bsize->width << 6; + { + /* this is a heuristical value */ + bsize->size = bsize->width * 64; + } prop = bdf_get_font_property( font, "PIXEL_SIZE" ); if ( prop ) - bsize->y_ppem = (FT_Short)prop->value.l << 6; + { +#ifdef FT_DEBUG_LEVEL_TRACE + if ( prop->value.l < 0 ) + FT_TRACE0(( "BDF_Face_Init: negative pixel size\n" )); +#endif + if ( prop->value.l > 0x7FFF || prop->value.l < -0x7FFF ) + { + bsize->y_ppem = 0x7FFF << 6; + FT_TRACE0(( "BDF_Face_Init: clamping pixel size to value %d\n", + bsize->y_ppem )); + } + else + bsize->y_ppem = FT_ABS( (FT_Short)prop->value.l ) << 6; + } prop = bdf_get_font_property( font, "RESOLUTION_X" ); if ( prop ) - resolution_x = (FT_Short)prop->value.l; + value = prop->value.l; + else + value = (long)font->resolution_x; + if ( value ) + { +#ifdef FT_DEBUG_LEVEL_TRACE + if ( value < 0 ) + FT_TRACE0(( "BDF_Face_Init: negative X resolution\n" )); +#endif + if ( value > 0x7FFF || value < -0x7FFF ) + { + resolution_x = 0x7FFF; + FT_TRACE0(( "BDF_Face_Init: clamping X resolution to value %d\n", + resolution_x )); + } + else + resolution_x = FT_ABS( (FT_Short)value ); + } prop = bdf_get_font_property( font, "RESOLUTION_Y" ); if ( prop ) - resolution_y = (FT_Short)prop->value.l; + value = prop->value.l; + else + value = (long)font->resolution_y; + if ( value ) + { +#ifdef FT_DEBUG_LEVEL_TRACE + if ( value < 0 ) + FT_TRACE0(( "BDF_Face_Init: negative Y resolution\n" )); +#endif + if ( value > 0x7FFF || value < -0x7FFF ) + { + resolution_y = 0x7FFF; + FT_TRACE0(( "BDF_Face_Init: clamping Y resolution to value %d\n", + resolution_y )); + } + else + resolution_y = FT_ABS( (FT_Short)value ); + } if ( bsize->y_ppem == 0 ) { bsize->y_ppem = bsize->size; if ( resolution_y ) - bsize->y_ppem = bsize->y_ppem * resolution_y / 72; + bsize->y_ppem = FT_MulDiv( bsize->y_ppem, resolution_y, 72 ); } if ( resolution_x && resolution_y ) - bsize->x_ppem = bsize->y_ppem * resolution_x / resolution_y; + bsize->x_ppem = FT_MulDiv( bsize->y_ppem, + resolution_x, + resolution_y ); else bsize->x_ppem = bsize->y_ppem; } @@ -545,7 +655,11 @@ THE SOFTWARE. if ( !ft_strcmp( s, "10646" ) || ( !ft_strcmp( s, "8859" ) && !ft_strcmp( face->charset_encoding, "1" ) ) ) - unicode_charmap = 1; + unicode_charmap = 1; + /* another name for ASCII */ + else if ( !ft_strcmp( s, "646.1991" ) && + !ft_strcmp( face->charset_encoding, "IRV" ) ) + unicode_charmap = 1; } { @@ -566,12 +680,6 @@ THE SOFTWARE. } error = FT_CMap_New( &bdf_cmap_class, NULL, &charmap, NULL ); - -#if 0 - /* Select default charmap */ - if ( bdfface->num_charmaps ) - bdfface->charmap = bdfface->charmaps[0]; -#endif } goto Exit; diff --git a/thirdparty/freetype/src/bdf/bdflib.c b/thirdparty/freetype/src/bdf/bdflib.c index 7fd95a7385..bf10887fd4 100644 --- a/thirdparty/freetype/src/bdf/bdflib.c +++ b/thirdparty/freetype/src/bdf/bdflib.c @@ -704,7 +704,15 @@ return 0; for ( v = 0; sbitset( ddigits, *s ); s++ ) - v = v * 10 + a2i[(int)*s]; + { + if ( v < ( ULONG_MAX - 9 ) / 10 ) + v = v * 10 + a2i[(int)*s]; + else + { + v = ULONG_MAX; + break; + } + } return v; } @@ -729,7 +737,15 @@ } for ( v = 0; sbitset( ddigits, *s ); s++ ) - v = v * 10 + a2i[(int)*s]; + { + if ( v < ( LONG_MAX - 9 ) / 10 ) + v = v * 10 + a2i[(int)*s]; + else + { + v = LONG_MAX; + break; + } + } return ( !neg ) ? v : -v; } @@ -746,7 +762,15 @@ return 0; for ( v = 0; sbitset( ddigits, *s ); s++ ) - v = (unsigned short)( v * 10 + a2i[(int)*s] ); + { + if ( v < ( USHRT_MAX - 9 ) / 10 ) + v = (unsigned short)( v * 10 + a2i[(int)*s] ); + else + { + v = USHRT_MAX; + break; + } + } return v; } @@ -771,7 +795,15 @@ } for ( v = 0; sbitset( ddigits, *s ); s++ ) - v = (short)( v * 10 + a2i[(int)*s] ); + { + if ( v < ( SHRT_MAX - 9 ) / 10 ) + v = (short)( v * 10 + a2i[(int)*s] ); + else + { + v = SHRT_MAX; + break; + } + } return (short)( ( !neg ) ? v : -v ); } diff --git a/thirdparty/freetype/src/cache/ftcbasic.c b/thirdparty/freetype/src/cache/ftcbasic.c index 289bd5c430..e804776ab4 100644 --- a/thirdparty/freetype/src/cache/ftcbasic.c +++ b/thirdparty/freetype/src/cache/ftcbasic.c @@ -304,10 +304,18 @@ if ( anode ) *anode = NULL; - if ( (FT_ULong)( type->flags - FT_INT_MIN ) > FT_UINT_MAX ) + /* + * Internal `FTC_BasicAttr->load_flags' is of type `FT_UInt', + * but public `FT_ImageType->flags' is of type `FT_Int32'. + * + * On 16bit systems, higher bits of type->flags cannot be handled. + */ +#if 0xFFFFFFFFUL > FT_UINT_MAX + if ( (type->flags & (FT_ULong)FT_UINT_MAX) ) FT_TRACE1(( "FTC_ImageCache_Lookup:" " higher bits in load_flags 0x%x are dropped\n", (FT_ULong)type->flags & ~((FT_ULong)FT_UINT_MAX) )); +#endif query.attrs.scaler.face_id = type->face_id; query.attrs.scaler.width = type->width; @@ -377,11 +385,18 @@ if ( anode ) *anode = NULL; - /* `FT_Load_Glyph' and `FT_Load_Char' take FT_UInt flags */ + /* + * Internal `FTC_BasicAttr->load_flags' is of type `FT_UInt', + * but public `FT_Face->face_flags' is of type `FT_Long'. + * + * On long > int systems, higher bits of load_flags cannot be handled. + */ +#if FT_ULONG_MAX > FT_UINT_MAX if ( load_flags > FT_UINT_MAX ) FT_TRACE1(( "FTC_ImageCache_LookupScaler:" " higher bits in load_flags 0x%x are dropped\n", load_flags & ~((FT_ULong)FT_UINT_MAX) )); +#endif query.attrs.scaler = scaler[0]; query.attrs.load_flags = (FT_UInt)load_flags; @@ -487,10 +502,18 @@ *ansbit = NULL; - if ( (FT_ULong)( type->flags - FT_INT_MIN ) > FT_UINT_MAX ) + /* + * Internal `FTC_BasicAttr->load_flags' is of type `FT_UInt', + * but public `FT_ImageType->flags' is of type `FT_Int32'. + * + * On 16bit systems, higher bits of type->flags cannot be handled. + */ +#if 0xFFFFFFFFUL > FT_UINT_MAX + if ( (type->flags & (FT_ULong)FT_UINT_MAX) ) FT_TRACE1(( "FTC_ImageCache_Lookup:" " higher bits in load_flags 0x%x are dropped\n", (FT_ULong)type->flags & ~((FT_ULong)FT_UINT_MAX) )); +#endif query.attrs.scaler.face_id = type->face_id; query.attrs.scaler.width = type->width; @@ -562,11 +585,18 @@ *ansbit = NULL; - /* `FT_Load_Glyph' and `FT_Load_Char' take FT_UInt flags */ + /* + * Internal `FTC_BasicAttr->load_flags' is of type `FT_UInt', + * but public `FT_Face->face_flags' is of type `FT_Long'. + * + * On long > int systems, higher bits of load_flags cannot be handled. + */ +#if FT_ULONG_MAX > FT_UINT_MAX if ( load_flags > FT_UINT_MAX ) FT_TRACE1(( "FTC_ImageCache_LookupScaler:" " higher bits in load_flags 0x%x are dropped\n", load_flags & ~((FT_ULong)FT_UINT_MAX) )); +#endif query.attrs.scaler = scaler[0]; query.attrs.load_flags = (FT_UInt)load_flags; diff --git a/thirdparty/freetype/src/cff/cf2blues.c b/thirdparty/freetype/src/cff/cf2blues.c index 250f89e0df..c491f2f9e5 100644 --- a/thirdparty/freetype/src/cff/cf2blues.c +++ b/thirdparty/freetype/src/cff/cf2blues.c @@ -194,8 +194,8 @@ blues->zone[blues->count].csTopEdge = cf2_blueToFixed( blueValues[i + 1] ); - zoneHeight = blues->zone[blues->count].csTopEdge - - blues->zone[blues->count].csBottomEdge; + zoneHeight = SUB_INT32( blues->zone[blues->count].csTopEdge, + blues->zone[blues->count].csBottomEdge ); if ( zoneHeight < 0 ) { @@ -243,8 +243,8 @@ blues->zone[blues->count].csTopEdge = cf2_blueToFixed( otherBlues[i + 1] ); - zoneHeight = blues->zone[blues->count].csTopEdge - - blues->zone[blues->count].csBottomEdge; + zoneHeight = SUB_INT32( blues->zone[blues->count].csTopEdge, + blues->zone[blues->count].csBottomEdge ); if ( zoneHeight < 0 ) { @@ -301,7 +301,7 @@ /* top edge */ flatFamilyEdge = cf2_blueToFixed( familyOtherBlues[j + 1] ); - diff = cf2_fixedAbs( flatEdge - flatFamilyEdge ); + diff = cf2_fixedAbs( SUB_INT32( flatEdge, flatFamilyEdge ) ); if ( diff < minDiff && diff < csUnitsPerPixel ) { @@ -319,7 +319,7 @@ /* top edge */ flatFamilyEdge = cf2_blueToFixed( familyBlues[1] ); - diff = cf2_fixedAbs( flatEdge - flatFamilyEdge ); + diff = cf2_fixedAbs( SUB_INT32( flatEdge, flatFamilyEdge ) ); if ( diff < minDiff && diff < csUnitsPerPixel ) blues->zone[i].csFlatEdge = flatFamilyEdge; @@ -342,7 +342,7 @@ /* adjust edges of top zone upward by twice darkening amount */ flatFamilyEdge += 2 * font->darkenY; /* bottom edge */ - diff = cf2_fixedAbs( flatEdge - flatFamilyEdge ); + diff = cf2_fixedAbs( SUB_INT32( flatEdge, flatFamilyEdge ) ); if ( diff < minDiff && diff < csUnitsPerPixel ) { @@ -408,8 +408,8 @@ /* Note: constant changed from 0.5 to 0.6 to avoid a problem with */ /* 10ppem Arial */ - blues->boost = cf2_floatToFixed( .6 ) - - FT_MulDiv( cf2_floatToFixed ( .6 ), + blues->boost = cf2_doubleToFixed( .6 ) - + FT_MulDiv( cf2_doubleToFixed ( .6 ), blues->scale, blues->blueScale ); if ( blues->boost > 0x7FFF ) @@ -489,17 +489,18 @@ if ( blues->zone[i].bottomZone && cf2_hint_isBottom( bottomHintEdge ) ) { - if ( ( blues->zone[i].csBottomEdge - csFuzz ) <= - bottomHintEdge->csCoord && + if ( SUB_INT32( blues->zone[i].csBottomEdge, csFuzz ) <= + bottomHintEdge->csCoord && bottomHintEdge->csCoord <= - ( blues->zone[i].csTopEdge + csFuzz ) ) + ADD_INT32( blues->zone[i].csTopEdge, csFuzz ) ) { /* bottom edge captured by bottom zone */ if ( blues->suppressOvershoot ) dsNew = blues->zone[i].dsFlatEdge; - else if ( ( blues->zone[i].csTopEdge - bottomHintEdge->csCoord ) >= + else if ( SUB_INT32( blues->zone[i].csTopEdge, + bottomHintEdge->csCoord ) >= blues->blueShift ) { /* guarantee minimum of 1 pixel overshoot */ @@ -514,7 +515,7 @@ dsNew = cf2_fixedRound( bottomHintEdge->dsCoord ); } - dsMove = dsNew - bottomHintEdge->dsCoord; + dsMove = SUB_INT32( dsNew, bottomHintEdge->dsCoord ); captured = TRUE; break; @@ -523,17 +524,18 @@ if ( !blues->zone[i].bottomZone && cf2_hint_isTop( topHintEdge ) ) { - if ( ( blues->zone[i].csBottomEdge - csFuzz ) <= - topHintEdge->csCoord && + if ( SUB_INT32( blues->zone[i].csBottomEdge, csFuzz ) <= + topHintEdge->csCoord && topHintEdge->csCoord <= - ( blues->zone[i].csTopEdge + csFuzz ) ) + ADD_INT32( blues->zone[i].csTopEdge, csFuzz ) ) { /* top edge captured by top zone */ if ( blues->suppressOvershoot ) dsNew = blues->zone[i].dsFlatEdge; - else if ( ( topHintEdge->csCoord - blues->zone[i].csBottomEdge ) >= + else if ( SUB_INT32( topHintEdge->csCoord, + blues->zone[i].csBottomEdge ) >= blues->blueShift ) { /* guarantee minimum of 1 pixel overshoot */ @@ -548,7 +550,7 @@ dsNew = cf2_fixedRound( topHintEdge->dsCoord ); } - dsMove = dsNew - topHintEdge->dsCoord; + dsMove = SUB_INT32( dsNew, topHintEdge->dsCoord ); captured = TRUE; break; @@ -561,13 +563,14 @@ /* move both edges and flag them `locked' */ if ( cf2_hint_isValid( bottomHintEdge ) ) { - bottomHintEdge->dsCoord += dsMove; + bottomHintEdge->dsCoord = ADD_INT32( bottomHintEdge->dsCoord, + dsMove ); cf2_hint_lock( bottomHintEdge ); } if ( cf2_hint_isValid( topHintEdge ) ) { - topHintEdge->dsCoord += dsMove; + topHintEdge->dsCoord = ADD_INT32( topHintEdge->dsCoord, dsMove ); cf2_hint_lock( topHintEdge ); } } diff --git a/thirdparty/freetype/src/cff/cf2blues.h b/thirdparty/freetype/src/cff/cf2blues.h index 96fb60f38d..a6bcd9de57 100644 --- a/thirdparty/freetype/src/cff/cf2blues.h +++ b/thirdparty/freetype/src/cff/cf2blues.h @@ -111,7 +111,7 @@ FT_BEGIN_HEADER * Constant used for hint adjustment and for synthetic em box hint * placement. */ -#define CF2_MIN_COUNTER cf2_floatToFixed( 0.5 ) +#define CF2_MIN_COUNTER cf2_doubleToFixed( 0.5 ) /* shared typedef is in cf2glue.h */ diff --git a/thirdparty/freetype/src/cff/cf2fixed.h b/thirdparty/freetype/src/cff/cf2fixed.h index 2e4b5032fa..a041184bda 100644 --- a/thirdparty/freetype/src/cff/cf2fixed.h +++ b/thirdparty/freetype/src/cff/cf2fixed.h @@ -63,10 +63,10 @@ FT_BEGIN_HEADER ( (FT_Short)( ( (FT_UInt32)(x) + 0x8000U ) >> 16 ) ) #define cf2_fixedRound( x ) \ ( (CF2_Fixed)( ( (FT_UInt32)(x) + 0x8000U ) & 0xFFFF0000UL ) ) -#define cf2_floatToFixed( f ) \ +#define cf2_doubleToFixed( f ) \ ( (CF2_Fixed)( (f) * 65536.0 + 0.5 ) ) #define cf2_fixedAbs( x ) \ - ( (x) < 0 ? -(x) : (x) ) + ( (x) < 0 ? NEG_INT32( x ) : (x) ) #define cf2_fixedFloor( x ) \ ( (CF2_Fixed)( (FT_UInt32)(x) & 0xFFFF0000UL ) ) #define cf2_fixedFraction( x ) \ diff --git a/thirdparty/freetype/src/cff/cf2font.c b/thirdparty/freetype/src/cff/cf2font.c index a86e3619b4..4ac71a8d71 100644 --- a/thirdparty/freetype/src/cff/cf2font.c +++ b/thirdparty/freetype/src/cff/cf2font.c @@ -117,7 +117,7 @@ return; /* protect against range problems and divide by zero */ - if ( emRatio < cf2_floatToFixed( .01 ) ) + if ( emRatio < cf2_doubleToFixed( .01 ) ) return; if ( stemDarkened ) @@ -447,7 +447,7 @@ /* choose a constant for StdHW that depends on font contrast */ stdHW = cf2_getStdHW( decoder ); - if ( stdHW > 0 && font->stdVW > 2 * stdHW ) + if ( stdHW > 0 && font->stdVW > MUL_INT32( 2, stdHW ) ) font->stdHW = FT_DivFix( cf2_intToFixed( 75 ), emRatio ); else { diff --git a/thirdparty/freetype/src/cff/cf2ft.c b/thirdparty/freetype/src/cff/cf2ft.c index eb8472f119..c6c00d1623 100644 --- a/thirdparty/freetype/src/cff/cf2ft.c +++ b/thirdparty/freetype/src/cff/cf2ft.c @@ -267,8 +267,8 @@ if ( *hinted ) { - *x_scale = ( decoder->builder.glyph->x_scale + 32 ) / 64; - *y_scale = ( decoder->builder.glyph->y_scale + 32 ) / 64; + *x_scale = ADD_INT32( decoder->builder.glyph->x_scale, 32 ) / 64; + *y_scale = ADD_INT32( decoder->builder.glyph->y_scale, 32 ) / 64; } else { diff --git a/thirdparty/freetype/src/cff/cf2hints.c b/thirdparty/freetype/src/cff/cf2hints.c index c8f7dfeba6..656eb2cff1 100644 --- a/thirdparty/freetype/src/cff/cf2hints.c +++ b/thirdparty/freetype/src/cff/cf2hints.c @@ -74,8 +74,8 @@ /* cross product of pt1 position from origin with pt2 position from */ /* pt1; we reduce the precision so that the result fits into 32 bits */ - return ( x1 >> 16 ) * ( ( y2 - y1 ) >> 16 ) - - ( y1 >> 16 ) * ( ( x2 - x1 ) >> 16 ); + return ( x1 >> 16 ) * ( SUB_INT32( y2, y1 ) >> 16 ) - + ( y1 >> 16 ) * ( SUB_INT32( x2, x1 ) >> 16 ); } @@ -105,7 +105,7 @@ stemHintArray, indexStemHint ); - width = stemHint->max - stemHint->min; + width = SUB_INT32( stemHint->max, stemHint->min ); if ( width == cf2_intToFixed( -21 ) ) { @@ -185,11 +185,11 @@ /* darkening. Bottoms are not changed; tops are incremented by twice */ /* `darkenY'. */ if ( cf2_hint_isTop( hint ) ) - hint->csCoord += 2 * font->darkenY; + hint->csCoord = ADD_INT32( hint->csCoord, 2 * font->darkenY ); - hint->csCoord += hintOrigin; - hint->scale = scale; - hint->index = indexStemHint; /* index in original stem hint array */ + hint->csCoord = ADD_INT32( hint->csCoord, hintOrigin ); + hint->scale = scale; + hint->index = indexStemHint; /* index in original stem hint array */ /* if original stem hint has been used, use the same position */ if ( hint->flags != 0 && stemHint->used ) @@ -314,6 +314,7 @@ /* start linear search from last hit */ CF2_UInt i = hintmap->lastIndex; + FT_ASSERT( hintmap->lastIndex < CF2_MAX_HINT_EDGES ); /* search up */ @@ -330,9 +331,10 @@ if ( i == 0 && csCoord < hintmap->edge[0].csCoord ) { /* special case for points below first edge: use uniform scale */ - return FT_MulFix( csCoord - hintmap->edge[0].csCoord, - hintmap->scale ) + - hintmap->edge[0].dsCoord; + return ADD_INT32( FT_MulFix( SUB_INT32( csCoord, + hintmap->edge[0].csCoord ), + hintmap->scale ), + hintmap->edge[0].dsCoord ); } else { @@ -340,9 +342,10 @@ * Note: entries with duplicate csCoord are allowed. * Use edge[i], the highest entry where csCoord >= entry[i].csCoord */ - return FT_MulFix( csCoord - hintmap->edge[i].csCoord, - hintmap->edge[i].scale ) + - hintmap->edge[i].dsCoord; + return ADD_INT32( FT_MulFix( SUB_INT32( csCoord, + hintmap->edge[i].csCoord ), + hintmap->edge[i].scale ), + hintmap->edge[i].dsCoord ); } } } @@ -437,14 +440,16 @@ /* is there room to move up? */ /* there is if we are at top of array or the next edge is at or */ /* beyond proposed move up? */ - if ( j >= hintmap->count - 1 || + if ( j >= hintmap->count - 1 || hintmap->edge[j + 1].dsCoord >= - hintmap->edge[j].dsCoord + moveUp + upMinCounter ) + ADD_INT32( hintmap->edge[j].dsCoord, + moveUp + upMinCounter ) ) { /* there is room to move up; is there also room to move down? */ - if ( i == 0 || + if ( i == 0 || hintmap->edge[i - 1].dsCoord <= - hintmap->edge[i].dsCoord + moveDown - downMinCounter ) + ADD_INT32( hintmap->edge[i].dsCoord, + moveDown - downMinCounter ) ) { /* move smaller absolute amount */ move = ( -moveDown < moveUp ) ? moveDown : moveUp; /* optimum */ @@ -455,9 +460,10 @@ else { /* is there room to move down? */ - if ( i == 0 || + if ( i == 0 || hintmap->edge[i - 1].dsCoord <= - hintmap->edge[i].dsCoord + moveDown - downMinCounter ) + ADD_INT32( hintmap->edge[i].dsCoord, + moveDown - downMinCounter ) ) { move = moveDown; /* true if non-optimum move */ @@ -491,9 +497,11 @@ } /* move the edge(s) */ - hintmap->edge[i].dsCoord += move; + hintmap->edge[i].dsCoord = ADD_INT32( hintmap->edge[i].dsCoord, + move ); if ( isPair ) - hintmap->edge[j].dsCoord += move; + hintmap->edge[j].dsCoord = ADD_INT32( hintmap->edge[j].dsCoord, + move ); } /* assert there are no overlaps in device space */ @@ -507,18 +515,20 @@ { if ( hintmap->edge[i].csCoord != hintmap->edge[i - 1].csCoord ) hintmap->edge[i - 1].scale = - FT_DivFix( - hintmap->edge[i].dsCoord - hintmap->edge[i - 1].dsCoord, - hintmap->edge[i].csCoord - hintmap->edge[i - 1].csCoord ); + FT_DivFix( SUB_INT32( hintmap->edge[i].dsCoord, + hintmap->edge[i - 1].dsCoord ), + SUB_INT32( hintmap->edge[i].csCoord, + hintmap->edge[i - 1].csCoord ) ); } if ( isPair ) { if ( hintmap->edge[j].csCoord != hintmap->edge[j - 1].csCoord ) hintmap->edge[j - 1].scale = - FT_DivFix( - hintmap->edge[j].dsCoord - hintmap->edge[j - 1].dsCoord, - hintmap->edge[j].csCoord - hintmap->edge[j - 1].csCoord ); + FT_DivFix( SUB_INT32( hintmap->edge[j].dsCoord, + hintmap->edge[j - 1].dsCoord ), + SUB_INT32( hintmap->edge[j].csCoord, + hintmap->edge[j - 1].csCoord ) ); i += 1; /* skip upper edge on next loop */ } @@ -539,15 +549,18 @@ /* is there room to move up? */ if ( hintmap->edge[j + 1].dsCoord >= - hintmap->edge[j].dsCoord + hintMove->moveUp + CF2_MIN_COUNTER ) + ADD_INT32( hintmap->edge[j].dsCoord, + hintMove->moveUp + CF2_MIN_COUNTER ) ) { /* there is more room now, move edge up */ - hintmap->edge[j].dsCoord += hintMove->moveUp; + hintmap->edge[j].dsCoord = ADD_INT32( hintmap->edge[j].dsCoord, + hintMove->moveUp ); if ( cf2_hint_isPair( &hintmap->edge[j] ) ) { FT_ASSERT( j > 0 ); - hintmap->edge[j - 1].dsCoord += hintMove->moveUp; + hintmap->edge[j - 1].dsCoord = + ADD_INT32( hintmap->edge[j - 1].dsCoord, hintMove->moveUp ); } } } @@ -635,18 +648,19 @@ { /* Use hint map to position the center of stem, and nominal scale */ /* to position the two edges. This preserves the stem width. */ - CF2_Fixed midpoint = cf2_hintmap_map( - hintmap->initialHintMap, - ( secondHintEdge->csCoord + - firstHintEdge->csCoord ) / 2 ); - CF2_Fixed halfWidth = FT_MulFix( - ( secondHintEdge->csCoord - - firstHintEdge->csCoord ) / 2, - hintmap->scale ); - - - firstHintEdge->dsCoord = midpoint - halfWidth; - secondHintEdge->dsCoord = midpoint + halfWidth; + CF2_Fixed midpoint = + cf2_hintmap_map( + hintmap->initialHintMap, + ADD_INT32( secondHintEdge->csCoord, + firstHintEdge->csCoord ) / 2 ); + CF2_Fixed halfWidth = + FT_MulFix( SUB_INT32( secondHintEdge->csCoord, + firstHintEdge->csCoord ) / 2, + hintmap->scale ); + + + firstHintEdge->dsCoord = SUB_INT32( midpoint, halfWidth ); + secondHintEdge->dsCoord = ADD_INT32( midpoint, halfWidth ); } else firstHintEdge->dsCoord = cf2_hintmap_map( hintmap->initialHintMap, @@ -715,7 +729,7 @@ /* insert first edge */ hintmap->edge[indexInsert] = *firstHintEdge; /* copy struct */ - hintmap->count += 1; + hintmap->count += 1; if ( isPair ) { @@ -781,7 +795,7 @@ cf2_arrstack_size( hStemHintArray ) + cf2_arrstack_size( vStemHintArray ) ); if ( !cf2_hintmask_isValid( hintMask ) ) - return; /* too many stem hints */ + return; /* too many stem hints */ } /* begin by clearing the map */ @@ -797,7 +811,7 @@ /* Defense-in-depth. Should never return here. */ if ( bitCount > hintMask->bitCount ) - return; + return; /* synthetic embox hints get highest priority */ if ( font->blues.doEmBoxHints ) @@ -1063,7 +1077,7 @@ cf2_fixedAbs( glyphpath->yOffset ) ); /* .1 character space unit */ - glyphpath->snapThreshold = cf2_floatToFixed( 0.1f ); + glyphpath->snapThreshold = cf2_doubleToFixed( 0.1 ); glyphpath->moveIsPending = TRUE; glyphpath->pathIsOpen = FALSE; @@ -1095,16 +1109,20 @@ FT_Vector pt; /* hinted point in upright DS */ - pt.x = FT_MulFix( glyphpath->scaleX, x ) + - FT_MulFix( glyphpath->scaleC, y ); + pt.x = ADD_INT32( FT_MulFix( glyphpath->scaleX, x ), + FT_MulFix( glyphpath->scaleC, y ) ); pt.y = cf2_hintmap_map( hintmap, y ); - ppt->x = FT_MulFix( glyphpath->font->outerTransform.a, pt.x ) + - FT_MulFix( glyphpath->font->outerTransform.c, pt.y ) + - glyphpath->fractionalTranslation.x; - ppt->y = FT_MulFix( glyphpath->font->outerTransform.b, pt.x ) + - FT_MulFix( glyphpath->font->outerTransform.d, pt.y ) + - glyphpath->fractionalTranslation.y; + ppt->x = ADD_INT32( + FT_MulFix( glyphpath->font->outerTransform.a, pt.x ), + ADD_INT32( + FT_MulFix( glyphpath->font->outerTransform.c, pt.y ), + glyphpath->fractionalTranslation.x ) ); + ppt->y = ADD_INT32( + FT_MulFix( glyphpath->font->outerTransform.b, pt.x ), + ADD_INT32( + FT_MulFix( glyphpath->font->outerTransform.d, pt.y ), + glyphpath->fractionalTranslation.y ) ); } @@ -1154,12 +1172,12 @@ CF2_Fixed denominator, s; - u.x = CF2_CS_SCALE( u2->x - u1->x ); - u.y = CF2_CS_SCALE( u2->y - u1->y ); - v.x = CF2_CS_SCALE( v2->x - v1->x ); - v.y = CF2_CS_SCALE( v2->y - v1->y ); - w.x = CF2_CS_SCALE( v1->x - u1->x ); - w.y = CF2_CS_SCALE( v1->y - u1->y ); + u.x = CF2_CS_SCALE( SUB_INT32( u2->x, u1->x ) ); + u.y = CF2_CS_SCALE( SUB_INT32( u2->y, u1->y ) ); + v.x = CF2_CS_SCALE( SUB_INT32( v2->x, v1->x ) ); + v.y = CF2_CS_SCALE( SUB_INT32( v2->y, v1->y ) ); + w.x = CF2_CS_SCALE( SUB_INT32( v1->x, u1->x ) ); + w.y = CF2_CS_SCALE( SUB_INT32( v1->y, u1->y ) ); denominator = cf2_perp( u, v ); @@ -1168,8 +1186,11 @@ s = FT_DivFix( cf2_perp( w, v ), denominator ); - intersection->x = u1->x + FT_MulFix( s, u2->x - u1->x ); - intersection->y = u1->y + FT_MulFix( s, u2->y - u1->y ); + intersection->x = ADD_INT32( u1->x, + FT_MulFix( s, SUB_INT32( u2->x, u1->x ) ) ); + intersection->y = ADD_INT32( u1->y, + FT_MulFix( s, SUB_INT32( u2->y, u1->y ) ) ); + /* * Special case snapping for horizontal and vertical lines. @@ -1180,25 +1201,29 @@ * */ - if ( u1->x == u2->x && - cf2_fixedAbs( intersection->x - u1->x ) < glyphpath->snapThreshold ) + if ( u1->x == u2->x && + cf2_fixedAbs( SUB_INT32( intersection->x, + u1->x ) ) < glyphpath->snapThreshold ) intersection->x = u1->x; - if ( u1->y == u2->y && - cf2_fixedAbs( intersection->y - u1->y ) < glyphpath->snapThreshold ) + if ( u1->y == u2->y && + cf2_fixedAbs( SUB_INT32( intersection->y, + u1->y ) ) < glyphpath->snapThreshold ) intersection->y = u1->y; - if ( v1->x == v2->x && - cf2_fixedAbs( intersection->x - v1->x ) < glyphpath->snapThreshold ) + if ( v1->x == v2->x && + cf2_fixedAbs( SUB_INT32( intersection->x, + v1->x ) ) < glyphpath->snapThreshold ) intersection->x = v1->x; - if ( v1->y == v2->y && - cf2_fixedAbs( intersection->y - v1->y ) < glyphpath->snapThreshold ) + if ( v1->y == v2->y && + cf2_fixedAbs( SUB_INT32( intersection->y, + v1->y ) ) < glyphpath->snapThreshold ) intersection->y = v1->y; /* limit the intersection distance from midpoint of u2 and v1 */ - if ( cf2_fixedAbs( intersection->x - ( u2->x + v1->x ) / 2 ) > - glyphpath->miterLimit || - cf2_fixedAbs( intersection->y - ( u2->y + v1->y ) / 2 ) > - glyphpath->miterLimit ) + if ( cf2_fixedAbs( intersection->x - ADD_INT32( u2->x, v1->x ) / 2 ) > + glyphpath->miterLimit || + cf2_fixedAbs( intersection->y - ADD_INT32( u2->y, v1->y ) / 2 ) > + glyphpath->miterLimit ) return FALSE; return TRUE; @@ -1446,16 +1471,16 @@ CF2_Fixed* x, CF2_Fixed* y ) { - CF2_Fixed dx = x2 - x1; - CF2_Fixed dy = y2 - y1; + CF2_Fixed dx = SUB_INT32( x2, x1 ); + CF2_Fixed dy = SUB_INT32( y2, y1 ); /* note: negative offsets don't work here; negate deltas to change */ /* quadrants, below */ if ( glyphpath->font->reverseWinding ) { - dx = -dx; - dy = -dy; + dx = NEG_INT32( dx ); + dy = NEG_INT32( dy ); } *x = *y = 0; @@ -1464,8 +1489,9 @@ return; /* add momentum for this path element */ - glyphpath->callbacks->windingMomentum += - cf2_getWindingMomentum( x1, y1, x2, y2 ); + glyphpath->callbacks->windingMomentum = + ADD_INT32( glyphpath->callbacks->windingMomentum, + cf2_getWindingMomentum( x1, y1, x2, y2 ) ); /* note: allow mixed integer and fixed multiplication here */ if ( dx >= 0 ) @@ -1474,13 +1500,13 @@ { /* first quadrant, +x +y */ - if ( dx > 2 * dy ) + if ( dx > MUL_INT32( 2, dy ) ) { /* +x */ *x = 0; *y = 0; } - else if ( dy > 2 * dx ) + else if ( dy > MUL_INT32( 2, dx ) ) { /* +y */ *x = glyphpath->xOffset; @@ -1489,9 +1515,9 @@ else { /* +x +y */ - *x = FT_MulFix( cf2_floatToFixed( 0.7 ), + *x = FT_MulFix( cf2_doubleToFixed( 0.7 ), glyphpath->xOffset ); - *y = FT_MulFix( cf2_floatToFixed( 1.0 - 0.7 ), + *y = FT_MulFix( cf2_doubleToFixed( 1.0 - 0.7 ), glyphpath->yOffset ); } } @@ -1499,24 +1525,24 @@ { /* fourth quadrant, +x -y */ - if ( dx > -2 * dy ) + if ( dx > MUL_INT32( -2, dy ) ) { /* +x */ *x = 0; *y = 0; } - else if ( -dy > 2 * dx ) + else if ( NEG_INT32( dy ) > MUL_INT32( 2, dx ) ) { /* -y */ - *x = -glyphpath->xOffset; + *x = NEG_INT32( glyphpath->xOffset ); *y = glyphpath->yOffset; } else { /* +x -y */ - *x = FT_MulFix( cf2_floatToFixed( -0.7 ), + *x = FT_MulFix( cf2_doubleToFixed( -0.7 ), glyphpath->xOffset ); - *y = FT_MulFix( cf2_floatToFixed( 1.0 - 0.7 ), + *y = FT_MulFix( cf2_doubleToFixed( 1.0 - 0.7 ), glyphpath->yOffset ); } } @@ -1527,13 +1553,13 @@ { /* second quadrant, -x +y */ - if ( -dx > 2 * dy ) + if ( NEG_INT32( dx ) > MUL_INT32( 2, dy ) ) { /* -x */ *x = 0; - *y = 2 * glyphpath->yOffset; + *y = MUL_INT32( 2, glyphpath->yOffset ); } - else if ( dy > -2 * dx ) + else if ( dy > MUL_INT32( -2, dx ) ) { /* +y */ *x = glyphpath->xOffset; @@ -1542,9 +1568,9 @@ else { /* -x +y */ - *x = FT_MulFix( cf2_floatToFixed( 0.7 ), + *x = FT_MulFix( cf2_doubleToFixed( 0.7 ), glyphpath->xOffset ); - *y = FT_MulFix( cf2_floatToFixed( 1.0 + 0.7 ), + *y = FT_MulFix( cf2_doubleToFixed( 1.0 + 0.7 ), glyphpath->yOffset ); } } @@ -1552,24 +1578,24 @@ { /* third quadrant, -x -y */ - if ( -dx > -2 * dy ) + if ( NEG_INT32( dx ) > MUL_INT32( -2, dy ) ) { /* -x */ *x = 0; - *y = 2 * glyphpath->yOffset; + *y = MUL_INT32( 2, glyphpath->yOffset ); } - else if ( -dy > -2 * dx ) + else if ( NEG_INT32( dy ) > MUL_INT32( -2, dx ) ) { /* -y */ - *x = -glyphpath->xOffset; + *x = NEG_INT32( glyphpath->xOffset ); *y = glyphpath->yOffset; } else { /* -x -y */ - *x = FT_MulFix( cf2_floatToFixed( -0.7 ), + *x = FT_MulFix( cf2_doubleToFixed( -0.7 ), glyphpath->xOffset ); - *y = FT_MulFix( cf2_floatToFixed( 1.0 + 0.7 ), + *y = FT_MulFix( cf2_doubleToFixed( 1.0 + 0.7 ), glyphpath->yOffset ); } } @@ -1675,10 +1701,10 @@ &yOffset ); /* construct offset points */ - P0.x = glyphpath->currentCS.x + xOffset; - P0.y = glyphpath->currentCS.y + yOffset; - P1.x = x + xOffset; - P1.y = y + yOffset; + P0.x = ADD_INT32( glyphpath->currentCS.x, xOffset ); + P0.y = ADD_INT32( glyphpath->currentCS.y, yOffset ); + P1.x = ADD_INT32( x, xOffset ); + P1.y = ADD_INT32( y, yOffset ); if ( glyphpath->moveIsPending ) { @@ -1753,19 +1779,20 @@ &yOffset3 ); /* add momentum from the middle segment */ - glyphpath->callbacks->windingMomentum += - cf2_getWindingMomentum( x1, y1, x2, y2 ); + glyphpath->callbacks->windingMomentum = + ADD_INT32( glyphpath->callbacks->windingMomentum, + cf2_getWindingMomentum( x1, y1, x2, y2 ) ); /* construct offset points */ - P0.x = glyphpath->currentCS.x + xOffset1; - P0.y = glyphpath->currentCS.y + yOffset1; - P1.x = x1 + xOffset1; - P1.y = y1 + yOffset1; + P0.x = ADD_INT32( glyphpath->currentCS.x, xOffset1 ); + P0.y = ADD_INT32( glyphpath->currentCS.y, yOffset1 ); + P1.x = ADD_INT32( x1, xOffset1 ); + P1.y = ADD_INT32( y1, yOffset1 ); /* note: preserve angle of final segment by using offset3 at both ends */ - P2.x = x2 + xOffset3; - P2.y = y2 + yOffset3; - P3.x = x3 + xOffset3; - P3.y = y3 + yOffset3; + P2.x = ADD_INT32( x2, xOffset3 ); + P2.y = ADD_INT32( y2, yOffset3 ); + P3.x = ADD_INT32( x3, xOffset3 ); + P3.y = ADD_INT32( y3, yOffset3 ); if ( glyphpath->moveIsPending ) { diff --git a/thirdparty/freetype/src/cff/cf2intrp.c b/thirdparty/freetype/src/cff/cf2intrp.c index 40bd9059a1..a816280748 100644 --- a/thirdparty/freetype/src/cff/cf2intrp.c +++ b/thirdparty/freetype/src/cff/cf2intrp.c @@ -304,10 +304,12 @@ CF2_StemHintRec stemhint; - stemhint.min = - position += cf2_stack_getReal( opStack, i ); - stemhint.max = - position += cf2_stack_getReal( opStack, i + 1 ); + stemhint.min = + position = ADD_INT32( position, + cf2_stack_getReal( opStack, i ) ); + stemhint.max = + position = ADD_INT32( position, + cf2_stack_getReal( opStack, i + 1 ) ); stemhint.used = FALSE; stemhint.maxDS = @@ -348,7 +350,8 @@ { vals[i + 2] = vals[i]; if ( readFromStack[i] ) - vals[i + 2] += cf2_stack_getReal( opStack, idx++ ); + vals[i + 2] = ADD_INT32( vals[i + 2], cf2_stack_getReal( opStack, + idx++ ) ); } if ( isHFlex ) @@ -356,31 +359,34 @@ if ( doConditionalLastRead ) { - FT_Bool lastIsX = (FT_Bool)( cf2_fixedAbs( vals[10] - *curX ) > - cf2_fixedAbs( vals[11] - *curY ) ); + FT_Bool lastIsX = (FT_Bool)( + cf2_fixedAbs( SUB_INT32( vals[10], *curX ) ) > + cf2_fixedAbs( SUB_INT32( vals[11], *curY ) ) ); CF2_Fixed lastVal = cf2_stack_getReal( opStack, idx ); if ( lastIsX ) { - vals[12] = vals[10] + lastVal; + vals[12] = ADD_INT32( vals[10], lastVal ); vals[13] = *curY; } else { vals[12] = *curX; - vals[13] = vals[11] + lastVal; + vals[13] = ADD_INT32( vals[11], lastVal ); } } else { if ( readFromStack[10] ) - vals[12] = vals[10] + cf2_stack_getReal( opStack, idx++ ); + vals[12] = ADD_INT32( vals[10], + cf2_stack_getReal( opStack, idx++ ) ); else vals[12] = *curX; if ( readFromStack[11] ) - vals[13] = vals[11] + cf2_stack_getReal( opStack, idx ); + vals[13] = ADD_INT32( vals[11], + cf2_stack_getReal( opStack, idx ) ); else vals[13] = *curY; } @@ -426,7 +432,10 @@ for ( j = 1; j < blend->lenBV; j++ ) - sum += FT_MulFix( *weight++, cf2_stack_getReal( opStack, delta++ ) ); + sum = ADD_INT32( sum, + FT_MulFix( *weight++, + cf2_stack_getReal( opStack, + delta++ ) ) ); /* store blended result */ cf2_stack_setReal( opStack, i + base, sum ); @@ -759,7 +768,8 @@ FT_TRACE4(( " vmoveto\n" )); if ( cf2_stack_count( opStack ) > 1 && !haveWidth ) - *width = cf2_stack_getReal( opStack, 0 ) + nominalWidthX; + *width = ADD_INT32( cf2_stack_getReal( opStack, 0 ), + nominalWidthX ); /* width is defined or default after this */ haveWidth = TRUE; @@ -767,7 +777,7 @@ if ( font->decoder->width_only ) goto exit; - curY += cf2_stack_popFixed( opStack ); + curY = ADD_INT32( curY, cf2_stack_popFixed( opStack ) ); cf2_glyphpath_moveTo( &glyphPath, curX, curY ); @@ -783,8 +793,10 @@ for ( idx = 0; idx < count; idx += 2 ) { - curX += cf2_stack_getReal( opStack, idx + 0 ); - curY += cf2_stack_getReal( opStack, idx + 1 ); + curX = ADD_INT32( curX, cf2_stack_getReal( opStack, + idx + 0 ) ); + curY = ADD_INT32( curY, cf2_stack_getReal( opStack, + idx + 1 ) ); cf2_glyphpath_lineTo( &glyphPath, curX, curY ); } @@ -810,9 +822,9 @@ if ( isX ) - curX += v; + curX = ADD_INT32( curX, v ); else - curY += v; + curY = ADD_INT32( curY, v ); isX = !isX; @@ -835,13 +847,15 @@ while ( idx + 6 <= count ) { - CF2_Fixed x1 = cf2_stack_getReal( opStack, idx + 0 ) + curX; - CF2_Fixed y1 = cf2_stack_getReal( opStack, idx + 1 ) + curY; - CF2_Fixed x2 = cf2_stack_getReal( opStack, idx + 2 ) + x1; - CF2_Fixed y2 = cf2_stack_getReal( opStack, idx + 3 ) + y1; - CF2_Fixed x3 = cf2_stack_getReal( opStack, idx + 4 ) + x2; - CF2_Fixed y3 = cf2_stack_getReal( opStack, idx + 5 ) + y2; + CF2_Fixed x1, y1, x2, y2, x3, y3; + + x1 = ADD_INT32( cf2_stack_getReal( opStack, idx + 0 ), curX ); + y1 = ADD_INT32( cf2_stack_getReal( opStack, idx + 1 ), curY ); + x2 = ADD_INT32( cf2_stack_getReal( opStack, idx + 2 ), x1 ); + y2 = ADD_INT32( cf2_stack_getReal( opStack, idx + 3 ), y1 ); + x3 = ADD_INT32( cf2_stack_getReal( opStack, idx + 4 ), x2 ); + y3 = ADD_INT32( cf2_stack_getReal( opStack, idx + 5 ), y2 ); cf2_glyphpath_curveTo( &glyphPath, x1, y1, x2, y2, x3, y3 ); @@ -852,8 +866,10 @@ if ( op1 == cf2_cmdRCURVELINE ) { - curX += cf2_stack_getReal( opStack, idx + 0 ); - curY += cf2_stack_getReal( opStack, idx + 1 ); + curX = ADD_INT32( curX, cf2_stack_getReal( opStack, + idx + 0 ) ); + curY = ADD_INT32( curY, cf2_stack_getReal( opStack, + idx + 1 ) ); cf2_glyphpath_lineTo( &glyphPath, curX, curY ); } @@ -1129,7 +1145,10 @@ arg = cf2_stack_popFixed( opStack ); - cf2_stack_pushFixed( opStack, FT_ABS( arg ) ); + if ( arg < -CF2_FIXED_MAX ) + cf2_stack_pushFixed( opStack, CF2_FIXED_MAX ); + else + cf2_stack_pushFixed( opStack, FT_ABS( arg ) ); } continue; /* do not clear the stack */ @@ -1144,7 +1163,9 @@ summand2 = cf2_stack_popFixed( opStack ); summand1 = cf2_stack_popFixed( opStack ); - cf2_stack_pushFixed( opStack, summand1 + summand2 ); + cf2_stack_pushFixed( opStack, + ADD_INT32( summand1, + summand2 ) ); } continue; /* do not clear the stack */ @@ -1159,7 +1180,8 @@ subtrahend = cf2_stack_popFixed( opStack ); minuend = cf2_stack_popFixed( opStack ); - cf2_stack_pushFixed( opStack, minuend - subtrahend ); + cf2_stack_pushFixed( opStack, + SUB_INT32( minuend, subtrahend ) ); } continue; /* do not clear the stack */ @@ -1174,7 +1196,8 @@ divisor = cf2_stack_popFixed( opStack ); dividend = cf2_stack_popFixed( opStack ); - cf2_stack_pushFixed( opStack, FT_DivFix( dividend, divisor ) ); + cf2_stack_pushFixed( opStack, + FT_DivFix( dividend, divisor ) ); } continue; /* do not clear the stack */ @@ -1187,7 +1210,10 @@ arg = cf2_stack_popFixed( opStack ); - cf2_stack_pushFixed( opStack, -arg ); + if ( arg < -CF2_FIXED_MAX ) + cf2_stack_pushFixed( opStack, CF2_FIXED_MAX ); + else + cf2_stack_pushFixed( opStack, -arg ); } continue; /* do not clear the stack */ @@ -1257,7 +1283,8 @@ arg2 = cf2_stack_popFixed( opStack ); arg1 = cf2_stack_popFixed( opStack ); - cf2_stack_pushFixed( opStack, cond1 <= cond2 ? arg1 : arg2 ); + cf2_stack_pushFixed( opStack, + cond1 <= cond2 ? arg1 : arg2 ); } continue; /* do not clear the stack */ @@ -1291,7 +1318,8 @@ factor2 = cf2_stack_popFixed( opStack ); factor1 = cf2_stack_popFixed( opStack ); - cf2_stack_pushFixed( opStack, FT_MulFix( factor1, factor2 ) ); + cf2_stack_pushFixed( opStack, + FT_MulFix( factor1, factor2 ) ); } continue; /* do not clear the stack */ @@ -1305,7 +1333,9 @@ arg = cf2_stack_popFixed( opStack ); if ( arg > 0 ) { - FT_Fixed root = arg; + /* use a start value that doesn't make */ + /* the algorithm's addition overflow */ + FT_Fixed root = arg < 10 ? arg : arg >> 1; FT_Fixed new_root; @@ -1369,7 +1399,8 @@ if ( size > 0 ) { - /* for `cf2_stack_getReal', index 0 is bottom of stack */ + /* for `cf2_stack_getReal', */ + /* index 0 is bottom of stack */ CF2_UInt gr_idx; @@ -1381,7 +1412,8 @@ gr_idx = size - 1 - (CF2_UInt)idx; cf2_stack_pushFixed( opStack, - cf2_stack_getReal( opStack, gr_idx ) ); + cf2_stack_getReal( opStack, + gr_idx ) ); } } continue; /* do not clear the stack */ @@ -1416,7 +1448,8 @@ cf2_stack_count( opStack ) == 5 ) { if ( !haveWidth ) - *width = cf2_stack_getReal( opStack, 0 ) + nominalWidthX; + *width = ADD_INT32( cf2_stack_getReal( opStack, 0 ), + nominalWidthX ); } /* width is defined or default after this */ @@ -1564,7 +1597,8 @@ FT_TRACE4(( " rmoveto\n" )); if ( cf2_stack_count( opStack ) > 2 && !haveWidth ) - *width = cf2_stack_getReal( opStack, 0 ) + nominalWidthX; + *width = ADD_INT32( cf2_stack_getReal( opStack, 0 ), + nominalWidthX ); /* width is defined or default after this */ haveWidth = TRUE; @@ -1572,8 +1606,8 @@ if ( font->decoder->width_only ) goto exit; - curY += cf2_stack_popFixed( opStack ); - curX += cf2_stack_popFixed( opStack ); + curY = ADD_INT32( curY, cf2_stack_popFixed( opStack ) ); + curX = ADD_INT32( curX, cf2_stack_popFixed( opStack ) ); cf2_glyphpath_moveTo( &glyphPath, curX, curY ); @@ -1583,7 +1617,8 @@ FT_TRACE4(( " hmoveto\n" )); if ( cf2_stack_count( opStack ) > 1 && !haveWidth ) - *width = cf2_stack_getReal( opStack, 0 ) + nominalWidthX; + *width = ADD_INT32( cf2_stack_getReal( opStack, 0 ), + nominalWidthX ); /* width is defined or default after this */ haveWidth = TRUE; @@ -1591,7 +1626,7 @@ if ( font->decoder->width_only ) goto exit; - curX += cf2_stack_popFixed( opStack ); + curX = ADD_INT32( curX, cf2_stack_popFixed( opStack ) ); cf2_glyphpath_moveTo( &glyphPath, curX, curY ); @@ -1607,8 +1642,10 @@ while ( idx + 6 < count ) { - curX += cf2_stack_getReal( opStack, idx + 0 ); - curY += cf2_stack_getReal( opStack, idx + 1 ); + curX = ADD_INT32( curX, cf2_stack_getReal( opStack, + idx + 0 ) ); + curY = ADD_INT32( curY, cf2_stack_getReal( opStack, + idx + 1 ) ); cf2_glyphpath_lineTo( &glyphPath, curX, curY ); idx += 2; @@ -1616,13 +1653,15 @@ while ( idx < count ) { - CF2_Fixed x1 = cf2_stack_getReal( opStack, idx + 0 ) + curX; - CF2_Fixed y1 = cf2_stack_getReal( opStack, idx + 1 ) + curY; - CF2_Fixed x2 = cf2_stack_getReal( opStack, idx + 2 ) + x1; - CF2_Fixed y2 = cf2_stack_getReal( opStack, idx + 3 ) + y1; - CF2_Fixed x3 = cf2_stack_getReal( opStack, idx + 4 ) + x2; - CF2_Fixed y3 = cf2_stack_getReal( opStack, idx + 5 ) + y2; + CF2_Fixed x1, y1, x2, y2, x3, y3; + + x1 = ADD_INT32( cf2_stack_getReal( opStack, idx + 0 ), curX ); + y1 = ADD_INT32( cf2_stack_getReal( opStack, idx + 1 ), curY ); + x2 = ADD_INT32( cf2_stack_getReal( opStack, idx + 2 ), x1 ); + y2 = ADD_INT32( cf2_stack_getReal( opStack, idx + 3 ), y1 ); + x3 = ADD_INT32( cf2_stack_getReal( opStack, idx + 4 ), x2 ); + y3 = ADD_INT32( cf2_stack_getReal( opStack, idx + 5 ), y2 ); cf2_glyphpath_curveTo( &glyphPath, x1, y1, x2, y2, x3, y3 ); @@ -1656,18 +1695,18 @@ if ( ( count - idx ) & 1 ) { - x1 = cf2_stack_getReal( opStack, idx ) + curX; + x1 = ADD_INT32( cf2_stack_getReal( opStack, idx ), curX ); idx++; } else x1 = curX; - y1 = cf2_stack_getReal( opStack, idx + 0 ) + curY; - x2 = cf2_stack_getReal( opStack, idx + 1 ) + x1; - y2 = cf2_stack_getReal( opStack, idx + 2 ) + y1; + y1 = ADD_INT32( cf2_stack_getReal( opStack, idx + 0 ), curY ); + x2 = ADD_INT32( cf2_stack_getReal( opStack, idx + 1 ), x1 ); + y2 = ADD_INT32( cf2_stack_getReal( opStack, idx + 2 ), y1 ); x3 = x2; - y3 = cf2_stack_getReal( opStack, idx + 3 ) + y2; + y3 = ADD_INT32( cf2_stack_getReal( opStack, idx + 3 ), y2 ); cf2_glyphpath_curveTo( &glyphPath, x1, y1, x2, y2, x3, y3 ); @@ -1701,17 +1740,17 @@ if ( ( count - idx ) & 1 ) { - y1 = cf2_stack_getReal( opStack, idx ) + curY; + y1 = ADD_INT32( cf2_stack_getReal( opStack, idx ), curY ); idx++; } else y1 = curY; - x1 = cf2_stack_getReal( opStack, idx + 0 ) + curX; - x2 = cf2_stack_getReal( opStack, idx + 1 ) + x1; - y2 = cf2_stack_getReal( opStack, idx + 2 ) + y1; - x3 = cf2_stack_getReal( opStack, idx + 3 ) + x2; + x1 = ADD_INT32( cf2_stack_getReal( opStack, idx + 0 ), curX ); + x2 = ADD_INT32( cf2_stack_getReal( opStack, idx + 1 ), x1 ); + y2 = ADD_INT32( cf2_stack_getReal( opStack, idx + 2 ), y1 ); + x3 = ADD_INT32( cf2_stack_getReal( opStack, idx + 3 ), x2 ); y3 = y2; cf2_glyphpath_curveTo( &glyphPath, x1, y1, x2, y2, x3, y3 ); @@ -1750,15 +1789,15 @@ if ( alternate ) { - x1 = cf2_stack_getReal( opStack, idx + 0 ) + curX; + x1 = ADD_INT32( cf2_stack_getReal( opStack, idx + 0 ), curX ); y1 = curY; - x2 = cf2_stack_getReal( opStack, idx + 1 ) + x1; - y2 = cf2_stack_getReal( opStack, idx + 2 ) + y1; - y3 = cf2_stack_getReal( opStack, idx + 3 ) + y2; + x2 = ADD_INT32( cf2_stack_getReal( opStack, idx + 1 ), x1 ); + y2 = ADD_INT32( cf2_stack_getReal( opStack, idx + 2 ), y1 ); + y3 = ADD_INT32( cf2_stack_getReal( opStack, idx + 3 ), y2 ); if ( count - idx == 5 ) { - x3 = cf2_stack_getReal( opStack, idx + 4 ) + x2; + x3 = ADD_INT32( cf2_stack_getReal( opStack, idx + 4 ), x2 ); idx++; } @@ -1770,14 +1809,14 @@ else { x1 = curX; - y1 = cf2_stack_getReal( opStack, idx + 0 ) + curY; - x2 = cf2_stack_getReal( opStack, idx + 1 ) + x1; - y2 = cf2_stack_getReal( opStack, idx + 2 ) + y1; - x3 = cf2_stack_getReal( opStack, idx + 3 ) + x2; + y1 = ADD_INT32( cf2_stack_getReal( opStack, idx + 0 ), curY ); + x2 = ADD_INT32( cf2_stack_getReal( opStack, idx + 1 ), x1 ); + y2 = ADD_INT32( cf2_stack_getReal( opStack, idx + 2 ), y1 ); + x3 = ADD_INT32( cf2_stack_getReal( opStack, idx + 3 ), x2 ); if ( count - idx == 5 ) { - y3 = cf2_stack_getReal( opStack, idx + 4 ) + y2; + y3 = ADD_INT32( cf2_stack_getReal( opStack, idx + 4 ), y2 ); idx++; } diff --git a/thirdparty/freetype/src/cff/cffgload.c b/thirdparty/freetype/src/cff/cffgload.c index 940804850e..20f3a2c28e 100644 --- a/thirdparty/freetype/src/cff/cffgload.c +++ b/thirdparty/freetype/src/cff/cffgload.c @@ -20,6 +20,7 @@ #include FT_INTERNAL_DEBUG_H #include FT_INTERNAL_STREAM_H #include FT_INTERNAL_SFNT_H +#include FT_INTERNAL_CALC_H #include FT_OUTLINE_H #include FT_CFF_DRIVER_H @@ -1450,8 +1451,8 @@ cff_builder_close_contour( builder ); builder->path_begun = 0; - x += args[-2]; - y += args[-1]; + x = ADD_LONG( x, args[-2] ); + y = ADD_LONG( y, args[-1] ); args = stack; break; @@ -1460,7 +1461,7 @@ cff_builder_close_contour( builder ); builder->path_begun = 0; - y += args[-1]; + y = ADD_LONG( y, args[-1] ); args = stack; break; @@ -1469,7 +1470,7 @@ cff_builder_close_contour( builder ); builder->path_begun = 0; - x += args[-1]; + x = ADD_LONG( x, args[-1] ); args = stack; break; @@ -1486,8 +1487,8 @@ args -= num_args & ~1; while ( args < decoder->top ) { - x += args[0]; - y += args[1]; + x = ADD_LONG( x, args[0] ); + y = ADD_LONG( y, args[1] ); cff_builder_add_point( builder, x, y, 1 ); args += 2; } @@ -1519,9 +1520,9 @@ while ( args < decoder->top ) { if ( phase ) - x += args[0]; + x = ADD_LONG( x, args[0] ); else - y += args[0]; + y = ADD_LONG( y, args[0] ); if ( cff_builder_add_point1( builder, x, y ) ) goto Fail; @@ -1552,15 +1553,18 @@ args -= nargs; while ( args < decoder->top ) { - x += args[0]; - y += args[1]; + x = ADD_LONG( x, args[0] ); + y = ADD_LONG( y, args[1] ); cff_builder_add_point( builder, x, y, 0 ); - x += args[2]; - y += args[3]; + + x = ADD_LONG( x, args[2] ); + y = ADD_LONG( y, args[3] ); cff_builder_add_point( builder, x, y, 0 ); - x += args[4]; - y += args[5]; + + x = ADD_LONG( x, args[4] ); + y = ADD_LONG( y, args[5] ); cff_builder_add_point( builder, x, y, 1 ); + args += 6; } args = stack; @@ -1589,7 +1593,7 @@ if ( nargs & 1 ) { - x += args[0]; + x = ADD_LONG( x, args[0] ); args++; nargs--; } @@ -1599,13 +1603,16 @@ while ( args < decoder->top ) { - y += args[0]; + y = ADD_LONG( y, args[0] ); cff_builder_add_point( builder, x, y, 0 ); - x += args[1]; - y += args[2]; + + x = ADD_LONG( x, args[1] ); + y = ADD_LONG( y, args[2] ); cff_builder_add_point( builder, x, y, 0 ); - y += args[3]; + + y = ADD_LONG( y, args[3] ); cff_builder_add_point( builder, x, y, 1 ); + args += 4; } args = stack; @@ -1633,7 +1640,7 @@ args -= nargs; if ( nargs & 1 ) { - y += args[0]; + y = ADD_LONG( y, args[0] ); args++; nargs--; } @@ -1643,13 +1650,16 @@ while ( args < decoder->top ) { - x += args[0]; + x = ADD_LONG( x, args[0] ); cff_builder_add_point( builder, x, y, 0 ); - x += args[1]; - y += args[2]; + + x = ADD_LONG( x, args[1] ); + y = ADD_LONG( y, args[2] ); cff_builder_add_point( builder, x, y, 0 ); - x += args[3]; + + x = ADD_LONG( x, args[3] ); cff_builder_add_point( builder, x, y, 1 ); + args += 4; } args = stack; @@ -1688,26 +1698,30 @@ nargs -= 4; if ( phase ) { - x += args[0]; + x = ADD_LONG( x, args[0] ); cff_builder_add_point( builder, x, y, 0 ); - x += args[1]; - y += args[2]; + + x = ADD_LONG( x, args[1] ); + y = ADD_LONG( y, args[2] ); cff_builder_add_point( builder, x, y, 0 ); - y += args[3]; + + y = ADD_LONG( y, args[3] ); if ( nargs == 1 ) - x += args[4]; + x = ADD_LONG( x, args[4] ); cff_builder_add_point( builder, x, y, 1 ); } else { - y += args[0]; + y = ADD_LONG( y, args[0] ); cff_builder_add_point( builder, x, y, 0 ); - x += args[1]; - y += args[2]; + + x = ADD_LONG( x, args[1] ); + y = ADD_LONG( y, args[2] ); cff_builder_add_point( builder, x, y, 0 ); - x += args[3]; + + x = ADD_LONG( x, args[3] ); if ( nargs == 1 ) - y += args[4]; + y = ADD_LONG( y, args[4] ); cff_builder_add_point( builder, x, y, 1 ); } args += 4; @@ -1740,23 +1754,27 @@ /* first, add the line segments */ while ( num_lines > 0 ) { - x += args[0]; - y += args[1]; + x = ADD_LONG( x, args[0] ); + y = ADD_LONG( y, args[1] ); cff_builder_add_point( builder, x, y, 1 ); + args += 2; num_lines--; } /* then the curve */ - x += args[0]; - y += args[1]; + x = ADD_LONG( x, args[0] ); + y = ADD_LONG( y, args[1] ); cff_builder_add_point( builder, x, y, 0 ); - x += args[2]; - y += args[3]; + + x = ADD_LONG( x, args[2] ); + y = ADD_LONG( y, args[3] ); cff_builder_add_point( builder, x, y, 0 ); - x += args[4]; - y += args[5]; + + x = ADD_LONG( x, args[4] ); + y = ADD_LONG( y, args[5] ); cff_builder_add_point( builder, x, y, 1 ); + args = stack; } break; @@ -1785,23 +1803,27 @@ /* first, add the curves */ while ( num_curves > 0 ) { - x += args[0]; - y += args[1]; + x = ADD_LONG( x, args[0] ); + y = ADD_LONG( y, args[1] ); cff_builder_add_point( builder, x, y, 0 ); - x += args[2]; - y += args[3]; + + x = ADD_LONG( x, args[2] ); + y = ADD_LONG( y, args[3] ); cff_builder_add_point( builder, x, y, 0 ); - x += args[4]; - y += args[5]; + + x = ADD_LONG( x, args[4] ); + y = ADD_LONG( y, args[5] ); cff_builder_add_point( builder, x, y, 1 ); + args += 6; num_curves--; } /* then the final line */ - x += args[0]; - y += args[1]; + x = ADD_LONG( x, args[0] ); + y = ADD_LONG( y, args[1] ); cff_builder_add_point( builder, x, y, 1 ); + args = stack; } break; @@ -1824,33 +1846,33 @@ start_y = y; /* first control point */ - x += args[0]; - y += args[1]; + x = ADD_LONG( x, args[0] ); + y = ADD_LONG( y, args[1] ); cff_builder_add_point( builder, x, y, 0 ); /* second control point */ - x += args[2]; - y += args[3]; + x = ADD_LONG( x, args[2] ); + y = ADD_LONG( y, args[3] ); cff_builder_add_point( builder, x, y, 0 ); /* join point; on curve, with y-value the same as the last */ /* control point's y-value */ - x += args[4]; + x = ADD_LONG( x, args[4] ); cff_builder_add_point( builder, x, y, 1 ); /* third control point, with y-value the same as the join */ /* point's y-value */ - x += args[5]; + x = ADD_LONG( x, args[5] ); cff_builder_add_point( builder, x, y, 0 ); /* fourth control point */ - x += args[6]; - y += args[7]; + x = ADD_LONG( x, args[6] ); + y = ADD_LONG( y, args[7] ); cff_builder_add_point( builder, x, y, 0 ); /* ending point, with y-value the same as the start */ - x += args[8]; - y = start_y; + x = ADD_LONG( x, args[8] ); + y = start_y; cff_builder_add_point( builder, x, y, 1 ); args = stack; @@ -1873,32 +1895,32 @@ start_y = y; /* first control point */ - x += args[0]; + x = ADD_LONG( x, args[0] ); cff_builder_add_point( builder, x, y, 0 ); /* second control point */ - x += args[1]; - y += args[2]; + x = ADD_LONG( x, args[1] ); + y = ADD_LONG( y, args[2] ); cff_builder_add_point( builder, x, y, 0 ); /* join point; on curve, with y-value the same as the last */ /* control point's y-value */ - x += args[3]; + x = ADD_LONG( x, args[3] ); cff_builder_add_point( builder, x, y, 1 ); /* third control point, with y-value the same as the join */ /* point's y-value */ - x += args[4]; + x = ADD_LONG( x, args[4] ); cff_builder_add_point( builder, x, y, 0 ); /* fourth control point */ - x += args[5]; - y = start_y; + x = ADD_LONG( x, args[5] ); + y = start_y; cff_builder_add_point( builder, x, y, 0 ); /* ending point, with y-value the same as the start point's */ /* y-value -- we don't add this point, though */ - x += args[6]; + x = ADD_LONG( x, args[6] ); cff_builder_add_point( builder, x, y, 1 ); args = stack; @@ -1934,8 +1956,8 @@ /* grab up to the last argument */ for ( count = 5; count > 0; count-- ) { - dx += temp[0]; - dy += temp[1]; + dx = ADD_LONG( dx, temp[0] ); + dy = ADD_LONG( dy, temp[1] ); temp += 2; } @@ -1949,8 +1971,8 @@ for ( count = 5; count > 0; count-- ) { - x += args[0]; - y += args[1]; + x = ADD_LONG( x, args[0] ); + y = ADD_LONG( y, args[1] ); cff_builder_add_point( builder, x, y, (FT_Bool)( count == 3 ) ); args += 2; @@ -1959,13 +1981,13 @@ /* is last operand an x- or y-delta? */ if ( horizontal ) { - x += args[0]; - y = start_y; + x = ADD_LONG( x, args[0] ); + y = start_y; } else { - x = start_x; - y += args[0]; + x = start_x; + y = ADD_LONG( y, args[0] ); } cff_builder_add_point( builder, x, y, 1 ); @@ -1987,8 +2009,8 @@ for ( count = 6; count > 0; count-- ) { - x += args[0]; - y += args[1]; + x = ADD_LONG( x, args[0] ); + y = ADD_LONG( y, args[1] ); cff_builder_add_point( builder, x, y, (FT_Bool)( count == 4 || count == 1 ) ); args += 2; @@ -2066,21 +2088,26 @@ FT_TRACE4(( " abs\n" )); if ( args[0] < 0 ) - args[0] = -args[0]; + { + if ( args[0] == FT_LONG_MIN ) + args[0] = FT_LONG_MAX; + else + args[0] = -args[0]; + } args++; break; case cff_op_add: FT_TRACE4(( " add\n" )); - args[0] += args[1]; + args[0] = ADD_LONG( args[0], args[1] ); args++; break; case cff_op_sub: FT_TRACE4(( " sub\n" )); - args[0] -= args[1]; + args[0] = SUB_LONG( args[0], args[1] ); args++; break; @@ -2094,6 +2121,8 @@ case cff_op_neg: FT_TRACE4(( " neg\n" )); + if ( args[0] == FT_LONG_MIN ) + args[0] = FT_LONG_MAX; args[0] = -args[0]; args++; break; @@ -2350,12 +2379,13 @@ FT_TRACE4(( " hsbw (invalid op)\n" )); - decoder->glyph_width = decoder->nominal_width + ( args[1] >> 16 ); + decoder->glyph_width = + ADD_LONG( decoder->nominal_width, ( args[1] >> 16 ) ); decoder->builder.left_bearing.x = args[0]; decoder->builder.left_bearing.y = 0; - x = decoder->builder.pos_x + args[0]; + x = ADD_LONG( decoder->builder.pos_x, args[0] ); y = decoder->builder.pos_y; args = stack; break; @@ -2367,13 +2397,14 @@ FT_TRACE4(( " sbw (invalid op)\n" )); - decoder->glyph_width = decoder->nominal_width + ( args[2] >> 16 ); + decoder->glyph_width = + ADD_LONG( decoder->nominal_width, ( args[2] >> 16 ) ); decoder->builder.left_bearing.x = args[0]; decoder->builder.left_bearing.y = args[1]; - x = decoder->builder.pos_x + args[0]; - y = decoder->builder.pos_y + args[1]; + x = ADD_LONG( decoder->builder.pos_x, args[0] ); + y = ADD_LONG( decoder->builder.pos_y, args[1] ); args = stack; break; @@ -2384,8 +2415,8 @@ FT_TRACE4(( " setcurrentpoint (invalid op)\n" )); - x = decoder->builder.pos_x + args[0]; - y = decoder->builder.pos_y + args[1]; + x = ADD_LONG( decoder->builder.pos_x, args[0] ); + y = ADD_LONG( decoder->builder.pos_y, args[1] ); args = stack; break; diff --git a/thirdparty/freetype/src/cff/cffload.c b/thirdparty/freetype/src/cff/cffload.c index 3beaeb1c8e..12420384af 100644 --- a/thirdparty/freetype/src/cff/cffload.c +++ b/thirdparty/freetype/src/cff/cffload.c @@ -1352,9 +1352,12 @@ sum = cff_parse_num( parser, &parser->stack[i + base] ) * 65536; for ( j = 1; j < blend->lenBV; j++ ) - sum += FT_MulFix( *weight++, - cff_parse_num( parser, - &parser->stack[delta++] ) * 65536 ); + sum = ADD_INT32( + sum, + FT_MulFix( + *weight++, + cff_parse_num( parser, + &parser->stack[delta++] ) * 65536 ) ); /* point parser stack to new value on blend_stack */ parser->stack[i + base] = subFont->blend_top; diff --git a/thirdparty/freetype/src/cff/cffparse.c b/thirdparty/freetype/src/cff/cffparse.c index e1511bdbd1..9d7bf6d22c 100644 --- a/thirdparty/freetype/src/cff/cffparse.c +++ b/thirdparty/freetype/src/cff/cffparse.c @@ -20,6 +20,7 @@ #include "cffparse.h" #include FT_INTERNAL_STREAM_H #include FT_INTERNAL_DEBUG_H +#include FT_INTERNAL_CALC_H #include "cfferrs.h" #include "cffpic.h" @@ -156,6 +157,22 @@ 1000000000L }; + /* maximum values allowed for multiplying */ + /* with the corresponding `power_tens' element */ + static const FT_Long power_ten_limits[] = + { + FT_LONG_MAX / 1L, + FT_LONG_MAX / 10L, + FT_LONG_MAX / 100L, + FT_LONG_MAX / 1000L, + FT_LONG_MAX / 10000L, + FT_LONG_MAX / 100000L, + FT_LONG_MAX / 1000000L, + FT_LONG_MAX / 10000000L, + FT_LONG_MAX / 100000000L, + FT_LONG_MAX / 1000000000L, + }; + /* read a real */ static FT_Fixed @@ -484,7 +501,15 @@ if ( scaling ) + { + if ( FT_ABS( val ) > power_ten_limits[scaling] ) + { + val = val > 0 ? 0x7FFFFFFFL : -0x7FFFFFFFL; + goto Overflow; + } + val *= power_tens[scaling]; + } if ( val > 0x7FFF ) { @@ -1585,7 +1610,7 @@ val = 0; while ( num_args > 0 ) { - val += cff_parse_num( parser, data++ ); + val = ADD_LONG( val, cff_parse_num( parser, data++ ) ); switch ( field->size ) { case (8 / FT_CHAR_BIT): diff --git a/thirdparty/freetype/src/gxvalid/README b/thirdparty/freetype/src/gxvalid/README index 7201459aaf..200f66cb12 100644 --- a/thirdparty/freetype/src/gxvalid/README +++ b/thirdparty/freetype/src/gxvalid/README @@ -9,7 +9,7 @@ gxvalid: TrueType GX validator additional tables in TrueType font which are used by `QuickDraw GX Text', Apple Advanced Typography (AAT). In addition, gxvalid can validates `kern' tables which have been extended for AAT. Like the - otvalid module, gxvalid uses Freetype 2's validator framework + otvalid module, gxvalid uses FreeType 2's validator framework (ftvalid). You can link gxvalid with your program; before running your own layout diff --git a/thirdparty/freetype/src/pcf/README b/thirdparty/freetype/src/pcf/README index 10eff15fbe..09ea970eda 100644 --- a/thirdparty/freetype/src/pcf/README +++ b/thirdparty/freetype/src/pcf/README @@ -41,8 +41,8 @@ value given as argument into the corresponding glyph number. Known problems ************** -- dealing explicitly with encodings breaks the uniformity of freetype2 - api. +- dealing explicitly with encodings breaks the uniformity of FreeType 2 + API. - except for encodings properties, client applications have no visibility of the PCF_Face object. This means that applications diff --git a/thirdparty/freetype/src/pcf/pcfdrivr.c b/thirdparty/freetype/src/pcf/pcfdrivr.c index 9f4d36d111..169f75e950 100644 --- a/thirdparty/freetype/src/pcf/pcfdrivr.c +++ b/thirdparty/freetype/src/pcf/pcfdrivr.c @@ -387,7 +387,11 @@ THE SOFTWARE. if ( !ft_strcmp( s, "10646" ) || ( !ft_strcmp( s, "8859" ) && !ft_strcmp( face->charset_encoding, "1" ) ) ) - unicode_charmap = 1; + unicode_charmap = 1; + /* another name for ASCII */ + else if ( !ft_strcmp( s, "646.1991" ) && + !ft_strcmp( face->charset_encoding, "IRV" ) ) + unicode_charmap = 1; } } @@ -409,12 +413,6 @@ THE SOFTWARE. } error = FT_CMap_New( &pcf_cmap_class, NULL, &charmap, NULL ); - -#if 0 - /* Select default charmap */ - if ( pcfface->num_charmaps ) - pcfface->charmap = pcfface->charmaps[0]; -#endif } } diff --git a/thirdparty/freetype/src/pcf/pcfread.c b/thirdparty/freetype/src/pcf/pcfread.c index 3eacf2baf6..da216b05f4 100644 --- a/thirdparty/freetype/src/pcf/pcfread.c +++ b/thirdparty/freetype/src/pcf/pcfread.c @@ -1162,6 +1162,20 @@ THE SOFTWARE. accel->fontDescent, accel->maxOverlap )); + /* sanity checks */ + if ( FT_ABS( accel->fontAscent ) > 0x7FFF ) + { + accel->fontAscent = accel->fontAscent < 0 ? -0x7FFF : 0x7FFF; + FT_TRACE0(( "pfc_get_accel: clamping font ascent to value %d\n", + accel->fontAscent )); + } + if ( FT_ABS( accel->fontDescent ) > 0x7FFF ) + { + accel->fontDescent = accel->fontDescent < 0 ? -0x7FFF : 0x7FFF; + FT_TRACE0(( "pfc_get_accel: clamping font descent to value %d\n", + accel->fontDescent )); + } + FT_TRACE5(( " minbounds:" )); error = pcf_get_metric( stream, format & ( ~PCF_FORMAT_MASK ), @@ -1496,8 +1510,16 @@ THE SOFTWARE. if ( face->accel.fontAscent + face->accel.fontDescent < 0 ) FT_TRACE0(( "pcf_load_font: negative height\n" )); #endif - bsize->height = FT_ABS( (FT_Short)( face->accel.fontAscent + - face->accel.fontDescent ) ); + if ( FT_ABS( face->accel.fontAscent + + face->accel.fontDescent ) > 0x7FFF ) + { + bsize->height = 0x7FFF; + FT_TRACE0(( "pcf_load_font: clamping height to value %d\n", + bsize->height )); + } + else + bsize->height = FT_ABS( (FT_Short)( face->accel.fontAscent + + face->accel.fontDescent ) ); prop = pcf_find_property( face, "AVERAGE_WIDTH" ); if ( prop ) @@ -1506,10 +1528,20 @@ THE SOFTWARE. if ( prop->value.l < 0 ) FT_TRACE0(( "pcf_load_font: negative average width\n" )); #endif - bsize->width = FT_ABS( (FT_Short)( ( prop->value.l ) + 5 ) / 10 ); + if ( ( FT_ABS( prop->value.l ) > 0x7FFFL * 10 - 5 ) ) + { + bsize->width = 0x7FFF; + FT_TRACE0(( "pcf_load_font: clamping average width to value %d\n", + bsize->width )); + } + else + bsize->width = FT_ABS( (FT_Short)( ( prop->value.l + 5 ) / 10 ) ); } else + { + /* this is a heuristical value */ bsize->width = (FT_Short)FT_MulDiv( bsize->height, 2, 3 ); + } prop = pcf_find_property( face, "POINT_SIZE" ); if ( prop ) @@ -1519,9 +1551,16 @@ THE SOFTWARE. FT_TRACE0(( "pcf_load_font: negative point size\n" )); #endif /* convert from 722.7 decipoints to 72 points per inch */ - bsize->size = FT_MulDiv( FT_ABS( prop->value.l ), - 64 * 7200, - 72270L ); + if ( FT_ABS( prop->value.l ) > 0x504C2L ) /* 0x7FFF * 72270/7200 */ + { + bsize->size = 0x7FFF; + FT_TRACE0(( "pcf_load_font: clamping point size to value %d\n", + bsize->size )); + } + else + bsize->size = FT_MulDiv( FT_ABS( prop->value.l ), + 64 * 7200, + 72270L ); } prop = pcf_find_property( face, "PIXEL_SIZE" ); @@ -1531,7 +1570,14 @@ THE SOFTWARE. if ( prop->value.l < 0 ) FT_TRACE0(( "pcf_load_font: negative pixel size\n" )); #endif - bsize->y_ppem = FT_ABS( (FT_Short)prop->value.l ) << 6; + if ( FT_ABS( prop->value.l ) > 0x7FFF ) + { + bsize->y_ppem = 0x7FFF << 6; + FT_TRACE0(( "pcf_load_font: clamping pixel size to value %d\n", + bsize->y_ppem )); + } + else + bsize->y_ppem = FT_ABS( (FT_Short)prop->value.l ) << 6; } prop = pcf_find_property( face, "RESOLUTION_X" ); @@ -1541,7 +1587,14 @@ THE SOFTWARE. if ( prop->value.l < 0 ) FT_TRACE0(( "pcf_load_font: negative X resolution\n" )); #endif - resolution_x = FT_ABS( (FT_Short)prop->value.l ); + if ( FT_ABS( prop->value.l ) > 0x7FFF ) + { + resolution_x = 0x7FFF; + FT_TRACE0(( "pcf_load_font: clamping X resolution to value %d\n", + resolution_x )); + } + else + resolution_x = FT_ABS( (FT_Short)prop->value.l ); } prop = pcf_find_property( face, "RESOLUTION_Y" ); @@ -1551,7 +1604,14 @@ THE SOFTWARE. if ( prop->value.l < 0 ) FT_TRACE0(( "pcf_load_font: negative Y resolution\n" )); #endif - resolution_y = FT_ABS( (FT_Short)prop->value.l ); + if ( FT_ABS( prop->value.l ) > 0x7FFF ) + { + resolution_y = 0x7FFF; + FT_TRACE0(( "pcf_load_font: clamping Y resolution to value %d\n", + resolution_y )); + } + else + resolution_y = FT_ABS( (FT_Short)prop->value.l ); } if ( bsize->y_ppem == 0 ) diff --git a/thirdparty/freetype/src/pfr/pfrobjs.c b/thirdparty/freetype/src/pfr/pfrobjs.c index 4b1703f51c..514af8050d 100644 --- a/thirdparty/freetype/src/pfr/pfrobjs.c +++ b/thirdparty/freetype/src/pfr/pfrobjs.c @@ -264,12 +264,6 @@ charmap.encoding = FT_ENCODING_UNICODE; error = FT_CMap_New( &pfr_cmap_class_rec, NULL, &charmap, NULL ); - -#if 0 - /* select default charmap */ - if ( pfrface->num_charmaps ) - pfrface->charmap = pfrface->charmaps[0]; -#endif } /* check whether we have loaded any kerning pairs */ diff --git a/thirdparty/freetype/src/psaux/psconv.c b/thirdparty/freetype/src/psaux/psconv.c index b092482194..d125b0834a 100644 --- a/thirdparty/freetype/src/psaux/psconv.c +++ b/thirdparty/freetype/src/psaux/psconv.c @@ -111,6 +111,10 @@ p++; if ( p == limit ) goto Bad; + + /* only a single sign is allowed */ + if ( *p == '-' || *p == '+' ) + return 0; } num_limit = 0x7FFFFFFFL / base; @@ -215,6 +219,10 @@ p++; if ( p == limit ) goto Bad; + + /* only a single sign is allowed */ + if ( *p == '-' || *p == '+' ) + return 0; } /* read the integer part */ diff --git a/thirdparty/freetype/src/psaux/t1decode.c b/thirdparty/freetype/src/psaux/t1decode.c index 7dd45135de..1250b53f5d 100644 --- a/thirdparty/freetype/src/psaux/t1decode.c +++ b/thirdparty/freetype/src/psaux/t1decode.c @@ -864,7 +864,9 @@ for ( mm = 1; mm < blend->num_designs; mm++ ) - tmp += FT_MulFix( *delta++, blend->weight_vector[mm] ); + tmp = ADD_LONG( tmp, + FT_MulFix( *delta++, + blend->weight_vector[mm] ) ); *values++ = tmp; } @@ -904,7 +906,7 @@ if ( arg_cnt != 2 ) goto Unexpected_OtherSubr; - top[0] += top[1]; /* XXX (over|under)flow */ + top[0] = ADD_LONG( top[0], top[1] ); known_othersubr_result_cnt = 1; break; @@ -915,7 +917,7 @@ if ( arg_cnt != 2 ) goto Unexpected_OtherSubr; - top[0] -= top[1]; /* XXX (over|under)flow */ + top[0] = SUB_LONG( top[0], top[1] ); known_othersubr_result_cnt = 1; break; @@ -1147,11 +1149,13 @@ builder->parse_state = T1_Parse_Have_Width; - builder->left_bearing.x += top[0]; - builder->advance.x = top[1]; - builder->advance.y = 0; + builder->left_bearing.x = ADD_LONG( builder->left_bearing.x, + top[0] ); - orig_x = x = builder->pos_x + top[0]; + builder->advance.x = top[1]; + builder->advance.y = 0; + + orig_x = x = ADD_LONG( builder->pos_x, top[0] ); orig_y = y = builder->pos_y; FT_UNUSED( orig_y ); @@ -1177,13 +1181,16 @@ builder->parse_state = T1_Parse_Have_Width; - builder->left_bearing.x += top[0]; - builder->left_bearing.y += top[1]; - builder->advance.x = top[2]; - builder->advance.y = top[3]; + builder->left_bearing.x = ADD_LONG( builder->left_bearing.x, + top[0] ); + builder->left_bearing.y = ADD_LONG( builder->left_bearing.y, + top[1] ); + + builder->advance.x = top[2]; + builder->advance.y = top[3]; - x = builder->pos_x + top[0]; - y = builder->pos_y + top[1]; + x = ADD_LONG( builder->pos_x, top[0] ); + y = ADD_LONG( builder->pos_y, top[1] ); /* the `metrics_only' indicates that we only want to compute */ /* the glyph's metrics (lsb + advance width), not load the */ @@ -1210,13 +1217,14 @@ if ( FT_SET_ERROR( t1_builder_start_point( builder, x, y ) ) ) goto Fail; - x += top[0]; + x = ADD_LONG( x, top[0] ); goto Add_Line; case op_hmoveto: FT_TRACE4(( " hmoveto" )); - x += top[0]; + x = ADD_LONG( x, top[0] ); + if ( !decoder->flex_state ) { if ( builder->parse_state == T1_Parse_Start ) @@ -1232,12 +1240,14 @@ FT_SET_ERROR( t1_builder_check_points( builder, 3 ) ) ) goto Fail; - x += top[0]; + x = ADD_LONG( x, top[0] ); t1_builder_add_point( builder, x, y, 0 ); - x += top[1]; - y += top[2]; + + x = ADD_LONG( x, top[1] ); + y = ADD_LONG( y, top[2] ); t1_builder_add_point( builder, x, y, 0 ); - y += top[3]; + + y = ADD_LONG( y, top[3] ); t1_builder_add_point( builder, x, y, 1 ); break; @@ -1247,8 +1257,8 @@ if ( FT_SET_ERROR( t1_builder_start_point( builder, x, y ) ) ) goto Fail; - x += top[0]; - y += top[1]; + x = ADD_LONG( x, top[0] ); + y = ADD_LONG( y, top[1] ); Add_Line: if ( FT_SET_ERROR( t1_builder_add_point1( builder, x, y ) ) ) @@ -1258,8 +1268,9 @@ case op_rmoveto: FT_TRACE4(( " rmoveto" )); - x += top[0]; - y += top[1]; + x = ADD_LONG( x, top[0] ); + y = ADD_LONG( y, top[1] ); + if ( !decoder->flex_state ) { if ( builder->parse_state == T1_Parse_Start ) @@ -1275,16 +1286,16 @@ FT_SET_ERROR( t1_builder_check_points( builder, 3 ) ) ) goto Fail; - x += top[0]; - y += top[1]; + x = ADD_LONG( x, top[0] ); + y = ADD_LONG( y, top[1] ); t1_builder_add_point( builder, x, y, 0 ); - x += top[2]; - y += top[3]; + x = ADD_LONG( x, top[2] ); + y = ADD_LONG( y, top[3] ); t1_builder_add_point( builder, x, y, 0 ); - x += top[4]; - y += top[5]; + x = ADD_LONG( x, top[4] ); + y = ADD_LONG( y, top[5] ); t1_builder_add_point( builder, x, y, 1 ); break; @@ -1295,12 +1306,14 @@ FT_SET_ERROR( t1_builder_check_points( builder, 3 ) ) ) goto Fail; - y += top[0]; + y = ADD_LONG( y, top[0] ); t1_builder_add_point( builder, x, y, 0 ); - x += top[1]; - y += top[2]; + + x = ADD_LONG( x, top[1] ); + y = ADD_LONG( y, top[2] ); t1_builder_add_point( builder, x, y, 0 ); - x += top[3]; + + x = ADD_LONG( x, top[3] ); t1_builder_add_point( builder, x, y, 1 ); break; @@ -1310,13 +1323,14 @@ if ( FT_SET_ERROR( t1_builder_start_point( builder, x, y ) ) ) goto Fail; - y += top[0]; + y = ADD_LONG( y, top[0] ); goto Add_Line; case op_vmoveto: FT_TRACE4(( " vmoveto" )); - y += top[0]; + y = ADD_LONG( y, top[0] ); + if ( !decoder->flex_state ) { if ( builder->parse_state == T1_Parse_Start ) @@ -1473,7 +1487,7 @@ /* record vertical hint */ if ( hinter ) { - top[0] += orig_x; + top[0] = ADD_LONG( top[0], orig_x ); hinter->stem( hinter->hints, 0, top ); } break; @@ -1487,9 +1501,9 @@ FT_Pos dx = orig_x; - top[0] += dx; - top[2] += dx; - top[4] += dx; + top[0] = ADD_LONG( top[0], dx ); + top[2] = ADD_LONG( top[2], dx ); + top[4] = ADD_LONG( top[4], dx ); hinter->stem3( hinter->hints, 0, top ); } break; diff --git a/thirdparty/freetype/src/psnames/psmodule.c b/thirdparty/freetype/src/psnames/psmodule.c index 3ff8cb911b..44ba9ec6ab 100644 --- a/thirdparty/freetype/src/psnames/psmodule.c +++ b/thirdparty/freetype/src/psnames/psmodule.c @@ -23,8 +23,21 @@ #include "psmodule.h" + /* + * The file `pstables.h' with its arrays and its function + * `ft_get_adobe_glyph_index' is useful for other projects also (for + * example, `pdfium' is using it). However, if used as a C++ header, + * including it in two different source files makes it necessary to use + * `extern const' for the declaration of its arrays, otherwise the data + * would be duplicated as mandated by the C++ standard. + * + * For this reason, we use `DEFINE_PS_TABLES' to guard the function + * definitions, and `DEFINE_PS_TABLES_DATA' to provide both proper array + * declarations and definitions. + */ #include "pstables.h" #define DEFINE_PS_TABLES +#define DEFINE_PS_TABLES_DATA #include "pstables.h" #include "psnamerr.h" diff --git a/thirdparty/freetype/src/psnames/pstables.h b/thirdparty/freetype/src/psnames/pstables.h index e0f5e30804..2a2b717d8f 100644 --- a/thirdparty/freetype/src/psnames/pstables.h +++ b/thirdparty/freetype/src/psnames/pstables.h @@ -19,7 +19,7 @@ /* This file has been generated automatically -- do not edit! */ -#ifndef DEFINE_PS_TABLES +#ifndef DEFINE_PS_TABLES_DATA #ifdef __cplusplus extern "C" #else @@ -27,7 +27,7 @@ #endif #endif const char ft_standard_glyph_names[3696] -#ifdef DEFINE_PS_TABLES +#ifdef DEFINE_PS_TABLES_DATA = { '.','n','u','l','l', 0, @@ -451,7 +451,7 @@ 'R','o','m','a','n', 0, 'S','e','m','i','b','o','l','d', 0, } -#endif /* DEFINE_PS_TABLES */ +#endif /* DEFINE_PS_TABLES_DATA */ ; @@ -459,7 +459,7 @@ /* Values are offsets into the `ft_standard_glyph_names' table */ -#ifndef DEFINE_PS_TABLES +#ifndef DEFINE_PS_TABLES_DATA #ifdef __cplusplus extern "C" #else @@ -467,7 +467,7 @@ #endif #endif const short ft_mac_names[FT_NUM_MAC_NAMES] -#ifdef DEFINE_PS_TABLES +#ifdef DEFINE_PS_TABLES_DATA = { 253, 0, 6, 261, 267, 274, 283, 294, 301, 309, 758, 330, 340, 351, @@ -490,7 +490,7 @@ 1270,1313,1323,1171,1290,1332,1211,1235,1276, 169, 175, 182, 189, 200, 209, 218, 225, 232, 239, 246 } -#endif /* DEFINE_PS_TABLES */ +#endif /* DEFINE_PS_TABLES_DATA */ ; @@ -498,7 +498,7 @@ /* Values are offsets into the `ft_standard_glyph_names' table */ -#ifndef DEFINE_PS_TABLES +#ifndef DEFINE_PS_TABLES_DATA #ifdef __cplusplus extern "C" #else @@ -506,7 +506,7 @@ #endif #endif const short ft_sid_names[FT_NUM_SID_NAMES] -#ifdef DEFINE_PS_TABLES +#ifdef DEFINE_PS_TABLES_DATA = { 253, 261, 267, 274, 283, 294, 301, 309, 319, 330, 340, 351, 360, 365, @@ -538,12 +538,12 @@ 3418,3430,3442,3454,3471,3483,3498,3506,3518,3530,3542,3559,3574,3586, 3597,3612,3620,3628,3636,3644,3650,3655,3660,3666,3673,3681,3687 } -#endif /* DEFINE_PS_TABLES */ +#endif /* DEFINE_PS_TABLES_DATA */ ; /* the following are indices into the SID name table */ -#ifndef DEFINE_PS_TABLES +#ifndef DEFINE_PS_TABLES_DATA #ifdef __cplusplus extern "C" #else @@ -551,7 +551,7 @@ #endif #endif const unsigned short t1_standard_encoding[256] -#ifdef DEFINE_PS_TABLES +#ifdef DEFINE_PS_TABLES_DATA = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -571,12 +571,12 @@ 0,138, 0,139, 0, 0, 0, 0,140,141,142,143, 0, 0, 0, 0, 0,144, 0, 0, 0,145, 0, 0,146,147,148,149, 0, 0, 0, 0 } -#endif /* DEFINE_PS_TABLES */ +#endif /* DEFINE_PS_TABLES_DATA */ ; /* the following are indices into the SID name table */ -#ifndef DEFINE_PS_TABLES +#ifndef DEFINE_PS_TABLES_DATA #ifdef __cplusplus extern "C" #else @@ -584,7 +584,7 @@ #endif #endif const unsigned short t1_expert_encoding[256] -#ifdef DEFINE_PS_TABLES +#ifdef DEFINE_PS_TABLES_DATA = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -604,7 +604,7 @@ 347,348,349,350,351,352,353,354,355,356,357,358,359,360,361,362, 363,364,365,366,367,368,369,370,371,372,373,374,375,376,377,378 } -#endif /* DEFINE_PS_TABLES */ +#endif /* DEFINE_PS_TABLES_DATA */ ; @@ -619,7 +619,7 @@ #ifdef FT_CONFIG_OPTION_ADOBE_GLYPH_LIST -#ifndef DEFINE_PS_TABLES +#ifndef DEFINE_PS_TABLES_DATA #ifdef __cplusplus extern "C" #else @@ -627,7 +627,7 @@ #endif #endif const unsigned char ft_adobe_glyph_list[55997L] -#ifdef DEFINE_PS_TABLES +#ifdef DEFINE_PS_TABLES_DATA = { 0, 52, 0,106, 2,167, 3, 63, 4,220, 6,125, 9,143, 10, 23, @@ -4131,7 +4131,7 @@ 182,117, 2,218,167,218,178,232,233,242,225,231,225,238, 97,128, 48, 90,235,225,244,225,235,225,238, 97,128, 48,186 } -#endif /* DEFINE_PS_TABLES */ +#endif /* DEFINE_PS_TABLES_DATA */ ; diff --git a/thirdparty/freetype/src/raster/ftrend1.c b/thirdparty/freetype/src/raster/ftrend1.c index 1a83e9e477..185a7f6fc2 100644 --- a/thirdparty/freetype/src/raster/ftrend1.c +++ b/thirdparty/freetype/src/raster/ftrend1.c @@ -31,12 +31,7 @@ static FT_Error ft_raster1_init( FT_Renderer render ) { - FT_Library library = FT_MODULE_LIBRARY( render ); - - - render->clazz->raster_class->raster_reset( render->raster, - library->raster_pool, - library->raster_pool_size ); + render->clazz->raster_class->raster_reset( render->raster, NULL, 0 ); return FT_Err_Ok; } @@ -194,7 +189,7 @@ bitmap->rows = height; bitmap->pitch = (int)pitch; - if ( FT_ALLOC_MULT( bitmap->buffer, pitch, height ) ) + if ( FT_ALLOC_MULT( bitmap->buffer, height, pitch ) ) goto Exit; slot->internal->flags |= FT_GLYPH_OWN_BITMAP; diff --git a/thirdparty/freetype/src/sfnt/pngshim.c b/thirdparty/freetype/src/sfnt/pngshim.c index b9b296ea5f..560db4835a 100644 --- a/thirdparty/freetype/src/sfnt/pngshim.c +++ b/thirdparty/freetype/src/sfnt/pngshim.c @@ -49,18 +49,82 @@ } - /* Premultiplies data and converts RGBA bytes => native endian. */ + /* Premultiplies data and converts RGBA bytes => BGRA. */ static void premultiply_data( png_structp png, png_row_infop row_info, png_bytep data ) { - unsigned int i; + unsigned int i = 0, limit; + + /* The `vector_size' attribute was introduced in gcc 3.1, which */ + /* predates clang; the `__BYTE_ORDER__' preprocessor symbol was */ + /* introduced in gcc 4.6 and clang 3.2, respectively. */ + /* `__builtin_shuffle' for gcc was introduced in gcc 4.7.0. */ +#if ( ( defined( __GNUC__ ) && \ + ( ( __GNUC__ >= 5 ) || \ + ( ( __GNUC__ == 4 ) && ( __GNUC_MINOR__ >= 7 ) ) ) ) || \ + ( defined( __clang__ ) && \ + ( ( __clang_major__ >= 4 ) || \ + ( ( __clang_major__ == 3 ) && ( __clang_minor__ >= 2 ) ) ) ) ) && \ + defined( __OPTIMIZE__ ) && \ + __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ + +#ifdef __clang__ + /* the clang documentation doesn't cover the two-argument case of */ + /* `__builtin_shufflevector'; however, it is is implemented since */ + /* version 2.8 */ +#define vector_shuffle __builtin_shufflevector +#else +#define vector_shuffle __builtin_shuffle +#endif - FT_UNUSED( png ); + typedef unsigned short v82 __attribute__(( vector_size( 16 ) )); - for ( i = 0; i < row_info->rowbytes; i += 4 ) + /* process blocks of 16 bytes in one rush, which gives a nice speed-up */ + limit = row_info->rowbytes - 16 + 1; + for ( ; i < limit; i += 16 ) + { + unsigned char* base = &data[i]; + + v82 s, s0, s1, a; + + /* clang <= 3.9 can't apply scalar values to vectors */ + /* (or rather, it needs a different syntax) */ + v82 n0x80 = { 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }; + v82 n0xFF = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; + v82 n8 = { 8, 8, 8, 8, 8, 8, 8, 8 }; + + v82 ma = { 1, 1, 3, 3, 5, 5, 7, 7 }; + v82 o1 = { 0, 0xFF, 0, 0xFF, 0, 0xFF, 0, 0xFF }; + v82 m0 = { 1, 0, 3, 2, 5, 4, 7, 6 }; + + + memcpy( &s, base, 16 ); /* RGBA RGBA RGBA RGBA */ + s0 = s & n0xFF; /* R B R B R B R B */ + s1 = s >> n8; /* G A G A G A G A */ + + a = vector_shuffle( s1, ma ); /* A A A A A A A A */ + s1 |= o1; /* G 1 G 1 G 1 G 1 */ + s0 = vector_shuffle( s0, m0 ); /* B R B R B R B R */ + + s0 *= a; + s1 *= a; + s0 += n0x80; + s1 += n0x80; + s0 = ( s0 + ( s0 >> n8 ) ) >> n8; + s1 = ( s1 + ( s1 >> n8 ) ) >> n8; + + s = s0 | ( s1 << n8 ); + memcpy( base, &s, 16 ); + } +#endif /* use `vector_size' */ + + FT_UNUSED( png ); + + limit = row_info->rowbytes; + for ( ; i < limit; i += 4 ) { unsigned char* base = &data[i]; unsigned int alpha = base[3]; diff --git a/thirdparty/freetype/src/sfnt/sfobjs.c b/thirdparty/freetype/src/sfnt/sfobjs.c index ac2e620e5d..69bf0a5c3d 100644 --- a/thirdparty/freetype/src/sfnt/sfobjs.c +++ b/thirdparty/freetype/src/sfnt/sfobjs.c @@ -787,6 +787,8 @@ tag != TTAG_OTTO && tag != TTAG_true && tag != TTAG_typ1 && + tag != TTAG_0xA5kbd && + tag != TTAG_0xA5lst && tag != 0x00020000UL ) { FT_TRACE2(( " not a font using the SFNT container format\n" )); @@ -1224,7 +1226,10 @@ goto Exit; } - if ( face->header.Units_Per_EM == 0 ) + /* OpenType 1.8.2 introduced limits to this value; */ + /* however, they make sense for older SFNT fonts also */ + if ( face->header.Units_Per_EM < 16 || + face->header.Units_Per_EM > 16384 ) { error = FT_THROW( Invalid_Table ); @@ -1464,7 +1469,8 @@ /* Polish the charmaps. */ /* */ /* Try to set the charmap encoding according to the platform & */ - /* encoding ID of each charmap. */ + /* encoding ID of each charmap. Emulate Unicode charmap if one */ + /* is missing. */ /* */ tt_face_build_cmaps( face ); /* ignore errors */ @@ -1472,7 +1478,10 @@ /* set the encoding fields */ { - FT_Int m; + FT_Int m; +#ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES + FT_Bool has_unicode = FALSE; +#endif for ( m = 0; m < root->num_charmaps; m++ ) @@ -1483,14 +1492,34 @@ charmap->encoding = sfnt_find_encoding( charmap->platform_id, charmap->encoding_id ); -#if 0 - if ( !root->charmap && - charmap->encoding == FT_ENCODING_UNICODE ) - { - /* set 'root->charmap' to the first Unicode encoding we find */ - root->charmap = charmap; - } -#endif +#ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES + + if ( charmap->encoding == FT_ENCODING_UNICODE || + charmap->encoding == FT_ENCODING_MS_SYMBOL ) /* PUA */ + has_unicode = TRUE; + } + + /* synthesize Unicode charmap if one is missing */ + if ( !has_unicode ) + { + FT_CharMapRec cmaprec; + + + cmaprec.face = root; + cmaprec.platform_id = TT_PLATFORM_MICROSOFT; + cmaprec.encoding_id = TT_MS_ID_UNICODE_CS; + cmaprec.encoding = FT_ENCODING_UNICODE; + + + error = FT_CMap_New( (FT_CMap_Class)&tt_cmap_unicode_class_rec, + NULL, &cmaprec, NULL ); + if ( error && + FT_ERR_NEQ( error, No_Unicode_Glyph_Name ) ) + goto Exit; + error = FT_Err_Ok; + +#endif /* FT_CONFIG_OPTION_POSTSCRIPT_NAMES */ + } } diff --git a/thirdparty/freetype/src/sfnt/ttcmap.c b/thirdparty/freetype/src/sfnt/ttcmap.c index 5afa6ae4b7..b995e5c050 100644 --- a/thirdparty/freetype/src/sfnt/ttcmap.c +++ b/thirdparty/freetype/src/sfnt/ttcmap.c @@ -23,8 +23,10 @@ #include FT_INTERNAL_VALIDATE_H #include FT_INTERNAL_STREAM_H +#include FT_SERVICE_POSTSCRIPT_CMAPS_H #include "ttload.h" #include "ttcmap.h" +#include "ttpost.h" #include "sfntpic.h" @@ -3622,6 +3624,110 @@ #endif /* TT_CONFIG_CMAP_FORMAT_14 */ + /*************************************************************************/ + /*************************************************************************/ + /***** *****/ + /***** SYNTHETIC UNICODE *****/ + /***** *****/ + /*************************************************************************/ + /*************************************************************************/ + + /* This charmap is generated using postscript glyph names. */ + +#ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES + + FT_CALLBACK_DEF( const char * ) + tt_get_glyph_name( TT_Face face, + FT_UInt idx ) + { + FT_String* PSname; + + + tt_face_get_ps_name( face, idx, &PSname ); + + return PSname; + } + + + FT_CALLBACK_DEF( FT_Error ) + tt_cmap_unicode_init( PS_Unicodes unicodes, + FT_Pointer pointer ) + { + TT_Face face = (TT_Face)FT_CMAP_FACE( unicodes ); + FT_Memory memory = FT_FACE_MEMORY( face ); + FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)face->psnames; + + FT_UNUSED( pointer ); + + + return psnames->unicodes_init( memory, + unicodes, + face->root.num_glyphs, + (PS_GetGlyphNameFunc)&tt_get_glyph_name, + (PS_FreeGlyphNameFunc)NULL, + (FT_Pointer)face ); + } + + + FT_CALLBACK_DEF( void ) + tt_cmap_unicode_done( PS_Unicodes unicodes ) + { + FT_Face face = FT_CMAP_FACE( unicodes ); + FT_Memory memory = FT_FACE_MEMORY( face ); + + + FT_FREE( unicodes->maps ); + unicodes->num_maps = 0; + } + + + FT_CALLBACK_DEF( FT_UInt ) + tt_cmap_unicode_char_index( PS_Unicodes unicodes, + FT_UInt32 char_code ) + { + TT_Face face = (TT_Face)FT_CMAP_FACE( unicodes ); + FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)face->psnames; + + + return psnames->unicodes_char_index( unicodes, char_code ); + } + + + FT_CALLBACK_DEF( FT_UInt32 ) + tt_cmap_unicode_char_next( PS_Unicodes unicodes, + FT_UInt32 *pchar_code ) + { + TT_Face face = (TT_Face)FT_CMAP_FACE( unicodes ); + FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)face->psnames; + + + return psnames->unicodes_char_next( unicodes, pchar_code ); + } + + + FT_DEFINE_TT_CMAP( + tt_cmap_unicode_class_rec, + + sizeof ( PS_UnicodesRec ), + + (FT_CMap_InitFunc) tt_cmap_unicode_init, /* init */ + (FT_CMap_DoneFunc) tt_cmap_unicode_done, /* done */ + (FT_CMap_CharIndexFunc)tt_cmap_unicode_char_index, /* char_index */ + (FT_CMap_CharNextFunc) tt_cmap_unicode_char_next, /* char_next */ + + (FT_CMap_CharVarIndexFunc) NULL, /* char_var_index */ + (FT_CMap_CharVarIsDefaultFunc)NULL, /* char_var_default */ + (FT_CMap_VariantListFunc) NULL, /* variant_list */ + (FT_CMap_CharVariantListFunc) NULL, /* charvariant_list */ + (FT_CMap_VariantCharListFunc) NULL, /* variantchar_list */ + + ~0U, + (TT_CMap_ValidateFunc)NULL, /* validate */ + (TT_CMap_Info_GetFunc)NULL /* get_cmap_info */ + ) + +#endif /* FT_CONFIG_OPTION_POSTSCRIPT_NAMES */ + #ifndef FT_CONFIG_OPTION_PIC static const TT_CMap_Class tt_cmap_classes[] = @@ -3801,8 +3907,10 @@ FT_CMap cmap = (FT_CMap)charmap; TT_CMap_Class clazz = (TT_CMap_Class)cmap->clazz; - - return clazz->get_cmap_info( charmap, cmap_info ); + if ( clazz->get_cmap_info ) + return clazz->get_cmap_info( charmap, cmap_info ); + else + return FT_THROW( Invalid_CharMap_Format ); } diff --git a/thirdparty/freetype/src/sfnt/ttcmap.h b/thirdparty/freetype/src/sfnt/ttcmap.h index 83f12df241..f7de0437b0 100644 --- a/thirdparty/freetype/src/sfnt/ttcmap.h +++ b/thirdparty/freetype/src/sfnt/ttcmap.h @@ -141,6 +141,8 @@ FT_BEGIN_HEADER #define TT_VALID_GLYPH_COUNT( x ) TT_VALIDATOR( x )->num_glyphs + FT_CALLBACK_TABLE const TT_CMap_ClassRec tt_cmap_unicode_class_rec; + FT_LOCAL( FT_Error ) tt_face_build_cmaps( TT_Face face ); diff --git a/thirdparty/freetype/src/sfnt/ttkern.c b/thirdparty/freetype/src/sfnt/ttkern.c index c97e5789ac..53d2436ae5 100644 --- a/thirdparty/freetype/src/sfnt/ttkern.c +++ b/thirdparty/freetype/src/sfnt/ttkern.c @@ -85,7 +85,7 @@ for ( nn = 0; nn < num_tables; nn++ ) { - FT_UInt num_pairs, length, coverage; + FT_UInt num_pairs, length, coverage, format; FT_Byte* p_next; FT_UInt32 mask = (FT_UInt32)1UL << nn; @@ -107,6 +107,12 @@ if ( p_next > p_limit ) /* handle broken table */ p_next = p_limit; + format = coverage >> 8; + + /* we currently only support format 0 kerning tables */ + if ( format != 0 ) + goto NextTable; + /* only use horizontal kerning tables */ if ( ( coverage & 3U ) != 0x0001 || p + 8 > p_next ) diff --git a/thirdparty/freetype/src/sfnt/ttpost.c b/thirdparty/freetype/src/sfnt/ttpost.c index 540d5f2546..69929c8d45 100644 --- a/thirdparty/freetype/src/sfnt/ttpost.c +++ b/thirdparty/freetype/src/sfnt/ttpost.c @@ -325,7 +325,6 @@ FT_UNUSED( post_limit ); - /* UNDOCUMENTED! This value appears only in the Apple TT specs. */ if ( FT_READ_USHORT( num_glyphs ) ) goto Exit; @@ -408,7 +407,7 @@ /* now read postscript table */ if ( format == 0x00020000L ) error = load_format_20( face, stream, post_limit ); - else if ( format == 0x00028000L ) + else if ( format == 0x00025000L ) error = load_format_25( face, stream, post_limit ); else error = FT_THROW( Invalid_File_Format ); @@ -447,7 +446,7 @@ FT_FREE( table->glyph_names ); table->num_names = 0; } - else if ( format == 0x00028000L ) + else if ( format == 0x00025000L ) { TT_Post_25 table = &names->names.format_25; @@ -543,7 +542,7 @@ *PSname = (FT_String*)table->glyph_names[name_index - 258]; } } - else if ( format == 0x00028000L ) + else if ( format == 0x00025000L ) { TT_Post_25 table = &names->names.format_25; diff --git a/thirdparty/freetype/src/sfnt/ttsbit.c b/thirdparty/freetype/src/sfnt/ttsbit.c index 0c76a55779..f41847b0af 100644 --- a/thirdparty/freetype/src/sfnt/ttsbit.c +++ b/thirdparty/freetype/src/sfnt/ttsbit.c @@ -448,6 +448,15 @@ metrics->max_advance = FT_MulDiv( hori->advance_Width_Max, ppem_ * 64, upem ); + /* set the scale values (in 16.16 units) so advances */ + /* from the hmtx and vmtx table are scaled correctly */ + metrics->x_scale = FT_MulDiv( metrics->x_ppem, + 64 * 0x10000, + face->header.Units_Per_EM ); + metrics->y_scale = FT_MulDiv( metrics->y_ppem, + 64 * 0x10000, + face->header.Units_Per_EM ); + return error; } @@ -1439,10 +1448,17 @@ return FT_THROW( Invalid_Table ); NoBitmap: + if ( recurse_count ) + { + FT_TRACE4(( "tt_sbit_decoder_load_image:" + " missing subglyph sbit with glyph index %d\n", + glyph_index )); + return FT_THROW( Invalid_Composite ); + } + FT_TRACE4(( "tt_sbit_decoder_load_image:" " no sbit found for glyph index %d\n", glyph_index )); - - return FT_THROW( Invalid_Argument ); + return FT_THROW( Missing_Bitmap ); } diff --git a/thirdparty/freetype/src/smooth/ftgrays.c b/thirdparty/freetype/src/smooth/ftgrays.c index e9a3ce7a7c..df645e66c9 100644 --- a/thirdparty/freetype/src/smooth/ftgrays.c +++ b/thirdparty/freetype/src/smooth/ftgrays.c @@ -141,6 +141,16 @@ #define FT_INT_MAX INT_MAX #define FT_ULONG_MAX ULONG_MAX +#define ADD_LONG( a, b ) \ + (long)( (unsigned long)(a) + (unsigned long)(b) ) +#define SUB_LONG( a, b ) \ + (long)( (unsigned long)(a) - (unsigned long)(b) ) +#define MUL_LONG( a, b ) \ + (long)( (unsigned long)(a) * (unsigned long)(b) ) +#define NEG_LONG( a ) \ + (long)( -(unsigned long)(a) ) + + #define ft_memset memset #define ft_setjmp setjmp @@ -264,6 +274,7 @@ typedef ptrdiff_t FT_PtrDist; #include "ftgrays.h" #include FT_INTERNAL_OBJECTS_H #include FT_INTERNAL_DEBUG_H +#include FT_INTERNAL_CALC_H #include FT_OUTLINE_H #include "ftsmerrs.h" @@ -1135,7 +1146,7 @@ typedef ptrdiff_t FT_PtrDist; /* s is L * the perpendicular distance from P1 to the line P0-P3. */ dx1 = arc[1].x - arc[0].x; dy1 = arc[1].y - arc[0].y; - s = FT_ABS( dy * dx1 - dx * dy1 ); + s = FT_ABS( SUB_LONG( MUL_LONG( dy, dx1 ), MUL_LONG( dx, dy1 ) ) ); if ( s > s_limit ) goto Split; @@ -1143,7 +1154,7 @@ typedef ptrdiff_t FT_PtrDist; /* s is L * the perpendicular distance from P2 to the line P0-P3. */ dx2 = arc[2].x - arc[0].x; dy2 = arc[2].y - arc[0].y; - s = FT_ABS( dy * dx2 - dx * dy2 ); + s = FT_ABS( SUB_LONG( MUL_LONG( dy, dx2 ), MUL_LONG( dx, dy2 ) ) ); if ( s > s_limit ) goto Split; diff --git a/thirdparty/freetype/src/smooth/ftsmooth.c b/thirdparty/freetype/src/smooth/ftsmooth.c index 435854e673..963435de15 100644 --- a/thirdparty/freetype/src/smooth/ftsmooth.c +++ b/thirdparty/freetype/src/smooth/ftsmooth.c @@ -31,12 +31,7 @@ static FT_Error ft_smooth_init( FT_Renderer render ) { - FT_Library library = FT_MODULE_LIBRARY( render ); - - - render->clazz->raster_class->raster_reset( render->raster, - library->raster_pool, - library->raster_pool_size ); + render->clazz->raster_class->raster_reset( render->raster, NULL, 0 ); return 0; } @@ -111,9 +106,6 @@ FT_Pos y_shift = 0; FT_Pos x_left, y_top; FT_Pos width, height, pitch; -#ifndef FT_CONFIG_OPTION_SUBPIXEL_RENDERING - FT_Pos height_org, width_org; -#endif FT_Int hmul = ( mode == FT_RENDER_MODE_LCD ); FT_Int vmul = ( mode == FT_RENDER_MODE_LCD_V ); @@ -124,7 +116,6 @@ #ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING - FT_Int lcd_extra = 0; FT_LcdFiveTapFilter lcd_weights = { 0 }; FT_Bool have_custom_weight = FALSE; FT_Bitmap_LcdFilterFunc lcd_filter_func = NULL; @@ -152,13 +143,12 @@ { /* * A per-font filter is set. It always uses the default 5-tap - * in-place FIR filter that needs 2 extra pixels. + * in-place FIR filter. */ ft_memcpy( lcd_weights, slot->face->internal->lcd_weights, FT_LCD_FILTER_FIVE_TAPS ); lcd_filter_func = ft_lcd_filter_fir; - lcd_extra = 2; } else { @@ -172,7 +162,6 @@ slot->library->lcd_weights, FT_LCD_FILTER_FIVE_TAPS ); lcd_filter_func = slot->library->lcd_filter_func; - lcd_extra = slot->library->lcd_extra; } #endif /*FT_CONFIG_OPTION_SUBPIXEL_RENDERING */ @@ -201,6 +190,45 @@ /* taking into account the origin shift */ FT_Outline_Get_CBox( outline, &cbox ); +#ifndef FT_CONFIG_OPTION_SUBPIXEL_RENDERING + + /* add minimal padding for LCD rendering */ + if ( hmul ) + { + cbox.xMax += 21; + cbox.xMin -= 21; + } + + if ( vmul ) + { + cbox.yMax += 21; + cbox.yMin -= 21; + } + +#else /* FT_CONFIG_OPTION_SUBPIXEL_RENDERING */ + + /* add minimal padding for LCD filter depending on specific weights */ + if ( lcd_filter_func ) + { + if ( hmul ) + { + cbox.xMax += lcd_weights[4] ? 43 + : lcd_weights[3] ? 22 : 0; + cbox.xMin -= lcd_weights[0] ? 43 + : lcd_weights[1] ? 22 : 0; + } + + if ( vmul ) + { + cbox.yMax += lcd_weights[4] ? 43 + : lcd_weights[3] ? 22 : 0; + cbox.yMin -= lcd_weights[0] ? 43 + : lcd_weights[1] ? 22 : 0; + } + } + +#endif /* FT_CONFIG_OPTION_SUBPIXEL_RENDERING */ + cbox.xMin = FT_PIX_FLOOR( cbox.xMin + x_shift ); cbox.yMin = FT_PIX_FLOOR( cbox.yMin + y_shift ); cbox.xMax = FT_PIX_CEIL( cbox.xMax + x_shift ); @@ -215,11 +243,6 @@ width = (FT_ULong)( cbox.xMax - cbox.xMin ) >> 6; height = (FT_ULong)( cbox.yMax - cbox.yMin ) >> 6; -#ifndef FT_CONFIG_OPTION_SUBPIXEL_RENDERING - width_org = width; - height_org = height; -#endif - pitch = width; if ( hmul ) { @@ -230,26 +253,6 @@ if ( vmul ) height *= 3; -#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING - if ( lcd_filter_func ) - { - if ( hmul ) - { - x_shift += 64 * ( lcd_extra >> 1 ); - x_left -= lcd_extra >> 1; - width += 3 * lcd_extra; - pitch = FT_PAD_CEIL( width, 4 ); - } - - if ( vmul ) - { - y_shift += 64 * ( lcd_extra >> 1 ); - y_top += lcd_extra >> 1; - height += 3 * lcd_extra; - } - } -#endif - /* * XXX: on 16bit system, we return an error for huge bitmap * to prevent an overflow. @@ -353,57 +356,98 @@ #else /* !FT_CONFIG_OPTION_SUBPIXEL_RENDERING */ - /* render outline into bitmap */ - error = render->raster_render( render->raster, ¶ms ); - if ( error ) - goto Exit; - - /* expand it horizontally */ - if ( hmul ) + if ( hmul ) /* lcd */ { - FT_Byte* line = bitmap->buffer; - FT_UInt hh; + FT_Byte* line; + FT_Byte* temp; + FT_Int i, j; - for ( hh = height_org; hh > 0; hh--, line += pitch ) - { - FT_UInt xx; - FT_Byte* end = line + width; + /* Render 3 separate monochrome bitmaps, shifting the outline */ + /* by 1/3 pixel. */ + width /= 3; + FT_Outline_Translate( outline, 21, 0 ); - for ( xx = width_org; xx > 0; xx-- ) - { - FT_UInt pixel = line[xx-1]; + error = render->raster_render( render->raster, ¶ms ); + if ( error ) + goto Exit; + + FT_Outline_Translate( outline, -21, 0 ); + bitmap->buffer += width; + + error = render->raster_render( render->raster, ¶ms ); + if ( error ) + goto Exit; + + FT_Outline_Translate( outline, -21, 0 ); + bitmap->buffer += width; + error = render->raster_render( render->raster, ¶ms ); + if ( error ) + goto Exit; - end[-3] = (FT_Byte)pixel; - end[-2] = (FT_Byte)pixel; - end[-1] = (FT_Byte)pixel; - end -= 3; + FT_Outline_Translate( outline, 21, 0 ); + bitmap->buffer -= 2 * width; + + /* XXX: Rearrange the bytes according to FT_PIXEL_MODE_LCD. */ + /* XXX: It is more efficient to render every third byte above. */ + + if ( FT_ALLOC( temp, (FT_ULong)pitch ) ) + goto Exit; + + for ( i = 0; i < height; i++ ) + { + line = bitmap->buffer + i * pitch; + for ( j = 0; j < width; j++ ) + { + temp[3 * j ] = line[j]; + temp[3 * j + 1] = line[j + width]; + temp[3 * j + 2] = line[j + width + width]; } + FT_MEM_COPY( line, temp, pitch ); } - } - /* expand it vertically */ - if ( vmul ) + FT_FREE( temp ); + } + else if ( vmul ) /* lcd_v */ { - FT_Byte* read = bitmap->buffer + ( height - height_org ) * pitch; - FT_Byte* write = bitmap->buffer; - FT_UInt hh; + /* Render 3 separate monochrome bitmaps, shifting the outline */ + /* by 1/3 pixel. Triple the pitch to render on each third row. */ + bitmap->pitch *= 3; + bitmap->rows /= 3; + FT_Outline_Translate( outline, 0, 21 ); + bitmap->buffer += 2 * pitch; - for ( hh = height_org; hh > 0; hh-- ) - { - ft_memcpy( write, read, pitch ); - write += pitch; + error = render->raster_render( render->raster, ¶ms ); + if ( error ) + goto Exit; - ft_memcpy( write, read, pitch ); - write += pitch; + FT_Outline_Translate( outline, 0, -21 ); + bitmap->buffer -= pitch; - ft_memcpy( write, read, pitch ); - write += pitch; - read += pitch; - } + error = render->raster_render( render->raster, ¶ms ); + if ( error ) + goto Exit; + + FT_Outline_Translate( outline, 0, -21 ); + bitmap->buffer -= pitch; + + error = render->raster_render( render->raster, ¶ms ); + if ( error ) + goto Exit; + + FT_Outline_Translate( outline, 0, 21 ); + + bitmap->pitch /= 3; + bitmap->rows *= 3; + } + else /* grayscale */ + { + error = render->raster_render( render->raster, ¶ms ); + if ( error ) + goto Exit; } #endif /* !FT_CONFIG_OPTION_SUBPIXEL_RENDERING */ diff --git a/thirdparty/freetype/src/truetype/ttgload.c b/thirdparty/freetype/src/truetype/ttgload.c index b7a844a6c7..5e102c6151 100644 --- a/thirdparty/freetype/src/truetype/ttgload.c +++ b/thirdparty/freetype/src/truetype/ttgload.c @@ -87,7 +87,7 @@ /*************************************************************************/ /* */ /* Return the vertical metrics in font units for a given glyph. */ - /* See macro `TT_LOADER_SET_PP' below for explanations. */ + /* See function `tt_loader_set_pp' below for explanations. */ /* */ FT_LOCAL_DEF( void ) TT_Get_VMetrics( TT_Face face, @@ -825,7 +825,7 @@ /* compatibility mode, where no movement on the x axis means no reason */ /* to change bearings or advance widths. */ if ( !( driver->interpreter_version == TT_INTERPRETER_VERSION_40 && - !loader->exec->backward_compatibility ) ) + loader->exec->backward_compatibility ) ) { #endif loader->pp1 = zone->cur[zone->n_points - 4]; @@ -1686,7 +1686,7 @@ /***********************************************************************/ /* otherwise, load a composite! */ - else if ( loader->n_contours == -1 ) + else if ( loader->n_contours < 0 ) { FT_Memory memory = face->root.memory; @@ -1697,6 +1697,9 @@ FT_ListNode node, node2; + /* normalize the `n_contours' value */ + loader->n_contours = -1; + /* * We store the glyph index directly in the `node->data' pointer, * following the glib solution (cf. macro `GUINT_TO_POINTER') with a @@ -1991,12 +1994,6 @@ } } } - else - { - /* invalid composite count (negative but not -1) */ - error = FT_THROW( Invalid_Outline ); - goto Exit; - } /***********************************************************************/ /***********************************************************************/ @@ -2100,8 +2097,8 @@ } /* set glyph dimensions */ - glyph->metrics.width = bbox.xMax - bbox.xMin; - glyph->metrics.height = bbox.yMax - bbox.yMin; + glyph->metrics.width = SUB_LONG( bbox.xMax, bbox.xMin ); + glyph->metrics.height = SUB_LONG( bbox.yMax, bbox.yMin ); /* Now take care of vertical metrics. In the case where there is */ /* no vertical information within the font (relatively common), */ @@ -2137,7 +2134,8 @@ /* table in the font. Otherwise, we use the */ /* values defined in the horizontal header. */ - height = (FT_Short)FT_DivFix( bbox.yMax - bbox.yMin, + height = (FT_Short)FT_DivFix( SUB_LONG( bbox.yMax, + bbox.yMin ), y_scale ); if ( face->os2.version != 0xFFFFU ) advance = (FT_Pos)( face->os2.sTypoAscender - @@ -2339,13 +2337,19 @@ #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL if ( driver->interpreter_version == TT_INTERPRETER_VERSION_40 ) { - subpixel_hinting_lean = TRUE; - grayscale_cleartype = !FT_BOOL( load_flags & - FT_LOAD_TARGET_LCD || - load_flags & - FT_LOAD_TARGET_LCD_V ); - exec->vertical_lcd_lean = FT_BOOL( load_flags & - FT_LOAD_TARGET_LCD_V ); + subpixel_hinting_lean = + FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) != + FT_RENDER_MODE_MONO ); + grayscale_cleartype = + FT_BOOL( subpixel_hinting_lean && + !( ( load_flags & + FT_LOAD_TARGET_LCD ) || + ( load_flags & + FT_LOAD_TARGET_LCD_V ) ) ); + exec->vertical_lcd_lean = + FT_BOOL( subpixel_hinting_lean && + ( load_flags & + FT_LOAD_TARGET_LCD_V ) ); } else { @@ -2621,7 +2625,64 @@ IS_DEFAULT_INSTANCE ) { error = load_sbit_image( size, glyph, glyph_index, load_flags ); - if ( !error ) + if ( FT_ERR_EQ( error, Missing_Bitmap ) ) + { + /* the bitmap strike is incomplete and misses the requested glyph; */ + /* if we have a bitmap-only font, return an empty glyph */ + if ( !FT_IS_SCALABLE( glyph->face ) ) + { + TT_Face face = (TT_Face)glyph->face; + FT_Short left_bearing = 0, top_bearing = 0; + FT_UShort advance_width = 0, advance_height = 0; + + + /* to return an empty glyph, however, we need metrics data */ + /* from the `hmtx' (or `vmtx') table; the assumption is that */ + /* empty glyphs are missing intentionally, representing */ + /* whitespace - not having at least horizontal metrics is */ + /* thus considered an error */ + if ( !face->horz_metrics_size ) + return error; + + /* we now construct an empty bitmap glyph */ + TT_Get_HMetrics( face, glyph_index, + &left_bearing, + &advance_width ); + TT_Get_VMetrics( face, glyph_index, + 0, + &top_bearing, + &advance_height ); + + glyph->outline.n_points = 0; + glyph->outline.n_contours = 0; + + glyph->metrics.width = 0; + glyph->metrics.height = 0; + + glyph->metrics.horiBearingX = left_bearing; + glyph->metrics.horiBearingY = 0; + glyph->metrics.horiAdvance = advance_width; + + glyph->metrics.vertBearingX = 0; + glyph->metrics.vertBearingY = top_bearing; + glyph->metrics.vertAdvance = advance_height; + + glyph->format = FT_GLYPH_FORMAT_BITMAP; + glyph->bitmap.pixel_mode = FT_PIXEL_MODE_MONO; + + glyph->bitmap_left = 0; + glyph->bitmap_top = 0; + + return FT_Err_Ok; + } + } + else if ( error ) + { + /* return error if font is not scalable */ + if ( !FT_IS_SCALABLE( glyph->face ) ) + return error; + } + else { if ( FT_IS_SCALABLE( glyph->face ) ) { diff --git a/thirdparty/freetype/src/truetype/ttgxvar.c b/thirdparty/freetype/src/truetype/ttgxvar.c index 0cedb6bdfa..49aa53a687 100644 --- a/thirdparty/freetype/src/truetype/ttgxvar.c +++ b/thirdparty/freetype/src/truetype/ttgxvar.c @@ -60,8 +60,11 @@ #define FT_Stream_FTell( stream ) \ (FT_ULong)( (stream)->cursor - (stream)->base ) -#define FT_Stream_SeekSet( stream, off ) \ - ( (stream)->cursor = (stream)->base + (off) ) +#define FT_Stream_SeekSet( stream, off ) \ + (stream)->cursor = \ + ( (off) < (FT_ULong)( (stream)->limit - (stream)->base ) ) \ + ? (stream)->base + (off) \ + : (stream)->limit /*************************************************************************/ @@ -392,14 +395,14 @@ /* some macros we need */ - #define FT_FIXED_ONE ( (FT_Fixed)0x10000 ) +#define FT_FIXED_ONE ( (FT_Fixed)0x10000 ) - #define FT_fdot14ToFixed( x ) \ - ( (FT_Fixed)( (FT_ULong)(x) << 2 ) ) - #define FT_intToFixed( i ) \ - ( (FT_Fixed)( (FT_ULong)(i) << 16 ) ) - #define FT_fixedToInt( x ) \ - ( (FT_Short)( ( (FT_UInt32)(x) + 0x8000U ) >> 16 ) ) +#define FT_fdot14ToFixed( x ) \ + ( (FT_Fixed)( (FT_ULong)(x) << 2 ) ) +#define FT_intToFixed( i ) \ + ( (FT_Fixed)( (FT_ULong)(i) << 16 ) ) +#define FT_fixedToInt( x ) \ + ( (FT_Short)( ( (FT_UInt32)(x) + 0x8000U ) >> 16 ) ) static FT_Error @@ -1953,6 +1956,7 @@ GX_FVar_Head fvar_head; FT_Bool usePsName; FT_UInt num_instances; + FT_UShort* axis_flags; static const FT_Frame_Field fvar_fields[] = { @@ -2038,14 +2042,16 @@ /* in fvar's table of named instances */ num_instances = face->root.style_flags >> 16; - /* cannot overflow 32-bit arithmetic because of the size limits */ - /* used in the `fvar' table validity check in `sfnt_init_face' */ + /* prepare storage area for MM data; this cannot overflow */ + /* 32-bit arithmetic because of the size limits used in the */ + /* `fvar' table validity check in `sfnt_init_face' */ face->blend->mmvar_len = sizeof ( FT_MM_Var ) + + fvar_head.axisCount * sizeof ( FT_UShort ) + fvar_head.axisCount * sizeof ( FT_Var_Axis ) + num_instances * sizeof ( FT_Var_Named_Style ) + num_instances * fvar_head.axisCount * sizeof ( FT_Fixed ) + - 5 * fvar_head.axisCount; + fvar_head.axisCount * 5; if ( FT_ALLOC( mmvar, face->blend->mmvar_len ) ) goto Exit; @@ -2062,8 +2068,12 @@ /* (or tuples, as called by Apple) */ mmvar->num_namedstyles = num_instances; + + /* alas, no public field in `FT_Var_Axis' for axis flags */ + axis_flags = + (FT_UShort*)&( mmvar[1] ); mmvar->axis = - (FT_Var_Axis*)&( mmvar[1] ); + (FT_Var_Axis*)&( axis_flags[fvar_head.axisCount] ); mmvar->namedstyle = (FT_Var_Named_Style*)&( mmvar->axis[fvar_head.axisCount] ); @@ -2107,6 +2117,8 @@ a->name[3] = (FT_String)( ( a->tag ) & 0xFF ); a->name[4] = '\0'; + *axis_flags = axis_rec.flags; + if ( a->minimum > a->def || a->def > a->maximum ) { @@ -2118,13 +2130,17 @@ a->maximum = a->def; } - FT_TRACE5(( " \"%s\": minimum=%.5f, default=%.5f, maximum=%.5f\n", + FT_TRACE5(( " \"%s\":" + " minimum=%.5f, default=%.5f, maximum=%.5f," + " flags=0x%04X\n", a->name, a->minimum / 65536.0, a->def / 65536.0, - a->maximum / 65536.0 )); + a->maximum / 65536.0, + *axis_flags )); a++; + axis_flags++; } FT_TRACE5(( "\n" )); @@ -2136,8 +2152,16 @@ goto Exit; if ( fvar_head.instanceCount && !face->blend->avar_loaded ) + { + FT_ULong offset = FT_STREAM_POS(); + + ft_var_load_avar( face ); + if ( FT_STREAM_SEEK( offset ) ) + goto Exit; + } + ns = mmvar->namedstyle; nsc = face->blend->normalized_stylecoords; for ( i = 0; i < fvar_head.instanceCount; i++, ns++ ) @@ -2154,8 +2178,11 @@ for ( j = 0; j < fvar_head.axisCount; j++, c++ ) *c = FT_GET_LONG(); + /* valid psid values are 6, [256;32767], and 0xFFFF */ if ( usePsName ) ns->psid = FT_GET_USHORT(); + else + ns->psid = 0xFFFF; ft_var_to_normalized( face, fvar_head.axisCount, @@ -2171,7 +2198,7 @@ SFNT_Service sfnt = (SFNT_Service)face->sfnt; FT_Int found, dummy1, dummy2; - FT_UInt strid = 0xFFFFFFFFUL; + FT_UInt strid = ~0U; /* the default instance is missing in array the */ @@ -2230,13 +2257,15 @@ goto Exit; FT_MEM_COPY( mmvar, face->blend->mmvar, face->blend->mmvar_len ); + axis_flags = + (FT_UShort*)&( mmvar[1] ); mmvar->axis = - (FT_Var_Axis*)&( mmvar[1] ); + (FT_Var_Axis*)&( axis_flags[mmvar->num_axis] ); mmvar->namedstyle = (FT_Var_Named_Style*)&( mmvar->axis[mmvar->num_axis] ); + next_coords = (FT_Fixed*)&( mmvar->namedstyle[mmvar->num_namedstyles] ); - for ( n = 0; n < mmvar->num_namedstyles; n++ ) { mmvar->namedstyle[n].coords = next_coords; @@ -2281,7 +2310,10 @@ GX_Blend blend; FT_MM_Var* mmvar; FT_UInt i, j; - FT_Bool is_default_instance = 1; + + FT_Bool is_default_instance = TRUE; + FT_Bool all_design_coords = FALSE; + FT_Memory memory = face->root.memory; enum @@ -2327,7 +2359,7 @@ } if ( coords[i] != 0 ) - is_default_instance = 0; + is_default_instance = FALSE; } FT_TRACE5(( "\n" )); @@ -2340,6 +2372,9 @@ { if ( FT_NEW_ARRAY( blend->coords, mmvar->num_axis ) ) goto Exit; + + /* the first time we have to compute all design coordinates */ + all_design_coords = TRUE; } if ( !blend->normalizedcoords ) @@ -2388,7 +2423,7 @@ if ( set_design_coords ) ft_var_to_design( face, - num_coords, + all_design_coords ? blend->num_axis : num_coords, blend->normalizedcoords, blend->coords ); @@ -2529,6 +2564,14 @@ blend = face->blend; + if ( !blend->coords ) + { + /* select default instance coordinates */ + /* if no instance is selected yet */ + if ( FT_SET_ERROR( tt_set_mm_blend( face, 0, NULL, 1 ) ) ) + return error; + } + nc = num_coords; if ( num_coords > blend->num_axis ) { @@ -2626,7 +2669,7 @@ num_coords * sizeof ( FT_Fixed ) ); a = mmvar->axis + num_coords; - c = coords + num_coords; + c = blend->coords + num_coords; for ( i = num_coords; i < mmvar->num_axis; i++, a++, c++ ) *c = a->def; @@ -2636,7 +2679,7 @@ if ( !face->blend->avar_loaded ) ft_var_load_avar( face ); - ft_var_to_normalized( face, num_coords, coords, normalized ); + ft_var_to_normalized( face, num_coords, blend->coords, normalized ); error = tt_set_mm_blend( face, mmvar->num_axis, normalized, 0 ); @@ -2686,6 +2729,14 @@ blend = face->blend; + if ( !blend->coords ) + { + /* select default instance coordinates */ + /* if no instance is selected yet */ + if ( FT_SET_ERROR( tt_set_mm_blend( face, 0, NULL, 1 ) ) ) + return error; + } + nc = num_coords; if ( num_coords > blend->num_axis ) { diff --git a/thirdparty/freetype/src/truetype/ttinterp.c b/thirdparty/freetype/src/truetype/ttinterp.c index af31408cbf..ddcc839bb3 100644 --- a/thirdparty/freetype/src/truetype/ttinterp.c +++ b/thirdparty/freetype/src/truetype/ttinterp.c @@ -65,11 +65,15 @@ TT_INTERPRETER_VERSION_40 ) #endif -#define PROJECT( v1, v2 ) \ - exc->func_project( exc, (v1)->x - (v2)->x, (v1)->y - (v2)->y ) +#define PROJECT( v1, v2 ) \ + exc->func_project( exc, \ + SUB_LONG( (v1)->x, (v2)->x ), \ + SUB_LONG( (v1)->y, (v2)->y ) ) -#define DUALPROJ( v1, v2 ) \ - exc->func_dualproj( exc, (v1)->x - (v2)->x, (v1)->y - (v2)->y ) +#define DUALPROJ( v1, v2 ) \ + exc->func_dualproj( exc, \ + SUB_LONG( (v1)->x, (v2)->x ), \ + SUB_LONG( (v1)->y, (v2)->y ) ) #define FAST_PROJECT( v ) \ exc->func_project( exc, (v)->x, (v)->y ) @@ -1676,7 +1680,10 @@ if ( SUBPIXEL_HINTING_INFINALITY && ( !exc->ignore_x_mode || ( exc->sph_tweak_flags & SPH_TWEAK_ALLOW_X_DMOVE ) ) ) - zone->cur[point].x += FT_MulDiv( distance, v, exc->F_dot_P ); + zone->cur[point].x = ADD_LONG( zone->cur[point].x, + FT_MulDiv( distance, + v, + exc->F_dot_P ) ); else #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ @@ -1685,12 +1692,18 @@ /* diagonal moves, but only post-IUP. DejaVu tries to adjust */ /* diagonal stems like on `Z' and `z' post-IUP. */ if ( SUBPIXEL_HINTING_MINIMAL && !exc->backward_compatibility ) - zone->cur[point].x += FT_MulDiv( distance, v, exc->F_dot_P ); + zone->cur[point].x = ADD_LONG( zone->cur[point].x, + FT_MulDiv( distance, + v, + exc->F_dot_P ) ); else #endif if ( NO_SUBPIXEL_HINTING ) - zone->cur[point].x += FT_MulDiv( distance, v, exc->F_dot_P ); + zone->cur[point].x = ADD_LONG( zone->cur[point].x, + FT_MulDiv( distance, + v, + exc->F_dot_P ) ); zone->tags[point] |= FT_CURVE_TAG_TOUCH_X; } @@ -1705,7 +1718,10 @@ exc->iupx_called && exc->iupy_called ) ) #endif - zone->cur[point].y += FT_MulDiv( distance, v, exc->F_dot_P ); + zone->cur[point].y = ADD_LONG( zone->cur[point].y, + FT_MulDiv( distance, + v, + exc->F_dot_P ) ); zone->tags[point] |= FT_CURVE_TAG_TOUCH_Y; } @@ -1741,12 +1757,18 @@ v = exc->GS.freeVector.x; if ( v != 0 ) - zone->org[point].x += FT_MulDiv( distance, v, exc->F_dot_P ); + zone->org[point].x = ADD_LONG( zone->org[point].x, + FT_MulDiv( distance, + v, + exc->F_dot_P ) ); v = exc->GS.freeVector.y; if ( v != 0 ) - zone->org[point].y += FT_MulDiv( distance, v, exc->F_dot_P ); + zone->org[point].y = ADD_LONG( zone->org[point].y, + FT_MulDiv( distance, + v, + exc->F_dot_P ) ); } @@ -1769,18 +1791,18 @@ { #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY if ( SUBPIXEL_HINTING_INFINALITY && !exc->ignore_x_mode ) - zone->cur[point].x += distance; + zone->cur[point].x = ADD_LONG( zone->cur[point].x, distance ); else #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL if ( SUBPIXEL_HINTING_MINIMAL && !exc->backward_compatibility ) - zone->cur[point].x += distance; + zone->cur[point].x = ADD_LONG( zone->cur[point].x, distance ); else #endif if ( NO_SUBPIXEL_HINTING ) - zone->cur[point].x += distance; + zone->cur[point].x = ADD_LONG( zone->cur[point].x, distance ); zone->tags[point] |= FT_CURVE_TAG_TOUCH_X; } @@ -1799,7 +1821,7 @@ exc->backward_compatibility && exc->iupx_called && exc->iupy_called ) ) #endif - zone->cur[point].y += distance; + zone->cur[point].y = ADD_LONG( zone->cur[point].y, distance ); zone->tags[point] |= FT_CURVE_TAG_TOUCH_Y; } @@ -1823,7 +1845,7 @@ { FT_UNUSED( exc ); - zone->org[point].x += distance; + zone->org[point].x = ADD_LONG( zone->org[point].x, distance ); } @@ -1835,7 +1857,7 @@ { FT_UNUSED( exc ); - zone->org[point].y += distance; + zone->org[point].y = ADD_LONG( zone->org[point].y, distance ); } @@ -1873,13 +1895,13 @@ if ( distance >= 0 ) { - val = distance + compensation; + val = ADD_LONG( distance, compensation ); if ( val < 0 ) val = 0; } else { - val = distance - compensation; + val = SUB_LONG( distance, compensation ); if ( val > 0 ) val = 0; } @@ -1915,13 +1937,14 @@ if ( distance >= 0 ) { - val = FT_PIX_ROUND( distance + compensation ); + val = FT_PIX_ROUND_LONG( ADD_LONG( distance, compensation ) ); if ( val < 0 ) val = 0; } else { - val = -FT_PIX_ROUND( compensation - distance ); + val = NEG_LONG( FT_PIX_ROUND_LONG( SUB_LONG( compensation, + distance ) ) ); if ( val > 0 ) val = 0; } @@ -1958,13 +1981,16 @@ if ( distance >= 0 ) { - val = FT_PIX_FLOOR( distance + compensation ) + 32; + val = ADD_LONG( FT_PIX_FLOOR( ADD_LONG( distance, compensation ) ), + 32 ); if ( val < 0 ) val = 32; } else { - val = -( FT_PIX_FLOOR( compensation - distance ) + 32 ); + val = NEG_LONG( ADD_LONG( FT_PIX_FLOOR( SUB_LONG( compensation, + distance ) ), + 32 ) ); if ( val > 0 ) val = -32; } @@ -2001,13 +2027,13 @@ if ( distance >= 0 ) { - val = FT_PIX_FLOOR( distance + compensation ); + val = FT_PIX_FLOOR( ADD_LONG( distance, compensation ) ); if ( val < 0 ) val = 0; } else { - val = -FT_PIX_FLOOR( compensation - distance ); + val = NEG_LONG( FT_PIX_FLOOR( SUB_LONG( compensation, distance ) ) ); if ( val > 0 ) val = 0; } @@ -2044,13 +2070,14 @@ if ( distance >= 0 ) { - val = FT_PIX_CEIL( distance + compensation ); + val = FT_PIX_CEIL_LONG( ADD_LONG( distance, compensation ) ); if ( val < 0 ) val = 0; } else { - val = -FT_PIX_CEIL( compensation - distance ); + val = NEG_LONG( FT_PIX_CEIL_LONG( SUB_LONG( compensation, + distance ) ) ); if ( val > 0 ) val = 0; } @@ -2087,13 +2114,14 @@ if ( distance >= 0 ) { - val = FT_PAD_ROUND( distance + compensation, 32 ); + val = FT_PAD_ROUND_LONG( ADD_LONG( distance, compensation ), 32 ); if ( val < 0 ) val = 0; } else { - val = -FT_PAD_ROUND( compensation - distance, 32 ); + val = NEG_LONG( FT_PAD_ROUND_LONG( SUB_LONG( compensation, distance ), + 32 ) ); if ( val > 0 ) val = 0; } @@ -2134,7 +2162,8 @@ if ( distance >= 0 ) { - val = ( distance - exc->phase + exc->threshold + compensation ) & + val = ADD_LONG( distance, + exc->threshold - exc->phase + compensation ) & -exc->period; val += exc->phase; if ( val < 0 ) @@ -2142,8 +2171,9 @@ } else { - val = -( ( exc->threshold - exc->phase - distance + compensation ) & - -exc->period ); + val = NEG_LONG( SUB_LONG( exc->threshold - exc->phase + compensation, + distance ) & + -exc->period ); val -= exc->phase; if ( val > 0 ) val = -exc->phase; @@ -2183,7 +2213,8 @@ if ( distance >= 0 ) { - val = ( ( distance - exc->phase + exc->threshold + compensation ) / + val = ( ADD_LONG( distance, + exc->threshold - exc->phase + compensation ) / exc->period ) * exc->period; val += exc->phase; if ( val < 0 ) @@ -2191,8 +2222,9 @@ } else { - val = -( ( ( exc->threshold - exc->phase - distance + compensation ) / - exc->period ) * exc->period ); + val = NEG_LONG( ( SUB_LONG( exc->threshold - exc->phase + compensation, + distance ) / + exc->period ) * exc->period ); val -= exc->phase; if ( val > 0 ) val = -exc->phase; @@ -2826,7 +2858,7 @@ static void Ins_ADD( FT_Long* args ) { - args[0] += args[1]; + args[0] = ADD_LONG( args[0], args[1] ); } @@ -2839,7 +2871,7 @@ static void Ins_SUB( FT_Long* args ) { - args[0] -= args[1]; + args[0] = SUB_LONG( args[0], args[1] ); } @@ -2882,7 +2914,8 @@ static void Ins_ABS( FT_Long* args ) { - args[0] = FT_ABS( args[0] ); + if ( args[0] < 0 ) + args[0] = NEG_LONG( args[0] ); } @@ -2895,7 +2928,7 @@ static void Ins_NEG( FT_Long* args ) { - args[0] = -args[0]; + args[0] = NEG_LONG( args[0] ); } @@ -4211,8 +4244,8 @@ p1 = exc->zp1.cur + aIdx2; p2 = exc->zp2.cur + aIdx1; - A = p1->x - p2->x; - B = p1->y - p2->y; + A = SUB_LONG( p1->x, p2->x ); + B = SUB_LONG( p1->y, p2->y ); /* If p1 == p2, SPvTL and SFvTL behave the same as */ /* SPvTCA[X] and SFvTCA[X], respectively. */ @@ -4227,9 +4260,9 @@ if ( ( opcode & 1 ) != 0 ) { - C = B; /* counter clockwise rotation */ - B = A; - A = -C; + C = B; /* counter clockwise rotation */ + B = A; + A = NEG_LONG( C ); } Normalize( A, B, Vec ); @@ -4770,7 +4803,7 @@ K = FAST_PROJECT( &exc->zp2.cur[L] ); - exc->func_move( exc, &exc->zp2, L, args[1] - K ); + exc->func_move( exc, &exc->zp2, L, SUB_LONG( args[1], K ) ); /* UNDOCUMENTED! The MS rasterizer does that with */ /* twilight points (confirmed by Greg Hitchcock) */ @@ -4894,12 +4927,12 @@ } { - FT_Vector* v1 = exc->zp1.org + p2; - FT_Vector* v2 = exc->zp2.org + p1; + FT_Vector* v1 = exc->zp1.org + p2; + FT_Vector* v2 = exc->zp2.org + p1; - A = v1->x - v2->x; - B = v1->y - v2->y; + A = SUB_LONG( v1->x, v2->x ); + B = SUB_LONG( v1->y, v2->y ); /* If v1 == v2, SDPvTL behaves the same as */ /* SVTCA[X], respectively. */ @@ -4915,9 +4948,9 @@ if ( ( opcode & 1 ) != 0 ) { - C = B; /* counter clockwise rotation */ - B = A; - A = -C; + C = B; /* counter clockwise rotation */ + B = A; + A = NEG_LONG( C ); } Normalize( A, B, &exc->GS.dualVector ); @@ -4927,8 +4960,8 @@ FT_Vector* v2 = exc->zp2.cur + p1; - A = v1->x - v2->x; - B = v1->y - v2->y; + A = SUB_LONG( v1->x, v2->x ); + B = SUB_LONG( v1->y, v2->y ); if ( A == 0 && B == 0 ) { @@ -4939,9 +4972,9 @@ if ( ( opcode & 1 ) != 0 ) { - C = B; /* counter clockwise rotation */ - B = A; - A = -C; + C = B; /* counter clockwise rotation */ + B = A; + A = NEG_LONG( C ); } Normalize( A, B, &exc->GS.projVector ); @@ -5392,7 +5425,7 @@ if ( !( SUBPIXEL_HINTING_MINIMAL && exc->backward_compatibility ) ) #endif - exc->zp2.cur[point].x += dx; + exc->zp2.cur[point].x = ADD_LONG( exc->zp2.cur[point].x, dx ); if ( touch ) exc->zp2.tags[point] |= FT_CURVE_TAG_TOUCH_X; @@ -5406,7 +5439,7 @@ exc->iupx_called && exc->iupy_called ) ) #endif - exc->zp2.cur[point].y += dy; + exc->zp2.cur[point].y = ADD_LONG( exc->zp2.cur[point].y, dy ); if ( touch ) exc->zp2.tags[point] |= FT_CURVE_TAG_TOUCH_Y; @@ -5781,14 +5814,17 @@ #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY /* subpixel hinting - make MSIRP respect CVT cut-in; */ - if ( SUBPIXEL_HINTING_INFINALITY && - exc->ignore_x_mode && - exc->GS.freeVector.x != 0 && - FT_ABS( distance - args[1] ) >= control_value_cutin ) + if ( SUBPIXEL_HINTING_INFINALITY && + exc->ignore_x_mode && + exc->GS.freeVector.x != 0 && + FT_ABS( SUB_LONG( distance, args[1] ) ) >= control_value_cutin ) distance = args[1]; #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ - exc->func_move( exc, &exc->zp1, point, args[1] - distance ); + exc->func_move( exc, + &exc->zp1, + point, + SUB_LONG( args[1], distance ) ); exc->GS.rp1 = exc->GS.rp0; exc->GS.rp2 = point; @@ -6027,8 +6063,10 @@ FT_Vector vec; - vec.x = FT_MulFix( vec1->x - vec2->x, exc->metrics.x_scale ); - vec.y = FT_MulFix( vec1->y - vec2->y, exc->metrics.y_scale ); + vec.x = FT_MulFix( SUB_LONG( vec1->x, vec2->x ), + exc->metrics.x_scale ); + vec.y = FT_MulFix( SUB_LONG( vec1->y, vec2->y ), + exc->metrics.y_scale ); org_dist = FAST_DUALPROJ( &vec ); } @@ -6081,8 +6119,8 @@ } else { - if ( distance > -minimum_distance ) - distance = -minimum_distance; + if ( distance > NEG_LONG( minimum_distance ) ) + distance = NEG_LONG( minimum_distance ); } } @@ -6090,7 +6128,7 @@ org_dist = PROJECT( exc->zp1.cur + point, exc->zp0.cur + exc->GS.rp0 ); - exc->func_move( exc, &exc->zp1, point, distance - org_dist ); + exc->func_move( exc, &exc->zp1, point, SUB_LONG( distance, org_dist ) ); Fail: exc->GS.rp1 = exc->GS.rp0; @@ -6265,8 +6303,8 @@ } else { - if ( distance > -minimum_distance ) - distance = -minimum_distance; + if ( distance > NEG_LONG( minimum_distance ) ) + distance = NEG_LONG( minimum_distance ); } } @@ -6290,7 +6328,10 @@ } #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ - exc->func_move( exc, &exc->zp1, point, distance - cur_dist ); + exc->func_move( exc, + &exc->zp1, + point, + SUB_LONG( distance, cur_dist ) ); #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY if ( SUBPIXEL_HINTING_INFINALITY ) @@ -6314,7 +6355,10 @@ } if ( reverse_move ) - exc->func_move( exc, &exc->zp1, point, -( distance - cur_dist ) ); + exc->func_move( exc, + &exc->zp1, + point, + SUB_LONG( cur_dist, distance ) ); } #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ @@ -6380,7 +6424,7 @@ distance = PROJECT( exc->zp1.cur + point, exc->zp0.cur + exc->GS.rp0 ); - exc->func_move( exc, &exc->zp1, point, -distance ); + exc->func_move( exc, &exc->zp1, point, NEG_LONG( distance ) ); } exc->GS.loop--; @@ -6437,19 +6481,19 @@ /* Cramer's rule */ - dbx = exc->zp0.cur[b1].x - exc->zp0.cur[b0].x; - dby = exc->zp0.cur[b1].y - exc->zp0.cur[b0].y; + dbx = SUB_LONG( exc->zp0.cur[b1].x, exc->zp0.cur[b0].x ); + dby = SUB_LONG( exc->zp0.cur[b1].y, exc->zp0.cur[b0].y ); - dax = exc->zp1.cur[a1].x - exc->zp1.cur[a0].x; - day = exc->zp1.cur[a1].y - exc->zp1.cur[a0].y; + dax = SUB_LONG( exc->zp1.cur[a1].x, exc->zp1.cur[a0].x ); + day = SUB_LONG( exc->zp1.cur[a1].y, exc->zp1.cur[a0].y ); - dx = exc->zp0.cur[b0].x - exc->zp1.cur[a0].x; - dy = exc->zp0.cur[b0].y - exc->zp1.cur[a0].y; + dx = SUB_LONG( exc->zp0.cur[b0].x, exc->zp1.cur[a0].x ); + dy = SUB_LONG( exc->zp0.cur[b0].y, exc->zp1.cur[a0].y ); - discriminant = FT_MulDiv( dax, -dby, 0x40 ) + - FT_MulDiv( day, dbx, 0x40 ); - dotproduct = FT_MulDiv( dax, dbx, 0x40 ) + - FT_MulDiv( day, dby, 0x40 ); + discriminant = ADD_LONG( FT_MulDiv( dax, NEG_LONG( dby ), 0x40 ), + FT_MulDiv( day, dbx, 0x40 ) ); + dotproduct = ADD_LONG( FT_MulDiv( dax, dbx, 0x40 ), + FT_MulDiv( day, dby, 0x40 ) ); /* The discriminant above is actually a cross product of vectors */ /* da and db. Together with the dot product, they can be used as */ @@ -6459,30 +6503,29 @@ /* discriminant = |da||db|sin(angle) . */ /* We use these equations to reject grazing intersections by */ /* thresholding abs(tan(angle)) at 1/19, corresponding to 3 degrees. */ - if ( 19 * FT_ABS( discriminant ) > FT_ABS( dotproduct ) ) + if ( MUL_LONG( 19, FT_ABS( discriminant ) ) > FT_ABS( dotproduct ) ) { - val = FT_MulDiv( dx, -dby, 0x40 ) + FT_MulDiv( dy, dbx, 0x40 ); + val = ADD_LONG( FT_MulDiv( dx, NEG_LONG( dby ), 0x40 ), + FT_MulDiv( dy, dbx, 0x40 ) ); R.x = FT_MulDiv( val, dax, discriminant ); R.y = FT_MulDiv( val, day, discriminant ); /* XXX: Block in backward_compatibility and/or post-IUP? */ - exc->zp2.cur[point].x = exc->zp1.cur[a0].x + R.x; - exc->zp2.cur[point].y = exc->zp1.cur[a0].y + R.y; + exc->zp2.cur[point].x = ADD_LONG( exc->zp1.cur[a0].x, R.x ); + exc->zp2.cur[point].y = ADD_LONG( exc->zp1.cur[a0].y, R.y ); } else { /* else, take the middle of the middles of A and B */ /* XXX: Block in backward_compatibility and/or post-IUP? */ - exc->zp2.cur[point].x = ( exc->zp1.cur[a0].x + - exc->zp1.cur[a1].x + - exc->zp0.cur[b0].x + - exc->zp0.cur[b1].x ) / 4; - exc->zp2.cur[point].y = ( exc->zp1.cur[a0].y + - exc->zp1.cur[a1].y + - exc->zp0.cur[b0].y + - exc->zp0.cur[b1].y ) / 4; + exc->zp2.cur[point].x = + ADD_LONG( ADD_LONG( exc->zp1.cur[a0].x, exc->zp1.cur[a1].x ), + ADD_LONG( exc->zp0.cur[b0].x, exc->zp0.cur[b1].x ) ) / 4; + exc->zp2.cur[point].y = + ADD_LONG( ADD_LONG( exc->zp1.cur[a0].y, exc->zp1.cur[a1].y ), + ADD_LONG( exc->zp0.cur[b0].y, exc->zp0.cur[b1].y ) ) / 4; } exc->zp2.tags[point] |= FT_CURVE_TAG_TOUCH_BOTH; @@ -6517,7 +6560,7 @@ distance = PROJECT( exc->zp0.cur + p2, exc->zp1.cur + p1 ) / 2; exc->func_move( exc, &exc->zp1, p1, distance ); - exc->func_move( exc, &exc->zp0, p2, -distance ); + exc->func_move( exc, &exc->zp0, p2, NEG_LONG( distance ) ); } @@ -6590,9 +6633,11 @@ FT_Vector vec; - vec.x = FT_MulFix( exc->zp1.orus[exc->GS.rp2].x - orus_base->x, + vec.x = FT_MulFix( SUB_LONG( exc->zp1.orus[exc->GS.rp2].x, + orus_base->x ), exc->metrics.x_scale ); - vec.y = FT_MulFix( exc->zp1.orus[exc->GS.rp2].y - orus_base->y, + vec.y = FT_MulFix( SUB_LONG( exc->zp1.orus[exc->GS.rp2].y, + orus_base->y ), exc->metrics.y_scale ); old_range = FAST_DUALPROJ( &vec ); @@ -6627,9 +6672,11 @@ FT_Vector vec; - vec.x = FT_MulFix( exc->zp2.orus[point].x - orus_base->x, + vec.x = FT_MulFix( SUB_LONG( exc->zp2.orus[point].x, + orus_base->x ), exc->metrics.x_scale ); - vec.y = FT_MulFix( exc->zp2.orus[point].y - orus_base->y, + vec.y = FT_MulFix( SUB_LONG( exc->zp2.orus[point].y, + orus_base->y ), exc->metrics.y_scale ); org_dist = FAST_DUALPROJ( &vec ); @@ -6668,7 +6715,7 @@ exc->func_move( exc, &exc->zp2, (FT_UShort)point, - new_dist - cur_dist ); + SUB_LONG( new_dist, cur_dist ) ); } Fail: @@ -6733,14 +6780,14 @@ FT_F26Dot6 dx; - dx = worker->curs[p].x - worker->orgs[p].x; + dx = SUB_LONG( worker->curs[p].x, worker->orgs[p].x ); if ( dx != 0 ) { for ( i = p1; i < p; i++ ) - worker->curs[i].x += dx; + worker->curs[i].x = ADD_LONG( worker->curs[i].x, dx ); for ( i = p + 1; i <= p2; i++ ) - worker->curs[i].x += dx; + worker->curs[i].x = ADD_LONG( worker->curs[i].x, dx ); } } @@ -6785,8 +6832,8 @@ org2 = worker->orgs[ref2].x; cur1 = worker->curs[ref1].x; cur2 = worker->curs[ref2].x; - delta1 = cur1 - org1; - delta2 = cur2 - org2; + delta1 = SUB_LONG( cur1, org1 ); + delta2 = SUB_LONG( cur2, org2 ); if ( cur1 == cur2 || orus1 == orus2 ) { @@ -6798,10 +6845,10 @@ if ( x <= org1 ) - x += delta1; + x = ADD_LONG( x, delta1 ); else if ( x >= org2 ) - x += delta2; + x = ADD_LONG( x, delta2 ); else x = cur1; @@ -6822,20 +6869,23 @@ if ( x <= org1 ) - x += delta1; + x = ADD_LONG( x, delta1 ); else if ( x >= org2 ) - x += delta2; + x = ADD_LONG( x, delta2 ); else { if ( !scale_valid ) { scale_valid = 1; - scale = FT_DivFix( cur2 - cur1, orus2 - orus1 ); + scale = FT_DivFix( SUB_LONG( cur2, cur1 ), + SUB_LONG( orus2, orus1 ) ); } - x = cur1 + FT_MulFix( worker->orus[i].x - orus1, scale ); + x = ADD_LONG( cur1, + FT_MulFix( SUB_LONG( worker->orus[i].x, orus1 ), + scale ) ); } worker->curs[i].x = x; } @@ -7310,7 +7360,11 @@ K |= 1 << 12; #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL - if ( SUBPIXEL_HINTING_MINIMAL ) + /* Toggle the following flags only outside of monochrome mode. */ + /* Otherwise, instructions may behave weirdly and rendering results */ + /* may differ between v35 and v40 mode, e.g., in `Times New Roman */ + /* Bold Italic'. */ + if ( SUBPIXEL_HINTING_MINIMAL && exc->subpixel_hinting_lean ) { /********************************/ /* HINTING FOR SUBPIXEL */ @@ -7345,7 +7399,7 @@ /* */ /* The only smoothing method FreeType supports unless someone sets */ /* FT_LOAD_TARGET_MONO. */ - if ( ( args[0] & 2048 ) != 0 ) + if ( ( args[0] & 2048 ) != 0 && exc->subpixel_hinting_lean ) K |= 1 << 18; /********************************/ @@ -7589,11 +7643,21 @@ #endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */ #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL - /* Toggle backward compatibility according to what font says, except */ - /* when it's a `tricky' font that heavily relies on the interpreter to */ - /* render glyphs correctly, e.g. DFKai-SB. Backward compatibility */ - /* hacks may break it. */ + /* + * Toggle backward compatibility according to what font wants, except + * when + * + * 1) we have a `tricky' font that heavily relies on the interpreter to + * render glyphs correctly, for example DFKai-SB, or + * 2) FT_RENDER_MODE_MONO (i.e, monochome rendering) is requested. + * + * In those cases, backward compatibility needs to be turned off to get + * correct rendering. The rendering is then completely up to the + * font's programming. + * + */ if ( SUBPIXEL_HINTING_MINIMAL && + exc->subpixel_hinting_lean && !FT_IS_TRICKY( &exc->face->root ) ) exc->backward_compatibility = !( exc->GS.instruct_control & 4 ); else @@ -7639,8 +7703,7 @@ FT_MAX( 50, exc->cvtSize / 10 ); else - exc->loopcall_counter_max = FT_MAX( 100, - 10 * exc->cvtSize ); + exc->loopcall_counter_max = 300 + 8 * exc->cvtSize; /* as a protection against an unreasonable number of CVT entries */ /* we assume at most 100 control values per glyph for the counter */ diff --git a/thirdparty/freetype/src/truetype/ttinterp.h b/thirdparty/freetype/src/truetype/ttinterp.h index 55e472091c..abbecfcee3 100644 --- a/thirdparty/freetype/src/truetype/ttinterp.h +++ b/thirdparty/freetype/src/truetype/ttinterp.h @@ -253,23 +253,38 @@ FT_BEGIN_HEADER #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL /* - * Modern TrueType fonts are usually rendered through Microsoft's - * collection of rendering techniques called ClearType (e.g., subpixel - * rendering and subpixel hinting). When ClearType was introduced, most - * fonts were not ready. Microsoft decided to implement a backward - * compatibility mode that employed several simple to complicated - * assumptions and tricks that modified the interpretation of the - * bytecode contained in these fonts to make them look ClearType-y - * somehow. Most (web)fonts that were released since then have come to - * rely on these hacks to render correctly, even some of Microsoft's - * flagship ClearType fonts (Calibri, Cambria, Segoe UI). + * FreeType supports ClearType-like hinting of TrueType fonts through + * the version 40 interpreter. This is achieved through several hacks + * in the base (v35) interpreter, as detailed below. * - * The minimal subpixel hinting code (interpreter version 40) employs a - * small list of font-agnostic hacks to bludgeon non-native-ClearType - * fonts (except tricky ones[1]) into submission. It will not try to - * toggle hacks for specific fonts for performance and complexity - * reasons. The focus is on modern (web)fonts rather than legacy fonts - * that were made for black-and-white rendering. + * ClearType is an umbrella term for several rendering techniques + * employed by Microsoft's various GUI and rendering toolkit + * implementations, most importantly: subpixel rendering for using the + * RGB subpixels of LCDs to approximately triple the perceived + * resolution on the x-axis and subpixel hinting for positioning stems + * on subpixel borders. TrueType programming is explicit, i.e., fonts + * must be programmed to take advantage of ClearType's possibilities. + * + * When ClearType was introduced, it seemed unlikely that all fonts + * would be reprogrammed, so Microsoft decided to implement a backward + * compatibility mode. It employs several simple to complicated + * assumptions and tricks, many of them font-dependent, that modify the + * interpretation of the bytecode contained in these fonts to retrofit + * them into a ClearType-y look. The quality of the results varies. + * Most (web)fonts that were released since then have come to rely on + * these hacks to render correctly, even some of Microsoft's flagship + * fonts (e.g., Calibri, Cambria, Segoe UI). + * + * FreeType's minimal subpixel hinting code (interpreter version 40) + * employs a small list of font-agnostic hacks loosely based on the + * public information available on Microsoft's compatibility mode[2]. + * The focus is on modern (web)fonts rather than legacy fonts that were + * made for monochrome rendering. It will not match ClearType rendering + * exactly. Unlike the `Infinality' code (interpreter version 38) that + * came before, it will not try to toggle hacks for specific fonts for + * performance and complexity reasons. It will fall back to version 35 + * behavior for tricky fonts[1] or when monochrome rendering is + * requested. * * Major hacks * @@ -347,7 +362,8 @@ FT_BEGIN_HEADER * */ - /* Using v40 implies subpixel hinting. Used to detect interpreter */ + /* Using v40 implies subpixel hinting, unless FT_RENDER_MODE_MONO has been + * requested. Used to detect interpreter */ /* version switches. `_lean' to differentiate from the Infinality */ /* `subpixel_hinting', which is managed differently. */ FT_Bool subpixel_hinting_lean; diff --git a/thirdparty/freetype/src/truetype/ttobjs.c b/thirdparty/freetype/src/truetype/ttobjs.c index 4db0f289f8..081fa2f1a5 100644 --- a/thirdparty/freetype/src/truetype/ttobjs.c +++ b/thirdparty/freetype/src/truetype/ttobjs.c @@ -576,9 +576,11 @@ /* We must also be able to accept Mac/GX fonts, as well as OT ones. */ /* The 0x00020000 tag is completely undocumented; some fonts from */ /* Arphic made for Chinese Windows 3.1 have this. */ - if ( face->format_tag != 0x00010000L && /* MS fonts */ - face->format_tag != 0x00020000L && /* CJK fonts for Win 3.1 */ - face->format_tag != TTAG_true ) /* Mac fonts */ + if ( face->format_tag != 0x00010000L && /* MS fonts */ + face->format_tag != 0x00020000L && /* CJK fonts for Win 3.1 */ + face->format_tag != TTAG_true && /* Mac fonts */ + face->format_tag != TTAG_0xA5kbd && /* `Keyboard.dfont' (legacy Mac OS X) */ + face->format_tag != TTAG_0xA5lst ) /* `LastResort.dfont' (legacy Mac OS X) */ { FT_TRACE2(( " not a TTF font\n" )); goto Bad_Format; @@ -1230,7 +1232,9 @@ /* <Input> */ /* size :: A handle to the target size object. */ /* */ - /* only_height :: Only recompute ascender, descender, and height. */ + /* only_height :: Only recompute ascender, descender, and height; */ + /* this flag is used for variation fonts where */ + /* `tt_size_reset' is used as an iterator function. */ /* */ FT_LOCAL_DEF( FT_Error ) tt_size_reset( TT_Size size, @@ -1277,7 +1281,11 @@ size->ttmetrics.valid = TRUE; if ( only_height ) + { + /* we must not recompute the scaling values here since */ + /* `tt_size_reset' was already called (with only_height = 0) */ return FT_Err_Ok; + } if ( face->header.Flags & 8 ) { diff --git a/thirdparty/freetype/src/truetype/ttpload.c b/thirdparty/freetype/src/truetype/ttpload.c index 70ac15da4a..bcf6b34f67 100644 --- a/thirdparty/freetype/src/truetype/ttpload.c +++ b/thirdparty/freetype/src/truetype/ttpload.c @@ -247,13 +247,13 @@ if ( pos2 > face->glyf_len ) { /* We try to sanitize the last `loca' entry. */ - if ( gindex == face->num_locations - 1 ) + if ( gindex == face->num_locations - 2 ) { FT_TRACE1(( "tt_face_get_location:" - " too large offset (0x%08lx) found for glyph index %ld,\n" + " too large size (%ld bytes) found for glyph index %ld,\n" " " - " truncating at the end of `glyf' table (0x%08lx)\n", - pos2, gindex + 1, face->glyf_len )); + " truncating at the end of `glyf' table to %ld bytes\n", + pos2 - pos1, gindex, face->glyf_len - pos1 )); pos2 = face->glyf_len; } else diff --git a/thirdparty/freetype/src/type1/t1load.c b/thirdparty/freetype/src/type1/t1load.c index f5c661f7de..f569d6bec3 100644 --- a/thirdparty/freetype/src/type1/t1load.c +++ b/thirdparty/freetype/src/type1/t1load.c @@ -329,8 +329,8 @@ for ( i = 0; i < mmaster.num_axis; i++ ) { mmvar->axis[i].name = mmaster.axis[i].name; - mmvar->axis[i].minimum = INT_TO_FIXED( mmaster.axis[i].minimum); - mmvar->axis[i].maximum = INT_TO_FIXED( mmaster.axis[i].maximum); + mmvar->axis[i].minimum = INT_TO_FIXED( mmaster.axis[i].minimum ); + mmvar->axis[i].maximum = INT_TO_FIXED( mmaster.axis[i].maximum ); mmvar->axis[i].def = ( mmvar->axis[i].minimum + mmvar->axis[i].maximum ) / 2; /* Does not apply. But this value is in range */ diff --git a/thirdparty/freetype/src/type1/t1objs.c b/thirdparty/freetype/src/type1/t1objs.c index 97c16b0fdf..5ac1292ae0 100644 --- a/thirdparty/freetype/src/type1/t1objs.c +++ b/thirdparty/freetype/src/type1/t1objs.c @@ -555,12 +555,6 @@ if ( clazz ) error = FT_CMap_New( clazz, NULL, &charmap, NULL ); - -#if 0 - /* Select default charmap */ - if (root->num_charmaps) - root->charmap = root->charmaps[0]; -#endif } } diff --git a/thirdparty/freetype/src/type42/t42objs.c b/thirdparty/freetype/src/type42/t42objs.c index 87e5206b7f..1c4ebd768a 100644 --- a/thirdparty/freetype/src/type42/t42objs.c +++ b/thirdparty/freetype/src/type42/t42objs.c @@ -394,12 +394,6 @@ if ( clazz ) error = FT_CMap_New( clazz, NULL, &charmap, NULL ); - -#if 0 - /* Select default charmap */ - if ( root->num_charmaps ) - root->charmap = root->charmaps[0]; -#endif } } Exit: diff --git a/thirdparty/freetype/src/winfonts/winfnt.c b/thirdparty/freetype/src/winfonts/winfnt.c index 9811fbb05a..4c47962319 100644 --- a/thirdparty/freetype/src/winfonts/winfnt.c +++ b/thirdparty/freetype/src/winfonts/winfnt.c @@ -859,10 +859,6 @@ NULL ); if ( error ) goto Fail; - - /* Select default charmap */ - if ( root->num_charmaps ) - root->charmap = root->charmaps[0]; } /* set up remaining flags */ @@ -1095,7 +1091,7 @@ /* note: since glyphs are stored in columns and not in rows we */ /* can't use ft_glyphslot_set_bitmap */ - if ( FT_ALLOC_MULT( bitmap->buffer, pitch, bitmap->rows ) ) + if ( FT_ALLOC_MULT( bitmap->buffer, bitmap->rows, pitch ) ) goto Exit; column = (FT_Byte*)bitmap->buffer; |