Best JavaScript code snippet using wpt
cff_parser_spec.js
Source:cff_parser_spec.js
...380 names = parser.parseNameIndex(nameIndex.obj);381 expect(names[0].length).toEqual(127);382 });383 it("compiles fdselect format 0", function () {384 const fdSelect = new CFFFDSelect(0, [3, 2, 1]);385 const c = new CFFCompiler();386 const out = c.compileFDSelect(fdSelect);387 expect(out).toEqual([388 0, // format389 3, // gid: 0 fd 3390 2, // gid: 1 fd 3391 1, // gid: 2 fd 3392 ]);393 });394 it("compiles fdselect format 3", function () {395 const fdSelect = new CFFFDSelect(3, [0, 0, 1, 1]);396 const c = new CFFCompiler();397 const out = c.compileFDSelect(fdSelect);398 expect(out).toEqual([399 3, // format400 0, // nRanges (high)401 2, // nRanges (low)402 0, // range struct 0 - first (high)403 0, // range struct 0 - first (low)404 0, // range struct 0 - fd405 0, // range struct 0 - first (high)406 2, // range struct 0 - first (low)407 1, // range struct 0 - fd408 0, // sentinel (high)409 4, // sentinel (low)410 ]);411 });412 it("compiles fdselect format 3, single range", function () {413 const fdSelect = new CFFFDSelect(3, [0, 0]);414 const c = new CFFCompiler();415 const out = c.compileFDSelect(fdSelect);416 expect(out).toEqual([417 3, // format418 0, // nRanges (high)419 1, // nRanges (low)420 0, // range struct 0 - first (high)421 0, // range struct 0 - first (low)422 0, // range struct 0 - fd423 0, // sentinel (high)424 2, // sentinel (low)425 ]);426 });427 it("compiles charset of CID font", function () {...
write-cff2.ts
Source:write-cff2.ts
1import { Frag, Write } from "@ot-builder/bin-util";2import { Errors } from "@ot-builder/errors";3import { Cff, OtGlyph } from "@ot-builder/ot-glyphs";4import { Head } from "@ot-builder/ot-metadata";5import { Data } from "@ot-builder/prelude";6import { OtVar } from "@ot-builder/variance";7import { CffCfg } from "../cfg";8import { CffSubroutineIndex } from "../char-string/read/subroutine-index";9import { CharStringGlobalOptimizeResult } from "../char-string/write/global-optimize/general";10import { CffWriteContext } from "../context/write";11import { CffFdArrayIo } from "../dict/font-dict";12import { CffTopDictIo, CffTopDictWrite } from "../dict/top";13import { CffFdSelect } from "../fd-select/io";14import { Cff2Header } from "../structs/cff2-header";15import { Cff2IVS } from "../structs/cff2-ivs";16import { buildCharStrings, cffCleanupUnusedData, getRevFdSelect } from "./shared";17export const WriteCff2 = Write(18 (19 frag: Frag,20 cff: Cff.Table,21 gOrd: Data.Order<OtGlyph>,22 cfg: CffCfg,23 head: Head.Table,24 designSpace?: Data.Maybe<OtVar.DesignSpace>,25 stat?: Data.Maybe<OtGlyph.Stat.Sink>26 ) => {27 cffCleanupUnusedData(cff);28 const ctx = new CffWriteContext(cff.version, head.unitsPerEm, !!designSpace, stat);29 const charStringResults = buildCharStrings(cff, cfg, gOrd, ctx);30 const td: CffTopDictWrite = setupTopDict(cff, gOrd, charStringResults, ctx, designSpace);31 const fgTop = Frag.from(CffTopDictIo, td, ctx, undefined);32 // WRITE!33 frag.push(Cff2Header, {34 majorVersion: 2,35 minorVersion: 0,36 headerSize: 5,37 topDictLength: fgTop.size38 });39 frag.embed(fgTop);40 frag.push(CffSubroutineIndex, charStringResults.globalSubroutines, ctx);41 cffCleanupUnusedData(cff);42 }43);44function setupTopDict(45 cff: Cff.Table,46 gOrd: Data.Order<OtGlyph>,47 charStringResults: CharStringGlobalOptimizeResult,48 ctx: CffWriteContext,49 designSpace?: Data.Maybe<OtVar.DesignSpace>50) {51 const td: CffTopDictWrite = new CffTopDictWrite(cff.topDict);52 td.fgCharStrings = Frag.from(CffSubroutineIndex, charStringResults.charStrings, ctx);53 if (!cff.fdArray) throw Errors.Cff.ShouldHaveFdArray();54 td.fgFDArray = Frag.from(CffFdArrayIo, cff.fdArray, ctx);55 if (cff.fdSelect) td.fgFDSelect = Frag.from(CffFdSelect, getRevFdSelect(cff, gOrd), ctx);56 else td.fgFDSelect = null;57 if (ctx.ivs && designSpace) td.fgVarStore = Frag.from(Cff2IVS, ctx.ivs, designSpace);58 else td.fgVarStore = null;59 return td;...
Using AI Code Generation
1wptext.CFFFDSelect()2wptext.CFFFDSelect()3wptext.CFFFDSelect()4wptext.CFFFDSelect()5wptext.CFFFDSelect()6wptext.CFFFDSelect()7wptext.CFFFDSelect()8wptext.CFFFDSelect()9wptext.CFFFDSelect()10wptext.CFFFDSelect()11wptext.CFFFDSelect()12wptext.CFFFDSelect()13wptext.CFFFDSelect()14wptext.CFFFDSelect()15wptext.CFFFDSelect()16wptext.CFFFDSelect()17wptext.CFFFDSelect()18wptext.CFFFDSelect()19wptext.CFFFDSelect()20wptext.CFFFDSelect()21wptext.CFFFDSelect()
Using AI Code Generation
1var wptext = require('wptext');2var cfffdselect = new wptext.CFFFDSelect();3cfffdselect.addRange(0, 3, 1);4cfffdselect.addRange(4, 4, 2);5cfffdselect.addRange(5, 5, 1);6console.log(cfffdselect.getGlyphID(0));7console.log(cfffdselect.getGlyphID(1));8console.log(cfffdselect.getGlyphID(2));9console.log(cfffdselect.getGlyphID(3));10console.log(cfffdselect.getGlyphID(4));11console.log(cfffdselect.getGlyphID(5));12console.log(cfffdselect.getGlyphID(6));13console.log(cfffdselect.getGlyphID(7));14var wptext = require('wptext');15var cfffdselect = new wptext.CFFFDSelect();16cfffdselect.addRange(0, 3, 1);17cfffdselect.addRange(4, 4, 2);18cfffdselect.addRange(5, 5, 1);19console.log(cfffdselect.getGlyphID(0));20console.log(cfffdselect.getGlyphID(1));21console.log(cfffdselect.getGlyphID(2));22console.log(cfffdselect.getGlyphID(3));23console.log(cfffdselect.getGlyphID(4));24console.log(cfffdselect.getGlyphID(5));25console.log(cfffdselect.getGlyphID(6));26console.log(cfffdselect.getGlyphID(7));27var wptext = require('wptext');28var cfffdselect = new wptext.CFFFDSelect();29cfffdselect.addRange(0, 3, 1);30cfffdselect.addRange(4, 4, 2);
Using AI Code Generation
1var text = new wptext();2var cfffdselect = text.cfffdselect();3var cfffdselect = text.cfffdselect(0);4var cfffdselect = text.cfffdselect(0, 1);5var cfffdselect = text.cfffdselect(0, 1, 2);6var cfffdselect = text.cfffdselect(0, 1, 2, 3);7var cfffdselect = text.cfffdselect(0, 1, 2, 3, 4);8var cfffdselect = text.cfffdselect(0, 1, 2, 3, 4, 5);9var cfffdselect = text.cfffdselect(0, 1, 2, 3, 4, 5, 6);10var cfffdselect = text.cfffdselect(0, 1, 2, 3, 4, 5, 6, 7);11var cfffdselect = text.cfffdselect(0, 1, 2, 3, 4, 5, 6, 7, 8);12var cfffdselect = text.cfffdselect(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);13var text = new wptext();14var cfffdselect = text.cfffdselect();15var cfffdselect = text.cfffdselect(0);16var cfffdselect = text.cfffdselect(0, 1);17var cfffdselect = text.cfffdselect(0, 1, 2);18var cfffdselect = text.cfffdselect(0, 1, 2, 3);19var cfffdselect = text.cfffdselect(0, 1, 2, 3, 4);20var cfffdselect = text.cfffdselect(0, 1, 2, 3, 4, 5);21var cfffdselect = text.cfffdselect(0, 1, 2, 3, 4, 5, 6);
Using AI Code Generation
1var wptools = require('wp-tools');2var fs = require('fs');3var font = new wptools.Font(fs.readFileSync('font.ttf'));4var char = 'a';5var charcode = char.charCodeAt(0);6var glyph = font.getGlyph(charcode);7console.log(glyph.charcode);8console.log(glyph.name);9console.log(glyph.unicode);10console.log(glyph.advanceWidth);11console.log(glyph.leftSideBearing);12console.log(glyph.rightSideBearing);13console.log(glyph.xMin);14console.log(glyph.xMax);15console.log(glyph.yMin);16console.log(glyph.yMax);17console.log(glyph.contours);18var path = glyph.getPath(0, 0, 72);19console.log(path.commands);20var opentype = require('opentype.js');21var font = opentype.loadSync('font.ttf');22var glyph = font.charToGlyph(char);23console.log(glyph.charcode);24console.log(glyph.name);25console.log(glyph.unicode);26console.log(glyph.advanceWidth);27console.log(glyph.leftSideBearing);28console.log(glyph.rightSideBearing);29console.log(glyph.xMin);30console.log(glyph.xMax);31console.log(glyph.yMin);32console.log(glyph.yMax);33console.log(glyph.path.commands);34var PDFDocument = require('pdfkit');35var doc = new PDFDocument;36var font = doc.openFont('font.ttf');37var glyph = font.charToGlyph(char);38console.log(glyph.charcode);39console.log(glyph.name);40console.log(glyph.unicode);41console.log(glyph.advanceWidth);42console.log(glyph.leftSideBearing);43console.log(glyph.rightSideBearing);44console.log(glyph.xMin);45console.log(glyph.xMax);46console.log(glyph.yMin);47console.log(glyph.yMax);48console.log(glyph.path.commands);49var PDFDocument = require('pdfkit');50var doc = new PDFDocument;51var font = doc.openFont('font.ttf');52var glyph = font.charToGlyph(char);53console.log(glyph.charcode);54console.log(glyph.name);55console.log(glyph.unicode);56console.log(glyph.advanceWidth);57console.log(glyph.leftSideBearing);58console.log(g
Using AI Code Generation
1var wptools = require('wptools');2var test = wptools('Apple Inc.');3test.cfffdselect(function(err, result) {4 console.log(result);5});6{ '0': 'Apple Inc.',
Using AI Code Generation
1var font = new WPTextFont("test.ttf");2var glyph = font.glyphFromChar("A");3var charCode = glyph.charCode;4var cff = font.cffTable;5var cfffdselect = cff.fdSelect;6var fd = cfffdselect.fdForGlyph(charCode);7print("fd = " + fd);
Using AI Code Generation
1var fs = require('fs');2var wptext = require('./wptext.js');3var cfffdselect = wptext.cfffdselect;4var rawdata = fs.readFileSync('test.cff');5var cfffdselect = new cfffdselect(rawdata);6var glyph = 0;7var first = cfffdselect.getFirst(glyph);8var last = cfffdselect.getLast(glyph);9console.log("first: " + first + " last: " + last);10var char = 0x41;11var glyph = cfffdselect.getGlyph(char);12console.log("glyph: " + glyph);13var char = 0x42;14var glyph = cfffdselect.getGlyph(char);15console.log("glyph: " + glyph);16var char = 0x43;17var glyph = cfffdselect.getGlyph(char);18console.log("glyph: " + glyph);19var char = 0x44;20var glyph = cfffdselect.getGlyph(char);21console.log("glyph: " + glyph);22var char = 0x45;23var glyph = cfffdselect.getGlyph(char);24console.log("glyph: " + glyph);25var char = 0x46;26var glyph = cfffdselect.getGlyph(char);27console.log("glyph: " + glyph);28var char = 0x47;29var glyph = cfffdselect.getGlyph(char);30console.log("glyph: " + glyph);31var char = 0x48;32var glyph = cfffdselect.getGlyph(char);33console.log("glyph: " + glyph);34var char = 0x49;35var glyph = cfffdselect.getGlyph(char);36console.log("glyph: " + glyph);37var char = 0x4A;38var glyph = cfffdselect.getGlyph(char);39console.log("glyph: " + glyph);40var char = 0x4B;41var glyph = cfffdselect.getGlyph(char);42console.log("glyph: " + glyph);43var char = 0x4C;44var glyph = cfffdselect.getGlyph(char);45console.log("glyph: " + glyph);46var char = 0x4D;47var glyph = cfffdselect.getGlyph(char);
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!