How to use writeInt16 method in wpt

Best JavaScript code snippet using wpt

write.js

Source:write.js Github

copy

Full Screen

...16 if (!glyf.compound && (!glyf.contours || 0 === glyf.contours.length)) {17 return;18 }19 // header20 writer.writeInt16(glyf.compound ? -1 : glyf.contours.length);21 writer.writeInt16(glyf.xMin);22 writer.writeInt16(glyf.yMin);23 writer.writeInt16(glyf.xMax);24 writer.writeInt16(glyf.yMax);25 var i;26 var l;27 var flags;28 // 复合图元29 if (glyf.compound) {30 for (i = 0, l = glyf.glyfs.length; i < l; i++) {31 flags = componentFlag.ARGS_ARE_XY_VALUES32 + componentFlag.ROUND_XY_TO_GRID; // xy values33 // more components34 if (i < l - 1) {35 flags += componentFlag.MORE_COMPONENTS;36 }37 var g = glyf.glyfs[i];38 // use my metrics39 flags += g.useMyMetrics ? componentFlag.USE_MY_METRICS : 0;40 // overlap compound41 flags += g.overlapCompound ? componentFlag.OVERLAP_COMPOUND : 0;42 var transform = g.transform;43 var a = transform.a;44 var b = transform.b;45 var c = transform.c;46 var d = transform.d;47 var e = transform.e;48 var f = transform.f;49 // xy values or points50 // int 8 放不下,则用int16放51 if (e < 0 || e > 0x7F || f < 0 || f > 0x7F) {52 flags += componentFlag.ARG_1_AND_2_ARE_WORDS;53 }54 if (b || c) {55 flags += componentFlag.WE_HAVE_A_TWO_BY_TWO;56 }57 else {58 if ((a !== 1 || d !== 1) && a === d) {59 flags += componentFlag.WE_HAVE_A_SCALE;60 }61 else if (a !== 1 || d !== 1) {62 flags += componentFlag.WE_HAVE_AN_X_AND_Y_SCALE;63 }64 }65 writer.writeUint16(flags);66 writer.writeUint16(g.glyphIndex);67 if (componentFlag.ARG_1_AND_2_ARE_WORDS & flags) {68 writer.writeInt16(e);69 writer.writeInt16(f);70 }71 else {72 writer.writeUint8(e);73 writer.writeUint8(f);74 }75 if (componentFlag.WE_HAVE_A_SCALE & flags) {76 writer.writeInt16(Math.round(a * 16384));77 }78 else if (componentFlag.WE_HAVE_AN_X_AND_Y_SCALE & flags) {79 writer.writeInt16(Math.round(a * 16384));80 writer.writeInt16(Math.round(d * 16384));81 }82 else if (componentFlag.WE_HAVE_A_TWO_BY_TWO & flags) {83 writer.writeInt16(Math.round(a * 16384));84 writer.writeInt16(Math.round(b * 16384));85 writer.writeInt16(Math.round(c * 16384));86 writer.writeInt16(Math.round(d * 16384));87 }88 }89 }90 else {91 var endPtsOfContours = -1;92 glyf.contours.forEach(function (contour) {93 endPtsOfContours += contour.length;94 writer.writeUint16(endPtsOfContours);95 });96 // instruction97 if (hinting && glyf.instructions) {98 var instructions = glyf.instructions;99 writer.writeUint16(instructions.length);100 for (i = 0, l = instructions.length; i < l; i++) {101 writer.writeUint8(instructions[i]);102 }103 }104 else {105 writer.writeUint16(0);106 }107 // 获取暂存中的flags108 flags = ttf.support.glyf[index].flags;109 for (i = 0, l = flags.length; i < l; i++) {110 writer.writeUint8(flags[i]);111 }112 var xCoord = ttf.support.glyf[index].xCoord;113 for (i = 0, l = xCoord.length; i < l; i++) {114 if (0 <= xCoord[i] && xCoord[i] <= 0xFF) {115 writer.writeUint8(xCoord[i]);116 }117 else {118 writer.writeInt16(xCoord[i]);119 }120 }121 var yCoord = ttf.support.glyf[index].yCoord;122 for (i = 0, l = yCoord.length; i < l; i++) {123 if (0 <= yCoord[i] && yCoord[i] <= 0xFF) {124 writer.writeUint8(yCoord[i]);125 }126 else {127 writer.writeInt16(yCoord[i]);128 }129 }130 }131 // 4字节对齐132 var glyfSize = ttf.support.glyf[index].glyfSize;133 if (glyfSize % 4) {134 writer.writeEmpty(4 - glyfSize % 4);135 }136 });137 return writer;138}139module.exports = write;...

Full Screen

Full Screen

os2.js

Source:os2.js Github

copy

Full Screen

...26 var buf = ByteBuffer.prototype.create(86);27 var os2 = font.tables.os2;28 var glyphs = font._glyphs;29 buf.writeUint16(1); //version30 buf.writeInt16(os2.xAvgCharWidth); // xAvgCharWidth31 buf.writeUint16(os2.usWeightClass); // usWeightClass32 buf.writeUint16(os2.usWidthClass); // usWidthClass33 buf.writeInt16(os2.fsType); // fsType34 buf.writeInt16(os2.ySubscriptXSize); // ySubscriptXSize35 buf.writeInt16(os2.ySubscriptYSize); //ySubscriptYSize36 buf.writeInt16(os2.ySubscriptXOffset); // ySubscriptXOffset37 buf.writeInt16(os2.ySubscriptYOffset); // ySubscriptYOffset38 buf.writeInt16(os2.ySuperscriptXSize); // ySuperscriptXSize39 buf.writeInt16(os2.ySuperscriptYSize); // ySuperscriptYSize40 buf.writeInt16(os2.ySuperscriptXOffset); // ySuperscriptXOffset41 buf.writeInt16(os2.ySuperscriptYOffset); // ySuperscriptYOffset42 buf.writeInt16(os2.yStrikeoutSize); // yStrikeoutSize43 buf.writeInt16(os2.yStrikeoutPosition); // yStrikeoutPosition44 buf.writeInt16(os2.sFamilyClass); // sFamilyClass45 buf.writeUint8(os2.panose[0]); // panose.bFamilyType46 buf.writeUint8(os2.panose[1]); // panose.bSerifStyle47 buf.writeUint8(os2.panose[2]); // panose.bWeight48 buf.writeUint8(os2.panose[3]); // panose.bProportion49 buf.writeUint8(os2.panose[4]); // panose.bContrast50 buf.writeUint8(os2.panose[5]); // panose.bStrokeVariation51 buf.writeUint8(os2.panose[6]); // panose.bArmStyle52 buf.writeUint8(os2.panose[7]); // panose.bLetterform53 buf.writeUint8(os2.panose[8]); // panose.bMidline54 buf.writeUint8(os2.panose[9]); // panose.bXHeight55 buf.writeUint32(os2.ulUnicodeRange1); // ulUnicodeRange156 buf.writeUint32(os2.ulUnicodeRange2); // ulUnicodeRange257 buf.writeUint32(os2.ulUnicodeRange3); // ulUnicodeRange358 buf.writeUint32(os2.ulUnicodeRange4); // ulUnicodeRange459 buf.writeUint8(os2.achVendID[0]); //achVendID60 buf.writeUint8(os2.achVendID[1]);61 buf.writeUint8(os2.achVendID[2]);62 buf.writeUint8(os2.achVendID[3]);63 buf.writeUint16(os2.fsSelection); // fsSelection64 buf.writeUint16(getFirstCharIndex(glyphs)); // usFirstCharIndex65 buf.writeUint16(getLastCharIndex(glyphs)); // usLastCharIndex66 buf.writeInt16(os2.sTypoAscender); // sTypoAscender67 buf.writeInt16(os2.sTypoDescender); // sTypoDescender68 buf.writeInt16(os2.sTypoLineGap); // lineGap69 // Enlarge win acscent/descent to avoid clipping70 buf.writeInt16(os2.usWinAscent); // usWinAscent71 buf.writeInt16(os2.usWinDescent); // usWinDescent72 buf.writeUint32(os2.ulCodePageRange1); // ulCodePageRange1, Latin 173 buf.writeUint32(os2.ulCodePageRange2); // ulCodePageRange274 return buf;75}...

Full Screen

Full Screen

hhea.js

Source:hhea.js Github

copy

Full Screen

...4function createHHeadTable(font) {5 var hhea = font.tables.hhea;6 var buf = ByteBuffer.prototype.create(36); // fixed table length7 buf.writeInt32(hhea.version); // version8 buf.writeInt16(hhea.ascender); // ascent9 buf.writeInt16(hhea.descender); // descend10 buf.writeInt16(hhea.lineGap); // lineGap11 buf.writeUint16(hhea.advanceWidthMax); // advanceWidthMax12 buf.writeInt16(hhea.minLeftSideBearing); // minLeftSideBearing13 buf.writeInt16(hhea.minRightSideBearing); // minRightSideBearing14 buf.writeInt16(hhea.xMaxExtent); // xMaxExtent15 buf.writeInt16(hhea.caretSlopeRise); // caretSlopeRise16 buf.writeInt16(hhea.caretSlopeRun); // caretSlopeRun17 buf.writeInt16(hhea.caretOffset); // caretSlopeRun18 buf.writeInt16(hhea.reserved[0]); // reserved019 buf.writeInt16(hhea.reserved[1]); // reserved120 buf.writeInt16(hhea.reserved[2]); // reserved221 buf.writeInt16(hhea.reserved[3]); // reserved322 buf.writeInt16(hhea.metricDataFormat); // metricDataFormat23 buf.writeUint16(hhea.numberOfHMetrics); // numberOfHMetrics24 return buf;25}...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var fs = require('fs');3var wav = require('wav');4var file = fs.createWriteStream('test.wav');5var writer = new wav.Writer({6});7writer.pipe(file

Full Screen

Using AI Code Generation

copy

Full Screen

1const wptools = require('wptools');2const fs = require('fs');3const path = require('path');4const file = path.join(__dirname, 'test.wav');5const file2 = path.join(__dirname, 'test2.wav');6const file3 = path.join(__dirname, 'test3.wav');7const file4 = path.join(__dirname, 'test4.wav');8const file5 = path.join(__dirname, 'test5.wav');9const wav = new wptools.WavFile(file);10const wav2 = new wptools.WavFile(file2);11const wav3 = new wptools.WavFile(file3);12const wav4 = new wptools.WavFile(file4);13const wav5 = new wptools.WavFile(file5);14let int16 = new Int16Array(10);15for (let i = 0; i < 10; i++) {16 int16[i] = i;17}18wav.writeInt16(int16);19wav2.writeInt16(int16);20wav3.writeInt16(int16);21wav4.writeInt16(int16);22wav5.writeInt16(int16);23const int16_2 = wav.readInt16(10);24const int16_3 = wav2.readInt16(10);25const int16_4 = wav3.readInt16(10);26const int16_5 = wav4.readInt16(10);27const int16_6 = wav5.readInt16(10);28console.log(int16_2);29console.log(int16_3);30console.log(int16_4);31console.log(int16_5);32console.log(int16_6);33#### constructor(file, options)34 - `float32` {boolean}

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2var fs = require('fs');3var path = require('path');4var http = require('http');5var server = http.createServer(function (req, res) {6 res.writeHead(200, { 'Content-Type': 'text/plain' });7 res.end('okay');8});9server.listen(1337, '

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2var buffer = new Buffer(2);3buffer.writeInt16(100, 0);4console.log(buffer);5* `buffer.writeInt32(value, offset)`6var wpt = require('wpt');7var buffer = new Buffer(4);8buffer.writeInt32(100, 0);9console.log(buffer);10* `buffer.writeIntLE(value, offset, byteLength)`11var wpt = require('wpt');12var buffer = new Buffer(4);13buffer.writeIntLE(100, 0, 4);14console.log(buffer);15* `buffer.writeIntBE(value, offset, byteLength)`16var wpt = require('wpt');17var buffer = new Buffer(4);18buffer.writeIntBE(100, 0, 4);19console.log(buffer);20* `buffer.writeUInt8(value, offset)`21var wpt = require('wpt');22var buffer = new Buffer(1);23buffer.writeUInt8(100, 0);24console.log(buffer);25* `buffer.writeUInt16(value, offset)`

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var wp = new wptools('test');3wp.writeInt16(0x1234);4wp.writeInt16(0x4321);5wp.writeInt16(0x5678);6wp.writeInt16(0x8765);7wp.writeInt16(0x9abc);8wp.writeInt16(0xcba9);9wp.writeInt16(0xdef0);10wp.writeInt16(0xfedc);11wp.writeInt16(0x0000);12wp.writeInt16(0xffff);13wp.writeInt16(0x8000);14wp.writeInt16(0x7fff);15wp.writeInt16(0x0001);16wp.writeInt16(0xfffe);17wp.writeInt16(0x8001);18wp.writeInt16(0x7ffe);19wp.writeInt16(0x0002);20wp.writeInt16(0xfffd);21wp.writeInt16(0x8002);22wp.writeInt16(0x7ffd);23wp.writeInt16(0x0003);24wp.writeInt16(0xfffc);25wp.writeInt16(0x8003);26wp.writeInt16(0x7ffc);27wp.writeInt16(0x0004);28wp.writeInt16(0xfffb);29wp.writeInt16(0x8004);30wp.writeInt16(0x7ffb);31wp.writeInt16(0x0005);32wp.writeInt16(0xfffa);33wp.writeInt16(0x8005);34wp.writeInt16(0x7ffa);35wp.writeInt16(0x0006);36wp.writeInt16(0xfff9);37wp.writeInt16(0x8006);38wp.writeInt16(0x7ff9);39wp.writeInt16(0x0007);40wp.writeInt16(0xfff8);41wp.writeInt16(0x8007);42wp.writeInt16(0x7ff8);43wp.writeInt16(0x0008);44wp.writeInt16(0xfff7);45wp.writeInt16(0x8008);46wp.writeInt16(0x7ff7);47wp.writeInt16(0x0009);48wp.writeInt16(0xfff6);49wp.writeInt16(0x8009);50wp.writeInt16(0x7ff6);51wp.writeInt16(0x000a);52wp.writeInt16(0xfff5);53wp.writeInt16(0x800a);54wp.writeInt16(0x7ff5);55wp.writeInt16(0x000b);56wp.writeInt16(0xfff

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var fs = require('fs');3var file = fs.createWriteStream('test.wav');4var wav = new wptools.WavFile(file);5wav.writeHeader(1, 44100, 16);6wav.writeInt16(0);7wav.writeInt16(32767);8wav.writeInt16(-32768);9wav.writeInt16(0);10file.end();11The MIT License (MIT)

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2var fs = require('fs');3var file = fs.createWriteStream('test2.wav');4var wav = new wpt.WavFile(file);5wav.setNumChannels(2);6wav.setSampleRate(44100);7wav.setBitsPerSample(16);

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