当前位置: 首页 > wzjs >正文

建企业网站程序系统单位的网站建设费如何核算

建企业网站程序系统,单位的网站建设费如何核算,网站流量是怎么计算的,中文设置wordpress字体格式如何解析(open-type) 当前项目源码 首先需要了解字体的格式,字体的格式是ttf(TrueType Font),它是一种用于计算机显示的矢量字体格式。 字体是一种二进制文件,需要用二进制解析的思想进行解析。 比如:我们参考微软的字…

字体格式如何解析(open-type)

当前项目源码

首先需要了解字体的格式,字体的格式是ttf(TrueType Font),它是一种用于计算机显示的矢量字体格式。

字体是一种二进制文件,需要用二进制解析的思想进行解析。

比如:我们参考微软的字体文档

当然还有苹果字体文档

在这里插入图片描述

第一个参数是 uint32类型 解释为:sfntVersion 就是字体的版本号,如果是0x00010000就是ttf格式,如果是0x00020000就是otf格式

如何读取呢?:

<input type="file" onchange="fileChange(this.files[0])" accept=".ttf"/>
<script>function fileChange(file) {let reader = new FileReader();reader.readAsArrayBuffer(file);reader.onload = function () {const arrayBuffer = reader.result;const dataView = new DataView(arrayBuffer);const version = dataView.getUint32(0);console.log("字体版本: 0x" + version.toString(16));}}
</script>

输出结果:字体版本: 0x10000

按照文档读取字体文件

文档表格中的最后一条记录TableRecord表示一个数据集合,就是一个"对象"的概念。它包含多个参数。

