From 36e45c198a09de843889b01a65e6ffe2fc9f286f Mon Sep 17 00:00:00 2001 From: Mathieu Virbel Date: Thu, 1 Nov 2012 04:05:25 +0100 Subject: [PATCH] label: removed px hack for font_size + updated the font_size to 13dp (instead of 10). --- kivy/core/text/markup.py | 2 +- kivy/uix/label.py | 14 ++++---------- kivy/uix/textinput.py | 10 ++-------- 3 files changed, 7 insertions(+), 19 deletions(-) diff --git a/kivy/core/text/markup.py b/kivy/core/text/markup.py index 3e9cc2199..6424ff947 100644 --- a/kivy/core/text/markup.py +++ b/kivy/core/text/markup.py @@ -140,7 +140,7 @@ class MarkupLabel(MarkupLabelBase): elif item[:6] == '[size=': item = item[6:-1] try: - if item[-2:] in ('px', 'pt', 'in', 'cm', 'mm'): + if item[-2:] in ('px', 'pt', 'in', 'cm', 'mm', 'dp'): size = dpi2px(item[:-2], item[-2:]) else: size = int(item) diff --git a/kivy/uix/label.py b/kivy/uix/label.py index 64c2aac52..3836592f8 100644 --- a/kivy/uix/label.py +++ b/kivy/uix/label.py @@ -15,7 +15,7 @@ strings:: l = Label(text='Multi\\nLine') # size - l = Label(text='Hello world', font_size=20) + l = Label(text='Hello world', font_size='20dp') Markup text ----------- @@ -148,9 +148,6 @@ class Label(Widget): # markup have change, we need to change our rendering method. d = Label._font_properties dkw = dict(zip(d, [getattr(self, x) for x in d])) - # XXX font_size core provider compatibility - if Label.font_size.get_format(self) == 'px': - dkw['font_size'] *= 1.333 if markup: self._label = CoreMarkupLabel(**dkw) else: @@ -166,9 +163,6 @@ class Label(Widget): elif name == 'text_size': self._label.usersize = value elif name == 'font_size': - # XXX font_size core provider compatibility - if Label.font_size.get_format(self) == 'px': - value *= 1.333 self._label.options[name] = value else: self._label.options[name] = value @@ -274,11 +268,11 @@ class Label(Widget): 'DroidSans'. ''' - font_size = NumericProperty('12px') + font_size = NumericProperty('14dp') '''Font size of the text, in pixels. :data:`font_size` is a :class:`~kivy.properties.NumericProperty`, default to - 12. + 12dp. ''' bold = BooleanProperty(False) @@ -379,7 +373,7 @@ class Label(Widget): l = Label(text='Hello world') # l.texture is good - l.font_size = 50 + l.font_size = '50dp' # l.texture is not updated yet l.update_texture() # l.texture is good now. diff --git a/kivy/uix/textinput.py b/kivy/uix/textinput.py index ce1c8b7be..cd01e941d 100644 --- a/kivy/uix/textinput.py +++ b/kivy/uix/textinput.py @@ -1171,15 +1171,9 @@ class TextInput(Widget): def _get_line_options(self): # Get or create line options, to be used for Label creation - - # XXX font_size core label compatibility - factor = 1. - if TextInput.font_size.get_format(self) == 'px': - factor = 1.333 - if self._line_options is None: self._line_options = kw = { - 'font_size': self.font_size * factor, + 'font_size': self.font_size, 'font_name': self.font_name, 'anchor_x': 'left', 'anchor_y': 'top', @@ -1714,7 +1708,7 @@ class TextInput(Widget): 'DroidSans'. ''' - font_size = NumericProperty(10) + font_size = NumericProperty('13dp') '''Font size of the text, in pixels. :data:`font_size` is a :class:`~kivy.properties.NumericProperty`, default to