2017-11-01 2 views
0

나는 Downloadable fonts api으로 게임 중입니다. Google sample application을 다운로드하고 코드를 내 프로젝트에 통합했습니다. 둘 다 성공적으로 실행되지만 일부 글꼴은 내 앱과 샘플 앱에서 지속적으로 다운로드하지 못합니다.다운로드 가능한 글꼴 - 일부 Google 글꼴을 다운로드 할 수 없습니다.

나는 FontsContractCompat.requestFont을 사용하고 이유가 1이면 onTypefaceRequestFailed(int reason)으로 콜백을받습니다. 문서에 "FAIL_REASON_FONT_NOT_FOUND"이 (가) 있습니다. 나는 때문에 해당 글꼴이 존재한다 가정 : 1) 그들은 샘플 응용 프로그램과 함께 제공 xml 파일에 나타납니다, 2) 그들은 online list of Google Fonts에 표시, 3) 그들은 개발자 웹 API (여기 https://www.googleapis.com/webfonts/v1/webfonts?key=)

에서 반환 실패한 글꼴 목록 : Angkor Archivo Asap Condensed Baloo Bhaijaan Baloo Tammudu Battambang Bayon Bellefair BioRhyme Expanded Bokor Cabin Condensed Chau Philomene One Chenla Content Dangrek Encode Sans Encode Sans Condensed Encode Sans Expanded Encode Sans Semi Condensed Encode Sans Semi Expanded Fasthand Faustina Freehand Hanuman Khmer Koulen Libre Barcode 128 Libre Barcode 128 Text Libre Barcode 39 Libre Barcode 39 Extended Libre Barcode 39 Extended Text Libre Barcode 39 Text Mada Manuale Metal Moul Moulpali Mukta Mukta Mahee Mukta Malar Nokora Open Sans Condensed Preahvihear Roboto Condensed Saira Saira Condensed Saira Extra Condensed Saira Semi Condensed Sedgwick Ave Sedgwick Ave Display Siemreap Suwannaphum Taprom Ubuntu Condensed Zilla Slab Zilla Slab Highlight

+0

https://fonts.google.com/download?family=Angkor 링크를 통해 글꼴을 다운로드 할 수 있었지만 API와 함께 작동하지 않는 이유가 확실하지 않습니다. –

+0

감사합니다. 나는 또한 그것을 시도했다. –

답변

0

확실히 이상합니다. 그 중 많은 글꼴 (전부는 아니지만)에 "라틴"또는 "라틴어 - 확장"하위 집합이 없으므로 자동 필터링하는 것처럼 보였습니다. API 전체 글꼴 목록을 묻는 작은 python2 스크립트를 작성한 다음 "latin"에 대한 필터를 적용하고 family_names.xml으로 리디렉션 할 수있는 새로운 글꼴 모음 리소스 파일로 남은 것을 출력합니다.

사용법 : fontlist.py <API_KEY>

#!/usr/bin/python 
# fontlist.py by fat-tire 
# 
# Collects Google provider latin & latin-ext font families and creates a replacement for 
# https://github.com/googlesamples/android-DownloadableFonts/blob/master/app/src/main/res/values/family_names.xml 
# 
# See https://developers.google.com/fonts/docs/developer_api for more info on the Google Fonts API 
# 
# Usage:  fontlist.py <API_KEY> > family_names.xml 

import sys, urllib2, json 

if len(sys.argv) != 2: 
    print "Usage:" 
    print " fontlist.py <API_KEY> > family_names.xml" 
    print "No Google Fonts API key? Get one at https://developers.google.com/fonts/docs/developer_api#APIKey" 
    sys.exit(0) 

APIKEY=sys.argv[1] 
url="https://www.googleapis.com/webfonts/v1/webfonts?key=" 

opener = urllib2.build_opener() 
try: 
    request = urllib2.Request(url + APIKEY) 
    conn = opener.open(request) 
except Exception, e: 
    print "Whoopsie. Got a " + str(e.code) + " " + str(e.reason) + " error. You sure that API is legit?" 
    sys.exit(1) 
data = json.loads(conn.read()) 

count = 0 
items = data["items"] 

print "<?xml version=\"1.0\" encoding=\"utf-8\"?>" 
print "<!-- Collected from " + url+APIKEY + " -->" 
print """<resources> 
    <string-array name="family_names">""" 
for key in items: 
    if "latin" in key["subsets"]: 
     print " "*10 + "<item>" + key["family"] + "</item>" 
     count = count + 1 
print """ <!--Total: """ + str(count) + """--> 
    </array> 
</resources>""" 
sys.exit(0) 

이 스크립트는 흥미있는 family_names.xml 출력합니다. one provided by google과 비교하면 질문에 나열된 대부분의 글꼴을 흑백으로 처리합니다. 그러나 "Zilla", "Ubuntu", "Barcode"및 "Encode"글꼴을 포함한 모든 글꼴을 얻을 수는 없습니다. 어쩌면 이러한 글꼴들도 공통적으로 가지고있는 목록이 더 많이 필터링 될 수 있습니다.

  • VolKorn SC
  • 스펙트럼
  • 스펙트럼 SC
  • 세지 번가
  • 세지 번가 디스플레이
  • :

    흥미롭게도, 생성 된 목록도 포함하여 GitHub의 목록에서 새로운 글꼴 NOT을 포함

.... "Barlow", "Belle 공정한 ", 그리고 무리. 그리고 이러한 글꼴 중 일부는 Android에서 작동하는 것 같습니다.

그래서 데모 파일의 목록이 오래되었다고 생각합니다. 어쩌면 목록을 바꿀 필요가있는 라이센스 문제 또는 기술적 인 문제가 있었을 것입니다.

더 이상 제공되지 않는 글꼴을 제거하고 API가 제공하는 테스트 및 알려진 기능을 추가하는 더 최신의 최신 목록으로 풀 요청을 제출해도 좋습니다. 공급자.

+0

나는 프로젝트에서 더 이상 일하지 않는다. 그러나 당신은 대답이 신용을 공헌 할만큼 충분히 도움이되는 것처럼 보인다. 나는 그들이 똑같은 문제에 빠지면 다른 사람들도 그것을 즐길 것이라고 확신한다. (솔직히 놀랍게도, 거의 아무도 그걸 보지 못했다.) –

관련 문제