Search Results: "Joachim Breitner"

18 June 2011

Joachim Breitner: Better PDF screenshots with gtk 3

Half a year ago, I experimented with gtk+ and cairo to extract a PDF screenshot out of a progam, i.e. a screenshot of the window that is not a table of colored dots as a regular PNG file would be, but rather a vector graphic that scales perfectly and has selectable text. The main use that I see is documentation: A scalable screenshots looks much better in print, and even in an online-PDF-file, having the full-text-search also find the text in the images is useful. My experiments back then were successful in a proof-of-concept way, but they were very ugly hacks. With the new version 3 of gtk+, though, things become much easier, as only one cairo context is used, instead of each widget creating its own context to draw on. By now, the first gtk-3 applications have reached Debian unstable, so I thought it would be time to re-do the experiment. And the result is very pleasing: The pdf screenshot program comes as a gtk module that you can load by setting an environment variable before launching a gtk-3 program. The application will run as usual, but there is an additional PDF screenshot button. If you click it, you get a Save File dialog (with a nice, live-updated preview of the screenshot, as an additional gimmick) that lets you save a PDF file. Its as easy as that. You can check out the resulting PDF file of gucharmap and a screencast of me creating that file, including copy n pasting from the resulting document.
<video controls="true" height="592" preload="none" src="http://www.joachim-breitner.de/various/pdf_screenshot_3.ogv" tabindex="0" width="800"> Your browser does not support the video tag, but you can still download and view the screencast with the above link. </video>
PS: I would offer the video as well on YouTube, but it seems it does not accept Ogg Theora videos. I hope all of you can make use of the above links.

13 June 2011

Joachim Breitner: 401 page family book published

Over the course of the last five years, some relatives of me and I have been working on a family book which lists all descendants of my grandgrandgrandgrandfather Isaak Riehm, born 1799, and his wife Charlotte. My task was everything related to maintaining the data, running the infrastructure and generating the final book. In the end, we have collected biographical details, often with the person s live story, of 703 descendants, 285 partners and 416 parents-in-law. Together with an extensive preface the book now has a respectable size of 401 pages, includes 144 pictures and maps and over 200 copies have been printed and sold through the family.
The book cover
Although I do not think that the details of the lives of my family is very interesting for the general public, or even suitable for general release, I do want to show the fruit of our work. Therefore, I have created a stripped-down on-line version that only covers the first four generations. I bundled the book body with the cover and the end sheets into one complete PDF file (caution, large: 54MB, and of course in German). Some nifty embellishments of the book that I especially like are the abstract looking descendant fan in the front-end and back-end sheets, the separating bars between the persons which indicate the livespan of that person between 1799 and 2011 and the maps of the birth places and Isaak s travel destinations in the preface. Now to the technical details: Naturally, I used only Free Software in the genesis of the work (The cover is an exception, as it was not created by me). The most important is definitely gramps, a free genealogy system that held all our data. It is written in python and extensible with plug-ins, so I was able to create a custom report that takes the data relevant for us, filters for people who have agreed to appear in the book, and then generate LaTeX code that typesets the book, ready to be printed. I learned a great deal of LaTeX for this project, which uses over 30 different packages and required me to create a font of my own (which, as a side product, lead to a publication in the Linux-Magazin). For the maps I found the Generic Mapping Tools (GMT) and the freely available data for that of great use. I still had to manually collect the coordinates for all the places I wanted to show up in the map. Here, I relied mostly on Wikipedia. The fan which appears in the end sheets is laid out using a Haskell program (naturally, I have to use Haskell somewhere).
The front-end sheet
Of course, generating the book is only one side of the story; first, the data has to be collected and edited. For that, I wrote a plug-in to gramps that creates forms for each person. These forms contain the current known data and are used to correct and extend our knowledge. One variant of the form, created using LaTeX, was printed and mailed by snail-mail around the country and beyond, for those who are not reachable by mail. The other variant is an HTML form, hosted on a password-protected web site. Changes to that form cause the server to send an e-mail with a description of the changes (and only the changes, not the fields that are left untouched) to the mailing list of our team. There, the changes can be reviewed, e.g. for spelling and stylistic issues, and finally I copy n pasted them into gramps. These parts are implemented in python as well. Since genealogical data is never complete or up-to-date, I have set up a password-protected mediawiki based web site for the book where we collect corrections and additions to the data in the book. We have never anticipated that it would be so much work and that it would take us so long to finish this project, but we pulled it through and we are very happy with the result. Also, the reception has been very good and it was definitely a success. At this point I d like to express my gratitude to the hundreds of Free Software developers out there whose code we used and without whom it would not have been possible publish the book in the current form at all! Update: Due to some requests, I am making the code that I wrote available. You can download the tarball. Note that the code is a big mess and will not be usable right away. I guess if you can get the code to run and actually adjust to your needs, then you can as well write it yourself. Nevertheless it might be useful as inspiration or reference.

