ttf-telugu-fonts and ttf-kannada-fonts ignored due to missing lang field in fonts.cache-1

Bug #48280 reported by Suraj N. Kurapati
26
Affects Status Importance Assigned to Milestone
ttf-indic-fonts
Fix Released
Unknown
ttf-indic-fonts (Baltix)
Fix Released
Undecided
Unassigned
ttf-indic-fonts (Debian)
Fix Released
Unknown
ttf-indic-fonts (Ubuntu)
Fix Released
Medium
Soumyadip Modak

Bug Description

= Problem =

The Telugu fonts provided by the ttf-telugu-fonts package (version 0.4.7) are effectively ignored for rendering Telugu text in Dapper because the /usr/share/fonts/truetype/ttf-telugu-fonts/fonts.cache-1 file lacks a lang=te field. In fact, the lang field is *empty* in that file! As a result, fc-list fails to detect that the Telugu fonts provided by that package should be used to render Telugu text.

The same problem applies to Kannada fonts provided by the package ttf-kannada-fonts (see below).

For example, here is the situation before the fix:

$ fc-list :lang=hi
Samanata:style=Regular
Gargi_1.7:style=Medium
FreeSans:style=Medium,navadno
Chandas:style=Regular
Lohit Hindi:style=Regular
$ fc-list :lang=te
$

Notice that fontconfig correctly detects that the Hindi fonts provided by ttf-devanagari-fonts should be used to render Hindi text. This is because that package correctly defines the lang field in its fonts.cache-1 file.

However, notice that fontconfig does not detect any fonts that should be used when rendering Telugu text (because ttf-telugu-fonts does not define the lang field properly in its fonts.cache-1 file).

The result of this situation can be seen in this screenshot (see attachment). Here the Telugu text is incorrectly rendered, and many glyphs are entirely missing (shown by Unicode hexadecimal boxes).

= Solution =

Replace the blank "lang=:" field with "lang=te:" in the /usr/share/fonts/truetype/ttf-telugu-fonts/fonts.cache-1 file:

$ sudo sed -i.orig 's/lang=:/lang=te:/g' /usr/share/fonts/truetype/ttf-telugu-fonts/fonts.cache-1

Afterwards, you will see that fontconfig properly recognizes the Telugu fonts provided by ttf-telugu-fonts package:

$ fc-list :lang=te
Pothana2000:style=Regular
Pothana2000,Vemana2000:style=Regular

As a result, Telugu text is now correctly rendered using the Telugu fonts provided by the ttf-telugu-fonts package, as shown here (see attachment).

= Further work =

To my knowledge, the fonts.cache-1 files are generated by the fc-cache command. Thus, the previous "solution" is a temporary fix.

We need to determine and fix what is causing the ttf-telugu-fonts package to *not* provide fc-cache with the correct lang=te information.

Revision history for this message
Suraj N. Kurapati (sunaku) wrote :

This bug also affects the following font packages:

$ find /usr/share/fonts/truetype -name fonts.cache-1 | xargs grep -l 'lang=:'
/usr/share/fonts/truetype/openoffice/fonts.cache-1
/usr/share/fonts/truetype/ttf-kannada-fonts/fonts.cache-1
/usr/share/fonts/truetype/ttf-telugu-fonts/fonts.cache-1
/usr/share/fonts/truetype/latex-xft-fonts/fonts.cache-1

description: updated
Revision history for this message
Suraj N. Kurapati (sunaku) wrote : Incorrectly rendered Telugu text in Dapper

This is how Telugu text appears on a fresh install of Dapper + the ttf-indic-fonts package.

Revision history for this message
Suraj N. Kurapati (sunaku) wrote : Correctly rendered Telugu text in Dapper

Here is how Telugu text appears after the solution described in this bug report has been applied.

description: updated
Revision history for this message
Suraj N. Kurapati (sunaku) wrote : Fixed fonts.cache-1 file

This is a fixed /usr/share/fonts/truetype/ttf-telugu-fonts/fonts.cache-1 file, which produces the correct Telugu text rendering.

