Archive for the ‘Ubuntu’ Category

Articles

Jetbrains in Unity integration

In Java,Ubuntu on 02/07/2012 by weirdfellow Tagged: , , , , , ,

I really really love products by . Those guys really know what a developer expects, needs and they deliver. However, the IDEs (I have been using IntelliJ IDEA, as well as PhpStorm) don’t integrate with Unity that well – it’s not possible to pin the icon to launch bar, the windows do not merge and you get duplicate icons etc.

To tackle this problem, you can create custom launchers and drop them into /usr/local/share/applications (you might need to create this directory first).

IntelliJ IDEA.desktop

[Desktop Entry]
Name=IntelliJ IDEA Community Edition
GenericName=Java Editor
Comment=Develop with pleasure!
Exec=/usr/local/programs/idea-ce/bin/idea.sh
Icon=/usr/local/programs/idea-ce/bin/idea.png
Type=Application
MimeType=text/plain;
Categories=Development;
StartupNotify=true
Terminal=false
NoDisplay=false
StartupWMClass=jetbrains-idea-ce

PhpStorm.desktop

[Desktop Entry]
Name=PhpStorm
GenericName=PHP Editor
Comment=Develop with pleasure!
Exec=/usr/local/programs/phpstorm/bin/phpstorm.sh
Icon=/usr/local/programs/phpstorm/bin/webide.png
Type=Application
MimeType=text/plain;
Categories=Development;
StartupNotify=true
Terminal=false
NoDisplay=false
StartupWMClass=jetbrains-phpstorm

The important thing is the StartupWMClass – it allows Unity to identify the windows and connect them to icon in the launcher, so that they merge nicely… Small thing, but makes me so much happier 🙂

Articles

Cannot open Name index using db3

In Ubuntu on 28/09/2011 by weirdfellow Tagged:

I am using Ubuntu 10.04, but often have to work with RPMs – see what’s inside or get the content. And errors drive me crazy – “Cannot open Name index using db3 – No such file or directory (2)” especially.

Eventually I figured it out. If you are getting it, that means the file /var/lib/rpm/Name is missing.

Because I am on Ubuntu and don’t really depend on RPMs databases, I purged the whole /var/lib/rpm directory, and then ran rpm --rebuilddb to recreate them. This created empty /var/lib/rpm/Packages file. Now just copy it as /var/lib/rpm/Name.

Error free environment 🙂

Articles

Compressing RAM with zRam

In Ubuntu on 04/05/2011 by weirdfellow Tagged: , , , , , , ,

A successor to compcache, zram, has been already integrated in the Linux kernel for a while now. This means that no additional compilation nor tweaking is required to benefit from compressing memory on the fly and massively reduced swapping.

As with compache, I wanted to nicely integrate the solution into the Ubuntu Upstart deamon – hence this short article. After a couple of minutes of playing the configuration was ready.

Create file zramswap.conf in /etc/init and put the following content in it.

description "Initializes zram swaping"
 
start on runlevel [2345]
stop on runlevel [!2345]
 
pre-start script
 
# load dependency modules
modprobe zram num_devices=2
 
# initialize the devices
echo 1073741824 > /sys/block/zram0/disksize
echo 1073741824 > /sys/block/zram1/disksize
 
# Creating swap filesystems
mkswap /dev/zram0
mkswap /dev/zram1
 
# Switch the swaps on
swapon -p 5 /dev/zram0
swapon -p 5 /dev/zram1
end script
 
post-stop script
 
# Switching off swap
swapoff /dev/zram0
swapoff /dev/zram1
 
rmmod zram
end script

Now you can start the service with sudo start zramswap (it will be automatically started on after the reboot as well).
You will benefit from 2x1GB swap files, which will be compressed and stored in the RAM. Tested on Ubuntu 11.04.

Articles

Patching Cairo

In Ubuntu on 01/08/2010 by weirdfellow

I had it enough… GTK applications are respecting some of the Fontconfig setting (you can switch antialias or hinting on/off), but others were just ignored (it wasn’t possible to specify hintstyle or switch between grayscale and subpixel antialiasing)… Not only I have had issue with that – in my case the “quasi-bitmap” fonts used for programming look much better with grayscale AA. There were some ad-hoc patches, for instance cairo-respect-fontconfig, but they don’t really fix the problem – just sweep the problem under the carpet.

First of all I had to decode what is used to render fonts in Gnome. After identifying that the bugs are in Cairo, I decided to compile it myself. After a bit of the struggle with missing libraries – thank you Ubuntu for Synaptic Package Manager – I managed to compile Cairo 1.8.10. I have applied patches shipped with Ubuntu and started to look into the problems.

The functions dealing with properties returned by Fontconfig have been rewritten and profusely commented – patch file and binary package available to download below.

Be aware: After the installation, you might notice that the Appearance panel seems not to work. This behavior is intentional and absolutely OK.
Gnome does not save it’s settings in Fontconfig registry, and by default Fontconfig comes with some settings – they are stored in files in /etc/fonts/conf.d. By default they cover switching on antialiasing (10-antialias.conf) and switching on slight hinting (10-hinting-slight.conf). In the result Fontconfig will always override those two settings.

As a workaround, remove those two mentioned symbolic links, and the panel will start to behave correctly again. Files 10-hinting.conf and 11-lcd-filter-lcddefault.conf are ok and should stay in /etc/fonts/conf.d. The long term solution would be for Gnome to save the font settings in the Fontconfig registry too – I am working on the plug-in for gnome-settings-daemon, that would do this.

Downloading

The source of Cairo is available from the project homepage, but I downloaded the source package from Ubuntu launchpad – this version does not require autoconf, you can just call ./configure.

Patching

Ubuntu patches are to be downloaded from here. Each patch is to be executed from cairo-1.8.10 directory in following manner:
$ patch -p 1 <path-to-the-patch-file. After applying Ubuntu patches, you can apply my patch.

Compilation

My version of library would compile, but it was much bigger than the one shipped within distro. Setting environment variables to skip debug information and add some optimizations prior executing configure (export CFLAGS='-Wall -g0 -O0 -O2') helped a lot. After successful execution of configure and make, the result can be found in src/.libs directory. Copy it into the /usr/lib folder and restart X.

Results and downloads

Finally I have fonts that work as I want.

Patch file from Rapidshare
Binary package from in progress.

Articles

Insanity

In Ubuntu on 25/07/2010 by weirdfellow Tagged: , , , , , , , , , , ,

This is just insane…

The number of blog articles, forum posts and standard proposals definitely proves it….

After struggling with it for a while I have finally managed to (at least I hope so) get an overview of the font rendering stack in Gnome… That’s how it looks at the moment (Ubuntu 10.04):

