Working example
This commit is contained in:
169
sdl3/ttf/LICENSE.freetype.txt
Normal file
169
sdl3/ttf/LICENSE.freetype.txt
Normal file
@@ -0,0 +1,169 @@
|
||||
The FreeType Project LICENSE
|
||||
----------------------------
|
||||
|
||||
2006-Jan-27
|
||||
|
||||
Copyright 1996-2002, 2006 by
|
||||
David Turner, Robert Wilhelm, and Werner Lemberg
|
||||
|
||||
|
||||
|
||||
Introduction
|
||||
============
|
||||
|
||||
The FreeType Project is distributed in several archive packages;
|
||||
some of them may contain, in addition to the FreeType font engine,
|
||||
various tools and contributions which rely on, or relate to, the
|
||||
FreeType Project.
|
||||
|
||||
This license applies to all files found in such packages, and
|
||||
which do not fall under their own explicit license. The license
|
||||
affects thus the FreeType font engine, the test programs,
|
||||
documentation and makefiles, at the very least.
|
||||
|
||||
This license was inspired by the BSD, Artistic, and IJG
|
||||
(Independent JPEG Group) licenses, which all encourage inclusion
|
||||
and use of free software in commercial and freeware products
|
||||
alike. As a consequence, its main points are that:
|
||||
|
||||
o We don't promise that this software works. However, we will be
|
||||
interested in any kind of bug reports. (`as is' distribution)
|
||||
|
||||
o You can use this software for whatever you want, in parts or
|
||||
full form, without having to pay us. (`royalty-free' usage)
|
||||
|
||||
o You may not pretend that you wrote this software. If you use
|
||||
it, or only parts of it, in a program, you must acknowledge
|
||||
somewhere in your documentation that you have used the
|
||||
FreeType code. (`credits')
|
||||
|
||||
We specifically permit and encourage the inclusion of this
|
||||
software, with or without modifications, in commercial products.
|
||||
We disclaim all warranties covering The FreeType Project and
|
||||
assume no liability related to The FreeType Project.
|
||||
|
||||
|
||||
Finally, many people asked us for a preferred form for a
|
||||
credit/disclaimer to use in compliance with this license. We thus
|
||||
encourage you to use the following text:
|
||||
|
||||
"""
|
||||
Portions of this software are copyright © <year> The FreeType
|
||||
Project (www.freetype.org). All rights reserved.
|
||||
"""
|
||||
|
||||
Please replace <year> with the value from the FreeType version you
|
||||
actually use.
|
||||
|
||||
|
||||
Legal Terms
|
||||
===========
|
||||
|
||||
0. Definitions
|
||||
--------------
|
||||
|
||||
Throughout this license, the terms `package', `FreeType Project',
|
||||
and `FreeType archive' refer to the set of files originally
|
||||
distributed by the authors (David Turner, Robert Wilhelm, and
|
||||
Werner Lemberg) as the `FreeType Project', be they named as alpha,
|
||||
beta or final release.
|
||||
|
||||
`You' refers to the licensee, or person using the project, where
|
||||
`using' is a generic term including compiling the project's source
|
||||
code as well as linking it to form a `program' or `executable'.
|
||||
This program is referred to as `a program using the FreeType
|
||||
engine'.
|
||||
|
||||
This license applies to all files distributed in the original
|
||||
FreeType Project, including all source code, binaries and
|
||||
documentation, unless otherwise stated in the file in its
|
||||
original, unmodified form as distributed in the original archive.
|
||||
If you are unsure whether or not a particular file is covered by
|
||||
this license, you must contact us to verify this.
|
||||
|
||||
The FreeType Project is copyright (C) 1996-2000 by David Turner,
|
||||
Robert Wilhelm, and Werner Lemberg. All rights reserved except as
|
||||
specified below.
|
||||
|
||||
1. No Warranty
|
||||
--------------
|
||||
|
||||
THE FREETYPE PROJECT IS PROVIDED `AS IS' WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. IN NO EVENT WILL ANY OF THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
BE LIABLE FOR ANY DAMAGES CAUSED BY THE USE OR THE INABILITY TO
|
||||
USE, OF THE FREETYPE PROJECT.
|
||||
|
||||
2. Redistribution
|
||||
-----------------
|
||||
|
||||
This license grants a worldwide, royalty-free, perpetual and
|
||||
irrevocable right and license to use, execute, perform, compile,
|
||||
display, copy, create derivative works of, distribute and
|
||||
sublicense the FreeType Project (in both source and object code
|
||||
forms) and derivative works thereof for any purpose; and to
|
||||
authorize others to exercise some or all of the rights granted
|
||||
herein, subject to the following conditions:
|
||||
|
||||
o Redistribution of source code must retain this license file
|
||||
(`FTL.TXT') unaltered; any additions, deletions or changes to
|
||||
the original files must be clearly indicated in accompanying
|
||||
documentation. The copyright notices of the unaltered,
|
||||
original files must be preserved in all copies of source
|
||||
files.
|
||||
|
||||
o Redistribution in binary form must provide a disclaimer that
|
||||
states that the software is based in part of the work of the
|
||||
FreeType Team, in the distribution documentation. We also
|
||||
encourage you to put an URL to the FreeType web page in your
|
||||
documentation, though this isn't mandatory.
|
||||
|
||||
These conditions apply to any software derived from or based on
|
||||
the FreeType Project, not just the unmodified files. If you use
|
||||
our work, you must acknowledge us. However, no fee need be paid
|
||||
to us.
|
||||
|
||||
3. Advertising
|
||||
--------------
|
||||
|
||||
Neither the FreeType authors and contributors nor you shall use
|
||||
the name of the other for commercial, advertising, or promotional
|
||||
purposes without specific prior written permission.
|
||||
|
||||
We suggest, but do not require, that you use one or more of the
|
||||
following phrases to refer to this software in your documentation
|
||||
or advertising materials: `FreeType Project', `FreeType Engine',
|
||||
`FreeType library', or `FreeType Distribution'.
|
||||
|
||||
As you have not signed this license, you are not required to
|
||||
accept it. However, as the FreeType Project is copyrighted
|
||||
material, only this license, or another one contracted with the
|
||||
authors, grants you the right to use, distribute, and modify it.
|
||||
Therefore, by using, distributing, or modifying the FreeType
|
||||
Project, you indicate that you understand and accept all the terms
|
||||
of this license.
|
||||
|
||||
4. Contacts
|
||||
-----------
|
||||
|
||||
There are two mailing lists related to FreeType:
|
||||
|
||||
o freetype@nongnu.org
|
||||
|
||||
Discusses general use and applications of FreeType, as well as
|
||||
future and wanted additions to the library and distribution.
|
||||
If you are looking for support, start in this list if you
|
||||
haven't found anything to help you in the documentation.
|
||||
|
||||
o freetype-devel@nongnu.org
|
||||
|
||||
Discusses bugs, as well as engine internals, design issues,
|
||||
specific licenses, porting, etc.
|
||||
|
||||
Our home page can be found at
|
||||
|
||||
https://www.freetype.org
|
||||
|
||||
|
||||
--- end of FTL.TXT ---
|
||||
42
sdl3/ttf/LICENSE.harfbuzz.txt
Normal file
42
sdl3/ttf/LICENSE.harfbuzz.txt
Normal file
@@ -0,0 +1,42 @@
|
||||
HarfBuzz is licensed under the so-called "Old MIT" license. Details follow.
|
||||
For parts of HarfBuzz that are licensed under different licenses see individual
|
||||
files names COPYING in subdirectories where applicable.
|
||||
|
||||
Copyright © 2010-2022 Google, Inc.
|
||||
Copyright © 2015-2020 Ebrahim Byagowi
|
||||
Copyright © 2019,2020 Facebook, Inc.
|
||||
Copyright © 2012,2015 Mozilla Foundation
|
||||
Copyright © 2011 Codethink Limited
|
||||
Copyright © 2008,2010 Nokia Corporation and/or its subsidiary(-ies)
|
||||
Copyright © 2009 Keith Stribley
|
||||
Copyright © 2011 Martin Hosken and SIL International
|
||||
Copyright © 2007 Chris Wilson
|
||||
Copyright © 2005,2006,2020,2021,2022,2023 Behdad Esfahbod
|
||||
Copyright © 2004,2007,2008,2009,2010,2013,2021,2022,2023 Red Hat, Inc.
|
||||
Copyright © 1998-2005 David Turner and Werner Lemberg
|
||||
Copyright © 2016 Igalia S.L.
|
||||
Copyright © 2022 Matthias Clasen
|
||||
Copyright © 2018,2021 Khaled Hosny
|
||||
Copyright © 2018,2019,2020 Adobe, Inc
|
||||
Copyright © 2013-2015 Alexei Podtelezhnikov
|
||||
|
||||
For full copyright notices consult the individual files in the package.
|
||||
|
||||
|
||||
Permission is hereby granted, without written agreement and without
|
||||
license or royalty fees, to use, copy, modify, and distribute this
|
||||
software and its documentation for any purpose, provided that the
|
||||
above copyright notice and the following two paragraphs appear in
|
||||
all copies of this software.
|
||||
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
|
||||
DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
|
||||
ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
|
||||
IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGE.
|
||||
|
||||
THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
|
||||
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
|
||||
ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
|
||||
PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
||||
21
sdl3/ttf/LICENSE.plutosvg.txt
Normal file
21
sdl3/ttf/LICENSE.plutosvg.txt
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020-2025 Samuel Ugochukwu <sammycageagle@gmail.com>
|
||||
|
||||
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.
|
||||
21
sdl3/ttf/LICENSE.plutovg.txt
Normal file
21
sdl3/ttf/LICENSE.plutovg.txt
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020-2025 Samuel Ugochukwu <sammycageagle@gmail.com>
|
||||
|
||||
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.
|
||||
17
sdl3/ttf/LICENSE.txt
Normal file
17
sdl3/ttf/LICENSE.txt
Normal file
@@ -0,0 +1,17 @@
|
||||
Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
181
sdl3/ttf/include/SDL_textengine.h
Normal file
181
sdl3/ttf/include/SDL_textengine.h
Normal file
@@ -0,0 +1,181 @@
|
||||
/*
|
||||
SDL_ttf: A companion library to SDL for working with TrueType (tm) fonts
|
||||
Copyright (C) 2001-2025 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* \file SDL_textengine.h
|
||||
*
|
||||
* Definitions for implementations of the TTF_TextEngine interface.
|
||||
*/
|
||||
#ifndef SDL_TTF_TEXTENGINE_H_
|
||||
#define SDL_TTF_TEXTENGINE_H_
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3_ttf/SDL_ttf.h>
|
||||
|
||||
#include <SDL3/SDL_begin_code.h>
|
||||
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* A font atlas draw command.
|
||||
*
|
||||
* \since This enum is available since SDL_ttf 3.0.0.
|
||||
*/
|
||||
typedef enum TTF_DrawCommand
|
||||
{
|
||||
TTF_DRAW_COMMAND_NOOP,
|
||||
TTF_DRAW_COMMAND_FILL,
|
||||
TTF_DRAW_COMMAND_COPY
|
||||
} TTF_DrawCommand;
|
||||
|
||||
/**
|
||||
* A filled rectangle draw operation.
|
||||
*
|
||||
* \since This struct is available since SDL_ttf 3.0.0.
|
||||
*
|
||||
* \sa TTF_DrawOperation
|
||||
*/
|
||||
typedef struct TTF_FillOperation
|
||||
{
|
||||
TTF_DrawCommand cmd; /**< TTF_DRAW_COMMAND_FILL */
|
||||
SDL_Rect rect; /**< The rectangle to fill, in pixels. The x coordinate is relative to the left side of the text area, going right, and the y coordinate is relative to the top side of the text area, going down. */
|
||||
} TTF_FillOperation;
|
||||
|
||||
/**
|
||||
* A texture copy draw operation.
|
||||
*
|
||||
* \since This struct is available since SDL_ttf 3.0.0.
|
||||
*
|
||||
* \sa TTF_DrawOperation
|
||||
*/
|
||||
typedef struct TTF_CopyOperation
|
||||
{
|
||||
TTF_DrawCommand cmd; /**< TTF_DRAW_COMMAND_COPY */
|
||||
int text_offset; /**< The offset in the text corresponding to this glyph.
|
||||
There may be multiple glyphs with the same text offset
|
||||
and the next text offset might be several Unicode codepoints
|
||||
later. In this case the glyphs and codepoints are grouped
|
||||
together and the group bounding box is the union of the dst
|
||||
rectangles for the corresponding glyphs. */
|
||||
TTF_Font *glyph_font; /**< The font containing the glyph to be drawn, can be passed to TTF_GetGlyphImageForIndex() */
|
||||
Uint32 glyph_index; /**< The glyph index of the glyph to be drawn, can be passed to TTF_GetGlyphImageForIndex() */
|
||||
SDL_Rect src; /**< The area within the glyph to be drawn */
|
||||
SDL_Rect dst; /**< The drawing coordinates of the glyph, in pixels. The x coordinate is relative to the left side of the text area, going right, and the y coordinate is relative to the top side of the text area, going down. */
|
||||
void *reserved;
|
||||
} TTF_CopyOperation;
|
||||
|
||||
/**
|
||||
* A text engine draw operation.
|
||||
*
|
||||
* \since This struct is available since SDL_ttf 3.0.0.
|
||||
*/
|
||||
typedef union TTF_DrawOperation
|
||||
{
|
||||
TTF_DrawCommand cmd;
|
||||
TTF_FillOperation fill;
|
||||
TTF_CopyOperation copy;
|
||||
} TTF_DrawOperation;
|
||||
|
||||
|
||||
/* Private data in TTF_Text, to assist in text measurement and layout */
|
||||
typedef struct TTF_TextLayout TTF_TextLayout;
|
||||
|
||||
|
||||
/* Private data in TTF_Text, available to implementations */
|
||||
struct TTF_TextData
|
||||
{
|
||||
TTF_Font *font; /**< The font used by this text, read-only. */
|
||||
SDL_FColor color; /**< The color of the text, read-only. */
|
||||
|
||||
bool needs_layout_update; /**< True if the layout needs to be updated */
|
||||
TTF_TextLayout *layout; /**< Cached layout information, read-only. */
|
||||
int x; /**< The x offset of the upper left corner of this text, in pixels, read-only. */
|
||||
int y; /**< The y offset of the upper left corner of this text, in pixels, read-only. */
|
||||
int w; /**< The width of this text, in pixels, read-only. */
|
||||
int h; /**< The height of this text, in pixels, read-only. */
|
||||
int num_ops; /**< The number of drawing operations to render this text, read-only. */
|
||||
TTF_DrawOperation *ops; /**< The drawing operations used to render this text, read-only. */
|
||||
int num_clusters; /**< The number of substrings representing clusters of glyphs in the string, read-only */
|
||||
TTF_SubString *clusters; /**< Substrings representing clusters of glyphs in the string, read-only */
|
||||
|
||||
SDL_PropertiesID props; /**< Custom properties associated with this text, read-only. This field is created as-needed using TTF_GetTextProperties() and the properties may be then set and read normally */
|
||||
|
||||
bool needs_engine_update; /**< True if the engine text needs to be updated */
|
||||
TTF_TextEngine *engine; /**< The engine used to render this text, read-only. */
|
||||
void *engine_text; /**< The implementation-specific representation of this text */
|
||||
};
|
||||
|
||||
/**
|
||||
* A text engine interface.
|
||||
*
|
||||
* This structure should be initialized using SDL_INIT_INTERFACE()
|
||||
*
|
||||
* \since This struct is available since SDL_ttf 3.0.0.
|
||||
*
|
||||
* \sa SDL_INIT_INTERFACE
|
||||
*/
|
||||
struct TTF_TextEngine
|
||||
{
|
||||
Uint32 version; /**< The version of this interface */
|
||||
|
||||
void *userdata; /**< User data pointer passed to callbacks */
|
||||
|
||||
/* Create a text representation from draw instructions.
|
||||
*
|
||||
* All fields of `text` except `internal->engine_text` will already be filled out.
|
||||
*
|
||||
* This function should set the `internal->engine_text` field to a non-NULL value.
|
||||
*
|
||||
* \param userdata the userdata pointer in this interface.
|
||||
* \param text the text object being created.
|
||||
*/
|
||||
bool (SDLCALL *CreateText)(void *userdata, TTF_Text *text);
|
||||
|
||||
/**
|
||||
* Destroy a text representation.
|
||||
*/
|
||||
void (SDLCALL *DestroyText)(void *userdata, TTF_Text *text);
|
||||
|
||||
};
|
||||
|
||||
/* Check the size of TTF_TextEngine
|
||||
*
|
||||
* If this assert fails, either the compiler is padding to an unexpected size,
|
||||
* or the interface has been updated and this should be updated to match and
|
||||
* the code using this interface should be updated to handle the old version.
|
||||
*/
|
||||
SDL_COMPILE_TIME_ASSERT(TTF_TextEngine_SIZE,
|
||||
(sizeof(void *) == 4 && sizeof(TTF_TextEngine) == 16) ||
|
||||
(sizeof(void *) == 8 && sizeof(TTF_TextEngine) == 32));
|
||||
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#include <SDL3/SDL_close_code.h>
|
||||
|
||||
#endif /* SDL_TTF_TEXTENGINE_H_ */
|
||||
|
||||
2833
sdl3/ttf/include/SDL_ttf.h
Normal file
2833
sdl3/ttf/include/SDL_ttf.h
Normal file
File diff suppressed because it is too large
Load Diff
62
sdl3/ttf/sdl3_textengine.odin
Normal file
62
sdl3/ttf/sdl3_textengine.odin
Normal file
@@ -0,0 +1,62 @@
|
||||
package sdl3_ttf
|
||||
|
||||
import "core:c"
|
||||
import SDL "vendor:sdl3"
|
||||
|
||||
DrawCommand :: enum c.int {
|
||||
NOOP,
|
||||
FILL,
|
||||
COPY,
|
||||
}
|
||||
|
||||
FillOperation :: struct {
|
||||
cmd: DrawCommand,
|
||||
rect: SDL.Rect,
|
||||
}
|
||||
|
||||
CopyOperation :: struct {
|
||||
cmd: DrawCommand,
|
||||
text_offset: c.int,
|
||||
glyph_font: ^Font,
|
||||
glyph_index: u32,
|
||||
src: SDL.Rect,
|
||||
dst: SDL.Rect,
|
||||
reserved: rawptr,
|
||||
}
|
||||
|
||||
DrawOperation :: struct #raw_union {
|
||||
cmd: DrawCommand,
|
||||
fill: FillOperation,
|
||||
copy: CopyOperation,
|
||||
}
|
||||
|
||||
TextLayout :: struct {}
|
||||
|
||||
TextData :: struct {
|
||||
font: ^Font,
|
||||
color: SDL.FColor,
|
||||
needs_layout_update: bool,
|
||||
layout: ^TextLayout,
|
||||
x, y: c.int,
|
||||
w, h: c.int,
|
||||
num_ops: c.int,
|
||||
ops: [^]DrawOperation `fmt:"v,num_ops"`,
|
||||
num_clusters: c.int,
|
||||
clusters: [^]SubString `fmt:"v,num_clusters"`,
|
||||
props: SDL.PropertiesID,
|
||||
needs_engine_update: bool,
|
||||
engine: ^TextEngine,
|
||||
engine_text: rawptr,
|
||||
}
|
||||
|
||||
TextEngine :: struct {
|
||||
version: u32,
|
||||
userdata: rawptr,
|
||||
CreateText: proc "c" (userdata: rawptr, text: ^Text) -> bool,
|
||||
DestroyText: proc "c" (userdata: rawptr, Textext: ^Text),
|
||||
}
|
||||
|
||||
#assert(
|
||||
(size_of(TextEngine) == 16 && size_of(rawptr) == 4) ||
|
||||
(size_of(TextEngine) == 32 && size_of(rawptr) == 8),
|
||||
)
|
||||
293
sdl3/ttf/sdl3_ttf.odin
Normal file
293
sdl3/ttf/sdl3_ttf.odin
Normal file
@@ -0,0 +1,293 @@
|
||||
// Bindings for [[ SDL3 TTF ; https://wiki.libsdl.org/SDL3_ttf/FrontPage ]].
|
||||
package sdl3_ttf
|
||||
|
||||
import "core:c"
|
||||
import SDL "vendor:sdl3"
|
||||
|
||||
when ODIN_OS == .Windows {
|
||||
foreign import lib "SDL3_ttf.lib"
|
||||
} else {
|
||||
foreign import lib "system:SDL3_ttf"
|
||||
}
|
||||
|
||||
|
||||
PROP_FONT_CREATE_FILENAME_STRING :: "SDL_ttf.font.create.filename"
|
||||
PROP_FONT_CREATE_IOSTREAM_POINTER :: "SDL_ttf.font.create.iostream"
|
||||
PROP_FONT_CREATE_IOSTREAM_OFFSET_NUMBER :: "SDL_ttf.font.create.iostream.offset"
|
||||
PROP_FONT_CREATE_IOSTREAM_AUTOCLOSE_BOOLEAN :: "SDL_ttf.font.create.iostream.autoclose"
|
||||
PROP_FONT_CREATE_SIZE_FLOAT :: "SDL_ttf.font.create.size"
|
||||
PROP_FONT_CREATE_FACE_NUMBER :: "SDL_ttf.font.create.face"
|
||||
PROP_FONT_CREATE_HORIZONTAL_DPI_NUMBER :: "SDL_ttf.font.create.hdpi"
|
||||
PROP_FONT_CREATE_VERTICAL_DPI_NUMBER :: "SDL_ttf.font.create.vdpi"
|
||||
PROP_FONT_CREATE_EXISTING_FONT :: "SDL_ttf.font.create.existing_font"
|
||||
|
||||
FONT_WEIGHT_THIN :: 100 /**< Thin (100) named font weight value */
|
||||
FONT_WEIGHT_EXTRA_LIGHT :: 200 /**< ExtraLight (200) named font weight value */
|
||||
FONT_WEIGHT_LIGHT :: 300 /**< Light (300) named font weight value */
|
||||
FONT_WEIGHT_NORMAL :: 400 /**< Normal (400) named font weight value */
|
||||
FONT_WEIGHT_MEDIUM :: 500 /**< Medium (500) named font weight value */
|
||||
FONT_WEIGHT_SEMI_BOLD :: 600 /**< SemiBold (600) named font weight value */
|
||||
FONT_WEIGHT_BOLD :: 700 /**< Bold (700) named font weight value */
|
||||
FONT_WEIGHT_EXTRA_BOLD :: 800 /**< ExtraBold (800) named font weight value */
|
||||
FONT_WEIGHT_BLACK :: 900 /**< Black (900) named font weight value */
|
||||
FONT_WEIGHT_EXTRA_BLACK :: 950 /**< ExtraBlack (950) named font weight value */
|
||||
|
||||
PROP_RENDERER_TEXT_ENGINE_RENDERER :: "SDL_ttf.renderer_text_engine.create.renderer"
|
||||
PROP_RENDERER_TEXT_ENGINE_ATLAS_TEXTURE_SIZE :: "SDL_ttf.renderer_text_engine.create.atlas_texture_size"
|
||||
|
||||
PROP_GPU_TEXT_ENGINE_DEVICE :: "SDL_ttf.gpu_text_engine.create.device"
|
||||
PROP_GPU_TEXT_ENGINE_ATLAS_TEXTURE_SIZE :: "SDL_ttf.gpu_text_engine.create.atlas_texture_size"
|
||||
|
||||
MAJOR_VERSION :: 3
|
||||
MINOR_VERSION :: 2
|
||||
PATCHLEVEL :: 2
|
||||
|
||||
Font :: struct {}
|
||||
|
||||
Text :: struct {
|
||||
text: [^]u8,
|
||||
num_lines: c.int,
|
||||
refcount: c.int,
|
||||
internal: ^TextData,
|
||||
}
|
||||
|
||||
FontStyle :: enum u32 {
|
||||
BOLD,
|
||||
ITALIC,
|
||||
UNDERLINE,
|
||||
STRIKETHROUGH,
|
||||
}
|
||||
|
||||
FontStyleFlags :: distinct bit_set[FontStyle; u32]
|
||||
|
||||
// NOTE: This is called TTF_HintingFlags but its not a bit_set so
|
||||
// the "flags" doesn't really make sense, its just the hinting.
|
||||
Hinting :: enum c.int {
|
||||
INVALID = -1,
|
||||
NORMAL,
|
||||
LIGHT,
|
||||
MONO,
|
||||
NONE,
|
||||
LIGHT_SUBPIXEL,
|
||||
}
|
||||
|
||||
HorizontalAlignment :: enum c.int {
|
||||
INVALID = -1,
|
||||
LEFT,
|
||||
CENTER,
|
||||
RIGHT,
|
||||
}
|
||||
|
||||
Direction :: enum c.int {
|
||||
INVALID,
|
||||
LTR = 4,
|
||||
RTL,
|
||||
TTB,
|
||||
BTT,
|
||||
}
|
||||
|
||||
ImageType :: enum c.int {
|
||||
INVALID,
|
||||
ALPHA,
|
||||
COLOR,
|
||||
SDF,
|
||||
}
|
||||
|
||||
GPUAtlasDrawSequence :: struct {
|
||||
atlas_texture: ^SDL.GPUTexture,
|
||||
xy, uv: [^]SDL.FPoint `fmt:"v,num_vertices"`,
|
||||
num_vertices: c.int,
|
||||
indices: [^]c.int `fmt:"v,num_indices"`,
|
||||
num_indices: c.int,
|
||||
image_type: ImageType,
|
||||
next: ^GPUAtlasDrawSequence,
|
||||
}
|
||||
|
||||
GPUTextEngineWinding :: enum c.int {
|
||||
INVALID = -1,
|
||||
CLOCKWISE = 0,
|
||||
COUNTER_CLOCKWISE = +1,
|
||||
}
|
||||
|
||||
SubStringFlags :: bit_field u32 {
|
||||
direction: u8 | 8,
|
||||
text_start: bool | 1,
|
||||
line_start: bool | 1,
|
||||
line_end: bool | 1,
|
||||
text_end: bool | 1,
|
||||
}
|
||||
|
||||
SubString :: struct {
|
||||
flags: SubStringFlags,
|
||||
offset, length: c.int,
|
||||
line_index, cluster_index: c.int,
|
||||
rect: SDL.Rect,
|
||||
}
|
||||
|
||||
@(default_calling_convention="c", link_prefix="TTF_", require_results)
|
||||
foreign lib {
|
||||
Version :: proc() -> c.int ---
|
||||
WasInit :: proc() -> c.int ---
|
||||
|
||||
OpenFont :: proc(file: cstring, ptsize: f32) -> ^Font ---
|
||||
OpenFontIO :: proc(src: ^SDL.IOStream, closeio: bool, ptsize: f32) -> ^Font ---
|
||||
OpenFontWithProperties :: proc(props: SDL.PropertiesID) -> ^Font ---
|
||||
|
||||
CopyFont :: proc(existing_font: ^Font) -> ^Font ---
|
||||
|
||||
GetFontProperties :: proc(font: ^Font) -> SDL.PropertiesID ---
|
||||
GetFontGeneration :: proc(font: ^Font) -> u32 ---
|
||||
|
||||
GetFontSize :: proc(font: ^Font) -> f32 ---
|
||||
|
||||
SetFontStyle :: proc(font: ^Font, style: FontStyleFlags) ---
|
||||
GetFontStyle :: proc(font: ^Font) -> FontStyleFlags ---
|
||||
|
||||
SetFontOutline :: proc(font: ^Font, outline: c.int) -> bool ---
|
||||
GetFontOutline :: proc(font: ^Font) -> c.int ---
|
||||
|
||||
SetFontHinting :: proc(font: ^Font, hinting: Hinting) ---
|
||||
GetFontHinting :: proc(font: ^Font) -> Hinting ---
|
||||
|
||||
GetNumFontFaces :: proc(font: ^Font) -> c.int ---
|
||||
|
||||
SetFontSDF :: proc(font: ^Font, enabled: bool) -> bool ---
|
||||
GetFontSDF :: proc(font: ^Font) -> bool ---
|
||||
|
||||
GetFontWeight :: proc(font: ^Font) -> c.int ---
|
||||
|
||||
SetFontWrapAlignment :: proc(font: ^Font, align: HorizontalAlignment) ---
|
||||
GetFontWrapAlignment :: proc(font: ^Font) -> HorizontalAlignment ---
|
||||
|
||||
GetFontHeight :: proc(font: ^Font) -> c.int ---
|
||||
GetFontAscent :: proc(font: ^Font) -> c.int ---
|
||||
GetFontDescent :: proc(font: ^Font) -> c.int ---
|
||||
|
||||
SetFontLineSkip :: proc(font: ^Font, lineskip: c.int) ---
|
||||
GetFontLineSkip :: proc(font: ^Font) -> c.int ---
|
||||
|
||||
SetFontKerning :: proc(font: ^Font, enabled: bool) ---
|
||||
GetFontKerning :: proc(font: ^Font) -> bool ---
|
||||
|
||||
FontIsFixedWidth :: proc(font: ^Font) -> bool ---
|
||||
FontIsScalable :: proc(font: ^Font) -> bool ---
|
||||
|
||||
GetFontFamilyName :: proc(font: ^Font) -> cstring ---
|
||||
GetFontStyleName :: proc(font: ^Font) -> cstring ---
|
||||
|
||||
GetFontDirection :: proc(font: ^Font) -> Direction ---
|
||||
|
||||
StringToTag :: proc(string: cstring) -> u32 ---
|
||||
|
||||
GetFontScript :: proc(font: ^Font) -> u32 ---
|
||||
|
||||
GetGlyphScript :: proc(ch: u32) -> u32 ---
|
||||
FontHasGlyph :: proc(font: ^Font, ch: u32) -> bool ---
|
||||
GetGlyphImage :: proc(font: ^Font, ch: u32, image_type: ^ImageType) -> ^SDL.Surface ---
|
||||
GetGlyphImageForIndex :: proc(font: ^Font, glyph_index: u32, image_type: ^ImageType) -> ^SDL.Surface ---
|
||||
|
||||
RenderText_Solid :: proc(font: ^Font, text: cstring, length: c.size_t, fg: SDL.Color) -> ^SDL.Surface ---
|
||||
RenderText_Solid_Wrapped :: proc(font: ^Font, text: cstring, length: c.size_t, fg: SDL.Color, wrap_Length: c.int) -> ^SDL.Surface ---
|
||||
RenderGlyph_Solid :: proc(font: ^Font, ch: u32, fg: SDL.Color) -> ^SDL.Surface ---
|
||||
RenderText_Shaded :: proc(font: ^Font, text: cstring, length: c.size_t, fg, bg: SDL.Color) -> ^SDL.Surface ---
|
||||
RenderText_Shaded_Wrapped :: proc(font: ^Font, text: cstring, length: c.size_t, fg, bg: SDL.Color, wrap_width: c.int) -> ^SDL.Surface ---
|
||||
RenderGlyph_Shaded :: proc(font: ^Font, ch: u32, fg, bg: SDL.Color) -> ^SDL.Surface ---
|
||||
RenderText_Blended :: proc(font: ^Font, text: cstring, length: c.size_t, fg: SDL.Color) -> ^SDL.Surface ---
|
||||
RenderText_Blended_Wrapped :: proc(font: ^Font, text: cstring, length: c.size_t, fg: SDL.Color, wrap_width: c.int) -> ^SDL.Surface ---
|
||||
RenderGlyph_Blended :: proc(font: ^Font, ch: u32, fg: SDL.Color) -> ^SDL.Surface ---
|
||||
RenderText_LCD :: proc(font: ^Font, text: cstring, length: c.size_t, fg, bg: SDL.Color) -> ^SDL.Surface ---
|
||||
RenderText_LCD_Wrapped :: proc(font: ^Font, text: cstring, length: c.size_t, fg, bg: SDL.Color, wrap_width: c.int) -> ^SDL.Surface ---
|
||||
RenderGlyph_LCD :: proc(font: ^Font, ch: u32, fg, bg: SDL.Color) -> ^SDL.Surface ---
|
||||
|
||||
CreateSurfaceTextEngine :: proc() -> ^TextEngine ---
|
||||
|
||||
CreateRendererTextEngine :: proc(renderer: ^SDL.Renderer) -> ^TextEngine ---
|
||||
CreateRendererTextEngineWithProperties :: proc(props: SDL.PropertiesID) -> ^TextEngine ---
|
||||
|
||||
CreateGPUTextEngine :: proc(device: ^SDL.GPUDevice) -> ^TextEngine ---
|
||||
CreateGPUTextEngineWithProperties :: proc(props: SDL.PropertiesID) -> ^TextEngine ---
|
||||
GetGPUTextDrawData :: proc(text: ^Text) -> ^GPUAtlasDrawSequence ---
|
||||
SetGPUTextEngineWinding :: proc(engine: ^TextEngine, winding: GPUTextEngineWinding) ---
|
||||
GetGPUTextEngineWinding :: proc(#by_ptr engine: TextEngine) -> GPUTextEngineWinding ---
|
||||
|
||||
CreateText :: proc(engine: ^TextEngine, font: ^Font, text: cstring, length: c.size_t) -> ^Text ---
|
||||
GetTextProperties :: proc(text: ^Text) -> SDL.PropertiesID ---
|
||||
GetTextEngine :: proc(text: ^Text) -> ^TextEngine ---
|
||||
GetTextFont :: proc(text: ^Text) -> ^Font ---
|
||||
GetTextDirection :: proc(text: ^Text) -> Direction ---
|
||||
GetTextScript :: proc(text: ^Text) -> u32 ---
|
||||
TextWrapWhitespaceVisible :: proc(text: ^Text) -> bool ---
|
||||
|
||||
GetTextSubStringsForRange :: proc(text: ^Text, offset, length: c.int, count: ^c.int) -> [^]^SubString ---
|
||||
}
|
||||
|
||||
@(default_calling_convention="c", link_prefix="TTF_")
|
||||
foreign lib {
|
||||
GetFreeTypeVersion :: proc(major, minor, patch: ^c.int) ---
|
||||
GetHarfBuzzVersion :: proc(major, minor, patch: ^c.int) ---
|
||||
|
||||
Init :: proc() -> bool ---
|
||||
|
||||
AddFallbackFont :: proc(font: ^Font, fallback: ^Font) -> bool ---
|
||||
RemoveFallbackFont :: proc(font: ^Font, fallback: ^Font) ---
|
||||
ClearFallbackFonts :: proc(font: ^Font) ---
|
||||
|
||||
SetFontSize :: proc(font: ^Font, ptsize: f32) -> bool ---
|
||||
SetFontSizeDPI :: proc(font: ^Font, ptsize: f32, hdpi: c.int, vdpi: c.int) -> bool ---
|
||||
GetFontDPI :: proc(font: ^Font, hdpi: ^c.int, vdpi: ^c.int) -> bool ---
|
||||
|
||||
SetFontDirection :: proc(font: ^Font, direction: Direction) -> bool ---
|
||||
|
||||
TagToString :: proc(tag: u32, string: [^]c.char, size: c.size_t) ---
|
||||
|
||||
SetFontScript :: proc(font: ^Font, script: u32) -> bool ---
|
||||
|
||||
SetFontLanguage :: proc(font: ^Font, language_bcp47: cstring) -> bool ---
|
||||
|
||||
GetGlyphMetrics :: proc(font: ^Font, ch: u32, minx, maxx, miny, maxy, advance: ^c.int) -> bool ---
|
||||
GetGlyphKerning :: proc(font: ^Font, previous_ch: u32, ch: u32, kerning: ^c.int) -> bool ---
|
||||
|
||||
GetStringSize :: proc(font: ^Font, text: cstring, length: c.size_t, w, h: ^c.int) -> bool ---
|
||||
GetStringSizeWrapped :: proc(font: ^Font, text: cstring, length: c.size_t, wrap_width: c.int, w, h: ^c.int) -> bool ---
|
||||
MeasureString :: proc(font: ^Font, text: cstring, length: c.size_t, max_width: c.int, measured_width: ^c.int, measured_length: ^c.size_t) -> bool ---
|
||||
|
||||
DrawSurfaceText :: proc(text: ^Text, x, y: c.int, surface: ^SDL.Surface) -> bool ---
|
||||
DestroySurfaceTextEngine :: proc(engine: ^TextEngine) ---
|
||||
|
||||
DrawRendererText :: proc(text: ^Text, x, y: f32) -> bool ---
|
||||
DestroyRendererTextEngine :: proc(engine: ^TextEngine) ---
|
||||
|
||||
DestroyGPUTextEngine :: proc(engine: ^TextEngine) ---
|
||||
|
||||
SetTextEngine :: proc(text: ^Text, engine: ^TextEngine) -> bool ---
|
||||
SetTextFont :: proc(text: ^Text, font: ^Font) -> bool ---
|
||||
SetTextDirection :: proc(text: ^Text, direction: Direction) -> bool ---
|
||||
SetTextScript :: proc(text: ^Text, script: u32) -> bool ---
|
||||
SetTextColor :: proc(text: ^Text, r, g, b, a: u8) -> bool ---
|
||||
SetTextColorFloat :: proc(text: ^Text, r, g, b, a: f32) -> bool ---
|
||||
GetTextColor :: proc(text: ^Text, r, g, b, a: ^u8) -> bool ---
|
||||
GetTextColorFloat :: proc(text: ^Text, r, g, b, a: ^f32) -> bool ---
|
||||
SetTextPosition :: proc(text: ^Text, x, y: c.int) -> bool ---
|
||||
GetTextPosition :: proc(text: ^Text, x, y: ^c.int) -> bool ---
|
||||
SetTextWrapWidth :: proc(text: ^Text, wrap_width: c.int) -> bool ---
|
||||
GetTextWrapWidth :: proc(text: ^Text, wrap_width: ^c.int) -> bool ---
|
||||
SetTextWrapWhitespaceVisible :: proc(text: ^Text, visible: bool) -> bool ---
|
||||
|
||||
SetTextString :: proc(text: ^Text, string: cstring, length: c.size_t) -> bool ---
|
||||
InsertTextString :: proc(text: ^Text, offset: c.int, string: cstring, length: c.size_t) -> bool ---
|
||||
AppendTextString :: proc(text: ^Text, string: cstring, length: c.size_t) -> bool ---
|
||||
DeleteTextString :: proc(text: ^Text, offset, length: c.int) -> bool ---
|
||||
|
||||
GetTextSize :: proc(text: ^Text, w, h: ^c.int) -> bool ---
|
||||
|
||||
GetTextSubString :: proc(text: ^Text, offset: c.int, substring: ^SubString) -> bool ---
|
||||
GetTextSubStringForLine :: proc(text: ^Text, line: c.int, substring: ^SubString) -> bool ---
|
||||
GetTextSubStringForPoint :: proc(text: ^Text, x, y: c.int, substring: ^SubString) -> bool ---
|
||||
GetPreviousTextSubString :: proc(text: ^Text, #by_ptr substring: SubString, previous: ^SubString) -> bool ---
|
||||
GetNextTextSubString :: proc(text: ^Text, #by_ptr substring: SubString, next: ^SubString) -> bool ---
|
||||
|
||||
UpdateText :: proc(text: ^Text) -> bool ---
|
||||
DestroyText :: proc(text: ^Text) ---
|
||||
CloseFont :: proc(font: ^Font) ---
|
||||
Quit :: proc() ---
|
||||
}
|
||||
Reference in New Issue
Block a user