igniteui-angular-core
Version:
Ignite UI Angular Core logic used in multiple UI components.
146 lines (145 loc) • 4.85 kB
JavaScript
/*
THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE AGREEMENT ("AGREEMENT") LOCATED HERE:
https://www.infragistics.com/legal/license/igultimate-la
https://www.infragistics.com/legal/license/igultimate-eula
GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE: you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company.
*/
import { Base, markType } from "./type";
import { FontStringInfo } from "./FontStringInfo";
import { stringContains, stringReplace, stringStartsWith } from "./string";
import { tryParseNumber } from "./number";
/**
* @hidden
*/
export let FontStringUtil = /*@__PURE__*/ (() => {
class FontStringUtil extends Base {
static a(a) {
if (a == null) {
return null;
}
let b = new FontStringInfo();
a = a.trim();
if (FontStringUtil.b(a)) {
b.c = ((() => { let c = FontStringUtil.e(a); a = c.p0; return c.ret; })());
}
if (FontStringUtil.c(a)) {
b.d = ((() => { let c = FontStringUtil.f(a); a = c.p0; return c.ret; })());
}
b.a = ((() => { let c = FontStringUtil.d(a); a = c.p0; return c.ret; })());
b.b = a;
return b;
}
static d(a) {
let b = a.split(' ');
let c = b[0];
a = b[1];
if (stringContains(c, "rem")) {
let d = stringReplace(c, "rem", "");
let e = 0;
let f = tryParseNumber(d, e);
e = f.p1;
return {
ret: e * 16,
p0: a
};
}
if (stringContains(c, "px")) {
let g = stringReplace(c, "px", "");
let h = 0;
let i = tryParseNumber(g, h);
h = i.p1;
return {
ret: h,
p0: a
};
}
if (stringContains(c, "pt")) {
let j = stringReplace(c, "pt", "");
let k = 0;
let l = tryParseNumber(j, k);
k = l.p1;
return {
ret: k,
p0: a
};
}
return {
ret: NaN,
p0: a
};
}
static f(a) {
let b = a.toLowerCase();
if (stringStartsWith(b, "normal")) {
a = a.substr(("normal").length);
a = a.trim();
return {
ret: "normal",
p0: a
};
}
if (stringStartsWith(b, "bold")) {
a = a.substr(("bold").length);
a = a.trim();
return {
ret: "bold",
p0: a
};
}
return {
ret: null,
p0: a
};
}
static c(a) {
let b = a.toLowerCase();
if (stringStartsWith(b, "normal")) {
return true;
}
if (stringStartsWith(b, "italic")) {
return true;
}
return false;
}
static e(a) {
let b = a.toLowerCase();
if (stringStartsWith(b, "normal")) {
a = a.substr(("normal").length);
a = a.trim();
return {
ret: "normal",
p0: a
};
}
if (stringStartsWith(b, "italic")) {
a = a.substr(("italic").length);
a = a.trim();
return {
ret: "italic",
p0: a
};
}
if (stringStartsWith(b, "oblique")) {
a = a.substr(("oblique").length);
a = a.trim();
return {
ret: "oblique",
p0: a
};
}
return {
ret: null,
p0: a
};
}
static b(a) {
let b = a.toLowerCase();
if (stringStartsWith(b, "normal") || stringStartsWith(b, "italic") || stringStartsWith(b, "oblique")) {
return true;
}
return false;
}
}
FontStringUtil.$t = markType(FontStringUtil, 'FontStringUtil');
return FontStringUtil;
})();