-
Notifications
You must be signed in to change notification settings - Fork 38
fix text-halo-width units #66
Comments
The values depend on how the signed distance field is generated. Currently, we're using 24px fonts to generate the glyphs and compute the distance field. In the generation code, we store values from -2 pixels to +6 pixels (256 / 32 = 8). So currently, a value of 0 corresponds to a halo width of 6px on a 24px font, and a value of 0.5 corresponds to a halo width of 2px on a 24px font. Since we shift all values by 64 (= 2px on a 24px font), a halo width of 0 has the value 0.75. We should allow users to specify |
@nickidlugash would it be more useful to have halo-width be in pixels or em? |
I'm not sure how text-halo-blur actually renders -- it seems like it should render relative to text-halo-width? In which case maybe it wouldn't make sense for them both to be in pixels? But it does seem like maybe a weird and arbitrary scale right now...? |
So if
If text-halo-width was pixel-based, you'd have to specify different pixel widths per stop in a stop function, which seems kind of crazy. ...? |
That almost makes me want to say maybe instead we should just do something to translate the scale to be more intuitive, like where 0 is min (no) halo and 1 is max halo, so what's currently .75 would be specified by |
I think pixels should work fine. Migrating them is tricky because it's a switch from units relative to the font size to pixels. I'd suggest migrating in an easier but inexact way, based on newHaloWidth = (6 - 8 * oldHaloWidth) * (fontSize / 24); |
Right, right. Hm...I've got migration code working for functions that writes functions inside of
-- should text-halo-width read
o_O? |
Hmm, reading the constant and adding it directly on the layer might be better than creating a new constant that is used once |
I'm just reading migrated code and want to do a gut check here. This is what a migrated text-halo-width function looks like and I'm just worried this seems like maybe a major pain to write:
(The same code before was
|
@lbud IMO the reason for using px units for |
Thanks @nickidlugash, that's very helpful input. Based on that, the proposed design of making the halo width a pixel unit that is independent of the font size seems okay. |
Awesome, thanks @nickidlugash -- very helpful. Next question: in a case like
(found here) where no size is specified -- where does it inherit |
@lbud it inherits from |
@edenh thanks. Would there ever be a case where |
|
|
halo blur should also be in pixels. It's currently an even weirder value (multiples of some arbitrary constant value, with blur=1 being the default). I think this should convert it to pixels where 0 is the default newHaloBlur = (oldHaloBlur - 1) * 2.5 / 24 * 8 |
Hm, ok. Weird thing about halo blur is that there is none committed anywhere in our repos, so ...do we even need to write migration code? |
nope, no migration needed then |
I'm trying to figure out where this comes from
right now drawtext.js says
do you mean to say that |
woops, oldHaloWidth was supposed to be oldHaloBlur (the value of the blur in the old stylesheet). But since no styles need to be converted, that equation can be forgotten. I'm not completely sure if it was even right. The halo blur first needs to be converted from pixel units to sdf units. sdfDistance = pixelDistance / (fontSize / 24) / 8 This is the same as what you changed for halo-width, except width has the Text is antialiased by always having at least a little blur. The halo blur equation is also going to need an offset so that there is some blur even when
|
I don't know if maybe I'm missing something but wouldn't it maybe look more like
(or that, and then simplified)...so the 2.5 (still not sure what that does) is preserved?
) |
The units for text-halo-width are completely arbitrary and unclear. What should they be, pixels?
The text was updated successfully, but these errors were encountered: