fonts.css - 跨平臺 CSS 中文字體解決方案
Fonts.css -- 跨平臺中文字體解決方案
一直以來跨平臺的中文字體 CSS 設置都是一件讓人很頭疼的事情,這個庫打包了一些常見字體的名字,希望能覆蓋 Windows、Mac 以及 Linux 的常見字體,方便引用。在 font-family 直接支持宋、楷、黑和仿宋之前,我覺得這樣一種解決方案依然還是必要的。
Demo & Doc
http://zenozeng.github.io/fonts.css/
NPM
npm install fonts.css --save
Usage
<head>
<link rel="stylesheet" type="text/css" href="fonts.css" />
</head>
<body>
<p class="font-kai">
故天將降大任于是人也必先苦其心智勞其筋骨餓其體膚空乏其身行弗亂其所為所以動心忍性曾益其所不能
</p>
</body>
Contribute
Fork 這個項目然后修改 fonts.yml。 如果你要自己編譯可以npm安裝 coffee-script, js-yaml 然后運行 cake build。 如果不的話,可以直接 pull request 回來,由我來編譯。
Known Issues
關于 MS Office 自帶的華文字體
我現在的觀點是,作為一個庫我應該直接面向 API, 既然系統的字體列表里有華文字體,那么就應該被認為是可用的。 再加上華文字體是 Mac 下默認就提供的字體,所以我調整了華文字體在列表里頭的順序。
License
Copyright (C) 2013-2015 Zeno Zeng
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.