2017-06-19 4 views
1

カスタムフォントをPolymerのアプリケーションまたは要素にインポートするにはどうすればよいですか?Polymerを使用してカスタムフォントをアプリまたは要素にインポートする方法は?

Polymer Slack Channel上@tweightmanパー

<link rel="import" href="/bower_components/polymer/polymer-element.html"> 
<link rel="import" href="/bower_components/my-typography/my-typography.html"> 

<dom-module id="my-page-styles"> 
    <template> 
    <style include="my-typography"> 
     :host { 
     @apply --my-custom-font-mixin; 
     } 
    </style> 
    </template> 
</dom-module> 

は可能な解決策に出くわし:代わりに私の-typography.htmlスタイルモジュール内@font-faceルールを使用しての、私の代わりに<link rel="stylesheet" href="my-font-face.css">に持っているようです。私のアプリのシェルエントリポイント(index.html)で

+0

私は、ポリマーアプリに新しいフォントを追加し、デフォルトのフォントとして使用する権利の実装を見つけようとしています。あなたの可能な解決策をもう少し詳しく説明できますか? my-typography.htmlには何が入っていますか? –

+0

@ d.mares:私はまだ解決策がありません。 [ただし、ここには参照ファイルの親戚の公開バージョンがあります](https://github.com/PolymerElements/paper-styles/blob/master/typography.html)。もしあなたがそれを考え出すなら、答えを加えてください。それが少なくともうまくいかなくても、それはいくつかのアイデアを生み出すのを助けるかもしれません。 https://github.com/PolymerElements/paper-styles/blob/master/typography.html – Mowzer

答えて

2

、私が持っている:あなたはどこか他のと同じよう

<custom-style> 
    <style is="custom-style"> 
     @font-face { 
      font-family: 'Space Mono', monospace; 
      src: url(/fonts/SpaceMono-Regular.ttf) format('truetype'); 
      font-weight: normal; 
      font-style: normal; 
     } 

     html { 
      --primary-font-family: 'Space Mono', monospace; 
     } 
    </style> 
</custom-style> 

その後、私はちょうどvar(--primary-font-family)として、あるいは単にfont-family: 'Space Mono'のいずれかとして、フォントを使用します。

0
index.htmlを
<head> 
    <link rel="stylesheet" href="css/style.css"> 
</head> 
CSS/style.cssに
@import url('https://fonts.googleapis.com/css?family=Lato:300,400'); 

See this example for more details.

関連する問題