How to use sanitizeTTProgram method in wpt

Best JavaScript code snippet using wpt

fonts.js

Source:fonts.js Github

copy

Full Screen

...1380 }1381 return names;1382 }1383 var TTOpsStackDeltas = [0, 0, 0, 0, 0, 0, 0, 0, -2, -2, -2, -2, 0, 0, -2, -5, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, -1, 0, -1, -1, -1, -1, 1, -1, -999, 0, 1, 0, -1, -2, 0, -1, -2, -1, -1, 0, -1, -1, 0, 0, -999, -999, -1, -1, -1, -1, -2, -999, -2, -2, -999, 0, -2, -2, 0, 0, -2, 0, -2, 0, 0, 0, -2, -1, -1, 1, 1, 0, 0, -1, -1, -1, -1, -1, -1, -1, 0, 0, -1, 0, -1, -1, 0, -999, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -2, -999, -999, -999, -999, -999, -1, -1, -2, -2, 0, 0, 0, 0, -1, -1, -999, -2, -2, 0, 0, -1, -2, -2, 0, 0, 0, -1, -1, -1, -2];1384 function sanitizeTTProgram(table, ttContext) {1385 var data = table.data;1386 var i = 0,1387 j,1388 n,1389 b,1390 funcId,1391 pc,1392 lastEndf = 0,1393 lastDeff = 0;1394 var stack = [];1395 var callstack = [];1396 var functionsCalled = [];1397 var tooComplexToFollowFunctions = ttContext.tooComplexToFollowFunctions;1398 var inFDEF = false,1399 ifLevel = 0,1400 inELSE = 0;1401 for (var ii = data.length; i < ii;) {1402 var op = data[i++];1403 if (op === 0x40) {1404 n = data[i++];1405 if (inFDEF || inELSE) {1406 i += n;1407 } else {1408 for (j = 0; j < n; j++) {1409 stack.push(data[i++]);1410 }1411 }1412 } else if (op === 0x41) {1413 n = data[i++];1414 if (inFDEF || inELSE) {1415 i += n * 2;1416 } else {1417 for (j = 0; j < n; j++) {1418 b = data[i++];1419 stack.push(b << 8 | data[i++]);1420 }1421 }1422 } else if ((op & 0xF8) === 0xB0) {1423 n = op - 0xB0 + 1;1424 if (inFDEF || inELSE) {1425 i += n;1426 } else {1427 for (j = 0; j < n; j++) {1428 stack.push(data[i++]);1429 }1430 }1431 } else if ((op & 0xF8) === 0xB8) {1432 n = op - 0xB8 + 1;1433 if (inFDEF || inELSE) {1434 i += n * 2;1435 } else {1436 for (j = 0; j < n; j++) {1437 b = data[i++];1438 stack.push(b << 8 | data[i++]);1439 }1440 }1441 } else if (op === 0x2B && !tooComplexToFollowFunctions) {1442 if (!inFDEF && !inELSE) {1443 funcId = stack[stack.length - 1];1444 ttContext.functionsUsed[funcId] = true;1445 if (funcId in ttContext.functionsStackDeltas) {1446 stack.length += ttContext.functionsStackDeltas[funcId];1447 } else if (funcId in ttContext.functionsDefined && functionsCalled.indexOf(funcId) < 0) {1448 callstack.push({1449 data: data,1450 i: i,1451 stackTop: stack.length - 11452 });1453 functionsCalled.push(funcId);1454 pc = ttContext.functionsDefined[funcId];1455 if (!pc) {1456 (0, _util.warn)('TT: CALL non-existent function');1457 ttContext.hintsValid = false;1458 return;1459 }1460 data = pc.data;1461 i = pc.i;1462 }1463 }1464 } else if (op === 0x2C && !tooComplexToFollowFunctions) {1465 if (inFDEF || inELSE) {1466 (0, _util.warn)('TT: nested FDEFs not allowed');1467 tooComplexToFollowFunctions = true;1468 }1469 inFDEF = true;1470 lastDeff = i;1471 funcId = stack.pop();1472 ttContext.functionsDefined[funcId] = {1473 data: data,1474 i: i1475 };1476 } else if (op === 0x2D) {1477 if (inFDEF) {1478 inFDEF = false;1479 lastEndf = i;1480 } else {1481 pc = callstack.pop();1482 if (!pc) {1483 (0, _util.warn)('TT: ENDF bad stack');1484 ttContext.hintsValid = false;1485 return;1486 }1487 funcId = functionsCalled.pop();1488 data = pc.data;1489 i = pc.i;1490 ttContext.functionsStackDeltas[funcId] = stack.length - pc.stackTop;1491 }1492 } else if (op === 0x89) {1493 if (inFDEF || inELSE) {1494 (0, _util.warn)('TT: nested IDEFs not allowed');1495 tooComplexToFollowFunctions = true;1496 }1497 inFDEF = true;1498 lastDeff = i;1499 } else if (op === 0x58) {1500 ++ifLevel;1501 } else if (op === 0x1B) {1502 inELSE = ifLevel;1503 } else if (op === 0x59) {1504 if (inELSE === ifLevel) {1505 inELSE = 0;1506 }1507 --ifLevel;1508 } else if (op === 0x1C) {1509 if (!inFDEF && !inELSE) {1510 var offset = stack[stack.length - 1];1511 if (offset > 0) {1512 i += offset - 1;1513 }1514 }1515 }1516 if (!inFDEF && !inELSE) {1517 var stackDelta = op <= 0x8E ? TTOpsStackDeltas[op] : op >= 0xC0 && op <= 0xDF ? -1 : op >= 0xE0 ? -2 : 0;1518 if (op >= 0x71 && op <= 0x75) {1519 n = stack.pop();1520 if (!isNaN(n)) {1521 stackDelta = -n * 2;1522 }1523 }1524 while (stackDelta < 0 && stack.length > 0) {1525 stack.pop();1526 stackDelta++;1527 }1528 while (stackDelta > 0) {1529 stack.push(NaN);1530 stackDelta--;1531 }1532 }1533 }1534 ttContext.tooComplexToFollowFunctions = tooComplexToFollowFunctions;1535 var content = [data];1536 if (i > data.length) {1537 content.push(new Uint8Array(i - data.length));1538 }1539 if (lastDeff > lastEndf) {1540 (0, _util.warn)('TT: complementing a missing function tail');1541 content.push(new Uint8Array([0x22, 0x2D]));1542 }1543 foldTTTable(table, content);1544 }1545 function checkInvalidFunctions(ttContext, maxFunctionDefs) {1546 if (ttContext.tooComplexToFollowFunctions) {1547 return;1548 }1549 if (ttContext.functionsDefined.length > maxFunctionDefs) {1550 (0, _util.warn)('TT: more functions defined than expected');1551 ttContext.hintsValid = false;1552 return;1553 }1554 for (var j = 0, jj = ttContext.functionsUsed.length; j < jj; j++) {1555 if (j > maxFunctionDefs) {1556 (0, _util.warn)('TT: invalid function id: ' + j);1557 ttContext.hintsValid = false;1558 return;1559 }1560 if (ttContext.functionsUsed[j] && !ttContext.functionsDefined[j]) {1561 (0, _util.warn)('TT: undefined function: ' + j);1562 ttContext.hintsValid = false;1563 return;1564 }1565 }1566 }1567 function foldTTTable(table, content) {1568 if (content.length > 1) {1569 var newLength = 0;1570 var j, jj;1571 for (j = 0, jj = content.length; j < jj; j++) {1572 newLength += content[j].length;1573 }1574 newLength = newLength + 3 & ~3;1575 var result = new Uint8Array(newLength);1576 var pos = 0;1577 for (j = 0, jj = content.length; j < jj; j++) {1578 result.set(content[j], pos);1579 pos += content[j].length;1580 }1581 table.data = result;1582 table.length = newLength;1583 }1584 }1585 function sanitizeTTPrograms(fpgm, prep, cvt, maxFunctionDefs) {1586 var ttContext = {1587 functionsDefined: [],1588 functionsUsed: [],1589 functionsStackDeltas: [],1590 tooComplexToFollowFunctions: false,1591 hintsValid: true1592 };1593 if (fpgm) {1594 sanitizeTTProgram(fpgm, ttContext);1595 }1596 if (prep) {1597 sanitizeTTProgram(prep, ttContext);1598 }1599 if (fpgm) {1600 checkInvalidFunctions(ttContext, maxFunctionDefs);1601 }1602 if (cvt && cvt.length & 1) {1603 var cvtData = new Uint8Array(cvt.length + 1);1604 cvtData.set(cvt.data);1605 cvt.data = cvtData;1606 }1607 return ttContext.hintsValid;1608 }1609 font = new _stream.Stream(new Uint8Array(font.getBytes()));1610 var VALID_TABLES = ['OS/2', 'cmap', 'head', 'hhea', 'hmtx', 'maxp', 'name', 'post', 'loca', 'glyf', 'fpgm', 'prep', 'cvt ', 'CFF '];1611 var header = readOpenTypeHeader(font);...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptt = require('./wptt.js');2var sanitizeTTProgram = wptt.sanitizeTTProgram;3var ttProgram = "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16";4console.log(sanitizeTTProgram(ttProgram));5var sanitizeTTProgram = function(ttProgram){6 return ttProgram;7}8module.exports = {9}10var express = require('express');11var app = express();12var port = process.env.PORT || 8080;

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptt = require('wptt');2var ttProgram = wptt.sanitizeTTProgram(ttProgram);3console.log(ttProgram);4var wptt = require('wptt');5var ttProgram = wptt.sanitizeTTProgram(ttProgram);6console.log(ttProgram);7var wptt = require('wptt');8var ttProgram = wptt.sanitizeTTProgram(ttProgram);9console.log(ttProgram);10var wptt = require('wptt');11var ttProgram = wptt.sanitizeTTProgram(ttProgram);12console.log(ttProgram);13var wptt = require('wptt');14var ttProgram = wptt.sanitizeTTProgram(ttProgram);15console.log(ttProgram);

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptt = require('./wptt.js');2var program = 'program to sanitize';3var sanitizedProgram = wptt.sanitizeTTProgram(program);4var wptt = require('./wptt.js');5var program = 'program to sanitize';6var sanitizedProgram = wptt.sanitizeTTProgram(program);7var wptt = require('./wptt.js');8var program = 'program to sanitize';9var sanitizedProgram = wptt.sanitizeTTProgram(program);10var wptt = require('./wptt.js');11var program = 'program to sanitize';12var sanitizedProgram = wptt.sanitizeTTProgram(program);13var wptt = require('./wptt.js');14var program = 'program to sanitize';15var sanitizedProgram = wptt.sanitizeTTProgram(program);16var wptt = require('./wptt.js');17var program = 'program to sanitize';18var sanitizedProgram = wptt.sanitizeTTProgram(program);19var wptt = require('./wptt.js');20var program = 'program to sanitize';21var sanitizedProgram = wptt.sanitizeTTProgram(program);22var wptt = require('./wptt.js');23var program = 'program to sanitize';24var sanitizedProgram = wptt.sanitizeTTProgram(program);25var wptt = require('./wptt.js');26var program = 'program to sanitize';27var sanitizedProgram = wptt.sanitizeTTProgram(program);28var wptt = require('./wptt.js');

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptt = require('wptt');2var input = "test";3var output = wptt.sanitizeTTProgram(input);4console.log(output);5var input = "test";6var output = wptt.sanitizeTTProgram(input);7console.log(output);8var wptt = require('wptt');9var input = "test";10var output = wptt.sanitizeTTProgram(input);11console.log(output);

Full Screen

Using AI Code Generation

copy

Full Screen

1const wptt = require('wptt');2wptt.sanitizeTTProgram(timetableProgram);3const wptt = require('wptt');4wptt.generateTimetable(sanitizedTTProgram);5const wptt = require('wptt');6wptt.getTimetable(timetableProgram);7const wptt = require('wptt');8wptt.getTimetable(timetableProgram);9const wptt = require('wptt');10wptt.getTimetable(timetableProgram);11const wptt = require('wptt');12wptt.getTimetable(timetableProgram);

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