Path: blob/master/modules/text_server_fb/thorvg_svg_in_ot.h
11389 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/string/ustring.h"46#include "core/templates/hash_map.h"47#include "core/typedefs.h"4849#include "modules/modules_enabled.gen.h" // For svg, freetype.50#endif5152#ifdef MODULE_SVG_ENABLED53#ifdef MODULE_FREETYPE_ENABLED5455#include <freetype/freetype.h>56#include <freetype/otsvg.h>57#include <ft2build.h>58#include <thorvg.h>5960struct GL_State {61bool ready = false;62float x = 0;63float y = 0;64float w = 0;65float h = 0;66CharString xml_code;67tvg::Matrix m;68};6970struct TVG_NodeCache {71uint64_t document_offset;72uint64_t body_offset;73};7475struct TVG_DocumentCache {76String xml_body;77double embox_x;78double embox_y;79HashMap<int64_t, Vector<TVG_NodeCache>> node_caches;80};8182struct TVG_State {83Mutex mutex;84HashMap<uint32_t, GL_State> glyph_map;85HashMap<FT_Byte *, TVG_DocumentCache> document_map;86};8788FT_Error tvg_svg_in_ot_init(FT_Pointer *p_state);89void tvg_svg_in_ot_free(FT_Pointer *p_state);90FT_Error tvg_svg_in_ot_preset_slot(FT_GlyphSlot p_slot, FT_Bool p_cache, FT_Pointer *p_state);91FT_Error tvg_svg_in_ot_render(FT_GlyphSlot p_slot, FT_Pointer *p_state);9293SVG_RendererHooks *get_tvg_svg_in_ot_hooks();9495#endif // MODULE_FREETYPE_ENABLED96#endif // MODULE_SVG_ENABLED979899