• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python font.load函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pyglet.font.load函数的典型用法代码示例。如果您正苦于以下问题:Python load函数的具体用法?Python load怎么用?Python load使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了load函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: _draw_items

    def _draw_items( self ):

        width, height = director.get_window_size()

        fo = font.load( self.font_items, self.font_items_size )
        fo_selected = font.load( self.font_items, self.font_items_selected_size )
        fo_height = int( (fo.ascent - fo.descent) * 0.9 )

        if self.menu_halign == CENTER:
            pos_x = width / 2
        elif self.menu_halign == RIGHT:
            pos_x = width - 2
        elif self.menu_halign == LEFT:
            pos_x = 2
        else:
            raise Exception("Invalid halign value for menu")

        for idx,item in enumerate( self.items ):

            if self.menu_valign == CENTER:
                pos_y = height / 2 + (fo_height * len(self.items) )/2 - (idx * fo_height )
            elif self.menu_valign == TOP:
                pos_y = height - (idx * fo_height )
            elif self.menu_valign == BOTTOM:
                pos_y = 0 + fo_height * len(self.items) - (idx * fo_height )

            item._init_font( pos_x, pos_y, self.font_items, self.font_items_selected_size, self.font_items_size )
开发者ID:hugoruscitti,项目名称:irobotgame,代码行数:27,代码来源:menu.py


示例2: on_enter

    def on_enter(self):
        super(ControlLayer, self).on_enter()

        ft_title = font.load("Arial", 32)
        ft_subtitle = font.load("Arial", 18)
        ft_help = font.load("Arial", 16)

        self.text_title = font.Text(ft_title, "Transition Demos",
                                    x=5,
                                    y=480,
                                    anchor_x=font.Text.LEFT,
                                    anchor_y=font.Text.TOP)

        self.text_subtitle = font.Text(ft_subtitle, transition_list[current_transition].__name__,
                                       x=5,
                                       y=400,
                                       anchor_x=font.Text.LEFT,
                                       anchor_y=font.Text.TOP)

        self.text_help = font.Text(ft_help, "Press LEFT / RIGHT for prev/next example, "
                                   "ENTER to restart example",
                                   x=320,
                                   y=20,
                                   anchor_x=font.Text.CENTER,
                                   anchor_y=font.Text.CENTER)
开发者ID:1414648814,项目名称:cocos,代码行数:25,代码来源:presentacion.py


示例3: __init__

 def __init__(self, handler):
     mode.Renderer.__init__(self, handler)
     font.add_file('resources/amsterdam.ttf')
     self.amsterdam = font.load('Amsterdam Graffiti', 45)
     self.amsterdam_detail = font.load('Amsterdam Graffiti', 24)
     if(not self.handler.menu_boxes):
         self.handler.menu_boxes = []
         for i in range(10):
             self.handler.menu_boxes.append((50, 700, 
                 575 - i * BAR_HEIGHT, 575 - (i + 1) * BAR_HEIGHT))
开发者ID:jseutter,项目名称:getoffmylawn,代码行数:10,代码来源:degrees_of_awesome.py


示例4: __init__

 def __init__(self, win):
     helv = font.load('Helvetica', win.width / 15.0)
     self.text = font.Text(
         helv,
         'Hello!',
         x=win.width / 2,
         y=win.height / 2,
         halign=font.Text.CENTER,
         valign=font.Text.CENTER,
         color=(1, 1, 1, 0.5),
     )
     h = font.load('Helvetica', 15)
     self.help = font.Text(h, 'to exit: type "smash" and press escape', x=10, y=win.height-25, color=(1,1,1,.5))
     self.fps = clock.ClockDisplay()
开发者ID:jon1012,项目名称:babytux,代码行数:14,代码来源:app.py