<input type="file" onchange="fileChange(this.files[0])" accept=".ttf"/>
<script>function parseFont(arrayBuffer) {let offset = 0;const dataView = new DataView(arrayBuffer);const version = dataView.getUint32(offset);offset += 4;console.log("字体版本: 0x" + version.toString(16));const numTables = dataView.getUint16(offset);offset += 2;console.log("字体表数量: " + numTables);// searchRange到rangeShift变量用于快速查找字体表,暂未用到。好像也不建议用这个参数了。直接跳过offset += 6;const tableDirectory = {};// 字体表的定义集合: tag-name={checksum , offset , length}for (let i = 0; i < numTables; i++) {// const tag = dataView.getUint32(offset);// 将标签值转换为字符串,更容易理解const tag = String.fromCharCode(dataView.getUint8(offset),dataView.getUint8(offset + 1),dataView.getUint8(offset + 2),dataView.getUint8(offset + 3));offset += 4;const checksum = dataView.getUint32(offset);offset += 4;const tableOffset = dataView.getUint32(offset);offset += 4;const length = dataView.getUint32(offset);offset += 4;tableDirectory[tag] = {checksum, offset: tableOffset, length};}console.log(tableDirectory);return tableDirectory;}function fileChange(file) {let reader = new FileReader();reader.readAsArrayBuffer(file);reader.onload = function () {const headers = parseFont(reader.result);}}
</script>
  • 控制台结果应该是这样的:
    在这里插入图片描述

  • 前面的TableRecord就是每个表的Header信息。读取完成后紧接着就是具体表的数据内容。

解析字体名称表(name)

解析名称表应该跳转到名称表的偏移位置,就是tableDirectory中name

查看文档字体结构name

function parseName(arrayBuffer, header) {const dataView = new DataView(arrayBuffer);let offset = header.offset;const version = dataView.getUint16(offset); // 这个版本标记这之后如何读取内容console.log("name表版本: " + version);offset += 2;const count = dataView.getUint16(offset);offset += 2;console.log("name表数量: " + count);// 定义中数据格式为Offset16 在文档开有说明:Offset16	表的短偏移量,与 uint16 相同,NULL 偏移量 = 0x0000const storageOffset = dataView.getUint16(offset);offset += 2;const nameRecords = [];if (version === 0) {// 版本0就按照版本0格式读取// 有count个NameRecordfor (let i = 0; i < count; i++) {const platformID = dataView.getUint16(offset);offset += 2;const encodingID = dataView.getUint16(offset);offset += 2;const languageID = dataView.getUint16(offset);offset += 2;const nameID = dataView.getUint16(offset);offset += 2;const length = dataView.getUint16(offset);offset += 2;const stringOffset = dataView.getUint16(offset);offset += 2;nameRecords.push({platformID,encodingID,languageID,nameID,length,stringOffset});}}console.log(nameRecords)// 读取字符串,每个record都有一个字符串偏移位置for (let i = 0; i < nameRecords.length; i++) {const record = nameRecords[i];const stringBytes = new Uint8Array(dataView.buffer, header.offset + storageOffset + record.stringOffset, record.length);// 上面是读取到的字节数组,每个平台的字符串编码都不一样,需要根据platformID和encodingID来判断。// 编码表可以参考:https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-lcid/70feba9f-294e-491e-b6eb-56532684c37frecord.stringData = stringBytes;// 输出window平台展示的字符串// 文档原文:all string data for platform 3 must be encoded in UTF-16BE.// 就是windows平台所有的字符串都是UTF-16BE编码的,所以需要用TextDecoder来解码。if (record.platformID === 3 && record.encodingID === 1) {// UTF-16BE 是一种使用大端字节序的 UTF-16 编码方式。JavaScript 的字符串默认是以 UTF-16 编码存储的,但需要手动处理字节序问题。// 将 UTF-16BE 转换为 UTF-16LEfunction convertUTF16BEtoUTF16LE(utf16beBytes) {const utf16leBytes = new Uint8Array(utf16beBytes.length);for (let i = 0; i < utf16beBytes.length; i += 2) {utf16leBytes[i] = utf16beBytes[i + 1];     // 高位字节utf16leBytes[i + 1] = utf16beBytes[i];     // 低位字节}return utf16leBytes;}// 英文if (record.languageID === 0x0409) {// 读取字符串const string = new TextDecoder("utf-16le").decode(convertUTF16BEtoUTF16LE(stringBytes));console.log("Windows平台英文:" + record.nameID + " " + string);}// 中文if (record.languageID === 0x0804) {// 读取字符串const string = new TextDecoder("utf-16le").decode(convertUTF16BEtoUTF16LE(stringBytes));console.log("Windows平台中文:" + record.nameID + " " + string);}}}
}
  • 结果就是这样的
  • 在这里插入图片描述

其他关键表

  • TTF必要的表有:
    在这里插入图片描述
  • 假如你想看当前字体中有哪些字形
  • 可以读取cmap表,这个表就是字形到字符的映射关系,也就可以找到unicode对应的第几个字形。
  • 假如你想读取字形的具体坐标
  • 可以读取glyf表,这个表就是字形的具体坐标。
  • 当然要用loca这个表定位到具体的偏移位置,这个表就是第几个字形对应的glyf表中的偏移位置,从哪到哪。

文章转载自:

http://SOehPjFj.mwjwy.cn
http://Ioowd5fo.mwjwy.cn
http://RuXCPvL9.mwjwy.cn
http://yuzyUojX.mwjwy.cn
http://BtF6jYhX.mwjwy.cn
http://h48jgoJm.mwjwy.cn
http://7vceO7tZ.mwjwy.cn
http://amQbTriX.mwjwy.cn
http://BmSTj4ij.mwjwy.cn
http://sm8sHLGQ.mwjwy.cn
http://ZQo9A9If.mwjwy.cn
http://b20bKT8z.mwjwy.cn
http://NRoCzC1s.mwjwy.cn
http://AyUUT34G.mwjwy.cn
http://VQhDyBQZ.mwjwy.cn
http://HWdLdBqU.mwjwy.cn
http://7YEoy049.mwjwy.cn
http://3T0gKUxT.mwjwy.cn
http://SGuQdQVQ.mwjwy.cn
http://GBHPETpm.mwjwy.cn
http://EN3zcLPn.mwjwy.cn
http://zhJPIkC8.mwjwy.cn
http://uUdelhq4.mwjwy.cn
http://JAvledKd.mwjwy.cn
http://bP6XvHcR.mwjwy.cn
http://MViL8fTQ.mwjwy.cn
http://CEDAChiC.mwjwy.cn
http://N7IK9QO6.mwjwy.cn
http://0QmPerZo.mwjwy.cn
http://zpcKMOOw.mwjwy.cn
http://www.dtcms.com/wzjs/649103.html

相关文章:

  • 西安 餐饮 网站建设如何创建一个和淘宝一样的网站
  • 佛山网站如何制作重庆建设工程质量监督检测中心
  • 做电脑系统的网站好wordpress怎么弄背景
  • 中小型网站建设咨询今天的新闻联播文字版
  • 潢川微信网站建设怎么做游戏代理
  • 如何网站后台清理缓存编写html的软件
  • 设计师网站建设宠物网站建设内容
  • 手机网站建设一般多少钱手机网站转换小程序
  • 西安市住房和城乡建设局门户网站搜索引擎网站排行榜
  • 百度网站优化排行中国企业100强排名
  • 南京电子商务网站建设织梦免费企业网站
  • 农家乐网站设计费用北京icp网站备案
  • 织梦可以做家教网站吗网站建设留言板的实现
  • 网站 开发 工具教育网站开发需求分析
  • 电商网站建设免费深圳住房建设局网站首页
  • 网站开发如何dw中小手定制开发电商网站建设多少钱
  • 外贸网站需要多少个语言甘肃省兰州市城乡建设厅网站
  • 网站定制那个好南充市租房子信息网
  • 服务器建设网站软件下载网络科技公司一般都是骗
  • 长治制作网站企业官网首页图片
  • 查信息的网站有哪些网页游戏网站手机
  • 做企业网站 需要那些功能wordpress突然打不开
  • 电子商务网站建设的定义郑州政策最新消息
  • 本地建站工具动漫网页设计模板素材
  • 基于php的网站开发流程图网站新闻审核怎么做
  • 直播视频网站开发建造师证书查询官网
  • 阳泉网站建设网站网站服务器租用协议
  • 政务服务网站建设方案大型企业网站设计案例
  • 成都哪里有做网站建设的桂林论坛
  • 安丘网站建设制作重庆招标信息网