Archive for September, 2007

The Microsoft Clear Type Fonts

Friday, September 21st, 2007

I’m wondering how long will it take until the legions of low skilled Weekend Web Designers will start using the Microsoft ClearType Fonts en masse. I’m guessing it’s popularity will be largely dependent on proliferation of the 2007 edition of Front Page which doubtlessly use Calibri as the default font for the WYSIWYG editor. What does it mean for people without Office 2007 or Vista on our machines?

Probably not much. But we can probably expect tons of websites with layouts that don’t quite look right due to the subtle difference in a way browsers render Calibri and your default fallback sans-serif font. Is this a big problem? No, it’s not. But then again, some stuff might be font sensitive. For example our little chess game was based on font shapes present in Microsoft’s True Type font package that usually ships with office. Again - this is bad web design practice, inconsiderate for non-windows users, and etc. But chances are that at one point or another you will have some semi-legitimate need for one of the MS specific fonts. With the True Type set this was relatively easy - linux users could just download an appropriate package for their system - like the msttcorefonts package for Ubuntu. This is possible because the original EULA for the True Type fonts did not prohibit their repackaging and use on non-windows system.

Microsoft since then has revised their position, when it stopped distributing these fonts online back in 2005. They seem to be much more stingy with the new Clear Type fonts - they are not distributed online, and only shipped with software bundles. Windows users can still get them for free with a copy of the Powerpoint Viewer. But the fonts come with a nasty licensing restriction:

You may use the fonts that accompany the PowerPoint Viewer only to display and print content from a device running a Microsoft Windows operating system. Additionally, you may do the following:

  • Embed fonts in content as permitted by the embedding restrictions in the fonts
  • When printing content, temporarily download the fonts to a printer or other output device

You may not copy, install or use the fonts on other devices.

In other words, the use of these fonts on Mac and Linux is explicitly forbidden. You are not even allowed to run PowerPoint Viewer in Wine! This of course does not mean it is not laughingly easy to extract these fonts from the Powerpoint Viewer binary using cabextract tool and a simple bash script by Aristotle Pagaltzis. Still, it’s a breach of EULA - using them on a non-windows system is illegal, and you could be liable if caught. Sure, you are probably safe to have them on your home machine. But, if you install them on your Linux machine at work for the sake of testing layouts, and your company gets audited you could get in trouble.

If you want to go the legal route and get the ClearType fonts on a non-windows machine you will have to buy them from Ascender the hefty price of $299 for the whole bundle, or $35 per individual font. This does not include redistribution though - and the company does not disclose their licensing fees instead providing an online contact form for requesting a personalized proposal.

What I’m saying here is this: Microsoft is poising Calibri to replace Times New Roman by making it the default Office font. As such it is bound to become ubiquitous font for Word documents within the next few years. You’d think that one would want to widely distribute this font across platforms for the sake of integration, compatibility and building a broad user base. Especially with a set of fonts optimized for screen reading - and and by this virtue really sort-of destined to become dominant on the web.

But this is not the case - MS prohibits non-windows operating systems from legally obtaining this font without a hefty fee by restrictive EULA. So I ask you - isn’t that playing a little bit dirty? Doesn’t that seem a bit problematic?

The other obvious concern about these C-Fonts (have you noticed that all of them start with C? Constantia, Corbel, Calibri, Cambria, Candara, Consolas and etc..) is that they trade off screen readability for print readability. Ask professional typesetters what do they think about printing text in the new sans-serif fonts. I can bet that most of them will probably agree that Calibri is marginally better than printing in Arial but nowhere near as readable in print as the good old Times. Serif fonts just look better on paper - that’s just how it is. Go and check your bookshelf - pull out any paperback or a textbook. 9 out of 10 of the books you pull out will be using Serif fonts.

And yet, in a strange twist most Office 2007 documents will probably print in Calibri - because let’s face it, if it looks pretty on their monitor a lot of people won’t bother changing it the way they changed Times to the more screen friendly Arial or Verdana. I could understand making this screen-font the default for, say Outlook as you don’t usually print all your emails. Most Word documents on the other hand will eventually get printed in one way or another. Thus, Sans-Serif fonts will become more and more widespread in paper publications inducing eye-strains all across the globe, and making my LaTex generated documents look beautiful and very professional by comparison.

