Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[HOWTO]New freetype subpixel font rendering for lcd monitors
View unanswered posts
View posts from last 24 hours

Goto page Previous  1, 2, 3 ... 10, 11, 12 ... 28, 29, 30  Next  
This topic is locked: you cannot edit posts or make replies.    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
ExZombie
Apprentice
Apprentice


Joined: 29 May 2004
Posts: 170

PostPosted: Sun Jul 01, 2007 8:24 pm    Post subject: Reply with quote

Funny. I've been pondering about this "smeared" pixels for a long time and your screenshot makes is way easier to explain.

You see, all of my fonts look like your kcontrol. If I make a screenshot and zoom in, I see exactly the same. The funny thing is, (and that's what I've been wondering about) without zooming in, I don't see that "smear". I guess that means the way the fonts are rendered fits my LCD panel perfectly. Is that correct? It makes some sense.

If that's true then it would explain why I can't see what you're complaining about. Your kcontrol looks better than your firefox on my panel :) . Unfortunately, I can't answer why they look different in the first place.

FYI, I'm using VRGB sub-pixel rendering. I guess you need RGB.
Back to top
View user's profile Send private message
Da Fox
Guru
Guru


Joined: 06 Jul 2005
Posts: 341

PostPosted: Mon Jul 02, 2007 12:33 pm    Post subject: Reply with quote

I've tried both RGB and BGR (even though I know my LCD has RGB ordering), but the fonts are rendered exactly the same. (Do I need to restart X for changes in the subpixel ordering to take effect? All other things such as hinting and anti-aliasing immediately affect newly started applications.). The are all rendered like the screenshot, orange on the left, blue on the right. Should that not reverse when I change from RGB to BGR ordering?

Further, I've been looking at all the screenshots posted in this topic, and they all show this blur. Also the 'original' screenshot, the one posted to some mailing list, has the same 'blur'. I guess that means that this is the way the fonts are supposed to look?

But if that is so then I don't understand what hinting does, because as far as I know 'hinting' is the process of adapting the shape of font glyphs before they are sent to the rasterizer such that certain features and shapes are retained, for example forcing the stems of the letter 'm' to fall in integral pixels. (See the screenshot in this wiki link, and some more explanation on font rasterization here). From what I see it looks as if there is something wrong with the font hinting in this new subpixel renderer?

