line height lower than 1.2em

180 views
Skip to first unread message

mattyk

unread,
Aug 12, 2009, 8:03:54 AM8/12/09
to cufón
Hi all

Reading the the documentation it seems that we can't have a line-
height less than 1.2em

Why do you think this is? Surely that's never going to be low enough
for some projects.

Does anyone know of a way around this, I have a rather large font that
only has about 2-3 words per line. 1.2em is far too much line-height
for my project....

might have to go back to image replacement I suppose!!

Thanks
M

Simo Kinnunen

unread,
Aug 12, 2009, 1:59:59 PM8/12/09
to cu...@googlegroups.com
Hi,

It's a limitation of the current rendering technique we use.
Unfortunately there are no workarounds at the moment, but I'll keep
this in mind and see if something can be done about it.

Simo

mattyk

unread,
Aug 13, 2009, 6:56:25 AM8/13/09
to cufón
OK - thanks for clearing this up....
> > M- Hide quoted text -
>
> - Show quoted text -

antitoxic

unread,
Aug 29, 2009, 5:03:58 PM8/29/09
to cufón
Well, I was struggling today and I end up with a decent solution I
think.

Let's say we have to apply custom font to any link and therefore we
have:
Cufon.replace('a');

In every standard browser you can do this:
$('a span.cufon-canvas').css('height','XXXpx');
(Where XXX is the desired line-height). I've tested firefox, safari,
opera. All good.

IE:
$('span.cufon-vml').css('float','left');
And if the <a> element is inline than apply display:inline-block to
gain the normal flow.

Why not implement this into the cufon itself ? Does anyone have any
drawbacks from this solution ?

All best,
Join a beerfest,
antotixic @ www.toxdox.net

On Aug 13, 11:56 am, mattyk <keog...@googlemail.com> wrote:
> OK - thanks for clearing this up....
>
> On Aug 12, 6:59 pm, Simo Kinnunen <sor...@gmail.com> wrote:
>
> > Hi,
>
> > It's a limitation of the current rendering technique we use.  
> > Unfortunately there are no workarounds at the moment, but I'll keep  
> > this in mind and see if something can be done about it.
>
> > Simo
>
> > On Aug 12, 2009, at 3:03 PM, mattyk wrote:
>
> > > Hi all
>
> > > Reading the the documentation it seems that we can't have aline-> > heightless than 1.2em

Simo Kinnunen

unread,
Aug 31, 2009, 6:18:42 AM8/31/09
to cu...@googlegroups.com
Hi,

It will be a part of a bigger patch that fixes a few other (related)
issues as well.

Simo

none none

unread,
Sep 2, 2009, 5:08:29 PM9/2/09
to cufón
When do you think the new version with the line-height patch will be
available?

I really need this fix.

Simo Kinnunen

unread,
Sep 3, 2009, 1:34:45 PM9/3/09
to cu...@googlegroups.com
Hi,

Probably in about 2-3 weeks, when my other projects should be
finished. Sorry! There's just not enough time.

Simo

fyankai

unread,
Sep 3, 2009, 2:01:20 PM9/3/09
to cufón
I tried this and it worked great but I couldn't get it to work in IE.
I've added this in my header:

Cufon.replace('h2');
$(document).ready(function(){
$('h2 span.cufon-canvas').css('height','20px');
$('h2.cufon-vml').css('float','left');
});

- but that doesn't seem to have any effect on IE. I'm using HTML
strict, and have tried tweaking the CSS line-height but to no avail...

Any ideas?

Simo Kinnunen

unread,
Sep 3, 2009, 2:16:42 PM9/3/09
to cu...@googlegroups.com
Hi,

This is the DOM structure in IE:

<span class="cufon cufon-vml">
<span class="cufon-vml-canvas"></span>
<span class="alt"></span>
</span>

And in other browers:

<span class="cufon cufon-canvas">
<canvas></canvas>
<span class="alt"></span>
</span>

Applying your styles to span.cufon instead of span.cufon-canvas should
work.

Simo

Charlie

unread,
Oct 14, 2009, 5:36:07 AM10/14/09
to cufón
Any progress on this fix? I'm having trouble with the other solutions
people have mentioned.


