From: Neil Date: Wed, 7 Sep 2016 11:00:13 +0000 (+0200) Subject: Add font loader and DejaVu sans font X-Git-Tag: tabakrolletjie-v1.0.0~209 X-Git-Url: https://git.ctpug.org.za/?p=tabakrolletjie.git;a=commitdiff_plain;h=ac4252ec763afa290f98bd8b5de4d96d11f3ad99 Add font loader and DejaVu sans font --- diff --git a/data/fonts/DejaVu-Copyright.txt b/data/fonts/DejaVu-Copyright.txt new file mode 100644 index 0000000..136f2b2 --- /dev/null +++ b/data/fonts/DejaVu-Copyright.txt @@ -0,0 +1,48 @@ +Fonts are (c) Bitstream (see below). DejaVu changes are in public domain. + +Bitstream Vera Fonts Copyright +------------------------------ + +Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream Vera is +a trademark of Bitstream, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of the fonts accompanying this license ("Fonts") and associated +documentation files (the "Font Software"), to reproduce and distribute the +Font Software, including without limitation the rights to use, copy, merge, +publish, distribute, and/or sell copies of the Font Software, and to permit +persons to whom the Font Software is furnished to do so, subject to the +following conditions: + +The above copyright and trademark notices and this permission notice shall +be included in all copies of one or more of the Font Software typefaces. + +The Font Software may be modified, altered, or added to, and in particular +the designs of glyphs or characters in the Fonts may be modified and +additional glyphs or characters may be added to the Fonts, only if the fonts +are renamed to names not containing either the words "Bitstream" or the word +"Vera". + +This License becomes null and void to the extent applicable to Fonts or Font +Software that has been modified and is distributed under the "Bitstream +Vera" names. + +The Font Software may be sold as part of a larger software package but no +copy of one or more of the Font Software typefaces may be sold by itself. + +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 BITSTREAM OR THE GNOME +FOUNDATION 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. + +Except as contained in this notice, the names of Gnome, the Gnome +Foundation, and Bitstream Inc., shall not be used in advertising or +otherwise to promote the sale, use or other dealings in this Font Software +without prior written authorization from the Gnome Foundation or Bitstream +Inc., respectively. For further information, contact: fonts at gnome dot +org. diff --git a/data/fonts/DejaVuSans.ttf b/data/fonts/DejaVuSans.ttf new file mode 100644 index 0000000..84ca1d7 Binary files /dev/null and b/data/fonts/DejaVuSans.ttf differ diff --git a/tabakrolletjie/loader.py b/tabakrolletjie/loader.py index b2ff527..252960b 100644 --- a/tabakrolletjie/loader.py +++ b/tabakrolletjie/loader.py @@ -4,6 +4,7 @@ import json import os import pygame.image +import pygame.font import pygame.display from .constants import DEBUG @@ -43,6 +44,14 @@ class Loader(object): self._cache[fn] = img return img + def load_font(self, *parts, **kwargs): + """Return a pygame font of the given size""" + size = kwargs.get('size', 12) + fn = self.full_path("fonts", *parts) + font = pygame.font.Font(fn, size) + # Do we need to cache this? + return font + _DATA_PREFIX = os.path.abspath( os.path.join(os.path.dirname(__file__), "..", "data"))