commit 075cd395d1457e695718b534653527accaac1a60 Author: Belleve Invis Date: Sun Jul 19 07:14:01 2015 +0800 first commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ae2dfc2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,33 @@ +# Logs +logs +*.log + +# Runtime data +pids +*.pid +*.seed + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directory +# Deployed apps should consider commenting this line out: +# see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git +node_modules + +# Special +*.ttf +*.7z +test/ +preview/ +build/ +ref/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/empty.json b/empty.json new file mode 100644 index 0000000..7f453c5 --- /dev/null +++ b/empty.json @@ -0,0 +1,16 @@ +{ + "version":1, + "numTables":12, + "searchRenge":128, + "entrySelector":3, + "rengeShift":64, + "head":{"version":1,"fontRevision":1,"checkSumAdjustment":369537602,"magickNumber":1594834165,"flags":11,"unitsPerEm":1000,"created":"2014-12-06T22:05:19.000Z","modified":"2014-12-06T22:20:03.000Z","xMin":34,"yMin":0,"xMax":306,"yMax":682,"macStyle":0,"lowestRecPPEM":8,"fontDirectionHint":2,"indexToLocFormat":0,"glyphDataFormat":0}, + "glyf":[ + {"contours":[[{"x":34,"y":0,"onCurve":true},{"x":34,"y":682,"onCurve":true},{"x":306,"y":682,"onCurve":true},{"x":306,"y":0,"onCurve":true}],[{"x":68,"y":34,"onCurve":true},{"x":272,"y":34,"onCurve":true},{"x":272,"y":648,"onCurve":true},{"x":68,"y":648,"onCurve":true}]],"advanceWidth":500,"name":".notdef"} + ], + "cmap":{}, + "name":{"fontFamily":"fonteditor","fontSubFamily":"Medium","uniqueSubFamily":"FontEditor 1.0 : fonteditor : 6-10-2014","fullName":"fonteditor","version":"Version 1.0","postScriptName":"fonteditor"}, + "hhea":{"version":1,"ascent":812,"descent":-212,"lineGap":92,"advanceWidthMax":374,"minLeftSideBearing":34,"minRightSideBearing":68,"xMaxExtent":306,"caretSlopeRise":1,"caretSlopeRun":0,"caretOffset":0,"reserved0":0,"reserved1":0,"reserved2":0,"reserved3":0,"metricDataFormat":0,"numOfLongHorMetrics":1}, + "post":{"italicAngle":0,"postoints":65411,"underlinePosition":50,"underlineThickness":0,"isFixedPitch":0,"minMemType42":0,"maxMemType42":0,"minMemType1":0,"maxMemType1":1,"format":2}, + "OS/2":{"version":4,"xAvgCharWidth":1031,"usWeightClass":400,"usWidthClass":5,"fsType":0,"ySubscriptXSize":665,"ySubscriptYSize":716,"ySubscriptXOffset":0,"ySubscriptYOffset":143,"ySuperscriptXSize":665,"ySuperscriptYSize":716,"ySuperscriptXOffset":0,"ySuperscriptYOffset":491,"yStrikeoutSize":51,"yStrikeoutPosition":265,"sFamilyClass":0,"bFamilyType":2,"bSerifStyle":0,"bWeight":6,"bProportion":3,"bContrast":0,"bStrokeVariation":0,"bArmStyle":0,"bLetterform":0,"bMidline":0,"bXHeight":0,"ulUnicodeRange1":1,"ulUnicodeRange2":268435456,"ulUnicodeRange3":0,"ulUnicodeRange4":0,"achVendID":"PfEd","fsSelection":192,"usFirstCharIndex":0,"usLastCharIndex":0,"sTypoAscender":812,"sTypoDescender":-212,"sTypoLineGap":92,"usWinAscent":812,"usWinDescent":212,"ulCodePageRange1":1,"ulCodePageRange2":0,"sxHeight":792,"sCapHeight":0,"usDefaultChar":0,"usBreakChar":32,"usMaxContext":1} +} \ No newline at end of file diff --git a/font.js b/font.js new file mode 100644 index 0000000..c1b8fd9 --- /dev/null +++ b/font.js @@ -0,0 +1,1021 @@ +{ + var r0_font, r0_bezierCubic2Q2, r0_glyphList, r0_glyphs, r0_Bezier, r0_Smooth, r0_intersection, r0_para, r0_TINY, r0_LITTLE, r0_DESCENDER, r0_O, r0_WIDTH, r0_STROKE, r0_HALFSTROKE, r0_SB, r0_CAP, r0_XH, r0_XO, r0_HOOK, r0_SMOOTH, r0_SMALLSMOOTH, r0_RIGHTSB, r0_CAP_SMOOTH, r0_MIDDLE, r0_KAPPA, r0_COKAPPA, r0_COBKAPPA, r0_BKAPPA, r0_CAPMIDDLE, r0_CAPO, r0_ESS, r0_SAMPLES, r0_KAPPA_HOOK, r0_Glyph, r0_Stroke, r0_dforward, r0_dbackward, r0_nonlinear, r0_Ring, r0_ORing, r0_xn$createglyph$7Hrq, _r0_t0, _r0_t1, _r0_t2, _r0_t3, _r0_t4, _r0_t5, _r0_t6, _r0_t7, _r0_t8, _r0_t9, _r0_t10, _r0_t11, _r0_t12, _r0_t13, _r0_t14, _r0_t15, _r0_t16, _r0_t17, _r0_t18, _r0_t19, _r0_t20, _r0_t21, _r0_t22, _r0_t23, _r0_t24, _r0_t25, _r0_t26, _r0_t27, _r0_t28, _r0_t29, _r0_t30, _r0_t31, _r0_t32, _r0_t33, _r0_t34, _r0_t35, _r0_t36, _r0_t37, _r0_t38, _r0_t39, _r0_t40, _r0_t41, _r0_t42, _r0_t43, _r0_t44, _r0_t45, _r0_t46, _r0_t47, _r0_t48; + r0_font = require('./empty.json'); + r0_bezierCubic2Q2 = require('node-sfnt/lib/math/bezierCubic2Q2'); + r0_glyphList = r0_font['glyf']; + r0_glyphs = { '.notdef': r0_glyphList[0] }; + r0_Bezier = require('bezier-js'); + r0_Smooth = require('./smooth.js')['Smooth']; + r0_intersection = require('./intersection.js')['intersection']; + r0_para = { + 'width': 500, + 'stroke': 85, + 'sb': 50, + 'cap': 771, + 'xheight': 572, + 'hook': 135, + 'smooth': 192, + 'smallsmooth': 242, + 'o': -8, + 'descender': -178 + }; + r0_TINY = 0.0001; + r0_LITTLE = 0.01; + r0_DESCENDER = r0_para['descender']; + r0_O = r0_para['o']; + r0_WIDTH = r0_para['width']; + r0_STROKE = r0_para['stroke']; + r0_HALFSTROKE = r0_STROKE / 2; + r0_SB = r0_para['sb']; + r0_CAP = r0_para['cap']; + r0_XH = r0_para['xheight']; + r0_XO = r0_XH - r0_O; + r0_HOOK = r0_para['hook']; + r0_SMOOTH = r0_para['smooth']; + r0_SMALLSMOOTH = r0_para['smallsmooth']; + r0_RIGHTSB = r0_WIDTH - r0_SB; + r0_CAP_SMOOTH = r0_CAP - r0_SMOOTH; + r0_MIDDLE = r0_WIDTH / 2; + r0_KAPPA = 0.51; + r0_COKAPPA = 1 - r0_KAPPA; + r0_COBKAPPA = r0_COKAPPA - 0.1; + r0_BKAPPA = r0_KAPPA + 0.1; + r0_CAPMIDDLE = r0_CAP / 2; + r0_CAPO = r0_CAP - r0_O; + r0_ESS = r0_STROKE * 0.5; + r0_SAMPLES = 4; + r0_KAPPA_HOOK = 0.7; + r0_Glyph = function _r0_t0(r1_name) { + var r1_name, _r1_t0; + _r1_t0 = this; + _r1_t0['name'] = r1_name; + _r1_t0['unicode'] = []; + _r1_t0['contours'] = []; + _r1_t0['advanceWidth'] = 500; + return void 0; + }; + r0_Glyph['prototype']['set-width'] = function _r0_t1(r2_w) { + var r2_w, _r2_t0; + _r2_t0 = this; + _r2_t0['advanceWidth'] = r2_w; + return _r2_t0; + }; + r0_Glyph['prototype']['assign-unicode'] = function _r0_t2(r3_u) { + var r3_u, _r3_t0; + _r3_t0 = this; + _r3_t0['unicode']['push'](r3_u['charCodeAt'](0)); + return _r3_t0; + }; + r0_Glyph['prototype']['start-from'] = function _r0_t3(r4_x, r4_y) { + var r4_x, r4_y, _r4_t0; + _r4_t0 = this; + _r4_t0['contours']['push']([{ + 'x': r4_x, + 'y': r4_y, + 'onCurve': true + }]); + return _r4_t0; + }; + r0_Glyph['prototype']['line-to'] = function _r0_t4(r5_x, r5_y) { + var r5_x, r5_y, _r5_t0; + _r5_t0 = this; + _r5_t0['contours'][_r5_t0['contours']['length'] - 1]['push']({ + 'x': r5_x, + 'y': r5_y, + 'onCurve': true + }); + return _r5_t0; + }; + r0_Glyph['prototype']['curve-to'] = function _r0_t5(r6_xc, r6_yc, r6_x, r6_y) { + var r6_xc, r6_yc, r6_x, r6_y, _r6_t0; + _r6_t0 = this; + _r6_t0['contours'][_r6_t0['contours']['length'] - 1]['push']({ + 'x': r6_xc, + 'y': r6_yc, + 'onCurve': false + }, { + 'x': r6_x, + 'y': r6_y, + 'onCurve': true + }); + return _r6_t0; + }; + r0_Glyph['prototype']['cubic-to'] = function _r0_t6(r7_x1, r7_y1, r7_x2, r7_y2, r7_x, r7_y) { + var r7_x1, r7_y1, r7_x2, r7_y2, r7_x, r7_y, r7_lastContour, r7_lastPoint, r7_segments, r7_p0, r7_xc, r7_yc, r7_xf, r7_yf, _r7_t0, _r7_t1, _r7_t2, _r7_t3, _r7_t4, _r7_t5, _r7_t6; + _r7_t6 = this; + r7_lastContour = _r7_t6['contours'][_r7_t6['contours']['length'] - 1]; + r7_lastPoint = r7_lastContour[r7_lastContour['length'] - 1]; + r7_segments = r0_bezierCubic2Q2(r7_lastPoint, { + 'x': r7_x1, + 'y': r7_y1 + }, { + 'x': r7_x2, + 'y': r7_y2 + }, { + 'x': r7_x, + 'y': r7_y + }); + _r7_t0 = r7_segments; + _r7_t1 = _r7_t0['length']; + _r7_t2 = 0; + for (; _r7_t2 < _r7_t1; _r7_t2 = _r7_t2 + 1) { + _r7_t3 = _r7_t0[_r7_t2]; + r7_p0 = _r7_t3[0]; + _r7_t4 = _r7_t3[1]; + r7_xc = _r7_t4['x']; + r7_yc = _r7_t4['y']; + _r7_t5 = _r7_t3[2]; + r7_xf = _r7_t5['x']; + r7_yf = _r7_t5['y']; + _r7_t6['curve-to'](r7_xc, r7_yc, r7_xf, r7_yf); + } + return _r7_t6; + }; + r0_Glyph['prototype']['reverse-last'] = function _r0_t7() { + var _r9_t0; + _r9_t0 = this; + return _r9_t0['contours'][_r9_t0['contours']['length'] - 1] = _r9_t0['contours'][_r9_t0['contours']['length'] - 1]['reverse'](); + }; + r0_Glyph['prototype']['put-shapes'] = function _r0_t8(r10_contours) { + var r10_contours, r10_contour, r10_j, r10_point, r10_p2, r10_p3, _r10_t0, _r10_t1, _r10_t2, _r10_t3; + _r10_t3 = this; + _r10_t0 = r10_contours; + _r10_t1 = _r10_t0['length']; + _r10_t2 = 0; + for (; _r10_t2 < _r10_t1; _r10_t2 = _r10_t2 + 1) { + r10_contour = _r10_t0[_r10_t2]; + _r10_t3['start-from'](r10_contour[0]['x'], r10_contour[0]['y']); + r10_j = 1; + for (; r10_j < r10_contour['length']; r10_j = r10_j + 1) { + r10_point = r10_contour[r10_j]; + if (r10_point['cubic']) { + r10_p2 = r10_contour[r10_j + 1]; + r10_p3 = r10_contour[r10_j + 2]; + _r10_t3['cubic-to'](r10_point['x'], r10_point['y'], r10_p2['x'], r10_p2['y'], r10_p3['x'], r10_p3['y']); + r10_j = r10_j + 2; + } else if (r10_point['onCurve']) + _r10_t3['line-to'](r10_point['x'], r10_point['y']); + else { + r10_p2 = r10_contour[r10_j + 1]; + _r10_t3['curve-to'](r10_point['x'], r10_point['y'], r10_p2['x'], r10_p2['y']); + r10_j = r10_j + 1; + } + } + } + return _r10_t3; + }; + r0_Stroke = function _r0_t9() { + var _r12_t0; + _r12_t0 = this; + _r12_t0['points'] = []; + return _r12_t0; + }; + r0_Stroke['prototype']['set-width'] = function _r0_t10(r13_d1, r13_d2) { + var r13_d1, r13_d2, r13_point, _r13_t0; + _r13_t0 = this; + r13_point = _r13_t0['points'][_r13_t0['points']['length'] - 1]; + r13_point['d1'] = r13_d1; + r13_point['d2'] = r13_d2; + return _r13_t0; + }; + r0_Stroke['prototype']['start-from'] = function _r0_t11(r14_x, r14_y) { + var r14_x, r14_y, _r14_t0; + _r14_t0 = this; + _r14_t0['points'] = [{ + 'x': r14_x, + 'y': r14_y, + 'onCurve': true + }]; + return _r14_t0; + }; + r0_Stroke['prototype']['line-to'] = function _r0_t12(r15_x, r15_y) { + var r15_x, r15_y, _r15_t0; + _r15_t0 = this; + _r15_t0['points']['push']({ + 'x': r15_x, + 'y': r15_y, + 'onCurve': true + }); + return _r15_t0; + }; + r0_Stroke['prototype']['curve-to'] = function _r0_t13(r16_xc, r16_yc, r16_x, r16_y) { + var r16_xc, r16_yc, r16_x, r16_y, _r16_t0; + _r16_t0 = this; + _r16_t0['points']['push']({ + 'x': r16_xc, + 'y': r16_yc, + 'onCurve': false + }, { + 'x': r16_x, + 'y': r16_y, + 'onCurve': true + }); + return _r16_t0; + }; + r0_Stroke['prototype']['cubic-to'] = function _r0_t14(r17_x1, r17_y1, r17_x2, r17_y2, r17_x, r17_y) { + var r17_x1, r17_y1, r17_x2, r17_y2, r17_x, r17_y, _r17_t0; + _r17_t0 = this; + _r17_t0['points']['push']({ + 'x': r17_x1, + 'y': r17_y1, + 'onCurve': false, + 'cubic': true + }, { + 'x': r17_x2, + 'y': r17_y2, + 'onCurve': false, + 'cubic': true + }, { + 'x': r17_x, + 'y': r17_y, + 'onCurve': true + }); + return _r17_t0; + }; + r0_Stroke['prototype']['arc-vh-to'] = function _r0_t15(r18_x, r18_y) { + var r18_x, r18_y, r18_last, _r18_t0; + _r18_t0 = this; + r18_last = _r18_t0['points'][_r18_t0['points']['length'] - 1]; + _r18_t0['cubic-to'](r18_last['x'], r18_last['y'] + r0_BKAPPA * (r18_y - r18_last['y']), r18_x + r0_BKAPPA * (r18_last['x'] - r18_x), r18_y, r18_x, r18_y); + return _r18_t0; + }; + r0_Stroke['prototype']['arc-hv-to'] = function _r0_t16(r19_x, r19_y) { + var r19_x, r19_y, r19_last, _r19_t0; + _r19_t0 = this; + r19_last = _r19_t0['points'][_r19_t0['points']['length'] - 1]; + _r19_t0['cubic-to'](r19_last['x'] + r0_BKAPPA * (r19_x - r19_last['x']), r19_last['y'], r19_x, r19_y + r0_BKAPPA * (r19_last['y'] - r19_y), r19_x, r19_y); + return _r19_t0; + }; + r0_dforward = function _r0_t17(r20_p0, r20_p1, r20_p2, r20_p3) { + var r20_p0, r20_p1, r20_p2, r20_p3; + return { + 'x': r20_p0['x'] + (-11 / 6 * r20_p0['x'] + 3 * r20_p1['x'] - 3 / 2 * r20_p2['x'] + r20_p3['x'] / 3) / r0_TINY * r0_LITTLE, + 'y': r20_p0['y'] + (-11 / 6 * r20_p0['y'] + 3 * r20_p1['y'] - 3 / 2 * r20_p2['y'] + r20_p3['y'] / 3) / r0_TINY * r0_LITTLE + }; + }; + r0_dbackward = function _r0_t18(r21_p0, r21_p1, r21_p2, r21_p3) { + var r21_p0, r21_p1, r21_p2, r21_p3; + return { + 'x': r21_p0['x'] + (11 / 6 * r21_p0['x'] - 3 * r21_p1['x'] + 3 / 2 * r21_p2['x'] - r21_p3['x'] / 3) / r0_TINY * r0_LITTLE, + 'y': r21_p0['y'] + (11 / 6 * r21_p0['y'] - 3 * r21_p1['y'] + 3 / 2 * r21_p2['y'] - r21_p3['y'] / 3) / r0_TINY * r0_LITTLE + }; + }; + r0_nonlinear = function _r0_t19(r22_a, r22_b, r22_c) { + var r22_a, r22_b, r22_c; + return Math['abs']((r22_c['y'] - r22_a['y']) * (r22_b['x'] - r22_a['x']) - (r22_c['x'] - r22_a['x']) * (r22_b['y'] - r22_a['y'])) > r0_TINY; + }; + r0_Stroke['prototype']['form-stroke'] = function _r0_t20(r23_d1, r23_d2) { + var r23_d1, r23_d2, r23_d1s, r23_d2s, r23_subSegments, r23_p0, r23_j, r23_p1, r23_p2, r23_p3, r23_f1, r23_f2, r23_left, r23_right, r23_seg, r23_curve, r23_sample, r23_t, r23_tn, r23_lthis, r23_rthis, r23_lnext, r23_rnext, r23_lnthis1, r23_rnthis1, r23_lnnext1, r23_rnnext1, r23_lnthis2, r23_rnthis2, r23_lnnext2, r23_rnnext2, r23_lnthis3, r23_rnthis3, r23_lnnext3, r23_rnnext3, r23_dlthis, r23_drthis, r23_dlnext, r23_drnext, r23_il, r23_ir, r23_last, r23_shape, _r23_t0, _r23_t1, _r23_t2, _r23_t3, _r23_t4, _r23_t5, _r23_t6, _r23_t7, _r23_t8, _r23_t9, _r23_t10, _r23_t11, _r23_t12, _r23_t13, _r23_t14, _r23_t15, _r23_t16, _r23_t17, _r23_t18, _r23_t19, _r23_t20, _r23_t21, _r23_t22, _r23_t23, _r23_t24, _r23_t25, _r23_t26, _r23_t27, _r23_t28, _r23_t29, _r23_t30, _r23_t31, _r23_t32, _r23_t33, _r23_t34, _r23_t35, _r23_t36, _r23_t37, _r23_t38; + _r23_t2 = this; + if (_r23_t2['points'][0]['d1'] >= 0) + _r23_t3 = _r23_t2['points'][0]['d1']; + else + _r23_t3 = r23_d1; + _r23_t4 = r23_d1 = _r23_t3; + r23_d1s = [_r23_t4]; + if (_r23_t2['points'][0]['d2'] >= 0) + _r23_t5 = _r23_t2['points'][0]['d2']; + else + _r23_t5 = r23_d2; + _r23_t6 = r23_d2 = _r23_t5; + r23_d2s = [_r23_t6]; + r23_subSegments = []; + r23_p0 = _r23_t2['points'][0]; + r23_j = 1; + for (; r23_j < this['points']['length']; r23_j = r23_j + 1) { + r23_p1 = _r23_t2['points'][r23_j]; + if (r23_p1['onCurve']) { + r23_subSegments['push']([ + r23_p0, + { + 'x': (r23_p0['x'] + r23_p1['x']) / 2, + 'y': (r23_p0['y'] + r23_p1['y']) / 2 + }, + r23_p1 + ]); + _r23_t7 = r23_d1s; + _r23_t8 = _r23_t7['push']; + if (r23_p1['d1'] >= 0) + _r23_t9 = r23_p1['d1']; + else + _r23_t9 = r23_d1; + _r23_t10 = r23_d1 = _r23_t9; + _r23_t8['call'](_r23_t7, _r23_t10); + _r23_t11 = r23_d2s; + _r23_t12 = _r23_t11['push']; + if (r23_p1['d2'] >= 0) + _r23_t13 = r23_p1['d2']; + else + _r23_t13 = r23_d2; + _r23_t14 = r23_d2 = _r23_t13; + _r23_t12['call'](_r23_t11, _r23_t14); + r23_p0 = r23_p1; + } else if (r23_p1['cubic']) { + r23_p2 = _r23_t2['points'][r23_j + 1]; + r23_p3 = _r23_t2['points'][r23_j + 2]; + _r23_t15 = r23_d1s; + _r23_t16 = _r23_t15['push']; + if (r23_p3['d1'] >= 0) + _r23_t17 = r23_p3['d1']; + else + _r23_t17 = r23_d1; + _r23_t18 = r23_d1 = _r23_t17; + _r23_t16['call'](_r23_t15, _r23_t18); + _r23_t19 = r23_d2s; + _r23_t20 = _r23_t19['push']; + if (r23_p3['d2'] >= 0) + _r23_t21 = r23_p3['d2']; + else + _r23_t21 = r23_d2; + _r23_t22 = r23_d2 = _r23_t21; + _r23_t20['call'](_r23_t19, _r23_t22); + r23_subSegments['push']([ + r23_p0, + r23_p1, + r23_p2, + r23_p3 + ]); + r23_p0 = r23_p3; + r23_j = r23_j + 2; + } else if (true) { + r23_p2 = _r23_t2['points'][r23_j + 1]; + _r23_t23 = r23_d1s; + _r23_t24 = _r23_t23['push']; + if (r23_p2['d1'] >= 0) + _r23_t25 = r23_p2['d1']; + else + _r23_t25 = r23_d1; + _r23_t26 = r23_d1 = _r23_t25; + _r23_t24['call'](_r23_t23, _r23_t26); + _r23_t27 = r23_d2s; + _r23_t28 = _r23_t27['push']; + if (r23_p2['d2'] >= 0) + _r23_t29 = r23_p2['d2']; + else + _r23_t29 = r23_d2; + _r23_t30 = r23_d2 = _r23_t29; + _r23_t28['call'](_r23_t27, _r23_t30); + r23_subSegments['push']([ + r23_p0, + r23_p1, + r23_p2 + ]); + r23_p0 = r23_p2; + r23_j = r23_j + 1; + } else + void 0; + } + r23_f1 = r0_Smooth(r23_d1s, { 'method': 'cubic' }); + r23_f2 = r0_Smooth(r23_d2s, { 'method': 'cubic' }); + r23_left = []; + r23_right = []; + r23_j = 0; + for (; r23_j < r23_subSegments['length']; r23_j = r23_j + 1) { + r23_seg = r23_subSegments[r23_j]; + if (r23_seg['length'] > 3) + _r23_t31 = new r0_Bezier(r23_seg[0]['x'], r23_seg[0]['y'], r23_seg[1]['x'], r23_seg[1]['y'], r23_seg[2]['x'], r23_seg[2]['y'], r23_seg[3]['x'], r23_seg[3]['y']); + else + _r23_t31 = new r0_Bezier(r23_seg[0]['x'], r23_seg[0]['y'], r23_seg[1]['x'], r23_seg[1]['y'], r23_seg[2]['x'], r23_seg[2]['y']); + r23_curve = _r23_t31; + _r23_t0 = 0; + _r23_t1 = r0_SAMPLES; + r23_sample = _r23_t0; + for (; r23_sample < _r23_t1; r23_sample = r23_sample + 1) { + r23_t = r23_j + r23_sample / r0_SAMPLES; + r23_tn = r23_j + (r23_sample + 1) / r0_SAMPLES; + r23_lthis = r23_curve['offset'](r23_sample / r0_SAMPLES, r23_f1(r23_t)); + r23_rthis = r23_curve['offset'](r23_sample / r0_SAMPLES, -r23_f2(r23_t)); + r23_lnext = r23_curve['offset']((r23_sample + 1) / r0_SAMPLES, r23_f1(r23_tn)); + r23_rnext = r23_curve['offset']((r23_sample + 1) / r0_SAMPLES, -r23_f2(r23_tn)); + r23_lnthis1 = r23_curve['offset'](r23_sample / r0_SAMPLES + r0_TINY, r23_f1(r23_t + r0_TINY)); + r23_rnthis1 = r23_curve['offset'](r23_sample / r0_SAMPLES + r0_TINY, -r23_f2(r23_t + r0_TINY)); + r23_lnnext1 = r23_curve['offset']((r23_sample + 1) / r0_SAMPLES - r0_TINY, r23_f1(r23_tn - r0_TINY)); + r23_rnnext1 = r23_curve['offset']((r23_sample + 1) / r0_SAMPLES - r0_TINY, -r23_f2(r23_tn - r0_TINY)); + r23_lnthis2 = r23_curve['offset'](r23_sample / r0_SAMPLES + r0_TINY * 2, r23_f1(r23_t + r0_TINY * 2)); + r23_rnthis2 = r23_curve['offset'](r23_sample / r0_SAMPLES + r0_TINY * 2, -r23_f2(r23_t + r0_TINY * 2)); + r23_lnnext2 = r23_curve['offset']((r23_sample + 1) / r0_SAMPLES - r0_TINY * 2, r23_f1(r23_tn - r0_TINY * 2)); + r23_rnnext2 = r23_curve['offset']((r23_sample + 1) / r0_SAMPLES - r0_TINY * 2, -r23_f2(r23_tn - r0_TINY * 2)); + r23_lnthis3 = r23_curve['offset'](r23_sample / r0_SAMPLES + r0_TINY * 3, r23_f1(r23_t + r0_TINY * 3)); + r23_rnthis3 = r23_curve['offset'](r23_sample / r0_SAMPLES + r0_TINY * 3, -r23_f2(r23_t + r0_TINY * 3)); + r23_lnnext3 = r23_curve['offset']((r23_sample + 1) / r0_SAMPLES - r0_TINY * 3, r23_f1(r23_tn - r0_TINY * 3)); + r23_rnnext3 = r23_curve['offset']((r23_sample + 1) / r0_SAMPLES - r0_TINY * 3, -r23_f2(r23_tn - r0_TINY * 3)); + r23_dlthis = r0_dforward(r23_lthis, r23_lnthis1, r23_lnthis2, r23_lnthis3); + r23_drthis = r0_dforward(r23_rthis, r23_rnthis1, r23_rnthis2, r23_rnthis3); + r23_dlnext = r0_dbackward(r23_lnext, r23_lnnext1, r23_lnnext2, r23_lnnext3); + r23_drnext = r0_dbackward(r23_rnext, r23_rnnext2, r23_rnnext2, r23_rnnext3); + r23_il = r0_intersection(r23_lthis['x'], r23_lthis['y'], r23_dlthis['x'], r23_dlthis['y'], r23_lnext['x'], r23_lnext['y'], r23_dlnext['x'], r23_dlnext['y']); + r23_ir = r0_intersection(r23_rthis['x'], r23_rthis['y'], r23_drthis['x'], r23_drthis['y'], r23_rnext['x'], r23_rnext['y'], r23_drnext['x'], r23_drnext['y']); + if (r23_il['x'] !== null && r23_il['y'] !== null && r0_nonlinear(r23_lthis, r23_il, r23_lnext)) { + r23_left['push']({ + 'x': r23_lthis['x'], + 'y': r23_lthis['y'], + 'onCurve': true + }, { + 'x': r23_il['x'], + 'y': r23_il['y'], + 'onCurve': false + }); + } else { + r23_left['push']({ + 'x': r23_lthis['x'], + 'y': r23_lthis['y'], + 'onCurve': true + }); + } + if (r23_ir['x'] !== null && r23_ir['y'] !== null && r0_nonlinear(r23_rthis, r23_ir, r23_rnext)) { + r23_right['push']({ + 'x': r23_rthis['x'], + 'y': r23_rthis['y'], + 'onCurve': true + }, { + 'x': r23_ir['x'], + 'y': r23_ir['y'], + 'onCurve': false + }); + } else { + r23_right['push']({ + 'x': r23_rthis['x'], + 'y': r23_rthis['y'], + 'onCurve': true + }); + } + } + } + _r23_t32 = r23_left; + _r23_t33 = _r23_t32['push']; + r23_last = r23_curve['offset'](1, r23_f1(r23_t)); + _r23_t34 = { + 'x': r23_last['x'], + 'y': r23_last['y'], + 'onCurve': true + }; + _r23_t33['call'](_r23_t32, _r23_t34); + _r23_t35 = r23_right; + _r23_t36 = _r23_t35['push']; + r23_last = r23_curve['offset'](1, -r23_f2(r23_t)); + _r23_t37 = { + 'x': r23_last['x'], + 'y': r23_last['y'], + 'onCurve': true + }; + _r23_t36['call'](_r23_t35, _r23_t37); + r23_shape = r23_left['concat'](r23_right['reverse']())['map'](function _r23_t38(r25_p) { + var r25_p; + return { + 'x': r25_p['x'], + 'y': r25_p['y'], + 'onCurve': r25_p['onCurve'] + }; + }); + return [r23_shape]; + }; + r0_Ring = function _r0_t21(r26_u, r26_d, r26_l, r26_r) { + var r26_u, r26_d, r26_l, r26_r, r26_my, r26_mx, r26_s; + r26_my = (r26_u + r26_d) / 2; + r26_mx = (r26_l + r26_r) / 2; + r26_s = new r0_Stroke()['start-from'](r26_mx, r26_d)['cubic-to'](r26_mx + (r26_l - r26_mx) * r0_BKAPPA, r26_d, r26_l, r26_my + (r26_d - r26_my) * r0_BKAPPA, r26_l, r26_my)['cubic-to'](r26_l, r26_my + (r26_u - r26_my) * r0_BKAPPA, r26_mx + (r26_l - r26_mx) * r0_BKAPPA, r26_u, r26_mx, r26_u)['cubic-to'](r26_mx + (r26_r - r26_mx) * r0_BKAPPA, r26_u, r26_r, r26_my + (r26_u - r26_my) * r0_BKAPPA, r26_r, r26_my)['cubic-to'](r26_r, r26_my + (r26_d - r26_my) * r0_BKAPPA, r26_mx + (r26_r - r26_mx) * r0_BKAPPA, r26_d, r26_mx, r26_d); + return r26_s['points']; + }; + r0_ORing = function _r0_t22(r27_u, r27_d, r27_l, r27_r, r27_smooth) { + var r27_u, r27_d, r27_l, r27_r, r27_smooth, r27_myu, r27_myd, r27_mx, r27_s; + r27_myu = r27_u - r27_smooth; + r27_myd = r27_d + r27_smooth; + r27_mx = (r27_l + r27_r) / 2; + r27_s = new r0_Stroke()['start-from'](r27_mx, r27_d)['cubic-to'](r27_mx + (r27_l - r27_mx) * r0_BKAPPA, r27_d, r27_l, r27_myd + (r27_d - r27_myd) * r0_BKAPPA, r27_l, r27_myd)['line-to'](r27_l, r27_myu)['cubic-to'](r27_l, r27_myu + (r27_u - r27_myu) * r0_BKAPPA, r27_mx + (r27_l - r27_mx) * r0_BKAPPA, r27_u, r27_mx, r27_u)['cubic-to'](r27_mx + (r27_r - r27_mx) * r0_BKAPPA, r27_u, r27_r, r27_myu + (r27_u - r27_myu) * r0_BKAPPA, r27_r, r27_myu)['line-to'](r27_r, r27_myd)['cubic-to'](r27_r, r27_myd + (r27_d - r27_myd) * r0_BKAPPA, r27_mx + (r27_r - r27_mx) * r0_BKAPPA, r27_d, r27_mx, r27_d); + return r27_s['points']; + }; + r0_xn$createglyph$7Hrq = function _r0_t23(r32_name, r32_actions) { + var r32_name, r32_actions, r32_glyphObject; + r32_glyphObject = new r0_Glyph(r32_name); + r0_glyphList['push'](r32_glyphObject); + r0_glyphs[r32_name] = r32_glyphObject; + r32_actions['call'](r32_glyphObject); + return r32_glyphObject; + }; + r0_xn$createglyph$7Hrq('space', function _r0_t24() { + var r34_xn$setwidth$9Jrj, r34_xn$assignunicode$7Hrq, r34_xn$startfrom$1aao, r34_xn$lineto$5sIl, r34_xn$curveto$1aao, r34_xn$cubicto$1aao, r34_xn$putshapes$9Jrj, r34_xn$reverselast$3qIs, _r34_t0; + _r34_t0 = this; + r34_xn$setwidth$9Jrj = _r34_t0['set-width']['bind'](_r34_t0); + r34_xn$assignunicode$7Hrq = _r34_t0['assign-unicode']['bind'](_r34_t0); + r34_xn$startfrom$1aao = _r34_t0['start-from']['bind'](_r34_t0); + r34_xn$lineto$5sIl = _r34_t0['line-to']['bind'](_r34_t0); + r34_xn$curveto$1aao = _r34_t0['curve-to']['bind'](_r34_t0); + r34_xn$cubicto$1aao = _r34_t0['cubic-to']['bind'](_r34_t0); + r34_xn$putshapes$9Jrj = _r34_t0['put-shapes']['bind'](_r34_t0); + r34_xn$reverselast$3qIs = _r34_t0['reverse-last']['bind'](_r34_t0); + r34_xn$setwidth$9Jrj(r0_WIDTH); + r34_xn$assignunicode$7Hrq(' '); + return void 0; + }); + r0_xn$createglyph$7Hrq('bar', function _r0_t25() { + var r36_xn$setwidth$9Jrj, r36_xn$assignunicode$7Hrq, r36_xn$startfrom$1aao, r36_xn$lineto$5sIl, r36_xn$curveto$1aao, r36_xn$cubicto$1aao, r36_xn$putshapes$9Jrj, r36_xn$reverselast$3qIs, _r36_t0; + _r36_t0 = this; + r36_xn$setwidth$9Jrj = _r36_t0['set-width']['bind'](_r36_t0); + r36_xn$assignunicode$7Hrq = _r36_t0['assign-unicode']['bind'](_r36_t0); + r36_xn$startfrom$1aao = _r36_t0['start-from']['bind'](_r36_t0); + r36_xn$lineto$5sIl = _r36_t0['line-to']['bind'](_r36_t0); + r36_xn$curveto$1aao = _r36_t0['curve-to']['bind'](_r36_t0); + r36_xn$cubicto$1aao = _r36_t0['cubic-to']['bind'](_r36_t0); + r36_xn$putshapes$9Jrj = _r36_t0['put-shapes']['bind'](_r36_t0); + r36_xn$reverselast$3qIs = _r36_t0['reverse-last']['bind'](_r36_t0); + r36_xn$setwidth$9Jrj(r0_WIDTH); + r36_xn$assignunicode$7Hrq('|'); + r36_xn$putshapes$9Jrj(new r0_Stroke()['start-from'](r0_MIDDLE, r0_DESCENDER / 2)['set-width'](r0_STROKE / 2, r0_STROKE / 2)['line-to'](r0_MIDDLE, r0_CAP - r0_DESCENDER / 2)['form-stroke']()); + return void 0; + }); + r0_xn$createglyph$7Hrq('A', function _r0_t26() { + var r38_xn$setwidth$9Jrj, r38_xn$assignunicode$7Hrq, r38_xn$startfrom$1aao, r38_xn$lineto$5sIl, r38_xn$curveto$1aao, r38_xn$cubicto$1aao, r38_xn$putshapes$9Jrj, r38_xn$reverselast$3qIs, r38_TURN, r38_leftbar, r38_rightbar, r38_hbar, _r38_t0; + _r38_t0 = this; + r38_xn$setwidth$9Jrj = _r38_t0['set-width']['bind'](_r38_t0); + r38_xn$assignunicode$7Hrq = _r38_t0['assign-unicode']['bind'](_r38_t0); + r38_xn$startfrom$1aao = _r38_t0['start-from']['bind'](_r38_t0); + r38_xn$lineto$5sIl = _r38_t0['line-to']['bind'](_r38_t0); + r38_xn$curveto$1aao = _r38_t0['curve-to']['bind'](_r38_t0); + r38_xn$cubicto$1aao = _r38_t0['cubic-to']['bind'](_r38_t0); + r38_xn$putshapes$9Jrj = _r38_t0['put-shapes']['bind'](_r38_t0); + r38_xn$reverselast$3qIs = _r38_t0['reverse-last']['bind'](_r38_t0); + r38_xn$setwidth$9Jrj(r0_WIDTH); + r38_xn$assignunicode$7Hrq('A'); + r38_TURN = r0_XH * 0.1; + r38_leftbar = new r0_Stroke(); + r38_leftbar['start-from'](r0_SB, 0)['line-to'](r0_SB, r38_TURN)['curve-to'](r0_SB, r38_TURN + 0.27 * (r0_CAP - r38_TURN), r0_MIDDLE - r0_STROKE / 2, r0_CAP); + r38_rightbar = new r0_Stroke(); + r38_rightbar['start-from'](r0_RIGHTSB, 0)['line-to'](r0_RIGHTSB, r38_TURN)['curve-to'](r0_RIGHTSB, r38_TURN + 0.27 * (r0_CAP - r38_TURN), r0_MIDDLE + r0_STROKE / 2, r0_CAP); + r38_hbar = new r0_Stroke(); + r38_hbar['start-from'](r0_SB + r0_STROKE, r0_XH / 2)['line-to'](r0_RIGHTSB - r0_STROKE, r0_XH / 2); + r38_xn$putshapes$9Jrj(r38_leftbar['form-stroke'](0, r0_STROKE)); + r38_xn$putshapes$9Jrj(r38_hbar['form-stroke'](0, r0_STROKE)); + r38_xn$putshapes$9Jrj(r38_rightbar['form-stroke'](r0_STROKE, 0)); + r38_xn$startfrom$1aao(r0_MIDDLE - r0_STROKE / 2, r0_CAP); + r38_xn$lineto$5sIl(r0_MIDDLE + r0_STROKE / 2, r0_CAP); + r38_xn$lineto$5sIl(r0_MIDDLE, r0_CAP - r0_STROKE); + return void 0; + }); + r0_xn$createglyph$7Hrq('X', function _r0_t27() { + var r40_xn$setwidth$9Jrj, r40_xn$assignunicode$7Hrq, r40_xn$startfrom$1aao, r40_xn$lineto$5sIl, r40_xn$curveto$1aao, r40_xn$cubicto$1aao, r40_xn$putshapes$9Jrj, r40_xn$reverselast$3qIs, r40_TURN, r40_straight, r40_strench, r40_barone, r40_bartwo, _r40_t0, _r40_t1; + _r40_t0 = this; + r40_xn$setwidth$9Jrj = _r40_t0['set-width']['bind'](_r40_t0); + r40_xn$assignunicode$7Hrq = _r40_t0['assign-unicode']['bind'](_r40_t0); + r40_xn$startfrom$1aao = _r40_t0['start-from']['bind'](_r40_t0); + r40_xn$lineto$5sIl = _r40_t0['line-to']['bind'](_r40_t0); + r40_xn$curveto$1aao = _r40_t0['curve-to']['bind'](_r40_t0); + r40_xn$cubicto$1aao = _r40_t0['cubic-to']['bind'](_r40_t0); + r40_xn$putshapes$9Jrj = _r40_t0['put-shapes']['bind'](_r40_t0); + r40_xn$reverselast$3qIs = _r40_t0['reverse-last']['bind'](_r40_t0); + r40_xn$setwidth$9Jrj(r0_WIDTH); + r40_xn$assignunicode$7Hrq('X'); + r40_TURN = r0_XH * 0.05; + r40_straight = 0.6; + r40_strench = 0.125; + r40_barone = new r0_Stroke()['start-from'](r0_SB + r0_HALFSTROKE, 0)['set-width'](r0_HALFSTROKE, r0_HALFSTROKE)['line-to'](r0_SB + r0_HALFSTROKE, r40_TURN)['curve-to'](r0_SB + r0_HALFSTROKE, r40_TURN + r40_strench * (r0_CAP - r40_TURN), r0_MIDDLE + r40_straight * (r0_SB + r0_HALFSTROKE - r0_MIDDLE), r0_CAPMIDDLE + r40_straight * (r40_TURN + r40_strench * (r0_CAP - r40_TURN) - r0_CAPMIDDLE))['line-to'](r0_MIDDLE + r40_straight * (r0_RIGHTSB - r0_HALFSTROKE - r0_MIDDLE), r0_CAPMIDDLE + r40_straight * (r0_CAP - r40_TURN - r40_strench * (r0_CAP - r40_TURN) - r0_CAPMIDDLE))['curve-to'](r0_RIGHTSB - r0_HALFSTROKE, r0_CAP - r40_TURN - r40_strench * (r0_CAP - r40_TURN), r0_RIGHTSB - r0_HALFSTROKE, r0_CAP - r40_TURN)['line-to'](r0_RIGHTSB - r0_HALFSTROKE, r0_CAP)['form-stroke'](); + r40_bartwo = [r40_barone[0]['map'](function _r40_t1(r41_pt) { + var r41_pt; + return { + 'x': r0_WIDTH - r41_pt['x'], + 'y': r41_pt['y'], + 'onCurve': r41_pt['onCurve'], + 'cubic': r41_pt['cubic'] + }; + })['reverse']()]; + r40_xn$putshapes$9Jrj(r40_barone); + r40_xn$putshapes$9Jrj(r40_bartwo); + return void 0; + }); + r0_xn$createglyph$7Hrq('Y', function _r0_t28() { + var r43_xn$setwidth$9Jrj, r43_xn$assignunicode$7Hrq, r43_xn$startfrom$1aao, r43_xn$lineto$5sIl, r43_xn$curveto$1aao, r43_xn$cubicto$1aao, r43_xn$putshapes$9Jrj, r43_xn$reverselast$3qIs, r43_TURN, r43_straight, r43_strench, r43_cross, r43_barone, r43_bartwo, _r43_t0, _r43_t1; + _r43_t0 = this; + r43_xn$setwidth$9Jrj = _r43_t0['set-width']['bind'](_r43_t0); + r43_xn$assignunicode$7Hrq = _r43_t0['assign-unicode']['bind'](_r43_t0); + r43_xn$startfrom$1aao = _r43_t0['start-from']['bind'](_r43_t0); + r43_xn$lineto$5sIl = _r43_t0['line-to']['bind'](_r43_t0); + r43_xn$curveto$1aao = _r43_t0['curve-to']['bind'](_r43_t0); + r43_xn$cubicto$1aao = _r43_t0['cubic-to']['bind'](_r43_t0); + r43_xn$putshapes$9Jrj = _r43_t0['put-shapes']['bind'](_r43_t0); + r43_xn$reverselast$3qIs = _r43_t0['reverse-last']['bind'](_r43_t0); + r43_xn$setwidth$9Jrj(r0_WIDTH); + r43_xn$assignunicode$7Hrq('Y'); + r43_TURN = r0_XH * 0.05; + r43_straight = 0.6; + r43_strench = 0.15; + r43_cross = r0_CAP * 0.4; + r43_barone = new r0_Stroke()['start-from'](r0_MIDDLE, r43_cross)['set-width'](r0_HALFSTROKE, r0_HALFSTROKE)['line-to'](r0_MIDDLE + r43_straight * (r0_RIGHTSB - r0_HALFSTROKE - r0_MIDDLE), r43_cross + r43_straight * (r0_CAP - r43_TURN - r43_strench * (r0_CAP - r43_TURN) - r43_cross))['curve-to'](r0_RIGHTSB - r0_HALFSTROKE, r0_CAP - r43_TURN - r43_strench * (r0_CAP - r43_TURN), r0_RIGHTSB - r0_HALFSTROKE, r0_CAP - r43_TURN)['line-to'](r0_RIGHTSB - r0_HALFSTROKE, r0_CAP)['form-stroke'](); + r43_bartwo = [r43_barone[0]['map'](function _r43_t1(r44_pt) { + var r44_pt; + return { + 'x': r0_WIDTH - r44_pt['x'], + 'y': r44_pt['y'], + 'onCurve': r44_pt['onCurve'], + 'cubic': r44_pt['cubic'] + }; + })['reverse']()]; + r43_xn$putshapes$9Jrj(r43_barone); + r43_xn$putshapes$9Jrj(r43_bartwo); + r43_xn$putshapes$9Jrj(new r0_Stroke()['start-from'](r0_MIDDLE, 0)['set-width'](r0_HALFSTROKE, r0_HALFSTROKE)['line-to'](r0_MIDDLE, r43_cross + r0_HALFSTROKE)['form-stroke']()); + return void 0; + }); + r0_xn$createglyph$7Hrq('x', function _r0_t29() { + var r46_xn$setwidth$9Jrj, r46_xn$assignunicode$7Hrq, r46_xn$startfrom$1aao, r46_xn$lineto$5sIl, r46_xn$curveto$1aao, r46_xn$cubicto$1aao, r46_xn$putshapes$9Jrj, r46_xn$reverselast$3qIs, r46_TURN, r46_barone, r46_bartwo, _r46_t0, _r46_t1; + _r46_t0 = this; + r46_xn$setwidth$9Jrj = _r46_t0['set-width']['bind'](_r46_t0); + r46_xn$assignunicode$7Hrq = _r46_t0['assign-unicode']['bind'](_r46_t0); + r46_xn$startfrom$1aao = _r46_t0['start-from']['bind'](_r46_t0); + r46_xn$lineto$5sIl = _r46_t0['line-to']['bind'](_r46_t0); + r46_xn$curveto$1aao = _r46_t0['curve-to']['bind'](_r46_t0); + r46_xn$cubicto$1aao = _r46_t0['cubic-to']['bind'](_r46_t0); + r46_xn$putshapes$9Jrj = _r46_t0['put-shapes']['bind'](_r46_t0); + r46_xn$reverselast$3qIs = _r46_t0['reverse-last']['bind'](_r46_t0); + r46_xn$setwidth$9Jrj(r0_WIDTH); + r46_xn$assignunicode$7Hrq('x'); + r46_TURN = r0_XH * 0.1; + r46_barone = new r0_Stroke()['start-from'](r0_SB + r0_HALFSTROKE, 0)['set-width'](r0_HALFSTROKE, r0_HALFSTROKE)['cubic-to'](r0_SB + r0_HALFSTROKE, r46_TURN + 0.17 * (r0_XH - r46_TURN), r0_RIGHTSB - r0_HALFSTROKE, r0_XH - r46_TURN - 0.17 * (r0_XH - r46_TURN), r0_RIGHTSB - r0_HALFSTROKE, r0_XH)['form-stroke'](); + r46_bartwo = [r46_barone[0]['map'](function _r46_t1(r47_pt) { + var r47_pt; + return { + 'x': r0_WIDTH - r47_pt['x'], + 'y': r47_pt['y'], + 'onCurve': r47_pt['onCurve'], + 'cubic': r47_pt['cubic'] + }; + })['reverse']()]; + r46_xn$putshapes$9Jrj(r46_barone); + r46_xn$putshapes$9Jrj(r46_bartwo); + return void 0; + }); + r0_xn$createglyph$7Hrq('B', function _r0_t30() { + var r49_xn$setwidth$9Jrj, r49_xn$assignunicode$7Hrq, r49_xn$startfrom$1aao, r49_xn$lineto$5sIl, r49_xn$curveto$1aao, r49_xn$cubicto$1aao, r49_xn$putshapes$9Jrj, r49_xn$reverselast$3qIs, r49_bowl, r49_tkappa, r49_bkappa, r49_turntop, r49_turnbottom, r49_topbowl, r49_bottombowl, r49_leftbar, _r49_t0; + _r49_t0 = this; + r49_xn$setwidth$9Jrj = _r49_t0['set-width']['bind'](_r49_t0); + r49_xn$assignunicode$7Hrq = _r49_t0['assign-unicode']['bind'](_r49_t0); + r49_xn$startfrom$1aao = _r49_t0['start-from']['bind'](_r49_t0); + r49_xn$lineto$5sIl = _r49_t0['line-to']['bind'](_r49_t0); + r49_xn$curveto$1aao = _r49_t0['curve-to']['bind'](_r49_t0); + r49_xn$cubicto$1aao = _r49_t0['cubic-to']['bind'](_r49_t0); + r49_xn$putshapes$9Jrj = _r49_t0['put-shapes']['bind'](_r49_t0); + r49_xn$reverselast$3qIs = _r49_t0['reverse-last']['bind'](_r49_t0); + r49_xn$setwidth$9Jrj(r0_WIDTH); + r49_xn$assignunicode$7Hrq('B'); + r49_bowl = 451; + r49_tkappa = r0_COKAPPA - 0.22; + r49_bkappa = r0_COKAPPA - 0.2; + r49_turntop = (r0_CAP + (r49_bowl - r0_STROKE)) / 2; + r49_turnbottom = r49_bowl / 2; + r49_topbowl = new r0_Stroke(); + r49_topbowl['start-from'](r0_SB, r0_CAP)['line-to'](r0_RIGHTSB - r0_SB * 0.5 - r49_turnbottom, r0_CAP)['cubic-to'](r0_RIGHTSB - r0_SB * 0.5 - r49_tkappa * r49_turnbottom, r0_CAP, r0_RIGHTSB - r0_SB * 0.5, r49_turntop + (r0_CAP - r49_turntop) * r0_KAPPA, r0_RIGHTSB - r0_SB * 0.5, r49_turntop)['cubic-to'](r0_RIGHTSB - r0_SB * 0.5, r49_turntop + r0_KAPPA * (r49_bowl - r0_STROKE - r49_turntop), r0_RIGHTSB - r0_SB * 0.5 - r49_tkappa * r49_turnbottom, r49_bowl - r0_STROKE, r0_RIGHTSB - r0_SB * 0.5 - r49_turnbottom, r49_bowl - r0_STROKE)['line-to'](r0_SB, r49_bowl - r0_STROKE); + r49_bottombowl = new r0_Stroke(); + r49_bottombowl['start-from'](r0_SB, 0)['line-to'](r0_RIGHTSB - r49_turnbottom, 0)['cubic-to'](r0_RIGHTSB - r49_bkappa * r49_turnbottom, 0, r0_RIGHTSB, r49_turnbottom * r0_KAPPA, r0_RIGHTSB, r49_turnbottom)['cubic-to'](r0_RIGHTSB, r49_turnbottom + r0_KAPPA * (r49_bowl - r49_turnbottom), r0_RIGHTSB - r49_bkappa * r49_turnbottom, r49_bowl, r0_RIGHTSB - r49_turnbottom, r49_bowl)['line-to'](r0_SB, r49_bowl); + r49_leftbar = new r0_Stroke()['start-from'](r0_SB, 0)['line-to'](r0_SB, r0_CAP); + r49_xn$putshapes$9Jrj(r49_topbowl['form-stroke'](0, r0_STROKE)); + r49_xn$putshapes$9Jrj(r49_bottombowl['form-stroke'](r0_STROKE, 0)); + r49_xn$putshapes$9Jrj(r49_leftbar['form-stroke'](0, r0_STROKE)); + return void 0; + }); + r0_xn$createglyph$7Hrq('C', function _r0_t31() { + var r51_xn$setwidth$9Jrj, r51_xn$assignunicode$7Hrq, r51_xn$startfrom$1aao, r51_xn$lineto$5sIl, r51_xn$curveto$1aao, r51_xn$cubicto$1aao, r51_xn$putshapes$9Jrj, r51_xn$reverselast$3qIs, r51_outline, _r51_t0; + _r51_t0 = this; + r51_xn$setwidth$9Jrj = _r51_t0['set-width']['bind'](_r51_t0); + r51_xn$assignunicode$7Hrq = _r51_t0['assign-unicode']['bind'](_r51_t0); + r51_xn$startfrom$1aao = _r51_t0['start-from']['bind'](_r51_t0); + r51_xn$lineto$5sIl = _r51_t0['line-to']['bind'](_r51_t0); + r51_xn$curveto$1aao = _r51_t0['curve-to']['bind'](_r51_t0); + r51_xn$cubicto$1aao = _r51_t0['cubic-to']['bind'](_r51_t0); + r51_xn$putshapes$9Jrj = _r51_t0['put-shapes']['bind'](_r51_t0); + r51_xn$reverselast$3qIs = _r51_t0['reverse-last']['bind'](_r51_t0); + r51_xn$setwidth$9Jrj(r0_WIDTH); + r51_xn$assignunicode$7Hrq('C'); + r51_outline = new r0_Stroke(); + r51_outline['start-from'](r0_RIGHTSB - r0_SB * 0.1, r0_CAP - r0_HOOK)['curve-to'](r0_MIDDLE + r0_KAPPA_HOOK * (r0_MIDDLE - r0_para['sb']), r0_CAPO, r0_MIDDLE, r0_CAPO)['cubic-to'](r0_SB + (1 - r0_BKAPPA) * (r0_WIDTH / 2 - r0_SB), r0_CAPO, r0_SB, r0_CAP - r0_COBKAPPA * r0_SMOOTH, r0_SB, r0_CAP_SMOOTH)['line-to'](r0_SB, r0_SMOOTH)['cubic-to'](r0_SB, r0_COBKAPPA * r0_SMOOTH, r0_SB + (1 - r0_BKAPPA) * (r0_WIDTH / 2 - r0_SB), r0_O, r0_WIDTH / 2, r0_O)['curve-to'](r0_MIDDLE + r0_KAPPA_HOOK * (r0_MIDDLE - r0_SB), r0_O, r0_RIGHTSB - r0_SB * 0.1, r0_HOOK); + r51_xn$putshapes$9Jrj(r51_outline['form-stroke'](r0_STROKE, 0)); + return void 0; + }); + r0_xn$createglyph$7Hrq('D', function _r0_t32() { + var r53_xn$setwidth$9Jrj, r53_xn$assignunicode$7Hrq, r53_xn$startfrom$1aao, r53_xn$lineto$5sIl, r53_xn$curveto$1aao, r53_xn$cubicto$1aao, r53_xn$putshapes$9Jrj, r53_xn$reverselast$3qIs, r53_dsmooth, r53_bsmooth, r53_bkappa, r53_leftbar, r53_bowl, _r53_t0; + _r53_t0 = this; + r53_xn$setwidth$9Jrj = _r53_t0['set-width']['bind'](_r53_t0); + r53_xn$assignunicode$7Hrq = _r53_t0['assign-unicode']['bind'](_r53_t0); + r53_xn$startfrom$1aao = _r53_t0['start-from']['bind'](_r53_t0); + r53_xn$lineto$5sIl = _r53_t0['line-to']['bind'](_r53_t0); + r53_xn$curveto$1aao = _r53_t0['curve-to']['bind'](_r53_t0); + r53_xn$cubicto$1aao = _r53_t0['cubic-to']['bind'](_r53_t0); + r53_xn$putshapes$9Jrj = _r53_t0['put-shapes']['bind'](_r53_t0); + r53_xn$reverselast$3qIs = _r53_t0['reverse-last']['bind'](_r53_t0); + r53_xn$setwidth$9Jrj(r0_WIDTH); + r53_xn$assignunicode$7Hrq('D'); + r53_dsmooth = r0_SMOOTH * 1.55; + r53_bsmooth = r0_SMOOTH * 1.3; + r53_bkappa = r0_COKAPPA - 0.2; + r53_leftbar = new r0_Stroke()['start-from'](r0_SB, 0)['line-to'](r0_SB, r0_CAP); + r53_bowl = new r0_Stroke(); + r53_bowl['start-from'](r0_SB, 0)['line-to'](r0_RIGHTSB - r53_bsmooth, 0)['cubic-to'](r0_RIGHTSB - r53_bkappa * r53_bsmooth, 0, r0_RIGHTSB, r0_COBKAPPA * r53_dsmooth, r0_RIGHTSB, r53_dsmooth)['line-to'](r0_RIGHTSB, r0_CAP - r53_dsmooth)['cubic-to'](r0_RIGHTSB, r0_CAP - r0_COBKAPPA * r53_dsmooth, r0_RIGHTSB - r53_bkappa * r53_bsmooth, r0_CAP, r0_RIGHTSB - r53_bsmooth, r0_CAP)['line-to'](r0_SB, r0_CAP); + r53_xn$putshapes$9Jrj(r53_bowl['form-stroke'](r0_STROKE, 0)); + r53_xn$putshapes$9Jrj(r53_leftbar['form-stroke'](0, r0_STROKE)); + return void 0; + }); + r0_xn$createglyph$7Hrq('G', function _r0_t33() { + var r55_xn$setwidth$9Jrj, r55_xn$assignunicode$7Hrq, r55_xn$startfrom$1aao, r55_xn$lineto$5sIl, r55_xn$curveto$1aao, r55_xn$cubicto$1aao, r55_xn$putshapes$9Jrj, r55_xn$reverselast$3qIs, r55_outline, r55_bar, _r55_t0; + _r55_t0 = this; + r55_xn$setwidth$9Jrj = _r55_t0['set-width']['bind'](_r55_t0); + r55_xn$assignunicode$7Hrq = _r55_t0['assign-unicode']['bind'](_r55_t0); + r55_xn$startfrom$1aao = _r55_t0['start-from']['bind'](_r55_t0); + r55_xn$lineto$5sIl = _r55_t0['line-to']['bind'](_r55_t0); + r55_xn$curveto$1aao = _r55_t0['curve-to']['bind'](_r55_t0); + r55_xn$cubicto$1aao = _r55_t0['cubic-to']['bind'](_r55_t0); + r55_xn$putshapes$9Jrj = _r55_t0['put-shapes']['bind'](_r55_t0); + r55_xn$reverselast$3qIs = _r55_t0['reverse-last']['bind'](_r55_t0); + r55_xn$setwidth$9Jrj(r0_WIDTH); + r55_xn$assignunicode$7Hrq('G'); + r55_outline = new r0_Stroke(); + r55_outline['start-from'](r0_RIGHTSB - r0_SB * 0.1, r0_CAP - r0_HOOK)['curve-to'](r0_MIDDLE + r0_KAPPA_HOOK * (r0_MIDDLE - r0_para['sb']), r0_CAPO, r0_MIDDLE, r0_CAPO)['cubic-to'](r0_SB + (1 - r0_BKAPPA) * (r0_WIDTH / 2 - r0_SB), r0_CAPO, r0_SB, r0_CAP - r0_COBKAPPA * r0_SMOOTH, r0_SB, r0_CAP_SMOOTH)['line-to'](r0_SB, r0_SMOOTH)['cubic-to'](r0_SB, r0_COBKAPPA * r0_SMOOTH, r0_SB + (1 - r0_BKAPPA) * (r0_WIDTH / 2 - r0_SB), r0_O, r0_WIDTH / 2, r0_O)['cubic-to'](r0_MIDDLE + r0_BKAPPA * (r0_RIGHTSB - r0_MIDDLE), r0_O, r0_RIGHTSB, r0_COBKAPPA * r0_SMOOTH, r0_RIGHTSB, r0_SMOOTH)['line-to'](r0_RIGHTSB, r0_CAP / 2 + r0_STROKE / 2); + r55_xn$putshapes$9Jrj(r55_outline['form-stroke'](r0_STROKE, 0)); + r55_bar = new r0_Stroke()['start-from'](r0_MIDDLE, r0_CAP / 2 + r0_STROKE / 2)['line-to'](r0_RIGHTSB, r0_CAP / 2 + r0_STROKE / 2); + r55_xn$putshapes$9Jrj(r55_bar['form-stroke'](0, r0_STROKE)); + return void 0; + }); + r0_xn$createglyph$7Hrq('O', function _r0_t34() { + var r57_xn$setwidth$9Jrj, r57_xn$assignunicode$7Hrq, r57_xn$startfrom$1aao, r57_xn$lineto$5sIl, r57_xn$curveto$1aao, r57_xn$cubicto$1aao, r57_xn$putshapes$9Jrj, r57_xn$reverselast$3qIs, r57_outline, _r57_t0; + _r57_t0 = this; + r57_xn$setwidth$9Jrj = _r57_t0['set-width']['bind'](_r57_t0); + r57_xn$assignunicode$7Hrq = _r57_t0['assign-unicode']['bind'](_r57_t0); + r57_xn$startfrom$1aao = _r57_t0['start-from']['bind'](_r57_t0); + r57_xn$lineto$5sIl = _r57_t0['line-to']['bind'](_r57_t0); + r57_xn$curveto$1aao = _r57_t0['curve-to']['bind'](_r57_t0); + r57_xn$cubicto$1aao = _r57_t0['cubic-to']['bind'](_r57_t0); + r57_xn$putshapes$9Jrj = _r57_t0['put-shapes']['bind'](_r57_t0); + r57_xn$reverselast$3qIs = _r57_t0['reverse-last']['bind'](_r57_t0); + r57_xn$setwidth$9Jrj(r0_WIDTH); + r57_xn$assignunicode$7Hrq('O'); + r57_outline = new r0_Stroke(); + r57_outline['start-from'](r0_MIDDLE, r0_CAPO)['cubic-to'](r0_SB + (1 - r0_BKAPPA) * (r0_WIDTH / 2 - r0_SB), r0_CAPO, r0_SB, r0_CAP - r0_COBKAPPA * r0_SMOOTH, r0_SB, r0_CAP - r0_SMOOTH)['line-to'](r0_SB, r0_SMOOTH)['cubic-to'](r0_SB, r0_COBKAPPA * r0_SMOOTH, r0_SB + (1 - r0_BKAPPA) * (r0_WIDTH / 2 - r0_SB), r0_O, r0_WIDTH / 2, r0_O)['cubic-to'](r0_MIDDLE + r0_BKAPPA * (r0_RIGHTSB - r0_MIDDLE), r0_O, r0_RIGHTSB, r0_COBKAPPA * r0_SMOOTH, r0_RIGHTSB, r0_SMOOTH)['line-to'](r0_RIGHTSB, r0_CAP - r0_SMOOTH)['cubic-to'](r0_RIGHTSB, r0_CAP - r0_COBKAPPA * r0_SMOOTH, r0_MIDDLE + r0_BKAPPA * (r0_RIGHTSB - r0_MIDDLE), r0_CAPO, r0_MIDDLE, r0_CAPO); + r57_xn$putshapes$9Jrj(r57_outline['form-stroke'](r0_STROKE, 0)); + return void 0; + }); + r0_xn$createglyph$7Hrq('o', function _r0_t35() { + var r59_xn$setwidth$9Jrj, r59_xn$assignunicode$7Hrq, r59_xn$startfrom$1aao, r59_xn$lineto$5sIl, r59_xn$curveto$1aao, r59_xn$cubicto$1aao, r59_xn$putshapes$9Jrj, r59_xn$reverselast$3qIs, _r59_t0; + _r59_t0 = this; + r59_xn$setwidth$9Jrj = _r59_t0['set-width']['bind'](_r59_t0); + r59_xn$assignunicode$7Hrq = _r59_t0['assign-unicode']['bind'](_r59_t0); + r59_xn$startfrom$1aao = _r59_t0['start-from']['bind'](_r59_t0); + r59_xn$lineto$5sIl = _r59_t0['line-to']['bind'](_r59_t0); + r59_xn$curveto$1aao = _r59_t0['curve-to']['bind'](_r59_t0); + r59_xn$cubicto$1aao = _r59_t0['cubic-to']['bind'](_r59_t0); + r59_xn$putshapes$9Jrj = _r59_t0['put-shapes']['bind'](_r59_t0); + r59_xn$reverselast$3qIs = _r59_t0['reverse-last']['bind'](_r59_t0); + r59_xn$setwidth$9Jrj(r0_WIDTH); + r59_xn$assignunicode$7Hrq('o'); + r59_xn$putshapes$9Jrj([ + r0_ORing(r0_XO, r0_O, r0_SB, r0_RIGHTSB, r0_SMALLSMOOTH), + r0_ORing(r0_XO - r0_STROKE, r0_O + r0_STROKE, r0_SB + r0_STROKE, r0_RIGHTSB - r0_STROKE, r0_SMALLSMOOTH - r0_STROKE) + ]); + r59_xn$reverselast$3qIs(); + return void 0; + }); + r0_xn$createglyph$7Hrq('o.left', function _r0_t36() { + var r61_xn$setwidth$9Jrj, r61_xn$assignunicode$7Hrq, r61_xn$startfrom$1aao, r61_xn$lineto$5sIl, r61_xn$curveto$1aao, r61_xn$cubicto$1aao, r61_xn$putshapes$9Jrj, r61_xn$reverselast$3qIs, _r61_t0; + _r61_t0 = this; + r61_xn$setwidth$9Jrj = _r61_t0['set-width']['bind'](_r61_t0); + r61_xn$assignunicode$7Hrq = _r61_t0['assign-unicode']['bind'](_r61_t0); + r61_xn$startfrom$1aao = _r61_t0['start-from']['bind'](_r61_t0); + r61_xn$lineto$5sIl = _r61_t0['line-to']['bind'](_r61_t0); + r61_xn$curveto$1aao = _r61_t0['curve-to']['bind'](_r61_t0); + r61_xn$cubicto$1aao = _r61_t0['cubic-to']['bind'](_r61_t0); + r61_xn$putshapes$9Jrj = _r61_t0['put-shapes']['bind'](_r61_t0); + r61_xn$reverselast$3qIs = _r61_t0['reverse-last']['bind'](_r61_t0); + r61_xn$setwidth$9Jrj(r0_WIDTH); + r61_xn$putshapes$9Jrj([ + r0_ORing(r0_XO, r0_O, r0_SB + r0_STROKE / 2, r0_RIGHTSB, r0_SMALLSMOOTH), + r0_ORing(r0_XO - r0_STROKE, r0_O + r0_STROKE, r0_SB + r0_STROKE, r0_RIGHTSB - r0_STROKE, r0_SMALLSMOOTH - r0_STROKE) + ]); + r61_xn$reverselast$3qIs(); + return void 0; + }); + r0_xn$createglyph$7Hrq('o.right', function _r0_t37() { + var r63_xn$setwidth$9Jrj, r63_xn$assignunicode$7Hrq, r63_xn$startfrom$1aao, r63_xn$lineto$5sIl, r63_xn$curveto$1aao, r63_xn$cubicto$1aao, r63_xn$putshapes$9Jrj, r63_xn$reverselast$3qIs, _r63_t0; + _r63_t0 = this; + r63_xn$setwidth$9Jrj = _r63_t0['set-width']['bind'](_r63_t0); + r63_xn$assignunicode$7Hrq = _r63_t0['assign-unicode']['bind'](_r63_t0); + r63_xn$startfrom$1aao = _r63_t0['start-from']['bind'](_r63_t0); + r63_xn$lineto$5sIl = _r63_t0['line-to']['bind'](_r63_t0); + r63_xn$curveto$1aao = _r63_t0['curve-to']['bind'](_r63_t0); + r63_xn$cubicto$1aao = _r63_t0['cubic-to']['bind'](_r63_t0); + r63_xn$putshapes$9Jrj = _r63_t0['put-shapes']['bind'](_r63_t0); + r63_xn$reverselast$3qIs = _r63_t0['reverse-last']['bind'](_r63_t0); + r63_xn$setwidth$9Jrj(r0_WIDTH); + r63_xn$putshapes$9Jrj([ + r0_ORing(r0_XO, r0_O, r0_SB, r0_RIGHTSB - r0_STROKE / 2, r0_SMALLSMOOTH), + r0_ORing(r0_XO - r0_STROKE, r0_O + r0_STROKE, r0_SB + r0_STROKE, r0_RIGHTSB - r0_STROKE, r0_SMALLSMOOTH - r0_STROKE) + ]); + r63_xn$reverselast$3qIs(); + return void 0; + }); + r0_xn$createglyph$7Hrq('p', function _r0_t38() { + var r65_xn$setwidth$9Jrj, r65_xn$assignunicode$7Hrq, r65_xn$startfrom$1aao, r65_xn$lineto$5sIl, r65_xn$curveto$1aao, r65_xn$cubicto$1aao, r65_xn$putshapes$9Jrj, r65_xn$reverselast$3qIs, _r65_t0; + _r65_t0 = this; + r65_xn$setwidth$9Jrj = _r65_t0['set-width']['bind'](_r65_t0); + r65_xn$assignunicode$7Hrq = _r65_t0['assign-unicode']['bind'](_r65_t0); + r65_xn$startfrom$1aao = _r65_t0['start-from']['bind'](_r65_t0); + r65_xn$lineto$5sIl = _r65_t0['line-to']['bind'](_r65_t0); + r65_xn$curveto$1aao = _r65_t0['curve-to']['bind'](_r65_t0); + r65_xn$cubicto$1aao = _r65_t0['cubic-to']['bind'](_r65_t0); + r65_xn$putshapes$9Jrj = _r65_t0['put-shapes']['bind'](_r65_t0); + r65_xn$reverselast$3qIs = _r65_t0['reverse-last']['bind'](_r65_t0); + r65_xn$setwidth$9Jrj(r0_WIDTH); + r65_xn$assignunicode$7Hrq('p'); + r65_xn$putshapes$9Jrj(r0_glyphs['o.left']['contours']); + r65_xn$putshapes$9Jrj(new r0_Stroke()['start-from'](r0_SB, r0_XH)['set-width'](r0_STROKE, 0)['line-to'](r0_SB, r0_DESCENDER)['form-stroke']()); + return void 0; + }); + r0_xn$createglyph$7Hrq('b', function _r0_t39() { + var r67_xn$setwidth$9Jrj, r67_xn$assignunicode$7Hrq, r67_xn$startfrom$1aao, r67_xn$lineto$5sIl, r67_xn$curveto$1aao, r67_xn$cubicto$1aao, r67_xn$putshapes$9Jrj, r67_xn$reverselast$3qIs, _r67_t0; + _r67_t0 = this; + r67_xn$setwidth$9Jrj = _r67_t0['set-width']['bind'](_r67_t0); + r67_xn$assignunicode$7Hrq = _r67_t0['assign-unicode']['bind'](_r67_t0); + r67_xn$startfrom$1aao = _r67_t0['start-from']['bind'](_r67_t0); + r67_xn$lineto$5sIl = _r67_t0['line-to']['bind'](_r67_t0); + r67_xn$curveto$1aao = _r67_t0['curve-to']['bind'](_r67_t0); + r67_xn$cubicto$1aao = _r67_t0['cubic-to']['bind'](_r67_t0); + r67_xn$putshapes$9Jrj = _r67_t0['put-shapes']['bind'](_r67_t0); + r67_xn$reverselast$3qIs = _r67_t0['reverse-last']['bind'](_r67_t0); + r67_xn$setwidth$9Jrj(r0_WIDTH); + r67_xn$assignunicode$7Hrq('b'); + r67_xn$putshapes$9Jrj(r0_glyphs['o.left']['contours']); + r67_xn$putshapes$9Jrj(new r0_Stroke()['start-from'](r0_SB, 0)['set-width'](0, r0_STROKE)['line-to'](r0_SB, r0_CAP)['form-stroke']()); + return void 0; + }); + r0_xn$createglyph$7Hrq('q', function _r0_t40() { + var r69_xn$setwidth$9Jrj, r69_xn$assignunicode$7Hrq, r69_xn$startfrom$1aao, r69_xn$lineto$5sIl, r69_xn$curveto$1aao, r69_xn$cubicto$1aao, r69_xn$putshapes$9Jrj, r69_xn$reverselast$3qIs, _r69_t0; + _r69_t0 = this; + r69_xn$setwidth$9Jrj = _r69_t0['set-width']['bind'](_r69_t0); + r69_xn$assignunicode$7Hrq = _r69_t0['assign-unicode']['bind'](_r69_t0); + r69_xn$startfrom$1aao = _r69_t0['start-from']['bind'](_r69_t0); + r69_xn$lineto$5sIl = _r69_t0['line-to']['bind'](_r69_t0); + r69_xn$curveto$1aao = _r69_t0['curve-to']['bind'](_r69_t0); + r69_xn$cubicto$1aao = _r69_t0['cubic-to']['bind'](_r69_t0); + r69_xn$putshapes$9Jrj = _r69_t0['put-shapes']['bind'](_r69_t0); + r69_xn$reverselast$3qIs = _r69_t0['reverse-last']['bind'](_r69_t0); + r69_xn$setwidth$9Jrj(r0_WIDTH); + r69_xn$assignunicode$7Hrq('q'); + r69_xn$putshapes$9Jrj(r0_glyphs['o.right']['contours']); + r69_xn$putshapes$9Jrj(new r0_Stroke()['start-from'](r0_RIGHTSB, r0_XH)['set-width'](0, r0_STROKE)['line-to'](r0_RIGHTSB, r0_DESCENDER)['form-stroke']()); + return void 0; + }); + r0_xn$createglyph$7Hrq('g', function _r0_t41() { + var r71_xn$setwidth$9Jrj, r71_xn$assignunicode$7Hrq, r71_xn$startfrom$1aao, r71_xn$lineto$5sIl, r71_xn$curveto$1aao, r71_xn$cubicto$1aao, r71_xn$putshapes$9Jrj, r71_xn$reverselast$3qIs, r71_MODDLE, _r71_t0; + _r71_t0 = this; + r71_xn$setwidth$9Jrj = _r71_t0['set-width']['bind'](_r71_t0); + r71_xn$assignunicode$7Hrq = _r71_t0['assign-unicode']['bind'](_r71_t0); + r71_xn$startfrom$1aao = _r71_t0['start-from']['bind'](_r71_t0); + r71_xn$lineto$5sIl = _r71_t0['line-to']['bind'](_r71_t0); + r71_xn$curveto$1aao = _r71_t0['curve-to']['bind'](_r71_t0); + r71_xn$cubicto$1aao = _r71_t0['cubic-to']['bind'](_r71_t0); + r71_xn$putshapes$9Jrj = _r71_t0['put-shapes']['bind'](_r71_t0); + r71_xn$reverselast$3qIs = _r71_t0['reverse-last']['bind'](_r71_t0); + r71_xn$setwidth$9Jrj(r0_WIDTH); + r71_xn$assignunicode$7Hrq('g'); + r71_xn$putshapes$9Jrj([ + r0_Ring(r0_XO, r0_XH * 0.4, r0_SB * 1.5, r0_RIGHTSB - 0.5 * r0_SB, r0_SMALLSMOOTH), + r0_Ring(r0_XO - r0_STROKE, r0_XH * 0.4 + r0_STROKE, r0_SB * 1.5 + r0_STROKE, r0_RIGHTSB - 0.5 * r0_SB - r0_STROKE, r0_SMALLSMOOTH - r0_STROKE) + ]); + r71_xn$reverselast$3qIs(); + r71_xn$putshapes$9Jrj(new r0_Stroke()['start-from'](r0_MIDDLE, r0_XH * 0.4)['set-width'](0, r0_STROKE * 0.75)['arc-hv-to'](r0_SB * 1.5 + r0_STROKE, (r0_O - r0_DESCENDER * 0.85 + r0_XH * 0.4) / 2)['set-width'](0, r0_STROKE)['arc-vh-to'](r0_MIDDLE + r0_DESCENDER * 0.15, r0_O - r0_DESCENDER * 0.85)['line-to'](r0_MIDDLE - r0_DESCENDER * 0.15, r0_O - r0_DESCENDER * 0.85)['arc-hv-to'](r0_RIGHTSB - r0_O * 2, 0)['arc-vh-to'](r0_MIDDLE, r0_DESCENDER + r0_O)['arc-hv-to'](r0_SB, r0_DESCENDER * 0.1)['arc-vh-to'](r0_MIDDLE + r0_DESCENDER * 0.15, r0_O - r0_DESCENDER * 0.85)['form-stroke']()); + r71_xn$startfrom$1aao(r0_RIGHTSB, r0_XH); + r71_xn$lineto$5sIl(r0_RIGHTSB, r0_XH - r0_STROKE); + r71_xn$lineto$5sIl(r0_MIDDLE, r0_XH - r0_STROKE - r0_O); + r71_xn$lineto$5sIl(r71_MODDLE, r0_XH); + return void 0; + }); + r0_xn$createglyph$7Hrq('d', function _r0_t42() { + var r73_xn$setwidth$9Jrj, r73_xn$assignunicode$7Hrq, r73_xn$startfrom$1aao, r73_xn$lineto$5sIl, r73_xn$curveto$1aao, r73_xn$cubicto$1aao, r73_xn$putshapes$9Jrj, r73_xn$reverselast$3qIs, _r73_t0; + _r73_t0 = this; + r73_xn$setwidth$9Jrj = _r73_t0['set-width']['bind'](_r73_t0); + r73_xn$assignunicode$7Hrq = _r73_t0['assign-unicode']['bind'](_r73_t0); + r73_xn$startfrom$1aao = _r73_t0['start-from']['bind'](_r73_t0); + r73_xn$lineto$5sIl = _r73_t0['line-to']['bind'](_r73_t0); + r73_xn$curveto$1aao = _r73_t0['curve-to']['bind'](_r73_t0); + r73_xn$cubicto$1aao = _r73_t0['cubic-to']['bind'](_r73_t0); + r73_xn$putshapes$9Jrj = _r73_t0['put-shapes']['bind'](_r73_t0); + r73_xn$reverselast$3qIs = _r73_t0['reverse-last']['bind'](_r73_t0); + r73_xn$setwidth$9Jrj(r0_WIDTH); + r73_xn$assignunicode$7Hrq('d'); + r73_xn$putshapes$9Jrj(r0_glyphs['o.right']['contours']); + r73_xn$putshapes$9Jrj(new r0_Stroke()['start-from'](r0_RIGHTSB, 0)['set-width'](r0_STROKE, 0)['line-to'](r0_RIGHTSB, r0_CAP)['form-stroke']()); + return void 0; + }); + r0_xn$createglyph$7Hrq('zero', function _r0_t43() { + var r75_xn$setwidth$9Jrj, r75_xn$assignunicode$7Hrq, r75_xn$startfrom$1aao, r75_xn$lineto$5sIl, r75_xn$curveto$1aao, r75_xn$cubicto$1aao, r75_xn$putshapes$9Jrj, r75_xn$reverselast$3qIs, r75_bar, _r75_t0; + _r75_t0 = this; + r75_xn$setwidth$9Jrj = _r75_t0['set-width']['bind'](_r75_t0); + r75_xn$assignunicode$7Hrq = _r75_t0['assign-unicode']['bind'](_r75_t0); + r75_xn$startfrom$1aao = _r75_t0['start-from']['bind'](_r75_t0); + r75_xn$lineto$5sIl = _r75_t0['line-to']['bind'](_r75_t0); + r75_xn$curveto$1aao = _r75_t0['curve-to']['bind'](_r75_t0); + r75_xn$cubicto$1aao = _r75_t0['cubic-to']['bind'](_r75_t0); + r75_xn$putshapes$9Jrj = _r75_t0['put-shapes']['bind'](_r75_t0); + r75_xn$reverselast$3qIs = _r75_t0['reverse-last']['bind'](_r75_t0); + r75_xn$setwidth$9Jrj(r0_WIDTH); + r75_xn$assignunicode$7Hrq('0'); + r75_xn$putshapes$9Jrj(r0_glyphs['O']['contours']); + r75_bar = new r0_Stroke()['start-from'](r0_SB + r0_STROKE / 2, r0_CAP * (1 - 0.65))['line-to'](r0_RIGHTSB - r0_STROKE / 2, r0_CAP * 0.65); + r75_xn$putshapes$9Jrj(r75_bar['form-stroke'](r0_STROKE / 2, r0_STROKE / 2)); + return void 0; + }); + r0_xn$createglyph$7Hrq('Q', function _r0_t44() { + var r77_xn$setwidth$9Jrj, r77_xn$assignunicode$7Hrq, r77_xn$startfrom$1aao, r77_xn$lineto$5sIl, r77_xn$curveto$1aao, r77_xn$cubicto$1aao, r77_xn$putshapes$9Jrj, r77_xn$reverselast$3qIs, _r77_t0; + _r77_t0 = this; + r77_xn$setwidth$9Jrj = _r77_t0['set-width']['bind'](_r77_t0); + r77_xn$assignunicode$7Hrq = _r77_t0['assign-unicode']['bind'](_r77_t0); + r77_xn$startfrom$1aao = _r77_t0['start-from']['bind'](_r77_t0); + r77_xn$lineto$5sIl = _r77_t0['line-to']['bind'](_r77_t0); + r77_xn$curveto$1aao = _r77_t0['curve-to']['bind'](_r77_t0); + r77_xn$cubicto$1aao = _r77_t0['cubic-to']['bind'](_r77_t0); + r77_xn$putshapes$9Jrj = _r77_t0['put-shapes']['bind'](_r77_t0); + r77_xn$reverselast$3qIs = _r77_t0['reverse-last']['bind'](_r77_t0); + r77_xn$setwidth$9Jrj(r0_WIDTH); + r77_xn$assignunicode$7Hrq('Q'); + r77_xn$putshapes$9Jrj(r0_glyphs['O']['contours']); + r77_xn$startfrom$1aao(r0_MIDDLE, 0); + r77_xn$lineto$5sIl(r0_MIDDLE + r0_STROKE / 2, -r0_CAP * 0.2); + r77_xn$lineto$5sIl(r0_MIDDLE + r0_STROKE / 2 + r0_STROKE, -r0_CAP * 0.2); + r77_xn$lineto$5sIl(r0_MIDDLE + r0_STROKE, 0); + r77_xn$lineto$5sIl(r0_MIDDLE + r0_STROKE * (1 - 0.5 / 3), r0_STROKE * 0.5); + r77_xn$reverselast$3qIs(); + return void 0; + }); + r0_xn$createglyph$7Hrq('H', function _r0_t45() { + var r79_xn$setwidth$9Jrj, r79_xn$assignunicode$7Hrq, r79_xn$startfrom$1aao, r79_xn$lineto$5sIl, r79_xn$curveto$1aao, r79_xn$cubicto$1aao, r79_xn$putshapes$9Jrj, r79_xn$reverselast$3qIs, _r79_t0; + _r79_t0 = this; + r79_xn$setwidth$9Jrj = _r79_t0['set-width']['bind'](_r79_t0); + r79_xn$assignunicode$7Hrq = _r79_t0['assign-unicode']['bind'](_r79_t0); + r79_xn$startfrom$1aao = _r79_t0['start-from']['bind'](_r79_t0); + r79_xn$lineto$5sIl = _r79_t0['line-to']['bind'](_r79_t0); + r79_xn$curveto$1aao = _r79_t0['curve-to']['bind'](_r79_t0); + r79_xn$cubicto$1aao = _r79_t0['cubic-to']['bind'](_r79_t0); + r79_xn$putshapes$9Jrj = _r79_t0['put-shapes']['bind'](_r79_t0); + r79_xn$reverselast$3qIs = _r79_t0['reverse-last']['bind'](_r79_t0); + r79_xn$setwidth$9Jrj(r0_WIDTH); + r79_xn$assignunicode$7Hrq('H'); + r79_xn$putshapes$9Jrj(new r0_Stroke()['start-from'](r0_SB, 0)['set-width'](0, r0_STROKE)['line-to'](r0_SB, r0_CAP)['form-stroke']()); + r79_xn$putshapes$9Jrj(new r0_Stroke()['start-from'](r0_RIGHTSB, 0)['set-width'](r0_STROKE, 0)['line-to'](r0_RIGHTSB, r0_CAP)['form-stroke']()); + r79_xn$putshapes$9Jrj(new r0_Stroke()['start-from'](r0_SB, r0_CAP / 2)['set-width'](r0_HALFSTROKE, r0_HALFSTROKE)['line-to'](r0_RIGHTSB, r0_CAP / 2)['form-stroke']()); + return void 0; + }); + r0_xn$createglyph$7Hrq('L', function _r0_t46() { + var r81_xn$setwidth$9Jrj, r81_xn$assignunicode$7Hrq, r81_xn$startfrom$1aao, r81_xn$lineto$5sIl, r81_xn$curveto$1aao, r81_xn$cubicto$1aao, r81_xn$putshapes$9Jrj, r81_xn$reverselast$3qIs, _r81_t0; + _r81_t0 = this; + r81_xn$setwidth$9Jrj = _r81_t0['set-width']['bind'](_r81_t0); + r81_xn$assignunicode$7Hrq = _r81_t0['assign-unicode']['bind'](_r81_t0); + r81_xn$startfrom$1aao = _r81_t0['start-from']['bind'](_r81_t0); + r81_xn$lineto$5sIl = _r81_t0['line-to']['bind'](_r81_t0); + r81_xn$curveto$1aao = _r81_t0['curve-to']['bind'](_r81_t0); + r81_xn$cubicto$1aao = _r81_t0['cubic-to']['bind'](_r81_t0); + r81_xn$putshapes$9Jrj = _r81_t0['put-shapes']['bind'](_r81_t0); + r81_xn$reverselast$3qIs = _r81_t0['reverse-last']['bind'](_r81_t0); + r81_xn$setwidth$9Jrj(r0_WIDTH); + r81_xn$assignunicode$7Hrq('L'); + r81_xn$putshapes$9Jrj(new r0_Stroke()['start-from'](r0_SB * 1.5, r0_CAP)['line-to'](r0_SB * 1.5, 0)['form-stroke'](r0_STROKE, 0)); + r81_xn$putshapes$9Jrj(new r0_Stroke()['start-from'](r0_SB * 1.5, 0)['line-to'](r0_RIGHTSB, 0)['form-stroke'](r0_STROKE, 0)); + return void 0; + }); + r0_xn$createglyph$7Hrq('S', function _r0_t47() { + var r83_xn$setwidth$9Jrj, r83_xn$assignunicode$7Hrq, r83_xn$startfrom$1aao, r83_xn$lineto$5sIl, r83_xn$curveto$1aao, r83_xn$cubicto$1aao, r83_xn$putshapes$9Jrj, r83_xn$reverselast$3qIs, r83_slope, r83_bowltop, r83_strokemiddle, r83_bowlbottom, _r83_t0; + _r83_t0 = this; + r83_xn$setwidth$9Jrj = _r83_t0['set-width']['bind'](_r83_t0); + r83_xn$assignunicode$7Hrq = _r83_t0['assign-unicode']['bind'](_r83_t0); + r83_xn$startfrom$1aao = _r83_t0['start-from']['bind'](_r83_t0); + r83_xn$lineto$5sIl = _r83_t0['line-to']['bind'](_r83_t0); + r83_xn$curveto$1aao = _r83_t0['curve-to']['bind'](_r83_t0); + r83_xn$cubicto$1aao = _r83_t0['cubic-to']['bind'](_r83_t0); + r83_xn$putshapes$9Jrj = _r83_t0['put-shapes']['bind'](_r83_t0); + r83_xn$reverselast$3qIs = _r83_t0['reverse-last']['bind'](_r83_t0); + r83_xn$setwidth$9Jrj(r0_WIDTH); + r83_xn$assignunicode$7Hrq('S'); + r83_slope = 0.11; + r83_bowltop = new r0_Stroke(); + r83_bowltop['start-from'](r0_RIGHTSB - r0_SB * 0.1, r0_CAP - r0_HOOK)['set-width'](r0_STROKE, 0)['curve-to'](r0_MIDDLE + r0_KAPPA_HOOK * (r0_MIDDLE - r0_para['sb']), r0_CAPO, r0_MIDDLE, r0_CAPO)['cubic-to'](r0_SB + (1 - r0_BKAPPA) * (r0_WIDTH / 2 - r0_SB), r0_CAPO, r0_SB, r0_CAP - r0_COBKAPPA * r0_SMOOTH, r0_SB, r0_CAP_SMOOTH); + r83_strokemiddle = new r0_Stroke(); + r83_strokemiddle['start-from'](r0_SB + r0_STROKE / 2, r0_CAP_SMOOTH)['set-width'](r0_STROKE / 2, r0_STROKE / 2)['curve-to'](r0_SB + r0_STROKE / 2, (0.5 + r83_slope) * r0_CAP + 2 * r83_slope * r0_CAP / (0.4 * r0_WIDTH) * (0.3 * r0_WIDTH - r0_SB - r0_STROKE / 2), 0.3 * r0_WIDTH, (0.5 + r83_slope) * r0_CAP)['line-to'](0.7 * r0_WIDTH, (0.5 - r83_slope) * r0_CAP)['curve-to'](r0_RIGHTSB - r0_STROKE / 2, (0.5 - r83_slope) * r0_CAP - 2 * r83_slope * r0_CAP / (0.4 * r0_WIDTH) * (0.3 * r0_WIDTH - r0_SB - r0_STROKE / 2), r0_RIGHTSB - r0_STROKE / 2, r0_SMOOTH); + r83_bowlbottom = new r0_Stroke(); + r83_bowlbottom['start-from'](r0_RIGHTSB, r0_SMOOTH)['set-width'](0, r0_STROKE)['cubic-to'](r0_RIGHTSB, r0_COBKAPPA * r0_SMOOTH, r0_MIDDLE + r0_BKAPPA * (r0_RIGHTSB - r0_MIDDLE), r0_O, r0_MIDDLE, r0_O)['curve-to'](r0_MIDDLE - r0_KAPPA_HOOK * (r0_MIDDLE - r0_para['sb']), r0_O, r0_SB * 1.1, r0_HOOK); + r83_xn$putshapes$9Jrj(r83_bowltop['form-stroke']()); + r83_xn$putshapes$9Jrj(r83_strokemiddle['form-stroke']()); + r83_xn$putshapes$9Jrj(r83_bowlbottom['form-stroke']()); + return void 0; + }); + r0_xn$createglyph$7Hrq('dollar', function _r0_t48() { + var r85_xn$setwidth$9Jrj, r85_xn$assignunicode$7Hrq, r85_xn$startfrom$1aao, r85_xn$lineto$5sIl, r85_xn$curveto$1aao, r85_xn$cubicto$1aao, r85_xn$putshapes$9Jrj, r85_xn$reverselast$3qIs, _r85_t0; + _r85_t0 = this; + r85_xn$setwidth$9Jrj = _r85_t0['set-width']['bind'](_r85_t0); + r85_xn$assignunicode$7Hrq = _r85_t0['assign-unicode']['bind'](_r85_t0); + r85_xn$startfrom$1aao = _r85_t0['start-from']['bind'](_r85_t0); + r85_xn$lineto$5sIl = _r85_t0['line-to']['bind'](_r85_t0); + r85_xn$curveto$1aao = _r85_t0['curve-to']['bind'](_r85_t0); + r85_xn$cubicto$1aao = _r85_t0['cubic-to']['bind'](_r85_t0); + r85_xn$putshapes$9Jrj = _r85_t0['put-shapes']['bind'](_r85_t0); + r85_xn$reverselast$3qIs = _r85_t0['reverse-last']['bind'](_r85_t0); + r85_xn$setwidth$9Jrj(r0_WIDTH); + r85_xn$assignunicode$7Hrq('$'); + r85_xn$putshapes$9Jrj(r0_glyphs['S']['contours']); + r85_xn$putshapes$9Jrj(new r0_Stroke()['start-from'](r0_MIDDLE, r0_CAP)['set-width'](r0_HALFSTROKE, r0_HALFSTROKE)['line-to'](r0_MIDDLE, r0_CAP - r0_DESCENDER / 2)['form-stroke']()); + r85_xn$putshapes$9Jrj(new r0_Stroke()['start-from'](r0_MIDDLE, r0_DESCENDER / 2)['set-width'](r0_HALFSTROKE, r0_HALFSTROKE)['line-to'](r0_MIDDLE, 0)['form-stroke']()); + return void 0; + }); + exports['font'] = r0_font; +} diff --git a/font.patel b/font.patel new file mode 100644 index 0000000..09d691b --- /dev/null +++ b/font.patel @@ -0,0 +1,650 @@ +define font [require './empty.json'] +define bezierCubic2Q2 [require 'node-sfnt/lib/math/bezierCubic2Q2'] +define glyphList font.glyf +define glyphs (.'.notdef' glyphList.0) +define Bezier [require 'bezier-js'] +define Smooth [require './smooth.js'].Smooth +define intersection [require './intersection.js'].intersection + +define para ( + .width 500 + .stroke 85 + .sb 50 + .cap 771 + .xheight 572 + .hook 135 + .smooth 192 + .smallsmooth 242 + .o [-8] + .descender [-178] +) + +define TINY 0.0001 +define LITTLE 0.01 + +define DESCENDER para.descender +define O para.o +define WIDTH para.width +define STROKE para.stroke +define HALFSTROKE : STROKE / 2 +define SB para.sb +define CAP para.cap +define XH para.xheight +define XO : XH - O +define HOOK para.hook +define SMOOTH para.smooth +define SMALLSMOOTH para.smallsmooth +define RIGHTSB : WIDTH - SB +define CAP_SMOOTH : CAP - SMOOTH +define MIDDLE : WIDTH / 2 +define KAPPA 0.51 +define COKAPPA : 1 - KAPPA +define COBKAPPA : COKAPPA - 0.1 +define BKAPPA : KAPPA + 0.1 +define CAPMIDDLE : CAP / 2 +define CAPO : CAP - O +define ESS : STROKE * 0.5 +define SAMPLES 4 +define KAPPA_HOOK 0.7 + +define [Glyph name] : begin { + set this.name name + set this.unicode () + set this.contours () + set this.advanceWidth 500 + return nothing +} +define [Glyph.prototype.set-width w] : begin { + this.advanceWidth = w + return this +} +define [Glyph.prototype.assign-unicode u] : begin { + this.unicode.push [u.charCodeAt 0] + return this +} + +define [Glyph.prototype.start-from x y] : begin { + this.contours.push ((.x x .y y .onCurve true)) + return this +} +define [Glyph.prototype.line-to x y] : begin { + this.contours`[this.contours.length - 1].push (.x x .y y .onCurve true) + return this +} +define [Glyph.prototype.curve-to xc yc x y] : begin { + this.contours`[this.contours.length - 1].push (.x xc .y yc .onCurve false) (.x x .y y .onCurve true) + return this +} +define [Glyph.prototype.cubic-to x1 y1 x2 y2 x y] : begin { + local lastContour this.contours`[this.contours.length - 1] + local lastPoint lastContour`[lastContour.length - 1] + local segments [bezierCubic2Q2 lastPoint (.x x1 .y y1) (.x x2 .y y2) (.x x .y y)] + foreach (p0 (.x xc .y yc) (.x xf .y yf)) [items-of segments] : this.curve-to xc yc xf yf + return this +} +define [Glyph.prototype.reverse-last] : begin { + this.contours.[this.contours.length - 1] = [this.contours.[this.contours.length - 1].reverse] +} +define [Glyph.prototype.put-shapes contours] : begin { + foreach contour [items-of contours] : begin { + this.start-from contour.0.x contour.0.y + for [local j 1] [j < contour.length] [inc j] : begin { + local point contour`j + if point.cubic [begin { + local p2 contour`[j + 1] + local p3 contour`[j + 2] + this.cubic-to point.x point.y p2.x p2.y p3.x p3.y + j = j + 2 + }] [if point.onCurve [this.line-to point.x point.y] [begin { + local p2 contour`[j + 1] + this.curve-to point.x point.y p2.x p2.y + j = j + 1 + }]] + } + } + return this +} + +define [Stroke] : begin { + this.points = () + return this +} +define [Stroke.prototype.set-width d1 d2] : begin { + local point this.points`[this.points.length - 1] + point.d1 = d1 + point.d2 = d2 + return this +} +define [Stroke.prototype.start-from x y] : begin { + this.points = ((.x x .y y .onCurve true)) + return this +} +define [Stroke.prototype.line-to x y] : begin { + this.points.push (.x x .y y .onCurve true) + return this +} +define [Stroke.prototype.curve-to xc yc x y] : begin { + this.points.push (.x xc .y yc .onCurve false) (.x x .y y .onCurve true) + return this +} +define [Stroke.prototype.cubic-to x1 y1 x2 y2 x y] : begin { + this.points.push (.x x1 .y y1 .onCurve false .cubic true) (.x x2 .y y2 .onCurve false .cubic true) (.x x .y y .onCurve true) + return this +} +define [Stroke.prototype.arc-vh-to x y] : begin { + local last this.points`[this.points.length - 1] + this.cubic-to last.x [last.y + BKAPPA * [y - last.y]] [x + BKAPPA * [last.x - x]] y x y + return this +} +define [Stroke.prototype.arc-hv-to x y] : begin { + local last this.points`[this.points.length - 1] + this.cubic-to [last.x + BKAPPA * [x - last.x]] last.y x [y + BKAPPA * [last.y - y]] x y + return this +} +define [dforward p0 p1 p2 p3] ( + .x [p0.x + [[-11] / 6 * p0.x + 3 * p1.x - 3 / 2 * p2.x + p3.x / 3] / TINY * LITTLE] + .y [p0.y + [[-11] / 6 * p0.y + 3 * p1.y - 3 / 2 * p2.y + p3.y / 3] / TINY * LITTLE] +) +define [dbackward p0 p1 p2 p3] ( + .x [p0.x + [11 / 6 * p0.x - 3 * p1.x + 3 / 2 * p2.x - p3.x / 3] / TINY * LITTLE] + .y [p0.y + [11 / 6 * p0.y - 3 * p1.y + 3 / 2 * p2.y - p3.y / 3] / TINY * LITTLE] +) +define [nonlinear a b c] : [Math.abs [[c.y - a.y] * [b.x - a.x] - [c.x - a.x] * [b.y - a.y]]] > TINY + +define [Stroke.prototype.form-stroke d1 d2] : begin { + local d1s ([set d1 [if [this.points.0.d1 >= 0] this.points.0.d1 d1]]) + local d2s ([set d2 [if [this.points.0.d2 >= 0] this.points.0.d2 d2]]) + local subSegments () + local p0 this.points.0 + for [local j 1] [j < this.points.length] [inc j] : begin { + local p1 this.points`j + piecewise { + p1.onCurve : begin { + subSegments.push (p0 (.x [[p0.x + p1.x] / 2] .y [[p0.y + p1.y] / 2]) p1) + d1s.push : set d1 [if [p1.d1 >= 0] p1.d1 d1] + d2s.push : set d2 [if [p1.d2 >= 0] p1.d2 d2] + p0 = p1 + } + p1.cubic : begin { + local p2 this.points`[j + 1] + local p3 this.points`[j + 2] + d1s.push : set d1 [if [p3.d1 >= 0] p3.d1 d1] + d2s.push : set d2 [if [p3.d2 >= 0] p3.d2 d2] + subSegments.push (p0 p1 p2 p3) + p0 = p3 + j = j + 2 + } + true : begin { + local p2 this.points`[j + 1] + d1s.push : set d1 [if [p2.d1 >= 0] p2.d1 d1] + d2s.push : set d2 [if [p2.d2 >= 0] p2.d2 d2] + subSegments.push (p0 p1 p2) + p0 = p2 + j = j + 1 + } + } + } + local f1 : Smooth d1s (.method 'cubic') + local f2 : Smooth d2s (.method 'cubic') + local left () + local right () + for [local j 0] [j < subSegments.length] [inc j] : begin { + local seg subSegments`j + local curve : if [seg.length > 3] [new Bezier seg.0.x seg.0.y seg.1.x seg.1.y seg.2.x seg.2.y seg.3.x seg.3.y] [new Bezier seg.0.x seg.0.y seg.1.x seg.1.y seg.2.x seg.2.y] + foreach sample [range 0 SAMPLES] : begin { + local t : j + sample / SAMPLES + local tn : j + [sample + 1] / SAMPLES + + local lthis : curve.offset [sample / SAMPLES] [f1 t] + local rthis : curve.offset [sample / SAMPLES] [-[f2 t]] + + local lnext : curve.offset [[sample + 1] / SAMPLES] [f1 tn] + local rnext : curve.offset [[sample + 1] / SAMPLES] [-[f2 tn]] + + local lnthis1 : curve.offset [sample / SAMPLES + TINY] [f1 [t + TINY]] + local rnthis1 : curve.offset [sample / SAMPLES + TINY] [-[f2 [t + TINY]]] + local lnnext1 : curve.offset [[sample + 1] / SAMPLES - TINY] [f1 [tn - TINY]] + local rnnext1 : curve.offset [[sample + 1] / SAMPLES - TINY] [-[f2 [tn - TINY]]] + local lnthis2 : curve.offset [sample / SAMPLES + [TINY * 2]] [f1 [t + [TINY * 2]]] + local rnthis2 : curve.offset [sample / SAMPLES + [TINY * 2]] [-[f2 [t + [TINY * 2]]]] + local lnnext2 : curve.offset [[sample + 1] / SAMPLES - [TINY * 2]] [f1 [tn - [TINY * 2]]] + local rnnext2 : curve.offset [[sample + 1] / SAMPLES - [TINY * 2]] [-[f2 [tn - [TINY * 2]]]] + local lnthis3 : curve.offset [sample / SAMPLES + [TINY * 3]] [f1 [t + [TINY * 3]]] + local rnthis3 : curve.offset [sample / SAMPLES + [TINY * 3]] [-[f2 [t + [TINY * 3]]]] + local lnnext3 : curve.offset [[sample + 1] / SAMPLES - [TINY * 3]] [f1 [tn - [TINY * 3]]] + local rnnext3 : curve.offset [[sample + 1] / SAMPLES - [TINY * 3]] [-[f2 [tn - [TINY * 3]]]] + + local dlthis [dforward lthis lnthis1 lnthis2 lnthis3] + local drthis [dforward rthis rnthis1 rnthis2 rnthis3] + local dlnext [dbackward lnext lnnext1 lnnext2 lnnext3] + local drnext [dbackward rnext rnnext2 rnnext2 rnnext3] + + local il : intersection lthis.x lthis.y dlthis.x dlthis.y lnext.x lnext.y dlnext.x dlnext.y + local ir : intersection rthis.x rthis.y drthis.x drthis.y rnext.x rnext.y drnext.x drnext.y + + if [[il.x != null] && [il.y != null] && [nonlinear lthis il lnext]] [then { + left.push (.x lthis.x .y lthis.y .onCurve true) (.x il.x .y il.y .onCurve false) + }] [else { + left.push (.x lthis.x .y lthis.y .onCurve true) + }] + + if [[ir.x != null] && [ir.y != null] && [nonlinear rthis ir rnext]] [then { + right.push (.x rthis.x .y rthis.y .onCurve true) (.x ir.x .y ir.y .onCurve false) + }] [else { + right.push (.x rthis.x .y rthis.y .onCurve true) + }] + } + } + left.push [begin [local last [curve.offset 1 [f1 t]]] (.x last.x .y last.y .onCurve true)] + right.push [begin [local last [curve.offset 1 [-[f2 t]]]] (.x last.x .y last.y .onCurve true)] + + local shape : left.concat [right.reverse] :.map [[p] -> (.x p.x .y p.y .onCurve p.onCurve)] + return (shape) +} + +define [Ring u d l r] : begin { + local my [[u + d] / 2] + local mx [[l + r] / 2] + local s : new Stroke + :.start-from mx d + :.cubic-to [mx + [l - mx] * BKAPPA] d l [my + [d - my] * BKAPPA] l my + :.cubic-to l [my + [u - my] * BKAPPA] [mx + [l - mx] * BKAPPA] u mx u + :.cubic-to [mx + [r - mx] * BKAPPA] u r [my + [u - my] * BKAPPA] r my + :.cubic-to r [my + [d - my] * BKAPPA] [mx + [r - mx] * BKAPPA] d mx d + return s.points +} +define [ORing u d l r smooth] : begin { + local myu [u - smooth] + local myd [d + smooth] + local mx [[l + r] / 2] + local s : new Stroke + :.start-from mx d + :.cubic-to [mx + [l - mx] * BKAPPA] d l [myd + [d - myd] * BKAPPA] l myd + :.line-to l myu + :.cubic-to l [myu + [u - myu] * BKAPPA] [mx + [l - mx] * BKAPPA] u mx u + :.cubic-to [mx + [r - mx] * BKAPPA] u r [myu + [u - myu] * BKAPPA] r myu + :.line-to r myd + :.cubic-to r [myd + [d - myd] * BKAPPA] [mx + [r - mx] * BKAPPA] d mx d + return s.points +} + +define-macro glyph-construction : syntax-rules { + @`[glyph-construction @::steps] ('.syntactic-closure' @`[lambda [] [begin { + local set-width : this.set-width.bind this + local assign-unicode : this.assign-unicode.bind this + local start-from : this.start-from.bind this + local line-to : this.line-to.bind this + local curve-to : this.curve-to.bind this + local cubic-to : this.cubic-to.bind this + local put-shapes : this.put-shapes.bind this + local reverse-last : this.reverse-last.bind this + begin @::[steps.map formOf] + return nothing + }]] env) +} + +define [create-glyph name actions] : begin { + define glyphObject [new Glyph name] + glyphList.push glyphObject + glyphs`name = glyphObject + actions.call glyphObject + return glyphObject +} + + +### GLYPHS +create-glyph 'space' : glyph-construction { + set-width WIDTH + assign-unicode ' ' +} +create-glyph 'bar' : glyph-construction { + set-width WIDTH + assign-unicode '|' + put-shapes : new Stroke :.start-from MIDDLE [DESCENDER / 2] + :.set-width [STROKE / 2] [STROKE / 2] + :.line-to MIDDLE [CAP - DESCENDER / 2] + :.form-stroke +} + +create-glyph 'A' : glyph-construction { + set-width WIDTH + assign-unicode 'A' + + local TURN [XH * 0.1] + + local leftbar : new Stroke + leftbar.start-from SB 0 + :.line-to SB TURN + :.curve-to SB [TURN + 0.27 * [CAP - TURN]] [MIDDLE - STROKE / 2] CAP + + local rightbar : new Stroke + rightbar.start-from RIGHTSB 0 + :.line-to RIGHTSB TURN + :.curve-to RIGHTSB [TURN + 0.27 * [CAP - TURN]] [MIDDLE + STROKE / 2] CAP + + local hbar : new Stroke + hbar.start-from [SB + STROKE] [XH / 2] :.line-to [RIGHTSB - STROKE] [XH / 2] + + put-shapes : leftbar.form-stroke 0 STROKE + put-shapes : hbar.form-stroke 0 STROKE + put-shapes : rightbar.form-stroke STROKE 0 + + #top cap + start-from [MIDDLE - STROKE / 2] CAP + line-to [MIDDLE + STROKE / 2] CAP + line-to MIDDLE [CAP - STROKE] +} +create-glyph 'X' : glyph-construction { + set-width WIDTH + assign-unicode 'X' + + local TURN [XH * 0.05] + local straight 0.6 + local strench 0.125 + + local barone : new Stroke + :.start-from [SB + HALFSTROKE] 0 + :.set-width HALFSTROKE HALFSTROKE + :.line-to [SB + HALFSTROKE] TURN + :.curve-to [SB + HALFSTROKE] [TURN + strench * [CAP - TURN]] [MIDDLE + straight * [SB + HALFSTROKE - MIDDLE]] [CAPMIDDLE + straight * [TURN + strench * [CAP - TURN] - CAPMIDDLE]] + :.line-to [MIDDLE + straight * [RIGHTSB - HALFSTROKE - MIDDLE]] [CAPMIDDLE + straight * [CAP - TURN - strench * [CAP - TURN] - CAPMIDDLE]] + :.curve-to [RIGHTSB - HALFSTROKE] [CAP - TURN - strench * [CAP - TURN]] [RIGHTSB - HALFSTROKE] [CAP - TURN] + :.line-to [RIGHTSB - HALFSTROKE] CAP + :.form-stroke + + local bartwo : list : barone.0.map [[pt] -> (.x [WIDTH - pt.x] .y pt.y .onCurve pt.onCurve .cubic pt.cubic)] :.reverse + + put-shapes barone + put-shapes bartwo +} +create-glyph 'Y' : glyph-construction { + set-width WIDTH + assign-unicode 'Y' + + local TURN [XH * 0.05] + local straight 0.6 + local strench 0.15 + local cross [CAP * 0.4] + + local barone : new Stroke + :.start-from MIDDLE cross + :.set-width HALFSTROKE HALFSTROKE + :.line-to [MIDDLE + straight * [RIGHTSB - HALFSTROKE - MIDDLE]] [cross + straight * [CAP - TURN - strench * [CAP - TURN] - cross]] + :.curve-to [RIGHTSB - HALFSTROKE] [CAP - TURN - strench * [CAP - TURN]] [RIGHTSB - HALFSTROKE] [CAP - TURN] + :.line-to [RIGHTSB - HALFSTROKE] CAP + :.form-stroke + + local bartwo : list : barone.0.map [[pt] -> (.x [WIDTH - pt.x] .y pt.y .onCurve pt.onCurve .cubic pt.cubic)] :.reverse + + put-shapes barone + put-shapes bartwo + put-shapes : new Stroke :.start-from MIDDLE 0 :.set-width HALFSTROKE HALFSTROKE :.line-to MIDDLE [cross + HALFSTROKE] :.form-stroke +} +create-glyph 'x' : glyph-construction { + set-width WIDTH + assign-unicode 'x' + + local TURN [XH * 0.1] + + local barone : new Stroke + :.start-from [SB + HALFSTROKE] 0 + :.set-width HALFSTROKE HALFSTROKE + :.cubic-to [SB + HALFSTROKE] [TURN + 0.17 * [XH - TURN]] [RIGHTSB - HALFSTROKE] [XH - TURN - 0.17 * [XH - TURN]] [RIGHTSB - HALFSTROKE] XH + :.form-stroke + + local bartwo : list : barone.0.map [[pt] -> (.x [WIDTH - pt.x] .y pt.y .onCurve pt.onCurve .cubic pt.cubic)] :.reverse + + put-shapes barone + put-shapes bartwo +} + +create-glyph 'B' : glyph-construction { + set-width WIDTH + assign-unicode 'B' + + local bowl 451 + local tkappa [COKAPPA - 0.22] + local bkappa [COKAPPA - 0.2] + + local turntop : [CAP + [bowl - STROKE]] / 2 + local turnbottom : bowl / 2 + + local topbowl : new Stroke + topbowl.start-from SB CAP + :.line-to [RIGHTSB - SB * 0.5 - turnbottom] CAP + :.cubic-to [RIGHTSB - SB * 0.5 - tkappa * turnbottom] CAP [RIGHTSB - SB * 0.5] [turntop + [CAP - turntop] * KAPPA] [RIGHTSB - SB * 0.5] turntop + :.cubic-to [RIGHTSB - SB * 0.5] [turntop + KAPPA * [bowl - STROKE - turntop]] [RIGHTSB - SB * 0.5 - tkappa * turnbottom] [bowl - STROKE] [RIGHTSB - SB * 0.5 - turnbottom] [bowl - STROKE] + :.line-to SB [bowl - STROKE] + + local bottombowl : new Stroke + bottombowl.start-from SB 0 + :.line-to [RIGHTSB - turnbottom] 0 + :.cubic-to [RIGHTSB - bkappa * turnbottom] 0 RIGHTSB [turnbottom * KAPPA] RIGHTSB turnbottom + :.cubic-to RIGHTSB [turnbottom + KAPPA * [bowl - turnbottom]] [RIGHTSB - bkappa * turnbottom] bowl [RIGHTSB - turnbottom] bowl + :.line-to SB bowl + + local leftbar : new Stroke :.start-from SB 0 :.line-to SB CAP + + put-shapes : topbowl.form-stroke 0 STROKE + put-shapes : bottombowl.form-stroke STROKE 0 + put-shapes : leftbar.form-stroke 0 STROKE +} + +create-glyph 'C' : glyph-construction { + set-width WIDTH + assign-unicode 'C' + local outline : new Stroke + outline.start-from [RIGHTSB - SB * 0.1] [CAP - HOOK] + :.curve-to [MIDDLE + KAPPA_HOOK * [MIDDLE - para.sb]] CAPO MIDDLE CAPO + :.cubic-to [SB + [1 - BKAPPA] * [WIDTH / 2 - SB]] CAPO SB [CAP - COBKAPPA * SMOOTH] SB CAP_SMOOTH + :.line-to SB SMOOTH + :.cubic-to SB [COBKAPPA * SMOOTH] [SB + [1 - BKAPPA] * [WIDTH / 2 - SB]] O [WIDTH / 2] O + :.curve-to [MIDDLE + KAPPA_HOOK * [MIDDLE - SB]] O [RIGHTSB - SB * 0.1] HOOK + put-shapes : outline.form-stroke STROKE 0 +} + +create-glyph 'D' : glyph-construction { + set-width WIDTH + assign-unicode 'D' + + local dsmooth [SMOOTH * 1.55] + local bsmooth [SMOOTH * 1.3] + local bkappa [COKAPPA - 0.2] + + local leftbar : new Stroke :.start-from SB 0 :.line-to SB CAP + + local bowl : new Stroke + bowl.start-from SB 0 + :.line-to [RIGHTSB - bsmooth] 0 + :.cubic-to [RIGHTSB - bkappa * bsmooth] 0 RIGHTSB [COBKAPPA * dsmooth] RIGHTSB dsmooth + :.line-to RIGHTSB [CAP - dsmooth] + :.cubic-to RIGHTSB [CAP - COBKAPPA * dsmooth] [RIGHTSB - bkappa * bsmooth] CAP [RIGHTSB - bsmooth] CAP + :.line-to SB CAP + + put-shapes : bowl.form-stroke STROKE 0 + put-shapes : leftbar.form-stroke 0 STROKE +} + +create-glyph 'G' : glyph-construction { + set-width WIDTH + assign-unicode 'G' + local outline : new Stroke + outline.start-from [RIGHTSB - SB * 0.1] [CAP - HOOK] + :.curve-to [MIDDLE + KAPPA_HOOK * [MIDDLE - para.sb]] CAPO MIDDLE CAPO + :.cubic-to [SB + [1 - BKAPPA] * [WIDTH / 2 - SB]] CAPO SB [CAP - COBKAPPA * SMOOTH] SB CAP_SMOOTH + :.line-to SB SMOOTH + :.cubic-to SB [COBKAPPA * SMOOTH] [SB + [1 - BKAPPA] * [WIDTH / 2 - SB]] O [WIDTH / 2] O + :.cubic-to [MIDDLE + BKAPPA * [RIGHTSB - MIDDLE]] O RIGHTSB [COBKAPPA * SMOOTH] RIGHTSB SMOOTH + :.line-to RIGHTSB [CAP / 2 + STROKE / 2] + put-shapes : outline.form-stroke STROKE 0 + + local bar : new Stroke :.start-from MIDDLE [CAP / 2 + STROKE / 2] :.line-to RIGHTSB [CAP / 2 + STROKE / 2] + put-shapes : bar.form-stroke 0 STROKE +} + +create-glyph 'O' : glyph-construction { + set-width WIDTH + assign-unicode 'O' + local outline : new Stroke + outline.start-from MIDDLE CAPO + :.cubic-to [SB + [1 - BKAPPA] * [WIDTH / 2 - SB]] CAPO SB [CAP - COBKAPPA * SMOOTH] SB [CAP - SMOOTH] + :.line-to SB SMOOTH + :.cubic-to SB [COBKAPPA * SMOOTH] [SB + [1 - BKAPPA] * [WIDTH / 2 - SB]] O [WIDTH / 2] O + :.cubic-to [MIDDLE + BKAPPA * [RIGHTSB - MIDDLE]] O RIGHTSB [COBKAPPA * SMOOTH] RIGHTSB SMOOTH + :.line-to RIGHTSB [CAP - SMOOTH] + :.cubic-to RIGHTSB [CAP - COBKAPPA * SMOOTH] [MIDDLE + BKAPPA * [RIGHTSB - MIDDLE]] CAPO MIDDLE CAPO + put-shapes : outline.form-stroke STROKE 0 +} +create-glyph 'o' : glyph-construction { + set-width WIDTH + assign-unicode 'o' + put-shapes : list { + ORing XO O SB RIGHTSB SMALLSMOOTH + ORing [XO - STROKE] [O + STROKE] [SB + STROKE] [RIGHTSB - STROKE] [SMALLSMOOTH - STROKE] + } + reverse-last +} + +create-glyph 'o.left' : glyph-construction { + set-width WIDTH + # build outline manually + put-shapes : list { + ORing XO O [SB + STROKE / 2] RIGHTSB SMALLSMOOTH + ORing [XO - STROKE] [O + STROKE] [SB + STROKE] [RIGHTSB - STROKE] [SMALLSMOOTH - STROKE] + } + reverse-last +} +create-glyph 'o.right' : glyph-construction { + set-width WIDTH + # build outline manually + put-shapes : list { + ORing XO O SB [RIGHTSB - STROKE / 2] SMALLSMOOTH + ORing [XO - STROKE] [O + STROKE] [SB + STROKE] [RIGHTSB - STROKE] [SMALLSMOOTH - STROKE] + } + reverse-last +} +create-glyph 'p' : glyph-construction { + set-width WIDTH + assign-unicode 'p' + put-shapes glyphs.'o.left'.contours + put-shapes : new Stroke :.start-from SB XH :.set-width STROKE 0 :.line-to SB DESCENDER :.form-stroke +} +create-glyph 'b' : glyph-construction { + set-width WIDTH + assign-unicode 'b' + put-shapes glyphs.'o.left'.contours + put-shapes : new Stroke :.start-from SB 0 :.set-width 0 STROKE :.line-to SB CAP :.form-stroke +} +create-glyph 'q' : glyph-construction { + set-width WIDTH + assign-unicode 'q' + put-shapes glyphs.'o.right'.contours + put-shapes : new Stroke :.start-from RIGHTSB XH :.set-width 0 STROKE :.line-to RIGHTSB DESCENDER :.form-stroke +} +create-glyph 'g' : glyph-construction { + set-width WIDTH + assign-unicode 'g' + + put-shapes : list { + Ring XO [XH * 0.4] [SB * 1.5] [RIGHTSB - 0.5 * SB] SMALLSMOOTH + Ring [XO - STROKE] [[XH * 0.4] + STROKE] [SB * 1.5 + STROKE] [[RIGHTSB - 0.5 * SB] - STROKE] [SMALLSMOOTH - STROKE] + } + reverse-last + + put-shapes : new Stroke + :.start-from MIDDLE [XH * 0.4] + :.set-width 0 [STROKE * 0.75] + :.arc-hv-to [SB * 1.5 + STROKE] [[O - DESCENDER * 0.85 + XH * 0.4] / 2] + :.set-width 0 STROKE + :.arc-vh-to [MIDDLE + DESCENDER * 0.15] [O - DESCENDER * 0.85] + :.line-to [MIDDLE - DESCENDER * 0.15] [O - DESCENDER * 0.85] + :.arc-hv-to [RIGHTSB - O * 2] 0 + :.arc-vh-to MIDDLE [DESCENDER + O] + :.arc-hv-to SB [DESCENDER * 0.1] + :.arc-vh-to [MIDDLE + DESCENDER * 0.15] [O - DESCENDER * 0.85] + :.form-stroke + + start-from RIGHTSB XH + line-to RIGHTSB [XH - STROKE] + line-to MIDDLE [XH - STROKE - O] + line-to MODDLE XH +} +create-glyph 'd' : glyph-construction { + set-width WIDTH + assign-unicode 'd' + put-shapes glyphs.'o.right'.contours + put-shapes : new Stroke :.start-from RIGHTSB 0 :.set-width STROKE 0 :.line-to RIGHTSB CAP :.form-stroke +} + +create-glyph 'zero' : glyph-construction { + set-width WIDTH + assign-unicode '0' + put-shapes glyphs.O.contours + + local bar : new Stroke :.start-from [SB + STROKE / 2] [CAP * [1 - 0.65]] :.line-to [RIGHTSB - STROKE / 2] [CAP * 0.65] + put-shapes : bar.form-stroke [STROKE / 2] [STROKE / 2] +} + +create-glyph 'Q' : glyph-construction { + set-width WIDTH + assign-unicode 'Q' + + put-shapes glyphs.O.contours + start-from MIDDLE 0 + line-to [MIDDLE + STROKE / 2] [-CAP * 0.2] + line-to [MIDDLE + STROKE / 2 + STROKE] [-CAP * 0.2] + line-to [MIDDLE + STROKE] 0 + line-to [MIDDLE + STROKE * [1 - 0.5 / 3]] [STROKE * 0.5] + reverse-last +} + +create-glyph 'H' : glyph-construction { + set-width WIDTH + assign-unicode 'H' + + put-shapes : new Stroke :.start-from SB 0 :.set-width 0 STROKE :.line-to SB CAP :.form-stroke + put-shapes : new Stroke :.start-from RIGHTSB 0 :.set-width STROKE 0 :.line-to RIGHTSB CAP :.form-stroke + put-shapes : new Stroke :.start-from SB [CAP / 2] :.set-width HALFSTROKE HALFSTROKE :.line-to RIGHTSB [CAP / 2] :.form-stroke +} + +create-glyph 'L' : glyph-construction { + set-width WIDTH + assign-unicode 'L' + + put-shapes : new Stroke :.start-from [SB * 1.5] CAP :.line-to [SB * 1.5] 0 :.form-stroke STROKE 0 + put-shapes : new Stroke :.start-from [SB * 1.5] 0 :.line-to RIGHTSB 0 :.form-stroke STROKE 0 +} +create-glyph 'S' : glyph-construction { + set-width WIDTH; assign-unicode 'S' + + local slope 0.11 + + local bowltop : new Stroke + bowltop.start-from [RIGHTSB - SB * 0.1] [CAP - HOOK] + :.set-width STROKE 0 + :.curve-to [MIDDLE + KAPPA_HOOK * [MIDDLE - para.sb]] CAPO MIDDLE CAPO + :.cubic-to [SB + [1 - BKAPPA] * [WIDTH / 2 - SB]] CAPO SB [CAP - COBKAPPA * SMOOTH] SB CAP_SMOOTH + + local strokemiddle : new Stroke + strokemiddle.start-from [SB + STROKE / 2] CAP_SMOOTH + :.set-width [STROKE / 2] [STROKE / 2] + :.curve-to [SB + STROKE / 2] [[0.5 + slope] * CAP + [2 * slope * CAP] / [0.4 * WIDTH] * [0.3 * WIDTH - SB - STROKE / 2]] [0.3 * WIDTH] [[0.5 + slope] * CAP] + :.line-to [0.7 * WIDTH] [[0.5 - slope] * CAP] + :.curve-to [RIGHTSB - STROKE / 2] [[0.5 - slope] * CAP - [2 * slope * CAP] / [0.4 * WIDTH] * [0.3 * WIDTH - SB - STROKE / 2]] [RIGHTSB - STROKE / 2] SMOOTH + + local bowlbottom : new Stroke + bowlbottom.start-from RIGHTSB SMOOTH :.set-width 0 STROKE + :.cubic-to RIGHTSB [COBKAPPA * SMOOTH] [MIDDLE + BKAPPA * [RIGHTSB - MIDDLE]] O MIDDLE O + :.curve-to [MIDDLE - KAPPA_HOOK * [MIDDLE - para.sb]] O [SB * 1.1] HOOK + + put-shapes : bowltop.form-stroke + put-shapes : strokemiddle.form-stroke + put-shapes : bowlbottom.form-stroke +} +create-glyph 'dollar' : glyph-construction { + set-width WIDTH; assign-unicode '$' + put-shapes glyphs.S.contours + put-shapes : new Stroke :.start-from MIDDLE CAP :.set-width HALFSTROKE HALFSTROKE :.line-to MIDDLE [CAP - DESCENDER / 2] :.form-stroke + put-shapes : new Stroke :.start-from MIDDLE [DESCENDER / 2] :.set-width HALFSTROKE HALFSTROKE :.line-to MIDDLE 0 :.form-stroke +} +exports.font = font \ No newline at end of file diff --git a/generate.js b/generate.js new file mode 100644 index 0000000..484c1c1 --- /dev/null +++ b/generate.js @@ -0,0 +1,51 @@ +var fs = require('fs'); +var font = require('./font.js'); +var TTFWriter = require('node-sfnt').TTFWriter; +var TTF = require('node-sfnt').TTF; + +/** + * buffer转换成ArrayBuffer + * + * @param {Buffer} buffer 缓冲数组 + * @return {ArrayBuffer} + */ +function toArrayBuffer(buffer) { + var length = buffer.length; + var view = new DataView(new ArrayBuffer(length), 0, length); + for (var i = 0, l = length; i < l; i++) { + view.setUint8(i, buffer[i], false); + } + return view.buffer; +} + +/** + * ArrayBuffer转换成Buffer + * + * @param {ArrayBuffer} arrayBuffer 缓冲数组 + * @return {Buffer} + */ +function toBuffer(arrayBuffer) { + var length = arrayBuffer.byteLength; + var view = new DataView(arrayBuffer, 0, length); + var buffer = new Buffer(length); + for (var i = 0, l = length; i < l; i++) { + buffer[i] = view.getUint8(i, false); + } + return buffer; +} + +var options = {preserveOS2Version: true} + +function readttf(file) { + var data = fs.readFileSync(file); + var buffer = toArrayBuffer(data); + var ttf = (new OTFReader(options)).read(buffer); + return ttf; +} + +function writettf(ttf, file){ + var buffer = new TTFWriter(options).write(ttf); + fs.writeFileSync(file, toBuffer(buffer)); +} + +fs.writeFileSync(process.argv[2], toBuffer(new TTFWriter(options).write(font.font))); \ No newline at end of file diff --git a/intersection.js b/intersection.js new file mode 100644 index 0000000..9e407ab --- /dev/null +++ b/intersection.js @@ -0,0 +1,38 @@ +exports.intersection = function (line1StartX, line1StartY, line1EndX, line1EndY, line2StartX, line2StartY, line2EndX, line2EndY) { + // if the lines intersect, the result contains the x and y of the intersection (treating the lines as infinite) and booleans for whether line segment 1 or line segment 2 contain the point + var denominator, a, b, numerator1, numerator2, result = { + x: null, + y: null, + onLine1: false, + onLine2: false + }; + denominator = ((line2EndY - line2StartY) * (line1EndX - line1StartX)) - ((line2EndX - line2StartX) * (line1EndY - line1StartY)); + if (Math.abs(denominator) < 0.000000000001) { + return result; + } + a = line1StartY - line2StartY; + b = line1StartX - line2StartX; + numerator1 = ((line2EndX - line2StartX) * a) - ((line2EndY - line2StartY) * b); + numerator2 = ((line1EndX - line1StartX) * a) - ((line1EndY - line1StartY) * b); + a = numerator1 / denominator; + b = numerator2 / denominator; + + // if we cast these lines infinitely in both directions, they intersect here: + result.x = line1StartX + (a * (line1EndX - line1StartX)); + result.y = line1StartY + (a * (line1EndY - line1StartY)); +/* + // it is worth noting that this should be the same as: + x = line2StartX + (b * (line2EndX - line2StartX)); + y = line2StartX + (b * (line2EndY - line2StartY)); + */ + // if line1 is a segment and line2 is infinite, they intersect if: + if (a > 0 && a < 1) { + result.onLine1 = true; + } + // if line2 is a segment and line1 is infinite, they intersect if: + if (b > 0 && b < 1) { + result.onLine2 = true; + } + // if line1 and line2 are segments, they intersect if both of the above are true + return result; +}; diff --git a/makefile b/makefile new file mode 100644 index 0000000..f8073c8 --- /dev/null +++ b/makefile @@ -0,0 +1,8 @@ +JSFILES = font.js + +all : $(JSFILES) + +$(JSFILES) : + patel-c $< -o $@ + +font.js : font.patel \ No newline at end of file diff --git a/smooth.js b/smooth.js new file mode 100644 index 0000000..b63f32c --- /dev/null +++ b/smooth.js @@ -0,0 +1,411 @@ + +/* +Smooth.js version 0.1.7 + +Turn arrays into smooth functions. + +Copyright 2012 Spencer Cohen +Licensed under MIT license (see "Smooth.js MIT license.txt") +*/ + +/*Constants (these are accessible by Smooth.WHATEVER in user space) +*/ + +(function() { + var AbstractInterpolator, CubicInterpolator, Enum, LinearInterpolator, NearestInterpolator, PI, SincFilterInterpolator, Smooth, clipClamp, clipMirror, clipPeriodic, defaultConfig, getColumn, getType, isValidNumber, k, makeLanczosWindow, makeScaledFunction, makeSincKernel, normalizeScaleTo, shallowCopy, sin, sinc, v, validateNumber, validateVector, + __hasProp = Object.prototype.hasOwnProperty, + __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; }; + + Enum = { + /*Interpolation methods + */ + METHOD_NEAREST: 'nearest', + METHOD_LINEAR: 'linear', + METHOD_CUBIC: 'cubic', + METHOD_LANCZOS: 'lanczos', + METHOD_SINC: 'sinc', + /*Input clipping modes + */ + CLIP_CLAMP: 'clamp', + CLIP_ZERO: 'zero', + CLIP_PERIODIC: 'periodic', + CLIP_MIRROR: 'mirror', + /* Constants for control over the cubic interpolation tension + */ + CUBIC_TENSION_DEFAULT: 0, + CUBIC_TENSION_CATMULL_ROM: 0 + }; + + defaultConfig = { + method: Enum.METHOD_CUBIC, + cubicTension: Enum.CUBIC_TENSION_DEFAULT, + clip: Enum.CLIP_CLAMP, + scaleTo: 0, + sincFilterSize: 2, + sincWindow: void 0 + }; + + /*Index clipping functions + */ + + clipClamp = function(i, n) { + return Math.max(0, Math.min(i, n - 1)); + }; + + clipPeriodic = function(i, n) { + i = i % n; + if (i < 0) i += n; + return i; + }; + + clipMirror = function(i, n) { + var period; + period = 2 * (n - 1); + i = clipPeriodic(i, period); + if (i > n - 1) i = period - i; + return i; + }; + + /* + Abstract scalar interpolation class which provides common functionality for all interpolators + + Subclasses must override interpolate(). + */ + + AbstractInterpolator = (function() { + + function AbstractInterpolator(array, config) { + this.array = array.slice(0); + this.length = this.array.length; + if (!(this.clipHelper = { + clamp: this.clipHelperClamp, + zero: this.clipHelperZero, + periodic: this.clipHelperPeriodic, + mirror: this.clipHelperMirror + }[config.clip])) { + throw "Invalid clip: " + config.clip; + } + } + + AbstractInterpolator.prototype.getClippedInput = function(i) { + if ((0 <= i && i < this.length)) { + return this.array[i]; + } else { + return this.clipHelper(i); + } + }; + + AbstractInterpolator.prototype.clipHelperClamp = function(i) { + return this.array[clipClamp(i, this.length)]; + }; + + AbstractInterpolator.prototype.clipHelperZero = function(i) { + return 0; + }; + + AbstractInterpolator.prototype.clipHelperPeriodic = function(i) { + return this.array[clipPeriodic(i, this.length)]; + }; + + AbstractInterpolator.prototype.clipHelperMirror = function(i) { + return this.array[clipMirror(i, this.length)]; + }; + + AbstractInterpolator.prototype.interpolate = function(t) { + throw 'Subclasses of AbstractInterpolator must override the interpolate() method.'; + }; + + return AbstractInterpolator; + + })(); + + NearestInterpolator = (function(_super) { + + __extends(NearestInterpolator, _super); + + function NearestInterpolator() { + NearestInterpolator.__super__.constructor.apply(this, arguments); + } + + NearestInterpolator.prototype.interpolate = function(t) { + return this.getClippedInput(Math.round(t)); + }; + + return NearestInterpolator; + + })(AbstractInterpolator); + + LinearInterpolator = (function(_super) { + + __extends(LinearInterpolator, _super); + + function LinearInterpolator() { + LinearInterpolator.__super__.constructor.apply(this, arguments); + } + + LinearInterpolator.prototype.interpolate = function(t) { + var k; + k = Math.floor(t); + t -= k; + return (1 - t) * this.getClippedInput(k) + t * this.getClippedInput(k + 1); + }; + + return LinearInterpolator; + + })(AbstractInterpolator); + + CubicInterpolator = (function(_super) { + + __extends(CubicInterpolator, _super); + + function CubicInterpolator(array, config) { + this.tangentFactor = 1 - Math.max(0, Math.min(1, config.cubicTension)); + CubicInterpolator.__super__.constructor.apply(this, arguments); + } + + CubicInterpolator.prototype.getTangent = function(k) { + return this.tangentFactor * (this.getClippedInput(k + 1) - this.getClippedInput(k - 1)) / 2; + }; + + CubicInterpolator.prototype.interpolate = function(t) { + var k, m, p, t2, t3; + k = Math.floor(t); + m = [this.getTangent(k), this.getTangent(k + 1)]; + p = [this.getClippedInput(k), this.getClippedInput(k + 1)]; + t -= k; + t2 = t * t; + t3 = t * t2; + return (2 * t3 - 3 * t2 + 1) * p[0] + (t3 - 2 * t2 + t) * m[0] + (-2 * t3 + 3 * t2) * p[1] + (t3 - t2) * m[1]; + }; + + return CubicInterpolator; + + })(AbstractInterpolator); + + sin = Math.sin, PI = Math.PI; + + sinc = function(x) { + if (x === 0) { + return 1; + } else { + return sin(PI * x) / (PI * x); + } + }; + + makeLanczosWindow = function(a) { + return function(x) { + return sinc(x / a); + }; + }; + + makeSincKernel = function(window) { + return function(x) { + return sinc(x) * window(x); + }; + }; + + SincFilterInterpolator = (function(_super) { + + __extends(SincFilterInterpolator, _super); + + function SincFilterInterpolator(array, config) { + SincFilterInterpolator.__super__.constructor.apply(this, arguments); + this.a = config.sincFilterSize; + if (!config.sincWindow) throw 'No sincWindow provided'; + this.kernel = makeSincKernel(config.sincWindow); + } + + SincFilterInterpolator.prototype.interpolate = function(t) { + var k, n, sum, _ref, _ref2; + k = Math.floor(t); + sum = 0; + for (n = _ref = k - this.a + 1, _ref2 = k + this.a; _ref <= _ref2 ? n <= _ref2 : n >= _ref2; _ref <= _ref2 ? n++ : n--) { + sum += this.kernel(t - n) * this.getClippedInput(n); + } + return sum; + }; + + return SincFilterInterpolator; + + })(AbstractInterpolator); + + getColumn = function(arr, i) { + var row, _i, _len, _results; + _results = []; + for (_i = 0, _len = arr.length; _i < _len; _i++) { + row = arr[_i]; + _results.push(row[i]); + } + return _results; + }; + + makeScaledFunction = function(f, baseScale, scaleRange) { + var scaleFactor, translation; + if (scaleRange.join === '0,1') { + return f; + } else { + scaleFactor = baseScale / (scaleRange[1] - scaleRange[0]); + translation = scaleRange[0]; + return function(t) { + return f(scaleFactor * (t - translation)); + }; + } + }; + + getType = function(x) { + return Object.prototype.toString.call(x).slice('[object '.length, -1); + }; + + validateNumber = function(n) { + if (isNaN(n)) throw 'NaN in Smooth() input'; + if (getType(n) !== 'Number') throw 'Non-number in Smooth() input'; + if (!isFinite(n)) throw 'Infinity in Smooth() input'; + }; + + validateVector = function(v, dimension) { + var n, _i, _len; + if (getType(v) !== 'Array') throw 'Non-vector in Smooth() input'; + if (v.length !== dimension) throw 'Inconsistent dimension in Smooth() input'; + for (_i = 0, _len = v.length; _i < _len; _i++) { + n = v[_i]; + validateNumber(n); + } + }; + + isValidNumber = function(n) { + return (getType(n) === 'Number') && isFinite(n) && !isNaN(n); + }; + + normalizeScaleTo = function(s) { + var invalidErr; + invalidErr = "scaleTo param must be number or array of two numbers"; + switch (getType(s)) { + case 'Number': + if (!isValidNumber(s)) throw invalidErr; + s = [0, s]; + break; + case 'Array': + if (s.length !== 2) throw invalidErr; + if (!(isValidNumber(s[0]) && isValidNumber(s[1]))) throw invalidErr; + break; + default: + throw invalidErr; + } + return s; + }; + + shallowCopy = function(obj) { + var copy, k, v; + copy = {}; + for (k in obj) { + if (!__hasProp.call(obj, k)) continue; + v = obj[k]; + copy[k] = v; + } + return copy; + }; + + Smooth = function(arr, config) { + var baseDomainEnd, dimension, i, interpolator, interpolatorClass, interpolators, k, n, properties, smoothFunc, v; + if (config == null) config = {}; + properties = {}; + config = shallowCopy(config); + properties.config = shallowCopy(config); + if (config.scaleTo == null) config.scaleTo = config.period; + if (config.sincFilterSize == null) { + config.sincFilterSize = config.lanczosFilterSize; + } + for (k in defaultConfig) { + if (!__hasProp.call(defaultConfig, k)) continue; + v = defaultConfig[k]; + if (config[k] == null) config[k] = v; + } + if (!(interpolatorClass = { + nearest: NearestInterpolator, + linear: LinearInterpolator, + cubic: CubicInterpolator, + lanczos: SincFilterInterpolator, + sinc: SincFilterInterpolator + }[config.method])) { + throw "Invalid method: " + config.method; + } + if (config.method === 'lanczos') { + config.sincWindow = makeLanczosWindow(config.sincFilterSize); + } + if (arr.length < 2) throw 'Array must have at least two elements'; + properties.count = arr.length; + smoothFunc = (function() { + var _i, _j, _len, _len2; + switch (getType(arr[0])) { + case 'Number': + properties.dimension = 'scalar'; + if (Smooth.deepValidation) { + for (_i = 0, _len = arr.length; _i < _len; _i++) { + n = arr[_i]; + validateNumber(n); + } + } + interpolator = new interpolatorClass(arr, config); + return function(t) { + return interpolator.interpolate(t); + }; + case 'Array': + properties.dimension = dimension = arr[0].length; + if (!dimension) throw 'Vectors must be non-empty'; + if (Smooth.deepValidation) { + for (_j = 0, _len2 = arr.length; _j < _len2; _j++) { + v = arr[_j]; + validateVector(v, dimension); + } + } + interpolators = (function() { + var _results; + _results = []; + for (i = 0; 0 <= dimension ? i < dimension : i > dimension; 0 <= dimension ? i++ : i--) { + _results.push(new interpolatorClass(getColumn(arr, i), config)); + } + return _results; + })(); + return function(t) { + var interpolator, _k, _len3, _results; + _results = []; + for (_k = 0, _len3 = interpolators.length; _k < _len3; _k++) { + interpolator = interpolators[_k]; + _results.push(interpolator.interpolate(t)); + } + return _results; + }; + default: + throw "Invalid element type: " + (getType(arr[0])); + } + })(); + if (config.clip === 'periodic') { + baseDomainEnd = arr.length; + } else { + baseDomainEnd = arr.length - 1; + } + config.scaleTo || (config.scaleTo = baseDomainEnd); + properties.domain = normalizeScaleTo(config.scaleTo); + smoothFunc = makeScaledFunction(smoothFunc, baseDomainEnd, properties.domain); + properties.domain.sort(); + /*copy properties + */ + for (k in properties) { + if (!__hasProp.call(properties, k)) continue; + v = properties[k]; + smoothFunc[k] = v; + } + return smoothFunc; + }; + + for (k in Enum) { + if (!__hasProp.call(Enum, k)) continue; + v = Enum[k]; + Smooth[k] = v; + } + + Smooth.deepValidation = true; + + (typeof exports !== "undefined" && exports !== null ? exports : window).Smooth = Smooth; + +}).call(this); \ No newline at end of file