On Sep 3, 6:34 pm, Simo Kinnunen <sor...@gmail.com> wrote:
> Hi,
>
> Probably in about 2-3 weeks, when my other projects should be  
> finished. Sorry! There's just not enough time.
>
> Simo
>
> On Sep 3, 2009, at 12:08 AM, none none wrote:
>
>
>
> > When do you think the new version with theline-heightpatch will be

Simo Kinnunen

unread,
Oct 15, 2009, 6:31:29 PM10/15/09
to cu...@googlegroups.com
Hi Charlie,

It's going to be a part of the magical "fix everything" release
(1.10). No exact release date is planned but it's probably going to be
somewhere around the end of the next week / the week after that due to
other things (still) keeping me busy.

Simo

antitoxic

unread,
Nov 24, 2009, 6:25:54 PM11/24/09
to cufón
For all struggling. I've written a basic function for my suggested
(somewhere above) solution.
You can see a demo at:
http://toxdox.net/uploads/tests/cufonlineheight/check.html
It is a stripped version of a website i've made.

In the example i am replacing the text from the links in the menu, the
h2 title, a paragraph and a SPAN element to check inline support
Cufon.replace('#menu li a', { textShadow: "1px 1px #cecece" });
Cufon.replace('h2', {textShadow: "1px 2px #cecece" });
Cufon.replace('p');
Cufon.replace('span.spun');


And basically this is the important part:


// ---------- NORMALISE THE LINE-HEIGHT TO 1
// ---------- (done because of IE bug that if defined for the
lineheight more than 1em it acts as multiplier to any value defined
after the text is replaced with Cufon)
$('#menu li a').css('line-height','1em');
$('h2').css('line-height','1em');
$('p').css('line-height','1em');
$('span.spun').css('line-height','1em');

// ---------- AFTER the normalisation , execute replacement of text
---------
Cufon.now();

//--------- Function with basic intelligence to fix the lineheight
-------------
function fixLineHeight($replaced, lineHeight, clearFloat) {
$replaced.each(function(){

var $current = $(this);
if (clearFloat==null) {
clearFloat = false;
}
var clearFloatClassname = 'fltbox';
var cufonSpanSelector = ie ? 'span.cufon-vml' : 'span.cufon-canvas';
var $cufonWords = $current.children(cufonSpanSelector)
var $cufonSiblings = $current.children(':not('+cufonSpanSelector
+')');

if ($(this).css('display')=='inline') {
$cufonWords.css('display','inline-block');
} else {
$cufonWords.css('float','left');
$cufonWords.css('display','inline');// IE floats margin bug
$cufonSiblings.each(function(){
$sib = $(this);
if (!($sib.css('float')=='left' || $sib.css('float')=='right') ) {
$sib.css('float','left');
$sib.css('display','inline');// IE floats margin bug
}
});
if (clearFloat && !$current.hasClass(clearFloatClassname)) { //
$current.addClass(clearFloatClassname);
}
}
$current.css('line-height', lineHeight);
$cufonWords.css('height', lineHeight);
});
}
// ---------- Call function for replaced elements
fixLineHeight($('#menu li a'),'3px');
fixLineHeight($('h2'),'1px');
fixLineHeight($('p'),'8px');
fixLineHeight($('span.spun'),'8px');

antitoxic

unread,
Nov 24, 2009, 6:38:34 PM11/24/09
to cufón
And if you're certain the browsers of your user target group support
inline-block properly then the function can be reduced to :
function fixLineHeight($replaced, lineHeight) {
$replaced.each(function(){
var $current = $(this);
var cufonSpanSelector = ie ? 'span.cufon-vml' : 'span.cufon-canvas';
var $cufonWords = $current.children(cufonSpanSelector);
$cufonWords.css('display','inline-block');
$current.css('line-height', lineHeight);
$cufonWords.css('height', lineHeight);
});
}
But a WARNING there:
Webkit based (Safari, Chrome) browsers in their latest versions have
some issues. Otherwise it is better to use this method.

Cheers all

antitoxic

unread,
Nov 25, 2009, 2:09:56 PM11/25/09
to cufón
Ahh... I've missed a bit. You have to establish whether browser is IE
first:

/*Use Object Detection to detect IE6*/
var ie = document.uniqueID /*IE*/
&& document.compatMode /*>=IE6*/
&& !window.XMLHttpRequest /*<=IE6*/
&& document.execCommand ;

