fontFamily(): allow string value for font-family attribute
Currently, it is ~~not~~ possible to use font-faces from external CSS-files:
fontFamily.apply() allow only FontFace instances.
This commit allows to specify raw font-family string value, making possible to use non-inline fonts faces.
@japgolly, it looks like, there are an issues with travis-ci build, not related to this commit:
[error] phantomjs: error while loading shared libraries: libicui18n.so.48: cannot open shared object file: No such file or directory
I've suddenly found very simple workaround in docs:
fontFamily.attr := "times-new-roman"
Close this PR?
@helllamer I’ve been doing this to use default/local fonts:
fontFamily :=! "monospace"
It’s ugly to have to use the ! to avoid the warning, but it does work.
@dneades Yes, thanks. It looks like, := also works without warning against fontFamily.attr.
@helllamer I hadn’t known that .attr was a possibility until I saw your original comment. I think, in this case, that it would be nice if fontFamily := "something" were to work without a warning, since I suspect that the most frequent use of fontFamily will be with default/local fonts. I know that isn’t typesafe, though, and I suppose the extra .attr or ! isn’t the end of the world. (I did spend some time being puzzled when I was first trying to work out how to use fontFamily, though! It would be nice if the documentation covered this common usage.)
@dneades Thanks for response. I agree, using fontFamily looks unclear/tricky for scalaCSS end-users.
Will wait for @japgolly 's opinion.
Observed another possible-dangerous situation with using := or :=? against fontFamily.
CSS font-family may contain comma-separated sequence of names, some of names may need quoting, for example:
font-family: verdana, "times new roman", "10ttf"
Possible solution is to implement attr constructor with like that:
fontFamily.apply(name1: String, names: String*): AV
val myFont1 = fontFamily("some-font-family")
val myFont2 = fontFamily("pn10din xfont", "confic", "gazzelle")
Such method will force "-quoting for each family name, and will concat all strings via ,
Sorry for the delay. Varargs seems like a good and reasonable way to go