File size: 5,608 Bytes
9713441 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | export interface VietnameseFontSpec {
id: string;
family: string;
category: 'sans-serif' | 'display' | 'serif' | 'monospace';
weights: number[];
googleCssUrl: string;
recommendedLineHeightHeading: number;
recommendedLineHeightBody: number;
description: string;
}
export const VIETNAMESE_FONTS: VietnameseFontSpec[] = [
{
id: 'be-vietnam-pro',
family: 'Be Vietnam Pro',
category: 'sans-serif',
weights: [400, 500, 600, 700, 800],
googleCssUrl: 'https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:ital,wght@0,400;0,500;0,600;0,700;0,800;1,400&subset=vietnamese&display=block',
recommendedLineHeightHeading: 1.28,
recommendedLineHeightBody: 1.55,
description: 'Font thiết kế riêng cho Tiếng Việt — dấu thanh cân đối hoàn hảo cho cả tiêu đề & phụ đề',
},
{
id: 'plus-jakarta-sans',
family: 'Plus Jakarta Sans',
category: 'sans-serif',
weights: [400, 500, 600, 700, 800],
googleCssUrl: 'https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&subset=vietnamese&display=block',
recommendedLineHeightHeading: 1.26,
recommendedLineHeightBody: 1.55,
description: 'Phong cách SaaS & Công nghệ hiện đại, hình học sắc nét',
},
{
id: 'space-grotesk',
family: 'Space Grotesk',
category: 'display',
weights: [500, 600, 700],
googleCssUrl: 'https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&subset=vietnamese&display=block',
recommendedLineHeightHeading: 1.25,
recommendedLineHeightBody: 1.5,
description: 'Tiêu đề số liệu, biểu đồ, công nghệ & AI cực kỳ nổi bật',
},
{
id: 'inter',
family: 'Inter',
category: 'sans-serif',
weights: [400, 500, 600, 700, 800],
googleCssUrl: 'https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&subset=vietnamese&display=block',
recommendedLineHeightHeading: 1.25,
recommendedLineHeightBody: 1.55,
description: 'Chuẩn giao diện UI/UX trung tính, dễ đọc trên mọi kích thước màn hình',
},
{
id: 'montserrat',
family: 'Montserrat',
category: 'display',
weights: [600, 700, 800, 900],
googleCssUrl: 'https://fonts.googleapis.com/css2?family=Montserrat:wght@600;700;800;900&subset=vietnamese&display=block',
recommendedLineHeightHeading: 1.28,
recommendedLineHeightBody: 1.5,
description: 'Mạnh mẽ, dày dặn, cực hợp cho Hook TikTok/Reels và Poster quảng cáo',
},
{
id: 'playfair-display',
family: 'Playfair Display',
category: 'serif',
weights: [600, 700, 800],
googleCssUrl: 'https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,600;0,700;0,800;1,600&subset=vietnamese&display=block',
recommendedLineHeightHeading: 1.32,
recommendedLineHeightBody: 1.6,
description: 'Sang trọng, cổ điển (Editorial, Mỹ phẩm, Thời trang, Bất động sản cao cấp)',
},
{
id: 'jetbrains-mono',
family: 'JetBrains Mono',
category: 'monospace',
weights: [400, 600, 700],
googleCssUrl: 'https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;600;700&subset=vietnamese&display=block',
recommendedLineHeightHeading: 1.3,
recommendedLineHeightBody: 1.5,
description: 'Font lập trình, Terminal, thông số kỹ thuật & nhãn dữ liệu',
},
{
id: 'oswald',
family: 'Oswald',
category: 'display',
weights: [500, 600, 700],
googleCssUrl: 'https://fonts.googleapis.com/css2?family=Oswald:wght@500;600;700&subset=vietnamese&display=block',
recommendedLineHeightHeading: 1.28,
recommendedLineHeightBody: 1.45,
description: 'Chữ cao hẹp, tối ưu không gian cho màn hình dọc 9:16',
},
{
id: 'chakra-petch',
family: 'Chakra Petch',
category: 'display',
weights: [500, 600, 700],
googleCssUrl: 'https://fonts.googleapis.com/css2?family=Chakra+Petch:wght@500;600;700&subset=vietnamese&display=block',
recommendedLineHeightHeading: 1.26,
recommendedLineHeightBody: 1.5,
description: 'Phong cách Gaming, Cyberpunk, Phần cứng & Xe công nghệ',
},
];
export function getFontHeadLinksHtml(families: string[] = ['Be Vietnam Pro', 'Space Grotesk', 'JetBrains Mono']): string {
const normalized = new Set(families.map((f) => f.toLowerCase().trim()));
normalized.add('be vietnam pro');
const selected = VIETNAMESE_FONTS.filter((f) => normalized.has(f.family.toLowerCase()));
const links = selected
.map((f) => `<link rel="stylesheet" href="${f.googleCssUrl}" crossorigin="anonymous" />`)
.join('\n ');
return `<!-- Render-Safe Vietnamese Fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin="anonymous" />
${links}`;
}
export function getVietnameseTypographyGuardCss(headingFont = 'Space Grotesk', bodyFont = 'Be Vietnam Pro'): string {
return `
:root {
--font-heading: '${headingFont}', 'Be Vietnam Pro', system-ui, -apple-system, sans-serif;
--font-body: '${bodyFont}', 'Be Vietnam Pro', system-ui, -apple-system, sans-serif;
--font-mono: 'JetBrains Mono', monospace;
}
/* Guard Vietnamese Stacked Diacritics (Ấ, Ể, Ỗ, Ự) from clipping */
h1, h2, h3, .vn-heading {
font-family: var(--font-heading);
line-height: 1.28 !important;
padding-top: 0.06em;
padding-bottom: 0.06em;
overflow: visible;
}
body, p, span, div, .vn-body {
font-family: var(--font-body);
}
`.trim();
}
|