summaryrefslogtreecommitdiffstats
path: root/devtools/client/inspector/fonts/types.js
blob: f27625f7422c8974d6d18e802b1911dc9d1a0e1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

"use strict";

const PropTypes = require("resource://devtools/client/shared/vendor/react-prop-types.js");

/**
 * A font variation axis.
 */
const fontVariationAxis = (exports.fontVariationAxis = {
  // The OpenType tag name of the variation axis
  tag: PropTypes.string,

  // The axis name of the variation axis
  name: PropTypes.string,

  // The minimum value of the variation axis
  minValue: PropTypes.number,

  // The maximum value of the variation axis
  maxValue: PropTypes.number,

  // The default value of the variation axis
  defaultValue: PropTypes.number,
});

const fontVariationInstanceValue = (exports.fontVariationInstanceValue = {
  // The axis name of the variation axis
  axis: PropTypes.string,

  // The value of the variation axis
  value: PropTypes.number,
});

/**
 * A font variation instance.
 */
const fontVariationInstance = (exports.fontVariationInstance = {
  // The variation instance name of the font
  name: PropTypes.string,

  // The font variation values for the variation instance of the font
  values: PropTypes.arrayOf(PropTypes.shape(fontVariationInstanceValue)),
});

/**
 * A single font.
 */
const font = (exports.font = {
  // Font family name
  CSSFamilyName: PropTypes.string,

  // The format of the font
  format: PropTypes.string,

  // The name of the font
  name: PropTypes.string,

  // URL for the font preview
  previewUrl: PropTypes.string,

  // Object containing the CSS rule for the font
  rule: PropTypes.object,

  // The text of the CSS rule
  ruleText: PropTypes.string,

  // The URI of the font file
  URI: PropTypes.string,

  // The variation axes of the font
  variationAxes: PropTypes.arrayOf(PropTypes.shape(fontVariationAxis)),

  // The variation instances of the font
  variationInstances: PropTypes.arrayOf(PropTypes.shape(fontVariationInstance)),
});

exports.fontOptions = {
  // The current preview text
  previewText: PropTypes.string,
};

exports.fontEditor = {
  // Variable font axes and their values
  axes: PropTypes.object,

  // Axes values changed at runtime structured like the "values" property
  // of a fontVariationInstance
  customInstanceValues: PropTypes.array,

  // Fonts used on the selected element
  fonts: PropTypes.arrayOf(PropTypes.shape(font)),

  // Font variation instance currently selected
  instance: PropTypes.shape(fontVariationInstance),

  // CSS font properties defined on the element
  properties: PropTypes.object,
};

/**
 * Font data.
 */
exports.fontData = {
  // All fonts on the current page.
  allFonts: PropTypes.arrayOf(PropTypes.shape(font)),
};