Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add default text font family and expose ENUM #130

Merged
merged 8 commits into from
Oct 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -1266,6 +1266,15 @@ export default class Player extends FakeEventTarget {
return PlayerEvents;
}

/**
* Get the player TextStyle.
* @returns {TextStyle} - The TextStyle class
* @public
*/
get TextStyle(): typeof TextStyle {
return TextStyle;
}

/**
* Get the player states.
* @returns {Object} - The states of the player.
Expand Down
26 changes: 22 additions & 4 deletions src/track/text-style.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,25 @@
*/
class TextStyle {

/**
* Defined set of font families
* @enum {Object.<string, string>}}
* @export
*/
static FontFamily: {[string]: string} = {
"ARIAL": "Arial",
"HELVETICA": "Helvetica",
"VERDANA": "Verdana",
"SANS_SERIF": "sans-serif"
};

/**
* Defined in {@link https://goo.gl/ZcqOOM FCC 12-9}, paragraph 111, footnote
* 448. Each value is an array of the three RGB values for that color.
* @enum {!Array.<number>}
* @enum {Object.<string, Array.<number>>}}
* @export
*/
static StandardColors: Object = {
static StandardColors: {[string]: Array<number>} = {
'WHITE': [255, 255, 255],
'BLACK': [0, 0, 0],
'RED': [255, 0, 0],
Expand All @@ -33,10 +45,10 @@ class TextStyle {

/**
* Defined in {@link https://goo.gl/ZcqOOM FCC 12-9}, paragraph 111.
* @enum {number}
* @enum {Object.<string, number>}}
* @export
*/
static StandardOpacities: Object = {
static StandardOpacities: {[string]: number} = {
'OPAQUE': 1,
'SEMI_HIGH': 0.75,
'SEMI_LOW': 0.25,
Expand Down Expand Up @@ -102,6 +114,11 @@ class TextStyle {
*/
fontSize: string = '100%';

/**
* @type {TextStyle.FontFamily}
*/
fontFamily: string = TextStyle.FontFamily.SANS_SERIF;

/**
* @type {TextStyle.StandardColors}
*/
Expand Down Expand Up @@ -138,6 +155,7 @@ class TextStyle {
toCSS(): string {
let attributes: Array<string> = [];

attributes.push('font-family: ' + this.fontFamily);
attributes.push('font-size: ' + this.fontSize);
attributes.push('color: ' + TextStyle._toRGBA(this.fontColor, this.fontOpacity));
attributes.push('background-color: ' +
Expand Down