SOURCE DUMP v1

This commit is contained in:
Rian Drake 2026-10-15 14:09:11 +13:00
commit fb20299e9d
18 changed files with 768360 additions and 0 deletions

View file

@ -0,0 +1,15 @@
// <auto-generated/>
// Generated by Brutal.Sdl.Generate; do not edit by hand.
#nullable enable
namespace Brutal.SdlApi.Ttf
{
public enum TtfDirection : uint
{
Invalid = 0u,
Ltr = 4u,
Rtl = 5u,
Ttb = 6u,
Btt = 7u,
}
}

View file

@ -0,0 +1,13 @@
// <auto-generated/>
// Generated by Brutal.Sdl.Generate; do not edit by hand.
#nullable enable
namespace Brutal.SdlApi.Ttf
{
public enum TtfDrawCommand : uint
{
Noop = 0u,
Fill = 1u,
Copy = 2u,
}
}

View file

@ -0,0 +1,16 @@
// <auto-generated/>
// Generated by Brutal.Sdl.Generate; do not edit by hand.
#nullable enable
namespace Brutal.SdlApi.Ttf
{
[Flags]
public enum TtfFontStyleFlags : uint
{
Bold = 1u,
Italic = 2u,
Normal = 0u,
Strikethrough = 8u,
Underline = 4u,
}
}

View file

@ -0,0 +1,13 @@
// <auto-generated/>
// Generated by Brutal.Sdl.Generate; do not edit by hand.
#nullable enable
namespace Brutal.SdlApi.Ttf
{
public enum TtfGpuTextEngineWinding
{
Invalid = -1,
Clockwise = 0,
CounterClockwise = 1,
}
}

View file

@ -0,0 +1,16 @@
// <auto-generated/>
// Generated by Brutal.Sdl.Generate; do not edit by hand.
#nullable enable
namespace Brutal.SdlApi.Ttf
{
public enum TtfHintingFlags
{
Invalid = -1,
Normal = 0,
Light = 1,
Mono = 2,
None = 3,
LightSubpixel = 4,
}
}

View file

@ -0,0 +1,14 @@
// <auto-generated/>
// Generated by Brutal.Sdl.Generate; do not edit by hand.
#nullable enable
namespace Brutal.SdlApi.Ttf
{
public enum TtfHorizontalAlignment
{
Invalid = -1,
Left = 0,
Center = 1,
Right = 2,
}
}

View file

@ -0,0 +1,14 @@
// <auto-generated/>
// Generated by Brutal.Sdl.Generate; do not edit by hand.
#nullable enable
namespace Brutal.SdlApi.Ttf
{
public enum TtfImageType : uint
{
Invalid = 0u,
Alpha = 1u,
Color = 2u,
Sdf = 3u,
}
}

View file