Revision history for this message
Soumyadip Modak (soumyadip) wrote : Re: ttf-telugu-fonts ignored due to missing lang=te field in fonts.cache-1

Thanks a lot Suraj for the amount of information you provided. Yes ttf-indic-fonts is due for an overhaul, and I'll do it as soon as possible. Meanwhile do me a favour and alsofile a bug report against ttf-indic-fonts in Debian. Thanks a ton for all the info you digged up

Changed in ttf-indic-fonts:
assignee: nobody → soumyadip
status: Unconfirmed → Confirmed
Revision history for this message
Suraj N. Kurapati (sunaku) wrote :

I have filed the bug upstream to Debian (debbugs 370385) as you requested.

Revision history for this message
Suraj N. Kurapati (sunaku) wrote : also affects ttf-kannada-fonts

I just confirmed that this bug also affects rendering of Kannada text. Please see the attached screenshots for evidence.

= Solution =

Same procedure as before, except for Kannada language.

$ sudo sed -i.orig 's/lang=:/lang=kn:/g' /usr/share/fonts/truetype/ttf-kannada-fonts/fonts.cache-1

Revision history for this message
Suraj N. Kurapati (sunaku) wrote : Incorrectly rendered Kannada text in Dapper

Same symptoms as the incorrectly rendered Telugu text. There are missing glyphs depicted by Unicode hex boxes.

Revision history for this message
Suraj N. Kurapati (sunaku) wrote : Correctly rendered Kannada text (after fix)

After the fix, Kannada text is correctly rendered in gedit.

description: updated
description: updated
Revision history for this message
Soumyadip Modak (soumyadip) wrote :

Well it is apparent that somehow fc-cache doesn't find the information required to generate the appropriate fonts.cache-1 file from the fonts themselves. In my opinion we should be looking into the metadata contained in the fonts themselves

Revision history for this message
Soumyadip Modak (soumyadip) wrote :

Does having a custom .fonts.conf (in the home directory) help to choose the appropriate font for Telugu and Kannada ?

It is quite possible that this issue also affects ttf-malayalam-fonts. fc-list :lang=ml says :

FreeSerif:style=Medium,navadno

Revision history for this message
Suraj N. Kurapati (sunaku) wrote : .fonts.conf for Pothana2000

I tried this .fonts.conf to force recognition of Pothana2000 font for lang=te, but it did not work.

Maybe I did not use the correct syntax; please have a look.

Revision history for this message
Suraj N. Kurapati (sunaku) wrote : Re: metadata in fonts

I agree, fixing the metadata in the fonts themselves is the best approach.

We should see how ttf-hindi-fonts define the lang= field in their metadata and update the Telugu, Kannada, and Malayalam fonts accordingly.

Revision history for this message
Sunil Mohan Adapa (sunil) wrote :

As I have written in https://wiki.ubuntu.com/HowtoFixIndicFontRendering, giving priority to Pothana2000 in ~/.fonts.conf is same as doing it in /etc/fonts/local.conf and it works (I don't know about specifying lang=te for a specific font in fonts.conf).

While I agree that Telugu fonts should be fixed to have lang=te recognised by fc-cache, I don't think that this is proper solution to the problem. This is because FreeFont one day will also fix itself to contain lang=te and then the prioritisation problem will reapper. In an ideal scenario, we will have multiple Telugu OpenType fonts on the system and we will have to have a default font set somewhere in the system. For other languages (atleast for Korean?) this has been set in /etc/fonts/fonts.conf. All Indian languages should have the default fonts set somewhere for "sans" "serif" and "monospace".

Revision history for this message
Suraj N. Kurapati (sunaku) wrote : Re: assigning priority through fonts.conf

