<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>GetSnappy.com Technology Blog</title>
	<atom:link href="http://www.getsnappy.com/tech-blog/freebsd-tips-tricks/freebsd-openjdk6-b17-font-issues/wp-feed.php" rel="self" type="application/rss+xml" />
	<link>http://www.getsnappy.com/tech-blog</link>
	<description>Tips &#38; Techniques We&#039;ve Learned From Practice</description>
	<lastBuildDate>Fri, 06 Nov 2009 17:04:25 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>FreeBSD OpenJDK6-b17 font issues</title>
		<link>http://www.getsnappy.com/tech-blog/freebsd-tips-tricks/freebsd-openjdk6-b17-font-issues/</link>
		<comments>http://www.getsnappy.com/tech-blog/freebsd-tips-tricks/freebsd-openjdk6-b17-font-issues/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 17:39:18 +0000</pubDate>
		<dc:creator>brian</dc:creator>
				<category><![CDATA[FreeBSD Tips & Tricks]]></category>

		<guid isPermaLink="false">http://www.getsnappy.com/tech-blog/?p=52</guid>
		<description><![CDATA[Quite simply.  Fonts look terrible when using openjdk6 on FreeBSD.  I&#8217;ve been spending quite a bit of time researching and fixing this issue.
This is a simple test program I put together for comparing fonts.
    import java.awt.*;
    import javax.swing.*;

    public class BasicDraw {
   [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.getsnappy.com%2Ftech-blog%2Ffreebsd-tips-tricks%2Ffreebsd-openjdk6-b17-font-issues%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.getsnappy.com%2Ftech-blog%2Ffreebsd-tips-tricks%2Ffreebsd-openjdk6-b17-font-issues%2F" height="61" width="51" /></a></div><p>Quite simply.  Fonts look terrible when using openjdk6 on FreeBSD.  I&#8217;ve been spending quite a bit of time researching and fixing this issue.</p>
<p>This is a simple test program I put together for comparing fonts.</p>
<pre><tt>    import java.awt.*;
    import javax.swing.*;

    public class BasicDraw {
        public static void main(String[] args) {
            new BasicDraw();
        }
        BasicDraw() {
            // Create a frame
            JFrame frame = new JFrame();

            // Add a component with a custom paint method
            frame.getContentPane().add(new MyComponent());

            // Display the frame
            int frameWidth = 300;
            int frameHeight = 300;
            frame.setSize(frameWidth, frameHeight);
            frame.setVisible(true);
        }

        class MyComponent extends JComponent {
            // This method is called whenever the contents needs to be painted
            public void paint(Graphics g) {
                // Retrieve the graphics context; this object is used to paint shapes
                Graphics2D g2d = (Graphics2D)g;

                // Draw an oval that fills the window
                int x = 0;
                int y = 0;
                int width = getSize().width-1;
                int height = getSize().height-1;
                g2d.drawOval(x, y, width, height);

                // Set the desired font if different from default font

                String family = "Serif";
                int style = Font.PLAIN;
                int size = 12;
                Font font = new Font(family, style, size);
                g.setFont(font);

                // Draw a string such that its base line is at x, y
                x = 10;
                y = 10;
                g.drawString("aString", x, y);

                // Draw a string such that the top-left corner is at x, y
                x = 10;
                y = 30;
                FontMetrics fontMetrics = g.getFontMetrics();
                g.drawString("bString", x, y+fontMetrics.getAscent());
            }
        }

    }
</tt></pre>
<p>When comparing the results of Openjdk6-b17 vs diablo-jdk-1.6.0.07.02_6, you&#8217;ll see a noticeable difference in the fonts being used.  Openjdk6 looks terrible.  </p>
<p>Here is another executable class that lists all available fonts on a machine: </p>
<pre><tt>import java.awt.GraphicsEnvironment;

public class AvailableFonts
{

	/**
	 * @param args
	 */
	public static void main(String[] args) {
	    GraphicsEnvironment gEnv = GraphicsEnvironment
        	.getLocalGraphicsEnvironment();
		String envfonts[] = gEnv.getAvailableFontFamilyNames();

		for (String font: envfonts) {
			System.err.println(font);
		}
	}

}
</tt></pre>
<p>When comparing the output between openjdk and diablo-jdk,  the only difference were these three lines in the diablo-jdk output:</p>
<pre><tt>Lucida Bright
Lucida Sans
Lucida Sans Typewriter
</tt></pre>
<p>These fonts turned out to be .ttf font files located at /usr/local/diablo-jdk16/jre/lib/fonts/.</p>
<p>I performed the following command to link them inside openjdk6</p>
<pre><tt>ln -s /usr/local/diablo-jdk16/jre/lib/fonts/ /usr/local/openjdk6/jre/lib/fonts/
</tt></pre>
<p>Now the AvailableFonts class returns identical results, however BasicDraw, doesn&#8217;t appear to render the text all together.  Trying to run netbeans or eclipse, or any GUI/swing app for that matter causes even more unusual results.  It looks as if the fonts are being drawn with a width of 0, and height 10 times their normal size.</p>
<p>I imported a couple of patches for bugs 6761856 and 6817112 from the jdk7 branch, to try and resolve this unusual behavior with no luck.  I then started playing with fontconfig.properties, in hopes of resolving the font issues there.  It looked like it wanted to use DejaVU LGC fonts as the primary for latin-1.  I used the port x11-fonts/dejavu which contains the non LGC fonts since there DejaVU LGC fonts don&#8217;t appear to have a port yet.  After installing the fonts and updating fontconfig.properties I re-ran my BasicDraw test class&#8230; and SUCCESS!  Font&#8217;s looked equivalent to those in diablo-jdk and the best part is I don&#8217;t have to worry about licensing issues with Sun&#8217;s Lucida fonts.</p>
<p>I&#8217;ve added the following to the ports/java/openjdk6 Makefile:</p>
<pre><tt>RUN_DEPENDS+=	dejavu:${PORTSDIR}/x11-fonts/dejavu
</tt></pre>
<p>I&#8217;d like to offer a better out-of-the-box installation to our japanese,chinese, and korean audience, but I&#8217;m not sure what the best way to do this is.  So far this is what I&#8217;ve come up with as the ideal fonts for each locality:</p>
<pre><tt>korean = korean/unfonts-ttf
chinese = chinese/mingunittf
japanese = japanese/font-sazanami
</tt></pre>
<p>I&#8217;ve updated the fontconfig.properties to reflect these fonts and their installed locations, however I&#8217;m not sure I&#8217;ve chosen the right fonts.  Furthermore I&#8217;d like out-of-box font dependencies to be resolved based on the LOCALE of the machine.  I haven&#8217;t found any examples of doing this, and I can only assume their is a reason for it.  Perhaps the right thing to do is require all fonts for all languages regardless of the LOCALE? </p>
<p>My work so far has been included in pre release 2 and, you can grab the latest preliminary port from this blog:<br />
<a href="http://www.getsnappy.com/tech-blog/freebsd-tips-tricks/upgrading-freebsd-port-java-openjdk6-from-b16-to-b17/">http://www.getsnappy.com/tech-blog/freebsd-tips-tricks/upgrading-freebsd-port-java-openjdk6-from-b16-to-b17/</a></p>
<p>Any feedback good or bad, is appreciated.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.getsnappy.com/tech-blog/freebsd-tips-tricks/freebsd-openjdk6-b17-font-issues/feed/</wfw:commentRss>
		<slash:comments>23376</slash:comments>
		</item>
		<item>
		<title>Upgrading FreeBSD port java/openjdk6 from b16 to b17</title>
		<link>http://www.getsnappy.com/tech-blog/freebsd-tips-tricks/upgrading-freebsd-port-java-openjdk6-from-b16-to-b17/</link>
		<comments>http://www.getsnappy.com/tech-blog/freebsd-tips-tricks/upgrading-freebsd-port-java-openjdk6-from-b16-to-b17/#comments</comments>
		<pubDate>Fri, 30 Oct 2009 21:18:32 +0000</pubDate>
		<dc:creator>brian</dc:creator>
				<category><![CDATA[FreeBSD Tips & Tricks]]></category>

		<guid isPermaLink="false">http://www.getsnappy.com/tech-blog/?p=35</guid>
		<description><![CDATA[Details about my recent upgrade of Openjdk for FreeBSD from Openjdk6 b16 to b17, including some tips on using the patch command.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.getsnappy.com%2Ftech-blog%2Ffreebsd-tips-tricks%2Fupgrading-freebsd-port-java-openjdk6-from-b16-to-b17%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.getsnappy.com%2Ftech-blog%2Ffreebsd-tips-tricks%2Fupgrading-freebsd-port-java-openjdk6-from-b16-to-b17%2F" height="61" width="51" /></a></div><p>As the maintainer of the java/openjdk6 port for FreeBSD I recently took on the challenge of upgrading the java/openjdk6 port from b16 to the newly released b17.  I&#8217;ve decided to blog about, partly to document my efforts to review when b18 comes out, but also to share the process with all that are interested.  </p>
<p>I started by downloading the new zip from http://download.java.net/openjdk/jdk6/, and updating the distinfo and Makefile for the port to use the b17 bundle.</p>
<p>Next I went to extract and apply patches.  I got a weird message during the extraction process that the hotspot/linux/Makefile didn&#8217;t exist.  This seemed unusual at first, but it turns out there is a post-extract section in the ports Makefile that was copying and running sed expressions, to create bsd files from linux versions.  A couple of directories and files needed to be removed, then I moved on to the patching process.</p>
<p>I optimistically tried to patch but patch died complaining about a hunk ordering mismatch.  I tried to work with the single patch-set file for several minutes before deciding to take a different approach and split the patch.  I separated the single patch file so that every file that required a patch had its own patch file.  This allowed me to deal with patches on a file by file basis.  I found splitpatch.rb at http://www.clearchain.com/~benjsc/download/splitpatch/splitpatch.rb, and slightly modified the output filename, and quickly got the job done.</p>
<p>Next I seperated patches that applied cleanly from patches that had errors using the following command and parsing the results by hand.  </p>
<pre><tt>find /usr/ports/java/openjdk6/files/brian1/ -name \*patch\* -print -exec bash -c "patch -lsC < {};" ';' 2&#038;1; | less
</tt></pre>
<p>Of 288 total files patched, 221 patches merged successfully and 67 patches failed.  I started addressing the failed patches by categorizing them.  There where 34 makefiles, 13 build files, 12 src files, 6 agent files, and 2 uncategorized files.  </p>
<p>My plan was to apply all the clean patches, then hand merge the rest, build, then recreate the patch-set at the very end.  I started by making a non-patched work directory using the command make extract.  Then I created two copies of this directory called orig and work-progress.  I would perform all work inside of work-progress and copy any modified files into the work directory to test my changes.  I planned to use orig for creating the patch-set from my modified work-progress copy.</p>
<p>If I made numerous changes, or wanted to verify the entire patch I would start with a fresh copy of my work-progress directory.</p>
<pre><tt># equivalent of a make clean
rm -rf work &#038;&#038; cp -Rp work-progress work
</tt></pre>
<p>There was one file that proved to be a pain to patch.  hotspot/src/os/bsd/vm/os_bsd.cpp, would not patch with the following error message.</p>
<pre><tt>patch: **** misordered hunks! output would be garbled</tt></pre>
<p>I started hand merging the patch, and after 15 minutes, I thought to myself there had to be a better way.  I decided to split the patch into individual hunks using the splitpatch.rb script, and apply each hunk individually.  It worked like a charm, and only one of the hunks had to be hand merged.  I did have to instruct patch as to which file these hunks applied to be passing hotspot/src/os/bsd/vm/os_bsd.cpp as an extra argument.  </p>
<p>However compiling this file resulted in an error.  Some hunks were applied in obviously incorrect locations.  Turns out the default fuzz factor of two, was the culprit.  I reapplied the patch with a fuzz factor of 0, and this time three hunks failed and needed to be  applied by hand.  I bet if I tried a fuzz factor of 0, with the original non-split-by-hunk  patch that it would have succeeded with the three rejects.  </p>
<p>There were lots of small errors that occurred during the building process.  All of them were very minor and required small simple changes.  Where error lead my to applying patches for PR #138348 and PR #139452.  One thing I found very handy for speeding up the porting process was setting the BUILD_<subproject> MAKE_ENV options inside the ports Makefile to only compile one subproject at a time. </p>
<pre><tt>#default BUILD_<all subprojects>
BUILD_CORBA=true \
BUILD_JAXP=true \
BUILD_JAXWS=true \
BUILD_HOTSPOT=true \
BUILD_MOTIF=true \
BUILD_JDK=true
</tt></pre>
<pre><tt>#only build the hotspot
BUILD_CORBA=false \
BUILD_JAXP=false \
BUILD_JAXWS=false \
BUILD_HOTSPOT=true \
BUILD_MOTIF=false \
BUILD_JDK=false
</tt></pre>
<p>I finally got a clean building work-progress directory after making a lot of little tiny fixes and reapplying some patches.  </p>
<p>Below is the script I used to create the patchset from my modified source:</p>
<pre><tt>#!/bin/sh

rm -rf /usr/ports/java/openjdk6/work-pristine;
cp -rp /usr/ports/java/openjdk6/work-progress /usr/ports/java/openjdk6/work-pristine;
cd /usr/ports/java/openjdk6/work-pristine;
find ./ -name \*.rej -exec rm '{}' ';'
find ./ -name \*.orig -exec rm '{}' ';'
find ./ -name \*sC -exec rm '{}' ';'
diff -uNr ../orig/ ./ > ../files/make1/patch-set
</tt></pre>
<p>You can gain early access to this port by downloading it from:<br />
<a href="http://www.getsnappy.com/downloads/openjdk6-b17-pr2.tar.gz">http://www.getsnappy.com/downloads/openjdk6-b17-pr2.tar.gz</a></p>
<p>To install:</p>
<pre><tt>cd /usr/ports/java
tar -xjf &lt;path_to_tar_bundle&gt;/openjdk6-b17-pr2.tar.gz
cd openjdk6-b17
make
</tt></pre>
<p>Pre Release 2 features these fixes:</p>
<ul>
<li>
no more <a href="http://www.getsnappy.com/tech-blog/freebsd-tips-tricks/freebsd-openjdk6-b17-font-issues/">ugly fonts</a>!
</li>
<li>
locale data is now correct
</li>
<li>
supports building on 9.0 current
</li>
<li>
include fastdebug build options creates a mirrored /usr/local/openjdk6-fastdebug installation
</li>
]]></content:encoded>
			<wfw:commentRss>http://www.getsnappy.com/tech-blog/freebsd-tips-tricks/upgrading-freebsd-port-java-openjdk6-from-b16-to-b17/feed/</wfw:commentRss>
		<slash:comments>1092</slash:comments>
		</item>
		<item>
		<title>openjdk6 b17 is right around the corner</title>
		<link>http://www.getsnappy.com/tech-blog/freebsd-tips-tricks/openjdk6-b17-is-right-around-the-corner/</link>
		<comments>http://www.getsnappy.com/tech-blog/freebsd-tips-tricks/openjdk6-b17-is-right-around-the-corner/#comments</comments>
		<pubDate>Tue, 29 Sep 2009 15:50:00 +0000</pubDate>
		<dc:creator>brian</dc:creator>
				<category><![CDATA[FreeBSD Tips & Tricks]]></category>

		<guid isPermaLink="false">http://blogb.getsnappy.com/?p=6</guid>
		<description><![CDATA[The openjdk6 team has put in a ton of effort to merge in changes from jdk6 hs14 into the openjdk6 branch.  They have also included some security related patches that were fixed in jdk6 hs15.  The openjdk6 branch should now contain all security related patches as of jdk6 hs20.  All of this [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.getsnappy.com%2Ftech-blog%2Ffreebsd-tips-tricks%2Fopenjdk6-b17-is-right-around-the-corner%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.getsnappy.com%2Ftech-blog%2Ffreebsd-tips-tricks%2Fopenjdk6-b17-is-right-around-the-corner%2F" height="61" width="51" /></a></div><p>The openjdk6 team has put in a ton of effort to merge in changes from jdk6 hs14 into the openjdk6 branch.  They have also included some security related patches that were fixed in jdk6 hs15.  The openjdk6 branch should now contain all security related patches as of jdk6 hs20.  All of this will soon be bundled in the openjdk6 b17 snapshot very soon.</p>
<p>As the maintainer of the openjdk6 port on FreeBSD I will be releasing openjdk6 b17 out to the FreeBSD community as soon as it&#8217;s available.</p>
<p>Cheers!<br />
Brian</p>
]]></content:encoded>
			<wfw:commentRss>http://www.getsnappy.com/tech-blog/freebsd-tips-tricks/openjdk6-b17-is-right-around-the-corner/feed/</wfw:commentRss>
		<slash:comments>10322</slash:comments>
		</item>
		<item>
		<title>Sharing files with other users in Mac OS X 10.4+</title>
		<link>http://www.getsnappy.com/tech-blog/mac-os-x-tips-tricks/sharing-files-with-other-users-in-mac-os-x-10-4/</link>
		<comments>http://www.getsnappy.com/tech-blog/mac-os-x-tips-tricks/sharing-files-with-other-users-in-mac-os-x-10-4/#comments</comments>
		<pubDate>Tue, 02 Jun 2009 05:59:00 +0000</pubDate>
		<dc:creator>brian</dc:creator>
				<category><![CDATA[Mac OS X Tips & Tricks]]></category>
		<category><![CDATA[different]]></category>
		<category><![CDATA[file sharing]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[mac os x]]></category>
		<category><![CDATA[mac os x macosx osx file sharing multiple users]]></category>
		<category><![CDATA[macosx]]></category>
		<category><![CDATA[multiple]]></category>
		<category><![CDATA[multiple users]]></category>
		<category><![CDATA[os x]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[two accounts]]></category>
		<category><![CDATA[users]]></category>

		<guid isPermaLink="false">http://blogb.getsnappy.com/?p=5</guid>
		<description><![CDATA[I&#8217;ve been wanting to share files between me and my wife&#8217;s account on the Mac, but have not been able to do so.  I&#8217;ve finally found the answer using ACL&#8217;s.  It&#8217;s very easy to do, just follow these steps for every account you want to make accessible by others.

 Open up a Terminal [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.getsnappy.com%2Ftech-blog%2Fmac-os-x-tips-tricks%2Fsharing-files-with-other-users-in-mac-os-x-10-4%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.getsnappy.com%2Ftech-blog%2Fmac-os-x-tips-tricks%2Fsharing-files-with-other-users-in-mac-os-x-10-4%2F" height="61" width="51" /></a></div><p>I&#8217;ve been wanting to share files between me and my wife&#8217;s account on the Mac, but have not been able to do so.  I&#8217;ve finally found the answer using ACL&#8217;s.  It&#8217;s very easy to do, just follow these steps for every account you want to make accessible by others.</p>
<ol>
<li> Open up a Terminal (Finder -&gt; Applications -&gt; Utilities -&gt; Terminal)</li>
<li>Execute the following command from the prompt, notice that the leading # is not part of the command, and that  &lt;username&gt; tag should be replaced by the &#8220;short name&#8221; of the users whose files you want to share.
<pre><tt>find /Users/&lt;username&gt;/ -exec sudo chmod +a# 0 'staff allow add_file,add_subdirectory,list,search,readattr,delete,delete_child, writeattr,writeextattr,file_inherit,directory_inherit' '{}' ';'
</pre>
<p></tt></li>
<li>All accounts on the machine should belong to the staff group and have full access to this users files.</li>
</ol>
<p>You can modify the command to fit your needs, for example lets say you only want to share Pictures change "/Users/&lt;username&gt;/" to "/Users/&lt;username&gt;/Pictures/"</p>
<p>If you only want admins to be able to have permissions change <code>+a# 0 'staff allow</code> to <code>+a# 0 'admin allow</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.getsnappy.com/tech-blog/mac-os-x-tips-tricks/sharing-files-with-other-users-in-mac-os-x-10-4/feed/</wfw:commentRss>
		<slash:comments>2907</slash:comments>
		</item>
	</channel>
</rss>
