/*************************************************************************/ /* font_config_plugin.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ /* "Software"), to deal in the Software without restriction, including */ /* without limitation the rights to use, copy, modify, merge, publish, */ /* distribute, sublicense, and/or sell copies of the Software, and to */ /* permit persons to whom the Software is furnished to do so, subject to */ /* the following conditions: */ /* */ /* The above copyright notice and this permission notice shall be */ /* included in all copies or substantial portions of the Software. */ /* */ /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "font_config_plugin.h" #include "editor/editor_scale.h" #include "editor/import/dynamic_font_import_settings.h" /*************************************************************************/ /* EditorPropertyFontMetaObject */ /*************************************************************************/ bool EditorPropertyFontMetaObject::_set(const StringName &p_name, const Variant &p_value) { String name = p_name; if (name.begins_with("keys")) { String key = name.get_slicec('/', 1); dict[key] = p_value; return true; } return false; } bool EditorPropertyFontMetaObject::_get(const StringName &p_name, Variant &r_ret) const { String name = p_name; if (name.begins_with("keys")) { String key = name.get_slicec('/', 1); r_ret = dict[key]; return true; } return false; } void EditorPropertyFontMetaObject::_bind_methods() { } void EditorPropertyFontMetaObject::set_dict(const Dictionary &p_dict) { dict = p_dict; } Dictionary EditorPropertyFontMetaObject::get_dict() { return dict; } /*************************************************************************/ /* EditorPropertyFontOTObject */ /*************************************************************************/ bool EditorPropertyFontOTObject::_set(const StringName &p_name, const Variant &p_value) { String name = p_name; if (name.begins_with("keys")) { int key = name.get_slicec('/', 1).to_int(); dict[key] = p_value; return true; } return false; } bool EditorPropertyFontOTObject::_get(const StringName &p_name, Variant &r_ret) const { String name = p_name; if (name.begins_with("keys")) { int key = name.get_slicec('/', 1).to_int(); r_ret = dict[key]; return true; } return false; } void EditorPropertyFontOTObject::set_dict(const Dictionary &p_dict) { dict = p_dict; } Dictionary EditorPropertyFontOTObject::get_dict() { return dict; } void EditorPropertyFontOTObject::set_defaults(const Dictionary &p_dict) { defaults_dict = p_dict; } Dictionary EditorPropertyFontOTObject::get_defaults() { return defaults_dict; } bool EditorPropertyFontOTObject::_property_can_revert(const StringName &p_name) const { String name = p_name; if (name.begins_with("keys")) { int key = name.get_slicec('/', 1).to_int(); if (defaults_dict.has(key) && dict.has(key)) { int value = dict[key]; Vector3i range = defaults_dict[key]; return range.z != value; } } return false; } bool EditorPropertyFontOTObject::_property_get_revert(const StringName &p_name, Variant &r_property) const { String name = p_name; if (name.begins_with("keys")) { int key = name.get_slicec('/', 1).to_int(); if (defaults_dict.has(key)) { Vector3i range = defaults_dict[key]; r_property = range.z; return true; } } return false; } /*************************************************************************/ /* EditorPropertyFontMetaOverride */ /*************************************************************************/ void EditorPropertyFontMetaOverride::_notification(int p_what) { switch (p_what) { case NOTIFICATION_THEME_CHANGED: { if (Object::cast_to