-
Notifications
You must be signed in to change notification settings - Fork 296
Add support for text highlight boxes + underlines #761
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
Conversation
|
cc @nvkelso @bdon @meetar @matteblair @tallytalwar thoughts on functionality, syntax, and naming appreciated! |
|
Nice! I'm excited to use this to make some sick Supreme-branded maps.
|
|
Most excellent!
…On Sat, Jul 4, 2020 at 23:51 Matt Blair ***@***.***> wrote:
Nice! I'm excited to use this to make some sick Supreme-branded maps.
- How are the dimensions of the background box determined from the
text layout?
- What happens for curved labels?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#761 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAGQIOY5BULQ2FXPLGYWE7LR2APFPANCNFSM4OQVSTGQ>
.
|
|
Looking good!
|
|
Padding of background box?
For curved text, I agree can be for later. Usually there is option to stop
the box behind whole string, words, and characters when a threshold of
letter space or word space is reached.
…On Thu, Jul 9, 2020 at 20:44 Brandon Liu ***@***.***> wrote:
Looking good!
- IMHO curved labels can be excluded from this
- I'm getting a WebGL: INVALID_VALUE: texImage2D: no canvas when there
is no stroke key defined in background
- I think there should be a way to control the padding of the
background box.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#761 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAGQIO5UFTR2ARELGOU5L4TR22FBDANCNFSM4OQVSTGQ>
.
|
|
OK, getting back to this again and trying to wrap up...
As always, we can make further enhancements or adjustments in the future, but given the scope of this PR, I'd love to wrap it up and proceed. There looks to be general consensus. If you have any further comments on default background box sizing, text underlines, or anything else, please speak up now and then we can get this into Tangram v0.21.0! 🚀 |
|
Thanks for the clarifications 👍 A few more questions:
|
|
Fantastic!
…On Sat, Jul 11, 2020 at 16:28 Brett Camper ***@***.***> wrote:
OK, getting back to this again and trying to wrap up...
-
*Which labels apply:* Sorry if this was lost here, but based on
discussion in original issue #724
<#724>, the approach here
was to limit to *point labels only*, e.g. exclude both curved and
angled straight line labels. Curved labels present the implementation
difficulty here, so angled straight labels (e.g. usually straight road
labels) were excluded largely to match the omission of curved labels, since
they are usually labelling the same set of features, and it seemed it would
be weird to have it on some but not others. This could be revisited in the
future, but I wanted to manage this initial implementation complexity, and
believe point labels are the primary use case. cc @matteblair
<https://github.com/matteblair>
-
*Background box size:* The background box dimensions are currently
calculated as 4px on each side of the text, but in practice as you can
see from screenshots, it creates a bit more padding vertically than
horizontally, because font heights extend above. This size was mostly
arbitrary, we can adjust the default if people have other suggestions.
-
*Background box size configurability:* I was initially going to
suggest we defer making the background box dimension configurable, because
there's already a lot going on here and I don't want to re-create the CSS
box model ;) However, it was only a few lines of code now that everything
else is setup, so... here you go, e.g. font.background.width = 8px
6cf2090
<6cf2090>
.
-
*Text underlines:* I know I said I wanted to manage complexity... I
do, but I was already in process of adding the companion feature to this,
#723 <#723>. I've added that
here now, with similar syntax. As with the text box, a lot these
calculations for positioning and spacing have just been manually tweaked
here until they more or less look right under a variety of conditions,
because canvas text font metrics are not complex and/or widely available
enough to support all these cases. Example:
draw:
text:
font:
underline:
color: blue
# alpha: 0.5 # optional alpha override
width: 2px # defaults to 1px if only `color` is defined
[image: Screen Shot 2020-07-11 at 4 22 33 PM]
<https://urldefense.proofpoint.com/v2/url?u=https-3A__user-2Dimages.githubusercontent.com_16733_87235623-2Df8d8c080-2Dc3ab-2D11ea-2D8ed4-2Da6c3819b22d2.png&d=DwMFaQ&c=ncDTmphkJTvjIDPh0hpF_w&r=d__e7RyVjCBMVyq0q3TP4Q&m=GVe_5g2_6cAWRqk8ybBTvieqxPXpn5saMwFe02kwLKU&s=aO4z-juOf1NPJeko6KbjNsJ1l_Xdx2eQnn7lKLcHxK8&e=>
Optionally combined w/background box: [image: Screen Shot 2020-07-11
at 4 23 06 PM]
<https://urldefense.proofpoint.com/v2/url?u=https-3A__user-2Dimages.githubusercontent.com_16733_87235629-2D03935580-2Dc3ac-2D11ea-2D816a-2D13fcb2431792.png&d=DwMFaQ&c=ncDTmphkJTvjIDPh0hpF_w&r=d__e7RyVjCBMVyq0q3TP4Q&m=GVe_5g2_6cAWRqk8ybBTvieqxPXpn5saMwFe02kwLKU&s=kALre10McwPTYQnNQKRAayXAkNhMV0Fbv0Xiinm2ecI&e=>
-
@bdon <https://github.com/bdon> I believe this should have been
addressed by e0d3bde
<e0d3bde>,
if you're still seeing on this branch, could you please send me a scene
YAML reduction example I can work off of.
I'm getting a WebGL: INVALID_VALUE: texImage2D: no canvas when there
is no stroke key defined in background
As always, we can make further enhancements or adjustments in the future,
but given the scope of this PR, I'd love to wrap it up and proceed. There
looks to be general consensus. If you have any further comments on *default
background box sizing*, *text underlines*, or anything else, please speak
up now and then we can get this into Tangram v0.21.0! 🚀
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#761 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAGQIO6IOYXKEWHZQYIRFE3R3DYQXANCNFSM4OQVSTGQ>
.
|
In this case, the full stroke is drawn "outside of"/beyond the background box edge, so the stroke
Where
Since for Tangram JS these elements are all drawn as part of the label texture, they are composited using Canvas default
Only I like Similarly, I haven't loved the use of
There is not but that makes sense, I think that's a better default, to have In this case, would there then not be a default for |
|
|
Makes sense to me to use @nvkelso @bdon see above, @matteblair is proposing we start with fixed values for text underline color and width, to manage complexity (especially as they are not 100% sure yet how they would implement this in Tangram ES). Does this make sense as an initial limitation to you? @matteblair pointed out that even most text editing software doesn't offer that level of customization. The code is already written on the Tangram JS side, so not a big difference for me either way :) |
|
I like |
|
+1 to fixed values for underline color and width |



See #724. Adds support for an optional box behind text labels, which adds the following parameters, in a new
font.backgroundblock:font.background.colorfont.background.alphafont.background.stroke.colorfont.background.stroke.alphafont.background.stroke.widthfont.stroke.widthfont.background.stroke.width: 2px(explicit) orfont.background.stroke.width: 2(implicit)1pxwhenfont.background.stroke.coloris not nullExamples
Fill only:
Fill and stroke:
Stroke only:
All parameters can accept JS functions (alpha and stroke width shown here):
Open Questions
font.background.colorinstead offont.background.fill. Generally,coloris more common thanfillin Tangram, and the latter always felt like a bit of an outlier. That said, there's an argument for using it here for consistency withfont.fill.font.background.stroke, withfont.background.stroke.{color|width}, which does followfont.stroke.{color|width}. An alternative would beoutline, to match shape outlines forlinesandpoints.alphaoverrides, to match recently added functionality for all other color properties. Seems like potential overkill, but it's consistent.font.background.stroke.width. There's some implementation-specific limit, but for instancestroke: 64pxdoes work: