Get screen DPI from the OS

    Parameters
    ----------
    raise_error : bool
        If True, raise an error if DPI could not be determined.

    Returns
    -------
    dpi : float
        Dots per inch of the primary screen.
351965
def get_dpi(raise_error=True):
    
    try:
        user32.SetProcessDPIAware()
    except AttributeError:
        pass  # not present on XP
    dc = user32.GetDC(0)
    h_size = gdi32.GetDeviceCaps(dc, HORZSIZE)
    v_size = gdi32.GetDeviceCaps(dc, VERTSIZE)
    h_res = gdi32.GetDeviceCaps(dc, HORZRES)
    v_res = gdi32.GetDeviceCaps(dc, VERTRES)
    user32.ReleaseDC(None, dc)
    return (h_res/float(h_size) + v_res/float(v_size)) * 0.5 * 25.4
535967
def size_from_readline
      if defined?(Readline) && Readline.respond_to?(:get_screen_size)
        size = Readline.get_screen_size
        size if nonzero_column?(size[1])
      end
    rescue NotImplementedError
    end
256626
def get_console_width():
    

    if os.name == 'nt':
        STD_INPUT_HANDLE = -10
        STD_OUTPUT_HANDLE = -11
        STD_ERROR_HANDLE = -12

        # get console handle
        from ctypes import windll, Structure, byref
        try:
            from ctypes.wintypes import SHORT, WORD, DWORD
        except ImportError:
            # workaround for missing types in Python 2.5
            from ctypes import (
                c_short as SHORT, c_ushort as WORD, c_ulong as DWORD)
        console_handle = windll.kernel32.GetStdHandle(STD_OUTPUT_HANDLE)

        # CONSOLE_SCREEN_BUFFER_INFO Structure
        class COORD(Structure):
            _fields_ = [("X", SHORT), ("Y", SHORT)]

        class SMALL_RECT(Structure):
            _fields_ = [("Left", SHORT), ("Top", SHORT),
                        ("Right", SHORT), ("Bottom", SHORT)]

        class CONSOLE_SCREEN_BUFFER_INFO(Structure):
            _fields_ = [("dwSize", COORD),
                        ("dwCursorPosition", COORD),
                        ("wAttributes", WORD),
                        ("srWindow", SMALL_RECT),
                        ("dwMaximumWindowSize", DWORD)]

        sbi = CONSOLE_SCREEN_BUFFER_INFO()
        ret = windll.kernel32.GetConsoleScreenBufferInfo(
            console_handle, byref(sbi))
        if ret == 0:
            return 0
        return sbi.srWindow.Right + 1

    elif os.name == 'posix':
        from fcntl import ioctl
        from termios import TIOCGWINSZ
        from array import array

        winsize = array("H", [0] * 4)
        try:
            ioctl(sys.stdout.fileno(), TIOCGWINSZ, winsize)
        except IOError:
            pass
        return (winsize[1], winsize[0])[0]

    return 80
875360
def get_monitor_physical_size(monitor):
    
    width_value = ctypes.c_int(0)
    width = ctypes.pointer(width_value)
    height_value = ctypes.c_int(0)
    height = ctypes.pointer(height_value)
    _glfw.glfwGetMonitorPhysicalSize(monitor, width, height)
    return width_value.value, height_value.value
1133073
public static int getPixelFromDp(Context context, int dp) {
		// Get the screen's density scale		
		float scale = context.getResources().getDisplayMetrics().density;

		// Convert the dps to pixels, based on density scale
		// because dp*scale is cast as an integer value, this will cause the result to be truncated.
		// Therefore, Adding ROUND_FACTOR helps the result to have properly rounded integer value.
		return (int)(dp * scale + ROUND_FACTOR);
	}
1081573
def get_size(self):
        """"""
        self.curses.setupterm()
        return self.curses.tigetnum('cols'), self.curses.tigetnum('lines')
1355995
def get_region_size(region):
        
        if region is None:
            return 180.
        tokens = parse_hpxregion(region)
        if tokens[0] in ['DISK', 'DISK_INC']:
            return float(tokens[3])
        elif tokens[0] == 'HPX_PIXEL':
            pixel_size = get_pixel_size_from_nside(int(tokens[2]))
            return 2. * pixel_size
        else:
            raise Exception(
                "HPX.get_region_size did not recognize region type %s" % tokens[0])
        return None
742757
def get_device_scale(self):
        
        size = ffi.new('double[2]')
        cairo.cairo_surface_get_device_scale(self._pointer, size + 0, size + 1)
        return tuple(size)
64651
private static int getFontSize() {
        if (Toolkit.getDefaultToolkit().getScreenResolution() >= 110) {
            // Rely on DPI if it is a high value.
            return Toolkit.getDefaultToolkit().getScreenResolution() / 7 + 1;
        } else {
            // Otherwise try to guess it from the monitor size:
            // If the width is wider than Full HD (1080p, or 1920x1080), then assume it's high-DPI.
            GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
            if (ge.getMaximumWindowBounds().getWidth() > 4096) {
                return 56;
            } else if (ge.getMaximumWindowBounds().getWidth() > 2048) {
                return 28;
            } else {
                return 14;
            }
        }
    }
208773
def getPixelValue(self, x, y):
        """"""
        assert x < self.size, "x: %d<%d" % (x, self.size)
        assert y < self.size, "y: %d<%d" % (y, self.size)
        # Same as calcOffset, inlined for performance reasons
        offset = x + self.size * (self.size - y - 1)
        #print offset
        value = self.data[offset]
        if value == -32768:
            return -1 # -32768 is a special value for areas with no data
        return value
1093061
def _get_size(self):
        
        if self._chan is None:
            return Size(rows=20, columns=79)
        else:
            width, height, pixwidth, pixheight = self._chan.get_terminal_size()
            return Size(rows=height, columns=width)
948595
def get_mouse_location(self):
        
        x = ctypes.c_int(0)
        y = ctypes.c_int(0)
        screen_num = ctypes.c_int(0)
        _libxdo.xdo_get_mouse_location(
            self._xdo, ctypes.byref(x), ctypes.byref(y),
            ctypes.byref(screen_num))
        return mouse_location(x.value, y.value, screen_num.value)
118489
function calc_screen_size(scount) {
    if (!scount) { scount = $("#screens .screen").length; }
    var ssize = (($(window).height() - bottom_height - 20) / scount)
      - (bar_height + 53);
    return ssize;
  }
73583
def _height_and_width(self):
        

        # In Python 3.3+ we can let the standard library handle this
        if GTS_SUPPORTED:
            return os.get_terminal_size(self.stream_fd)

        window = get_csbi(self.stream_fh).srWindow
        return TerminalSize(window.Right - window.Left + 1, window.Bottom - window.Top + 1)
264991
def console_get_height(con: tcod.console.Console) -> int:
    
    return int(lib.TCOD_console_get_height(_console(con)))
819443
def _convert_to_scale(self):
        
        d = self._d
        s = (self._s - self._offset) % 86400.
        d -= int((s + self._offset) // 86400)
        return d, s
784022
def dpi(self):
        
        if self._dpi is None:
            if self._canvas is None:
                return None
            else:
                return self.canvas.dpi
        else:
            return self._dpi