3 June 2011

Rapha&#235;l Hertzog: My Debian activities in May 2011

This is my monthly summary of my Debian related activities. If you re among the people who made a donation to support my work, then you can learn how I spent your money. Otherwise it s just an interesting status update on my various projects. I have been Doing some work towards Debian Rolling At the start of the month, the discussions about Debian rolling were still very active on debian-devel. Declaring that testing would be rolling did not make it (as I hoped), the argument that some RC bugs last for far too long in that distribution carried the discussion and thus the most consensual proposition ended up being the one of Josselin Mouette were rolling would be testing plus a few selected cherry-picked packages from unstable. I believe it s a workable solution if we only care about a subset of architectures. Otherwise the same reasons that keep the fixed packages out of testing would probably also apply for rolling. Given this, I did setup britney (the software that controls testing) on my laptop to investigate how we can create rolling. It turns out britney is a very specialized software with very few configuration knobs. At the same time Joachim Breitner made a proposition that immediately grabbed my attention. He suggests to use SAT solvers to find out the set of packages that should migrate from unstable to testing. I thought that rolling would be a good testbed for this new implementation of britney (which he calls SAT-britney) so I jumped right in this project. I was not at all familiar with this science field, so I looked up quite some documentation: I learned that all SAT solvers expect the problem to be presented in CNF form, and that DIMACS was the file format of choice to represent those boolean constraints. Several SAT solvers are available in Debian and picosat appears to be one of the best. Then I started some early coding/prototyping to play with the concept. You can find the result in this git repository, you can grab a copy with git clone git://git.debian.org/~hertzog/sat-britney.git. There s not much yet, except some Python code to generate a SAT problem that can be fed to a SAT solver. But I really look forward to this project. Representing Debian during Solutions Linux During the second week, I spent 3 days in Paris to help manage the Debian booth at Solutions Linux. We have responded to lots of queries but most visitors already knew Debian, and many of them use it at work and/or at home. We tried to recruit those people as new members for Debian France, the local association. We also sold all our remaining goodies. The Ubuntu people were interviewed by France 3 (an important TV channel) and we took this opportunity (with the consent of the Ubuntu guys) to show our Debian t-shirts in the background: you can watch the video here (in French), you can see me with Carl Chenet at 1:21. We have also been interviewed by Intelli n TV: here and here (both in French). I m not very good at this exercise. :-) Improving dpkg triggers The third week was a vacation week, in theory I should have stayed away from my computer but I really wanted to take this opportunity to improve the state of dpkg triggers in Debian. I already covered my work in another article: Trying to make dpkg triggers more useful and less painful. The result is not merged yet, I just asked a question to all package maintainers who are using triggers to be able to decide whether I ll merge it as is, or if I can make the new behavior the default one. Supporting users after Alioth s migration When I came back from my vacation, many services provided by Alioth.debian.org were non-functional after a migration to a new setup that involves two machines instead of one. Given that I used to be an Alioth admin, I know that in those periods you tend to be get bogged down on many user support requests. So I re-joined #alioth on IRC and tried to help a bit. I did investigate some of the reported problems and prepared fixes (updated scripts, configuration files, etc.) for some of the issues. I also created a list of remaining issues that should have lasted only a few days but that s still active because there are still regressions left. The most important things still missing are: Improving the 3.0 (quilt) source format I have made some proposals to change the way the new source format would work. The goals are to be less painful for packagers who are using a VCS, and to avoid unexpected changes slipping through a new patch generated by dpkg-source. It seems that the proposals are relatively consensual so I ll implement them at some point. Missing in action on my blog I did a lots of stuff for Debian between travel and vacation, and in the remaining time, I did not manage to write many articles for my blog. In fact, besides the article on my triggers work mentioned above I only published one interview: People behind Debian: Steve Langasek, release wizard. I ll try to do better this month! Thanks Many thanks to the people who gave me 151.61 in May. See you next month for a new summary of my activities.

