ttf2imgpng

相关链接 参考文章canvas 转 图片

<input type="button" value="download" id="dd">
<div id="dropTarget"></div>
<div id="font-container"></div>
</body>
</html>
<script
        src="http://code.jquery.com/jquery-1.12.4.min.js"
        integrity="sha256-ZosEbRLbNQzLpnKIkEdrPv7lOy9C27hHQ+Xp8a4MxAQ="
        crossorigin="anonymous"></script>
<script src="https://cdn.bootcss.com/jszip/3.2.0/jszip.min.js"></script>
<script src="FileSaver.js"></script>
#dropTarget {
   
            width: 300px;
            height: 200px;
            background-color: red;
        }
"use strict";

    /** @param {string=} message */
    function assert(condition, message) {
   
        message = message || "Assertion failed";
        if (!condition) {
   
            alert(message);
            throw message;
        }
    }

    /** @constructor */
    function BinaryReader(arrayBuffer) {
   
        assert(arrayBuffer instanceof ArrayBuffer);
        this.pos = 0;
        this.data = new Uint8Array(arrayBuffer);
    }

    BinaryReader.prototype = {
   
        seek: function (pos) {
   
            assert(pos >= 0 && pos <= this.data.length);
            var oldPos = this.pos;
            this.pos = pos;
            return oldPos;
        },

        tell: function () {
   
            return this.pos;
        },

        getUint8: function () {
   
            assert(this.pos < this.data.length);
            return this.data[this.pos++];
        },

        getUint16: function () {
   
            return ((this.getUint8() << 8) | this.getUint8()) >>> 0;
        },

        getUint32: function () {
   
            return this.getInt32() >>> 0;
        },

        getInt16: function () {
   
            var result = this.getUint16();
            if (result & 0x8000) {
   
                result -= (1 << 16);
            }
            return result;
        },

        getInt32: function () {
   
            return ((this.getUint8() << 24) |
                (this.getUint8() << 16) |
                (this.getUint8() << 8) |
                (this.getUint8()));
        },

        getFword: function () {
   
            return this.getInt16();
        },

        get2Dot14: function () {
   
            return this.getInt16() / (1 << 14);
        },

        getFixed: function () {
   
            return this.getInt32() / (1 << 16);
        },

        getString: function (length) {
   
            var result = "";
            for (var i = 0; i < length; i++) {
   
                result += String.fromCharCode(this.getUint8());
            }
            return result;
        },

        getDate: function () {
   
            var macTime = this.getUint32() * 0x100000000 + this.getUint32();
            var utcTime = macTime * 1000 + Date.UTC(1904, 1, 1);
            return new Date(utcTime)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值