In either case, I don't like it, and would really prefer my KDE fonts to look the way my GTK are and always have looked. Isn't there anyway I can tell KDE to use Cairo for font rendering, or am I spouting nonsense here... :)
(I think maybe cairo and qt are two different implementations of the same thing, I think this holds true at least for Qt4, but I don't really know anything about cairo or qt other than that one looks pwitty and the other does not :p)
_________________
"Man fears the darkness, and so he scrapes away at the edges of it with fire."
- Rei Ayanami

JGBE, a Java based GameBoy Emulator
Back to top
View user's profile Send private message
enderandrew
l33t
l33t


Joined: 25 Oct 2005
Posts: 731

PostPosted: Tue Jul 03, 2007 6:27 am    Post subject: Reply with quote

Given that even the Trolltech guys are pushing for universal text layout with Pango, I think we'll be at a point very soon when text rendering is all the same on Linux boxes, if not all boxes that wish to take advantage of stuff like Pango.
_________________
Nihilism makes me smile.
Back to top
View user's profile Send private message
Da Fox
Guru
Guru


Joined: 06 Jul 2005
Posts: 341

PostPosted: Tue Jul 03, 2007 12:41 pm    Post subject: Reply with quote

YES!
I finally found /some/ proof that is *should* be possible to get nice anti-aliasing even in kde/qt: screenshot
This came from the Arch-linux forums, bij someone named 'emmybear' (second post from the top). As you can see, all text is rendered the way I want it, with 'pixel-perfect-hinting', and the screenshot appears to be taken from KDE, as you can see the characteristic KDE taskbar, konqueror and konsole.
Now I've tried what he/she said (put only the DPI setting in local.conf, and AA and hinting max in kcontrol), but it doesn't help, fonts are still rendered blurry* in Qt and sharp** in GTK, and in fact I can't tell anything is different from before :(.

I really don't understand, don't qt and gtk _both_ use the *same* font.conf, and don't they _both_ render text ultimately with freetype?



* **: relative to my point of view / preference


--edit:
And yet another small step in the right direction:
I've discovered that the 'blur' is actually a new 'lcd filter', and that the lcd filtering that I want is now called 'legacy lcd filter'.
Here is a pretty good explanation of it: http://www.mail-archive.com/freetype-devel@nongnu.org/msg01846.html
Basically it says that incase you have very good byte-code-hinted fonts (which I do, as I mostly use bitstream-vera) this filter is sharper than the new filter, but in all other cases is better to use the new filter.
A nice way to see the difference is to use the 'ftdiff' tool, it allows you to change a lot of parameters on-the-fly. (press F1 for a quick overview).
For example to view bitstream-vera-sans rendered at 96 dpi, fontsize 12 you'd do:
Code:
ftdiff -r 96 -s 12 /usr/share/fonts/ttf-bitstream-vera/Vera.ttf


So now I need to know where I can select which lcd filter to use, and tell it that I want it to use the legacy filter. Does anyone know how to do that? Can it be done through .fonts.conf/fonts.local?
_________________
"Man fears the darkness, and so he scrapes away at the edges of it with fire."
- Rei Ayanami

JGBE, a Java based GameBoy Emulator
Back to top
View user's profile Send private message
boniek
Guru
Guru


Joined: 26 Mar 2005
Posts: 373

PostPosted: Wed Jul 04, 2007 2:59 am    Post subject: Reply with quote

David Turner wrote:
The "legacy" LCD filter corresponds to the current implementation found in LibXft and Cairo

If you want effect like the other guy don't use this overlay at all. Install cairo, libxft from portage, enable bytecode interpreter and disable autohinter. If that won't work, at some point in xeffects overlay you could choose what filter you want by setting appropriate use flag. Look through older revisions of freetype ebuild to see how that can be done (I've removed them because Turner considers legacy filter deprecated).
_________________
[HOWTO]New freetype subpixel font rendering for lcd monitors
Back to top
View user's profile Send private message
IvanMajhen
Guru
Guru


Joined: 10 Jun 2006
Posts: 392
Location: Croatia

PostPosted: Wed Jul 04, 2007 12:15 pm    Post subject: Reply with quote

I just tested ftdiff with freetype 2.3.5, and in my opinion lcd filter light is the best for me. Can we set this filter with fontconfig?
I modified freetype that it uses lcd filter light by default.

Screenshot:
http://shrani.si/files/snapshot513c7b.png
Back to top
View user's profile Send private message
roderick
l33t
l33t


Joined: 11 Jul 2005
Posts: 908
Location: St. John's, NL CANADA

PostPosted: Wed Jul 04, 2007 2:15 pm    Post subject: Reply with quote

boniek,

Cairo 1.4.10 wasn't bumped in the overlay yet. We need to keep on top of these bumps, as users may install these unwittingly and cause problems.

This was bumped on June 28th.

For anyone who has currently installed cairo 1.4.10, you do not have the newspr patch. Either go back to 1.4.8 from overlay or re-emerge cairo 1.4.10 (as soon as I have had a chance to update the overlay).

Hopefully, we can get this updated today.

Cherers,

Rod.
_________________
If God were a pickle, I'd still say "no pickle on my burger".
http://roderick-greening.blogspot.com/
Back to top
View user's profile Send private message
roderick
l33t
l33t


Joined: 11 Jul 2005
Posts: 908
Location: St. John's, NL CANADA

PostPosted: Wed Jul 04, 2007 2:43 pm    Post subject: Reply with quote

Ok. Cairo updated.

Please re-emerge if you had previously installed 1.4.10 from portage.

emerge -1v cairo pango gtk+

Cherrs,

Rod.
_________________
If God were a pickle, I'd still say "no pickle on my burger".
http://roderick-greening.blogspot.com/
Back to top
View user's profile Send private message
PaulBredbury
Watchman
Watchman


Joined: 14 Jul 2005
Posts: 7310

PostPosted: Wed Jul 04, 2007 3:16 pm    Post subject: Reply with quote

IvanMajhen wrote:
light is the best for me.

In ~/.fonts.conf
Code:
    <!-- hintnone, hintslight, hintmedium, hintfull -->
    <match target="font">
        <edit name="hintstyle" mode="assign"><const>hintslight</const></edit>
    </match>
Back to top
View user's profile Send private message
anli
Tux's lil' helper
Tux's lil' helper


Joined: 08 Sep 2006
Posts: 80

PostPosted: Wed Jul 04, 2007 3:20 pm    Post subject: Reply with quote

BTW, freetype 2.3.5 is in official ~portage now.
Back to top
View user's profile Send private message
IvanMajhen
Guru
Guru


Joined: 10 Jun 2006
Posts: 392
Location: Croatia

PostPosted: Wed Jul 04, 2007 3:53 pm    Post subject: Reply with quote

PaulBredbury wrote:
IvanMajhen wrote:
light is the best for me.

In ~/.fonts.conf
Code:
    <!-- hintnone, hintslight, hintmedium, hintfull -->
    <match target="font">
        <edit name="hintstyle" mode="assign"><const>hintslight</const></edit>
    </match>


This is not what i'm looking for. This is hinting style.

#elif defined( FT_FORCE_LIGHT_LCD_FILTER ) ---> i wan't this to set with fontconfig. I patched freetype to use this and fonts look much smoother.
Back to top
View user's profile Send private message
PaulBredbury
Watchman
Watchman


Joined: 14 Jul 2005
Posts: 7310

PostPosted: Wed Jul 04, 2007 4:48 pm    Post subject: Reply with quote

Yes, the fonts are a bit crisper:
Code:
diff -u freetype-2.3.4_p20070428.ebuild-orig freetype-2.3.4_p20070428.ebuild
--- freetype-2.3.4_p20070428.ebuild-orig        2007-07-04 17:46:27.000000000 +0100
+++ freetype-2.3.4_p20070428.ebuild     2007-07-04 17:46:27.000000000 +0100
@@ -12,7 +12,7 @@
 LICENSE="FTL GPL-2"
 SLOT="2"
 KEYWORDS=""
-IUSE="demos zlib bindist doc"
+IUSE="demos zlib bindist doc light"
 
 # The RDEPEND below makes sure that if there is a version of moz/ff/tb
 # installed, then it will have the freetype-2.1.8+ binary compatibility patch.
@@ -57,6 +57,12 @@
 
        disable_option FT_CONFIG_OPTION_OLD_INTERNALS
 
+       if use light ; then
+               sed -i \
+                       -e "/FT_END_HEADER/i\#define FT_FORCE_LIGHT_LCD_FILTER" \
+                       include/freetype/config/ftoption.h || die "sed ftoption.h light"
+       fi
+
        elibtoolize
        epunt_cxx
 }
Back to top
View user's profile Send private message
IvanMajhen
Guru
Guru


Joined: 10 Jun 2006
Posts: 392
Location: Croatia

PostPosted: Wed Jul 04, 2007 7:18 pm    Post subject: Reply with quote

This is what i'm talking about. 8) They also look better to me.
I thought that there is some fontconfig option, and not hardcoding this in freetype.
This should go into xeffects.
Back to top
View user's profile Send private message
Da Fox
Guru
Guru


Joined: 06 Jul 2005
Posts: 341

PostPosted: Wed Jul 04, 2007 7:28 pm    Post subject: Reply with quote

boniek wrote:
David Turner wrote:
The "legacy" LCD filter corresponds to the current implementation found in LibXft and Cairo

If you want effect like the other guy don't use this overlay at all. Install cairo, libxft from portage, enable bytecode interpreter and disable autohinter. If that won't work, at some point in xeffects overlay you could choose what filter you want by setting appropriate use flag. Look through older revisions of freetype ebuild to see how that can be done (I've removed them because Turner considers legacy filter deprecated).
That won't be necessary, all I needed was PaulBredBury's patch, with a minor modification, thanks for the hint though :)

PaulBredbury wrote:
Yes, the fonts are a bit crisper:
Code:
diff -u freetype-2.3.4_p20070428.ebuild-orig freetype-2.3.4_p20070428.ebuild
--- freetype-2.3.4_p20070428.ebuild-orig        2007-07-04 17:46:27.000000000 +0100
+++ freetype-2.3.4_p20070428.ebuild     2007-07-04 17:46:27.000000000 +0100
@@ -12,7 +12,7 @@
 LICENSE="FTL GPL-2"
 SLOT="2"
 KEYWORDS=""
-IUSE="demos zlib bindist doc"
+IUSE="demos zlib bindist doc light"
 
 # The RDEPEND below makes sure that if there is a version of moz/ff/tb
 # installed, then it will have the freetype-2.1.8+ binary compatibility patch.
@@ -57,6 +57,12 @@
 
        disable_option FT_CONFIG_OPTION_OLD_INTERNALS
 
+       if use light ; then
+               sed -i \
+                       -e "/FT_END_HEADER/i\#define FT_FORCE_LIGHT_LCD_FILTER" \
+                       include/freetype/config/ftoption.h || die "sed ftoption.h light"
+       fi
+
        elibtoolize
        epunt_cxx
 }
