예제 #1
0
    def getGLFont(font_family_name,size=32,bold=False,italic=False,dpi=72):
        """
        Return a FontAtlas object that matches the family name, style info,
        and size provided. FontAtlas objects are cached, so if multiple
        TextBox instances use the same font (with matching font properties)
        then the existing FontAtlas is returned. Otherwise, a new FontAtlas is
        created , added to the cache, and returned.
        """
        from psychopy.visual.textbox import getFontManager
        fm=getFontManager()

        if fm:
            if fm.font_store:
                # should be loading from font store if requested font settings
                # have been saved to the hdf5 file (assuming it is faster)
                pass
                #print "TODO: Check if requested font is in FontStore"
            font_infos=fm.getFontsMatching(font_family_name,bold,italic)
            if len(font_infos) == 0:
                return False
            font_info=font_infos[0]
            fid=MonospaceFontAtlas.getIdFromArgs(font_info,size,dpi)
            font_atlas=fm.font_atlas_dict.get(fid)
            if font_atlas is None:
                font_atlas=fm.font_atlas_dict.setdefault(fid,MonospaceFontAtlas(font_info,size,dpi))
                font_atlas.createFontAtlas()
            if fm.font_store:
                t1=getTime()
                fm.font_store.addFontAtlas(font_atlas)
                t2=getTime()
                print 'font store add atlas:',t2-t1
        return font_atlas
예제 #2
0
    def getGLFont(font_family_name, size=32, bold=False, italic=False, dpi=72):
        """
        Return a FontAtlas object that matches the family name, style info,
        and size provided. FontAtlas objects are cached, so if multiple
        TextBox instances use the same font (with matching font properties)
        then the existing FontAtlas is returned. Otherwise, a new FontAtlas is
        created , added to the cache, and returned.
        """
        from psychopy.visual.textbox import getFontManager
        fm = getFontManager()

        if fm:
            font_infos = fm.getFontsMatching(font_family_name, bold, italic)
            if len(font_infos) == 0:
                return False
            font_info = font_infos[0]
            fid = MonospaceFontAtlas.getIdFromArgs(font_info, size, dpi)
            font_atlas = fm.font_atlas_dict.get(fid)
            if font_atlas is None:
                font_atlas = fm.font_atlas_dict.setdefault(
                    fid, MonospaceFontAtlas(font_info, size, dpi))
                font_atlas.createFontAtlas()
            if fm.font_store:
                t1 = getTime()
                fm.font_store.addFontAtlas(font_atlas)
                t2 = getTime()
                print('font store add atlas:', t2 - t1)
        return font_atlas
예제 #3
0
various timing measures collected.

Created on Thu Mar 21 18:37:10 2013

@author: Sol
"""
from __future__ import print_function
from __future__ import division
from builtins import range
import string
import random
from psychopy import visual, core, event
from psychopy.visual import textbox
from psychopy.iohub.util import NumPyRingBuffer
import pyglet.gl as gl
fm = textbox.getFontManager()
print(dir(fm))
print(fm.getFontFamilyNames())

# Variables to control text string length etc.
text_length=160
chng_txt_each_flips=5
max_flip_count=60*10
display_resolution=1920,1080

# Circular buffers to store timing measures
stim1_txt_change_draw_times=NumPyRingBuffer(6000)
stim1_no_change_draw_times=NumPyRingBuffer(6000)
stim2_txt_change_draw_times=NumPyRingBuffer(6000)
stim2_no_change_draw_times=NumPyRingBuffer(6000)
예제 #4
0
Created on Thu Mar 21 18:37:10 2013

@author: Sol
"""
from __future__ import print_function
from __future__ import division
from builtins import range
import string
import random
from psychopy import visual, core, event
from psychopy.visual import textbox
from psychopy.iohub.util import NumPyRingBuffer
import pyglet.gl as gl

fm = textbox.getFontManager()
print(dir(fm))
print(fm.getFontFamilyNames())

# Variables to control text string length etc.
text_length = 160
chng_txt_each_flips = 5
max_flip_count = 60 * 10
display_resolution = 1920, 1080

# Circular buffers to store timing measures
stim1_txt_change_draw_times = NumPyRingBuffer(6000)
stim1_no_change_draw_times = NumPyRingBuffer(6000)
stim2_txt_change_draw_times = NumPyRingBuffer(6000)
stim2_no_change_draw_times = NumPyRingBuffer(6000)