Thanks for the solution on that wiki Sunil. I have been trying to make fc-list recognize Pothana2000 for lang=te without any success. :-(

I hope you will be able to solve this whole font configuration problem. In particular, that solution fixes Telugu rendering, but what if someone wants to see both Telugu & Kannada & ...? We have to list all those fonts in that <assign> statement, no?

Revision history for this message
sree kasturi (sree-kasturi) wrote :

suraj, thank you so much for the fix - i have been looking so long for this!
now i can blog in telugu in linux http://seenu.wordpress.com

and while i'm commenting, i initially tried Sunil's solution but i must have missed something because it (setting up an /etc/fonts/local.conf file with Pothana2000 reference) didn't work for me, and removing ttf-freefont actually removes the entire ubuntu-desktop (gnome) - i learnt it the hard way:).

thanks to both of you and let's hope this gets fixed for good!

Revision history for this message
Sunil Mohan Adapa (sunil) wrote :

To have preference for Telugu fonts and Kannada fonts, the format is like this:

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
 <alias>
  <family>sans-serif</family>
  <prefer>
   <family>Kedage</family>
   <family>Pothana2000</family>
  </prefer>
 </alias>
 <alias>
  <family>serif</family>
  <prefer>
   <family>Kedage</family>
   <family>Pothana2000</family>
  </prefer>
 </alias>
 <alias>
  <family>monospace</family>
  <prefer>
   <family>Kedage</family>
   <family>Pothana2000</family>
  </prefer>
 </alias>
</fontconfig>

You can have the default font set for all the language like this. Note that I have changed from <accept> to <prefer>. Somehow both work tags for Telugu and only <prefer> works for Kannada.

Revision history for this message
Sunil Mohan Adapa (sunil) wrote :

I found out why "lang=" is empty in the font cache file. Fontconfig assumes that a font covers a langauge only if *all* the code points in the corresponding script are covered. Pothana2000 was not covering 0C55 Unicode codepoint. I tried adding some rubbish for that codepoint and fc-cache obtained from the changed font file had lang=te.

Kedage font was not covering 2 code points: 0C8C and 0CBD.

Revision history for this message
Suraj N. Kurapati (sunaku) wrote : Re: missing codepoints in fonts

Brilliant find, Sunil! We should relay this information to the font authors and have them fix the fonts accordingly.

Good work.

Revision history for this message
pulihora (pulihora-java) wrote :

I am also facing the same problem on ubuntu 6.06.
I tried all of the above solutions, but none seem to work.

When can we expect a patch or solution to this problem.

Looks like you guys are doing gnome telugu translation. I too would like to do that.

Can you provide few pointers on how to get started on that.

Revision history for this message
Sunil Mohan Adapa (sunil) wrote :

Can you tell us what exactly you have tried? Because the solutions given here work for us.

PS: I shall contact you seperately about GNOME translations.

Changed in ttf-indic-fonts:
status: Unknown → Unconfirmed
Revision history for this message
pulihora (pulihora-java) wrote :

hi guys,
i tried all the methods, still telugu font rendering is problamatic in fire fox and others. see attachment.

After the suggested fixes, font rendering is little better, but it is not that good.

Any help is appriciated.

Revision history for this message
Sunil Mohan Adapa (sunil) wrote :

The fonts have been correcly chosen in Firefox and the problem with Freefont getting higher priority has been solved. The screenshot shows only Pothana2000 and that is the desired effect.

The reason Firefox does not show the page properly is because it has got pango rendering turned off. You can enable this by installing language support for any of the Indian languages. Try installing the Telugu langauge support.

Alternatively, you can test our problem with gedit (which does not need the Telugu langauge pack to do proper rendering).

Revision history for this message
Suraj N. Kurapati (sunaku) wrote :

Sunil is correct. Please see bug 48326 for details about the incorrect rendering in Firefox and the solution procedure.

Changed in ttf-indic-fonts:
status: Unconfirmed → Fix Released
status: Unconfirmed → Fix Released
Revision history for this message
Soumyadip Modak (soumyadip) wrote :

New package that includes fontconfig config files hhave been uploaded to Debian. This problem should be solved when the package migrates to Ubuntu

Revision history for this message
Soumyadip Modak (soumyadip) wrote :

ttf-indic-fonts 0.4.9 in Gutsy fixes this issue. Closing this bug

Changed in ttf-indic-fonts:
status: Confirmed → Fix Committed
Arne Goetje (arnegoetje)
Changed in ttf-indic-fonts:
status: Fix Committed → Fix Released
Przemek K. (azrael)
Changed in ttf-indic-fonts (Baltix):
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.