fabric
Version:
Object model for HTML5 canvas, and SVG-to-canvas parser. Backed by jsdom and node-canvas.
1 lines • 4.12 kB
Source Map (JSON)
{"version":3,"file":"constants.mjs","names":[],"sources":["../../../../src/shapes/Text/constants.ts"],"sourcesContent":["import { FILL, LEFT, LTR, NORMAL, STROKE, reNewline } from '../../constants';\nimport type { TClassProperties } from '../../typedefs';\nimport type { FabricText } from './Text';\n\nexport const TEXT_DECORATION_THICKNESS = 'textDecorationThickness';\nexport const TEXT_DECORATION_COLOR = 'textDecorationColor';\n\nconst fontProperties = [\n 'fontSize',\n 'fontWeight',\n 'fontFamily',\n 'fontStyle',\n] as const;\n\nexport const textDecorationProperties = [\n 'underline',\n 'overline',\n 'linethrough',\n] as const;\n\nexport const textLayoutProperties: string[] = [\n ...fontProperties,\n 'lineHeight',\n 'text',\n 'charSpacing',\n 'textAlign',\n 'styles',\n 'path',\n 'pathStartOffset',\n 'pathSide',\n 'pathAlign',\n];\n\nexport const additionalProps = [\n ...textLayoutProperties,\n ...textDecorationProperties,\n 'textBackgroundColor',\n 'direction',\n TEXT_DECORATION_THICKNESS,\n TEXT_DECORATION_COLOR,\n] as const;\n\nexport type StylePropertiesType =\n | 'fill'\n | 'stroke'\n | 'strokeWidth'\n | 'fontSize'\n | 'fontFamily'\n | 'fontWeight'\n | 'fontStyle'\n | 'textBackgroundColor'\n | 'deltaY'\n | 'overline'\n | 'underline'\n | 'linethrough'\n | typeof TEXT_DECORATION_THICKNESS\n | typeof TEXT_DECORATION_COLOR;\n\nexport const styleProperties: Readonly<StylePropertiesType[]> = [\n ...fontProperties,\n ...textDecorationProperties,\n STROKE,\n 'strokeWidth',\n FILL,\n 'deltaY',\n 'textBackgroundColor',\n TEXT_DECORATION_THICKNESS,\n TEXT_DECORATION_COLOR,\n] as const;\n\n// @TODO: Many things here are configuration related and shouldn't be on the class nor prototype\n// regexes, list of properties that are not suppose to change by instances, magic consts.\n// this will be a separated effort\nexport const textDefaultValues: Partial<TClassProperties<FabricText>> = {\n _reNewline: reNewline,\n _reSpacesAndTabs: /[ \\t\\r]/g,\n _reSpaceAndTab: /[ \\t\\r]/,\n _reWords: /\\S+/g,\n fontSize: 40,\n fontWeight: NORMAL,\n fontFamily: 'Times New Roman',\n underline: false,\n overline: false,\n linethrough: false,\n textAlign: LEFT,\n fontStyle: NORMAL,\n lineHeight: 1.16,\n textBackgroundColor: '',\n stroke: null,\n shadow: null,\n path: undefined,\n pathStartOffset: 0,\n pathSide: LEFT,\n pathAlign: 'baseline',\n charSpacing: 0,\n deltaY: 0,\n direction: LTR,\n CACHE_FONT_SIZE: 400,\n MIN_TEXT_WIDTH: 2,\n // Text magic numbers\n superscript: {\n size: 0.6, // fontSize factor\n baseline: -0.35, // baseline-shift factor (upwards)\n },\n subscript: {\n size: 0.6, // fontSize factor\n baseline: 0.11, // baseline-shift factor (downwards)\n },\n _fontSizeFraction: 0.222,\n offsets: {\n underline: 0.1,\n linethrough: -0.28167, // added 1/30 to original number\n overline: -0.81333, // added 1/15 to original number\n },\n _fontSizeMult: 1.13,\n [TEXT_DECORATION_THICKNESS]: 66.667, // before implementation was 1/15\n};\n\nexport const JUSTIFY = 'justify';\nexport const JUSTIFY_LEFT = 'justify-left';\nexport const JUSTIFY_RIGHT = 'justify-right';\nexport const JUSTIFY_CENTER = 'justify-center';\n"],"mappings":";;AAIA,MAAa,4BAA4B;AACzC,MAAa,wBAAwB;AAErC,MAAM,iBAAiB;CACrB;CACA;CACA;CACA;CACD;AAED,MAAa,2BAA2B;CACtC;CACA;CACA;CACD;AAED,MAAa,uBAAiC;CAC5C,GAAG;CACH;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,MAAa,kBAAkB;CAC7B,GAAG;CACH,GAAG;CACH;CACA;CACA;CACA;CACD;AAkBD,MAAa,kBAAmD;CAC9D,GAAG;CACH,GAAG;CACH;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAKD,MAAa,oBAA2D;CACtE,YAAY;CACZ,kBAAkB;CAClB,gBAAgB;CAChB,UAAU;CACV,UAAU;CACV,YAAY;CACZ,YAAY;CACZ,WAAW;CACX,UAAU;CACV,aAAa;CACb,WAAW;CACX,WAAW;CACX,YAAY;CACZ,qBAAqB;CACrB,QAAQ;CACR,QAAQ;CACR,MAAM,KAAA;CACN,iBAAiB;CACjB,UAAU;CACV,WAAW;CACX,aAAa;CACb,QAAQ;CACR,WAAA;CACA,iBAAiB;CACjB,gBAAgB;CAEhB,aAAa;EACX,MAAM;EACN,UAAU;EACX;CACD,WAAW;EACT,MAAM;EACN,UAAU;EACX;CACD,mBAAmB;CACnB,SAAS;EACP,WAAW;EACX,aAAa;EACb,UAAU;EACX;CACD,eAAe;EACd,4BAA4B;CAC9B;AAED,MAAa,UAAU;AACvB,MAAa,eAAe;AAC5B,MAAa,gBAAgB;AAC7B,MAAa,iBAAiB"}