def GetFont(font): """ Returns a Pylget Font object for the given Agg or Kiva font """ if isinstance(font, PygletFont): pyglet_font = font else: # AggFontType key = (font.name, font.size, font.family, font.style) if key not in GlobalFontCache: if isinstance(font, AggFontType): agg_font = font font = Font(face_name = agg_font.name, size = agg_font.size, family = agg_font.family, style = agg_font.style) bold = False italic = False if font.style == BOLD or font.style == BOLD_ITALIC or font.weight == BOLD: bold = True if font.style == ITALIC or font.style == BOLD_ITALIC: italic = True pyglet_font = load_font(font.findfontname(), font.size, bold, italic) GlobalFontCache[key] = pyglet_font else: pyglet_font = GlobalFontCache[key] return pyglet_font
def GetFont(font): """ Returns a Pylget Font object for the given Agg or Kiva font """ if isinstance(font, PygletFont): pyglet_font = font else: # AggFontType key = (font.name, font.size, font.family, font.style) if key not in GlobalFontCache: if isinstance(font, AggFontType): agg_font = font font = Font(face_name=agg_font.name, size=agg_font.size, family=agg_font.family, style=agg_font.style) bold = False italic = False if font.style in [BOLD, BOLD_ITALIC] or font.weight == BOLD: bold = True if font.style in [ITALIC, BOLD_ITALIC]: italic = True pyglet_font = load_font(font.findfontname(), font.size, bold, italic) GlobalFontCache[key] = pyglet_font else: pyglet_font = GlobalFontCache[key] return pyglet_font
def __init__(self, font=None, interval=0.25, format='%(fps).2f', color=(.5, .5, .5, .5), clock=None): '''Create a ClockDisplay. All parameters are optional. By default, a large translucent font will be used to display the FPS to two decimal places. :Parameters: `font` : `pyglet.font.Font` The font to format text in. `interval` : float The number of seconds between updating the display. `format` : str A format string describing the format of the text. This string is modulated with the dict ``{'fps' : fps}``. `color` : 4-tuple of float The color, including alpha, passed to ``glColor4f``. `clock` : `Clock` The clock which determines the time. If None, the default clock is used. ''' if clock is None: clock = _default self.clock = clock self.clock.schedule_interval(self.update_text, interval) if not font: from pyglet.font import load as load_font font = load_font('', 36, bold=True) import pyglet.font self.label = pyglet.font.Text(font, '', color=color, x=10, y=10) self.format = format
def GetFont(font): """ Returns a Pylget Font object for the given Agg or Kiva font """ if isinstance(font, PygletFont): pyglet_font = font else: # KivaGLFontType key = (font.name, font.size, font.family, font.style) if key not in GlobalFontCache: if isinstance(font, KivaGLFontType): kiva_gl_font = font font = Font( face_name=kiva_gl_font.name, size=kiva_gl_font.size, family=kiva_gl_font.family, style=kiva_gl_font.style, ) bold = font.is_bold() italic = font.style in italic_styles pyglet_font = load_font(font.findfontname(), font.size, bold, italic) GlobalFontCache[key] = pyglet_font else: pyglet_font = GlobalFontCache[key] return pyglet_font
def __init__(self, scene=None, *args, **kwargs): super(Game, self).__init__(*args, **kwargs) self.fps_display = ClockDisplay(font=load_font('Arial', 24)) self.scene = scene self.on_enter()
from pyglet.font import add_file as load_font import pyexcel_ods3 as ods from os.path import basename as os_name from playsound import playsound from collections import OrderedDict import sys.argv as arguments from getopt import getopt from ipa import sort_IPA, \ IPA, IPA_Other, \ IPA_Place, IPA_Manner, \ IPA_Backness, IPA_Height, \ IPA_Type, IPA_i \ VERSION = "1.0.0b" RELEASE = "11/27/20" load_font("assets/NotoSans-Regular.ttf") def get_name(name): if "/" in list(name): return os_name(name) else: return name class Phono(tk.Frame): def __init__(self, parent=None): try: super().__init__(parent) self.root = parent self.root.iconbitmap("assets/icon.ico") self.root.title("Phonologiter - New Phonology")
import sys try: innerLevel = float(sys.argv[1]) outerLevel = float(sys.argv[2]) except IndexError: innerLevel = 1.0 outerLevel = 1.0 targetInnerLevel = innerLevel targetOuterLevel = outerLevel #spacing = 0 spacingStr = 'equal_spacing' import math import pyglet.font from pyglet.font import load as load_font font = load_font('', 12, bold=True) levelsLabel = pyglet.font.Text(font, 'Press the arrow keys.', color=(1,0,0,.5),x=10,y=10) auxLabel = pyglet.font.Text(font, 'asdf', color=(1,0,0,.5),x=10,y=30) helpLabel = pyglet.font.Text(font, 'Q,W,E: Change Spacing ' 'Arrows: Change Tess Levels', color=(1,0,0,.5),x=10,y=window.height-20) allLabels = [levelsLabel, auxLabel, helpLabel] def WriteShaderProgram(destPath, templatePath, replacements): with open(templatePath) as templateFile: with open(destPath, 'w') as destFile: for line in templateFile: for key, value in replacements.iteritems(): line = line.replace(key, value) destFile.write(line)
from gletools import ShaderProgram, VertexObject, Matrix window = pyglet.window.Window(width=1100, height=500) rotation = 0.0 innerLevel = 1.0 outerLevel = 1.0 targetInnerLevel = 1.0 targetOuterLevel = 1.0 # spacing = 0 spacingStr = "equal_spacing" import math import pyglet.font from pyglet.font import load as load_font font = load_font("", 12, bold=True) levelsLabel = pyglet.font.Text(font, "Press the arrow keys.", color=(1, 0, 0, 0.5), x=10, y=10) auxLabel = pyglet.font.Text(font, "asdf", color=(1, 0, 0, 0.5), x=10, y=30) helpLabel = pyglet.font.Text( font, "Q,W,E: Change Spacing " "Arrows: Change Tess Levels", color=(1, 0, 0, 0.5), x=10, y=window.height - 20 ) allLabels = [levelsLabel, auxLabel, helpLabel] def WriteShaderProgram(destPath, templatePath, replacements): with open(templatePath) as templateFile: with open(destPath, "w") as destFile: for line in templateFile: for key, value in replacements.iteritems(): line = line.replace(key, value) destFile.write(line)