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 3 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 @@ -1253,6 +1253,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
29 changes: 25 additions & 4 deletions src/track/text-style.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,28 @@
*/
class TextStyle {

/**
* Defined set of font families
* @enum {Object.<string, string>}}
* @export
*/
static FontFamily: {[string]: string} = {
"ARIAL": "Arial",
"ROBOTO": "Roboto",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't expose Roboto and other custom non-system fonts in the enum.
Maybe Hillel can assist with the font choice but I would go with:
'sans-serif' and 'serif'
other than that, the custom skin can define his own custom fonts and add it to the font options.

"ARIAL_UNICODE_MS": "Arial Unicode Ms",
"HELVETICA": "Helvetica",
"VERDANA": "Verdana",
"PT_SANS_CAPTION": "PT Sans Caption",
"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 +48,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 +117,11 @@ class TextStyle {
*/
fontSize: string = '100%';

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

/**
* @type {TextStyle.StandardColors}
*/
Expand Down Expand Up @@ -138,6 +158,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