diff --git a/arcade/examples/drawing_text.py b/arcade/examples/drawing_text.py index d7534a928..23b23badd 100644 --- a/arcade/examples/drawing_text.py +++ b/arcade/examples/drawing_text.py @@ -12,8 +12,9 @@ DEFAULT_LINE_HEIGHT = 45 DEFAULT_FONT_SIZE = 20 -# Load fonts bumbled with Arcade such as the Kenney fonts +# Load fonts bundled with Arcade such as the Kenney fonts arcade.resources.load_kenney_fonts() +arcade.resources.load_liberation_fonts() class GameView(arcade.View): @@ -158,7 +159,8 @@ def on_draw(self): font_name=( "Times New Roman", # Comes with Windows "Times", # MacOS may sometimes have this variant - "Liberation Serif" # Common on Linux systems + # Common on Linux systems + we ship it with Arcade + "Liberation Serif" )) start_y -= DEFAULT_LINE_HEIGHT diff --git a/arcade/examples/drawing_text_objects.py b/arcade/examples/drawing_text_objects.py index dac86c487..4e5521e06 100644 --- a/arcade/examples/drawing_text_objects.py +++ b/arcade/examples/drawing_text_objects.py @@ -13,8 +13,9 @@ DEFAULT_LINE_HEIGHT = 45 DEFAULT_FONT_SIZE = 20 -# Load fonts bumbled with Arcade such as the Kenney fonts +# Load fonts bundled with Arcade such as the Kenney fonts arcade.resources.load_kenney_fonts() +arcade.resources.load_liberation_fonts() class GameView(arcade.View): @@ -171,7 +172,8 @@ def __init__(self,): font_name=( "Times New Roman", # Comes with Windows "Times", # MacOS may sometimes have this variant - "Liberation Serif" # Common on Linux systems + # Common on Linux systems + we ship it with Arcade + "Liberation Serif" ) ) diff --git a/arcade/examples/drawing_text_objects_batch.py b/arcade/examples/drawing_text_objects_batch.py index 611892a04..c44b8fcf1 100644 --- a/arcade/examples/drawing_text_objects_batch.py +++ b/arcade/examples/drawing_text_objects_batch.py @@ -15,8 +15,9 @@ import arcade from pyglet.graphics import Batch -# Load fonts bumbled with Arcade such as the Kenney fonts +# Load fonts bundled with Arcade such as the Kenney fonts arcade.resources.load_kenney_fonts() +arcade.resources.load_liberation_fonts() WINDOW_WIDTH = 1280 # Window width in pixels WINDOW_HEIGHT = 800 # Window height in pixels @@ -193,7 +194,8 @@ def __init__(self): font_name=( "Times New Roman", # Comes with Windows "Times", # MacOS may sometimes have this variant - "Liberation Serif" # Common on Linux systems + # Common on Linux systems + we ship it with Arcade + "Liberation Serif" ), batch=self.batch, ) diff --git a/arcade/resources/__init__.py b/arcade/resources/__init__.py index c252c8a2f..f47119053 100644 --- a/arcade/resources/__init__.py +++ b/arcade/resources/__init__.py @@ -6,9 +6,16 @@ #: The absolute path to this directory RESOURCE_DIR = Path(__file__).parent.resolve() + +# The "system" resources common to Arcade SYSTEM_PATH = RESOURCE_DIR / "system" +FONTS_PATH = SYSTEM_PATH / "fonts" +TTF_PATH = FONTS_PATH / "ttf" + +# Basic resources in the :assets: handle ASSET_PATH = RESOURCE_DIR / "assets" + handles: dict[str, list[Path]] = { "resources": [SYSTEM_PATH, ASSET_PATH], "assets": [ASSET_PATH], @@ -212,32 +219,91 @@ def list_built_in_assets( def load_kenney_fonts() -> None: - """Loads all the fonts in arcade's system directory. - - Currently, this is only the Kenney fonts:: - - Kenney_Blocks.ttf - Kenney Blocks - Kenney_Future.ttf - Kenney Future - Kenney_Future_Narrow.ttf - Kenney Future Narrow - Kenney_High.ttf - Kenney High - Kenney_High_Square.ttf - Kenney High Square - Kenney_Mini.ttf - Kenney Mini - Kenney_Mini_Square.ttf - Kenney Mini Square - Kenney_Pixel.ttf - Kenney Pixel - Kenney_Pixel_Square.ttf - Kenney Pixel Square - Kenney_Rocket.ttf - Kenney Rocket - Kenney_Rocket_Square.ttf - Kenney Rocket Square + """Loads all the Kenney.nl fonts bundled with Arcade. + + .. tip:: This function is best for prototyping and experimenting! + + For best performance, you may want to switch to + :py:class:`arcade.load_font` before release. + + Please see :ref:`resources-fonts-kenney` for previews and + license information. The filename to load and ``font_name`` to use + when drawing text are summarized below: + + .. might swap to this style for the resources listing once I figure out how to + .. cleanly modify the file to use it. + + ========================================= ========================================================================= + ``font_name`` for :py:class:`arcade.Text` :ref:`Resource handle ` for :py:func:`arcade.load_font` + ========================================= ========================================================================= + ``"Kenney Blocks"`` ``:resources:fonts/ttf/Kenney/Kenney_Blocks.ttf`` + ``"Kenney Future"`` ``:resources:fonts/ttf/Kenney/Kenney_Future.ttf`` + ``"Kenney Future Narrow"`` ``:resources:fonts/ttf/Kenney/Kenney_Future_Narrow.ttf`` + ``"Kenney High"`` ``:resources:fonts/ttf/Kenney/Kenney_High.ttf`` + ``"Kenney High Square"`` ``:resources:fonts/ttf/Kenney/Kenney_High_Square.ttf`` + ``"Kenney Mini"`` ``:resources:fonts/ttf/Kenney/Kenney_Mini.ttf`` + ``"Kenney Mini Square"`` ``:resources:fonts/ttf/Kenney/Kenney_Mini_Square.ttf`` + ``"Kenney Pixel"`` ``:resources:fonts/ttf/Kenney/Kenney_Pixel.ttf`` + ``"Kenney Pixel Square"`` ``:resources:fonts/ttf/Kenney/Kenney_Pixel_Square.ttf`` + ``"Kenney Rocket"`` ``:resources:fonts/ttf/Kenney/Kenney_Rocket.ttf`` + ``"Kenney Rocket Square"`` ``:resources:fonts/ttf/Kenney/Kenney_Rocket_Square.ttf`` + ========================================= ========================================================================= + + """ # noqa: E501 # Silence ruff # pending: better generation + from arcade.text import load_font + + load_font(":system:fonts/ttf/Kenney/Kenney_Blocks.ttf") + load_font(":system:fonts/ttf/Kenney/Kenney_Future.ttf") + load_font(":system:fonts/ttf/Kenney/Kenney_Future_Narrow.ttf") + load_font(":system:fonts/ttf/Kenney/Kenney_High.ttf") + load_font(":system:fonts/ttf/Kenney/Kenney_High_Square.ttf") + load_font(":system:fonts/ttf/Kenney/Kenney_Mini.ttf") + load_font(":system:fonts/ttf/Kenney/Kenney_Mini_Square.ttf") + load_font(":system:fonts/ttf/Kenney/Kenney_Pixel.ttf") + load_font(":system:fonts/ttf/Kenney/Kenney_Pixel_Square.ttf") + load_font(":system:fonts/ttf/Kenney/Kenney_Rocket.ttf") + load_font(":system:fonts/ttf/Kenney/Kenney_Rocket_Square.ttf") + + +def load_liberation_fonts() -> None: + """Loads all styles for generic Arial, Courier, and Times New Roman replacements. + + .. tip:: This function is best for prototyping and experimenting! + + For best performance, you may want to switch to + :py:class:`arcade.load_font` before release. + + The Liberation fonts are proven, permissively-licensed fonts.[ + For previews and additional information, please see + :ref:`resources-fonts-liberation`. + + .. list-table:: ``font_name`` values for :py:class:`arcade.Text` + :header-rows: 1 + + * - Proprietary Font(s) + - Liberation Replacemetn + + * - ``"Courier"`` + - ``"Liberation Mono"`` + + * - ``"Times New Roman"``, ``"Times"`` + - ``"Liberation Serif"`` + + * - ``"Arial"`` + - ``"Liberation Sans"`` + """ from arcade.text import load_font - load_font(":system:fonts/ttf/Kenney_Blocks.ttf") - load_font(":system:fonts/ttf/Kenney_Future.ttf") - load_font(":system:fonts/ttf/Kenney_Future_Narrow.ttf") - load_font(":system:fonts/ttf/Kenney_High.ttf") - load_font(":system:fonts/ttf/Kenney_High_Square.ttf") - load_font(":system:fonts/ttf/Kenney_Mini.ttf") - load_font(":system:fonts/ttf/Kenney_Mini_Square.ttf") - load_font(":system:fonts/ttf/Kenney_Pixel.ttf") - load_font(":system:fonts/ttf/Kenney_Pixel_Square.ttf") - load_font(":system:fonts/ttf/Kenney_Rocket.ttf") - load_font(":system:fonts/ttf/Kenney_Rocket_Square.ttf") + load_font(":system:fonts/ttf/Liberation/Liberation_Mono_BoldItalic.ttf") + load_font(":system:fonts/ttf/Liberation/Liberation_Mono_Bold.ttf") + load_font(":system:fonts/ttf/Liberation/Liberation_Mono_Italic.ttf") + load_font(":system:fonts/ttf/Liberation/Liberation_Mono_Regular.ttf") + load_font(":system:fonts/ttf/Liberation/Liberation_Sans_BoldItalic.ttf") + load_font(":system:fonts/ttf/Liberation/Liberation_Sans_Bold.ttf") + load_font(":system:fonts/ttf/Liberation/Liberation_Sans_Italic.ttf") + load_font(":system:fonts/ttf/Liberation/Liberation_Sans_Regular.ttf") + load_font(":system:fonts/ttf/Liberation/Liberation_Serif_BoldItalic.ttf") + load_font(":system:fonts/ttf/Liberation/Liberation_Serif_Bold.ttf") + load_font(":system:fonts/ttf/Liberation/Liberation_Serif_Italic.ttf") + load_font(":system:fonts/ttf/Liberation/Liberation_Serif_Regular.ttf") diff --git a/arcade/resources/system/fonts/ttf/Kenney_Blocks.ttf b/arcade/resources/system/fonts/ttf/Kenney/Kenney_Blocks.ttf similarity index 100% rename from arcade/resources/system/fonts/ttf/Kenney_Blocks.ttf rename to arcade/resources/system/fonts/ttf/Kenney/Kenney_Blocks.ttf diff --git a/arcade/resources/system/fonts/ttf/Kenney_Future.ttf b/arcade/resources/system/fonts/ttf/Kenney/Kenney_Future.ttf similarity index 100% rename from arcade/resources/system/fonts/ttf/Kenney_Future.ttf rename to arcade/resources/system/fonts/ttf/Kenney/Kenney_Future.ttf diff --git a/arcade/resources/system/fonts/ttf/Kenney_Future_Narrow.ttf b/arcade/resources/system/fonts/ttf/Kenney/Kenney_Future_Narrow.ttf similarity index 100% rename from arcade/resources/system/fonts/ttf/Kenney_Future_Narrow.ttf rename to arcade/resources/system/fonts/ttf/Kenney/Kenney_Future_Narrow.ttf diff --git a/arcade/resources/system/fonts/ttf/Kenney_High.ttf b/arcade/resources/system/fonts/ttf/Kenney/Kenney_High.ttf similarity index 100% rename from arcade/resources/system/fonts/ttf/Kenney_High.ttf rename to arcade/resources/system/fonts/ttf/Kenney/Kenney_High.ttf diff --git a/arcade/resources/system/fonts/ttf/Kenney_High_Square.ttf b/arcade/resources/system/fonts/ttf/Kenney/Kenney_High_Square.ttf similarity index 100% rename from arcade/resources/system/fonts/ttf/Kenney_High_Square.ttf rename to arcade/resources/system/fonts/ttf/Kenney/Kenney_High_Square.ttf diff --git a/arcade/resources/system/fonts/ttf/Kenney_Mini.ttf b/arcade/resources/system/fonts/ttf/Kenney/Kenney_Mini.ttf similarity index 100% rename from arcade/resources/system/fonts/ttf/Kenney_Mini.ttf rename to arcade/resources/system/fonts/ttf/Kenney/Kenney_Mini.ttf diff --git a/arcade/resources/system/fonts/ttf/Kenney_Mini_Square.ttf b/arcade/resources/system/fonts/ttf/Kenney/Kenney_Mini_Square.ttf similarity index 100% rename from arcade/resources/system/fonts/ttf/Kenney_Mini_Square.ttf rename to arcade/resources/system/fonts/ttf/Kenney/Kenney_Mini_Square.ttf diff --git a/arcade/resources/system/fonts/ttf/Kenney_Pixel.ttf b/arcade/resources/system/fonts/ttf/Kenney/Kenney_Pixel.ttf similarity index 100% rename from arcade/resources/system/fonts/ttf/Kenney_Pixel.ttf rename to arcade/resources/system/fonts/ttf/Kenney/Kenney_Pixel.ttf diff --git a/arcade/resources/system/fonts/ttf/Kenney_Pixel_Square.ttf b/arcade/resources/system/fonts/ttf/Kenney/Kenney_Pixel_Square.ttf similarity index 100% rename from arcade/resources/system/fonts/ttf/Kenney_Pixel_Square.ttf rename to arcade/resources/system/fonts/ttf/Kenney/Kenney_Pixel_Square.ttf diff --git a/arcade/resources/system/fonts/ttf/Kenney_Rocket.ttf b/arcade/resources/system/fonts/ttf/Kenney/Kenney_Rocket.ttf similarity index 100% rename from arcade/resources/system/fonts/ttf/Kenney_Rocket.ttf rename to arcade/resources/system/fonts/ttf/Kenney/Kenney_Rocket.ttf diff --git a/arcade/resources/system/fonts/ttf/Kenney_Rocket_Square.ttf b/arcade/resources/system/fonts/ttf/Kenney/Kenney_Rocket_Square.ttf similarity index 100% rename from arcade/resources/system/fonts/ttf/Kenney_Rocket_Square.ttf rename to arcade/resources/system/fonts/ttf/Kenney/Kenney_Rocket_Square.ttf diff --git a/arcade/resources/system/fonts/ttf/Liberation/LICENSE b/arcade/resources/system/fonts/ttf/Liberation/LICENSE new file mode 100644 index 000000000..aba73e8a4 --- /dev/null +++ b/arcade/resources/system/fonts/ttf/Liberation/LICENSE @@ -0,0 +1,102 @@ +Digitized data copyright (c) 2010 Google Corporation + with Reserved Font Arimo, Tinos and Cousine. +Copyright (c) 2012 Red Hat, Inc. + with Reserved Font Name Liberation. + +This Font Software is licensed under the SIL Open Font License, +Version 1.1. + +This license is copied below, and is also available with a FAQ at: +http://scripts.sil.org/OFL + +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 + +PREAMBLE The goals of the Open Font License (OFL) are to stimulate +worldwide development of collaborative font projects, to support the font +creation efforts of academic and linguistic communities, and to provide +a free and open framework in which fonts may be shared and improved in +partnership with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. +The fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply to +any document created using the fonts or their derivatives. + + + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. +This may include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components +as distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting ? in part or in whole ? +any of the components of the Original Version, by changing formats or +by porting the Font Software to a new environment. + +"Author" refers to any designer, engineer, programmer, technical writer +or other person who contributed to the Font Software. + + +PERMISSION & CONDITIONS + +Permission is hereby granted, free of charge, to any person obtaining a +copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components,in + Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, + redistributed and/or sold with any software, provided that each copy + contains the above copyright notice and this license. These can be + included either as stand-alone text files, human-readable headers or + in the appropriate machine-readable metadata fields within text or + binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font + Name(s) unless explicit written permission is granted by the + corresponding Copyright Holder. This restriction only applies to the + primary font name as presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font + Software shall not be used to promote, endorse or advertise any + Modified Version, except to acknowledge the contribution(s) of the + Copyright Holder(s) and the Author(s) or with their explicit written + permission. + +5) The Font Software, modified or unmodified, in part or in whole, must + be distributed entirely under this license, and must not be distributed + under any other license. The requirement for fonts to remain under + this license does not apply to any document created using the Font + Software. + + + +TERMINATION +This license becomes null and void if any of the above conditions are not met. + + + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER +DEALINGS IN THE FONT SOFTWARE. + diff --git a/arcade/resources/system/fonts/ttf/Liberation/Liberation_Mono_Bold.ttf b/arcade/resources/system/fonts/ttf/Liberation/Liberation_Mono_Bold.ttf new file mode 100644 index 000000000..2e46737ac Binary files /dev/null and b/arcade/resources/system/fonts/ttf/Liberation/Liberation_Mono_Bold.ttf differ diff --git a/arcade/resources/system/fonts/ttf/Liberation/Liberation_Mono_BoldItalic.ttf b/arcade/resources/system/fonts/ttf/Liberation/Liberation_Mono_BoldItalic.ttf new file mode 100644 index 000000000..d1f46d7cd Binary files /dev/null and b/arcade/resources/system/fonts/ttf/Liberation/Liberation_Mono_BoldItalic.ttf differ diff --git a/arcade/resources/system/fonts/ttf/Liberation/Liberation_Mono_Italic.ttf b/arcade/resources/system/fonts/ttf/Liberation/Liberation_Mono_Italic.ttf new file mode 100644 index 000000000..954c39436 Binary files /dev/null and b/arcade/resources/system/fonts/ttf/Liberation/Liberation_Mono_Italic.ttf differ diff --git a/arcade/resources/system/fonts/ttf/Liberation/Liberation_Mono_Regular.ttf b/arcade/resources/system/fonts/ttf/Liberation/Liberation_Mono_Regular.ttf new file mode 100644 index 000000000..e774859cb Binary files /dev/null and b/arcade/resources/system/fonts/ttf/Liberation/Liberation_Mono_Regular.ttf differ diff --git a/arcade/resources/system/fonts/ttf/Liberation/Liberation_Sans_Bold.ttf b/arcade/resources/system/fonts/ttf/Liberation/Liberation_Sans_Bold.ttf new file mode 100644 index 000000000..dc5d57f15 Binary files /dev/null and b/arcade/resources/system/fonts/ttf/Liberation/Liberation_Sans_Bold.ttf differ diff --git a/arcade/resources/system/fonts/ttf/Liberation/Liberation_Sans_BoldItalic.ttf b/arcade/resources/system/fonts/ttf/Liberation/Liberation_Sans_BoldItalic.ttf new file mode 100644 index 000000000..158488a12 Binary files /dev/null and b/arcade/resources/system/fonts/ttf/Liberation/Liberation_Sans_BoldItalic.ttf differ diff --git a/arcade/resources/system/fonts/ttf/Liberation/Liberation_Sans_Italic.ttf b/arcade/resources/system/fonts/ttf/Liberation/Liberation_Sans_Italic.ttf new file mode 100644 index 000000000..25970d9d5 Binary files /dev/null and b/arcade/resources/system/fonts/ttf/Liberation/Liberation_Sans_Italic.ttf differ diff --git a/arcade/resources/system/fonts/ttf/Liberation/Liberation_Sans_Regular.ttf b/arcade/resources/system/fonts/ttf/Liberation/Liberation_Sans_Regular.ttf new file mode 100644 index 000000000..e6339859d Binary files /dev/null and b/arcade/resources/system/fonts/ttf/Liberation/Liberation_Sans_Regular.ttf differ diff --git a/arcade/resources/system/fonts/ttf/Liberation/Liberation_Serif_Bold.ttf b/arcade/resources/system/fonts/ttf/Liberation/Liberation_Serif_Bold.ttf new file mode 100644 index 000000000..3c7c55b57 Binary files /dev/null and b/arcade/resources/system/fonts/ttf/Liberation/Liberation_Serif_Bold.ttf differ diff --git a/arcade/resources/system/fonts/ttf/Liberation/Liberation_Serif_BoldItalic.ttf b/arcade/resources/system/fonts/ttf/Liberation/Liberation_Serif_BoldItalic.ttf new file mode 100644 index 000000000..6b35d9f7c Binary files /dev/null and b/arcade/resources/system/fonts/ttf/Liberation/Liberation_Serif_BoldItalic.ttf differ diff --git a/arcade/resources/system/fonts/ttf/Liberation/Liberation_Serif_Italic.ttf b/arcade/resources/system/fonts/ttf/Liberation/Liberation_Serif_Italic.ttf new file mode 100644 index 000000000..54d516481 Binary files /dev/null and b/arcade/resources/system/fonts/ttf/Liberation/Liberation_Serif_Italic.ttf differ diff --git a/arcade/resources/system/fonts/ttf/Liberation/Liberation_Serif_Regular.ttf b/arcade/resources/system/fonts/ttf/Liberation/Liberation_Serif_Regular.ttf new file mode 100644 index 000000000..5e5550c0a Binary files /dev/null and b/arcade/resources/system/fonts/ttf/Liberation/Liberation_Serif_Regular.ttf differ diff --git a/doc/api_docs/images/fonts_liberation.png b/doc/api_docs/images/fonts_liberation.png new file mode 100644 index 000000000..c1aaf3a64 Binary files /dev/null and b/doc/api_docs/images/fonts_liberation.png differ diff --git a/doc/links.rst b/doc/links.rst index ba049fdd0..85e9d2863 100644 --- a/doc/links.rst +++ b/doc/links.rst @@ -29,6 +29,7 @@ .. Concepts .. _CC0: https://creativecommons.org/publicdomain/#publicdomain-cc0-10 .. _Creative Commons licenses: https://creativecommons.org/share-your-work/cclicenses/ +.. _SIL Open Font License: https://openfontlicense.org/ .. Licensing .. _BibTeX: https://www.bibtex.org/Format/ diff --git a/tests/unit/text/test_text_instance_properties.py b/tests/unit/text/test_text_instance_properties.py index 73f96f934..837347a75 100644 --- a/tests/unit/text/test_text_instance_properties.py +++ b/tests/unit/text/test_text_instance_properties.py @@ -13,7 +13,7 @@ def instance() -> arcade.Text: ("value", "New test value"), ("x", 12.0), ("y", 12.0), - ("font_name", "Times New Roman"), + ("font_name", "Liberation Serif"), # Generic Times New Roman we ship in-box ("font_size", 20.0), ("width", 600), ("bold", True), diff --git a/util/create_resources_listing.py b/util/create_resources_listing.py index e26bc4e9d..7dd716b75 100644 --- a/util/create_resources_listing.py +++ b/util/create_resources_listing.py @@ -67,6 +67,7 @@ def announce_templating(var_name): ".txt", ".tiled-project", ".pyc", + "" # Zero-extension stuff like LICENSE and README ] @@ -112,16 +113,32 @@ def create_resource_path( return f"{prefix}:resources:{path.as_posix()}{suffix}" +KENNEY_TTFS = "Kenney TTFs" +LIBERATION_TTFS = "Liberation TTFs" + +PREFIX_REF_TARGET = { + KENNEY_TTFS: "resources-fonts-kenney", + LIBERATION_TTFS: "resources-fonts-liberation" +} + # pending: post-3.0 cleanup # unstructured kludge REPLACE_TITLE_WORDS = { - "ttf": "Kenney TTFs", + "Kenney": KENNEY_TTFS, + "Liberation": LIBERATION_TTFS, "gui": "GUI", "window": "Window & Panel", ".": "Top-level Resources" } +# NASTY! # pending: post-3.0 cleanup +OVERRIDE_LEVELS = { + KENNEY_TTFS: 2, + LIBERATION_TTFS: 2 +} + # pending: post-3.0 cleanup # more unstructured filth SKIP_TITLES = { - "Kenney TTFs" + "Ttf" + # "Kenney TTFs" } @@ -229,6 +246,10 @@ def process_resource_directory(out, dir: Path): file_list = filter_dir(path, keep=is_unskipped_file) num_files = len(file_list) + def _debug_print_files() -> None: # pending: post-3.0 cleanup + """Nasty little temp helper""" + for file in file_list: + print(file.name) if num_files > 0: @@ -245,23 +266,55 @@ def process_resource_directory(out, dir: Path): continue as_tup = tuple(display_parts[:heading_level]) if as_tup not in visited_headings: + # NASTY! # pending: post 3.0 cleanup + if part in OVERRIDE_LEVELS: + heading_level = OVERRIDE_LEVELS[part] + + # print("!!!", heading_level, part, as_tup) + + if ref_target := PREFIX_REF_TARGET.get(part, None): + out.write(f".. _{ref_target}:\n") + do_heading(out, heading_level, part) visited_headings.add(as_tup) if raw_resource_handle == ":resources:images/": - for f in file_list: - print(f.name) - - if raw_resource_handle == ":resources:fonts/ttf/": - for f in file_list: - print(f.name) - # pending: post-3.0 cleanup - out.write("\n") - out.write(".. figure:: images/fonts_blue.png\n") - out.write(" :alt: The bundled Kenney.nl fonts.\n") - out.write("\n") - out.write(" Arcade includes the following fonts from `Kenney.nl's font pack `_\n") - out.write(" are available using the path and filenames below.\n") + _debug_print_files() + + if raw_resource_handle.startswith(":resources:fonts/ttf/"): + _debug_print_files() + if raw_resource_handle.endswith("Kenney/"): + out.write("\n") + + out.write(".. figure:: images/fonts_blue.png\n") + # out.write(" :align: center\n") + out.write(" :alt: The bundled Kenney.nl fonts.\n") + out.write("\n") + # Put the text *after* the CSS, or add
via .. raw:: html blocks + # since the CSS may be broken. + out.write("Arcade includes the following fonts from `Kenney.nl's font pack `_\n") + out.write("are available using the path and filenames below.\n") + out.write("\n") + + elif raw_resource_handle.endswith("Liberation/"): + out.write( + "\n" + ".. figure:: images/fonts_liberation.png\n" + " :alt: The bundled Liberation font family trio.\n" + #" :align: center\n" + # Put the text *after* the CSS, or add
via .. raw:: html blocks + # since the CSS may be broken. + "\n" + "Arcade also includes the Liberation font family. This trio is designed and\n" + "licensed specifically to be a portable, drop-in set of substitutes for Times, Arial,\n" + "and Courier fonts. It uses the proven, commercial-friendly `SIL Open Font License`_.\n" + "\n" + "To use these fonts, you may use either approach:\n" + "\n" + "* load files for specific variants via :py:func:`arcade.load_font`\n" + "* load all variants at once with :py:func:`arcade.resources.load_liberation_fonts`.\n" + "\n" + ) n_cols = get_header_num_cols(raw_resource_handle, num_files) widths = get_column_widths_for_n(n_cols) @@ -297,6 +350,7 @@ def process_resource_directory(out, dir: Path): '.avi': 'avi' } + def process_resource_files(out, file_list: List[Path]): cell_count = 0 @@ -342,8 +396,12 @@ def process_resource_files(out, file_list: List[Path]): elif suffix == ".glsl": file_path = FMT_URL_REF_PAGE.format(resource_path) out.write(f" {start_row} - `{path} <{file_path}>`_\n") - # Link Tiled maps - elif suffix in (".json", ".ttf"): + # Fonts + elif suffix == ".ttf": + file_path = FMT_URL_REF_PAGE.format(resource_path) + out.write(f" {start_row} - `{name} <{file_path}>`_\n") + # Tiled maps + elif suffix == ".json": file_path = FMT_URL_REF_PAGE.format(resource_path) out.write(f" {start_row} - `{name} <{file_path}>`_\n") else: