How to use the @sketch-hq/sketch-file-format-ts.FileFormat1.TextTransform function in @sketch-hq/sketch-file-format-ts

To help you get started, we’ve selected a few @sketch-hq/sketch-file-format-ts examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github airbnb / react-sketchapp / src / jsonUtils / textLayers.ts View on Github external
if (typeof json.textStyle.encodedAttributes.kerning !== 'undefined') {
      style.letterSpacing = json.textStyle.encodedAttributes.kerning;
    }

    const color = json.textStyle.encodedAttributes.MSAttributedStringColorAttribute;
    style.color = `#${Math.round(color.red * 255).toString(16)}${Math.round(
      color.green * 255,
    ).toString(16)}${Math.round(color.blue * 255).toString(16)}`;

    if (color.alpha !== 1) {
      style.color += `${Math.round(color.alpha * 255).toString(16)}`;
    }

    if (
      json.textStyle.encodedAttributes.MSAttributedStringTextTransformAttribute !==
      FileFormat.TextTransform.None
    ) {
      style.textTransform =
        json.textStyle.encodedAttributes.MSAttributedStringTextTransformAttribute ===
        FileFormat.TextTransform.Lowercase
          ? 'lowercase'
          : 'uppercase';
    }

    const font = json.textStyle.encodedAttributes.MSAttributedStringFontAttribute;

    style.fontSize = font.attributes.size;

    // we are cheating here, setting the name of the font instead of parsing
    // the family, weight and traits. react-sketchapp will handle it nevertheless
    style.fontFamily = font.attributes.name;
  }
github airbnb / react-sketchapp / src / jsonUtils / textLayers.ts View on Github external
justify: FileFormat.TextHorizontalAlignment.Justified,
};

const TEXT_ALIGN_REVERSE = {
  [FileFormat.TextHorizontalAlignment.Right]: 'right',
  [FileFormat.TextHorizontalAlignment.Centered]: 'center',
  [FileFormat.TextHorizontalAlignment.Justified]: 'justify',
};

export const TEXT_DECORATION_LINETHROUGH = {
  none: 0,
  'line-through': 1,
};

export const TEXT_TRANSFORM = {
  uppercase: FileFormat.TextTransform.Uppercase,
  lowercase: FileFormat.TextTransform.Lowercase,
  initial: FileFormat.TextTransform.None,
  inherit: FileFormat.TextTransform.None,
  none: FileFormat.TextTransform.None,
  capitalize: FileFormat.TextTransform.None,
};

// this borrows heavily from react-native's RCTFont class
// thanks y'all
// https://github.com/facebook/react-native/blob/master/React/Views/RCTFont.mm

export const FONT_STYLES = {
  normal: false,
  italic: true,
  oblique: true,
};