def _create_line_label(self, text, hint=False): # Create a label from a text, using line options ntext = text.replace(u'\n', u'').replace(u'\t', u' ' * self.tab_width) if self.password and not hint: # Don't replace hint_text with * ntext = u'*' * len(ntext) ntext = self._get_bbcode(ntext) kw = self._get_line_options() cid = u'{}\0{}\0{}'.format(ntext, self.password, kw) texture = Cache_get('textinput.label', cid) if texture is None: # FIXME right now, we can't render very long line... # if we move on "VBO" version as fallback, we won't need to # do this. # try to find the maximum text we can handle label = Label(text=ntext, **kw) if text.find(u'\n') > 0: label.text = u'' else: label.text = ntext label.refresh() # ok, we found it. texture = label.texture Cache_append('textinput.label', cid, texture) label.text = '' return texture
def _create_line_label(self, text): # Create a label from a text, using line options ntext = text.replace("\n", "").replace("\t", " " * self.tab_width) if self.password: ntext = "*" * len(ntext) ntext = self._get_bbcode(ntext) kw = self._get_line_options() cid = "%s\0%s" % (ntext, str(kw)) texture = Cache_get("textinput.label", cid) if not texture: # FIXME right now, we can't render very long line... # if we move on "VBO" version as fallback, we won't need to do this. # try to found the maximum text we can handle label = Label(text=ntext, **kw) if text.find("\n") > 0: label.text = "" else: label.text = ntext try: label.refresh() except ValueError: return # ok, we found it. texture = label.texture Cache_append("textinput.label", cid, texture) label.text = "" return texture
def _create_line_label(self, text): # Create a label from a text, using line options ntext = text.replace('\n', '').replace('\t', ' ' * self.tab_width) if self.password: ntext = '*' * len(ntext) ntext = self._get_bbcode(ntext) kw = self._get_line_options() cid = '%s\0%s' % (ntext, str(kw)) texture = Cache_get('textinput.label', cid) if not texture: # FIXME right now, we can't render very long line... # if we move on "VBO" version as fallback, we won't need to do this. # try to found the maximum text we can handle label = Label(text=ntext, **kw) if text.find('\n') > 0: label.text = '' else: label.text = ntext try: label.refresh() except ValueError: return # ok, we found it. texture = label.texture Cache_append('textinput.label', cid, texture) label.text = '' return texture
def _create_line_label(self, text, hint=False): # Create a label from a text, using line options ntext = text.replace('\n', '').replace('\t', ' ' * self.tab_width) if self.password and not hint: # Don't replace hint_text with * ntext = '*' * len(ntext) ntext = self._get_bbcode(ntext) kw = self._get_line_options() cid = '%s\0%s' % (ntext, str(kw)) texture = Cache_get('textinput.label', cid) if not texture: # FIXME right now, we can't render very long line... # if we move on "VBO" version as fallback, we won't need to do this. # try to found the maximum text we can handle label = Label(text=ntext, **kw) if text.find('\n') > 0: label.text = '' else: label.text = ntext try: label.refresh() except ValueError: return # ok, we found it. texture = label.texture Cache_append('textinput.label', cid, texture) label.text = '' return texture
def render(self): mylabel = CoreMarkupLabel(text=fa_icon(self.fa_name), font_size=self.fa_font_size, color=self.fa_icon_color) mylabel.refresh() texture = mylabel.texture texture_size = list(texture.size) self.canvas.add(Rectangle(texture=texture, size=texture_size))
def __init__(self, text, pos=(0, 0), color=(1, 1, 1), font_size=20, stretch=(1, 1), **text_kwargs): text = MarkupLabel(text=text, font_size=font_size, **text_kwargs) text.refresh() # Create rectangle object for the text new_size = (text.size[0] * stretch[0], text.size[1] * stretch[1]) rect = Rectangle(size=new_size, pos=pos, texture=text.texture) super(TextSprite, self).__init__(rect, color)