Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Im-Madhur-Gupta
requested changes
Jan 13, 2026
1140fd5 to
c1289e0
Compare
Contributor
Author
|
The problem is that the font metrics weren't properly set. I used this Python script to fix the font files: from fontTools.ttLib import TTFont
import os
INPUT_FILENAME = 'app/britti-sans-variable.woff2'
OUTPUT_FILENAME = 'app/britti-sans-variable-fixed.woff2'
def get_max_bounds(font):
"""Scans every glyph to find the absolute highest and lowest points."""
# Start with the global values from the 'head' table
head = font['head']
ymax = head.yMax
ymin = head.yMin
# Check the 'glyf' table for precision (TrueType fonts)
if 'glyf' in font:
glyf_table = font['glyf']
# iterate over glyph names, not values directly
for glyph_name in glyf_table.keys():
glyph = glyf_table[glyph_name]
# Some glyphs (like space) might not have bounding boxes
if hasattr(glyph, 'yMax'):
if glyph.yMax > ymax: ymax = glyph.yMax
if hasattr(glyph, 'yMin'):
if glyph.yMin < ymin: ymin = glyph.yMin
return ymin, ymax
def patch_font(input_path, output_path):
print(f"Processing: {input_path}")
font = TTFont(input_path)
# Get exact bounding box
ymin, ymax = get_max_bounds(font)
print(f"Detected Bounding Box: Top={ymax}, Bottom={ymin}")
# 1. hhea Table (Mac/iOS/CSS primary)
hhea = font['hhea']
hhea.ascent = ymax
hhea.descent = ymin
hhea.lineGap = 0 # FORCE 0 GAP
# 2. OS/2 Table (Windows/Android)
os2 = font['OS/2']
# sTypo metrics (The 'ideal' layout)
os2.sTypoAscender = ymax
os2.sTypoDescender = ymin
os2.sTypoLineGap = 0 # FORCE 0 GAP
# usWin metrics (The 'clipping' zone)
os2.usWinAscent = ymax
os2.usWinDescent = abs(ymin) # Must be positive
# 3. FORCE "Use Typo Metrics"
# This bit (bit 7) tells browsers to respect sTypo values
os2.fsSelection |= 0b10000000
# Save
font.save(output_path)
print(f"Saved Fixed Font: {output_path}")
if __name__ == "__main__":
patch_font(INPUT_FILENAME, OUTPUT_FILENAME)How to run: cd frontend
pip install font-line fonttools brotli
python fix_font.py |
Camillebzd
approved these changes
Jan 14, 2026
…fo-icon-and-label
Im-Madhur-Gupta
approved these changes
Jan 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.