Ubuntulite: Problems Running Feisty on Old Hardware

Thursday, September 20th, 2007

While I was moderately happy with Fluxbuntu, I decided to give Ubuntulite a shot. It sounded like a great idea - the most basic of basic systems, with minimal Openbox setup on top of it. Fluxbuntu still seemed to exhibit some strange bloat here and there, and a very stripped down system seemed exactly what my old junky Presario 1240 needed.

Ubuntulite Logo

So I followed the Ubuntulite instructions to the iota and got the system on my machine. It’s very spartan, and rough around the edges, but hey - that’s what I wanted, wasn’t it?

But I run into a heap of issues with this installation. And I’m not really blaming Ubuntulite team for this. I think this is sum of unfortunate software choices, and inherit Feisty issues. My biggest issue was the strange shit that was happening on boot time. Every time I would power up this machine, I would get the following lovely message:

[ 0.000000] ACPI: Unable to locate RSDP
Loading, please wait...
kinit: name_to_dev_t(dev/disk/by/uuid/the-long-uuid-goes-here) = hda5(3,5)
kinit: trying to resume from /dev/disk/by/the-long-uuid-goes-here
kinit: No resume image, doing normal boot...

The machine would actually hang and wait about a minute on the Loading prompt before displaying the kinit messages and resuming boot sequence. Apparently, this issue has not one but at least two bug reports on launchpad already #103148 and #105316 and neither one has been resolved. There is also this thread in the Ubuntu forums about it. I followed all the proposed fixes and nothing worked. This was not a show stopper, but an annoyance.

I finally resolved it by following the instructions here, but instead of using the UUID’s I actually modified my fstab to use standard notation like /dev/hda5. If you are to lazy to follow the link and try to figure it out on your own, here is what you do. In your /etc/fstab you will see the following line for swap:

#/dev/hda5
UUID=the-swap-partition-uuid-number-here	swap	sw	0	0

Delete the UUID bullshit and change it to:

/dev/hda5	swap	sw	0	0

Now open your /etc/initramfs-tools/conf.d/resume. It will have a long UUID listed there. Get rid of it, and replace it by simple:

RESUME=/dev/hda5

Once that is done, do:

sudo update-initramfs -u

Note that this will take around 17 million hours when you are on slow hardware, so just be patient. Once it is done, sudo reboot now. Problem solved - at least for me. Your millage may vary.

To get rid of the ACPI error I just modified my GRUB entry to add acpi=off noacpi at the end of the kernel string. Go to your /boot/grub/menu.list and find the part where it lists all the bootable entries. Find the line that specifies the kernel - it will look something like this:

kernel	/boot/vmlinuz-version.number root=/dev/hda2 ro quiet splash elevator=cfq

Slap the aforementioned string at the end like so:

kernel	/boot/vmlinuz-version.number root=/dev/hda2 ro quiet splash elevator=cfq acpi=off noacpi

This is an old POS laptop, and none of the distros I tried could figure out the ACPI stuff for it. I kinda gave up on that stuff. I mean, there is no point in loading it if it won’t work on this machine anyway, no?

The rest of the boot was working ok, but I noticed bunch of things there that I can probably shave off to save time - like fetchmail, CUPS and etc.

