{"id":1048,"date":"2011-04-06T17:27:46","date_gmt":"2011-04-06T16:27:46","guid":{"rendered":"http:\/\/sahits.ch\/blog\/?p=1048"},"modified":"2011-04-06T17:27:46","modified_gmt":"2011-04-06T16:27:46","slug":"creating-custom-font-in-java","status":"publish","type":"post","link":"http:\/\/sahits.ch\/blog\/blog\/2011\/04\/06\/creating-custom-font-in-java\/","title":{"rendered":"Creating custom Font in Java"},"content":{"rendered":"<p>Creating a custom font from a TrueTypeFont file in Java is not that hard. However there are some pitfalls:<\/p>\n<ul>\n<li>The font size in in pt (Points) where a point is 1\/72 of an inch, that is for a normal person about 3.5mm.<\/li>\n<li>The created Font has an initial size of 1pt<\/li>\n<li>The font size is passed as Float but rounded to the nearest Integer<\/li>\n<li>Passing an Integer for the font size does not work (results in unchanged font size)<\/li>\n<\/ul>\n<pre>\r\npublic Font createDefaultFont(int size)throws FontFormatException, IOException{\r\n\tFont font = Font.createFont( Font.TRUETYPE_FONT, getClass().getResourceAsStream( \"\/\"+defaultFont) );\r\n        return font.deriveFont((float)size);\r\n}\r\n<\/pre>\n<p>Here <code>defaultFont<\/code> is the filename of the TrueType Font.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Creating a custom font from a TrueTypeFont file in Java is not that hard. However there are some pitfalls: The font size in in pt (Points) where a point is 1\/72 of an inch, that is for a normal person about 3.5mm. The created Font has an initial size of 1pt The font size is &hellip; <a href=\"http:\/\/sahits.ch\/blog\/blog\/2011\/04\/06\/creating-custom-font-in-java\/\" class=\"more-link\"><span class=\"screen-reader-text\">\u201eCreating custom Font in Java\u201c <\/span>weiterlesen<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[187,301],"class_list":["post-1048","post","type-post","status-publish","format-standard","hentry","category-java","tag-font","tag-java"],"_links":{"self":[{"href":"http:\/\/sahits.ch\/blog\/wp-json\/wp\/v2\/posts\/1048","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/sahits.ch\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/sahits.ch\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/sahits.ch\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/sahits.ch\/blog\/wp-json\/wp\/v2\/comments?post=1048"}],"version-history":[{"count":1,"href":"http:\/\/sahits.ch\/blog\/wp-json\/wp\/v2\/posts\/1048\/revisions"}],"predecessor-version":[{"id":1049,"href":"http:\/\/sahits.ch\/blog\/wp-json\/wp\/v2\/posts\/1048\/revisions\/1049"}],"wp:attachment":[{"href":"http:\/\/sahits.ch\/blog\/wp-json\/wp\/v2\/media?parent=1048"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/sahits.ch\/blog\/wp-json\/wp\/v2\/categories?post=1048"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/sahits.ch\/blog\/wp-json\/wp\/v2\/tags?post=1048"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}