blob: ab2b91671a86990870effbe4e993dd1f01b15a6a [file] [log] [blame]
// Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
library fuchsia.fonts;
using Weight = uint16;
// Commonly used constants for font weight.
const Weight WEIGHT_THIN = 100;
const Weight WEIGHT_EXTRA_LIGHT = 200;
const Weight WEIGHT_LIGHT = 300;
const Weight WEIGHT_NORMAL = 400;
const Weight WEIGHT_MEDIUM = 500;
const Weight WEIGHT_SEMI_BOLD = 600;
const Weight WEIGHT_BOLD = 700;
const Weight WEIGHT_EXTRA_BOLD = 800;
const Weight WEIGHT_BLACK = 900;
/// The type of slant of a type face.
enum Slant {
/// The default; upright glyphs.
UPRIGHT = 1;
/// Specially designed, slanted and slightly calligraphic glyphs.
ITALIC = 2;
/// Skewed glyphs. Oblique usually means an geometric transformation of the upright variant,
/// rather than a custom-designed variant.
OBLIQUE = 3;
};
/// Horizontal width class of the glyphs.
///
/// See https://docs.microsoft.com/en-us/typography/opentype/spec/os2#uswidthclass.
enum Width {
/// 50% of normal width
ULTRA_CONDENSED = 1;
/// 62.5% of normal width
EXTRA_CONDENSED = 2;
/// 75% of normal width
CONDENSED = 3;
/// 87.5% of normal width
SEMI_CONDENSED = 4;
/// Normal width
NORMAL = 5;
/// 112.5% of normal width
SEMI_EXPANDED = 6;
/// 125% of normal width
EXPANDED = 7;
/// 150% of normal width
EXTRA_EXPANDED = 8;
/// 200% of normal width
ULTRA_EXPANDED = 9;
};
/// Default weight of a typeface when none is specified.
const Weight DEFAULT_WEIGHT = WEIGHT_NORMAL;
/// Default slant of a typeface when none is specified.
const Slant DEFAULT_SLANT = Slant.UPRIGHT;
/// Default width of a typeface when none is specified.
const Width DEFAULT_WIDTH = Width.NORMAL;
/// Style properties that can be used when requesting or describing a type face.
table Style2 {
/// See `Slant`.
1: Slant slant;
/// Weight or thickness of the glyphs. Allowed values are integers in the range [1, 1000], but
/// most real-world font families only support some integer multiples of 100:
/// {100, 200, ..., 900}. Normal text (`WEIGHT_NORMAL`) is 400; `WEIGHT_BOLD` is 700.
///
/// See:
/// https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight#Common_weight_name_mapping
/// https://docs.microsoft.com/en-us/typography/opentype/spec/os2#usweightclass
2: Weight weight;
/// See `Width`.
3: Width width;
};
/// Generic groups of font families that can serve as fallbacks for a specific family.
///
/// Every font family belongs to some _generic_ font family (see examples below).
///
/// If an exact requested family is unavailable but a fallback group is specified in the request,
/// the provider may return some other family that belongs to the fallback group. For example, if
/// the client requests the "Arial" family with a `SANS_SERIF` fallback, and "Arial" is unavailable,
/// the provider may return another available sans serif family, such as "Roboto Regular", instead.
///
/// See also:
/// https://www.w3.org/TR/css-fonts-4/#generic-font-families
enum GenericFontFamily {
/// Glyphs have little "serifs", hooks, or notches at the ends of most strokes.
/// Examples: Georgia, Noto Serif, Times New Roman.
SERIF = 1;
/// Glyphs that have no serifs at the ends of most strokes.
/// Examples: Arial, Noto Sans, Roboto, Tahoma.
SANS_SERIF = 2;
/// Fixed-width fonts.
/// Examples: Consolas, Courier New, Inconsolata.
MONOSPACE = 3;
/// Handwritten or cursive fonts.
/// Examples: Brush Script, Comic Sans, Lucida Calligraphy.
CURSIVE = 4;
/// Decorative fonts.
/// Examples: Impact, Papyrus.
FANTASY = 5;
/// The default user interface font on the target platform.
/// This is included for completeness with the CSS specification; font manifests should not
/// declare that a font belongs to the `SYSTEM_UI` generic family, but instead should declare a
/// more specific option (e.g. `SERIF` for Roboto).
///
/// Not commonly used.
SYSTEM_UI = 6;
/// Fonts that are used specifically for rendering emoji code points.
/// Examples: Noto Color Emoji.
EMOJI = 7;
/// Fonts that are used primarily for rendering mathematical expressions.
///
/// Not commonly used.
MATH = 8;
/// A group of Chinese fonts between serif and cursive, often used for official Chinese
/// Government documents.
///
/// Not commonly used.
FANGSONG = 9;
};