The easiest way to use OS X fonts with GIMP
Fri 13 Apr 07 21:47 | Tags: Command Line, Guides, Mac, Software
Judging by RGR's stats, the most popular articles when it comes to hits from search engines have been those I've written about MacPorts. So I guess I should invite some more hits and write a little bit about it again, albeit somewhat indirectly.
If you've been reading RGR for a while, you've probably figured out that I'm a bit of a tightwad. I'd like not to be, but at this point in my life I'm not in any sort of position not to be, unfortunately. I can't really afford to do my image editing with the $650 Adobe Photoshop, as much as I'd like to (and, being a programmer myself, I can't pirate it). So instead I use the free open-source image editor GIMP, which can be easily installed via MacPorts. It falls short of Photoshop's capabilities in many ways, and the fact that it's not a "true" Mac OS X app and I can't copy-and-paste between it and other apps is pretty annoying, but it does the job, and you can't argue with the price.
When you first install it, it is somehow smart enough to find all of the standard OS X fonts, and make them available in GIMP. I'm not sure how it does this (I'm not a Unix expert; I just play one on the internet), but it's pretty handy; early on in OS X's history, when you installed GIMP, you'd just have a short list of plain and/or ugly Unixy fonts to choose from. However, if you've installed any new fonts besides the ones that come with OS X, those new fonts won't show up in GIMP's font menus. If you poke around the internet, you'll find various tips and tricks for getting your new Mac fonts to work with GIMP; I recently ran into this problem myself. I found another solution, however, and I believe the method I'm about to show you is the best and the easiest – in fact, I'm surprised I haven't come across it before.
This solution assumes you've installed your Mac fonts in the standard way; by double-clicking on them in the Finder, which causes Font Book to launch, then clicking Font Book's "Install Font" button. Installing fonts this way puts the font in the Fonts folder inside your Library folder, which is in turn inside your home folder – in Unix terms, in ~/Library/Fonts/. So all we need to do is tell GIMP to check for fonts there.
First, open up GIMP's preferences; select "Preferences" from the main "File" menu. Note that "Preferences" does not appear in the "File" menu attached to a GIMP document; you have to choose the "File" menu in GIMP's palette window, the one with the title "The GIMP." Yes, this is confusing. Thank you, Windows, for your inspirational innovations in user interface design.
Here's what the Preferences window looks like. Click the triangle next to the "Folders" item in the list on the left (labeled with a red 1 in this picture); this will make several folders appear below it. Click the Fonts item (2). A list of folders will appear to the right side of the window, but there will only be one item in the list; this is where GIMP is currently checking for fonts to use. You could copy fonts into this folder and have them show up in GIMP, but that'd be a pain; what we'll do instead is tell GIMP to also look in the folder where our fonts are already being stored.
To do this, click the icon that looks like a file (3). Then click the button with the ellipsis (4). In yet another wonderful stroke of obvious user interface design, this will bring up a navigation box that will let us choose the folder to add. It should show your home folder. Double-click on the Library folder, then click on the Fonts folder and click the OK button. That should close the navigation box and bring you back to the Preferences window. Click the Preferences window's OK button. GIMP will show you a little note about how you need to restart GIMP for the changes to take effect; click the OK button, then go ahead and quit and restart GIMP. Ta-daa! You should now see your installed fonts in GIMP's fonts menus.
An aside: If you're Unix-savvy, you may have noticed that there are not actually any fonts in GIMP's default font folder, ~/.gimp-2.2/fonts/. So how is GIMP seeing the standard OS X fonts? Answer: I don't know. I'm curious, though; if you can enlighten me on this, please do so in the comments.
Also, if you have any questions about MacPorts (or GIMP), please don't be afraid to mention them in the comments, or, if you're shy, contact me directly.
Get more great Ray Gun Robot content sent directly to your feed reader or email inbox! Subscribe today!
Articles & Links — Via Email
Articles Only — Via Email
8 Comments | 0 Trackbacks |
| ![]()
More MacPorts tricks
Sat 10 Mar 07 15:00 | Tags: Command Line, Guides, Mac, MacPorts
It's been a while since I wrote anything about MacPorts, so let's revisit it, shall we? Those of you who are entirely unfamiliar with MacPorts may wish to skip this article; it won't be of much use to you.
As I mentioned earlier, I was recently toying with the idea of switching to WordPress for this blog. In order to test WordPress out, I installed it on my own computer before installing it "live" on the public web server.
WordPress requires MySQL. I installed PHP without MySQL on my computer because I personally don't use MySQL; I prefer to use SQLite whenever I write programs that need to use a database. So I needed to add MySQL support to my PHP installation before I could use WordPress. Fortunately, I'm using MacPorts, so that's going to be pretty easy to do. There's a few different ways to go about it, though.
As I said in that earlier article, I could have used a "variant" trigger when I first installed PHP to add MySQL support. A list of possible variants for a port can be found by typing port variants portname:
Monster:~ Albright$ port variants php5
php5 has the variants:
universal
darwin_6
darwin_7
darwin_8
freebsd
macosx
apache
apache2
fastcgi
snmp
macports_snmp
mysql3
mysql4
mysql5
postgresql
ipc
pcntl
pear
Monster:~ Albright$
And you can see what variants your currently-installed port is using (as well as the version of that program) by using port installed portname:
Monster:~ Albright$ port installed php5
The following ports are currently installed:
php5 @5.2.0_0+darwin_8+fastcgi+macosx (active)
Monster:~ Albright$
(Just typing port installed will list everything that MacPorts has installed on your system and their versions. It may be a pretty long list.)
So I want the mysql5 variant on my PHP 5 installation. How should I go about that? It depends on circumstances.
Adding variants through upgrades
If the version of the port you currently have installed is out of date, you can choose to change the variants of the installation when you upgrade it. To check if an installed package is outdated, use port outdated portname. In this example, my SQLite installation is out of date.
Monster:~ Albright$ port outdated sqlite3
The following installed ports are outdated:
sqlite3 3.3.11_0 < 3.3.13_0
Monster:~ Albright$
But if you just get a blank line after the first line, then the package is up-to-date. In this example, my MySQL installation is current.
Monster:~ Albright$ port outdated mysql5
The following installed ports are outdated:
Monster:~ Albright$
In the above example, I had PHP5 version 5.2.0_0 installed. But it looks like it's out of date!
Monster:~ Albright$ port outdated php5
The following installed ports are outdated:
php5 5.2.0_0 < 5.2.1_1
Monster:~ Albright$
So I can upgrade it using the upgrade command, and specify my desired variants. MacPorts will respect those variants as it installs the new version of the package. (Remember that we need to prepend commands with the sudo command and type our password whenever we run a command that will install or remove files.)
Monster:~ Albright$ sudo port upgrade php5 +fastcgi +mysql5
Password:
---> Fetching php5
[...]
---> Activating php5 5.2.1_1+darwin_8+fastcgi+macosx+mysql5
Monster:~ Albright$ port installed php5
The following ports are currently installed:
php5 @5.2.1_1+darwin_8+fastcgi+macosx+mysql5 (active)
(You can get a list of all out-of-date installations by using just port outdated (with no port name), and upgrade all outdated ports at once using port upgrade installed. Be sure not to use port upgrade all, as that will try to install every single port available on your system! I found out that little fubar by personal experience, needless to say…)
Brute force reinstallation (avoid it!)
But what if your installed version of the package was already up-to-date? MacPorts won't let you upgrade an up-to-date installation, even if you try to specify different variants; it will fail silently.
Monster:~ Albright$ port installed php5
The following ports are currently installed:
php5 @5.2.1_1+darwin_8+fastcgi+macosx (active)
Monster:~ Albright$ sudo port upgrade php5 +fastcgi +mysql5
Monster:~ Albright$ port installed php5
The following ports are currently installed:
php5 @5.2.1_1+darwin_8+fastcgi+macosx (active)
How can we force MacPorts to rebuild the package with the new variants? Well, we can make like Luke and use the force… flag. Adding -f to a command forces MacPorts to follow a command, even if it doesn't think it's a good idea to do so. I generally recommend you never use this flag with MacPorts; it can make for some unpleasantness. However, using it with upgrade won't foul things up too much. It's a bit slow, because it seems to also fetch and reinstall all of the dependencies for the package you're trying to reinstall, but it works eventually.
Monster:~ Albright$ sudo port upgrade -f php5 +mysql5 +fastcgi
Note that you'll probably see some dire-looking warnings stating "Warning: Uninstall forced. Proceeding despite dependencies." Don't worry; all of the dependencies that it's uninstalling are being immediately re-installed anyway. Like I said, it's not pretty, but it works.
Cohabitation
But here's the coolest and most pleasant way to get around this problem. MacPorts is smart enough that it can handle multiple installations of the same package at the same time, so long as each installation has a different version number or different variants. Watch this:
Monster:~ Albright$ port installed php5
The following ports are currently installed:
php5 @5.2.1_1+darwin_8+fastcgi+macosx (active)
Monster:~ Albright$ sudo port install php5 +fastcgi +mysql5
Password:
---> Fetching php5
[...]
---> Activating php5 5.2.1_1+darwin_8+fastcgi+macosx+mysql5
Error: Target com.apple.activate returned: Image error: Another version of php5 (5.2.1_1+darwin_8+fastcgi+macosx) is already active.
Error: Status 1 encountered during processing.
Uh oh, but it caused an error! No problem, really.
Monster:~ Albright$ port installed php5
The following ports are currently installed:
php5 @5.2.1_1+darwin_8+fastcgi+macosx (active)
php5 @5.2.1_1+darwin_8+fastcgi+macosx+mysql5
See? I've got two installations of PHP now. However, the one without MySQL support is not "active;" it's not the PHP installation that the computer is going to use. MacPorts gives us two commands to change this; deactivate and activate. deactivate essentially "turns off" an installation without uninstalling it.
Monster:~ Albright$ sqlite3 -version
3.3.11
Monster:~ Albright$ sudo port deactivate sqlite3
---> Deactivating sqlite3
Monster:~ Albright$ sqlite3 -version
-bash: /opt/local/bin/sqlite3: No such file or directory
Monster:~ Albright$ sudo port activate sqlite3
---> Activating sqlite3
Monster:~ Albright$ sqlite3 -version
3.3.11
Monster:~ Albright$
As you can see, the usage is pretty simple: activate portname and deactivate portname. However, if you try to use it like that on a package you have multiple installations of, MacPorts rightly becomes confused. So to use these commands (as well as others, such as uninstall) on packages with multiple versions, you have to specify the version you wish to act on exactly as port installed labels them. You may find it helpful to do as I do and copy-and-paste the version numbers. So here, I'll disable the PHP installation without MySQL, and enable the one with MySQL:
Monster:~ Albright$ port installed php5
The following ports are currently installed:
php5 @5.2.1_1+darwin_8+fastcgi+macosx (active)
php5 @5.2.1_1+darwin_8+fastcgi+macosx+mysql5
Monster:~ Albright$ sudo port deactivate php5 @5.2.1_1+darwin_8+fastcgi+macosx
---> Deactivating php5 5.2.1_1+darwin_8+fastcgi+macosx
Monster:~ Albright$ sudo port activate php5 @5.2.1_1+darwin_8+fastcgi+macosx+mysql5
---> Activating php5 5.2.1_1+darwin_8+fastcgi+macosx+mysql5
Monster:~ Albright$ port installed php5
The following ports are currently installed:
php5 @5.2.1_1+darwin_8+fastcgi+macosx
php5 @5.2.1_1+darwin_8+fastcgi+macosx+mysql5 (active)
Monster:~ Albright$
Now, if I wish, I can uninstall the non-MySQL installation without any whining about dependencies or anything like that, because I already have another current and working installation on my machine.
Monster:~ Albright$ sudo port uninstall php5 @5.2.1_1+darwin_8+fastcgi+macosx
---> Uninstalling php5 5.2.1_1+darwin_8+fastcgi+macosx
Monster:~ Albright$ port installed php5
The following ports are currently installed:
php5 @5.2.1_1+darwin_8+fastcgi+macosx+mysql5 (active)
Monster:~ Albright$
This is a much prettier solution than the brute force method.
This "cohabitation" of installations can also work with two different versions of the same package. So, for example, if you're using version X of a vitally important application, and version Y has come out, you can install and activate version Y and test it out without uninstalling or installing over version X; just remember to use install portname instead of upgrade portname. If it turns out version Y is buggy or faulty, you can the very easily deactivate it and reactivate version X without causing too much downtime.
MacPorts is a powerful program for managing the more Unix-y software on your computer. It can be a bit tough to use at first, but as the above shows, its learning curve allows for some pretty convenient functionality -- and it's definitely still easier to use than compiling and installing applications and dependencies "by hand." If you have any questions about MacPorts, please post them in the comments or email me, and I'll try to help you out.
Get more great Ray Gun Robot content sent directly to your feed reader or email inbox! Subscribe today!
Articles & Links — Via Email
Articles Only — Via Email
2 Comments | 0 Trackbacks |
| ![]()
Installing X11 for MacPorts
Thu 8 Feb 07 01:51 | Tags: Command Line, Guides, Mac, MacPorts
Note: This entry was originally published on my SigFeeder blog, but I thought I'd post it here as a first entry both to help test things out and because it's the kind of article I'm hoping to feature here.
Fellow Mac freaks, are you aware of MacPorts? Well, as you may know, the Mac OS is basically a version of the Unix operating system with a very user-friendly graphical "wrapper" around its traditional command line interface guts. MacPorts (formerly DarwinPorts) is a system which makes it easy to get the wealth of free Unix software out there onto your Mac. If you know some Unix basics and aren't afraid to open up Terminal and use command line programs, you can use MacPorts to install some very handy Unix software. I used quite a few MacPorts-installed programs during the development of SigFeeder, including the GIMP image editor, sitecopy web site synchronizer, SQLite database system, LightTPD web server and PHP programming language (more on those last two another day).
Of course, there are graphical Mac-friendly installers for many of those programs, but I think MacPorts is a better choice. For one, when you go with such installers, you're at the whim at the person who made that package when it comes to where your program is installed, what system the program was optimized for (are you installing a crusty PowerPC-compiled program on your shiny new Intel-powered Mac?), and how often that person will release updates. With MacPorts, you can be sure that everything will be installed in a uniform place, that it will be compiled for optimal use on your system, and that updates will be swift and frequent.
The cost is complexity. MacPorts itself isn't too difficult to use; installing, say, the Vim text editor is as easy as typing sudo port install vim followed by your administrator password, then sitting back for a moment while everything downloads and compiles for you. However, actually installing MacPorts is a bit of a pain; it starts out by signing up for Apple's developer network (if you haven't already), then downloading a bunch of development compilers and tools and stuff to install in your system; this download is almost one gigabyte. And that's only the beginning! The MacPorts wiki has an installation guide which will walk you through everything, and fortunately it's something you only have to do once.
However, there is one glaring annoying error on that installation page which I've noticed others around the internet having trouble with; it tripped me up a bit myself, though the solution is rather simple. (Although the installation guide is ostensibly a wiki page, I can't find a way to edit it.) So I figured I'd post the solution here to help others who are having trouble with it, in the hope of Googlebaiting so others can find the solution if they're having trouble with it — and if we end up with a few new SigFeeder members in the process, then I can't say I'd complain.
The error is in Step 2, "Install XWindows (X11)." You're instructed to "Insert the OS X 10.4 installation DVD and run the package named Additional Software." Yeah, good luck on that; if you've tried it, you'd note that there's no freakin' package anywhere on that disc named "Additional Software." Don't bother browsing through all the various delicious-looking folders on that disc; you won't find it in there.
What you want to do — and this is the simple part — is to scroll down in that window in the Finder, and you'll see a package named "Optional Installs." This is the "Additional Software" package you should be looking for. Double-click that, expand the "Applications" category, and bam! There's X11, waiting for you to install it and continue on. See? I told you it was simple. You can then continue with the MacPorts installation as shown on the installation guide.
I'll be writing a little bit more about MacPorts in the future.
Get more great Ray Gun Robot content sent directly to your feed reader or email inbox! Subscribe today!
Articles & Links — Via Email
Articles Only — Via Email
0 Comments | 1 Trackback |
| ![]()