Openbox configured itself pretty well, but with two odd quirks. First one would only show up when you switched to a TTY using the Alt+Function Key shortcut and then go back to X. The display would become inexplicably dim and dark. Almost as if someone turned down the brightness on your monitor down to the lowest setting - but only when displaying X. All the other terminal screens looked fine. Killing X and restarting it solves the problem. I’m suspecting this is some oddball vesa quirk. Fluxbuntu did not seem to have this issue. (

Any idea why this happens and how to fix it? Once again, this is not a show stopper - just annoying as hell.

The most bizzare quirk however was the odd Openbox numlock behavior. The Presario 1240 is a laptop, and as many mobile machines it as one of those Fn keys and no numeric keypad. In a half assed attempt to provide customers with one, Compaq decided to use combos like Fn+J through L to mean 1-3 thereby re-using the whole right side of the keyboard as the numpad.

When logged into Openbox, it forces NumLock to the on state and so my keyboard would actually use these alternate values for all the “fake-numpad” keys. So pressing K would actually type 2, pressing P would trigger a minus sign and etc. I could still get the “normal” letters by holding down the Fn key as I press them but that was just plain stupid. External keyboard would work normally, and pressing NumLock on it would “fix” this issue on the built in keyboard as well.

Quickly swiching to a TTY and back would do the same. But then I’d have to deal with that dark-vision effect so that was not a good solution either. Why wouldn’t I just hit NumLock on the laptop keyboard? Oh, probably because I fucking couldn’t. You see - NumLock on that keyboard is one of these special keys that can only be accessed while holding Fn key. And for some reason, it would just not work. Whooptie do!

Fortunately, it seems that I’m not the only person experiencing this issue, and there is a quick software fix for this behavior called numlockx:

numlockx off

The downside of this is that you have to run this command every time you boot into X. I’ll have to figure how to plug this command into the openbox boot sequence, along with commands to start the fbpanel and xsetroot into something not ugly. Care to point me in the right direction? I still haven’t gotten around to customizing my environment this way.

Its strange, but none of the other distros I used really touched NumLock. Go figure.

Btw, I’m not saying Ubuntulite is bad I actually I kinda like it. Being rough around the edges is kinda their aim, so I can’t complain about that. And the fact it doesn’t pus any given setup GUI setup on you let’s me experiment with different lightweight components and create an environment I’m happy with. Most of my problems seem to be Feisty related - rather than Ubuntulite specific. Dapper was rock solid on this machine. Feisty is a tad flaky as you can see from the issues above. I will play around some more with this system. I think I solved most of the jarring issues, and the rest will probably just fall into places soon. If it continues being flaky, and pisses me off I will probably scrap this installation and try Vector or Wolvix at some point. We’ll see.

Update 09/23/2007 11:44:03 AM

Just to clarify - Ubuntulite is still in a very early beta stage. It’s in no way a finished product. I’m not really bashing the distro - just pointing out minor issues I encountered with the early version. If you download it now, it will be more polished and usable than when I got it because they just released a new version. ) I think this will be a really good distro for old hardware once it matures a bit and reaches a stable state.

MySQL: Find Duplicate Entries in a Table

Wednesday, September 19th, 2007

Here is a little background for this issue. The database used to run on ancient copy of MySQL until very recently we upgraded it to 5.0. Not without some headaches of migrating the database, but it worked. Common problem we had with this database was duplicate entries in printed reports. Why did these happen? Mostly because of user error combined with a lack of foreign key constraints.

The two MyIsam tables that were causing the issue were: report and proforma. Both were used for tracking documents through the review process. Report was the actual field audit report that would be submitted, reviewed and sent to the clients, while proforma was the documentation of expenses that our employees were supposed to submit for each assignment. Both would store dates, comments, notes and other info regarding said documents. The proforma had a 1-1 relationship with report (each proforma was tied to a single report entry). But since the old MySQL version did not support Foreign Key constraints this was not enforced (or rather only enforced by the PHP front end).

However users would continuously find ways to submit multiple proformas for the same report - for example by clicking the “submit” button 7 times. Other fun trick for re-submitting proforma was to send it in as TBA (to be annouced). Upon seeing the TBA the clerical staff in the office would manually associate it with appropriate report, usually without checking if another copy is already in the database. And when we locked that down, they would just continuously send bug reports about it forcing us to sort this out at the DB level.

What happened if the non-existent FK constraint was violated? One of the main reporting sections of the site used a complex join across these two tables. If there were two or more proformas per report, that report would show up on the list multiple times. What do people do when they see duplicates on the list? They start deleting them. Problem is - these were not real duplicates, but the same entry repeated several times. Deleting one copy would hose all of them, causing yet more support request for restoring the entry from the nightly DB dump.

Fun times. So after we switched to a DB engine that was actually developed in this century I immediately switched the tables to InnoDB and put a freaking foreign key constraint on that relationship. This way if someone finds a new loophole in the PHP code they will end up seeing a nice MySQL error instead of creating new duplicates.

But guess what - I just got more bug reports about duplicate entries. Apparently the FK constraint is not retroactive, and MySQL will gleefully allow duplicate keys to exist in your FK column when you apply the constraint. I figured that it would start trashing about and keep giving me errors if that was the case, but no - all it cared about was an index on the key column. So I was left with a task to track down all the duplicate entries in the foreign key column in my proforma table. How do I do this? This problem actually got me scratching my head for a bit, until I had a sudden epiphany:

SELECT 
	id, report_id, count(*)
FROM
	proforma
HAVING
	count(*)>1

I found around 17 separate instances of the foreign key (here report_id) being repeated anywhere from 2 to 8 times. All of these were for older entries that no longer show up on the first page of results, so naturally no one noticed. Still, it shows that the problem was more prevalent than we initially suspected.

What I’m really trying to say here is this: use database constraints to enforce table relationships. This is the only proper and effective way to do it. Trying to enforce constraints in software is just asking for trouble as you create multiple points of failure. Different parts of the code will update any given table at different times, and all of them must check this. Failing to implement proper checks in every piece of code that touches that table may lead to duplicate entries in FK columns and similar undesired side effects. A simple constraint on a column will stop this from happening much more effectively, with much less effort.

Latex: Squeezing the Vertical White Space

Wednesday, September 19th, 2007

Here are some tips on how to “compress” your paper vertically by minimizing white space gaps between elements. I had to do this few days ago when school refused to duplicate my syllabus because it was 14 pages long. I got it down to 6 without any cuts, and then down to 3 after doing some reductions in text.

So how do we squeeze the vertical whitespace? There are many ways to do this, and some are more complicated than the other. My tips range on the easy side, so you won’t need to write custom .sty files or redefine commands using intricate tex sequences.

First we want to set the spacing between paragraphs as small as possible. The commands below should kill just about any space inducing setting in your paper unless you are doing something fancy:

\setlength{\parskip}{0pt}
\setlength{\parsep}{0pt}
\setlength{\headsep}{0pt}
\setlength{\topskip}{0pt}
\setlength{\topmargin}{0pt}
\setlength{\topsep}{0pt}
\setlength{\partopsep}{0pt}

Now the paragraphs are snugly against each other so let’s take a look at line spacing. The \linespread command is usually used to increase the line spacing but we can exploit it to make it smaller by passing in a value smaller than 1:

\linespread{0.5}

You may want to play around with that value - if you set it to small, LaTex will just reject it. Below certain threshold some lines may start running into each other. For me 0.5 value did the trick, and slurped up swaths of white space.

Our next offender are section headings. By default they have huge gaps above and below them. Totally wasteful, especially if you are trying to save trees by decreasing your page count without sacrificing content. So what do you do? There are very complex ways to change the spacing above and below the section headings but we are lazy bums and don’t feel like using them. So let’s use the titlesec package and zero out all the spaces:

\usepackage[compact]{titlesec}
\titlespacing{\section}{0pt}{*0}{*0}
\titlespacing{\subsection}{0pt}{*0}{*0}
\titlespacing{\subsubsection}{0pt}{*0}{*0}

If you look int the documentation, the attributes to \titlespacing are command, left margin, above-skip and below-kip respectively. The * notation replaces the formal notation using plus/minus and etc. If you set it to zero, headings will snug up to the paragraphs above and below them.

Enumerations and itemizations are horrible space wasters too. By default, all the lists are double-spaced. Why? Don’t ask me, but it’s easy to get rid of that by using “compacted” lists provided by the mdwlist package. In your preamble add:

\usepackage{mdwlist}

Then instead of using normal lists use:

\begin{enumerate*}
	\item
\end{enumerate*}
 
\begin{itemize*}
	\item
\end{itemize*}

This is not as straightforward as the other steps, as it will require some search and replace in a pre-existing text. If you know a better way to do this, please let me know.

Last thing I did was to change my margins using the geometry package. My command looked like this:

\usepackage[left=2cm,top=1cm,right=2cm,nohead,nofoot]{geometry}

My document had no headers or footers so I was able to disable them. You should probably experiment a bit with the values above to see what is the maximum range of your printer. Most devices won’t print all the way to the paper edge so you must set margins appropriate to your printer.

My document had no formulas or figures, but had several long item lists. Some of them were very narrow - 2-3 words per item. These types of lists are major space wasters so I set them in multi-column mode. Depending on your list you can either use 2, 4 or either 4 columns. For me 2 columns were the right fit. I recommend using the multicol package. In your preamble add:

\usepackage{multicol}