示例5: __init__

 def __init__(self, x, y, width, height, font_name='Helvetica', size=10,\
               bck_color = (0.9,0.9,0.9,1.0), text_color = (0.0,0.0,0.0,1.0)):
     """
     Initialize all the default widget properties like position,
     size, background and foreground color, and other generic
     properties
     """
     #Ortho coords
     self._x, self._y = x,y
     
     #Ortho dimensions
     self._width, self._height = width, height
     
     #Font loader
     self._size = size
     self._font = font.load(font_name,size)
     
     #Other properties
     self._line_color = bck_color
     self._text_color = text_color
     self._loaded = False
     
     self._line = Sprite.Sprite(self._x, self._y, self._width,\
                         self._height, None, self._line_color)
     self._text = font.Text(self._font, "", self._x, self._y,\
                             halign = font.Text.LEFT, \
                             valign = font.Text.BOTTOM, \
                             color = self._text_color)
开发者ID:rosedu,项目名称:hfall,代码行数:28,代码来源:UI.py


示例6: __init__

    def __init__(self, caption="Simulation"):
        """Initialisiert das Fenster."""

        # Fenster öffnen
        try:
            config = Config(sample_buffers=1, samples=1, double_buffer=True)
            super(PendulumWindow, self).__init__(config=config,
                                                 resizable=True,
                                                 caption=caption)
        except:
            super(PendulumWindow, self).__init__(resizable=True,
                                                 caption=caption)

        # Schrift laden
        self.font_sans = font.load(None, 16)

        # FPS
        self.fps_display = clock.ClockDisplay()

        # Pendel aufhängen
        self.single_pendulum = SinglePendulum(length=9.0, phi=pi / 5)
        self.double_pendulum = DoublePendulum()

        # Einstellungsfenster
        self.settings_window = SettingsWindow(self,
                                              pendulum=self.double_pendulum,
                                              position=(15, 15))
        self.settings_window.reset()
开发者ID:Sir2B,项目名称:Uni,代码行数:28,代码来源:simulation.py


示例7: ranges

    def ranges(self, start, end):
        from pyglet import font

        for start, end, styles in self.zip_iter.ranges(start, end):
            font_name, font_size, bold, italic = styles
            ft = font.load(font_name, font_size, bold=bool(bold), italic=bool(italic), dpi=self.dpi)
            yield start, end, ft
开发者ID:josch,项目名称:fheroes3,代码行数:7,代码来源:document.py


示例8: __init__

 def __init__(self, *args, **kwargs):
   super(MainWindow, self).__init__(*args, **kwargs)
   self.keys = window.key.KeyStateHandler()
   self.push_handlers(self.keys)
   # self.set_exclusive_mouse()
   self.width, self.height, self.rat3d, self.ratex = 640, 480, 1.05, 0.5
   self.zoom, self.expand, self.mapping, self.blend = 0, 0, 0, 1
   self.fgc, self.bgc = (1.0, 1.0, 1.0, 0.9), (0.1, 0.1, 0.1, 0.1)
   self.loadfgc, self.loadbgc = (0.4, 0.2, 0.4, 0.3), (0.6, 0.3, 0.6, 0.9)
   self.instfgc, self.instbgc = (0.1, 0.1, 0.5, 0.9), (0.5, 0.9, 0.9, 0.8)
   self.instbkwidth, self.instbkheight = 480, 400
   bmplen = (self.instbkwidth / 8) * self.instbkheight
   self.instbkbmp = (ctypes.c_ubyte * bmplen)(*([255] * bmplen))
   self.ticktimer, self.tick, self.insttimer, self.inst = 0.5, 0.0, 30, 1
   self.printing, self.solver = 1, deque()
   self.stat = [None, 0, Queue.Queue(512)] # (key(1-9), direc), count, queue
   self.cmax, self.tanim = 18, [6, 3, 1, 3] # frames in rotate moving, speeds
   self.tcos, self.tsin = [1.0] * (self.cmax + 1), [0.0] * (self.cmax + 1)
   for i in xrange(1, self.cmax):
     t = i * math.pi / (2.0 * self.cmax) # 0 < t < pi/2
     self.tcos[i], self.tsin[i] = math.cos(t), math.sin(t)
   self.tcos[self.cmax], self.tsin[self.cmax] = 0.0, 1.0 # pi/2 regulation
   self.InitRot()
   self.InitAxis()
   self.InitGL(self.width, self.height)
   self.textures = [None] * (len(self.ary_norm) * 2 + 1 + len(TEXIMG_CHAR))
   self.loading, self.dat = 0, [('', 0, 0)] * len(self.textures)
   resource.add_font(FONT_FILE)
   self.font = font.load(FONT_FACE, 20)
   self.fontcolor = (0.5, 0.8, 0.5, 0.9)
   self.fps_display = clock.ClockDisplay(font=self.font, color=self.fontcolor)
   self.fps_pos = (-60.0, 30.0, -60.0)
   clock.set_fps_limit(60)
   clock.schedule_interval(self.update, 1.0 / 60.0)
开发者ID:HatsuneMiku,项目名称:HatsuneMiku,代码行数:34,代码来源:rcube.py


示例9: __init__

    def __init__(self, parent, title="Window", position=None,
                 constraints=(300, 250)):
        """Creates the window."""

        super(Window, self).__init__()

        # If no position is given, center the window.
        if position is None:
            self.x = (parent.width - constraints[0]) / 2
            self.y = (parent.height - constraints[1]) / 2
        else:
            self.x, self.y = position

        self.parent = parent
        self.title = title
        self.width, self.height = constraints

        # title bar dragging
        self._is_dragging = False
        self._drag_x, self._drag_y = (0, 0)

        # Load a font for the titlebar.
        self._titlebarheight = 15
        self.font = font.load(None, self._titlebarheight * 0.9, dpi=72)

        # manage widgets as a list
        self.widgets = []

        parent.push_handlers(self)
开发者ID:Sir2B,项目名称:Uni,代码行数:29,代码来源:window.py


示例10: __init__

    def __init__(self, *args, **kwargs):

        #Let all of the arguments pass through
        self.win = window.Window.__init__(self, *args, **kwargs)
        
        self.maxaliens = 50 # max num of aliens simultaneously on the screen
        
        clock.schedule_interval(self.create_alien, 0.5)
        clock.schedule_interval(self.update, 1.0/30) # update at FPS of Hz
        
        #clock.set_fps_limit(30)
        
        # setting text objects
        ft = font.load('Tahoma', 20)    #Create a font for our FPS clock
        self.fpstext = font.Text(ft, y=10)   # object to display the FPS
        self.score = font.Text(ft, x=self.width, y=self.height, 
                               halign=pyglet.font.Text.RIGHT, 
                               valign=pyglet.font.Text.TOP)
        
        # reading and saving images
        self.spaceship_image = pyglet.image.load('images/ship3.png')
        self.alien_image = pyglet.image.load('images/invader.png')
        self.bullet_image = pyglet.image.load('images/bullet_white_16.png')
        
        # create one spaceship
        self.spaceship = Spaceship(self.spaceship_image, x=50, y=50)
        
        self.aliens=[] # list of Alien objects
        self.bullets=[] # list of Bullet objects
开发者ID:guillermoaguilar,项目名称:pyglet_tutorial,代码行数:29,代码来源:game.py


