Path: blob/master/modules/text_server_fb/thorvg_svg_in_ot.h
10277 views
/**************************************************************************/1/* thorvg_svg_in_ot.h */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#pragma once3132#ifdef GDEXTENSION33// Headers for building as GDExtension plug-in.3435#include <godot_cpp/core/mutex_lock.hpp>36#include <godot_cpp/godot.hpp>37#include <godot_cpp/templates/hash_map.hpp>3839using namespace godot;4041#elif defined(GODOT_MODULE)42// Headers for building as built-in module.4344#include "core/os/mutex.h"45#include "core/templates/hash_map.h"46#include "core/typedefs.h"4748#include "modules/modules_enabled.gen.h" // For svg, freetype.49#endif5051#ifdef MODULE_SVG_ENABLED52#ifdef MODULE_FREETYPE_ENABLED5354#include <freetype/freetype.h>55#include <freetype/otsvg.h>56#include <ft2build.h>57#include <thorvg.h>5859struct GL_State {60bool ready = false;61float x = 0;62float y = 0;63float w = 0;64float h = 0;65CharString xml_code;66tvg::Matrix m;67};6869struct TVG_NodeCache {70uint64_t document_offset;71uint64_t body_offset;72};7374struct TVG_DocumentCache {75String xml_body;76double embox_x;77double embox_y;78HashMap<int64_t, Vector<TVG_NodeCache>> node_caches;79};8081struct TVG_State {82Mutex mutex;83HashMap<uint32_t, GL_State> glyph_map;84HashMap<FT_Byte *, TVG_DocumentCache> document_map;85};8687FT_Error tvg_svg_in_ot_init(FT_Pointer *p_state);88void tvg_svg_in_ot_free(FT_Pointer *p_state);89FT_Error tvg_svg_in_ot_preset_slot(FT_GlyphSlot p_slot, FT_Bool p_cache, FT_Pointer *p_state);90FT_Error tvg_svg_in_ot_render(FT_GlyphSlot p_slot, FT_Pointer *p_state);9192SVG_RendererHooks *get_tvg_svg_in_ot_hooks();9394#endif // MODULE_FREETYPE_ENABLED95#endif // MODULE_SVG_ENABLED969798