Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Labels with oblique or italic fonts look incorrect #3782

Closed
hpinkos opened this issue Mar 28, 2016 · 10 comments · Fixed by #4239
Closed

Labels with oblique or italic fonts look incorrect #3782

hpinkos opened this issue Mar 28, 2016 · 10 comments · Fixed by #4239

Comments

@hpinkos
Copy link
Contributor

hpinkos commented Mar 28, 2016

Reported on the forum: https://groups.google.com/forum/?hl=en#!topic/cesium-dev/GnWLZbIhKMk

image

var viewer = new Cesium.Viewer('cesiumContainer');

viewer.entities.add({
    position : Cesium.Cartesian3.fromDegrees(-75.1641667, 39.9522222),
    label : {
        text : 'Philadelphia',
        font : 'oblique 24pt Arial'
    }
});

viewer.entities.add({
    position : Cesium.Cartesian3.fromDegrees(-75.1641667, 32),
    label : {
        text : 'Philadelphia',
        font : 'italic 24pt Arial'
    }
});
@mramato
Copy link
Contributor

mramato commented Mar 28, 2016

I believe this is fixed by #2549, but I haven't tried it.

@mramato
Copy link
Contributor

mramato commented Mar 30, 2016

This is actually another manifestation of #2130 and will be fixed when that bug is addressed

@emackey
Copy link
Contributor

emackey commented Apr 1, 2016

@mramato actually, I think this is a separate bug. I have some sample code I've been playing with that pushes back the fringes of billboards into the Z buffer, which does fix 2130 but sadly is not compatible with translucent labels in their current implementation. We should chat offline about that sometime.

That said, this issue appears different, as it is not fixed with the same technique. My guess is that the slanted glyphs are actually sticking out past the right-hand edge of their allotment in the texture atlas, and getting cropped. As such I would expect your font-kerning branch to fix this by rendering all the glyphs together. But the low-alpha z-buffered translucency thing is not the problem here.

@mramato
Copy link
Contributor

mramato commented Apr 1, 2016

@emackey to clarify, I think the font-kerning branch and #2130 together are what will address this issue.

Also, while it's good you might have an alternative solution for the transparency issue, I will point out that a surprising number of browser/device combos do not support frag depth (IE11, iOS, many android devices), so anything requiring it is not an ideal solution for something as common as billboard transparency.

@emackey
Copy link
Contributor

emackey commented Apr 1, 2016

@mramato Yeah, I may have mis-remembered what font-kerning was actually doing, is each glyph still a separate billboard in the atlas? If so this bug stands: I think the individual slanted glyphs are getting cropped, not z-buffered out of existence here.

@emackey
Copy link
Contributor

emackey commented Apr 1, 2016

For example, there should be no Z buffer issue with a single lone letter:

var viewer = new Cesium.Viewer('cesiumContainer');

viewer.entities.add({
    position : Cesium.Cartesian3.fromDegrees(-75.1641667, 39.9522222),
    label : {
        text : 'd',
        font : 'oblique 24pt Arial'
    }
});

viewer.entities.add({
    position : Cesium.Cartesian3.fromDegrees(-75.1641667, 32),
    label : {
        text : 'd',
        font : 'italic 24pt Arial'
    }
});

This has got to be cropping, not Z-buffering.

@mramato
Copy link
Contributor

mramato commented Apr 1, 2016

Yes, each label is a separate glyph (which is absolutely required for performance/memory), but the code that generates the glyphs was fixed to properly take width into account. That being said, it's totally possible that oblique letters still cause problems so additional changes to the font-keming branch might be needed (in addition to the transparency fix to support proper kerning).

@GatorScott
Copy link

The problem with italic (and bold) text is that measureText does not apply font-style and font-weight to the text being measured. There also is a problem computing the width of the character.
philadelphia

@GatorScott
Copy link

I've been unable to figure out how to get my changes into a pull request, so they are attached.

Issue-3782.zip

@pjcozzi
Copy link
Contributor

pjcozzi commented Apr 4, 2016

Contacted @GatorScott offline about getting help opening a PR.

mramato added a commit that referenced this issue Aug 26, 2016
Take font weight into account when measuring text width.

Note that there will still be some issues with certain fonts due to
overlapping transparent billboards. That will be fixed with #2130.

Fixes #3782
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants