PHP 8.2.30
Preview: font.js Size: 1.75 KB
//proc/thread-self/root/home/byroehnu/.trash/node_modules11/css-to-react-native/src/transforms/font.js

import parseFontFamily from './fontFamily'
import {
  regExpToken,
  SPACE,
  LENGTH,
  UNSUPPORTED_LENGTH_UNIT,
  SLASH,
} from '../tokenTypes'

const NORMAL = regExpToken(/^(normal)$/)
const STYLE = regExpToken(/^(italic)$/)
const WEIGHT = regExpToken(/^([1-9]00|bold)$/)
const VARIANT = regExpToken(/^(small-caps)$/)

const defaultFontStyle = 'normal'
const defaultFontWeight = 'normal'
const defaultFontVariant = []

export default tokenStream => {
  let fontStyle
  let fontWeight
  let fontVariant
  // let fontSize;
  let lineHeight
  // let fontFamily;

  let numStyleWeightVariantMatched = 0
  while (numStyleWeightVariantMatched < 3 && tokenStream.hasTokens()) {
    if (tokenStream.matches(NORMAL)) {
      /* pass */
    } else if (fontStyle === undefined && tokenStream.matches(STYLE)) {
      fontStyle = tokenStream.lastValue
    } else if (fontWeight === undefined && tokenStream.matches(WEIGHT)) {
      fontWeight = tokenStream.lastValue
    } else if (fontVariant === undefined && tokenStream.matches(VARIANT)) {
      fontVariant = [tokenStream.lastValue]
    } else {
      break
    }

    tokenStream.expect(SPACE)
    numStyleWeightVariantMatched += 1
  }

  const fontSize = tokenStream.expect(LENGTH, UNSUPPORTED_LENGTH_UNIT)

  if (tokenStream.matches(SLASH)) {
    lineHeight = tokenStream.expect(LENGTH, UNSUPPORTED_LENGTH_UNIT)
  }

  tokenStream.expect(SPACE)

  const { fontFamily } = parseFontFamily(tokenStream)

  if (fontStyle === undefined) fontStyle = defaultFontStyle
  if (fontWeight === undefined) fontWeight = defaultFontWeight
  if (fontVariant === undefined) fontVariant = defaultFontVariant

  const out = { fontStyle, fontWeight, fontVariant, fontSize, fontFamily }
  if (lineHeight !== undefined) out.lineHeight = lineHeight

  return out
}

Directory Contents

Dirs: 0 × Files: 15

Name Size Perms Modified Actions
268 B lrw-r--r-- 2026-02-28 00:26:54
Edit Download
1.35 KB lrw-r--r-- 2026-02-28 00:27:14
Edit Download
246 B lrw-r--r-- 2026-02-28 00:27:46
Edit Download
1.58 KB lrw-r--r-- 2026-02-28 00:28:08
Edit Download
983 B lrw-r--r-- 2026-02-28 00:28:18
Edit Download
1.75 KB lrw-r--r-- 2026-02-28 00:28:26
Edit Download
456 B lrw-r--r-- 2026-02-28 00:28:28
Edit Download
280 B lrw-r--r-- 2026-02-28 00:28:30
Edit Download
1.82 KB lrw-r--r-- 2026-02-28 00:28:38
Edit Download
609 B lrw-r--r-- 2026-02-28 00:28:42
Edit Download
1.45 KB lrw-r--r-- 2026-02-28 00:28:46
Edit Download
374 B lrw-r--r-- 2026-02-28 00:28:50
Edit Download
236 B lrw-r--r-- 2026-02-28 00:28:54
Edit Download
1.97 KB lrw-r--r-- 2026-02-28 00:28:58
Edit Download
2.29 KB lrw-r--r-- 2026-02-28 00:29:00
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).