One comment Liked this article? Click here. My blog is Flattr-enabled.

2 June 2011

Joachim Breitner: Satire on Gender Issues at IIT Bombay

IIT Bombay, like most likely most Indian educational instituates, has some rules and regulations about the interaction between boys and girls that, at least to the uninitiated eye of a foreigner who was brought up in a liberal society, seem arbitrary and archaic. At IIT Bombay, for example, there may be no visits in hostels by students of the other gender (yes, there are separate boys and girls hostels) between 10pm and 7am, and during the day any such visit has to be registered at the reception security guard. And when there was need for more room for girls and they reassigned one wing of a boys hostel to the adjacent girls hostel, they closed the connection by bricking it and split the lawn by a fence. With barbed wire on top. I took this as a theme for a satirical inspection of these policies which comes to the conclusion that IIT Bombay is a very progressive institute that puts these rules in place as affirmative action towards same-gender relationships. After some discussion with the editors the text got actually published in the institutes bi-monthly newspaper Raintree , unfortunately only now, two weeks after I left India. You can read the text on the bottom of page 8 in the 6MB PDF file. I cannot predict how it will be received, but at least Utkarsh Raut, who illustrated the text, clearly got the message right. Thanks for the nice and very fitting drawing!

27 May 2011

Joachim Breitner: Conditional Elimination through Code Duplication

My Advanced Compilers course at IIT Bombay under Prof. D. M. Dhamdhere also involved a group project. Our group had the task to pick an existing compiler optimization which works by restructuring the control flow graph of the code, and implement that in LLVM. As we did not quickly find a suitable optimization, I came up with a simple idea by myself. At first, our professor was not really pleased by this move, but after the second presentation or so, when the ideas were more streamlined and we noticed how simple yet possibly widely applicable the transformation is, he allowed us to carry on with it. I concentrated on the theoretical part, writing a paper describing it, while the others in the team implemented parts of it as a pass for the LLVM compiler. The idea is simple: If within one execution of a program the same conditional expression (e.g. a variable debug_enabled) is evaluated several times, then it might be faster to copy the code in between the conditional jumps and thus remember the result without further conditional jumps. Of course this increases the code size, and there is a trade-off, but in some instances the benefits could well be the worth the effort, especially inside tight inner loops. You can read more about it in my paper about CECD, and I m considering uploading it to arxiv.org as well.

21 April 2011

Joachim Breitner: A talk on Church s result about the Entscheidungsproblem

