How to use Type1Font method in wpt

Best JavaScript code snippet using wpt

Type1Font.js

Source:Type1Font.js Github

copy

Full Screen

1goog.provide("trapeze.font.Type1Font");2goog.require("trapeze.font.OutlineFont");3goog.require("trapeze.font.PSParser");4goog.require("trapeze.font.FontSupport");5goog.require("trapeze.StreamBuffer");6goog.require("trapeze.GeneralPath");7goog.require("trapeze.AffineTransform");89trapeze.font.Type1Font = function(baseFont, fontObj, descriptor) {10 trapeze.font.OutlineFont.call(this, baseFont, fontObj, descriptor);11 this.name2width;12 this.char2name;13 this.password = 0;14 this.at;15 this.subrs;16 this.lenIV;17 this.name2outline;18 /** the Type1 stack of command values */19 this.stack = [];20 /** the current position in the Type1 stack */21 this.sloc = 0;22 /** the stack of postscript commands (used by callothersubr) */23 this.psStack = [];24 /** the current position in the postscript stack */25 this.psLoc = 0;26 this.callcount = 0;27 28 if (descriptor != null && descriptor.fontFile != null) {29 // parse that file, filling name2outline and chr2name30 var start = descriptor.fontFile.dictionary.getDictionaryObject("Length1").value;31 var len = descriptor.fontFile.dictionary.getDictionaryObject("Length2").value;32 var font = new trapeze.StreamBuffer(descriptor.fontFile.decode());3334 this.parseFontFromStream(font, start, len);35 }36};37goog.inherits(trapeze.font.Type1Font, trapeze.font.OutlineFont);383940trapeze.font.Type1Font.prototype.parseFontFromStream = function(font, start, len) {41 this.name2width = {};4243 var data = null;4445 if (this.isASCII(font, start)) {46 //var bData = readASCII(font, start, start + len);47 //data = decrypt(bData, 0, bData.length, 55665, 4);48 // TODO49 throw "not done in type1font ascii";50 } else {51 data = trapeze.font.Type1Font.decrypt(font, start, start + len, 55665, 4);52 }53 var fontArray = [];54 var i = 0;55 while(font.hasRemaining())56 {57 font.setPosition(i);58 fontArray.push(font.getByteAt(i++));59 }60 // encoding is in cleartext area61 this.chr2name = this.readEncoding(fontArray);62 var lenIVLoc = this.findSlashName(data, "lenIV");63 64 var psp = new trapeze.font.PSParser(data, 0);65 if (lenIVLoc < 0) {66 this.lenIV = 4;67 } else {68 psp.setLoc(lenIVLoc + 6);69 this.lenIV = parseInt(psp.readThing());70 }71 this.password = 4330;72 var matrixloc = this.findSlashName(fontArray, "FontMatrix");73 if (matrixloc < 0) {74 System.out.println("No FontMatrix!");75 this.at = new trapeze.AffineTransform(0.001, 0, 0, 0.001, 0, 0);76 } else {77 var psp2 = new trapeze.font.PSParser(fontArray, matrixloc + 11);78 // read [num num num num num num]79 var xf = psp2.readArray(6);80 // System.out.println("FONT MATRIX: "+xf);81 this.at = new trapeze.AffineTransform(xf[0], xf[1], xf[2], xf[3], xf[4], xf[5]);82 }8384 this.subrs = this.readArray(data, "Subrs", "index");85 this.name2outline = this.readChars(data);86};87/** 88 * Determine if data is in ASCII or binary format. According to the spec,89 * if any of the first 4 bytes are not character codes ('0' - '9' or90 * 'A' - 'F' or 'a' - 'f'), then the data is binary. Otherwise it is91 * ASCII92 */93trapeze.font.Type1Font.prototype.isASCII = function(data, start) {94 // look at the first 4 bytes95 for (var i = start; i < start + 4; i++) {96 // get the byte as a character97 var c = data.getByteAt(i);9899 if (c >= '0' && c <= '9') {100 continue;101 } else if (c >= 'a' && c <= 'f') {102 continue;103 } else if (c >= 'A' && c <= 'F') {104 continue;105 } else {106 // out of range107 return false;108 }109 }110};111112/**113 * parse the encoding portion of the font definition114 * @param d the font definition stream115 * @return an array of the glyphs corresponding to each byte116 */117trapeze.font.Type1Font.prototype.readEncoding = function(d) {118 var ary = this.readArray(d, "Encoding", "def");119 return ary;120 /*121 // TODO strip slash like below122 var res = []; //new String[256];123 for (int i = 0; i < ary.length; i++) {124 if (ary[i] != null) {125 if (ary[i][0] == '/') {126 res[i] = new String(ary[i]).substring(1);127 } else {128 res[i] = new String(ary[i]);129 }130 } else {131 res[i] = null;132 }133 }134 return res;135 */136};137/**138 * read a named array out of the font definition.139 * <p>140 * this function attempts to parse an array out of a postscript141 * definition without doing any postscript. It's actually looking142 * for things that look like "dup <i>id</i> <i>elt</i> put", and143 * placing the <i>elt</i> at the <i>i</i>th position in the array.144 * @param d the font definition stream145 * @param key the name of the array146 * @param end a string that appears at the end of the array147 * @return an array consisting of a byte array for each entry148 */149trapeze.font.Type1Font.prototype.readArray = function(d, key, end) {150 var i = this.findSlashName(d, key);151 if (i < 0) {152 // not found.153 return [[]]; //new byte[0][];154 }155 // now find things that look like "dup id elt put"156 // end at "def"157 var psp = new trapeze.font.PSParser(d, i);158 var type = psp.readThing(); // read the key (i is the start of the key)159 var val;160 type = psp.readThing();161 if (type == "StandardEncoding") {162 var stdenc = [];163 var length = trapeze.font.FontSupport.standardEncoding.length;164 for (i = 0; i < length; i++) {165 stdenc[i] = trapeze.font.FontSupport.getName(trapeze.font.FontSupport.standardEncoding[i]); //.getBytes();166 }167 return stdenc;168 }169 170 var len = parseInt(type);171 var out = []; //new byte[len][];172 var line;173 while (true) {174 var s = psp.readThing();175 if (s == "dup") {176 var id = parseInt(psp.readThing());177 var elt = psp.readThing();178 line = getBytes(elt);179 if (isDigit(elt.charAt(0))) {180 var hold = parseInt(elt);181 var special = psp.readThing();182 if (special == "-|" || special == "RD") {183 psp.setLoc(psp.getLoc() + 1);184 line = psp.getNEncodedBytes(hold, this.password, this.lenIV);185 }186 }187 out[id] = line;188 } else if (s == end) {189 break;190 }191 }192 return out;193};194/**195 * get the index into the byte array of a slashed name, like "/name".196 * @param d the search array197 * @param name the name to look for, without the initial /198 * @return the index of the first occurance of /name in the array.199 */200trapeze.font.Type1Font.prototype.findSlashName = function(d, name) {201 var i;202 for (i = 0; i < d.length; i++) {203 if (d[i] == '/'.charCodeAt(0)) {204 // check for key205 var found = true;206 for (var j = 0; j < name.length; j++) {207 if (d[i + j + 1] != name.charCodeAt(j)) {208 found = false;209 break;210 }211 }212 if (found) {213 return i;214 }215 }216 }217 return -1;218};219/**220 * get the character definitions of the font.221 * @param d the font data222 * @return a HashMap that maps string glyph names to byte arrays of223 * decoded font data.224 */225trapeze.font.Type1Font.prototype.readChars = function(d) {226 // skip thru data until we find "/"+key227 var hm = {};228 var i = this.findSlashName(d, "CharStrings");229 if (i < 0) {230 // not found231 return hm;232 }233 var psp = new trapeze.font.PSParser(d, i);234 // read /name len -| [len bytes] |-235 // until "end"236 while (true) {237 var s = psp.readThing();238 var c = s.charAt(0);239 if (c == '/') {240 var len = parseInt(psp.readThing());241 var go = psp.readThing(); // it's -| or RD242 if (go == "-|" || go == "RD") {243 psp.setLoc(psp.getLoc() + 1);244 var line = psp.getNEncodedBytes(len, this.password, this.lenIV);245 hm[s.substring(1)] = line;246 }247 } else if (s == "end") {248 break;249 }250 }251 return hm;252};253/** 254 * Get the width of a given character255 *256 * This method is overridden to work if the width array hasn't been257 * populated (as for one of the 14 base fonts)258 */259trapeze.font.Type1Font.prototype.getWidth = function(code, name) {260 // we don't have first and last chars, so therefore no width array261debugger; if (this.firstChar == -1 || this.lastChar == -1) {262 var key = this.chr2name[toSignedByte(code)];263264 // use a name if one is provided265 if (name != null) {266 key = name;267 }268269 if (key != null && this.name2outline[key] != null) {270 if (this.name2width[key] == null) {271 // glyph has not yet been parsed272 // getting the outline will force it to get read273 this.getOutlineByName(key, 0);274 }275276 var width = this.name2width[key];277 if (width != null) {278 return width.x / this.getDefaultWidth();279 }280 }281282 return 0;283 }284285 // return the width that has been specified286 return trapeze.font.Type1Font.superClass_.getWidth.call(this, code, name);287};288/**289 * Get a glyph outline by name290 *291 * @param name the name of the desired glyph292 * @return the glyph outline, or null if unavailable293 */294trapeze.font.Type1Font.prototype.getOutlineByName = function(name, width) {295 // make sure we have a valid name296 if (name == null || this.name2outline[name] == null) {297 name = ".notdef";298 }299300 // get whatever is stored in name. Could be a GeneralPath, could be byte[]301 var obj = this.name2outline[name];302303 // if it's a byte array, it needs to be parsed304 // otherwise, just return the path305 if (obj instanceof trapeze.GeneralPath) {306 return obj;307 } else {308 var cs = obj;309 var advance = {};310311 var gp = this.parseGlyph(cs, advance, this.at);312313 if (width != 0 && advance.x != 0) {314 // scale the glyph to fit in the width315 var p = {"x": advance.x, "y": advance.y};316 p = this.at.transform(p);317318 var scale = width / p.x;319 var xform = trapeze.AffineTransform.getScaleInstance(scale, 1.0);320 gp.transform(xform);321 }322323 // put the parsed object in the cache324 this.name2outline[name] = gp;325 this.name2width[name] = advance;326 return gp;327 }328};329/**330 * Get a glyph outline by character code331 *332 * Note this method must always return an outline 333 *334 * @param src the character code of the desired glyph335 * @return the glyph outline336 */337trapeze.font.Type1Font.prototype.getOutlineByCode = function(src, width) {338 return this.getOutlineByName(this.chr2name[toSignedByte(src)], width);339};340 /**341 * Decrypt a glyph stored in byte form342 */343trapeze.font.Type1Font.prototype.parseGlyph = function(cs, advance, at) {344 var gp = new trapeze.GeneralPath();345 var curpoint = {"x": null, "y": null};346347 this.sloc = 0;348 this.parse(cs, gp, curpoint, advance);349350 gp.transform(at);351 return gp;352};353 /**354 * pop the next item off the stack355 */356trapeze.font.Type1Font.prototype.pop = function() {357 var val = 0;358 if (this.sloc > 0) {359 val = this.stack[--this.sloc];360 }361 return val;362};363/**364 * build an accented character out of two pre-defined glyphs.365 * @param x the x offset of the accent366 * @param y the y offset of the accent367 * @param a the index of the accent glyph368 * @param b the index of the base glyph369 * @param gp the GeneralPath into which the combined glyph will be370 * written.371 */372trapeze.font.Type1Font.prototype.buildAccentChar = function(x, y, a, b, gp) {373 // get the outline of the accent374 console.warn("build aaccent char not finished yet");375 /*376 var pathA = this.getOutlineByCode(String.fromCharCode(a), this.getWidth(String.fromCharCode(a), null));377378 var xformA = this.at.createInverse();379 xformA = xformA.translate(x, y);380 pathA.transform(xformA);381382 var pathB = this.getOutlineByCode(String.fromCharCode(b), this.getWidth(String.fromCharCode(b), null));383384 var xformB = this.at.createInverse();385 pathB.transform(xformB);386387 gp.append(pathB, false);388 gp.append(pathA, false); */389};390/**391 * parse glyph data into a GeneralPath, and return the advance width.392 * The working point is passed in as a parameter in order to allow393 * recursion.394 * @param cs the decrypted glyph data395 * @param gp a GeneralPath into which the glyph shape will be stored396 * @param pt a FlPoint object that will be used to generate the path397 * @param wid a FlPoint into which the advance width will be placed.398 */399trapeze.font.Type1Font.prototype.parse = function(cs, gp, pt, wid) {400 // System.out.println("--- cmd length is "+cs.length);401 var loc = 0;402 var x1, x2, x3, y1, y2, y3;403 while (loc < cs.length) {404 var v = cs[loc++] & 0xff;405 if (v == 255) {406 this.stack[this.sloc++] = (((cs[loc]) & 0xff) << 24) +407 ((( cs[loc + 1]) & 0xff) << 16) +408 ((( cs[loc + 2]) & 0xff) << 8) +409 ((( cs[loc + 3]) & 0xff));410 loc += 4;411// System.out.println("Pushed long "+stack[sloc-1]);412 } else if (v >= 251) {413 this.stack[this.sloc++] = -((v - 251) << 8) - ((cs[loc]) & 0xff) - 108;414 loc++;415// System.out.println("Pushed lo "+stack[sloc-1]);416 } else if (v >= 247) {417 this.stack[this.sloc++] = ((v - 247) << 8) + ((cs[loc]) & 0xff) + 108;418 loc++;419// System.out.println("Pushed hi "+stack[sloc-1]);420 } else if (v >= 32) {421 this.stack[this.sloc++] = v - 139;422// System.out.println("Pushed "+stack[sloc-1]);423 } else {424 // System.out.println("CMD: "+v+" (stack is size "+sloc+")");425 switch (v) {426 case 0: // x427 throw new RuntimeException("Bad command (" + v + ")");428 case 1: // hstem429 this.sloc = 0;430 break;431 case 2: // x432 throw new RuntimeException("Bad command (" + v + ")");433 case 3: // vstem434 this.sloc = 0;435 break;436 case 4: // y vmoveto437 pt.y += this.pop();438 gp.moveTo(pt.x, pt.y);439 this.sloc = 0;440 break;441 case 5: // x y rlineto442 pt.y += this.pop();443 pt.x += this.pop();444 gp.lineTo(pt.x, pt.y);445 this.sloc = 0;446 break;447 case 6: // x hlineto448 pt.x += this.pop();449 gp.lineTo(pt.x, pt.y);450 this.sloc = 0;451 break;452 case 7: // y vlineto453 pt.y += this.pop();454 gp.lineTo(pt.x, pt.y);455 this.sloc = 0;456 break;457 case 8: // x1 y1 x2 y2 x3 y3 rcurveto458 y3 = this.pop();459 x3 = this.pop();460 y2 = this.pop();461 x2 = this.pop();462 y1 = this.pop();463 x1 = this.pop();464 gp.curveTo(pt.x + x1, pt.y + y1,465 pt.x + x1 + x2, pt.y + y1 + y2,466 pt.x + x1 + x2 + x3, pt.y + y1 + y2 + y3);467 pt.x += x1 + x2 + x3;468 pt.y += y1 + y2 + y3;469 this.sloc = 0;470 break;471 case 9: // closepath472 gp.closePath();473 this.sloc = 0;474 break;475 case 10: // n callsubr476 var n = this.pop();477 if (this.subrs[n] == null) {478 System.out.println("No subroutine #" + n);479 } else {480 this.callcount++;481 if (this.callcount > 10) {482 System.out.println("Call stack too large");483 // throw new RuntimeException("Call stack too large");484 } else {485 this.parse(this.subrs[n], gp, pt, wid);486 }487 this.callcount--;488 }489 break;490 case 11: // return491 return;492 case 12: // ext...493 v = (cs[loc++]) & 0xff;494 if (v == 6) { // s x y a b seac495 var b = this.pop();496 var a = this.pop();497 var y = this.pop();498 var x = this.pop();499 this.buildAccentChar(x, y, a, b, gp);500 this.sloc = 0;501 } else if (v == 7) { // x y w h sbw502 wid.y = this.pop();503 wid.x = this.pop();504 pt.y = this.pop();505 pt.x = this.pop();506 this.sloc = 0;507 } else if (v == 12) { // a b div -> a/b508 var b = this.pop();509 var a = this.pop();510 this.stack[this.sloc++] = a / b;511 } else if (v == 33) { // a b setcurrentpoint512 pt.y = this.pop();513 pt.x = this.pop();514 gp.moveTo(pt.x, pt.y);515 this.sloc = 0;516 } else if (v == 0) { // dotsection517 this.sloc = 0;518 } else if (v == 1) { // vstem3519 this.sloc = 0;520 } else if (v == 2) { // hstem3521 this.sloc = 0;522 } else if (v == 16) { // n callothersubr523 var cn = this.pop();524 var countargs = this.pop();525526 // System.out.println("Called othersubr with index "+cn);527528 switch (cn) {529 case 0:530 // push args2 and args3 onto stack531 this.psStack[this.psLoc++] = this.pop();532 this.psStack[this.psLoc++] = this.pop();533 this.pop();534 break;535 case 3:536 // push 3 onto the postscript stack537 this.psStack[this.psLoc++] = 3;538 break;539 default:540 // push arguments onto the postscript stack541 for (var i = 0; i > countargs; i--) {542 this.psStack[this.psLoc++] = this.pop();543 }544 break;545 }546 } else if (v == 17) { // pop547 // pop from the postscript stack onto the type1 stack548 this.stack[this.sloc++] = this.psStack[this.psLoc - 1];549 this.psLoc--;550 } else {551 throw new RuntimeException("Bad command (" + v + ")");552 }553 break;554 case 13: // s w hsbw555 wid.x = this.pop();556 wid.y = 0;557 pt.x = this.pop();558 pt.y = 0;559 // gp.moveTo(pt.x, pt.y);560 this.sloc = 0;561 break;562 case 14: // endchar563 // return;564 break;565 case 15: // x566 case 16: // x567 case 17: // x568 case 18: // x569 case 19: // x570 case 20: // x571 throw new RuntimeException("Bad command (" + v + ")");572 case 21: // x y rmoveto573 pt.y += this.pop();574 pt.x += this.pop();575 gp.moveTo(pt.x, pt.y);576 this.sloc = 0;577 break;578 case 22: // x hmoveto579 pt.x += this.pop();580 gp.moveTo(pt.x, pt.y);581 this.sloc = 0;582 break;583 case 23: // x584 case 24: // x585 case 25: // x586 case 26: // x587 case 27: // x588 case 28: // x589 case 29: // x590 throw new RuntimeException("Bad command (" + v + ")");591 case 30: // y1 x2 y2 x3 vhcurveto592 x3 = this.pop();593 y2 = this.pop();594 x2 = this.pop();595 y1 = this.pop();596 x1 = y3 = 0;597 gp.curveTo(pt.x, pt.y + y1,598 pt.x + x2, pt.y + y1 + y2,599 pt.x + x2 + x3, pt.y + y1 + y2);600 pt.x += x2 + x3;601 pt.y += y1 + y2;602 this.sloc = 0;603 break;604 case 31: // x1 x2 y2 y3 hvcurveto605 y3 = this.pop();606 y2 = this.pop();607 x2 = this.pop();608 x1 = this.pop();609 y1 = x3 = 0;610 gp.curveTo(pt.x + x1, pt.y,611 pt.x + x1 + x2, pt.y + y2,612 pt.x + x1 + x2, pt.y + y2 + y3);613 pt.x += x1 + x2;614 pt.y += y2 + y3;615 this.sloc = 0;616 break;617 }618 }619 }620};621/**622 * decrypt an array using the Adobe Type 1 Font decryption algorithm.623 * @param d the input array of bytes624 * @param start where in the array to start decoding625 * @param end where in the array to stop decoding626 * @param key the decryption key627 * @param skip how many bytes to skip initially628 * @return the decrypted bytes. The length of this array will be629 * (start-end-skip) bytes long630 */631trapeze.font.Type1Font.decrypt = function(d, start, end, key, skip) {632 if (end - start - skip < 0) {633 skip = 0;634 }635 var o = []; //new byte[end - start - skip];636 var r = key;637 var ipos;638 var c1 = 52845;639 var c2 = 22719;640 for (ipos = start; ipos < end; ipos++) {641 var c;642 if(d instanceof trapeze.StreamBuffer)643 c = d.getByteAt(ipos) & 0xff;644 else645 c = d[ipos] & 0xff;646 var p = (c ^ (r >> 8)) & 0xff;647 r = ((c + r) * c1 + c2) & 0xffff;648 if (ipos - start - skip >= 0) {649 if(p > 127)650 p = p - 256;651 else652 p = p;653 o[ipos - start - skip] = p;654 }655 }656 return o; ...

Full Screen

Full Screen

descriptor.ts

Source:descriptor.ts Github

copy

Full Screen

1import * as glyphmaps from '../encoding/glyphmaps';2import {Model, ContentStream} from '../models';3import {mergeArray} from '../util';4const encodingNameRegExp = /\/Encoding\s+(StandardEncoding|MacRomanEncoding|WinAnsiEncoding|PDFDocEncoding)/;5/**6Parse a Type1 Font Program and return a glyphmap (mapping from character codes to glyphnames)7*/8function parseEncoding(program: string): string[] {9 const Encoding_start_index = program.indexOf('/Encoding');10 const Encoding_string = program.slice(Encoding_start_index);11 const glyphmap: string[] = [];12 // if the program specifies a base encoding, use it as the base13 const encodingNameMatch = Encoding_string.match(encodingNameRegExp);14 if (encodingNameMatch !== null) {15 const encodingName = encodingNameMatch[1];16 mergeArray(glyphmap, glyphmaps[encodingName] || []);17 }18 const charCodeGlyphRegExp = /dup (\d+) \/(\w+) put/g;19 let match;20 while ((match = charCodeGlyphRegExp.exec(Encoding_string))) {21 const [, charCode, glyphname] = match;22 glyphmap[parseInt(charCode, 10)] = glyphname;23 }24 return glyphmap;25}26/**27See PDF32000_2008.pdf:9.8 Font Descriptors28*/29export class FontDescriptor extends Model {30 get CharSet(): string[] {31 const CharSet = this.get('CharSet');32 return CharSet ? CharSet.toString().slice(1).split('/') : [];33 }34 /**35 From PDF32000_2008.pdf:Table 12236 > The weight (thickness) component of the fully-qualified font name or font37 > specifier. The possible values shall be 100, 200, 300, 400, 500, 600, 700,38 > 800, or 900, where each number indicates a weight that is at least as dark39 > as its predecessor. A value of:40 > * 400 shall indicate a normal weight;41 > * 700 shall indicate bold.42 > The specific interpretation of these values varies from font to font.43 */44 // get FontWeight(): number {45 // return this.get('FontWeight');46 // }47 /**48 From PDF32000_2008.pdf:Table 12249 > The angle, expressed in degrees counterclockwise from the vertical, of the50 > dominant vertical strokes of the font. The 9-o'clock position is 90 degrees,51 > and the 3-o'clock position is –90 degrees. The value shall be negative for52 > fonts that slope to the right, as almost all italic fonts do.53 */54 // get ItalicAngle(): number {55 // return this.get('ItalicAngle');56 // }57 // get MissingWidth(): number {58 // return this.get('MissingWidth');59 // }60 private getType1FontProgramClearText(): string {61 const Type1FontProgram = new ContentStream(this._pdf, this.object['FontFile']);62 if (Type1FontProgram.object) {63 const Length1 = Type1FontProgram.dictionary.Length1 as number;64 return Type1FontProgram.buffer.toString('ascii', 0, Length1);65 }66 }67 getWeight(): string {68 const Type1FontProgram_string = this.getType1FontProgramClearText();69 if (Type1FontProgram_string) {70 const weightRegExp = /\/Weight\s+\(([^\)]+)\)/;71 const weightMatch = Type1FontProgram_string.match(weightRegExp);72 if (weightMatch !== null) {73 return weightMatch[1];74 }75 }76 }77 /**78 From T1_SPEC.pdf:79 > The tokens following /Encoding may be StandardEncoding def, in which case the Adobe Standard Encoding will be assigned to this font program. For special encodings, assignments must be performed as shown in the example in section 2.3, “Explanation of a Typical Font Program,” using the repetitive sequence:80 > dup index charactername put81 > where index is an integer corresponding to an entry in the Encoding vector, and charactername refers to a PostScript language name token, such as /Alpha or /A, giving the character name assigned to a particular character code. The Adobe Type Manager parser skips to the first dup token after /Encoding to find the first character encoding assignment. This sequence of assignments must be followed by an instance of the token def or readonly; such a token may not occur within the sequence of assignments.82 */83 getGlyphmap(): string[] {84 const Type1FontProgram_string = this.getType1FontProgramClearText();85 if (Type1FontProgram_string) {86 return parseEncoding(Type1FontProgram_string);87 }88 return [];89 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var type1 = new wptools.Type1Font('Helvetica');3console.log(type1.getGlyphWidths());4console.log(type1.getGlyphWidths('A'));5console.log(type1.getGlyphWidths('A', 100));6var wptools = require('wptools');7var type1 = new wptools.Type1Font('Helvetica');8console.log(type1.getGlyphWidths());9console.log(type1.getGlyphWidths('A'));10console.log(type1.getGlyphWidths('A', 100));11var wptools = require('wptools');12var type1 = new wptools.Type1Font('Helvetica');13console.log(type1.getGlyphWidths());14console.log(type1.getGlyphWidths('A'));15console.log(type1.getGlyphWidths('A', 100));16var wptools = require('wptools');17var type1 = new wptools.Type1Font('Helvetica');18console.log(type1.getGlyphWidths());19console.log(type1.getGlyphWidths('A'));20console.log(type1.getGlyphWidths('A', 100));21var wptools = require('wptools');22var type1 = new wptools.Type1Font('Helvetica');23console.log(type1.getGlyphWidths());24console.log(type1.getGlyphWidths('A'));25console.log(type1.getGlyphWidths('A', 100));26var wptools = require('wptools');27var type1 = new wptools.Type1Font('Helvetica');28console.log(type1.getGlyphWidths());29console.log(type1.getGlyphWidths('A'));30console.log(type1.getGlyphWidths('A', 100));31var wptools = require('wptools');32var type1 = new wptools.Type1Font('Helvetica');33console.log(type1

Full Screen

Using AI Code Generation

copy

Full Screen

1var fs = require('fs');2var wptextconverter = require('wptextconverter');3var font = new wptextconverter.Type1Font('font.pfb');4var type1 = font.getType1();5fs.writeFileSync('font.pfa', type1);6var fs = require('fs');7var wptextconverter = require('wptextconverter');8var font = new wptextconverter.Font('font.pfb');9var type1 = font.getType1();10fs.writeFileSync('font.pfa', type1);11var fs = require('fs');12var wptextconverter = require('wptextconverter');13var font = new wptextconverter.Font('font.pfb');14var type1 = font.getType1();15fs.writeFileSync('font.pfa', type1);16var fs = require('fs');17var wptextconverter = require('wptextconverter');18var font = new wptextconverter.Font('font.pfb');19var type1 = font.getType1();20fs.writeFileSync('font.pfa', type1);21var fs = require('fs');22var wptextconverter = require('wptextconverter');23var font = new wptextconverter.Font('font.pfb');24var type1 = font.getType1();25fs.writeFileSync('font.pfa', type1);26var fs = require('fs');27var wptextconverter = require('wptextconverter');28var font = new wptextconverter.Font('font.pfb');29var type1 = font.getType1();30fs.writeFileSync('font.pfa', type1);31var fs = require('fs');32var wptextconverter = require('wptextconverter');33var font = new wptextconverter.Font('font.pfb');34var type1 = font.getType1();35fs.writeFileSync('font.pfa', type1);

Full Screen

Using AI Code Generation

copy

Full Screen

1function test() {2 var doc = new jsPDF('p', 'pt', 'a4', true);3 doc.setFont('times', 'normal');4 doc.setFontSize(12);5 doc.text(20, 20, 'This is a test');6 doc.addFont('times.ttf', 'times', 'normal');7 doc.setFont('times', 'normal');8 doc.setFontSize(12);9 doc.text(20, 40, 'This is a test');10 doc.save('test.pdf');11}

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2wptools.init({3});4var wptools = require('wptools');5wptools.init({6});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptext2pdf = require('wptext2pdf');2var pdf = new wptext2pdf();3var font = new pdf.Type1Font("Helvetica", "ISO-8859-1");4pdf.setFont(font);5pdf.addText("Hello World!");6pdf.save("test.pdf");

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