Gnome fonts settings are stored in gconf registry (~/.gconf). They are read by gnome-settings-daemon and automatically published in two places: xrdb – and XSETTINGS. In addition to the Gnome settings, there is the Fontconfig with the handful of configuration files (/etc/fonts/fonts.conf, /etc/fonts/conf.d/*, /etc/fonts/local.conf and ~/.fonts.conf). All settings are combined by Cairo lib (which behaves weirdly when dealing with Fontconfig data – there are a few bugs in there) and Xft is invoked to render the fonts.

xrdb registry can be listed by calling xrdb -query. Getting to see the published XSETTINGS properties is a bit more tricky – but possible with tools provided by xsettingsd project. Install it (there are binaries for Ubuntu) and execute dump_xsettings. It is even possible to get rid of gnome-settings-daemon – useful especially for the KDE guys running GTK apps.

Why the hell doesn’t it look like that? Fontconfig sole purpose is to store font configuration information, why are additional registries introduced?

Appearance panel would need just to create/remove symlinks in ~/.fonts.conf.d/ to files in /etc/fonts/conf.avail or create one own there. There would be 5 of those for default values of: one for hinting and hintstyle, autohint (now still not available through GUI), antialias and lcdfilter. gnome-settings-daemon wouldn’t need to publish fonts settings anywhere… If the gconf must stay, there might be a plugin for gnome-settings-daemon that would publish the gnome font settings in a Fontconfig file, instead of xrdb and XSETTINGS.

It doesn’t sound like rocket science and definitely would make the font settings more consistent. Life would be so much simpler…

Articles

Valid autohinting / hinting style options

In Ubuntu on 25/07/2010 by weirdfellow Tagged: , , , , , , ,

Everyone that ever tried to edit any of the FontConfig configuration files came across the dilemma which hinting to select for your fonts. There are dozens of sample files in the Internet, but noone tells what are the possible valid options and what actually they do.

Today I have been doing some experiments and have found a way to render the same font face with different hinting settings side by side in one window. The conclusion from that is: there are only five different results to be expected out of eight possible combinations of hintstyle and autohint properties.

  • hintstyle = hintnone – switches off the hinting
  • hinstyle = hintslight – switches on the slight hinting (usually results with only vertical hinting but unfortunately not always). Autohint property is ignored and autohinter is always used with this hinting style.
  • hintstyle = hintmedium, autohint = true.
  • hintstyle = hintfull, autohint = true.
  • hintstyle = hintmedium | hintfull, autohint = false – uses the BCI (patented) hinter. In majority it does not matter if hintstyle is set to medium or full – the results are the same.

As an example, the DejaVu Sans with different hinting options.

The difference might not be huge with this font, but with different fonts product more versatile results (Liberation Serif 14pt):

I used a trick with introducing an additional property to the fontconfig – family-old.
In the <match type="pattern"> elements I replace the all the weird font families with something a bit more sensible. But I also store the original family in the family-old property, so later the additional test in <match type="font"> can be performed and properties hintstyle and autohint modified according to the original font family.

This is the .font.config file I have used:

<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
<match target="pattern">
  <test name="family" compare="eq" qual="any"><string>TestFont-ah-none</string></test>

  <edit name="family" binding="same" mode="assign"><string>TestFont</string></edit>
  <edit name="family-old" mode="assign"><string>TestFont-ah-none</string></edit>
</match> 

<match target="pattern">
  <test name="family" compare="eq" qual="any"><string>TestFont-ah-slight</string></test>

  <edit name="family" binding="same" mode="assign"><string>TestFont</string></edit>
  <edit name="family-old" mode="assign"><string>TestFont-ah-slight</string></edit>
</match> 

<match target="pattern">
  <test name="family" compare="eq" qual="any"><string>TestFont-ah-medium</string></test>

  <edit name="family" binding="same" mode="assign"><string>TestFont</string></edit>
  <edit name="family-old" mode="assign"><string>TestFont-ah-medium</string></edit>
</match> 

<match target="pattern">
  <test name="family" compare="eq" qual="any"><string>TestFont-ah-full</string></test>

  <edit name="family" binding="same" mode="assign"><string>TestFont</string></edit>
  <edit name="family-old" mode="assign"><string>TestFont-ah-full</string></edit>
</match> 

<match target="pattern">
  <test name="family" compare="eq" qual="any"><string>TestFont-nah-none</string></test>

  <edit name="family" binding="same" mode="assign"><string>TestFont</string></edit>
  <edit name="family-old" mode="assign"><string>TestFont-nah-none</string></edit>
</match> 

<match target="pattern">
  <test name="family" compare="eq" qual="any"><string>TestFont-nah-slight</string></test>

  <edit name="family" binding="same" mode="assign"><string>TestFont</string></edit>
  <edit name="family-old" mode="assign"><string>TestFont-nah-slight</string></edit>
</match> 

<match target="pattern">
  <test name="family" compare="eq" qual="any"><string>TestFont-nah-medium</string></test>

  <edit name="family" binding="same" mode="assign"><string>TestFont</string></edit>
  <edit name="family-old" mode="assign"><string>TestFont-nah-medium</string></edit>
</match> 

<match target="pattern">
  <test name="family" compare="eq" qual="any"><string>TestFont-nah-full</string></test>

  <edit name="family" binding="same" mode="assign"><string>TestFont</string></edit>
  <edit name="family-old" mode="assign"><string>TestFont-nah-full</string></edit>
</match> 

<match target="font">
  <test name="family-old" compare="eq" qual="any"><string>TestFont-ah-none</string></test>

  <edit name="autohint" mode="assign"><bool>true</bool></edit> 
  <edit name="hintstyle" mode="assign"><const>hintnone</const></edit> 
</match> 
<match target="font">
  <test name="family-old" compare="eq" qual="any"><string>TestFont-ah-slight</string></test>

  <edit name="autohint" mode="assign"><bool>true</bool></edit> 
  <edit name="hintstyle" mode="assign"><const>hintslight</const></edit> 
</match> 
<match target="font">
  <test name="family-old" compare="eq" qual="any"><string>TestFont-ah-medium</string></test>

  <edit name="autohint" mode="assign"><bool>true</bool></edit> 
  <edit name="hintstyle" mode="assign"><const>hintmedium</const></edit> 
</match> 
<match target="font">
  <test name="family-old" compare="eq" qual="any"><string>TestFont-ah-full</string></test>

  <edit name="autohint" mode="assign"><bool>true</bool></edit> 
  <edit name="hintstyle" mode="assign"><const>hintfull</const></edit> 
</match> 

<match target="font">
  <test name="family-old" compare="eq" qual="any"><string>TestFont-nah-none</string></test>

  <edit name="autohint" mode="assign"><bool>false</bool></edit> 
  <edit name="hintstyle" mode="assign"><const>hintnone</const></edit> 
</match> 
<match target="font">
  <test name="family-old" compare="eq" qual="any"><string>TestFont-nah-slight</string></test>

  <edit name="autohint" mode="assign"><bool>false</bool></edit> 
  <edit name="hintstyle" mode="assign"><const>hintslight</const></edit> 
</match> 
<match target="font">
  <test name="family-old" compare="eq" qual="any"><string>TestFont-nah-medium</string></test>

  <edit name="autohint" mode="assign"><bool>false</bool></edit> 
  <edit name="hintstyle" mode="assign"><const>hintmedium</const></edit> 
</match> 
<match target="font">
  <test name="family-old" compare="eq" qual="any"><string>TestFont-nah-full</string></test>

  <edit name="autohint" mode="assign"><bool>false</bool></edit> 
  <edit name="hintstyle" mode="assign"><const>hintfull</const></edit> 
</match> 

<match target="pattern">
  <test name="family" compare="eq" qual="any"><string>TestFont</string></test>
  <edit name="family" binding="same" mode="assign"><string>Liberation Serif</string></edit>
</match> 

</fontconfig>

Line 112 contains the name of the fontface to be actually used while rendering. The test images were generated in Firefox – following HTML/JavaScript document was used to display the content.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>
		<script src="http://ajax.microsoft.com/ajax/jquery/jquery-1.4.2.min.js" type="text/javascript"></script>
		<script type="text/javascript">
function putText( fontFamily, weight, size ) {
	if (!size) size = 14;

	var $span = $("<div><span style='width: 180px; float: left; clear: left;'>" + fontFamily + " " + size + "pt.</span>aąbcćdeęfghijklłoónńsśzźż AĄBCĆDEĘFGHIJKLŁOÓNŃSŚZŻŹ</div>");
	$span.css("font-family", fontFamily).css("font-size", size).css("font-weight", weight);

	$("BODY").append($span);
}

function putSpace() {
	$("BODY").append($("<div>&nbsp;</div>"));
}

function generateHifferentHintingOptions( familyName, fontWeight ) {
	putText ( familyName + "-ah-none", fontWeight );
	putText ( familyName + "-nah-none", fontWeight );
	putSpace();

	putText ( familyName + "-ah-slight", fontWeight );
	putText ( familyName + "-nah-slight", fontWeight );
	putSpace();

	putText ( familyName + "-nah-medium", fontWeight );
	putText ( familyName + "-nah-full", fontWeight );
	putSpace();

	putText ( familyName + "-ah-medium", fontWeight );
	putSpace();

	putText ( familyName + "-ah-full", fontWeight);
	putSpace();
}

$(document).ready(function(){
	generateHifferentHintingOptions( "TestFont", "normal" );
});
		</script>
	</head>
	<body>
	</body>
</html>

I mentioned ealier that usually I prefer the autohint + hintslight combination. There are some rare exceptions I identified with this method. What are your preferences?