@ -0,0 +1,15 @@
// <auto-generated/>
// Generated by Brutal.Sdl.Generate; do not edit by hand.
#nullable enable
namespace Brutal.SdlApi.Ttf
{
[Flags]
public enum TtfSubStringFlags : uint
{
LineEnd = 1024u,
LineStart = 512u,
TextEnd = 2048u,
TextStart = 256u,
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,50 @@
// <auto-generated/>
// Generated by Brutal.Sdl.Generate; do not edit by hand.
#nullable enable
namespace Brutal.SdlApi.Ttf
{
public static unsafe partial class SdlTtf
{
public static class Constants
{
public const int FontWeightBlack = 900;
public const int FontWeightBold = 700;
public const int FontWeightExtraBlack = 950;
public const int FontWeightExtraBold = 800;
public const int FontWeightExtraLight = 200;
public const int FontWeightLight = 300;
public const int FontWeightMedium = 500;
public const int FontWeightNormal = 400;
public const int FontWeightSemiBold = 600;
public const int FontWeightThin = 100;
public const string PropFontCreateExistingFont = "SDL_ttf.font.create.existing_font";
public const string PropFontCreateFaceNumber = "SDL_ttf.font.create.face";
public const string PropFontCreateFilenameString = "SDL_ttf.font.create.filename";
public const string PropFontCreateHorizontalDpiNumber = "SDL_ttf.font.create.hdpi";
public const string PropFontCreateIostreamAutocloseBoolean = "SDL_ttf.font.create.iostream.autoclose";
public const string PropFontCreateIostreamOffsetNumber = "SDL_ttf.font.create.iostream.offset";
public const string PropFontCreateIostreamPointer = "SDL_ttf.font.create.iostream";
public const string PropFontCreateSizeFloat = "SDL_ttf.font.create.size";
public const string PropFontCreateVerticalDpiNumber = "SDL_ttf.font.create.vdpi";
public const string PropFontOutlineLineCapNumber = "SDL_ttf.font.outline.line_cap";
public const string PropFontOutlineLineJoinNumber = "SDL_ttf.font.outline.line_join";
public const string PropFontOutlineMiterLimitNumber = "SDL_ttf.font.outline.miter_limit";
public const string PropGpuTextEngineAtlasTextureSize = "SDL_ttf.gpu_text_engine.create.atlas_texture_size";
public const string PropGpuTextEngineDevice = "SDL_ttf.gpu_text_engine.create.device";
public const string PropRendererTextEngineAtlasTextureSize =
"SDL_ttf.renderer_text_engine.create.atlas_texture_size";
public const string PropRendererTextEngineRenderer = "SDL_ttf.renderer_text_engine.create.renderer";
public const int StyleBold = 1;
public const int StyleItalic = 2;
public const int StyleNormal = 0;
public const int StyleStrikethrough = 8;
public const int StyleUnderline = 4;
public const int SubstringDirectionMask = 255;
public const int SubstringLineEnd = 1024;
public const int SubstringLineStart = 512;
public const int SubstringTextEnd = 2048;
public const int SubstringTextStart = 256;
}
}
}

View file

@ -0,0 +1,5 @@
// <auto-generated/>
// Generated by Brutal.Sdl.Generate; do not edit by hand.
#nullable enable
namespace Brutal.SdlApi.Ttf { }

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,26 @@
// <auto-generated/>
// Generated by Brutal.Sdl.Generate; do not edit by hand.
#nullable enable
using System;
using Brutal.Interop;
namespace Brutal.SdlApi.Ttf;
/// <summary>
/// A strongly-typed interop handle wrapping the opaque SDL <c>TTF_Font</c> pointer.
/// </summary>
[InteropHandle]
public readonly unsafe partial struct TtfFont : IDisposable
{
/// <inheritdoc/>
public void Dispose()
{
// A default/zeroed handle owns nothing; forwarding it to the native destructor is at
// best a wasted call and at worst undefined behaviour. Guard so Dispose is a safe no-op
// on a null handle (and so a double-dispose after the value was cleared is harmless).
if (IsNull())
return;
SdlTtf.PInvoke.CloseFont(this);
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,101 @@
// <auto-generated/>
// Generated by Brutal.Sdl.Generate; do not edit by hand.
#nullable enable
namespace Brutal.SdlApi.Ttf
{
[StructLayout(LayoutKind.Sequential)]
public unsafe partial struct TtfTextEngine
{
public uint version;
public void* userdata;
public delegate* unmanaged[Cdecl]<void*, TtfText*, byte> CreateText;
public delegate* unmanaged[Cdecl]<void*, TtfText*, void> DestroyText;
}
[StructLayout(LayoutKind.Sequential)]
public unsafe partial struct TtfTextData
{
public TtfFont font;
public SdlFColor color;
public byte needs_layout_update;
public nint layout;
public int x;
public int y;
public int w;
public int h;
public int num_ops;
public TtfDrawOperation* ops;
public int num_clusters;
public TtfSubString* clusters;
public uint props;
public byte needs_engine_update;
public TtfTextEngine* engine;
public void* engine_text;
}
[StructLayout(LayoutKind.Sequential)]
public unsafe partial struct TtfText
{
public byte* text;
public int num_lines;
public int refcount;
public TtfTextData* @internal;
}
[StructLayout(LayoutKind.Sequential)]
public unsafe partial struct TtfGpuAtlasDrawSequence
{
public nint atlas_texture;
public SdlFPoint* xy;
public SdlFPoint* uv;
public int num_vertices;
public int* indices;
public int num_indices;
public TtfImageType image_type;
public TtfGpuAtlasDrawSequence* next;
}
[StructLayout(LayoutKind.Sequential)]
public partial struct TtfSubString
{
public TtfSubStringFlags flags;
public int offset;
public int length;
public int line_index;
public int cluster_index;
public SdlRect rect;
}
[StructLayout(LayoutKind.Sequential)]
public partial struct TtfFillOperation
{
public TtfDrawCommand cmd;
public SdlRect rect;
}
[StructLayout(LayoutKind.Sequential)]
public unsafe partial struct TtfCopyOperation
{
public TtfDrawCommand cmd;
public int text_offset;
public TtfFont glyph_font;
public uint glyph_index;
public SdlRect src;
public SdlRect dst;
public void* reserved;
}
[StructLayout(LayoutKind.Explicit)]
public partial struct TtfDrawOperation
{
[FieldOffset(0)]
public TtfDrawCommand cmd;
[FieldOffset(0)]
public TtfFillOperation fill;
[FieldOffset(0)]
public TtfCopyOperation copy;
}
}

View file

@ -0,0 +1,3 @@
global using System.Runtime.CompilerServices;
global using System.Runtime.InteropServices;
global using Brutal.SdlApi;

View file

@ -0,0 +1,503 @@
THIRD-PARTY LICENSE NOTICES
RocketWerkz.Brutal.Sdl.Ttf
This package redistributes third-party software. The licenses governing that software
are reproduced below in full.
WHAT THIS PACKAGE CONTAINS
One native library, on every runtime identifier the package supports
(win-x64, linux-x64, osx-arm64):
SDL_ttf 3.2.2 SDL3_ttf.dll / libSDL3_ttf.so / libSDL3_ttf.dylib
Six third-party components are statically linked into that library and are governed
by their own licenses, one section each below:
FreeType 2.13.2 font rasterisation
BDF driver FreeType's contributed BDF font driver, separately licensed
PCF driver FreeType's contributed PCF font driver, separately licensed
zlib 1.3 bundled inside FreeType, used to decompress font tables
HarfBuzz 8.5.0 Unicode text shaping
stb_rect_pack glyph atlas packing for the renderer and GPU text engines
zlib arrives two levels down: FreeType bundles its own copy and compiles it in when
no system zlib is linked, which is the case here. Nothing in this package's own
configuration asks for it.
FREETYPE IS DUAL-LICENSED, AND WE DISTRIBUTE UNDER THE FREETYPE LICENSE
FreeType's own LICENSE.TXT distributes it "under two mutually exclusive open-source
licenses" - the FreeType License (FTL) and the GNU General Public License version 2 -
and states that "*you* must choose *one* of the two licenses ... then obey all its
terms and conditions". This distribution is made under the FreeType License,
reproduced in full below. The GPL v2 text is not reproduced.
This package contains FreeType in binary form only. The FreeType Project's credit
and disclaimer:
Portions of this software are copyright © 2023 The FreeType Project
(https://freetype.org). All rights reserved.
This software is based in part of the work of the FreeType Team.
The year is 2023 because that is the year of FreeType 2.13.2, the version contained
here. RocketWerkz.Brutal.FreeType contains a different version and its credit
states a different year; both are correct, and they must not be made to agree.
A NOTE ON SCOPE
This package depends on RocketWerkz.Brutal.Sdl and links against SDL3 at runtime.
SDL3 is not contained in this package and is covered by that package's own notices.
SDL_ttf can optionally be built against PlutoSVG and PlutoVG for colour-emoji
glyphs. This build enables neither, neither is contained in the shipped library,
and neither is attributed here.
Where an upstream license file covers more code than this package ships, only the
blocks governing the code actually contained here are reproduced. Each such omission
is named where it occurs, so that nothing below should be read as truncated.
==============================================================================
SDL_ttf
==============================================================================
Name SDL_ttf
Version 3.2.2
Upstream https://github.com/libsdl-org/SDL_ttf
SPDX Zlib
Shipped as SDL3_ttf.dll, libSDL3_ttf.so, libSDL3_ttf.dylib
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.
==============================================================================
FreeType
==============================================================================
Name FreeType
Version 2.13.2
Upstream https://freetype.org -- https://github.com/freetype/freetype
SPDX FTL
Shipped as statically linked into SDL3_ttf.dll, libSDL3_ttf.so, libSDL3_ttf.dylib
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 ---
==============================================================================
FreeType BDF driver
==============================================================================
Name BDF font driver
Version as contained in FreeType 2.13.2
Upstream https://freetype.org -- https://github.com/freetype/freetype
SPDX MIT
Shipped as statically linked into SDL3_ttf.dll, libSDL3_ttf.so, libSDL3_ttf.dylib
FreeType's BDF driver is contributed code under its own X11-style license, separate
from the FreeType License above. It is registered in this build and compiled in.
Two blocks apply: the driver, and the portions derived from Mark Leisher's bdf
library. Both are reproduced.
Copyright (C) 2001-2002 by Francesco Zappa Nardelli
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.
*** Portions of the driver (that is, bdflib.c and bdf.h):
Copyright 2000 Computing Research Labs, New Mexico State University
Copyright 2001-2002, 2011 Francesco Zappa Nardelli
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 COMPUTING RESEARCH LAB OR NEW MEXICO STATE UNIVERSITY 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.
==============================================================================
FreeType PCF driver
==============================================================================
Name PCF font driver
Version as contained in FreeType 2.13.2
Upstream https://freetype.org -- https://github.com/freetype/freetype
SPDX MIT
Shipped as statically linked into SDL3_ttf.dll, libSDL3_ttf.so, libSDL3_ttf.dylib
FreeType's PCF driver is contributed code under its own X11-style license, separate
from the FreeType License above. It is registered in this build and compiled in.
Copyright (C) 2000 by Francesco Zappa Nardelli
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.
==============================================================================
zlib
==============================================================================
Name zlib
Version 1.3
Upstream https://zlib.net -- https://github.com/madler/zlib
SPDX Zlib
Shipped as statically linked into SDL3_ttf.dll, libSDL3_ttf.so, libSDL3_ttf.dylib, inside FreeType
FreeType bundles a copy of zlib and compiles it in when no system zlib is available
to link against, which is the case in this build. The license below is reproduced
from the bundled copy's own header, which is where zlib states its terms.
zlib.h -- interface of the 'zlib' general purpose compression library
version 1.3, August 18th, 2023
Copyright (C) 1995-2023 Jean-loup Gailly and Mark Adler
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.
Jean-loup Gailly Mark Adler
jloup@gzip.org madler@alumni.caltech.edu
==============================================================================
HarfBuzz
==============================================================================
Name HarfBuzz
Version 8.5.0
Upstream https://harfbuzz.github.io -- https://github.com/harfbuzz/harfbuzz
SPDX MIT
Shipped as statically linked into SDL3_ttf.dll, libSDL3_ttf.so, libSDL3_ttf.dylib
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.
==============================================================================
stb_rect_pack
==============================================================================
Name stb_rect_pack
Version as vendored by SDL_ttf 3.2.2
Upstream https://github.com/nothings/stb
SPDX MIT OR Unlicense
Shipped as compiled into SDL3_ttf.dll, libSDL3_ttf.so, libSDL3_ttf.dylib
SDL_ttf carries stb_rect_pack in its own source directory and compiles it into the
library to pack glyph atlases. It is offered under two mutually exclusive licenses,
both reproduced below as upstream states them.
------------------------------------------------------------------------------
ALTERNATIVE A - MIT License
Copyright (c) 2017 Sean Barrett
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.
------------------------------------------------------------------------------
ALTERNATIVE B - Public Domain (www.unlicense.org)
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
software, either in source code form or as a compiled binary, for any purpose,
commercial or non-commercial, and by any means.
In jurisdictions that recognize copyright laws, the author or authors of this
software dedicate any and all copyright interest in the software to the public
domain. We make this dedication for the benefit of the public at large and to
the detriment of our heirs and successors. We intend this dedication to be an
overt act of relinquishment in perpetuity of all present and future rights to
this software under copyright law.
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 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.
------------------------------------------------------------------------------

View file

@ -0,0 +1,121 @@
using System.Reflection;
using Brutal.Logging;
namespace Brutal.SdlApi.Ttf;
/// <summary>
/// Provides access to the SDL_ttf library.
/// </summary>
public static unsafe partial class SdlTtf
{
/// <summary>
/// The name the generated P/Invoke surface imports against. The <see cref="PInvoke"/> static
/// constructor registers a <see cref="NativeLibrary.SetDllImportResolver"/> that normalizes
/// this name to the platform-specific SDL3_ttf shared library.
/// </summary>
internal const string Dll = "SDL3_ttf";
/// <summary>
/// The logging category for the per-call trace logs the generated P/Invoke surface emits. An
/// internal implementation detail mirroring core's <c>Sdl.TraceLog</c>; the generated
/// <c>SdlTtf.PInvoke</c> wrappers call <c>SdlTtf.TraceLog.Trace()</c> on every invocation.
/// </summary>
internal static readonly LogCategory TraceLog = LogCategory.Make("SdlTtf");
/// <summary>
/// Hosts the raw generated P/Invoke surface (filled in by a later task) and, for now, the
/// native library resolver that makes loading <c>SDL3_ttf</c> work.
/// </summary>
public static unsafe partial class PInvoke
{
// The native SDL3_ttf handle, resolved lazily by the DllImportResolver below and cached
// so the library is loaded at most once regardless of how many entry points are resolved.
private static nint _nativeHandle;
// Serializes resolution — see Brutal.Sdl's Sdl.PInvoke for the full rationale (two threads
// resolving different entry points concurrently must not race to load two handles).
private static readonly Lock ResolveLock = new();
// The resolver is registered in this static constructor rather than at first use so it is
// in place before ANY P/Invoke against this assembly is resolved. Accessing a member of the
// nested PInvoke type triggers this constructor (mirrors Brutal.Sdl's Sdl.PInvoke pattern).
static PInvoke()
{
// GUARANTEE: SDL3 must actually be loaded into the process before SDL3_ttf's own
// resolve runs below — SDL3_ttf's dylib/so/dll has a dynamic-link dependency on
// libSDL3 (@rpath/libSDL3.0.dylib on macOS, libSDL3.so.0 on Linux, SDL3.dll on
// Windows) that a nupkg-deployed app's probe layout cannot always be relied on to
// satisfy via rpath/loader-path alone (the CMake wrapper's INSTALL_RPATH is a second,
// belt-and-braces line of defense, not the primary guarantee).
//
// Merely running Sdl's or Sdl.PInvoke's static constructor is NOT sufficient: those
// constructors only *register* Brutal.Sdl's DllImportResolver
// (NativeLibrary.SetDllImportResolver) — the resolver is not invoked, and libSDL3 is
// not actually loaded, until the CLR resolves a real P/Invoke against it. So instead of
// RunClassConstructor, we make one real, side-effect-free P/Invoke call into core:
// Sdl.PInvoke.GetVersion() just reads SDL's compiled-in version number, requires no
// SDL_Init and has no observable side effects, but its LibraryImport binding is exactly
// what triggers Brutal.Sdl's resolver to actually NativeLibrary.Load libSDL3. By the
// time this call returns, libSDL3 is resident in the process, so SDL3_ttf's own
// dynamic-link dependency on it is satisfiable regardless of rpath/loader-path probing.
_ = Sdl.PInvoke.GetVersion();
NativeLibrary.SetDllImportResolver(typeof(SdlTtf).Assembly, Resolve);
}
// Normalizes the "SDL3_ttf" import name to the platform-specific shared library filename
// (SDL3_ttf.dll on Windows, libSDL3_ttf.dylib on macOS, libSDL3_ttf.so.0 on Linux).
// SDL_ttf's Linux build installs a versioned soname (libSDL3_ttf.so.0), same convention as
// core's SDL3, so the candidate list is spelled out explicitly, most-specific first, with
// the default probing convention name as a fallback.
private static nint Resolve(string libraryName, Assembly assembly, DllImportSearchPath? searchPath)
{
// Only ever asked to resolve SDL3_ttf; anything else is left to the default resolver.
if (libraryName != Dll)
return IntPtr.Zero;
lock (ResolveLock)
{
if (_nativeHandle != IntPtr.Zero)
return _nativeHandle;
var search = searchPath ?? DllImportSearchPath.AssemblyDirectory;
// Try each candidate with Load (not TryLoad): TryLoad reports only pass/fail and
// discards the OS diagnostic, so a candidate that *exists but fails to load* (a
// missing transitive dependency, an ABI mismatch) would vanish silently. Load throws
// with the real dlerror/LoadLibrary text, which we aggregate so the final exception
// names every attempt and why it failed.
var failures = new List<string>();
foreach (var candidate in Candidates())
{
try
{
_nativeHandle = NativeLibrary.Load(candidate, assembly, search);
return _nativeHandle;
}
catch (Exception ex)
{
failures.Add($"'{candidate}': {ex.Message}");
}
}
throw new DllNotFoundException(
"Could not load the SDL3_ttf native library. Attempts (most specific first): "
+ string.Join("; ", failures)
+ "."
);
}
}
private static string[] Candidates()
{
if (OperatingSystem.IsWindows())
return ["SDL3_ttf.dll", "SDL3_ttf"];
if (OperatingSystem.IsMacOS())
return ["libSDL3_ttf.dylib", "SDL3_ttf"];
// Linux and other Unix-likes.
return ["libSDL3_ttf.so.0", "libSDL3_ttf.so", "SDL3_ttf"];
}
}
}