A newly founded Logic Group in Mumbai, which seems to be a private thing but some professors from the IIT Bombay are taking part, has approached me and asked if I can give a talk about Church s lambda calculus and how he used it to show that Hilbert s Entscheidungsproblem is not solvable. They are starting a series of talk on logic on the occasion of Turing s 100th birth year and because I am finally leaving the IIT campus in two days, my talk turned out to be the opening talk for the series. Roughly guessed about fifty people attended, some professors but most of them students from fields other than mathematics and computer science I hope that they were not too confused by distinguishing truth and provability, expressability and computability, of which I did not give a proper explanation.
I started with a historical exposition of the state of logic in the beginning 20th century, then gave an introduction to lambda calculus, encoding of natural numbers in then, G del encoding. Finally I sketched the proof of the unsolvability of the question whether a lambda term has a normal form and then concluded by showing how this implies that the Entscheidungsproblem is not solvable.
I have before hand written out the talk in full, and again I ended up saying completely different things or at least said things completely different. Nevertheless, I am sharing the (planned) text of my talk, including the timeline that I draw on the whiteboard.

15 April 2011

Joachim Breitner: Vizing s theorem proved using Event-B and Rodin

As the project for the course System specification and implementation , which introduced the Event-B formalism to us, I modeled the algorithm given in one of the constructive proofs of Vizing s theorem and showed it to be correct, using the Event-B tool Rodin. Vizing s theorem states
For a finite undirected graph without autoloops and without multiple edges, at any vertex of which no more than N edges meet, N+1 colors suffice for an edge coloring such that edges incident on the same vertex are of different color.
You can find more details about my approach and my conclusions about Event-B and Rodin in the project report and you can download my Rodin model. I was asked in the comments about my conclusions, so I ll reply here. The proof looks unweidly, but I do think that refinement based proofs, where possible, increase clarity, as more, but smaller steps have to be looked at. Also note that I had no prior exposure to Rodin, so some thing could have been done quicker and easier with more experience. But Rodin itself is not the theorem proving tool of my choice. More detail in the report, shortly put: Its math is too weak and not expressive enough, individual proofs are WORN (write-once-read-never) and can easily be lost when changing the models and there is too little emphasis on correctness, e.g. no trusted core base approach known from dedicated theorem provers. So I would use a different tool for proving mathematical statements, nevertheless the idea of refinements, and trying to find those small-steps-refinements, can also help coming up with better proofs in those tools.

13 April 2011

Joachim Breitner: Pornyness calculator pimped up

My brother was so kind to improve the looks of the Pornyness Calculator which I recently presented here a small web application that tells you how porny a given word is, by comparing the filtered and the non-filtered Google Image search results. The new look is slightly unsuitable for work, so the plain old version is still available.

2 April 2011

Joachim Breitner: The general triangle, formally

My third submission to the Archive of Formal Proof has been published yesterday: A proof that there exists exactly one general triangle. Given that yesterday was the first of April, this is obviously not meant too be taken too serious; nevertheless it is not a prank either: The math is sound and now even formally verified using Isabelle.

2 March 2011

Joachim Breitner: Tor exit node shut down by server4you

As mentioned earlier this week, I changed the server for my hoster from server4you to Hetzner. Because the contract for my old server is still running until the 14th of April, I thought I can make some good use of it by running an Tor exit node on it. Tor, The onion router is a world-wide network of server to anonymize network connections, and used for example by freedom-loving people in repressive countries, or by Facebook users in repressively proxied university networks Naturally, such a system is also used by people with lesser motives, and after nearly one week of running the server, some complaints were reaching server4you a honeynet supposedly detected botnet activity from my IP address, another company hired by Paramount Pictures claimed that someone downloaded Iron Man 2 over BitTorrent via my server. These were forwarded to my by server4you, demanding an explanation. I explained that I am running a Tor node, that such things are unavailable, and that neither I nor server4you is going to be held responsible. Nevertheless, they insist that I should stop whatever I am doing (I am not sure if they really understood what tor is), and when I said that I won t, they decided to unilaterally and immediately end my contract by tomorrow. Thus a powerful exit node that might have made life better for Tor users is doing to disappear again. They will not reimburse the advance fee that I had paid in advance and made a non-specific threat about further claims they might have. So server4you was, at least in my case, not only an unreliable and inflexible provider, they also prefer to cut off their customer s server just because of two complaints by third parties. I conclude that this is not a hoster that you should trust important services to. And I am not a unique case: There are reports of similar server shut-downs by server4you (in German).

