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

fontFamily(): allow string value for font-family attribute #121

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

helllamer
Copy link

@helllamer helllamer commented Sep 6, 2017

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.

@helllamer
Copy link
Author

@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

@helllamer
Copy link
Author

I've suddenly found very simple workaround in docs:

fontFamily.attr := "times-new-roman"

Close this PR?

@djneades
Copy link

djneades commented Sep 6, 2017

@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.

@helllamer
Copy link
Author

@dneades Yes, thanks. It looks like, := also works without warning against fontFamily.attr.

@djneades
Copy link

djneades commented Sep 6, 2017

@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.)

@helllamer
Copy link
Author

@dneades Thanks for response. I agree, using fontFamily looks unclear/tricky for scalaCSS end-users.

Will wait for @japgolly 's opinion.

@helllamer
Copy link
Author

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 ,

@japgolly
Copy link
Owner

Sorry for the delay. Varargs seems like a good and reasonable way to go

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

Successfully merging this pull request may close these issues.

3 participants