XX点评H5字体映射

1.代码

import json

from fontTools.ttLib import TTFont
def get_font_info_dict():
    FONT_LIST=[
        "",
        "",
        "1",
        "2",
        "3",
        "4",
        "5",
        "6",
        "7",
        "8",
        "9",
        "0",
        "\u5e97",
        "\u4e2d",
        "\u7f8e",
        "\u5bb6",
        "\u9986",
        "\u5c0f",
        "\u8f66",
        "\u5927",
        "\u5e02",
        "\u516c",
        "\u9152",
        "\u884c",
        "\u56fd",
        "\u54c1",
        "\u53d1",
        "\u7535",
        "\u91d1",
        "\u5fc3",
        "\u4e1a",
        "\u5546",
        "\u53f8",
        "\u8d85",
        "\u751f",
        "\u88c5",
        "\u56ed",
        "\u573a",
        "\u98df",
        "\u6709",
        "\u65b0",
        "\u9650",
        "\u5929",
        "\u9762",
        "\u5de5",
        "\u670d",
        "\u6d77",
        "\u534e",
        "\u6c34",
        "\u623f",
        "\u9970",
        "\u57ce",
        "\u4e50",
        "\u6c7d",
        "\u9999",
        "\u90e8",
        "\u5229",
        "\u5b50",
        "\u8001",
        "\u827a",
        "\u82b1",
        "\u4e13",
        "\u4e1c",
        "\u8089",
        "\u83dc",
        "\u5b66",
        "\u798f",
        "\u996d",
        "\u4eba",
        "\u767e",
        "\u9910",
        "\u8336",
        "\u52a1",
        "\u901a",
        "\u5473",
        "\u6240",
        "\u5c71",
        "\u533a",
        "\u95e8",
        "\u836f",
        "\u94f6",
        "\u519c",
        "\u9f99",
        "\u505c",
        "\u5c1a",
        "\u5b89",
        "\u5e7f",
        "\u946b",
        "\u4e00",
        "\u5bb9",
        "\u52a8",
        "\u5357",
        "\u5177",
        "\u6e90",
        "\u5174",
        "\u9c9c",
        "\u8bb0",
        "\u65f6",
        "\u673a",
        "\u70e4",
        "\u6587",
        "\u5eb7",
        "\u4fe1",
        "\u679c",
        "\u9633",
        "\u7406",
        "\u9505",
        "\u5b9d",
        "\u8fbe",
        "\u5730",
        "\u513f",
        "\u8863",
        "\u7279",
        "\u4ea7",
        "\u897f",
        "\u6279",
        "\u574a",
        "\u5dde",
        "\u725b",
        "\u4f73",
        "\u5316",
        "\u4e94",
        "\u7c73",
        "\u4fee",
        "\u7231",
        "\u5317",
        "\u517b",
        "\u5356",
        "\u5efa",
        "\u6750",
        "\u4e09",
        "\u4f1a",
        "\u9e21",
        "\u5ba4",
        "\u7ea2",
        "\u7ad9",
        "\u5fb7",
        "\u738b",
        "\u5149",
        "\u540d",
        "\u4e3d",
        "\u6cb9",
        "\u9662",
        "\u5802",
        "\u70e7",
        "\u6c5f",
        "\u793e",
        "\u5408",
        "\u661f",
        "\u8d27",
        "\u578b",
        "\u6751",
        "\u81ea",
        "\u79d1",
        "\u5feb",
        "\u4fbf",
        "\u65e5",
        "\u6c11",
        "\u8425",
        "\u548c",
        "\u6d3b",
        "\u7ae5",
        "\u660e",
        "\u5668",
        "\u70df",
        "\u80b2",
        "\u5bbe",
        "\u7cbe",
        "\u5c4b",
        "\u7ecf",
        "\u5c45",
        "\u5e84",
        "\u77f3",
        "\u987a",
        "\u6797",
        "\u5c14",
        "\u53bf",
        "\u624b",
        "\u5385",
        "\u9500",
        "\u7528",
        "\u597d",
        "\u5ba2",
        "\u706b",
        "\u96c5",
        "\u76db",
        "\u4f53",
        "\u65c5",
        "\u4e4b",
        "\u978b",
        "\u8fa3",
        "\u4f5c",
        "\u7c89",
        "\u5305",
        "\u697c",
        "\u6821",
        "\u9c7c",
        "\u5e73",
        "\u5f69",
        "\u4e0a",
        "\u5427",
        "\u4fdd",
        "\u6c38",
        "\u4e07",
        "\u7269",
        "\u6559",
        "\u5403",
        "\u8bbe",
        "\u533b",
        "\u6b63",
        "\u9020",
        "\u4e30",
        "\u5065",
        "\u70b9",
        "\u6c64",
        "\u7f51",
        "\u5e86",
        "\u6280",
        "\u65af",
        "\u6d17",
        "\u6599",
        "\u914d",
        "\u6c47",
        "\u6728",
        "\u7f18",
        "\u52a0",
        "\u9ebb",
        "\u8054",
        "\u536b",
        "\u5ddd",
        "\u6cf0",
        "\u8272",
        "\u4e16",
        "\u65b9",
        "\u5bd3",
        "\u5c0f",
        "\u5e7c",
        "\u7f8a",
        "\u70eb",
        "\u6765",
        "\u9ad8",
        "\u5382",
        "\u5170",
        "\u963f",
        "\u8d1d",
        "\u76ae",
        "\u5168",
        "\u5973",
        "\u62c9",
        "\u6210",
        "\u4e91",
        "\u7ef4",
        "\u8d38",
        "\u9053",
        "\u672f",
        "\u8fd0",
        "\u90fd",
        "\u53e3",
        "\u535a",
        "\u6cb3",
        "\u745e",
        "\u5b8f",
        "\u4eac",
        "\u9645",
        "\u8def",
        "\u7965",
        "\u9752",
        "\u9547",
        "\u53a8",
        "\u57f9",
        "\u529b",
        "\u60e0",
        "\u8fde",
        "\u9a6c",
        "\u9e3f",
        "\u94a2",
        "\u8bad",
        "\u5f71",
        "\u7532",
        "\u52a9",
        "\u7a97",
        "\u5e03",
        "\u5bcc",
        "\u724c",
        "\u5934",
        "\u9762",
        "\u591a",
        "\u5986",
        "\u5409",
        "\u82d1",
        "\u6c99",
        "\u6052",
        "\u9686",
        "\u6625",
        "\u5e72",
        "\u997c",
        "\u6c0f",
        "\u91cc",
        "\u4e8c",
        "\u7ba1",
        "\u8bda",
        "\u5236",
        "\u552e",
        "\u5609",
        "\u957f",
        "\u8f69",
        "\u6742",
        "\u526f",
        "\u6e05",
        "\u8ba1",
        "\u9ec4",
        "\u8baf",
        "\u592a",
        "\u9e2d",
        "\u53f7",
        "\u8857",
        "\u4ea4",
        "\u4e0e",
        "\u53c9",
        "\u9644",
        "\u8fd1",
        "\u5c42",
        "\u65c1",
        "\u5bf9",
        "\u5df7",
        "\u680b",
        "\u73af",
        "\u7701",
        "\u6865",
        "\u6e56",
        "\u6bb5",
        "\u4e61",
        "\u53a6",
        "\u5e9c",
        "\u94fa",
        "\u5185",
        "\u4fa7",
        "\u5143",
        "\u8d2d",
        "\u524d",
        "\u5e62",
        "\u6ee8",
        "\u5904",
        "\u5411",
        "\u5ea7",
        "\u4e0b",
        "\u770c",
        "\u51e4",
        "\u6e2f",
        "\u5f00",
        "\u5173",
        "\u666f",
        "\u6cc9",
        "\u5858",
        "\u653e",
        "\u660c",
        "\u7ebf",
        "\u6e7e",
        "\u653f",
        "\u6b65",
        "\u5b81",
        "\u89e3",
        "\u767d",
        "\u7530",
        "\u753a",
        "\u6eaa",
        "\u5341",
        "\u516b",
        "\u53e4",
        "\u53cc",
        "\u80dc",
        "\u672c",
        "\u5355",
        "\u5229",
        "\u4e5d",
        "\u8fce",
        "\u7b2c",
        "\u53f0",
        "\u7389",
        "\u9526",
        "\u5e95",
        "\u540e",
        "\u4e03",
        "\u659c",
        "\u671f",
        "\u6b66",
        "\u5cad",
        "\u677e",
        "\u89d2",
        "\u7eaa",
        "\u671d",
        "\u5cf0",
        "\u516d",
        "\u632f",
        "\u73e0",
        "\u5c40",
        "\u5c97",
        "\u6d32",
        "\u6a2a",
        "\u8fb9",
        "\u6d4e",
        "\u4e95",
        "\u529e",
        "\u6c49",
        "\u4ee3",
        "\u4e34",
        "\u5f04",
        "\u56e2",
        "\u5916",
        "\u5854",
        "\u6768",
        "\u94c1",
        "\u6d66",
        "\u5b57",
        "\u5e74",
        "\u5c9b",
        "\u9675",
        "\u539f",
        "\u6885",
        "\u8fdb",
        "\u8363",
        "\u53cb",
        "\u8679",
        "\u592e",
        "\u6842",
        "\u6cbf",
        "\u4e8b",
        "\u6d25",
        "\u51ef",
        "\u83b2",
        "\u4e01",
        "\u79c0",
        "\u67f3",
        "\u96c6",
        "\u7d2b",
        "\u65d7",
        "\u5f20",
        "\u8c37",
        "\u7684",
        "\u662f",
        "\u4e0d",
        "\u4e86",
        "\u5f88",
        "\u8fd8",
        "\u4e2a",
        "\u4e5f",
        "\u8fd9",
        "\u6211",
        "\u5c31",
        "\u5728",
        "\u4ee5",
        "\u53ef",
        "\u5230",
        "\u9519",
        "\u6ca1",
        "\u53bb",
        "\u8fc7",
        "\u611f",
        "\u6b21",
        "\u8981",
        "\u6bd4",
        "\u89c9",
        "\u770b",
        "\u5f97",
        "\u8bf4",
        "\u5e38",
        "\u771f",
        "\u4eec",
        "\u4f46",
        "\u6700",
        "\u559c",
        "\u54c8",
        "\u4e48",
        "\u522b",
        "\u4f4d",
        "\u80fd",
        "\u8f83",
        "\u5883",
        "\u975e",
        "\u4e3a",
        "\u6b22",
        "\u7136",
        "\u4ed6",
        "\u633a",
        "\u7740",
        "\u4ef7",
        "\u90a3",
        "\u610f",
        "\u79cd",
        "\u60f3",
        "\u51fa",
        "\u5458",
        "\u4e24",
        "\u63a8",
        "\u505a",
        "\u6392",
        "\u5b9e",
        "\u5206",
        "\u95f4",
        "\u751c",
        "\u5ea6",
        "\u8d77",
        "\u6ee1",
        "\u7ed9",
        "\u70ed",
        "\u5b8c",
        "\u683c",
        "\u8350",
        "\u559d",
        "\u7b49",
        "\u5176",
        "\u518d",
        "\u51e0",
        "\u53ea",
        "\u73b0",
        "\u670b",
        "\u5019",
        "\u6837",
        "\u76f4",
        "\u800c",
        "\u4e70",
        "\u4e8e",
        "\u822c",
        "\u8c46",
        "\u91cf",
        "\u9009",
        "\u5976",
        "\u6253",
        "\u6bcf",
        "\u8bc4",
        "\u5c11",
        "\u7b97",
        "\u53c8",
        "\u56e0",
        "\u60c5",
        "\u627e",
        "\u4e9b",
        "\u4efd",
        "\u7f6e",
        "\u9002",
        "\u4ec0",
        "\u86cb",
        "\u5e08",
        "\u6c14",
        "\u4f60",
        "\u59d0",
        "\u68d2",
        "\u8bd5",
        "\u603b",
        "\u5b9a",
        "\u554a",
        "\u8db3",
        "\u7ea7",
        "\u6574",
        "\u5e26",
        "\u867e",
        "\u5982",
        "\u6001",
        "\u4e14",
        "\u5c1d",
        "\u4e3b",
        "\u8bdd",
        "\u5f3a",
        "\u5f53",
        "\u66f4",
        "\u677f",
        "\u77e5",
        "\u5df1",
        "\u65e0",
        "\u9178",
        "\u8ba9",
        "\u5165",
        "\u5566",
        "\u5f0f",
        "\u7b11",
        "\u8d5e",
        "\u7247",
        "\u9171",
        "\u5dee",
        "\u50cf",
        "\u63d0",
        "\u961f",
        "\u8d70",
        "\u5ae9",
        "\u624d",
        "\u521a",
        "\u5348",
        "\u63a5",
        "\u91cd",
        "\u4e32",
        "\u56de",
        "\u665a",
        "\u5fae",
        "\u5468",
        "\u503c",
        "\u8d39",
        "\u6027",
        "\u684c",
        "\u62cd",
        "\u8ddf",
        "\u5757",
        "\u8c03",
        "\u7cd5"
    ]
    font = TTFont(r'C:\Users\x\Desktop\xx\1111.woff')
    uni_list = font['cmap'].tables[1].ttFont.getGlyphOrder()
    json_data = dict(zip(uni_list,FONT_LIST))
    h5_json_data={}
    for k,v in json_data.items():
        h5_json_data[f"{k.replace('uni',r'&#x')};"]=f'{v}'
    print(uni_list)
    print(json_data)
    print(h5_json_data)

if __name__ == '__main__':
    get_font_info_dict()
posted @ 2021-03-10 18:29  小小咸鱼YwY  阅读(258)  评论(0编辑  收藏  举报