1 March 2011

Joachim Breitner: Nomen est Omen

Google provides a handy image search, and given that the Internet is for porn, it is a good thing that they provide a filter that tries to remove pornographic images. This allows us to define the pornyness of a name (or of any word): It is the percentage of images found by Google that are removed when enabling the SafeSearch filter. For those who want to find out the pornyness of their name without having to count pictures that are NSFW, I have created the pornyness calculator. The range of values goes from 0% (for Ursel) to 97% (for Aletta, exact percentage depends on your location, it seems). This is implemented by some simple JavaScript in a static file, and using Google s API. PS: It was pointed out to me that Maschinenbau (civil engeneering) has a score of 0%, but Mathematik (mathematics) has a score of 2%. Feel free to add more interesting results to the comments.

23 February 2011

Joachim Breitner: Goodbye server4you

My server, which is among other things hosting this weblog, is a dedicated server originally hosted by the German webhoster webperoni. It was a bargain at that time, and still a good price, and I was satisfied with webperoni s performance and reliability. Unfortunately, they were taken over by another web hosting company, best known for their server4you brand. They moved my server to a different data center and continued to run it there. Unfortunately, server4you was less reliable and less flexible than my original hoster: For example, when one sector on the hard drive turned bad, they were not able to put in a new drive in my system, let me mirror the content, and then remove the old drive. In another, even worse, instance, my second IP address, which I bought from webperoni, was given to another customer. When I finally noticed and complained, they refunded me the charges that I paid for the IP. But understandably, I wanted to get away from that hoster. The contract is automatically prolonged for one year if not canceled in time, and I missed the deadline last year. This year, I finally got around to rent a slightly better and slightly more expensive server from Hetzner, which whom I already made good experience. I would have preferred to switch when I am back from India, but server4you would not even let me prolong the contract by just two months only a whole year or nothing. So they got nothing, and I started to work on the move yesterday. At first I set off installing the new system from scratch, setting up all the various services and copying over data and configuration. But quickly, I gave up and moved the system by completely by copying programs, configuration and data from the old server. The new system has its root partition on a LVM share on software RAID, and now uses grub2 to boot. I had a hard time to get it booting, and a hard time to debug the issues without access to the physical console. I finally understood the problem by running kvm -hda /dev/sda -hdb /dev/sdb -curses from the recovery system and observing that the initial ramdisk is having problems finding the root partition. The problem was that I thought addressing partitions via file system labels is the way to go now and manually added root=LABEL=root to the Linux command line in /etc/default/grub. But then the initial ramdisk would not activate the logical volume. If I had just left it to the grub package, which inserted root=/dev/mapper/vg-root, everything would work fine. The new IP address (88.198.48.143) has not propagated throughout the Internet yet. Running the following command for a variety of ports on the old machine (80.86.81.20) makes sure nobody notices:
port=443
iptables -t nat -A POSTROUTING -p tcp --dst 88.198.48.143 --dport $port -j SNAT --to-source 80.86.81.20
iptables -t nat -A PREROUTING -p tcp --dst 80.86.81.20 --dport $port -j DNAT --to-destination 88.198.48.143:$port
The only question remaining is: What to do with the old server for the remaining six weeks? I am considering to erase the system, set up a plain Debian system and run a tor/freenet/whatelse node at full speed.

11 February 2011

Joachim Breitner: First day of GNUnify 11

