|
6 | 6 |
|
7 | 7 | #: The absolute path to this directory
|
8 | 8 | RESOURCE_DIR = Path(__file__).parent.resolve()
|
| 9 | + |
| 10 | +# The "system" resources common to Arcade |
9 | 11 | SYSTEM_PATH = RESOURCE_DIR / "system"
|
| 12 | +FONTS_PATH = SYSTEM_PATH / "fonts" |
| 13 | +TTF_PATH = FONTS_PATH / "ttf" |
| 14 | + |
| 15 | +# Basic resources in the :assets: handle |
10 | 16 | ASSET_PATH = RESOURCE_DIR / "assets"
|
11 | 17 |
|
| 18 | + |
12 | 19 | handles: dict[str, list[Path]] = {
|
13 | 20 | "resources": [SYSTEM_PATH, ASSET_PATH],
|
14 | 21 | "assets": [ASSET_PATH],
|
@@ -212,32 +219,91 @@ def list_built_in_assets(
|
212 | 219 |
|
213 | 220 |
|
214 | 221 | def load_kenney_fonts() -> None:
|
215 |
| - """Loads all the fonts in arcade's system directory. |
216 |
| -
|
217 |
| - Currently, this is only the Kenney fonts:: |
218 |
| -
|
219 |
| - Kenney_Blocks.ttf - Kenney Blocks |
220 |
| - Kenney_Future.ttf - Kenney Future |
221 |
| - Kenney_Future_Narrow.ttf - Kenney Future Narrow |
222 |
| - Kenney_High.ttf - Kenney High |
223 |
| - Kenney_High_Square.ttf - Kenney High Square |
224 |
| - Kenney_Mini.ttf - Kenney Mini |
225 |
| - Kenney_Mini_Square.ttf - Kenney Mini Square |
226 |
| - Kenney_Pixel.ttf - Kenney Pixel |
227 |
| - Kenney_Pixel_Square.ttf - Kenney Pixel Square |
228 |
| - Kenney_Rocket.ttf - Kenney Rocket |
229 |
| - Kenney_Rocket_Square.ttf - Kenney Rocket Square |
| 222 | + """Loads all the Kenney.nl fonts bundled with Arcade. |
| 223 | +
|
| 224 | + .. tip:: This function is best for prototyping and experimenting! |
| 225 | +
|
| 226 | + For best performance, you may want to switch to |
| 227 | + :py:class:`arcade.load_font` before release. |
| 228 | +
|
| 229 | + Please see :ref:`resources-fonts-kenney` for previews and |
| 230 | + license information. The filename to load and ``font_name`` to use |
| 231 | + when drawing text are summarized below: |
| 232 | +
|
| 233 | + .. might swap to this style for the resources listing once I figure out how to |
| 234 | + .. cleanly modify the file to use it. |
| 235 | +
|
| 236 | + ========================================= ========================================================================= |
| 237 | + ``font_name`` for :py:class:`arcade.Text` :ref:`Resource handle <resource_handles>` for :py:func:`arcade.load_font` |
| 238 | + ========================================= ========================================================================= |
| 239 | + ``"Kenney Blocks"`` ``:resources:fonts/ttf/Kenney/Kenney_Blocks.ttf`` |
| 240 | + ``"Kenney Future"`` ``:resources:fonts/ttf/Kenney/Kenney_Future.ttf`` |
| 241 | + ``"Kenney Future Narrow"`` ``:resources:fonts/ttf/Kenney/Kenney_Future_Narrow.ttf`` |
| 242 | + ``"Kenney High"`` ``:resources:fonts/ttf/Kenney/Kenney_High.ttf`` |
| 243 | + ``"Kenney High Square"`` ``:resources:fonts/ttf/Kenney/Kenney_High_Square.ttf`` |
| 244 | + ``"Kenney Mini"`` ``:resources:fonts/ttf/Kenney/Kenney_Mini.ttf`` |
| 245 | + ``"Kenney Mini Square"`` ``:resources:fonts/ttf/Kenney/Kenney_Mini_Square.ttf`` |
| 246 | + ``"Kenney Pixel"`` ``:resources:fonts/ttf/Kenney/Kenney_Pixel.ttf`` |
| 247 | + ``"Kenney Pixel Square"`` ``:resources:fonts/ttf/Kenney/Kenney_Pixel_Square.ttf`` |
| 248 | + ``"Kenney Rocket"`` ``:resources:fonts/ttf/Kenney/Kenney_Rocket.ttf`` |
| 249 | + ``"Kenney Rocket Square"`` ``:resources:fonts/ttf/Kenney/Kenney_Rocket_Square.ttf`` |
| 250 | + ========================================= ========================================================================= |
| 251 | +
|
| 252 | + """ # noqa: E501 # Silence ruff # pending: better generation |
| 253 | + from arcade.text import load_font |
| 254 | + |
| 255 | + load_font(":system:fonts/ttf/Kenney/Kenney_Blocks.ttf") |
| 256 | + load_font(":system:fonts/ttf/Kenney/Kenney_Future.ttf") |
| 257 | + load_font(":system:fonts/ttf/Kenney/Kenney_Future_Narrow.ttf") |
| 258 | + load_font(":system:fonts/ttf/Kenney/Kenney_High.ttf") |
| 259 | + load_font(":system:fonts/ttf/Kenney/Kenney_High_Square.ttf") |
| 260 | + load_font(":system:fonts/ttf/Kenney/Kenney_Mini.ttf") |
| 261 | + load_font(":system:fonts/ttf/Kenney/Kenney_Mini_Square.ttf") |
| 262 | + load_font(":system:fonts/ttf/Kenney/Kenney_Pixel.ttf") |
| 263 | + load_font(":system:fonts/ttf/Kenney/Kenney_Pixel_Square.ttf") |
| 264 | + load_font(":system:fonts/ttf/Kenney/Kenney_Rocket.ttf") |
| 265 | + load_font(":system:fonts/ttf/Kenney/Kenney_Rocket_Square.ttf") |
| 266 | + |
| 267 | + |
| 268 | +def load_liberation_fonts() -> None: |
| 269 | + """Loads all styles for generic Arial, Courier, and Times New Roman replacements. |
| 270 | +
|
| 271 | + .. tip:: This function is best for prototyping and experimenting! |
| 272 | +
|
| 273 | + For best performance, you may want to switch to |
| 274 | + :py:class:`arcade.load_font` before release. |
| 275 | +
|
| 276 | + The Liberation fonts are proven, permissively-licensed fonts.[ |
| 277 | + For previews and additional information, please see |
| 278 | + :ref:`resources-fonts-liberation`. |
| 279 | +
|
| 280 | + .. list-table:: ``font_name`` values for :py:class:`arcade.Text` |
| 281 | + :header-rows: 1 |
| 282 | +
|
| 283 | + * - Proprietary Font(s) |
| 284 | + - Liberation Replacemetn |
| 285 | +
|
| 286 | + * - ``"Courier"`` |
| 287 | + - ``"Liberation Mono"`` |
| 288 | +
|
| 289 | + * - ``"Times New Roman"``, ``"Times"`` |
| 290 | + - ``"Liberation Serif"`` |
| 291 | +
|
| 292 | + * - ``"Arial"`` |
| 293 | + - ``"Liberation Sans"`` |
| 294 | +
|
230 | 295 | """
|
231 | 296 | from arcade.text import load_font
|
232 | 297 |
|
233 |
| - load_font(":system:fonts/ttf/Kenney_Blocks.ttf") |
234 |
| - load_font(":system:fonts/ttf/Kenney_Future.ttf") |
235 |
| - load_font(":system:fonts/ttf/Kenney_Future_Narrow.ttf") |
236 |
| - load_font(":system:fonts/ttf/Kenney_High.ttf") |
237 |
| - load_font(":system:fonts/ttf/Kenney_High_Square.ttf") |
238 |
| - load_font(":system:fonts/ttf/Kenney_Mini.ttf") |
239 |
| - load_font(":system:fonts/ttf/Kenney_Mini_Square.ttf") |
240 |
| - load_font(":system:fonts/ttf/Kenney_Pixel.ttf") |
241 |
| - load_font(":system:fonts/ttf/Kenney_Pixel_Square.ttf") |
242 |
| - load_font(":system:fonts/ttf/Kenney_Rocket.ttf") |
243 |
| - load_font(":system:fonts/ttf/Kenney_Rocket_Square.ttf") |
| 298 | + load_font(":system:fonts/ttf/Liberation/Liberation_Mono_BoldItalic.ttf") |
| 299 | + load_font(":system:fonts/ttf/Liberation/Liberation_Mono_Bold.ttf") |
| 300 | + load_font(":system:fonts/ttf/Liberation/Liberation_Mono_Italic.ttf") |
| 301 | + load_font(":system:fonts/ttf/Liberation/Liberation_Mono_Regular.ttf") |
| 302 | + load_font(":system:fonts/ttf/Liberation/Liberation_Sans_BoldItalic.ttf") |
| 303 | + load_font(":system:fonts/ttf/Liberation/Liberation_Sans_Bold.ttf") |
| 304 | + load_font(":system:fonts/ttf/Liberation/Liberation_Sans_Italic.ttf") |
| 305 | + load_font(":system:fonts/ttf/Liberation/Liberation_Sans_Regular.ttf") |
| 306 | + load_font(":system:fonts/ttf/Liberation/Liberation_Serif_BoldItalic.ttf") |
| 307 | + load_font(":system:fonts/ttf/Liberation/Liberation_Serif_Bold.ttf") |
| 308 | + load_font(":system:fonts/ttf/Liberation/Liberation_Serif_Italic.ttf") |
| 309 | + load_font(":system:fonts/ttf/Liberation/Liberation_Serif_Regular.ttf") |
0 commit comments