Yes! Finally my fonts look exactly the way I like them, even in KDE :D
Thank you so much, you saved me a lot of work going through old ebuilds :)
For the record: changing the sed line from the above ebuild to
Code:
sed -i -e "/FT_END_HEADER/i\#define FT_FORCE_LEGACY_LCD_FILTER" include/freetype/config/ftoption.h || die "sed ftoption.h LEGACY_LCD_FILTER_HAX"
will force freetype to use the legacy lcd filter.
_________________
"Man fears the darkness, and so he scrapes away at the edges of it with fire."
- Rei Ayanami

JGBE, a Java based GameBoy Emulator
Back to top
View user's profile Send private message
PaulBredbury
Watchman
Watchman


Joined: 14 Jul 2005
Posts: 7310

PostPosted: Wed Jul 04, 2007 7:59 pm    Post subject: Reply with quote

Here's a tidied ebuild which adds 2 new USE flags: light and legacy. Plus some minor tidying :)
Back to top
View user's profile Send private message
Nah
Tux's lil' helper
Tux's lil' helper


Joined: 01 May 2006
Posts: 107
Location: Lille,France

PostPosted: Sat Jul 07, 2007 12:57 pm    Post subject: Reply with quote

PaulBredbury wrote:
Here's a tidied ebuild which adds 2 new USE flags: light and legacy. Plus some minor tidying :)

