first commit

This commit is contained in:
Stefan Hacker
2026-04-03 09:38:48 +02:00
commit 37ad745546
47450 changed files with 3120798 additions and 0 deletions
@@ -0,0 +1,3 @@
import type { IFontStyles } from '../types/IFontStyles';
export declare const DefaultFontStyles: IFontStyles;
export declare function registerDefaultFontFaces(baseUrl: string): void;
+69
View File
@@ -0,0 +1,69 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DefaultFontStyles = void 0;
exports.registerDefaultFontFaces = registerDefaultFontFaces;
var merge_styles_1 = require("@fluentui/merge-styles");
var FluentFonts_1 = require("./FluentFonts");
var createFontStyles_1 = require("./createFontStyles");
var utilities_1 = require("@fluentui/utilities");
// Default urls.
var DefaultBaseUrl = 'https://res-1.cdn.office.net/files/fabric-cdn-prod_20230815.002/assets';
// Standard font styling.
exports.DefaultFontStyles = (0, createFontStyles_1.createFontStyles)((0, utilities_1.getLanguage)());
function _registerFontFace(fontFamily, url, fontWeight, localFontName) {
fontFamily = "'".concat(fontFamily, "'");
var localFontSrc = localFontName !== undefined ? "local('".concat(localFontName, "'),") : '';
(0, merge_styles_1.fontFace)({
fontFamily: fontFamily,
src: localFontSrc + "url('".concat(url, ".woff2') format('woff2'),") + "url('".concat(url, ".woff') format('woff')"),
fontWeight: fontWeight,
fontStyle: 'normal',
fontDisplay: 'swap',
});
}
function _registerFontFaceSet(baseUrl, fontFamily, cdnFolder, cdnFontName, localFontName) {
if (cdnFontName === void 0) { cdnFontName = 'segoeui'; }
var urlBase = "".concat(baseUrl, "/").concat(cdnFolder, "/").concat(cdnFontName);
_registerFontFace(fontFamily, urlBase + '-light', FluentFonts_1.FontWeights.light, localFontName && localFontName + ' Light');
_registerFontFace(fontFamily, urlBase + '-semilight', FluentFonts_1.FontWeights.semilight, localFontName && localFontName + ' SemiLight');
_registerFontFace(fontFamily, urlBase + '-regular', FluentFonts_1.FontWeights.regular, localFontName);
_registerFontFace(fontFamily, urlBase + '-semibold', FluentFonts_1.FontWeights.semibold, localFontName && localFontName + ' SemiBold');
_registerFontFace(fontFamily, urlBase + '-bold', FluentFonts_1.FontWeights.bold, localFontName && localFontName + ' Bold');
}
function registerDefaultFontFaces(baseUrl) {
if (baseUrl) {
var fontUrl = "".concat(baseUrl, "/fonts");
// Produce @font-face definitions for all supported web fonts.
_registerFontFaceSet(fontUrl, FluentFonts_1.LocalizedFontNames.Thai, 'leelawadeeui-thai', 'leelawadeeui');
_registerFontFaceSet(fontUrl, FluentFonts_1.LocalizedFontNames.Arabic, 'segoeui-arabic');
_registerFontFaceSet(fontUrl, FluentFonts_1.LocalizedFontNames.Cyrillic, 'segoeui-cyrillic');
_registerFontFaceSet(fontUrl, FluentFonts_1.LocalizedFontNames.EastEuropean, 'segoeui-easteuropean');
_registerFontFaceSet(fontUrl, FluentFonts_1.LocalizedFontNames.Greek, 'segoeui-greek');
_registerFontFaceSet(fontUrl, FluentFonts_1.LocalizedFontNames.Hebrew, 'segoeui-hebrew');
_registerFontFaceSet(fontUrl, FluentFonts_1.LocalizedFontNames.Vietnamese, 'segoeui-vietnamese');
_registerFontFaceSet(fontUrl, FluentFonts_1.LocalizedFontNames.WestEuropean, 'segoeui-westeuropean', 'segoeui', 'Segoe UI');
_registerFontFaceSet(fontUrl, FluentFonts_1.LocalizedFontFamilies.Selawik, 'selawik', 'selawik');
_registerFontFaceSet(fontUrl, FluentFonts_1.LocalizedFontNames.Armenian, 'segoeui-armenian');
_registerFontFaceSet(fontUrl, FluentFonts_1.LocalizedFontNames.Georgian, 'segoeui-georgian');
// Leelawadee UI (Thai) does not have a 'light' weight, so we override
// the font-face generated above to use the 'semilight' weight instead.
_registerFontFace('Leelawadee UI Web', "".concat(fontUrl, "/leelawadeeui-thai/leelawadeeui-semilight"), FluentFonts_1.FontWeights.light);
// Leelawadee UI (Thai) does not have a 'semibold' weight, so we override
// the font-face generated above to use the 'bold' weight instead.
_registerFontFace('Leelawadee UI Web', "".concat(fontUrl, "/leelawadeeui-thai/leelawadeeui-bold"), FluentFonts_1.FontWeights.semibold);
}
}
/**
* Reads the fontBaseUrl from window.FabricConfig.fontBaseUrl or falls back to a default.
*/
function _getFontBaseUrl() {
var _a, _b;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
var fabricConfig = (_a = (0, utilities_1.getWindow)()) === null || _a === void 0 ? void 0 : _a.FabricConfig;
return (_b = fabricConfig === null || fabricConfig === void 0 ? void 0 : fabricConfig.fontBaseUrl) !== null && _b !== void 0 ? _b : DefaultBaseUrl;
}
/**
* Register the font faces.
*/
registerDefaultFontFaces(_getFontBaseUrl());
//# sourceMappingURL=DefaultFontStyles.js.map
File diff suppressed because one or more lines are too long
+72
View File
@@ -0,0 +1,72 @@
import type { IFontWeight } from '@fluentui/merge-styles';
export declare namespace LocalizedFontNames {
const Arabic = "Segoe UI Web (Arabic)";
const Cyrillic = "Segoe UI Web (Cyrillic)";
const EastEuropean = "Segoe UI Web (East European)";
const Greek = "Segoe UI Web (Greek)";
const Hebrew = "Segoe UI Web (Hebrew)";
const Thai = "Leelawadee UI Web";
const Vietnamese = "Segoe UI Web (Vietnamese)";
const WestEuropean = "Segoe UI Web (West European)";
const Selawik = "Selawik Web";
const Armenian = "Segoe UI Web (Armenian)";
const Georgian = "Segoe UI Web (Georgian)";
}
export declare namespace LocalizedFontFamilies {
const Arabic = "'Segoe UI Web (Arabic)'";
const ChineseSimplified = "'Microsoft Yahei UI', Verdana, Simsun";
const ChineseTraditional = "'Microsoft Jhenghei UI', Pmingliu";
const Cyrillic = "'Segoe UI Web (Cyrillic)'";
const EastEuropean = "'Segoe UI Web (East European)'";
const Greek = "'Segoe UI Web (Greek)'";
const Hebrew = "'Segoe UI Web (Hebrew)'";
const Hindi = "'Nirmala UI'";
const Japanese = "'Yu Gothic UI', 'Meiryo UI', Meiryo, 'MS Pgothic', Osaka";
const Korean = "'Malgun Gothic', Gulim";
const Selawik = "'Selawik Web'";
const Thai = "'Leelawadee UI Web', 'Kmer UI'";
const Vietnamese = "'Segoe UI Web (Vietnamese)'";
const WestEuropean = "'Segoe UI Web (West European)'";
const Armenian = "'Segoe UI Web (Armenian)'";
const Georgian = "'Segoe UI Web (Georgian)'";
}
export declare namespace FontSizes {
const size10 = "10px";
const size12 = "12px";
const size14 = "14px";
const size16 = "16px";
const size18 = "18px";
const size20 = "20px";
const size24 = "24px";
const size28 = "28px";
const size32 = "32px";
const size42 = "42px";
const size68 = "68px";
const mini: string;
const xSmall: string;
const small: string;
const smallPlus: string;
const medium: string;
const mediumPlus: string;
const icon: string;
const large: string;
const xLarge: string;
const xLargePlus: string;
const xxLarge: string;
const xxLargePlus: string;
const superLarge: string;
const mega: string;
}
export declare namespace FontWeights {
const light: IFontWeight;
const semilight: IFontWeight;
const regular: IFontWeight;
const semibold: IFontWeight;
const bold: IFontWeight;
}
export declare namespace IconFontSizes {
const xSmall: string;
const small: string;
const medium: string;
const large: string;
}
+85
View File
@@ -0,0 +1,85 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.IconFontSizes = exports.FontWeights = exports.FontSizes = exports.LocalizedFontFamilies = exports.LocalizedFontNames = void 0;
// Font face names to be registered.
var LocalizedFontNames;
(function (LocalizedFontNames) {
LocalizedFontNames.Arabic = 'Segoe UI Web (Arabic)';
LocalizedFontNames.Cyrillic = 'Segoe UI Web (Cyrillic)';
LocalizedFontNames.EastEuropean = 'Segoe UI Web (East European)';
LocalizedFontNames.Greek = 'Segoe UI Web (Greek)';
LocalizedFontNames.Hebrew = 'Segoe UI Web (Hebrew)';
LocalizedFontNames.Thai = 'Leelawadee UI Web';
LocalizedFontNames.Vietnamese = 'Segoe UI Web (Vietnamese)';
LocalizedFontNames.WestEuropean = 'Segoe UI Web (West European)';
LocalizedFontNames.Selawik = 'Selawik Web';
LocalizedFontNames.Armenian = 'Segoe UI Web (Armenian)';
LocalizedFontNames.Georgian = 'Segoe UI Web (Georgian)';
})(LocalizedFontNames || (exports.LocalizedFontNames = LocalizedFontNames = {}));
// Font families with fallbacks, for the general regions.
var LocalizedFontFamilies;
(function (LocalizedFontFamilies) {
LocalizedFontFamilies.Arabic = "'".concat(LocalizedFontNames.Arabic, "'");
LocalizedFontFamilies.ChineseSimplified = "'Microsoft Yahei UI', Verdana, Simsun";
LocalizedFontFamilies.ChineseTraditional = "'Microsoft Jhenghei UI', Pmingliu";
LocalizedFontFamilies.Cyrillic = "'".concat(LocalizedFontNames.Cyrillic, "'");
LocalizedFontFamilies.EastEuropean = "'".concat(LocalizedFontNames.EastEuropean, "'");
LocalizedFontFamilies.Greek = "'".concat(LocalizedFontNames.Greek, "'");
LocalizedFontFamilies.Hebrew = "'".concat(LocalizedFontNames.Hebrew, "'");
LocalizedFontFamilies.Hindi = "'Nirmala UI'";
LocalizedFontFamilies.Japanese = "'Yu Gothic UI', 'Meiryo UI', Meiryo, 'MS Pgothic', Osaka";
LocalizedFontFamilies.Korean = "'Malgun Gothic', Gulim";
LocalizedFontFamilies.Selawik = "'".concat(LocalizedFontNames.Selawik, "'");
LocalizedFontFamilies.Thai = "'Leelawadee UI Web', 'Kmer UI'";
LocalizedFontFamilies.Vietnamese = "'".concat(LocalizedFontNames.Vietnamese, "'");
LocalizedFontFamilies.WestEuropean = "'".concat(LocalizedFontNames.WestEuropean, "'");
LocalizedFontFamilies.Armenian = "'".concat(LocalizedFontNames.Armenian, "'");
LocalizedFontFamilies.Georgian = "'".concat(LocalizedFontNames.Georgian, "'");
})(LocalizedFontFamilies || (exports.LocalizedFontFamilies = LocalizedFontFamilies = {}));
// Standard font sizes.
var FontSizes;
(function (FontSizes) {
FontSizes.size10 = '10px';
FontSizes.size12 = '12px';
FontSizes.size14 = '14px';
FontSizes.size16 = '16px';
FontSizes.size18 = '18px';
FontSizes.size20 = '20px';
FontSizes.size24 = '24px';
FontSizes.size28 = '28px';
FontSizes.size32 = '32px';
FontSizes.size42 = '42px';
FontSizes.size68 = '68px';
FontSizes.mini = '10px';
FontSizes.xSmall = '10px';
FontSizes.small = '12px';
FontSizes.smallPlus = '12px';
FontSizes.medium = '14px';
FontSizes.mediumPlus = '16px';
FontSizes.icon = '16px';
FontSizes.large = '18px';
FontSizes.xLarge = '20px';
FontSizes.xLargePlus = '24px';
FontSizes.xxLarge = '28px';
FontSizes.xxLargePlus = '32px';
FontSizes.superLarge = '42px';
FontSizes.mega = '68px';
})(FontSizes || (exports.FontSizes = FontSizes = {}));
// Standard font weights.
var FontWeights;
(function (FontWeights) {
FontWeights.light = 100;
FontWeights.semilight = 300;
FontWeights.regular = 400;
FontWeights.semibold = 600;
FontWeights.bold = 700;
})(FontWeights || (exports.FontWeights = FontWeights = {}));
// Standard Icon Sizes.
var IconFontSizes;
(function (IconFontSizes) {
IconFontSizes.xSmall = '10px';
IconFontSizes.small = '12px';
IconFontSizes.medium = '16px';
IconFontSizes.large = '20px';
})(IconFontSizes || (exports.IconFontSizes = IconFontSizes = {}));
//# sourceMappingURL=FluentFonts.js.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1,2 @@
import type { IFontStyles } from '../types/IFontStyles';
export declare function createFontStyles(localeCode: string | null): IFontStyles;
+84
View File
@@ -0,0 +1,84 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createFontStyles = createFontStyles;
var FluentFonts_1 = require("./FluentFonts");
// Fallback fonts, if specified system or web fonts are unavailable.
var FontFamilyFallbacks = "'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', sans-serif";
// By default, we favor system fonts for the default.
// All localized fonts use a web font and never use the system font.
var defaultFontFamily = "'Segoe UI', '".concat(FluentFonts_1.LocalizedFontNames.WestEuropean, "'");
// Mapping of language prefix to to font family.
var LanguageToFontMap = {
ar: FluentFonts_1.LocalizedFontFamilies.Arabic,
bg: FluentFonts_1.LocalizedFontFamilies.Cyrillic,
cs: FluentFonts_1.LocalizedFontFamilies.EastEuropean,
el: FluentFonts_1.LocalizedFontFamilies.Greek,
et: FluentFonts_1.LocalizedFontFamilies.EastEuropean,
he: FluentFonts_1.LocalizedFontFamilies.Hebrew,
hi: FluentFonts_1.LocalizedFontFamilies.Hindi,
hr: FluentFonts_1.LocalizedFontFamilies.EastEuropean,
hu: FluentFonts_1.LocalizedFontFamilies.EastEuropean,
ja: FluentFonts_1.LocalizedFontFamilies.Japanese,
kk: FluentFonts_1.LocalizedFontFamilies.EastEuropean,
ko: FluentFonts_1.LocalizedFontFamilies.Korean,
lt: FluentFonts_1.LocalizedFontFamilies.EastEuropean,
lv: FluentFonts_1.LocalizedFontFamilies.EastEuropean,
pl: FluentFonts_1.LocalizedFontFamilies.EastEuropean,
ru: FluentFonts_1.LocalizedFontFamilies.Cyrillic,
sk: FluentFonts_1.LocalizedFontFamilies.EastEuropean,
'sr-latn': FluentFonts_1.LocalizedFontFamilies.EastEuropean,
th: FluentFonts_1.LocalizedFontFamilies.Thai,
tr: FluentFonts_1.LocalizedFontFamilies.EastEuropean,
uk: FluentFonts_1.LocalizedFontFamilies.Cyrillic,
vi: FluentFonts_1.LocalizedFontFamilies.Vietnamese,
'zh-hans': FluentFonts_1.LocalizedFontFamilies.ChineseSimplified,
'zh-hant': FluentFonts_1.LocalizedFontFamilies.ChineseTraditional,
hy: FluentFonts_1.LocalizedFontFamilies.Armenian,
ka: FluentFonts_1.LocalizedFontFamilies.Georgian,
};
function _fontFamilyWithFallbacks(fontFamily) {
return "".concat(fontFamily, ", ").concat(FontFamilyFallbacks);
}
/**
* If there is a localized font for this language, return that.
* Returns undefined if there is no localized font for that language.
*/
function _getLocalizedFontFamily(language) {
for (var lang in LanguageToFontMap) {
if (LanguageToFontMap.hasOwnProperty(lang) && language && lang.indexOf(language) === 0) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return LanguageToFontMap[lang];
}
}
return defaultFontFamily;
}
function _createFont(size, weight, fontFamily) {
return {
fontFamily: fontFamily,
MozOsxFontSmoothing: 'grayscale',
WebkitFontSmoothing: 'antialiased',
fontSize: size,
fontWeight: weight,
};
}
function createFontStyles(localeCode) {
var localizedFont = _getLocalizedFontFamily(localeCode);
var fontFamilyWithFallback = _fontFamilyWithFallbacks(localizedFont);
var fontStyles = {
tiny: _createFont(FluentFonts_1.FontSizes.mini, FluentFonts_1.FontWeights.regular, fontFamilyWithFallback),
xSmall: _createFont(FluentFonts_1.FontSizes.xSmall, FluentFonts_1.FontWeights.regular, fontFamilyWithFallback),
small: _createFont(FluentFonts_1.FontSizes.small, FluentFonts_1.FontWeights.regular, fontFamilyWithFallback),
smallPlus: _createFont(FluentFonts_1.FontSizes.smallPlus, FluentFonts_1.FontWeights.regular, fontFamilyWithFallback),
medium: _createFont(FluentFonts_1.FontSizes.medium, FluentFonts_1.FontWeights.regular, fontFamilyWithFallback),
mediumPlus: _createFont(FluentFonts_1.FontSizes.mediumPlus, FluentFonts_1.FontWeights.regular, fontFamilyWithFallback),
large: _createFont(FluentFonts_1.FontSizes.large, FluentFonts_1.FontWeights.regular, fontFamilyWithFallback),
xLarge: _createFont(FluentFonts_1.FontSizes.xLarge, FluentFonts_1.FontWeights.semibold, fontFamilyWithFallback),
xLargePlus: _createFont(FluentFonts_1.FontSizes.xLargePlus, FluentFonts_1.FontWeights.semibold, fontFamilyWithFallback),
xxLarge: _createFont(FluentFonts_1.FontSizes.xxLarge, FluentFonts_1.FontWeights.semibold, fontFamilyWithFallback),
xxLargePlus: _createFont(FluentFonts_1.FontSizes.xxLargePlus, FluentFonts_1.FontWeights.semibold, fontFamilyWithFallback),
superLarge: _createFont(FluentFonts_1.FontSizes.superLarge, FluentFonts_1.FontWeights.semibold, fontFamilyWithFallback),
mega: _createFont(FluentFonts_1.FontSizes.mega, FluentFonts_1.FontWeights.semibold, fontFamilyWithFallback),
};
return fontStyles;
}
//# sourceMappingURL=createFontStyles.js.map
File diff suppressed because one or more lines are too long
+3
View File
@@ -0,0 +1,3 @@
export { FontSizes, FontWeights, IconFontSizes, LocalizedFontFamilies, LocalizedFontNames } from './FluentFonts';
export { createFontStyles } from './createFontStyles';
export { DefaultFontStyles, registerDefaultFontFaces } from './DefaultFontStyles';
+15
View File
@@ -0,0 +1,15 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.registerDefaultFontFaces = exports.DefaultFontStyles = exports.createFontStyles = exports.LocalizedFontNames = exports.LocalizedFontFamilies = exports.IconFontSizes = exports.FontWeights = exports.FontSizes = void 0;
var FluentFonts_1 = require("./FluentFonts");
Object.defineProperty(exports, "FontSizes", { enumerable: true, get: function () { return FluentFonts_1.FontSizes; } });
Object.defineProperty(exports, "FontWeights", { enumerable: true, get: function () { return FluentFonts_1.FontWeights; } });
Object.defineProperty(exports, "IconFontSizes", { enumerable: true, get: function () { return FluentFonts_1.IconFontSizes; } });
Object.defineProperty(exports, "LocalizedFontFamilies", { enumerable: true, get: function () { return FluentFonts_1.LocalizedFontFamilies; } });
Object.defineProperty(exports, "LocalizedFontNames", { enumerable: true, get: function () { return FluentFonts_1.LocalizedFontNames; } });
var createFontStyles_1 = require("./createFontStyles");
Object.defineProperty(exports, "createFontStyles", { enumerable: true, get: function () { return createFontStyles_1.createFontStyles; } });
var DefaultFontStyles_1 = require("./DefaultFontStyles");
Object.defineProperty(exports, "DefaultFontStyles", { enumerable: true, get: function () { return DefaultFontStyles_1.DefaultFontStyles; } });
Object.defineProperty(exports, "registerDefaultFontFaces", { enumerable: true, get: function () { return DefaultFontStyles_1.registerDefaultFontFaces; } });
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["fonts/index.ts"],"names":[],"mappings":";;;AAAA,6CAAiH;AAAxG,wGAAA,SAAS,OAAA;AAAE,0GAAA,WAAW,OAAA;AAAE,4GAAA,aAAa,OAAA;AAAE,oHAAA,qBAAqB,OAAA;AAAE,iHAAA,kBAAkB,OAAA;AACzF,uDAAsD;AAA7C,oHAAA,gBAAgB,OAAA;AACzB,yDAAkF;AAAzE,sHAAA,iBAAiB,OAAA;AAAE,6HAAA,wBAAwB,OAAA","sourcesContent":["export { FontSizes, FontWeights, IconFontSizes, LocalizedFontFamilies, LocalizedFontNames } from './FluentFonts';\nexport { createFontStyles } from './createFontStyles';\nexport { DefaultFontStyles, registerDefaultFontFaces } from './DefaultFontStyles';\n"]}