The first day of GNUnify 11 has passed. My talk on Haskell went, as far as I can tell, well. Attendance was good (rough estimate: just above 50), although it was not as packed as later talks, and there some questions being asked. There were some technical problems with the microphone, I m not sure how that affected the people sitting in the rear rows. Also, I fear that the video recording of the talk might have suffered we will see. Later throughout the afternoon and evening I would repeatedly find myself cornered by five to ten students of SICSR who would question me about Haskell (Why should I learn it, where is it used, how is different from Java?) mostly volunteers who were busy and thus unable to attend the session. I think I got some of them at least curious about Haskell. I did attend a talk on virtualization and a short demo of GNOME 3 and otherwise just talked to people or sat in the speakers corner. The pampering by the organizers continued if I would stand for half a second with a slightest, even false, hint of help-needing on my face, they would ask me if I need any thing. When I pass they would step back to free the path. It made me feel a bit uneasy, but I figured that normal behavior in the Indian culture and they, being hosts to me, would not feel comfortable any other way. We had dinner at the side of the pool of the Symbiosis university, and more interesting talk happened. So far, nobody seemed to be interested in GPG keysigning, maybe I should give a talk about GPG and the web of trust next time.

Joachim Breitner: GNUnify started

Yesterday night I arrived in Pune for the GNUnify conference where I m a speaker. I should speak more often at such conferences, they really pamper the speakers: I was picked up with a car from the train station, brought to a posh restaurant where other speakers were already dining and afterwards accommodated in the guest house of the Symbiosis University, which means a spacious room with my own bathroom (with running hot water) and best of all: Internet connectivity after midnight! Tonight I was alone, the next night I ll be sharing it with another speaker.
Today we had breakfast at the conference venue and the first talks started. I attended a talk about Openmoko, but nothing new to me so far. I was happy to see Debian listed as one of the Distributions for the FreeRunner, given that I once co-initiated that port. Nevertheless it could not bring me to try using the FreeRunner again, reliability is just not good enough. I asked for the next best (in terms of freedom and geek-compatibility) phone, but there is no obvious good answer. The n700 seems to be a dead end, given that Nokia might ditch Meego. The Geeksphone sounds like a good candidate, but is out of stock. My Haskell talk will start in 30 minutes. I hope I ll reach my audience and haskell-cafe will see more Indian names soon... The talks are recorded. I guess I should have dressed better.

3 February 2011

Joachim Breitner: I m going to talk at GNUnify 2011

I have submitted an talk about the Haskell programming language to the organizers of GNUnify, a Free Software conference in Pune, India, on 11th and 12th of Februrary, and they accepted. The talk will be similar to the one I gave to the FOSSEE group. If you are at GNUnify and want to exchange key signatures or chat, just talk to me.

23 January 2011

Joachim Breitner: A Mistake in Church s Paper

For a course at the IIT Bombay on functional programing, I was preparing a presentation on Alonzo Church s theorem, based on his original 1936 paper An Unsolvable Problem of Elementary Number Theory where he first showed that the Entscheidungsproblem is not solvable. In that paper, he states a theorem (Theorem II) If a formula has a normal form [ ] any sequence of reductions of the formula must (if continued) terminate in the normal form . This seems to be wrong. Consider the lambda expression KI , where K=( xy.x), I=( x.x) and =( x.xx)( x.xx). This has a normal form I. But because reduces to , there is a non-terminating sequence KI KI , in contradiction to Church s claim. The same example contradicts his Theorem III: If a formula has a normal form, every well-formed part of it has a normal form. , which is used in the very proof of his main result, Theorem XVIII. There is no proof for Theorem II in this paper. He cites it from the then forthcoming paper Some properties of Conversion by him and J. B. Rosser. There, proofs are given (see Theorem 2 and its Corollary) but they are quite impenetrable to me. So I was searching for some correction paper, or any other discussion of this issue, but could not find any. Does any reader of this blog know more? What happened in that times when a paper had an error in some proof? What would happen now? Or is this not an error after all, but just a subtle difference between the definitions of -calculus as we know and as they introduced it? Unrelated to this question: The professor asked me to write down a summary of (my interpretation of) the importance and impact of Church s paper with regard to G del and Hilbert s program, and how that relates to B hm s theorem. In the spirit of sharing, I have uploaded my thoughts on Church and B hm, comments are welcome. Update: Christian von Essen solved the riddle in a comment to this post: Church only considers lambda abstractions as well-formed when the bound variable actually occurs (freely) in the abstracted term. This does not allow for the K combinator and thus there is no problem.