Link don't work. :(
Back to top
View user's profile Send private message
PaulBredbury
Watchman
Watchman


Joined: 14 Jul 2005
Posts: 7310

PostPosted: Sat Jul 07, 2007 1:35 pm    Post subject: Reply with quote

rafb must only keep it for a day or two. Here's the ebuild:

/usr/local/portage/media-libs/freetype/freetype-2.3.4_p20070428.ebuild

Code:
# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

inherit eutils flag-o-matic libtool

DESCRIPTION="A high-quality and portable font engine"
HOMEPAGE="http://www.freetype.org/"
SRC_URI="http://manta.univ.gda.pl/~rbonieck/${P}.tar.gz
   doc? ( mirror://sourceforge/${PN}/${PN}-doc-2.3.4.tar.bz2 )"

LICENSE="FTL GPL-2"
SLOT="2"
KEYWORDS=""
IUSE="bindist demos doc legacy light zlib"

# The RDEPEND below makes sure that if there is a version of moz/ff/tb
# installed, then it will have the freetype-2.1.8+ binary compatibility patch.
# Otherwise updating freetype will cause moz/ff/tb crashes. #59849
# 20 Nov 2004 agriffis
DEPEND="zlib? ( sys-libs/zlib )"

RDEPEND="${DEPEND}
   !<www-client/mozilla-1.7.3-r3
   !<www-client/mozilla-firefox-1.0-r3
   !<mail-client/mozilla-thunderbird-0.9-r3
   !<media-libs/libwmf-0.2.8.2"

S="${WORKDIR}/freetype2"

src_unpack() {
   unpack ${A}
   cd "${S}"

   enable_option() {
      sed -i -e "/#define $1/a #define $1" \
         include/freetype/config/ftoption.h \
         || die "unable to enable option $1"
   }

   disable_option() {
         sed -i -e "/#define $1/ { s:^:/*:; s:$:*/: }" \
         include/freetype/config/ftoption.h \
         || die "unable to disable option $1"
   }

   if ! use bindist ; then
      # Bytecodes and subpixel hinting supports are patented
      # in United States; for safety, disable them while building
      # binaries, so that no risky code is distributed.
      # See http://freetype.org/patents.html

      enable_option TT_CONFIG_OPTION_BYTECODE_INTERPRETER
      enable_option FT_CONFIG_OPTION_SUBPIXEL_RENDERING
      disable_option TT_CONFIG_OPTION_UNPATENTED_HINTING
   fi

   disable_option FT_CONFIG_OPTION_OLD_INTERNALS

   if use light ; then
      elog "Enabling FT_FORCE_LIGHT_LCD_FILTER."
      sed -i \
         -e "/FT_END_HEADER/i\#define FT_FORCE_LIGHT_LCD_FILTER" \
         include/freetype/config/ftoption.h || die "sed ftoption.h light"
   elif use legacy ; then
      elog "Enabling FT_FORCE_LEGACY_LCD_FILTER."
      sed -i \
         -e "/FT_END_HEADER/i\#define FT_FORCE_LEGACY_LCD_FILTER" \
         include/freetype/config/ftoption.h || die "sed ftoption.h legacy"
   fi

   elibtoolize
   epunt_cxx
}

src_compile() {
   # https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=118021
   append-flags "-fno-strict-aliasing"

   type -p gmake &> /dev/null && export GNUMAKE=gmake
   sh autogen.sh || die "autogen.sh"
   econf $(use_with zlib) || die "econf"

   emake || die "emake"

   if use demos ; then
      cd "${WORKDIR}"/ft2demos
      emake || die "emake ft2demos"
   fi
}

src_install() {
   emake -j1 DESTDIR="${D}" install || die "emake install"

   dodoc ChangeLog README docs/{CHANGES,CUSTOMIZE,DEBUG,*.txt,PATENTS,TODO}

   cd "${WORKDIR}/${PN}-doc-${PV}"
   use doc && dohtml -r docs/*

   if use demos ; then
      cd "${WORKDIR}"/ft2demos/bin/.libs || die
      dobin * || die "dobin demos"
   fi
}

pkg_postinst() {
   ewarn "DO NOT report bugs to Gentoo's bugzilla."
   elog "See http://forums.gentoo.org/viewtopic-t-511382.html for support."
   einfo "Thank you on behalf of the Gentoo Xeffects team."
}
Back to top
View user's profile Send private message
Nah
Tux's lil' helper
Tux's lil' helper


Joined: 01 May 2006
Posts: 107
Location: Lille,France

PostPosted: Sat Jul 07, 2007 1:59 pm    Post subject: Reply with quote

Thank ! :P
Back to top
View user's profile Send private message
KejPi
Tux's lil' helper
Tux's lil' helper


Joined: 17 Jan 2004
Posts: 122
Location: Prague, Czech republic

PostPosted: Tue Jul 10, 2007 5:14 pm    Post subject: Reply with quote

This is very interesting article http://antigrain.com/research/font_rasterization/index.html.
It would be nice to achieve something what is shown in section labeled What can we do?

After all trials I am still not able to achieve nice "k" letter (using DejaVu sans font) :-( I am getting exactly what is shown in the article - at the end section Gamma does not Work!
Back to top
View user's profile Send private message
KejPi
Tux's lil' helper
Tux's lil' helper


Joined: 17 Jan 2004
Posts: 122
Location: Prague, Czech republic

PostPosted: Tue Jul 10, 2007 5:20 pm    Post subject: Reply with quote

IvanMajhen wrote:
This is what i'm talking about. 8) They also look better to me.
I thought that there is some fontconfig option, and not hardcoding this in freetype.
This should go into xeffects.


I can't see any difference :-(
Back to top
View user's profile Send private message
ExZombie
Apprentice
Apprentice


Joined: 29 May 2004
Posts: 170

PostPosted: Fri Jul 13, 2007 5:38 pm    Post subject: Reply with quote

Mmmm, 'light' filter is only slightly better on my screen, but it's still better. Man, I love having a 130dpi display :P
There's just one little gripe I have which I've been trying to solve on and off for a while now. I can't seem to find out why some fonts tend to render the letter 'o' and letters 'N', 'M' and 'W' in funny ways. While DejaVu just rocks, I want to cry at this screenshot. I'm gonna take a look at the soruce to see which font this is.
Back to top
View user's profile Send private message
Eimai
n00b
n00b


Joined: 17 Dec 2006
Posts: 8

PostPosted: Fri Jul 13, 2007 8:20 pm    Post subject: Reply with quote

ExZombie wrote:
I want to cry at this screenshot. I'm gonna take a look at the soruce to see which font this is.


That's Trebuchet MS, one of the corefonts.
Back to top
View user's profile Send private message
Belliash
Advocate
Advocate


Joined: 24 Nov 2004
Posts: 2503
Location: Wroclaw, Poland

PostPosted: Tue Jul 17, 2007 8:45 am    Post subject: Reply with quote

This does not work for me...

I use it since this topic had just 2 pages and everytime worked for me, but not this time :(
I always set it in KDE to use sub-pixel hinting (RGB) and hinting style to Medium. This worked, but i have installed new Gentoo and now does not work :(

I have installed packages with USE:

[ebuild R ] media-libs/freetype-2.3.5 USE="X zlib -bindist -debug -doc" 0 kB
[ebuild R ] x11-libs/cairo-1.4.10 USE="X glitz newspr opengl svg -debug -directfb -doc -xcb" 0 kB [1]
[ebuild R ] x11-libs/libXft-2.1.12 USE="newspr -debug" 0 kB [1]

I tried downgrading freetype to latest from xeffects, cairo to 1.4.8 libXft to 2.1.11... None helped...

What i can say more?
When i disable antialiasing in KDE then fonts look ugly, but when enable it look prettier, but not the same like looked before. They look like i would have installed both cairo iand libXft with USE="-newspr" - old antialiasing, but as You can see i have enabled this flag...

So, whan can be wrong?

Thanks!
_________________
Asio Software Technologies
Belliash IT Weblog
Back to top
View user's profile Send private message
IvanMajhen
Guru
Guru


Joined: 10 Jun 2006
Posts: 392
Location: Croatia

PostPosted: Tue Jul 17, 2007 11:42 am    Post subject: Reply with quote

Hinting must be full.
Back to top
View user's profile Send private message
Belliash
Advocate
Advocate


Joined: 24 Nov 2004
Posts: 2503
Location: Wroclaw, Poland

PostPosted: Tue Jul 17, 2007 12:23 pm    Post subject: Reply with quote

IvanMajhen wrote:
Hinting must be full.


1) was medium and worked...
2) no difference when set to full...
_________________
Asio Software Technologies
Belliash IT Weblog
Back to top
View user's profile Send private message
Display posts from previous:   
This topic is locked: you cannot edit posts or make replies.    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Goto page Previous  1, 2, 3 ... 10, 11, 12 ... 28, 29, 30  Next
Page 11 of 30

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum