• Disabling bitmapped fonts

    A week ago or so I reinstalled NetBSD — 3.0_STABLE, not current — on my machine, finally replacing the previous unstable and out-of-control system. I had to do it to get some work done more easily than on Windows and to be able to keep up with my developer duties.After a successful and painless installation, I built and installed Firefox and Windowmaker, both of which come handy from time to time (specially while rebuilding the entire GNOME Desktop). However, launching Firefox under a plain Windowmaker session greeted me with extremely ugly fonts. The GTK interface was OK, but web pages were rendered horribly in general. It was simply unusable.At first I thought it had to do with the anti-aliasing configuration, but several attempts to change its details only resulted in worse fonts. The same happened when dealing with DPI settings. So what was happening? It turns out that Firefox was using bitmapped fonts instead of vector ones — and you know how ugly these look if they are not rendered in their native size.Firefox was asking Fontconfig (X's font configuration and access library) to provide a font from the Serif family, without caring about which it could be. Fontconfig then provided it with a bitmapped font. (I still don't know why it preferred those over any other.)The nice thing is that you can tell Fontconfig how to match generic font names to the fonts you really have. And this effectively means that you can force it to never use bitmapped fonts. All I had to do was to create a custom local.conf file in Fontconfig's configuration directory (/etc/pkg/fontconfig in my case):<?xml version="1.0"?><!DOCTYPE fontconfig SYSTEM "fonts.dtd"><fontconfig><include>conf.d/no-bitmaps.conf</include></fontconfig>The curious thing is that GNOME seems to take care of this on its own because Firefox uses nice fonts under it even if you do not touch Fontconfig files.Oh! Be aware that NetBSD has two Fontconfig installations: one from the native XFree86 installation and one from pkgsrc. These are configured in different directories: /etc/fonts and PKG_SYSCONFDIR/fontconfig respectively.Don't know if this issue also happens in other operating systems if Fontconfig is not manually configured... [Continue reading]

  • Windows: Remapping keyboard keys

    Some time ago, I bought an Apple Keyboard to use with both my PC and iBook. Compared to a traditional PC keyboard, this one includes extra function keys (from F13 to F16) and some multimedia ones, but does not provide those that are PC-specific and which are very rarely used even in, for example, Windows. One of such keys is Print Screen; I needed this key to take a screenshot of my desktop a couple of days ago and couldn't find a quick way to do it otherwise.In order to solve the problem, I searched for information on how to remap keys in Windows. It turns out that doing so manually is quite complex because you need to fiddle with a cryptic key in the registry (how not!). Fortunately, there is a little free utility that simplifies this process: SharpKeys.This tool lets you remap any physical key on your keyboard to any other one you can imagine. To my surprise, you can even remap your keys to those multimedia functions found in new keyboards, which comes great to control the media player. For example: F14 to go to the previous track, F15 to toggle between play and pause and F16 to go to the next track. I have been using a similar setup to control iTunes with SizzlingKeys and is certainly a comfortable configuration.Think about it: your keyboard surely has some keys that you do not ever use and which could be mapped to become useful! (And this applies to any OS.)Hmm... too much Windows-related posts in a row. The next one will be different; promise! [Continue reading]

  • Windows: Where is deltree?

    If you were a MSDOS user as I was, you may remember one of the useful novelties in the 5.0 version: an utility to delete whole directory hierarchies. It was known as deltree. That tool came really useful to avoid launching third party applications such as PC-Tools or PC-Shell (if I remember their names correctly).What a surprise when I needed it a year ago while working in Windows XP and couldn't find it anywhere; it certainly existed in Windows 9x! Where is it? Well, it simply does not exist any more.So, how can you delete whole directory trees from the Windows XP command line? Just use the rmdir command. Its /s option can be specified to ask it to recursively delete directories. And the /q flag comes helpful to avoid the multiple and annoying "Are you sure?" questions.As far as I can tell, deltree ceased to exist in Windows 2000. And yes: I have been meaning to post this message for almost a year! [Continue reading]

  • Happy second birthday!

    Today makes the second year since this blog was born; its birth happened in the middle of final exams, just as the same period I'm in now. As you may remember, it was firstly hosted on Livejournal but was later migrated to Blogger on October 22nd, 2005. During the switch, it was renamed from "jmmv's weblog" to "The Julipedia".This makes the 272nd post which gives an average of 0.37 posts a day. My initial intention was to reach a constant rate of a post per day, but I have been unable to keep up with that goal. I have so much other things to do... but now that the semester is almost over, I hope to be able to post more often.During the whole life time of this blog, there was a single month without posts (August 2004) because I was on holidays. According to the statistics, there are an average of 70 unique visits per day with some random days going over 120. Overall, a total of almost 15,400 unique visits since the migration to Blogger. I think it's in quite good health.Happy birthday and thank you all for reading :-) [Continue reading]

  • Windows Vista Beta 2 review

    It has already been a week since I downloaded and installed Windows Vista Beta 2 on my workstation. I was curious to see what the much delayed final version will finally bring us and how well it would perform on my three year old machine.Just after the installation process, I was greeted by the Aero-based desktop; it turns out Windows decided that my machine was powerful enough to run it. It is true that the new interface has many visual pleasing effects (window shadows, fade ins and outs, a full screen task switcher...) but it is not that similar to Mac OS X as some seem to say.Things as the control panel or the file browser have changed almost completely, in a way that it is trivial to spot dialogs that remain unchanged since XP. I like the new structure but you will need some time to get used to it; some things — specially configuration panels — have changed too much to be remotely familiar.Then there is this new annoying security feature that warns you about every single administrative task you perform and asks for your permission to continue. It seems as a good feature to prevent intrusions from malicious software, but it asks so much questions that the regular user will end up answering without reading (if they are not scared enough to answer, that is). I bet they'd have organized this whole thing in some other way to minimize the amount of questions raised without removing them.Overall, I would like to mention that it behaves quite well and, in my opinnion, it will be a good desktop OS. Unfortunately, some things are desperately slow like, for example, navigating your hard disk while there are other Explorer windows open. And, well... it is not Unix-based, something that could be really helpful for us programmers. I'll stick to NetBSD for that :-)Oh, and given that this is a free beta I have already filled some bug reports in exchange. Now... it's time for me to leave for this semester's first final exam... [Continue reading]

  • Setting up BoostBook under Windows

    In order to have a complete development environment for my SoC project under Windows, I still had to install and configure BoostBook. Why I want this is beyond the aim of this post, but for the curious ones: my NetBSD setup is severely broken and I want to be able to work on documentation when I will be doing the Win32 part.I have spent a lot of time to get BoostBook properly configured, although now that I know the appropriate path it is quite simple. Let's see how.First of all, you need to have xsltproc in Windows. "Easy", I thought; "I can install it through Cygwin". It wasn't that nice when I started to see bash crashing during installation, probably due to some Vista-related issue. I discarded Cygwin and soon after discovered some prebuilt, standalone binaries that made the task a lot easier.So, the required steps are:Get the iconv, zlib, libxml2 and libxslt binary packages made by Igor Zlatkovic.Unpack all these packages in the same directory so that you get unique bin, include and lib directories within the hierarchy. I used C:UsersjmmvDocumentsboostxml as the root for all files.Go to the bin directory and launch xsltproc.exe. It should just work.Download Docbook XML 4.2 and unpack it; for example, in the same directory as above. In my case I used C:UsersjmmvDocumentsboostxmldocbook-xml.Download the latest Docbook XSL version and unpack it; you can use the same root directory used previously. To make things easier, rename the directory created during the extraction to docbook-xsl (bypassing the version name). Here I have: C:UsersjmmvDocumentsboostxmldocbook-xsl.Add the following to your user-config.jam file, which probably lives in your home directory (%HOMEDRIVE%%HOMEPATH%). You must already have it, or otherwise you could not be building Boost.using xsltproc : "C:/Users/jmmv/Documents/boost/xml/bin/xsltproc.exe" ;using boostbook : "C:/Users/jmmv/Documents/boost/xml/docbook-xsl" : "C:/Users/jmmv/Documents/boost/xml/docbook-xml" ;Adjust the paths as appropriate.As you can see, it is quite simple. Just keep one thing in mind: if you try to build some documents and the process breaks due to misconfiguration, be sure to delete any bin and bin.v2 directories generated by the build before you try again. Otherwise your configuration changes will not take any effect. This is what made me lose a lot of time because, although I had already fixed the configuration problems, they were not being honored!For more information, check out the official documentation about manual setup. [Continue reading]

  • Win32: Mappings for Unicode support

    I have spent some time during the past few days to play with the Win32 API again after a year since first looking at them. I must learn how to manage processes under Windows as part of my SoC project, Boost.Process, and this involves native Windows programming with the Win32 API.After creating a fresh C++ Win32 console application project from Visual Studio 2005, I noticed that the template code had a _tmain function rather than a main one. I did not pay much attention to it until I looked at some code examples that deal with the CreateProcess call: they use weirdly named functions such as _tcsdup and types as _TCHAR instead of the traditional strdup and char * respectively. I could not resist to learn why they did this.Spending some time searching and reading the MSDN documentation answered my question. These functions and types are wrappers around the standard objects: the functions and types they really point to depend on whether you define the _UNICODE macro during the build or not.As you can easily guess, defining _UNICODE maps those routines and types to entities that can handle Unicode strings, effectively making your application Unicode-aware. Similarly, if you do not define the symbol, the application remains SBCS/MBCS compatible (the distinction between these two also depends on another macro, as far as I can tell). And because all these redirections are handled by the preprocessor, there is no run-time overhead.For example: the _tmain function is mapped to the traditional main subroutine if and only if _UNICODE is undefined while it is mapped to wmain otherwise. The latter takes wide-character argv and envp pointers in contrast to the former.I do not know to which extent this macro is supported by the standard libraries, although I bet almost everything supports it; I have seen many other functions taking advantage of this redirection. In the specific domain I am analyzing, there are two implementations for CreateProcess: CreateProcessW, the Unicode version; and CreateProcessA, the ANSI one.OK, my knowledge about internationalization is very limited, and I do not know if this feature is very useful or not, but it seems quite interesting at the very least.See Routine Mappings (CRT) and main: Program Startup (C++) for more details.Edit (17:24): Changed MFC references to Win32. Thanks to Jason for pointing out the difference between the two in one of the comments. I am in fact investigating the latter. [Continue reading]

  • Burning ISO images from Windows

    While I was doing some work under Windows this evening, I had the need to burn some ISO files I had downloaded from the MSDNAA. I had just reinstalled the whole system this morning (hint hint, Vista Beta 2) and I did not have any CD recording utility installed.I noticed the "Burn" button when exploring the folder containing the ISOs and I thought that it could allow me to press them to pristine CDs... but it turns out I was wrong. If you have ever used this feature under Windows XP, you know that it only lets you to create new data CDs and burn them, but not burn prerecorded ISO images. It remains the same in Vista.As I was lazy to look for the CD containing the recording utility that came with my DVD unit — and, sincerely, I do not like it that much —, I looked for and tried several free tools that were supposed to allow me do this. Guess what? None of them worked: they could simply refuse to install or fail to detect my drive.Fortunately, this search let me discover the Windows Server 2003 Resource Kit Tools, a set of utilities to ease administration of Windows boxes. These are free and work on several Windows versions, including Vista. Among all the included goodies, there is one that solved my problem: cdburn.exe. OK, fine, it is command-line based but it does the job it is supposed to do.Just as an example, this could burn some_image.iso:cdburn -sao -speed max d: some_image.isoMore on the beta experience on a future post ;-) [Continue reading]

  • Little application with Qt and OpenGL

    As part of the VIG (Graphical Visualization and Interaction) course I took this semester, we had to develop an application using Qt and OpenGL to practice the concepts learned through the semester. The application loads several 3D Studio models using lib3ds, renders them using OpenGL and lets the user control its behavior through a Qt interface. We have handed it in a few minutes ago; finally! :-)The goal of the application is to show a scenario with up to ten cars moving on top of its surface in circles. These cars may optionally have a driver that automatically looks to the closest car in front of them. You can freely inspect the rendered scene (zoom, pan and free movement) using the mouse. You can also adjust several lights and other parameters.Overall, doing this little application has been quite interesting, specially because I was OpenGL-clueless before starting the course and the results are impressive (to my point of view, that is). As regards the code, I mainly focused on the Qt interface while my partner worked more on the rendering code.After having spent many hours in Qt Designer and dealing with the library, I can say that it is very complete and lets you write code extremely quickly. The signals and slots mechanism is very powerful and it becomes specially useful when working in the IDE. If you spend some time extending the predefined widgets to suit your needs, creating a new interface is really easy: just put the pieces where you want them, lay them out and connect the appropriate signals!It is also true that it is very easy to create crappy code. I have to admit that our application is very hackish in some places... but there was no time to fix them to be better. This is mostly because it was not designed beforehand (we did not know all the requirements until a late date) and because of the learning-as-you-do with Qt Designer. It'd certainly be much better if we started it all over again.Now some screenshots for your pleasure :-)First of all, a simple scenario with a single light:The same scenario with a darker light but with a car's lights turned on:The previous scenario but tracking a car's movement from its inside:The car configuration dialog:The lights configuration dialog:There are some more dialogs and features, but oh well, the application itself is useless ;-) [Continue reading]

  • SoC: First commit

    Due to all the university tasks I had to finish, I could not start work on my SoC project eariler than this weekend. Final exams are now around the corner (first one on the 21st, last one on the 30th), but I will have to balance study time and SoC work if I want to make progress in both directions... and I have to!Sincerely, I was lazy to start working on my project because I had to investigate how Boost's build infrastructure works and how to integrate a new library into it. However, as this had to be done, I sat down today and some hours, I passed that barrier. It has not been easy, though: everything is fairly well documented, but it is not organized in a way that a novice can see the overall picture. Now that the basic project files are up, I am really eager to continue working on the project.What I have done today has been to understand how to set up a standalone project using Boost.Build v2 (that is, outside the Boost's source code) and how to set up the basic documentation using QuickBook. The following logical step is to integrate all the notes I took a year ago and complete them with other requirements and useful information.The Boost people kindly set up a Trac system and a Subversion repository for us to work on our SoC projects. So... the above has made its way into my first commit to the tree!And before I forget: this past weekend I started to investigate the MFC to learn how to manage processes under Windows, a requirement for this project. More on this on future posts. [Continue reading]

  • Become productive with Quicksilver

    Quicksilver is, at a first glance, an application launcher for OS X. It lets you search for and quickly launch your applications using predictive lookups. You invoke the application with a keybinding of your choice, type in the first letters of the program you want to launch (as much as it takes to locate it) and hit return. If you have ever used Spotlight, you know what I mean.Even though, Quicksilver is much more than a program launcher. It lets you control the active application or look for files in your machine, making it possible to apply many actions to them with few key presses (again, predictive lookups). For example, you'd copy the Application form.txt file stored in your Documents folder straight to the pen drive you just connected by using as few as 7 key presses. It may sound a lot, but if you get used to it, it is a really quick way to work.But wait! There is much more to it. Quicksilver can be extended by means of plugins. They integrate with other applications such as iTunes, bringing you the ability to "remotely" control them from the keyboard. (For this specific case, I still prefer SizzlingKeys.)This utility is specially useful when you are working at the keyboard and do not want to move your hands away to reach the mouse. Of course, you first need to get efficient with it to really appreciate its power. I have only been using it for a few days, but it certainly improves productivity in some situations.You may want to read this introduction or this intermediate guide by Dan Dickinson in case you try it out.Pity it takes so long to start on my iBook... [Continue reading]

  • Games: Half-Life 2: Episode One

    So... past Saturday (June 2nd), I ran to the closest store and bought Half-Life 2: Episode One, the continuation to Half-Life 2. As you may already know from my Half-Life 2 "review", I am a big fan of this title so I was dying to play EP1. (I know, I know... I still have a lot of work to do — e.g. SoC — but I had to relax a bit.)A lot has been said about this game already, but I wanted to give my own opinion. And what a better place than this. Overall, the game deserves a good score. If you liked HL2, you will certainly enjoy this one because it is more of the same old and well-known things. At first, it feels a bit slow because there are lots of dialogues, not to mention that you go unarmed (except for the gravity gun). This is because the game starts exactly where HL2 ended. Afterward, you get your weapons again and it becomes as active as you'd expect.If you are wondering why I am posting this now, it is I just finished the game today. If I have to say something negative about it is that EP1 feels too short. Its play time is estimated to be around five hours; I surely spent some more, but it still ended too quickly. HL2 was a bit more than twice the price, but it was much, much longer. If EP2 and EP3 are as "short" as this one, they'd benefit from a cheaper price.And until EP2 comes out (will be a long wait...), I will go through EP1 again with the developers' comments enabled to see what I missed :-) Pity my machine is not powerful enough to enable HDR and other quality effects in Source. [Continue reading]

  • Functional programming and Haskell

    This semester, I was assigned a task that was meant to practice the knowledge gathered about the functional programming paradigm during a CS course. The task was to develop an abstract data type for a processes network and a way to automatically convert it to Miranda executable code.A processes network is an idea based on the data flow paradigm: a network is a set of processes that cooperate together to reach a result. A process is an entity that produces a single output based on a set of inputs, which can be other processes or parameters fed in by the user (think of a shell pipeline). The process itself is modeled by a function, either defined in another network or provided by the language natively. A program is then composed of a set of these networks. Functional languages are ideal to implement a program modeled using this paradigm.Our program could be written either in Miranda (the language taught in class) or Haskell. My partner and I decided to go for the latter because it is a live language (Miranda seems dead), it is free and there is much more information for it than for the former. The drawback was that we were on our own learning it and it was really tough to get started, but it has been a very rewarding experience.But why is functional programming so interesting? It is a paradigm where the sole basis of execution is the evaluation of expressions. These expressions are composed of functions (either native ones or defined by the user), so the programmer's task is to write new functions and compose them to achieve the correct data transformation. There is no notion of memory nor variables as in imperative languages. And in Haskell's case, everything just feels correct; if something is not well understood or does not fit the paradigm, it is not included in the language.Here are some of the key items to functional programming; some of them may be Haskell-specific:Functions have no side effects: there are no global variables.There are no loops: algorithms have to be thought in recursive terms. Although this may seem difficult at first, it is not so much thanks to the built-in functions.Everything has a mathematical background, which makes formal proofing easier than with imperative languages. For example, one can define an abstract data type based exclusively on its formal construction equations: in the stack's case, it'd be defined by means of an empty constructor and a "push" one.High-order functions: ever thought to pass a function as a parameter to another one? C++ has some kind of support for this through predicates, but in a functional language this idea is the key to success: it is used extensively and is much more powerful.Lazy evaluation: a neat idea. It makes the treatment of infinite or undefined objects possible. This concept is not generic to the paradigm but is commonly associated with it.Strong typed: Haskell is very strong typed but it does not require you to manually specify types (although you can); isn't it strange? The compiler/interpreter comes with a powerful type deduction system that does the work for you and ensures everything makes sense, type-wise speaking.So far I like the language and the paradigm very much, and I have only grasped their surface. There are tons of things I still do not know how to do, not to mention that it is quite hard to avoid imperative programming thinking. I'm thinking to use Haskell to write at least one of my personal projects to really experience its power.If you have some spare time and are willing to learn something new, give functional programming languages — hmm, Haskell — a try. Just get the Hugs interpreter, the Haskell tutorial and get started! I bet you'll like it ;-) [Continue reading]