0

LESS に Web フォントを含めようとしています。部分的に仕事をするパラメトリックミックスインは次のとおりです。

.fontface(@fontName, @fontFile) { 
    @font-face { 
        font-family: @fontName;
        src: url("@{fontFile}.eot");    
        src: url("@{fontFile}.eot?#iefix") format('embedded-opentype'),
        url("@{fontFile}.woff") format('woff'),
        url("@{fontFile}.ttf") format('truetype'),
        url("@{fontFile}.svg#DistantGalaxyRegular") format('svg');
        font-weight: normal;
        font-style: normal; } }
.font(@fontsize:10pt, @fontName:"Aierbazzi", @fontFile:"Aierbazzi-fontfacekit/aierbazzi-webfont") { 
        .fontface(@fontName, @fontFile);
font-family:@fontName;
font-size:@fontsize; }

初めて呼び出されても問題なく動作します。

.font1 { .font(24pt, "Black-Rose","Black-Rose-fontfacekit/BLACKR-webfont"); }
.font4 { .font(24pt, "bubblegum-sans","bubblegum-sans-fontfacekit/BubblegumSans-Regular-webfont"); }

結果:

.font1 { 
    font-family:"Black-Rose";
    font-size:24pt; }
    @font-face { 
        font-family:"Black-Rose";
        src:url("Black-Rose-fontfacekit/BLACKR-webfont.eot");
        src:url("Black-Rose-fontfacekit/BLACKR-webfont.eot?#iefix") format('embedded-opentype'),url("Black-Rose-fontfacekit/BLACKR-webfont.woff") format('woff'),url("Black-Rose-fontfacekit/BLACKR-webfont.ttf") format('truetype'),url("Black-Rose-fontfacekit/BLACKR-webfont.svg#DistantGalaxyRegular") format('svg');
        font-weight:normal;
        font-style:normal; }

.font4 { 
    font-family:"bubblegum-sans";
    font-size:24pt; }
    @font-face { 
        font-family:"Black-Rose";
        src:url("Black-Rose-fontfacekit/BLACKR-webfont.eot");
        src:url("Black-Rose-fontfacekit/BLACKR-webfont.eot?#iefix") format('embedded-opentype'),url("Black-Rose-fontfacekit/BLACKR-webfont.woff") format('woff'),url("Black-Rose-fontfacekit/BLACKR-webfont.ttf") format('truetype'),url("Black-Rose-fontfacekit/BLACKR-webfont.svg#DistantGalaxyRegular") format('svg');
        font-weight:normal;
        font-style:normal; }

2行を入れ替えると:

.font4 { .font(24pt, "bubblegum-sans","bubblegum-sans-fontfacekit/BubblegumSans-Regular-webfont"); }
.font1 { .font(24pt, "Black-Rose","Black-Rose-fontfacekit/BLACKR-webfont"); }

ここでも最初の Web フォントだけが CSS に登録されます。

.font4 { 
    font-family:"bubblegum-sans";
    font-size:24pt; } 
@font-face { 
    font-family:"bubblegum-sans";
    src:url("bubblegum-sans-fontfacekit/BubblegumSans-Regular-webfont.eot");
    src:url("bubblegum-sans-fontfacekit/BubblegumSans-Regular-webfont.eot?#iefix") format('embedded-opentype'),url("bubblegum-sans-fontfacekit/BubblegumSans-Regular-webfont.woff") format('woff'),url("bubblegum-sans-fontfacekit/BubblegumSans-Regular-webfont.ttf") format('truetype'),url("bubblegum-sans-fontfacekit/BubblegumSans-Regular-webfont.svg#DistantGalaxyRegular") format('svg');
    font-weight:normal;
    font-style:normal;}

.font1 { 
    font-family:"Black-Rose";
    font-size:24pt; }
@font-face { 
    font-family:"bubblegum-sans";
    src:url("bubblegum-sans-fontfacekit/BubblegumSans-Regular-webfont.eot");
    src:url("bubblegum-sans-fontfacekit/BubblegumSans-Regular-webfont.eot?#iefix") format('embedded-opentype'),url("bubblegum-sans-fontfacekit/BubblegumSans-Regular-webfont.woff") format('woff'),url("bubblegum-sans-fontfacekit/BubblegumSans-Regular-webfont.ttf") format('truetype'),url("bubblegum-sans-fontfacekit/BubblegumSans-Regular-webfont.svg#DistantGalaxyRegular") format('svg');
    font-weight:normal;
    font-style:normal; }

その理由は何ですか?私は今のところ無知です。事前にどうもありがとうございました。

4

1 に答える 1

2

この現在の(私の答えの時点での)バグに基づいて、私はそこに投稿されたソリューションを使用してコードを変更しました。変数を呼び出し(ブロック内から呼び出されるようになりました)に@fontName渡さないように、入力の複製が必要になりますが、適切な出力が得られます。.fontface@font-face

以下

.fontface(@fontName:"Aierbazzi", @fontFile:"Aierbazzi-fontfacekit/aierbazzi-webfont")  {   
    font-family: @fontName;
    src: url("@{fontFile}.eot");    
    src: url("@{fontFile}.eot?#iefix") format('embedded-opentype'),
    url("@{fontFile}.woff") format('woff'),
    url("@{fontFile}.ttf") format('truetype'),
    url("@{fontFile}.svg#DistantGalaxyRegular") format('svg');
    font-weight: normal;
    font-style: normal; 
} 

.font(@fontsize:10pt, @fontName:"Aierbazzi"){
    font-family:@fontName;
    font-size:@fontsize; 
}

.font1 { 
    .font(24pt, "Black-Rose");
    @font-face { 
       .fontface("Black-Rose","Black-Rose-fontfacekit/BLACKR-webfont");
    } 
}

.font4 { 
    .font(24pt, "bubblegum-sans");
    @font-face { 
        .fontface("bubblegum-sans","bubblegum-sans-fontfacekit/BubblegumSans-Regular-webfont");
    } 
}

CSS出力

.font1 {
  font-family: "Black-Rose";
  font-size: 24pt;
}
@font-face {
  font-family: "Black-Rose";
  src: url("Black-Rose-fontfacekit/BLACKR-webfont.eot");
  src: url("Black-Rose-fontfacekit/BLACKR-webfont.eot?#iefix") format('embedded-opentype'), url("Black-Rose-fontfacekit/BLACKR-webfont.woff") format('woff'), url("Black-Rose-fontfacekit/BLACKR-webfont.ttf") format('truetype'), url("Black-Rose-fontfacekit/BLACKR-webfont.svg#DistantGalaxyRegular") format('svg');
  font-weight: normal;
  font-style: normal;
}
.font4 {
  font-family: "bubblegum-sans";
  font-size: 24pt;
}
@font-face {
  font-family: "bubblegum-sans";
  src: url("bubblegum-sans-fontfacekit/BubblegumSans-Regular-webfont.eot");
  src: url("bubblegum-sans-fontfacekit/BubblegumSans-Regular-webfont.eot?#iefix") format('embedded-opentype'), url("bubblegum-sans-fontfacekit/BubblegumSans-Regular-webfont.woff") format('woff'), url("bubblegum-sans-fontfacekit/BubblegumSans-Regular-webfont.ttf") format('truetype'), url("bubblegum-sans-fontfacekit/BubblegumSans-Regular-webfont.svg#DistantGalaxyRegular") format('svg');
  font-weight: normal;
  font-style: normal;
}
于 2012-07-23T11:33:25.580 に答える