mirror of https://github.com/kivy/kivy.git
Merge branch 'master' of ssh://github.com/kivy/kivy
This commit is contained in:
commit
97e4555ff0
|
@ -0,0 +1,19 @@
|
|||
from kivy.app import App
|
||||
from kivy.lang import Builder
|
||||
|
||||
root = Builder.load_string('''
|
||||
Label:
|
||||
text:
|
||||
('[b]Hello[/b] [color=ff0099]World[/color]\\n'
|
||||
'[color=ff0099]Hello[/color] [b]World[/b]\\n'
|
||||
'[b]Hello[/b] [color=ff0099]World[/color]')
|
||||
markup: True
|
||||
font_size: '64pt'
|
||||
''')
|
||||
|
||||
class LabelWithMarkup(App):
|
||||
def build(self):
|
||||
return root
|
||||
|
||||
if __name__ == '__main__':
|
||||
LabelWithMarkup().run()
|
|
@ -217,14 +217,15 @@ class MarkupLabel(MarkupLabelBase):
|
|||
uw, uh = self.text_size
|
||||
|
||||
# split the word
|
||||
default_line_height = get_extents(' ')[1]
|
||||
for part in re.split(r'( |\n)', word):
|
||||
|
||||
if part == '':
|
||||
part = ' '
|
||||
continue
|
||||
|
||||
if part == '\n':
|
||||
# put a new line!
|
||||
line = [0, 0, []]
|
||||
line = [0, default_line_height, []]
|
||||
lines.append(line)
|
||||
continue
|
||||
|
||||
|
@ -310,26 +311,18 @@ class MarkupLabel(MarkupLabelBase):
|
|||
# create texture is necessary
|
||||
texture = self.texture
|
||||
mipmap = self.options['mipmap']
|
||||
if texture is None:
|
||||
if data is None:
|
||||
if platform() in ('android', 'ios'):
|
||||
colorfmt = 'rgba'
|
||||
else:
|
||||
colorfmt = 'luminance_alpha'
|
||||
texture = Texture.create(
|
||||
size=self.size, colorfmt=colorfmt,
|
||||
mipmap=mipmap)
|
||||
else:
|
||||
texture = Texture.create_from_data(data, mipmap=mipmap)
|
||||
texture.flip_vertical()
|
||||
elif self.width != texture.width or self.height != texture.height:
|
||||
if data is None:
|
||||
texture = Texture.create(size=self.size, mipmap=mipmap)
|
||||
else:
|
||||
texture = Texture.create_from_data(data, mipmap=mipmap)
|
||||
if texture is None or \
|
||||
self.width != texture.width or \
|
||||
self.height != texture.height:
|
||||
texture = Texture.create_from_data(data, mipmap=mipmap)
|
||||
data = None
|
||||
texture.flip_vertical()
|
||||
texture.add_reload_observer(self._texture_refresh)
|
||||
self.texture = texture
|
||||
|
||||
# update texture
|
||||
self.texture = texture
|
||||
self.texture.blit_data(data)
|
||||
# If the text is 1px width, usually, the data is black.
|
||||
# Don't blit that kind of data, otherwise, you have a little black bar.
|
||||
if data is not None and data.width > 1:
|
||||
texture.blit_data(data)
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
cdef class Property:
|
||||
cdef str _name
|
||||
cdef int allownone
|
||||
cdef object defaultvalue
|
||||
cdef public object defaultvalue
|
||||
cdef init_storage(self, object obj, dict storage)
|
||||
cpdef link(self, object obj, str name)
|
||||
cpdef link_deps(self, object obj, str name)
|
||||
|
|
Loading…
Reference in New Issue