def get_dpi(self, force_recompute=False): if not force_recompute and self._dpi is not None: return self._dpi if platform == 'android': if USE_SDL2: import jnius Hardware = jnius.autoclass('org.renpy.android.Hardware') value = Hardware.getDPI() else: import android value = android.get_dpi() elif platform == 'ios': import ios value = ios.get_dpi() else: # for all other platforms.. from kivy.base import EventLoop EventLoop.ensure_window() value = EventLoop.window.dpi # because dp prop binds to dpi etc. its getter will be executed # before dispatch_pixel_scale bound to dpi was called, so we need to # call this to make sure it's updated sync_pixel_scale(dpi=value) return value
def dpi(self): '''Return the DPI of the screen. Depending on the platform, the DPI can be taken from the Window provider (Desktop mainly) or from a platform-specific module (like android/ios). ''' custom_dpi = environ.get('KIVY_DPI') if custom_dpi: return float(custom_dpi) if platform == 'android': if USE_SDL2: import jnius Hardware = jnius.autoclass('org.renpy.android.Hardware') return Hardware.getDPI() else: import android return android.get_dpi() elif platform == 'ios': import ios return ios.get_dpi() # for all other platforms.. from kivy.base import EventLoop EventLoop.ensure_window() return EventLoop.window.dpi
def dpi(self): '''Return the DPI of the screen. Depending of the platform, the DPI can be taken from the Window provider (Desktop mainly), or from platform-specific module (like android/ios). ''' custom_dpi = environ.get('KIVY_DPI') if custom_dpi: return float(custom_dpi) if platform() == 'android': import android return android.get_dpi() elif platform() == 'ios': import ios return ios.get_dpi() # for all other platforms.. from kivy.base import EventLoop EventLoop.ensure_window() return EventLoop.window.dpi