That's all I believe. Sorry for the misleading.

antitoxic

unread,
Nov 25, 2009, 2:22:39 PM11/25/09
to cufón
A fellow (steffen) has reported that it doesn't work for 1.09.
It's problem of the selector. Cufon now uses it's own tagname 'cufon'.
The solution above is teste on 1.03 version. For version when you can
see <cufon> in the code use:

function fixLineHeight($replaced, lineHeight, clearFloat) {
$replaced.each(function(){

var $current = $(this);
if (clearFloat==null) {
clearFloat = false;
}
var clearFloatClassname = 'fltbox';
var $cufonWords = $current.children('cufon')
var $cufonSiblings = $current.children(':not(cufon)');

if ($(this).css('display')=='inline') {
$cufonWords.css('display','inline-block');
} else {
$cufonWords.css('float','left');
$cufonWords.css('display','inline');// IE floats margin bug
$cufonSiblings.each(function(){
$sib = $(this);
if (!($sib.css('float')=='left' || $sib.css('float')=='right') ) {
$sib.css('float','left');
$sib.css('display','inline');// IE floats margin bug
}
});
if (clearFloat && !$current.hasClass(clearFloatClassname)) { //
$current.addClass(clearFloatClassname);
}
}
$current.css('line-height', lineHeight);
$cufonWords.css('height', lineHeight);
});
}


And the inline-block version:

function fixLineHeight($replaced, lineHeight) {
$replaced.each(function(){
var $current = $(this);
var $cufonWords = $current.children('cufon');
$cufonWords.css('display','inline-block');
$current.css('line-height', lineHeight);
$cufonWords.css('height', lineHeight);
});
}

Worry free coding for all of you :))

steffn

unread,
Nov 25, 2009, 2:40:38 PM11/25/09
to cufón
I'm not a webdesigner and certainly not a webdeveloper, but I
simplified Anton's workaround to make it easier to build upon the
"important parts" If there are any other novices that come across
this group I've uploaded it here: http://pastebin.com/f457087ee

Thanks again Anton.. A few bucks found their way to your paypal!

digitalbart

unread,
Dec 17, 2009, 1:08:01 PM12/17/09
to cufón
Thank you steffn & Anton this is great. I can now get this to work in
FF3.5 but I still am having a problem with IE8 any other suggestions?

Christopher Bullen

unread,
Jan 6, 2010, 1:53:52 PM1/6/10
to cufón
If you go into the .font.js file you can manually adjust the "ascent"
and "descent" values which effectively hold the top and bottom reaches
of the font. This will allow you to reduce the natural line-height of
the font itself.

Without knowing exactly how the rendering process works I assume this
will work consistently across all browsers - I've only tested it in
Firefox and Chrome.

Safalta

unread,
Jan 7, 2010, 9:10:38 AM1/7/10
to cufón
Hi Christopher,

I have tested your method in it works in Safari!

Anyway what units are those, ascent and descent?

mattyk

unread,
Jan 14, 2010, 1:00:22 PM1/14/10
to cufón
I hate to hassle but is there a release date for 1.10 which will
hopefully fix this? Also, is that still the plan as I can't see it
mentioned directly in the changelog.

many thanks...

mattyk

unread,
Jan 19, 2010, 12:55:32 PM1/19/10
to cufón
I've tested Christopher Bullen's technique (ascent / descent) but I'm
afraid that it doesn't work in IE7 (the only one I've tested at the
moment).

I haven't yet tried the other techniques above but it does seem a
shame to have to start hacking around. I was really hopefull of this
technique as I'm not really enjoying @font-face's rendering with IE.

One day something will just work!!

Anyway thanks everyone for their help. Hopefully a way around it will
be in the next release.

On Jan 14, 6:00 pm, mattyk <keog...@googlemail.com> wrote:ally.

Simo Kinnunen

unread,
Jan 20, 2010, 4:58:44 PM1/20/10
to cu...@googlegroups.com
Hi everyone,

Yes, it will be fixed in 1.10 (code name "soon™"). I'm terribly sorry for having had to delay the release so many times, my schedule's been failing all over. Don't worry though, 1.10's definitely on its way; most of the work has already been done (even if has not been pushed to GitHub yet).

Simo

> --
> You received this message because you are subscribed to the Google Groups "cufón" group.
> To post to this group, send email to cu...@googlegroups.com.
> To unsubscribe from this group, send email to cufon+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/cufon?hl=en.
>
>

Gareth Evans

unread,
Jan 20, 2010, 8:43:27 PM1/20/10
to cu...@googlegroups.com
Thanks for the update Simo - looking forward to it.
"soon™" should fix a lot of problems. :)
 
Gareth

mattyk

unread,
Jan 21, 2010, 12:45:16 PM1/21/10
to cufón
Going to stick with image replacement for now but looking forward to
this.

Thanks for all the hard work you must be putting in on this!!

M

> > cufon+un...@googlegroups.com <cufon%2Bunsu...@googlegroups.com>.


> > > For more options, visit this group at
> >http://groups.google.com/group/cufon?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "cufón" group.
> > To post to this group, send email to cu...@googlegroups.com.
> > To unsubscribe from this group, send email to

> > cufon+un...@googlegroups.com <cufon%2Bunsu...@googlegroups.com>.


> > For more options, visit this group at

> >http://groups.google.com/group/cufon?hl=en.- Hide quoted text -

mattyk

unread,
Mar 1, 2010, 11:44:52 AM3/1/10
to cufón
Hi Just checking to see if there was any release date for 1.10 set yet
- don't mean to hassle, its just that I'm about to start a new project
and if this is coming out soon I'd prefer to use Cufon.

Cheers
M


On Jan 21, 5:45 pm, mattyk <keog...@googlemail.com> wrote:
> Going to stick with image replacement for now but looking forward to
> this.
>
> Thanks for all the hard work you must be putting in on this!!
>
> M
>
> On Jan 21, 1:43 am, Gareth Evans <agr...@gmail.com> wrote:
>
>
>
> > Thanks for the update Simo - looking forward to it.
> > "soon™" should fix a lot of problems. :)
>
> > Gareth
>
> > On Thu, Jan 21, 2010 at 10:58 AM, Simo Kinnunen <sor...@gmail.com> wrote:
> > > Hi everyone,
>

> > > Yes, it will be fixed in1.10(code name "soon™"). I'm terribly sorry for


> > > having had to delay the release so many times, my schedule's been failing

> > > all over. Don't worry though,1.10's definitely on its way; most of the work


> > > has already been done (even if has not been pushed to GitHub yet).
>
> > > Simo
>
> > > On Jan 19, 2010, at 7:55 PM, mattyk wrote:
>
> > > > I've tested Christopher Bullen's technique (ascent / descent) but I'm
> > > > afraid that it doesn't work in IE7 (the only one I've tested at the
> > > > moment).
>
> > > > I haven't yet tried the other techniques above but it does seem a
> > > > shame to have to start hacking around. I was really hopefull of this
> > > > technique as I'm not really enjoying @font-face's rendering with IE.
>
> > > > One day something will just work!!
>
> > > > Anyway thanks everyone for their help. Hopefully a way around it will
> > > > be in the next release.
>
> > > > On Jan 14, 6:00 pm, mattyk <keog...@googlemail.com> wrote:ally.

> > > >> I hate to hassle but is there a release date for1.10which will


> > > >> hopefully fix this? Also, is that still the plan as I can't see it
> > > >> mentioned directly in the changelog.
>
> > > >> many thanks...
> > > > --
> > >  > You received this message because you are subscribed to the Google
> > > Groups "cufón" group.
> > > > To post to this group, send email to cu...@googlegroups.com.
> > > > To unsubscribe from this group, send email to
> > > cufon+un...@googlegroups.com <cufon%2Bunsu...@googlegroups.com>.
> > > > For more options, visit this group at
> > >http://groups.google.com/group/cufon?hl=en.
>
> > > --
> > > You received this message because you are subscribed to the Google Groups
> > > "cufón" group.
> > > To post to this group, send email to cu...@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > cufon+un...@googlegroups.com <cufon%2Bunsu...@googlegroups.com>.
> > > For more options, visit this group at

> > >http://groups.google.com/group/cufon?hl=en.-Hide quoted text -
>
> > - Show quoted text -- Hide quoted text -

Reply all
Reply to author
Forward
0 new messages