Using Google Font API in Google Web Toolkit
Are there any best practices for using Google Web Fonts in a Google Web Toolkit application? My initial inclination is to simply add the css reference directly in my .html file, a la
<link href='http://fonts.googlea开发者_运维百科pis.com/css?family=Josefin+Sans:light,regular,bold' rel='stylesheet' type='text/css'>
But I'm not sure if this is the best way to do it. Is there any advantage to (or any way to) use ClientBundle here?
Google discourages the direct inclusion of css files on host pages for a mere fact that in this case GWT code has an external (detached) dependence. This only matters if you share a GWT module with other developers - note that this might happen in the future when your project gets refactored by some other people that took over the development. So it's still a good practice to make GWT modules with type-safe external dependencies.
As you know you can simply use one of the recommended ways:
- Using a CssResource contained within a ClientBundle.
- Using an inline
<ui:style src="http://fonts.googleapis.com/css?family=Josefin">
element in a UiBinder template.
精彩评论