示例11: __init__

    def __init__(self, client, points=9, eye=1, wait=1, randomize=1, auto=0, speed=1, level=3):
        super(CalibrationLayer, self).__init__(0, 0, 255, 255)
        self.client = client
        self.points = points
        self.eye = eye
        self.wait = wait
        self.randomize = randomize
        self.auto = auto
        self.speed = speed
        self.level = level
        self.on_success = None
        self.on_failure = None

        self.window = director.window.get_size()
        self.screen = director.get_window_size()
        self.center_x = self.screen[0] / 2
        self.center_y = self.screen[1] / 2
        self.win_scale = (self.screen[0] / self.window[0], self.screen[1] / self.window[1])

        self.font = font.load("Cut Outs for 3D FX", 32)
        self.circle_img = self.font.get_glyphs("E")[0].get_texture(True)
        self.circle_img.anchor_x = "center"
        self.circle_img.anchor_y = "center"
        self.pnt_img = self.font.get_glyphs("Y")[0].get_texture(True)
        self.pnt_img.anchor_x = "center"
        self.pnt_img.anchor_y = "center"

        self.circle = Sprite(self.circle_img, color=(255, 255, 0), scale=1, opacity=0)
        self.spinner = Sprite(
            resource.image("spinner.png"), position=(self.screen[0] / 2, self.screen[1] / 2), color=(255, 255, 255)
        )
开发者ID:CogWorks,项目名称:WhackAMole,代码行数:31,代码来源:calibrator.py


示例12: render

	def render(self, dt):
		self.window.clear()
		
		self.set_projection()
		
		font.add_file('./font/Pure-ThinDuranGo.ttf')
		arial = font.load('Roman', 9, dpi=96)
		
		text = 'Hello, world!'
		glyphs = arial.get_glyphs(text)

		#gs = GlyphString(text, glyphs)
		# glyph_string.draw()
		#for g in gs:
		#	g.blit(x, y, z=0, width=None, height=None)


		label = pyglet.text.Label('Hello, world a',
			#font_name='./font/Pure-ThinDuranGo.ttf',
			font_size=14,
			x=10, y=10
		)
		label.draw()

		#glBegin(GL_LINES)
		#for ob in self.model:
		#	self.render_ob(*ob)
		#glEnd()

		self.window.flip()
开发者ID:institution,项目名称:c3rush,代码行数:30,代码来源:main_new.py


示例13: __init__

    def __init__(self, title, lines):
        super(BulletListLayer, self).__init__()
        x, y = director.get_window_size()


        self.title = text.Label(
                title, (x/2, y-50), font_name = 'Gill Sans',
                font_size = 64, anchor_x='center', anchor_y='center' )
        self.add( self.title )

        start_y = (y/12)*8
        font_size = 52 / (len(lines)/2.2+1)
        font_size = min(font_size, 52)
        line_font = font.load('Gill Sans', font_size)
        tot_height = 0
        max_width = 0
        rendered_lines = []
        step = 300/ max(len(lines),1)
        i = 0
        for line in lines:
            line_text = text.Label(
                line, (x/2, y-150-step*i), font_name = 'Gill Sans',
                font_size = font_size, anchor_x='center', anchor_y='center' )
            i += 1   
            self.add( line_text )    
开发者ID:DatRollingStone,项目名称:nwidget,代码行数:25,代码来源:presentacion.py


示例14: __init__

    def __init__(self, title, lines):
        super(BulletListLayer, self).__init__()
        x, y = director.get_window_size()

        self.title = text.Label(
            title, (x // 2, y - 100), font_name='Consolas',
            font_size=46, anchor_x='center', anchor_y='center')
        self.add(self.title)

        start_y = (y // 12) * 8
        font_size = 22
        line_font = font.load('Consolas', font_size)
        tot_height = 0
        max_width = 0
        rendered_lines = []
        step = 40
        i = 0
        for line in lines:
            line_text = text.Label(
                line, (x // 2, y - 185 - step * i), font_name='Consolas',
                font_size=font_size, anchor_x='center', anchor_y='center')
            i += 1
            self.add(line_text)

        bgimage = Sprite('background.jpg')
        bgimage.scale = 0.8
        bgimage.position = x/2, y/2 - 200
        self.add(bgimage, z=-1)
开发者ID:gitTARDIS,项目名称:HATman,代码行数:28,代码来源:ppt_is_boring.py


示例15: __init__

 def __init__(self, client):
     super(HeadPositionLayer, self).__init__()
     self.client = client
     
     self.screen = director.get_window_size()
     
     self.font = font.load('Cut Outs for 3D FX', 384)
     arrow1_img = self.font.get_glyphs("I")[0].get_texture(True)
     arrow1_img.anchor_x = 'center'
     arrow1_img.anchor_y = 'center'
     arrow2_img = self.font.get_glyphs("J")[0].get_texture(True)
     arrow2_img.anchor_x = 'center'
     arrow2_img.anchor_y = 'center'
     
     self.arrows = [Sprite(arrow1_img, position=(self.screen[0] / 2, self.screen[1] / 8 * 7), color=(255, 0, 0), opacity=0, scale=.75, rotation=270),
                    Sprite(arrow1_img, position=(self.screen[0] / 2, self.screen[1] / 8 * 7), color=(255, 0, 0), opacity=0, scale=.75, rotation=90),
                    Sprite(arrow1_img, position=(self.screen[0] / 8, self.screen[1] / 2), color=(255, 0, 0), opacity=0, scale=.75, rotation=0),
                    Sprite(arrow1_img, position=(self.screen[0] / 8 * 7, self.screen[1] / 2), color=(255, 0, 0), opacity=0, scale=.75, rotation=180),
                    Sprite(arrow2_img, position=(self.screen[0] / 2, self.screen[1] / 8), color=(255, 0, 0), opacity=0, scale=.75, rotation=90),
                    Sprite(arrow2_img, position=(self.screen[0] / 2, self.screen[1] / 8), color=(255, 0, 0), opacity=0, scale=.75, rotation=270)]
     
     for arrow in self.arrows:
         self.add(arrow)
         
     self.head = (0,0,0)
开发者ID:CogWorks,项目名称:WilliamsTask,代码行数:25,代码来源:calibrator.py


示例16: __init__

 def __init__(self):
     super(BackgroundLayer, self).__init__()
     self.screen = director.get_window_size()
     self.batch = BatchNode()
     self.add(self.batch)
     
     self.shapes = {"circle":"E",
                    "square":"K",
                    "oval":"F",
                    "diamond":"T",
                    "crescent":"Q",
                    "cross":"Y",
                    "star":"C",
                    "triangle":"A"}
     
     self.font = font.load('Cut Outs for 3D FX', 128)
     self.glyphs = self.font.get_glyphs("".join(self.shapes.values()))
     
     ratio = 1 - self.screen[1] / self.screen[0]
     n = int(750 * ratio)
     for _ in range(0, n):
         img = choice(self.glyphs).get_texture(True)
         img.anchor_x = 'center'
         img.anchor_y = 'center'
         max_o = 96
         o = choice([0, max_o])
         speed = uniform(1, 10)
         sprite = Shape(img, rotation=randrange(0, 365), scale=uniform(ratio, 3 * ratio),
                         position=(randrange(0, self.screen[0]), randrange(0, self.screen[1])),
                         opacity=o, color=(randrange(0, 256), randrange(0, 256), randrange(0, 256)))
         if o == max_o:
             sprite.do(Repeat(FadeTo(0, speed) + FadeTo(max_o, speed)))
         else:
             sprite.do(Repeat(FadeTo(max_o, speed) + FadeTo(0, speed)))
         self.batch.add(sprite)
开发者ID:CogWorks,项目名称:WilliamsTask,代码行数:35,代码来源:main.py


示例17: __init__

    def __init__(self, *args, **kwargs):

        #Let all of the arguments pass through
        self.win = window.Window.__init__(self, *args, **kwargs)
        
        clock.schedule_interval(self.update, 1.0/30) # update at 30 Hz
        clock.schedule_interval(self.create_alien, 1.0/2) # update at 5 Hz
        
        
        # setting text objects
        ft = font.load('Tahoma', 20)         #Create a font for our FPS clock
        self.fpstext = font.Text(ft, y=10)   # object to display the FPS
        
        self.score = font.Text(ft, x=self.width, y=self.height, 
                               halign=pyglet.font.Text.RIGHT, 
                               valign=pyglet.font.Text.TOP)
                               
        # loading image
        self.spaceship_image = pyglet.image.load('images/ship3.png')
        self.spaceship = Spaceship(self.spaceship_image, x=200, y=50)
        
        self.alien_image = pyglet.image.load('images/invader.png')
        self.aliens = []
        
        self.bullet_image = pyglet.image.load('images/bullet_white_16.png')
        self.bullets = []
开发者ID:ocarneiro,项目名称:pyglet_tutorial,代码行数:26,代码来源:game5.py


示例18: _generate_title

    def _generate_title(self):
        width, height = director.get_window_size()
        fo = font.load(self.font_item['font_name'], self.font_item['font_size'])
        fo_height = int( (fo.ascent - fo.descent) * 0.9 )

        if self.menu_halign == CENTER:
            self.font_title['x'] = width // 2
        elif self.menu_halign == RIGHT:
            self.font_title['x'] = width - self.menu_hmargin
        elif self.menu_halign == LEFT:
            self.font_title['x'] = self.menu_hmargin
        else:
            raise Exception("Invalid anchor_x value for menu")

        self.font_title['anchor_x'] = self.menu_halign
        self.font_title['anchor_y'] = "center"
        self.font_title['text'] = self.title
        self.title_label = pyglet.text.Label( **self.font_title )
        self.title_height = self.title_label.content_height

        if self.menu_valign == CENTER:
            self.title_label.y = (height + len(self.children) * fo_height +
                         self.title_height) * 0.5
        elif self.menu_valign == TOP:
            self.title_label.y = (height - self.menu_vmargin - self.title_height //2)
        elif self.menu_valign == BOTTOM:
            self.title_label.y = (0 + fo_height * (len(self.children)) +
                         self.title_height + self.menu_vmargin)
开发者ID:dangillet,项目名称:space_tactical,代码行数:28,代码来源:gui.py


示例19: verticalMenuLayout

def verticalMenuLayout(menu):
    width, height = director.get_window_size()
    fo = font.load(menu.font_item['font_name'], menu.font_item['font_size'])
    fo_height = int((fo.ascent - fo.descent) * 0.9)

    if menu.menu_halign == CENTER:
        pos_x = width // 2
    elif menu.menu_halign == RIGHT:
        pos_x = width - menu.menu_hmargin
    elif menu.menu_halign == LEFT:
        pos_x = menu.menu_hmargin
    else:
        raise Exception("Invalid anchor_x value for menu")

    for idx, i in enumerate(menu.children):
        item = i[1]
        if menu.menu_valign == CENTER:
            pos_y = (height + (len(menu.children) - 2 * idx)
                     * fo_height - menu.title_height) * 0.5
        elif menu.menu_valign == TOP:
            pos_y = (height - ((idx + 0.8) * fo_height)
                     - menu.title_height - menu.menu_vmargin)
        elif menu.menu_valign == BOTTOM:
            pos_y = (0 + fo_height * (len(menu.children) - idx) +
                     menu.menu_vmargin)
        item.transform_anchor = (pos_x, pos_y)
        item.generateWidgets(pos_x, pos_y, menu.font_item,
                             menu.font_item_selected)
开发者ID:RyanHope,项目名称:cocos,代码行数:28,代码来源:menu.py


示例20: glont

    def glont(self, family, size):
        if not self.families.has_key(family):
            self.families[family] = {}
        if not self.families[family].has_key(size):
            self.families[family][size] = font.load(family, size)

        return self.families[family][size]
开发者ID:prismofeverything,项目名称:python-ball,代码行数:7,代码来源:gl.py



注:本文中的pyglet.font.load函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python gl.glBegin函数代码示例发布时间:2022-05-25
下一篇:
Python event.EventDispatcher类代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap