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
+3
View File
@@ -0,0 +1,3 @@
import type { IFontStyles } from '../types/IFontStyles';
export declare const DefaultFontStyles: IFontStyles;
export declare function registerDefaultFontFaces(baseUrl: string): void;
+65
View File
@@ -0,0 +1,65 @@
import { fontFace } from '@fluentui/merge-styles';
import { FontWeights, LocalizedFontFamilies, LocalizedFontNames } from './FluentFonts';
import { createFontStyles } from './createFontStyles';
import { getLanguage, getWindow } from '@fluentui/utilities';
// Default urls.
var DefaultBaseUrl = 'https://res-1.cdn.office.net/files/fabric-cdn-prod_20230815.002/assets';
// Standard font styling.
export var DefaultFontStyles = createFontStyles(getLanguage());
function _registerFontFace(fontFamily, url, fontWeight, localFontName) {
fontFamily = "'".concat(fontFamily, "'");
var localFontSrc = localFontName !== undefined ? "local('".concat(localFontName, "'),") : '';
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', FontWeights.light, localFontName && localFontName + ' Light');
_registerFontFace(fontFamily, urlBase + '-semilight', FontWeights.semilight, localFontName && localFontName + ' SemiLight');
_registerFontFace(fontFamily, urlBase + '-regular', FontWeights.regular, localFontName);
_registerFontFace(fontFamily, urlBase + '-semibold', FontWeights.semibold, localFontName && localFontName + ' SemiBold');
_registerFontFace(fontFamily, urlBase + '-bold', FontWeights.bold, localFontName && localFontName + ' Bold');
}
export function registerDefaultFontFaces(baseUrl) {
if (baseUrl) {
var fontUrl = "".concat(baseUrl, "/fonts");
// Produce @font-face definitions for all supported web fonts.
_registerFontFaceSet(fontUrl, LocalizedFontNames.Thai, 'leelawadeeui-thai', 'leelawadeeui');
_registerFontFaceSet(fontUrl, LocalizedFontNames.Arabic, 'segoeui-arabic');
_registerFontFaceSet(fontUrl, LocalizedFontNames.Cyrillic, 'segoeui-cyrillic');
_registerFontFaceSet(fontUrl, LocalizedFontNames.EastEuropean, 'segoeui-easteuropean');
_registerFontFaceSet(fontUrl, LocalizedFontNames.Greek, 'segoeui-greek');
_registerFontFaceSet(fontUrl, LocalizedFontNames.Hebrew, 'segoeui-hebrew');
_registerFontFaceSet(fontUrl, LocalizedFontNames.Vietnamese, 'segoeui-vietnamese');
_registerFontFaceSet(fontUrl, LocalizedFontNames.WestEuropean, 'segoeui-westeuropean', 'segoeui', 'Segoe UI');
_registerFontFaceSet(fontUrl, LocalizedFontFamilies.Selawik, 'selawik', 'selawik');
_registerFontFaceSet(fontUrl, LocalizedFontNames.Armenian, 'segoeui-armenian');
_registerFontFaceSet(fontUrl, 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"), 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"), 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 = 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;
}
+82
View File
@@ -0,0 +1,82 @@
// Font face names to be registered.
export 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 || (LocalizedFontNames = {}));
// Font families with fallbacks, for the general regions.
export 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 || (LocalizedFontFamilies = {}));
// Standard font sizes.
export 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 || (FontSizes = {}));
// Standard font weights.
export var FontWeights;
(function (FontWeights) {
FontWeights.light = 100;
FontWeights.semilight = 300;
FontWeights.regular = 400;
FontWeights.semibold = 600;
FontWeights.bold = 700;
})(FontWeights || (FontWeights = {}));
// Standard Icon Sizes.
export var IconFontSizes;
(function (IconFontSizes) {
IconFontSizes.xSmall = '10px';
IconFontSizes.small = '12px';
IconFontSizes.medium = '16px';
IconFontSizes.large = '20px';
})(IconFontSizes || (IconFontSizes = {}));
//# sourceMappingURL=FluentFonts.js.map
File diff suppressed because one or more lines are too long
+2
View File
@@ -0,0 +1,2 @@
import type { IFontStyles } from '../types/IFontStyles';
export declare function createFontStyles(localeCode: string | null): IFontStyles;
+81
View File
@@ -0,0 +1,81 @@
import { FontSizes, FontWeights, LocalizedFontFamilies, LocalizedFontNames } from './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(LocalizedFontNames.WestEuropean, "'");
// Mapping of language prefix to to font family.
var LanguageToFontMap = {
ar: LocalizedFontFamilies.Arabic,
bg: LocalizedFontFamilies.Cyrillic,
cs: LocalizedFontFamilies.EastEuropean,
el: LocalizedFontFamilies.Greek,
et: LocalizedFontFamilies.EastEuropean,
he: LocalizedFontFamilies.Hebrew,
hi: LocalizedFontFamilies.Hindi,
hr: LocalizedFontFamilies.EastEuropean,
hu: LocalizedFontFamilies.EastEuropean,
ja: LocalizedFontFamilies.Japanese,
kk: LocalizedFontFamilies.EastEuropean,
ko: LocalizedFontFamilies.Korean,
lt: LocalizedFontFamilies.EastEuropean,
lv: LocalizedFontFamilies.EastEuropean,
pl: LocalizedFontFamilies.EastEuropean,
ru: LocalizedFontFamilies.Cyrillic,
sk: LocalizedFontFamilies.EastEuropean,
'sr-latn': LocalizedFontFamilies.EastEuropean,
th: LocalizedFontFamilies.Thai,
tr: LocalizedFontFamilies.EastEuropean,
uk: LocalizedFontFamilies.Cyrillic,
vi: LocalizedFontFamilies.Vietnamese,
'zh-hans': LocalizedFontFamilies.ChineseSimplified,
'zh-hant': LocalizedFontFamilies.ChineseTraditional,
hy: LocalizedFontFamilies.Armenian,
ka: 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,
};
}
export function createFontStyles(localeCode) {
var localizedFont = _getLocalizedFontFamily(localeCode);
var fontFamilyWithFallback = _fontFamilyWithFallbacks(localizedFont);
var fontStyles = {
tiny: _createFont(FontSizes.mini, FontWeights.regular, fontFamilyWithFallback),
xSmall: _createFont(FontSizes.xSmall, FontWeights.regular, fontFamilyWithFallback),
small: _createFont(FontSizes.small, FontWeights.regular, fontFamilyWithFallback),
smallPlus: _createFont(FontSizes.smallPlus, FontWeights.regular, fontFamilyWithFallback),
medium: _createFont(FontSizes.medium, FontWeights.regular, fontFamilyWithFallback),
mediumPlus: _createFont(FontSizes.mediumPlus, FontWeights.regular, fontFamilyWithFallback),
large: _createFont(FontSizes.large, FontWeights.regular, fontFamilyWithFallback),
xLarge: _createFont(FontSizes.xLarge, FontWeights.semibold, fontFamilyWithFallback),
xLargePlus: _createFont(FontSizes.xLargePlus, FontWeights.semibold, fontFamilyWithFallback),
xxLarge: _createFont(FontSizes.xxLarge, FontWeights.semibold, fontFamilyWithFallback),
xxLargePlus: _createFont(FontSizes.xxLargePlus, FontWeights.semibold, fontFamilyWithFallback),
superLarge: _createFont(FontSizes.superLarge, FontWeights.semibold, fontFamilyWithFallback),
mega: _createFont(FontSizes.mega, 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';
+4
View File
@@ -0,0 +1,4 @@
export { FontSizes, FontWeights, IconFontSizes, LocalizedFontFamilies, LocalizedFontNames } from './FluentFonts';
export { createFontStyles } from './createFontStyles';
export { DefaultFontStyles, registerDefaultFontFaces } from './DefaultFontStyles';
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["fonts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,aAAa,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACjH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC","sourcesContent":["export { FontSizes, FontWeights, IconFontSizes, LocalizedFontFamilies, LocalizedFontNames } from './FluentFonts';\nexport { createFontStyles } from './createFontStyles';\nexport { DefaultFontStyles, registerDefaultFontFaces } from './DefaultFontStyles';\n"]}