21 January 2011

Joachim Breitner: Haskell Demonstration at IIT Bombay

Yesterday, I held a small Haskell demonstration talk at the FOSSEE group, an advocacy group for Free Software in engineering education located at the IIT Bombay in Mumbai, India, where am I currently staying as a visiting student. We had to move out of the proper lecture hall into a small room with no projector, due to an exam taken in the other room, but as the audience was small enough (seven people), using an LCD monitor was sufficient. My talk explained some the features of Haskell, namely functional, pure, lazy, strictly typed, interpreted or compiled and its library ecosystem (often forgotten in academical treatments of Haskell), and then demonstrated these features by some live coding action where I used the nice gloss vector library to render drawing commands given in a comma-separated value files, which is also parsed by a library from hackage. I have put the slides, the example csv file and the code online.

23 December 2010

Joachim Breitner: Going to IIT Bombay, Mumbai, India

Next monday, I will by flying to Mumbai, India, to spend one semester studying computer science at the Indian Institute of Technology Bombay. Slowly, I m getting excited. I will write about this trip here, as I did for my Ghana travel, and upload pictures to my online photo album. If you are in Mumbai and interested in Debian, Haskell, Isabelle, GPG Keysigning or similar stuff, drop me a mail. And if you are at IITB, just come by, I ll be staying in hostel no. 13 (room number not known yet). Namaste!

16 December 2010

Joachim Breitner: Giving up on the FreeRunner (again)

More than two years ago, I got the most proper free mobile phone ever created, the Openmoko FreeRunner. Unfortunately, things did not go very well. At first, the device was affected by the infamous buzzing hardware issue, making it unusable as a phone. This could be fixed, but even then the device was not reliable: At times, it lost, without any indication, the GSM connection and I d start missing calls; and the audio quality was still an imposition for people trying to talk to me by telephone. I tried to stick to it for almost one year now, using it as my daily phone and hoping that things would get better, but my patience (and the patience of the people around me) have come to an end. So I m finally reviving my old and trusty Siemens S35 phone. I am eying the Nokia N900 phone, which is the most interesting phone for Free Software supporters at the time and, from what I hear, does not suffer from any of technical issues the FreeRunner had. But for now I ll be content if people can reach and hear me reliably, and for that I don t need a new, expensive phone.

26 November 2010

Joachim Breitner: Screenshots as vector graphics

Recently, I was considering the following set of statements: Vector graphics are great, especially in print. Program documentation needs screenshots. Usual screenshots are not bitmaps. Some programs use gtk. Gtk uses Cairo to render most of its display. Cairo can generate PDF. PDF is a vector graphics format.
And while I was doing so, for some reason, I thought: Wouldn t it be great if I my gtk programs could generate vector PDF files of their screen content? And after some experimentation, I was able to extract this PDF file from the buttonbox example program (see here if you do not see anything below):
<iframe height="300" src="http://www.joachim-breitner.de/various/pdf_screenshot.pdf" width="80%">Use the link above</iframe>
This works without any modification to the original program. Instead, I am loading some code using LD_PRELOAD that overrides the cairo_xlib_surface_create function and creates a PDF surface instead. It also monitors calls to XCopyArea to observe where on the window gtk (gdk actually) paints the resulting image. Then I combine these PDF files (6 in this example, theoretically a lot more) using a latex document and I must say, the result is pretty good for a start: All lines are vector lines, the text really is text (and not just rendered pixels), so you can actually copy n paste from it. Of course this is but a proof of concept and has several problems: I don t think I ll fix that myself, as I had my fun. But maybe it can inspire a more useful tool exploiting this idea, and maybe there are cleaner approaches (for example special gtk theme engines, or by patching gtk).

Next.

Previous.