Then surround your text to be “columnized” (shut up, it’s a new word I just mad up) using:

\begin{multicols}{2}
	% your stuff goes here
\end{multicols}

Once I did all of that, the page count of my document was cut roughly in half. Feel free to add your vertical space squeezing tips in the comments.

Is Dell Dropping the Ball on Ubuntu?

Tuesday, September 18th, 2007

I admit that I was pretty excited when I first heard about Dell shipping Ubuntu on their select machines. I figured that you can’t go wrong with a pre-installed tested system. However, since I haven’t bought one, or read any thorough, critical reviews I didn’t know how piss poor is their support.

If you read slashdot you probably seen this already, so forgive me for regurgitating this material. I’m kinda angry at Dell right now so I think it’s worth bringing it up even if it’s recycled news. Anyway, the story is that Walt Mossberg, a technology columnist for Wall Street Journal blogged his experience with the Ubuntu Dell and decided it’s not ready for the average Joe. Unfortunately Mr. Mossberg is what we in the know call a clinical case of complete fucking idiot - which is by the way, smack dab in the middle of the bell curve when it comes to tech competency. Most people are just dumb as dirt wen it comes to computers, and the only way to teach them how not to inadvertently break their own laptops is to forcibly insert knowledge into their skulls using blunt objects. So when I call Mr. Mossberg an idiot, I’m not doing this to offend him. I’m doing this to underline the fact that I don’t blame him for spreading the nasty FUD around like some Microsoft butt-monkey. I read his article, and I watched his video and I tell you - he just doesn’t know any better. So what you have here is a “complete idiot’s review of Dell-buntu” which is kinda refreshing, as it points out obvious stuff that doesn’t work while it should.

For example it seems that Dell is to cheep to pay for basic codec packs needed for playing various music and video formats. How come they don’t pre-load these machines with all the non-free shit that is not included on iso’s due to incompatible licensing? The fact that Ubuntu can’t ship with some of this stuff doesn’t mean Dell can’t. Hell they should - Windows boxes come pre-loaded with all kinds of garbage. Why can’t they install basic stuff? I mean people even make (poorly written) scripts like Automatix to make this process easier. Is it to much to expect from Dell?

Mossbergs other complaint is over-sensitivity of the touchpad, and lack of appropriate tool to regulate it. This is a blatant example of not fucking bothering to properly configure X or install the Qsynaptics package. How fucking hard would it be to put a link to Qsynaptics in the Gnome menu somewhere? Jesus Christ - that’s like 30 seconds of work. WTF Dell? Are you people even trying? You can’t just slap Ubuntu on a laptop and hope it will work, just like you can’t do the same with Windows.

Mossberg also mentioned shit kept crashing when waking up the laptop from sleep mode. I never experienced that issue because I don’t use Gnome but I believe him. ACPI on linux is pretty much Russian roulette. You never know if the system will wake up or crash unexpectedly. Honestly, I have no clue. This might be a Gnome thing, shitty support for ACPI in the Feisty kerner or something completely different. Still, this is something that could potentially be fixed by Dell in one way or another.

DVD support is, of course a lost cause. Mossberg of course is to clueless to know about the legal pile of fucking horse shit surrounding this issue so I guess we can forgive him. Ubuntu won’t play commercial DVD’s not because it can’t but because it is legally prohibited from doing so because of infinite stupidity of American entertainment industry. Not much we can do about this.

I have absolutely no clue why Mossberg claims he had to reboot to get his camera and iPod recognized. But I can’t comment here cause I do not own an iPod, nor have I tried getting my camera recognized on my work laptop. So maybe he is right, but once again - iPod support is something that could be achieved out of the box by preinstalling GTKPod package and making some appropriate entries in the fstab.

I’m not saying that Ubuntu is 100% ready for desktop use by your average techno-retatd. What I’m saying is that most of Mossberg’s complaints stem from sloppy and incompetent installation and system configuration by dell. It seems that they have decided to release the *buntu machines on the cheap without extensive testing of their installation procedures. Which is very sad. I always hoped that vendor installed Linux would ship with full hardware support, the most optimal X configuration possible and all the additional driver and helper packages required to run it. It seems that this is not the case, and dell just slaps the most basic Ubuntu image onto their drives without regard for user convenience.