How to use CFFCharset method in wpt

Best JavaScript code snippet using wpt

cff_parser.js

Source:cff_parser.js Github

copy

Full Screen

...685 privateDict.subrsIndex = subrsIndex.obj;686 },687 parseCharsets: function CFFParser_parseCharsets(pos, length, strings, cid) {688 if (pos === 0) {689 return new CFFCharset(true, CFFCharsetPredefinedTypes.ISO_ADOBE, _charsets.ISOAdobeCharset);690 } else if (pos === 1) {691 return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT, _charsets.ExpertCharset);692 } else if (pos === 2) {693 return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT_SUBSET, _charsets.ExpertSubsetCharset);694 }695 var bytes = this.bytes;696 var start = pos;697 var format = bytes[pos++];698 var charset = ['.notdef'];699 var id, count, i;700 length -= 1;701 switch (format) {702 case 0:703 for (i = 0; i < length; i++) {704 id = bytes[pos++] << 8 | bytes[pos++];705 charset.push(cid ? id : strings.get(id));706 }707 break;708 case 1:709 while (charset.length <= length) {710 id = bytes[pos++] << 8 | bytes[pos++];711 count = bytes[pos++];712 for (i = 0; i <= count; i++) {713 charset.push(cid ? id++ : strings.get(id++));714 }715 }716 break;717 case 2:718 while (charset.length <= length) {719 id = bytes[pos++] << 8 | bytes[pos++];720 count = bytes[pos++] << 8 | bytes[pos++];721 for (i = 0; i <= count; i++) {722 charset.push(cid ? id++ : strings.get(id++));723 }724 }725 break;726 default:727 throw new _util.FormatError('Unknown charset format');728 }729 var end = pos;730 var raw = bytes.subarray(start, end);731 return new CFFCharset(false, format, charset, raw);732 },733 parseEncoding: function CFFParser_parseEncoding(pos, properties, strings, charset) {734 var encoding = Object.create(null);735 var bytes = this.bytes;736 var predefined = false;737 var format, i, ii;738 var raw = null;739 function readSupplement() {740 var supplementsCount = bytes[pos++];741 for (i = 0; i < supplementsCount; i++) {742 var code = bytes[pos++];743 var sid = (bytes[pos++] << 8) + (bytes[pos++] & 0xff);744 encoding[code] = charset.indexOf(strings.get(sid));745 }746 }747 if (pos === 0 || pos === 1) {748 predefined = true;749 format = pos;750 var baseEncoding = pos ? _encodings.ExpertEncoding : _encodings.StandardEncoding;751 for (i = 0, ii = charset.length; i < ii; i++) {752 var index = baseEncoding.indexOf(charset[i]);753 if (index !== -1) {754 encoding[index] = i;755 }756 }757 } else {758 var dataStart = pos;759 format = bytes[pos++];760 switch (format & 0x7f) {761 case 0:762 var glyphsCount = bytes[pos++];763 for (i = 1; i <= glyphsCount; i++) {764 encoding[bytes[pos++]] = i;765 }766 break;767 case 1:768 var rangesCount = bytes[pos++];769 var gid = 1;770 for (i = 0; i < rangesCount; i++) {771 var start = bytes[pos++];772 var left = bytes[pos++];773 for (var j = start; j <= start + left; j++) {774 encoding[j] = gid++;775 }776 }777 break;778 default:779 throw new _util.FormatError('Unknown encoding format: ' + format + ' in CFF');780 }781 var dataEnd = pos;782 if (format & 0x80) {783 bytes[dataStart] &= 0x7f;784 readSupplement();785 }786 raw = bytes.subarray(dataStart, dataEnd);787 }788 format = format & 0x7f;789 return new CFFEncoding(predefined, format, encoding, raw);790 },791 parseFDSelect: function CFFParser_parseFDSelect(pos, length) {792 var start = pos;793 var bytes = this.bytes;794 var format = bytes[pos++];795 var fdSelect = [],796 rawBytes;797 var i,798 invalidFirstGID = false;799 switch (format) {800 case 0:801 for (i = 0; i < length; ++i) {802 var id = bytes[pos++];803 fdSelect.push(id);804 }805 rawBytes = bytes.subarray(start, pos);806 break;807 case 3:808 var rangesCount = bytes[pos++] << 8 | bytes[pos++];809 for (i = 0; i < rangesCount; ++i) {810 var first = bytes[pos++] << 8 | bytes[pos++];811 if (i === 0 && first !== 0) {812 (0, _util.warn)('parseFDSelect: The first range must have a first GID of 0' + ' -- trying to recover.');813 invalidFirstGID = true;814 first = 0;815 }816 var fdIndex = bytes[pos++];817 var next = bytes[pos] << 8 | bytes[pos + 1];818 for (var j = first; j < next; ++j) {819 fdSelect.push(fdIndex);820 }821 }822 pos += 2;823 rawBytes = bytes.subarray(start, pos);824 if (invalidFirstGID) {825 rawBytes[3] = rawBytes[4] = 0;826 }827 break;828 default:829 throw new _util.FormatError('parseFDSelect: Unknown format "' + format + '".');830 }831 if (fdSelect.length !== length) {832 throw new _util.FormatError('parseFDSelect: Invalid font data.');833 }834 return new CFFFDSelect(fdSelect, rawBytes);835 }836 };837 return CFFParser;838}();839var CFF = function CFFClosure() {840 function CFF() {841 this.header = null;842 this.names = [];843 this.topDict = null;844 this.strings = new CFFStrings();845 this.globalSubrIndex = null;846 this.encoding = null;847 this.charset = null;848 this.charStrings = null;849 this.fdArray = [];850 this.fdSelect = null;851 this.isCIDFont = false;852 }853 return CFF;854}();855var CFFHeader = function CFFHeaderClosure() {856 function CFFHeader(major, minor, hdrSize, offSize) {857 this.major = major;858 this.minor = minor;859 this.hdrSize = hdrSize;860 this.offSize = offSize;861 }862 return CFFHeader;863}();864var CFFStrings = function CFFStringsClosure() {865 function CFFStrings() {866 this.strings = [];867 }868 CFFStrings.prototype = {869 get: function CFFStrings_get(index) {870 if (index >= 0 && index <= 390) {871 return CFFStandardStrings[index];872 }873 if (index - 391 <= this.strings.length) {874 return this.strings[index - 391];875 }876 return CFFStandardStrings[0];877 },878 add: function CFFStrings_add(value) {879 this.strings.push(value);880 },881 get count() {882 return this.strings.length;883 }884 };885 return CFFStrings;886}();887var CFFIndex = function CFFIndexClosure() {888 function CFFIndex() {889 this.objects = [];890 this.length = 0;891 }892 CFFIndex.prototype = {893 add: function CFFIndex_add(data) {894 this.length += data.length;895 this.objects.push(data);896 },897 set: function CFFIndex_set(index, data) {898 this.length += data.length - this.objects[index].length;899 this.objects[index] = data;900 },901 get: function CFFIndex_get(index) {902 return this.objects[index];903 },904 get count() {905 return this.objects.length;906 }907 };908 return CFFIndex;909}();910var CFFDict = function CFFDictClosure() {911 function CFFDict(tables, strings) {912 this.keyToNameMap = tables.keyToNameMap;913 this.nameToKeyMap = tables.nameToKeyMap;914 this.defaults = tables.defaults;915 this.types = tables.types;916 this.opcodes = tables.opcodes;917 this.order = tables.order;918 this.strings = strings;919 this.values = Object.create(null);920 }921 CFFDict.prototype = {922 setByKey: function CFFDict_setByKey(key, value) {923 if (!(key in this.keyToNameMap)) {924 return false;925 }926 var valueLength = value.length;927 if (valueLength === 0) {928 return true;929 }930 for (var i = 0; i < valueLength; i++) {931 if (isNaN(value[i])) {932 (0, _util.warn)('Invalid CFFDict value: "' + value + '" for key "' + key + '".');933 return true;934 }935 }936 var type = this.types[key];937 if (type === 'num' || type === 'sid' || type === 'offset') {938 value = value[0];939 }940 this.values[key] = value;941 return true;942 },943 setByName: function CFFDict_setByName(name, value) {944 if (!(name in this.nameToKeyMap)) {945 throw new _util.FormatError('Invalid dictionary name "' + name + '"');946 }947 this.values[this.nameToKeyMap[name]] = value;948 },949 hasName: function CFFDict_hasName(name) {950 return this.nameToKeyMap[name] in this.values;951 },952 getByName: function CFFDict_getByName(name) {953 if (!(name in this.nameToKeyMap)) {954 throw new _util.FormatError('Invalid dictionary name ' + name + '"');955 }956 var key = this.nameToKeyMap[name];957 if (!(key in this.values)) {958 return this.defaults[key];959 }960 return this.values[key];961 },962 removeByName: function CFFDict_removeByName(name) {963 delete this.values[this.nameToKeyMap[name]];964 }965 };966 CFFDict.createTables = function CFFDict_createTables(layout) {967 var tables = {968 keyToNameMap: {},969 nameToKeyMap: {},970 defaults: {},971 types: {},972 opcodes: {},973 order: []974 };975 for (var i = 0, ii = layout.length; i < ii; ++i) {976 var entry = layout[i];977 var key = Array.isArray(entry[0]) ? (entry[0][0] << 8) + entry[0][1] : entry[0];978 tables.keyToNameMap[key] = entry[1];979 tables.nameToKeyMap[entry[1]] = key;980 tables.types[key] = entry[2];981 tables.defaults[key] = entry[3];982 tables.opcodes[key] = Array.isArray(entry[0]) ? entry[0] : [entry[0]];983 tables.order.push(key);984 }985 return tables;986 };987 return CFFDict;988}();989var CFFTopDict = function CFFTopDictClosure() {990 var layout = [[[12, 30], 'ROS', ['sid', 'sid', 'num'], null], [[12, 20], 'SyntheticBase', 'num', null], [0, 'version', 'sid', null], [1, 'Notice', 'sid', null], [[12, 0], 'Copyright', 'sid', null], [2, 'FullName', 'sid', null], [3, 'FamilyName', 'sid', null], [4, 'Weight', 'sid', null], [[12, 1], 'isFixedPitch', 'num', 0], [[12, 2], 'ItalicAngle', 'num', 0], [[12, 3], 'UnderlinePosition', 'num', -100], [[12, 4], 'UnderlineThickness', 'num', 50], [[12, 5], 'PaintType', 'num', 0], [[12, 6], 'CharstringType', 'num', 2], [[12, 7], 'FontMatrix', ['num', 'num', 'num', 'num', 'num', 'num'], [0.001, 0, 0, 0.001, 0, 0]], [13, 'UniqueID', 'num', null], [5, 'FontBBox', ['num', 'num', 'num', 'num'], [0, 0, 0, 0]], [[12, 8], 'StrokeWidth', 'num', 0], [14, 'XUID', 'array', null], [15, 'charset', 'offset', 0], [16, 'Encoding', 'offset', 0], [17, 'CharStrings', 'offset', 0], [18, 'Private', ['offset', 'offset'], null], [[12, 21], 'PostScript', 'sid', null], [[12, 22], 'BaseFontName', 'sid', null], [[12, 23], 'BaseFontBlend', 'delta', null], [[12, 31], 'CIDFontVersion', 'num', 0], [[12, 32], 'CIDFontRevision', 'num', 0], [[12, 33], 'CIDFontType', 'num', 0], [[12, 34], 'CIDCount', 'num', 8720], [[12, 35], 'UIDBase', 'num', null], [[12, 37], 'FDSelect', 'offset', null], [[12, 36], 'FDArray', 'offset', null], [[12, 38], 'FontName', 'sid', null]];991 var tables = null;992 function CFFTopDict(strings) {993 if (tables === null) {994 tables = CFFDict.createTables(layout);995 }996 CFFDict.call(this, tables, strings);997 this.privateDict = null;998 }999 CFFTopDict.prototype = Object.create(CFFDict.prototype);1000 return CFFTopDict;1001}();1002var CFFPrivateDict = function CFFPrivateDictClosure() {1003 var layout = [[6, 'BlueValues', 'delta', null], [7, 'OtherBlues', 'delta', null], [8, 'FamilyBlues', 'delta', null], [9, 'FamilyOtherBlues', 'delta', null], [[12, 9], 'BlueScale', 'num', 0.039625], [[12, 10], 'BlueShift', 'num', 7], [[12, 11], 'BlueFuzz', 'num', 1], [10, 'StdHW', 'num', null], [11, 'StdVW', 'num', null], [[12, 12], 'StemSnapH', 'delta', null], [[12, 13], 'StemSnapV', 'delta', null], [[12, 14], 'ForceBold', 'num', 0], [[12, 17], 'LanguageGroup', 'num', 0], [[12, 18], 'ExpansionFactor', 'num', 0.06], [[12, 19], 'initialRandomSeed', 'num', 0], [20, 'defaultWidthX', 'num', 0], [21, 'nominalWidthX', 'num', 0], [19, 'Subrs', 'offset', null]];1004 var tables = null;1005 function CFFPrivateDict(strings) {1006 if (tables === null) {1007 tables = CFFDict.createTables(layout);1008 }1009 CFFDict.call(this, tables, strings);1010 this.subrsIndex = null;1011 }1012 CFFPrivateDict.prototype = Object.create(CFFDict.prototype);1013 return CFFPrivateDict;1014}();1015var CFFCharsetPredefinedTypes = {1016 ISO_ADOBE: 0,1017 EXPERT: 1,1018 EXPERT_SUBSET: 21019};1020var CFFCharset = function CFFCharsetClosure() {1021 function CFFCharset(predefined, format, charset, raw) {1022 this.predefined = predefined;1023 this.format = format;1024 this.charset = charset;1025 this.raw = raw;1026 }1027 return CFFCharset;1028}();1029var CFFEncoding = function CFFEncodingClosure() {1030 function CFFEncoding(predefined, format, encoding, raw) {1031 this.predefined = predefined;1032 this.format = format;1033 this.encoding = encoding;1034 this.raw = raw;1035 }...

Full Screen

Full Screen

parseCFFCharset.js

Source:parseCFFCharset.js Github

copy

Full Screen

...14 * @param {number} nGlyphs 字形个数15 * @param {Object} strings cff字符串字典16 * @return {Array} 字符集17 */18 function parseCFFCharset(reader, start, nGlyphs, strings) {19 if (start) {20 reader.seek(start);21 }22 var i;23 var sid;24 var count;25 // The .notdef glyph is not included, so subtract 1.26 nGlyphs -= 1;27 var charset = ['.notdef'];28 var format = reader.readUint8();29 if (format === 0) {30 for (i = 0; i < nGlyphs; i += 1) {31 sid = reader.readUint16();32 charset.push(getCFFString(strings, sid));...

Full Screen

Full Screen

CFFCharset.ts

Source:CFFCharset.ts Github

copy

Full Screen

...55 }56 break;57 default:58 }59 return new CFFCharset(parameters);60 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptextflow = require("wptextflow");2var cffcharset = new wptextflow.CFFCharset();3cffcharset.addString("test");4cffcharset.addString("test2");5cffcharset.addString("test3");6console.log(cffcharset.getString(2));7console.log(cffcharset.getString(3));8console.log(cffcharset.getString(4));9console.log(cffcharset.getString(5));10console.log(cffcharset.getString(6));11console.log(cffcharset.getString(7));12console.log(cffcharset.getString(8));13console.log(cffcharset.getString(9));14console.log(cffcharset.getString(10));15console.log(cffcharset.getString(11));16console.log(cffcharset.getString(12));17console.log(cffcharset.getString(13));18console.log(cffcharset.getString(14));19console.log(cffcharset.getString(15));20console.log(cffcharset.getString(16));21console.log(cffcharset.getString(17));22console.log(cffcharset.getString(18));23console.log(cffcharset.getString(19));24console.log(cffcharset.getString(20));25console.log(cffcharset.getString(21));26console.log(cffcharset.getString(22));27console.log(cffcharset.getString(23));28console.log(cffcharset.getString(24));29console.log(cffcharset.getString(25));30console.log(cffcharset.getString(26));31console.log(cffcharset.getString(27));32console.log(cffcharset.getString(28));33console.log(cffcharset.getString(29));34console.log(cffcharset.getString(30));35console.log(cffcharset.getString(31));36console.log(cffcharset.getString(32));37console.log(cffcharset.getString(33));38console.log(cffcharset.getString(34));39console.log(cffcharset.getString(35));40console.log(cffcharset.getString(36));41console.log(cffcharset.getString(37));42console.log(cffcharset.getString(38));43console.log(cffcharset.getString(39));44console.log(cffcharset.getString(40));45console.log(cffcharset.getString(41));46console.log(cffcharset.getString(42));47console.log(cffcharset.getString(43));48console.log(cffcharset.getString(44));49console.log(cffcharset.getString(45));50console.log(cffcharset.getString(46));51console.log(cffcharset.getString(47));52console.log(cffcharset.getString(48));53console.log(cffcharset.getString(49));54console.log(cffcharset.getString(50));55console.log(cffcharset

Full Screen

Using AI Code Generation

copy

Full Screen

1var fs = require('fs');2var wptext2pdf = require('wptext2pdf');3var pdf = new wptext2pdf();4var pdf = new wptext2pdf();5var font = new wptext2pdf.Font('Times', 'Times-Roman', 'Times-Bold', 'Times-Italic', 'Times-BoldItalic');6var text = "The quick brown fox jumps over the lazy dog.";

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptextdecoder = require("wptextdecoder");2var charset = new wptextdecoder.CFFCharset();3charset.addRange(0, 0x7f);4charset.addRange(0x80, 0xff);5charset.addString("hello");6charset.addString("world");7charset.addString("foo");8charset.addString("bar");9charset.addString("baz");10charset.addString("qux");11charset.addString("quux");12charset.addString("quuz");13charset.addString("corge");14charset.addString("grault");15charset.addString("garply");16charset.addString("waldo");17charset.addString("fred");18charset.addString("plugh");19charset.addString("xyzzy");20charset.addString("thud");21var data = charset.toCFF();22console.log("data: " + data.toString("hex"));

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var charset = wptools.CFFCharset;3var cff = charset('Adobe-CNS1');4console.log(cff);5console.log(cff.getGlyphName(0x4E00));6var wptools = require('wptools');7var charset = wptools.CFFCharset;8var cff = charset('Adobe-GB1');9console.log(cff);10console.log(cff.getGlyphName(0x4E00));11var wptools = require('wptools');12var charset = wptools.CFFCharset;13var cff = charset('Adobe-Japan1');14console.log(cff);15console.log(cff.getGlyphName(0x4E00));16var wptools = require('wptools');17var charset = wptools.CFFCharset;18var cff = charset('Adobe-Korea1');19console.log(cff);20console.log(cff.getGlyphName(0x4E00));21var wptools = require('wptools');22var charset = wptools.CFFCharset;23var cff = charset('Adobe-UCS2');24console.log(cff);25console.log(cff.getGlyphName(0x4E00));26var wptools = require('wptools');27var charset = wptools.CFFCharset;28var cff = charset('Adobe-Identity-0');29console.log(cff);30console.log(cff.getGlyphName(0x4E00));31var wptools = require('wptools');32var charset = wptools.CFFCharset;33var cff = charset('Adobe-Identity-1');34console.log(cff);35console.log(cff.getGlyphName(0x4E00));

Full Screen

Using AI Code Generation

copy

Full Screen

1var fs = require('fs');2var WpTextDecoder = require('./wptextdecoder');3var cff = fs.readFileSync('cff.txt', 'utf8');4var decoder = new WpTextDecoder(cff);5var charset = decoder.CFFCharset();6console.log(charset);

Full Screen

Using AI Code Generation

copy

Full Screen

1var charset = new CFFCharset();2var charCode = 0;3var charName = charset.getCharName(charCode);4console.log(charName);5var encoding = new CFFEncoding();6var charCode = 0;7var charName = encoding.getCharName(charCode);8console.log(charName);9var standardStrings = new CFFStandardStrings();10var index = 0;11var str = standardStrings.getString(index);12console.log(str);13var stringIndex = new CFFStringIndex();14var index = 0;15var str = stringIndex.getString(index);16console.log(str);17var topDict = new CFFTopDict();18var charCode = 0;19var charName = topDict.getCharName(charCode);20console.log(charName);21var topDictIndex = new CFFTopDictIndex();22var index = 0;23var charCode = 0;24var charName = topDictIndex.getCharName(index, charCode);25console.log(charName);26var type1CharString = new CFFType1CharString();27var charCode = 0;28var charName = type1CharString.getCharName(charCode);29console.log(charName);30var type1CharStringIndex = new CFFType1CharStringIndex();31var index = 0;32var charCode = 0;33var charName = type1CharStringIndex.getCharName(index, charCode);34console.log(charName);35var type1Font = new CFFType1Font();36var charCode = 0;

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful