2014-12-08 1 views
0

Chrome과 Firefox는 Font-Awesome의 WOFF/TTF를 렌더링하지 않습니다. HttpListener에서 다운로드 한 경우에도 iOS의 Safari가 Font-Awesome을 올바르게 렌더링합니다.HttpListener 응답이있는 WOFF 및 TTF에 사용되는 ContentEncoding은 무엇입니까?

private void Send(HttpListenerContext context, byte[] response, string contentType) 
    { 
     context.Response.StatusCode = (int)HttpStatusCode.OK; 
     context.Response.ContentEncoding = Encoding.UTF8; 
     context.Response.ContentType = contentType; 
     context.Response.ContentLength64 = response.Length; 
     context.Response.AddHeader("Server", SERVER); 

     if (response == null || response.Length == 0) 
     { 
      logger.Error("Send: Engine generated null or empty content"); 
      context.Response.StatusCode = (int)HttpStatusCode.NotFound; 
      return; 
     } 

     using (var s = context.Response.OutputStream) 
     { 
      s.Write(response, 0, response.Length); 
     } 
    } 

WOFF에 대한 (UTF8 이외의) 다른 인코딩 유형이 있습니까 : 나는 다음과 같이 .NET의 HTTP Listener에 클래스를 사용하여 HTTP 응답을 보낸다? 또는 크롬이나 파이어 폭스에서 처리해야 할 부분이 있습니까?

도움이나 감사의 말씀 감사합니다.

답변

0

내 자신의 구현에서는 글꼴이나 이진을 처리 할 때 ContentEncoding 헤더를 함께 사용하지 않습니다.

이 작동합니다 :

context.Response.ContentLength64 = response.Length; 
context.Response.ContentType = "application/x-font-woff"; 
context.Response.OutputStream.Write(response, 0, response.Length); 

context.Response.OutputStream.Close(); 
+0

해결책 주셔서 감사합니다. 그러나 문제가 해결되지 않았습니다. 내 글꼴이 아직 보이지 않습니다. Chrome은 여전히'다운로드 한 폰트를 디코딩하지 못했습니다 .'를 보여줍니다. – Vikrant

+0

당신의 취향은 무엇입니까? CS 프로젝트에서'임베디드 리소스 '라고 불리는이 파일을 가지고 있습니다. .NET에서이 글꼴 파일을 UTF-8 인코딩으로 변환하는 동안 'assembly.GetManifestResourceStream' 메소드를 통해 글꼴 파일의 바이트를 가져 오는 동안 파일을'포함 리소스 '로 변환 할 가능성이 있습니까? – Vikrant

0

문제는 내가 Embedded Resource 모든 www가 컨텐츠를 가지고 있었고, 내가 먼저 UTF-8를 사용하여 string에 그 변환하여 byte 배열에 그 Embedded ResourceStream를 변환하는 방법을 만들어 부호화. 그래서 this stackoverflow question은 근본 원인을 정확히 찾아 내는데 도움이되었습니다. Embedded ResourceStreambyte 배열로 직접 변환하면 Chrome에서 글꼴 굉장 글꼴을 올바르게 표시하기 시작했습니다.

관련 문제