{"action":"created","comment":{"url":"https://api.github.com/repos/mabe02/lanterna/pulls/comments/189456876","pull_request_review_id":121641696,"id":189456876,"diff_hunk":"@@ -70,61 +76,54 @@\n     )));\n \n     private static List<Font> getDefaultWindowsFonts() {\n+        int fontSize = getFontSize();\n         return Collections.unmodifiableList(Arrays.asList(\n-                new Font(\"Courier New\", Font.PLAIN, getFontSize()), //Monospaced can look pretty bad on Windows, so let's override it\n-                new Font(\"Monospaced\", Font.PLAIN, getFontSize())));\n+                new Font(\"Courier New\", Font.PLAIN, fontSize), //Monospaced can look pretty bad on Windows, so let's override it\n+                new Font(\"Monospaced\", Font.PLAIN, fontSize)));\n     }\n \n     private static List<Font> getDefaultLinuxFonts() {\n+        int fontSize = getFontSize();\n         return Collections.unmodifiableList(Arrays.asList(\n-                new Font(\"DejaVu Sans Mono\", Font.PLAIN, getFontSize()),\n-                new Font(\"Monospaced\", Font.PLAIN, getFontSize()),\n+                new Font(\"DejaVu Sans Mono\", Font.PLAIN, fontSize),\n+                new Font(\"Monospaced\", Font.PLAIN, fontSize),\n                 //Below, these should be redundant (Monospaced is supposed to catch-all)\n                 // but Java 6 seems to have issues with finding monospaced fonts sometimes\n-                new Font(\"Ubuntu Mono\", Font.PLAIN, getFontSize()),\n-                new Font(\"FreeMono\", Font.PLAIN, getFontSize()),\n-                new Font(\"Liberation Mono\", Font.PLAIN, getFontSize()),\n-                new Font(\"VL Gothic Regular\", Font.PLAIN, getFontSize()),\n-                new Font(\"NanumGothic\", Font.PLAIN, getFontSize()),\n-                new Font(\"WenQuanYi Zen Hei Mono\", Font.PLAIN, getFontSize()),\n-                new Font(\"WenQuanYi Zen Hei\", Font.PLAIN, getFontSize()),\n-                new Font(\"AR PL UMing TW\", Font.PLAIN, getFontSize()),\n-                new Font(\"AR PL UMing HK\", Font.PLAIN, getFontSize()),\n-                new Font(\"AR PL UMing CN\", Font.PLAIN, getFontSize())));\n+                new Font(\"Ubuntu Mono\", Font.PLAIN, fontSize),\n+                new Font(\"FreeMono\", Font.PLAIN, fontSize),\n+                new Font(\"Liberation Mono\", Font.PLAIN, fontSize),\n+                new Font(\"VL Gothic Regular\", Font.PLAIN, fontSize),\n+                new Font(\"NanumGothic\", Font.PLAIN, fontSize),\n+                new Font(\"WenQuanYi Zen Hei Mono\", Font.PLAIN, fontSize),\n+                new Font(\"WenQuanYi Zen Hei\", Font.PLAIN, fontSize),\n+                new Font(\"AR PL UMing TW\", Font.PLAIN, fontSize),\n+                new Font(\"AR PL UMing HK\", Font.PLAIN, fontSize),\n+                new Font(\"AR PL UMing CN\", Font.PLAIN, fontSize)));\n     }\n \n     private static List<Font> getDefaultFonts() {\n+        int fontSize = getFontSize();\n         return Collections.unmodifiableList(Collections.singletonList(\n-                new Font(\"Monospaced\", Font.PLAIN, getFontSize())));\n+                new Font(\"Monospaced\", Font.PLAIN, fontSize)));\n     }\n \n     // Here we check the screen resolution on the primary monitor and make a guess at if it's high-DPI or not\n-    private static Integer CHOSEN_FONT_SIZE = null;\n-    private synchronized static int getFontSize() {\n-        if(CHOSEN_FONT_SIZE != null) {\n-            return CHOSEN_FONT_SIZE;\n-        }\n-        // Source: http://stackoverflow.com/questions/3680221/how-can-i-get-the-monitor-size-in-java\n-        GraphicsEnvironment ge      = GraphicsEnvironment.getLocalGraphicsEnvironment();\n-        GraphicsDevice[]    gs      = ge.getScreenDevices();\n-\n-        // Assume the first GraphicsDevice is the primary screen (this isn't always correct but what to do?)\n-        // Warning, there could be printers coming back here according to JavaDoc! Hopefully Java is reasonable and\n-        // passes them in after the real monitor(s).\n-        if (gs.length > 0) {\n-            int primaryMonitorWidth = gs[0].getDisplayMode().getWidth();\n-\n-            // If the width is wider than Full HD (1080p, or 1920x1080), then assume it's high-DPI\n-            if (primaryMonitorWidth > 2000) {\n-                CHOSEN_FONT_SIZE = 28;\n+    private static int getFontSize() {\n+        if (Toolkit.getDefaultToolkit().getScreenResolution() >= 110) {\n+            // Rely on DPI if it is a high value.\n+            return Toolkit.getDefaultToolkit().getScreenResolution() / 7 + 1;\n+        } else {\n+            // Otherwise try to guess it from the monitor size:\n+            // If the width is wider than Full HD (1080p, or 1920x1080), then assume it's high-DPI.\n+            GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();\n+            if (ge.getMaximumWindowBounds().getWidth() > 4000) {","path":"src/main/java/com/googlecode/lanterna/terminal/swing/AWTTerminalFontConfiguration.java","position":101,"original_position":101,"commit_id":"a22cc18599ebc455418888650858a94d149abd0c","original_commit_id":"a22cc18599ebc455418888650858a94d149abd0c","user":{"login":"avl42","id":5255346,"avatar_url":"https://avatars0.githubusercontent.com/u/5255346?v=4","gravatar_id":"","url":"https://api.github.com/users/avl42","html_url":"https://github.com/avl42","followers_url":"https://api.github.com/users/avl42/followers","following_url":"https://api.github.com/users/avl42/following{/other_user}","gists_url":"https://api.github.com/users/avl42/gists{/gist_id}","starred_url":"https://api.github.com/users/avl42/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/avl42/subscriptions","organizations_url":"https://api.github.com/users/avl42/orgs","repos_url":"https://api.github.com/users/avl42/repos","events_url":"https://api.github.com/users/avl42/events{/privacy}","received_events_url":"https://api.github.com/users/avl42/received_events","type":"User","site_admin":false},"body":"Since we're not using screen-resolutions but MaximumWindowBounds, I think 4000 is an unfortunate value.  Someone with a 4096 monitor then might see different font-sizes in lanterna apps based on how wide his sidebar is. E.g.: 4096 with a 96 pixel wide sidebar will make a smaller font than with an even-slightly-more-than-96 pixel wide sidebar.\r\n\r\nIf there isn't a convenient \"the widest one of all the monitors\" method, I'd propose 3840 as a somewhat \"sweeter\" value.","created_at":"2018-05-20T11:03:11Z","updated_at":"2018-05-20T11:03:12Z","html_url":"https://github.com/mabe02/lanterna/pull/369#discussion_r189456876","pull_request_url":"https://api.github.com/repos/mabe02/lanterna/pulls/369","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/mabe02/lanterna/pulls/comments/189456876"},"html":{"href":"https://github.com/mabe02/lanterna/pull/369#discussion_r189456876"},"pull_request":{"href":"https://api.github.com/repos/mabe02/lanterna/pulls/369"}}},"pull_request":{"url":"https://api.github.com/repos/mabe02/lanterna/pulls/369","id":189227369,"html_url":"https://github.com/mabe02/lanterna/pull/369","diff_url":"https://github.com/mabe02/lanterna/pull/369.diff","patch_url":"https://github.com/mabe02/lanterna/pull/369.patch","issue_url":"https://api.github.com/repos/mabe02/lanterna/issues/369","number":369,"state":"open","locked":false,"title":"Rework high-DPI detection to work in multi-monitor setups on linux (#351)","user":{"login":"jrb0001","id":2380263,"avatar_url":"https://avatars1.githubusercontent.com/u/2380263?v=4","gravatar_id":"","url":"https://api.github.com/users/jrb0001","html_url":"https://github.com/jrb0001","followers_url":"https://api.github.com/users/jrb0001/followers","following_url":"https://api.github.com/users/jrb0001/following{/other_user}","gists_url":"https://api.github.com/users/jrb0001/gists{/gist_id}","starred_url":"https://api.github.com/users/jrb0001/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jrb0001/subscriptions","organizations_url":"https://api.github.com/users/jrb0001/orgs","repos_url":"https://api.github.com/users/jrb0001/repos","events_url":"https://api.github.com/users/jrb0001/events{/privacy}","received_events_url":"https://api.github.com/users/jrb0001/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-05-20T10:08:16Z","updated_at":"2018-05-20T11:03:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"97f30351ddd11111d75d2f9ea39b8c567d2b0655","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/mabe02/lanterna/pulls/369/commits","review_comments_url":"https://api.github.com/repos/mabe02/lanterna/pulls/369/comments","review_comment_url":"https://api.github.com/repos/mabe02/lanterna/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mabe02/lanterna/issues/369/comments","statuses_url":"https://api.github.com/repos/mabe02/lanterna/statuses/a22cc18599ebc455418888650858a94d149abd0c","head":{"label":"jrb0001:hdpi","ref":"hdpi","sha":"a22cc18599ebc455418888650858a94d149abd0c","user":{"login":"jrb0001","id":2380263,"avatar_url":"https://avatars1.githubusercontent.com/u/2380263?v=4","gravatar_id":"","url":"https://api.github.com/users/jrb0001","html_url":"https://github.com/jrb0001","followers_url":"https://api.github.com/users/jrb0001/followers","following_url":"https://api.github.com/users/jrb0001/following{/other_user}","gists_url":"https://api.github.com/users/jrb0001/gists{/gist_id}","starred_url":"https://api.github.com/users/jrb0001/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jrb0001/subscriptions","organizations_url":"https://api.github.com/users/jrb0001/orgs","repos_url":"https://api.github.com/users/jrb0001/repos","events_url":"https://api.github.com/users/jrb0001/events{/privacy}","received_events_url":"https://api.github.com/users/jrb0001/received_events","type":"User","site_admin":false},"repo":{"id":134139283,"name":"lanterna","full_name":"jrb0001/lanterna","owner":{"login":"jrb0001","id":2380263,"avatar_url":"https://avatars1.githubusercontent.com/u/2380263?v=4","gravatar_id":"","url":"https://api.github.com/users/jrb0001","html_url":"https://github.com/jrb0001","followers_url":"https://api.github.com/users/jrb0001/followers","following_url":"https://api.github.com/users/jrb0001/following{/other_user}","gists_url":"https://api.github.com/users/jrb0001/gists{/gist_id}","starred_url":"https://api.github.com/users/jrb0001/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jrb0001/subscriptions","organizations_url":"https://api.github.com/users/jrb0001/orgs","repos_url":"https://api.github.com/users/jrb0001/repos","events_url":"https://api.github.com/users/jrb0001/events{/privacy}","received_events_url":"https://api.github.com/users/jrb0001/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jrb0001/lanterna","description":"Java library for creating text-based GUIs","fork":true,"url":"https://api.github.com/repos/jrb0001/lanterna","forks_url":"https://api.github.com/repos/jrb0001/lanterna/forks","keys_url":"https://api.github.com/repos/jrb0001/lanterna/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jrb0001/lanterna/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jrb0001/lanterna/teams","hooks_url":"https://api.github.com/repos/jrb0001/lanterna/hooks","issue_events_url":"https://api.github.com/repos/jrb0001/lanterna/issues/events{/number}","events_url":"https://api.github.com/repos/jrb0001/lanterna/events","assignees_url":"https://api.github.com/repos/jrb0001/lanterna/assignees{/user}","branches_url":"https://api.github.com/repos/jrb0001/lanterna/branches{/branch}","tags_url":"https://api.github.com/repos/jrb0001/lanterna/tags","blobs_url":"https://api.github.com/repos/jrb0001/lanterna/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jrb0001/lanterna/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jrb0001/lanterna/git/refs{/sha}","trees_url":"https://api.github.com/repos/jrb0001/lanterna/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jrb0001/lanterna/statuses/{sha}","languages_url":"https://api.github.com/repos/jrb0001/lanterna/languages","stargazers_url":"https://api.github.com/repos/jrb0001/lanterna/stargazers","contributors_url":"https://api.github.com/repos/jrb0001/lanterna/contributors","subscribers_url":"https://api.github.com/repos/jrb0001/lanterna/subscribers","subscription_url":"https://api.github.com/repos/jrb0001/lanterna/subscription","commits_url":"https://api.github.com/repos/jrb0001/lanterna/commits{/sha}","git_commits_url":"https://api.github.com/repos/jrb0001/lanterna/git/commits{/sha}","comments_url":"https://api.github.com/repos/jrb0001/lanterna/comments{/number}","issue_comment_url":"https://api.github.com/repos/jrb0001/lanterna/issues/comments{/number}","contents_url":"https://api.github.com/repos/jrb0001/lanterna/contents/{+path}","compare_url":"https://api.github.com/repos/jrb0001/lanterna/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jrb0001/lanterna/merges","archive_url":"https://api.github.com/repos/jrb0001/lanterna/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jrb0001/lanterna/downloads","issues_url":"https://api.github.com/repos/jrb0001/lanterna/issues{/number}","pulls_url":"https://api.github.com/repos/jrb0001/lanterna/pulls{/number}","milestones_url":"https://api.github.com/repos/jrb0001/lanterna/milestones{/number}","notifications_url":"https://api.github.com/repos/jrb0001/lanterna/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jrb0001/lanterna/labels{/name}","releases_url":"https://api.github.com/repos/jrb0001/lanterna/releases{/id}","deployments_url":"https://api.github.com/repos/jrb0001/lanterna/deployments","created_at":"2018-05-20T10:03:49Z","updated_at":"2018-05-20T10:05:21Z","pushed_at":"2018-05-20T10:14:52Z","git_url":"git://github.com/jrb0001/lanterna.git","ssh_url":"git@github.com:jrb0001/lanterna.git","clone_url":"https://github.com/jrb0001/lanterna.git","svn_url":"https://github.com/jrb0001/lanterna","homepage":"","size":8283,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"lgpl-3.0","name":"GNU Lesser General Public License v3.0","spdx_id":"LGPL-3.0","url":"https://api.github.com/licenses/lgpl-3.0"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mabe02:master","ref":"master","sha":"1c36b78921db00c2fc9463d53757f9753ede67b9","user":{"login":"mabe02","id":10136489,"avatar_url":"https://avatars0.githubusercontent.com/u/10136489?v=4","gravatar_id":"","url":"https://api.github.com/users/mabe02","html_url":"https://github.com/mabe02","followers_url":"https://api.github.com/users/mabe02/followers","following_url":"https://api.github.com/users/mabe02/following{/other_user}","gists_url":"https://api.github.com/users/mabe02/gists{/gist_id}","starred_url":"https://api.github.com/users/mabe02/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mabe02/subscriptions","organizations_url":"https://api.github.com/users/mabe02/orgs","repos_url":"https://api.github.com/users/mabe02/repos","events_url":"https://api.github.com/users/mabe02/events{/privacy}","received_events_url":"https://api.github.com/users/mabe02/received_events","type":"User","site_admin":false},"repo":{"id":38230607,"name":"lanterna","full_name":"mabe02/lanterna","owner":{"login":"mabe02","id":10136489,"avatar_url":"https://avatars0.githubusercontent.com/u/10136489?v=4","gravatar_id":"","url":"https://api.github.com/users/mabe02","html_url":"https://github.com/mabe02","followers_url":"https://api.github.com/users/mabe02/followers","following_url":"https://api.github.com/users/mabe02/following{/other_user}","gists_url":"https://api.github.com/users/mabe02/gists{/gist_id}","starred_url":"https://api.github.com/users/mabe02/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mabe02/subscriptions","organizations_url":"https://api.github.com/users/mabe02/orgs","repos_url":"https://api.github.com/users/mabe02/repos","events_url":"https://api.github.com/users/mabe02/events{/privacy}","received_events_url":"https://api.github.com/users/mabe02/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mabe02/lanterna","description":"Java library for creating text-based GUIs","fork":false,"url":"https://api.github.com/repos/mabe02/lanterna","forks_url":"https://api.github.com/repos/mabe02/lanterna/forks","keys_url":"https://api.github.com/repos/mabe02/lanterna/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mabe02/lanterna/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mabe02/lanterna/teams","hooks_url":"https://api.github.com/repos/mabe02/lanterna/hooks","issue_events_url":"https://api.github.com/repos/mabe02/lanterna/issues/events{/number}","events_url":"https://api.github.com/repos/mabe02/lanterna/events","assignees_url":"https://api.github.com/repos/mabe02/lanterna/assignees{/user}","branches_url":"https://api.github.com/repos/mabe02/lanterna/branches{/branch}","tags_url":"https://api.github.com/repos/mabe02/lanterna/tags","blobs_url":"https://api.github.com/repos/mabe02/lanterna/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mabe02/lanterna/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mabe02/lanterna/git/refs{/sha}","trees_url":"https://api.github.com/repos/mabe02/lanterna/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mabe02/lanterna/statuses/{sha}","languages_url":"https://api.github.com/repos/mabe02/lanterna/languages","stargazers_url":"https://api.github.com/repos/mabe02/lanterna/stargazers","contributors_url":"https://api.github.com/repos/mabe02/lanterna/contributors","subscribers_url":"https://api.github.com/repos/mabe02/lanterna/subscribers","subscription_url":"https://api.github.com/repos/mabe02/lanterna/subscription","commits_url":"https://api.github.com/repos/mabe02/lanterna/commits{/sha}","git_commits_url":"https://api.github.com/repos/mabe02/lanterna/git/commits{/sha}","comments_url":"https://api.github.com/repos/mabe02/lanterna/comments{/number}","issue_comment_url":"https://api.github.com/repos/mabe02/lanterna/issues/comments{/number}","contents_url":"https://api.github.com/repos/mabe02/lanterna/contents/{+path}","compare_url":"https://api.github.com/repos/mabe02/lanterna/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mabe02/lanterna/merges","archive_url":"https://api.github.com/repos/mabe02/lanterna/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mabe02/lanterna/downloads","issues_url":"https://api.github.com/repos/mabe02/lanterna/issues{/number}","pulls_url":"https://api.github.com/repos/mabe02/lanterna/pulls{/number}","milestones_url":"https://api.github.com/repos/mabe02/lanterna/milestones{/number}","notifications_url":"https://api.github.com/repos/mabe02/lanterna/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mabe02/lanterna/labels{/name}","releases_url":"https://api.github.com/repos/mabe02/lanterna/releases{/id}","deployments_url":"https://api.github.com/repos/mabe02/lanterna/deployments","created_at":"2015-06-29T06:06:29Z","updated_at":"2018-05-20T09:02:19Z","pushed_at":"2018-05-20T10:14:53Z","git_url":"git://github.com/mabe02/lanterna.git","ssh_url":"git@github.com:mabe02/lanterna.git","clone_url":"https://github.com/mabe02/lanterna.git","svn_url":"https://github.com/mabe02/lanterna","homepage":"","size":8283,"stargazers_count":888,"watchers_count":888,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":false,"has_wiki":false,"has_pages":true,"forks_count":117,"mirror_url":null,"archived":false,"open_issues_count":30,"license":{"key":"lgpl-3.0","name":"GNU Lesser General Public License v3.0","spdx_id":"LGPL-3.0","url":"https://api.github.com/licenses/lgpl-3.0"},"forks":117,"open_issues":30,"watchers":888,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mabe02/lanterna/pulls/369"},"html":{"href":"https://github.com/mabe02/lanterna/pull/369"},"issue":{"href":"https://api.github.com/repos/mabe02/lanterna/issues/369"},"comments":{"href":"https://api.github.com/repos/mabe02/lanterna/issues/369/comments"},"review_comments":{"href":"https://api.github.com/repos/mabe02/lanterna/pulls/369/comments"},"review_comment":{"href":"https://api.github.com/repos/mabe02/lanterna/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mabe02/lanterna/pulls/369/commits"},"statuses":{"href":"https://api.github.com/repos/mabe02/lanterna/statuses/a22cc18599ebc455418888650858a94d149abd0c"}},"author_association":"NONE"}}
{"actor":{"display_login":"avl42"}}