Font that can be used for validating baseline alignments. sajidanwar.com/misc/baseline-diagnostic-font/
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Initial commit of font build system

Sajid Anwar b9497cbd

+841
+9
.gitignore
··· 1 + # Python-generated files 2 + __pycache__/ 3 + *.py[oc] 4 + build/ 5 + wheels/ 6 + *.egg-info 7 + 8 + # Virtual environments 9 + .venv
+1
.python-version
··· 1 + 3.14
+7
LICENSE.md
··· 1 + Copyright 2026 Sajid Anwar 2 + 3 + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 + 5 + The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 + 7 + THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+20
README.md
··· 1 + # Baseline Diagnostic Font 2 + 3 + ## Overview 4 + 5 + Font that can be used for validating baseline alignments. This project contains 6 + the build system for the font using the [fonttools] Python library. 7 + 8 + ## Building 9 + 10 + This project uses [uv] for dependency management. Use `uv run` to build the font 11 + files into the `dist` folder. 12 + 13 + ## License 14 + 15 + This font contains [Noto Sans Mono][noto-sans-mono] glyphs in the rendering 16 + of its baseline labels. Like that font, this font is licensed under the 17 + [SIL Open Font License, Version 1.1][ofl-1.1], and is available at `LICENSE.txt`. 18 + 19 + [uv]: https://docs.astral.sh/uv/#highlights 20 + [fonttools]: https://fonttools.readthedocs.io/en/latest/
dist/BaselineDiagnostic.ttf

This is a binary file and will not be displayed.

dist/BaselineDiagnosticAlphabeticZero.ttf

This is a binary file and will not be displayed.

+108
dist/LICENSE.md
··· 1 + 2 + Copyright (c) 2026, Sajid Anwar. 3 + 4 + This Font Software is licensed under the SIL Open Font License, Version 1.1. 5 + This license is copied below, and is also available with a FAQ at: 6 + https\://openfontlicense.org 7 +   8 + 9 + \---------------------------------------------------------------------- 10 + 11 + #### SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 12 + 13 + \---------------------------------------------------------------------- 14 + 15 +   16 + 17 + PREAMBLE 18 + ----------- 19 + 20 + The goals of the Open Font License (OFL) are to stimulate worldwide 21 + development of collaborative font projects, to support the font creation 22 + efforts of academic and linguistic communities, and to provide a free and 23 + open framework in which fonts may be shared and improved in partnership 24 + with others. 25 + 26 + The OFL allows the licensed fonts to be used, studied, modified and 27 + redistributed freely as long as they are not sold by themselves. The 28 + fonts, including any derivative works, can be bundled, embedded, 29 + redistributed and/or sold with any software provided that any reserved 30 + names are not used by derivative works. The fonts and derivatives, 31 + however, cannot be released under any other type of license. The 32 + requirement for fonts to remain under this license does not apply 33 + to any document created using the fonts or their derivatives. 34 + 35 + DEFINITIONS 36 + ----------- 37 + 38 + "Font Software" refers to the set of files released by the Copyright 39 + Holder(s) under this license and clearly marked as such. This may 40 + include source files, build scripts and documentation. 41 + 42 + "Reserved Font Name" refers to any names specified as such after the 43 + copyright statement(s). 44 + 45 + "Original Version" refers to the collection of Font Software components as 46 + distributed by the Copyright Holder(s). 47 + 48 + "Modified Version" refers to any derivative made by adding to, deleting, 49 + or substituting -- in part or in whole -- any of the components of the 50 + Original Version, by changing formats or by porting the Font Software to a 51 + new environment. 52 + 53 + "Author" refers to any designer, engineer, programmer, technical 54 + writer or other person who contributed to the Font Software. 55 + 56 + PERMISSION & CONDITIONS 57 + ----------- 58 + 59 + Permission is hereby granted, free of charge, to any person obtaining 60 + a copy of the Font Software, to use, study, copy, merge, embed, modify, 61 + redistribute, and sell modified and unmodified copies of the Font 62 + Software, subject to the following conditions: 63 + 64 + 1) Neither the Font Software nor any of its individual components, 65 + in Original or Modified Versions, may be sold by itself. 66 + 67 + 2) Original or Modified Versions of the Font Software may be bundled, 68 + redistributed and/or sold with any software, provided that each copy 69 + contains the above copyright notice and this license. These can be 70 + included either as stand-alone text files, human-readable headers or 71 + in the appropriate machine-readable metadata fields within text or 72 + binary files as long as those fields can be easily viewed by the user. 73 + 74 + 3) No Modified Version of the Font Software may use the Reserved Font 75 + Name(s) unless explicit written permission is granted by the corresponding 76 + Copyright Holder. This restriction only applies to the primary font name as 77 + presented to the users. 78 + 79 + 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font 80 + Software shall not be used to promote, endorse or advertise any 81 + Modified Version, except to acknowledge the contribution(s) of the 82 + Copyright Holder(s) and the Author(s) or with their explicit written 83 + permission. 84 + 85 + 5) The Font Software, modified or unmodified, in part or in whole, 86 + must be distributed entirely under this license, and must not be 87 + distributed under any other license. The requirement for fonts to 88 + remain under this license does not apply to any document created 89 + using the Font Software. 90 + 91 + TERMINATION 92 + ----------- 93 + 94 + This license becomes null and void if any of the above conditions are 95 + not met. 96 + 97 + DISCLAIMER 98 + ----------- 99 + 100 + THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 101 + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF 102 + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 103 + OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE 104 + COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 105 + INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL 106 + DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 107 + FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM 108 + OTHER DEALINGS IN THE FONT SOFTWARE.
+42
dist/README.md
··· 1 + 2 + # Baseline Diagnostic Font 3 + 4 + ## Overview 5 + 6 + Font that can be used for validating baseline alignments. Given the embedded 7 + text in the font, this should be used with very large font sizes. There are 8 + two glyphs in the font: 9 + 10 + - `X` (U+0058) which has all baselines drawn 11 + - `.notdef` (for all other characters) which is an empty box 12 + 13 + It has the following baselines: 14 + 15 + | Baseline/Metric | Value | BASE Value | OS/2 Value | hhea Value | 16 + |-------------------|-------|------------|----------------|------------| 17 + | ascent | 800 | | sTypoAscender | ascent | 18 + | ideographic-over | 750 | Idtp | | | 19 + | hanging | 650 | hang | | | 20 + | cap-height | 550 | | sCapHeight | | 21 + | math | 450 | math | | | 22 + | /central/ | 350 | | | | 23 + | /em-middle/ | 300 | | | | 24 + | x-height | 250 | | sxHeight | | 25 + | /x-middle/ | 150 | | | | 26 + | alphabetic | 50 | romn | | | 27 + | /zero/ | | | | | 28 + | ideographic-under | -50 | ideo | | | 29 + | descent | -200 | | sTypoDescender | descent | 30 + 31 + The `BaselineDiagnosticAlphabeticZero` variant is the same as `Baseline`, 32 + except the alphabetic baseline is at the common value of 0. This also 33 + results in the x-middle baseline being at 125. 34 + 35 + ## License 36 + 37 + This font contains [Noto Sans Mono][noto-sans-mono] glyphs in the rendering 38 + of its baseline labels. Like that font, this font is licensed under the 39 + [SIL Open Font License, Version 1.1][ofl-1.1], and is available at `LICENSE.txt`. 40 + 41 + [noto-sans-mono]: https://fonts.google.com/noto/specimen/Noto+Sans+Mono/license 42 + [ofl-1.1]: https://openfontlicense.org/open-font-license-official-text/
+19
dist/baseline-diagnostic-font.css
··· 1 + 2 + @font-face { 3 + /** 4 + * Font that can be used for validating baseline alignments. Given the embedded 5 + * text in the font, this should be used with very large font sizes. There are 6 + * two glyphs in the font. 7 + */ 8 + font-family: "BaselineDiagnostic"; 9 + src: url('./BaselineDiagnostic.ttf') format('opentype'); 10 + } 11 + 12 + @font-face { 13 + /** 14 + * Same as the "BaselineDiagnostic" font, but uses the common alphabetic baseline 15 + * of 0. This also results in the x-middle baseline being at 125. 16 + */ 17 + font-family: "BaselineDiagnostic"; 18 + src: url('./BaselineDiagnosticAlphabeticZero.ttf') format('opentype'); 19 + }
+248
font.py
··· 1 + import os 2 + from dataclasses import dataclass 3 + from typing import List, Literal, Union 4 + 5 + from fontTools.fontBuilder import FontBuilder 6 + from fontTools.pens.transformPen import TransformPen 7 + from fontTools.pens.ttGlyphPen import TTGlyphPen 8 + from fontTools.ttLib import TTFont, getTableClass, newTable 9 + from fontTools.ttLib.tables import otTables 10 + 11 + EM_ASCENT = 800 12 + EM_DESCENT = 200 13 + EM_SIZE = EM_ASCENT + EM_DESCENT 14 + BORDER_WIDTH = 12 15 + 16 + 17 + @dataclass 18 + class FontBaselineStyle: 19 + stroke_style: str 20 + stroke_width: int 21 + 22 + 23 + FontBaselineStyle.SOLID = FontBaselineStyle("solid", 12) 24 + FontBaselineStyle.DASHED = FontBaselineStyle("dashed", 8) 25 + 26 + 27 + @dataclass 28 + class FontBaseline: 29 + type: Union[Literal["BASE", "OS/2", "hhea"], None] 30 + name: str 31 + label: str 32 + position: int 33 + style: FontBaselineStyle 34 + 35 + 36 + @dataclass 37 + class Rect: 38 + x: int 39 + y: int 40 + width: int 41 + height: int 42 + 43 + 44 + @dataclass 45 + class GlyphMetrics: 46 + glyph: any 47 + width: float 48 + 49 + 50 + @dataclass 51 + class TextMetrics: 52 + scale: float 53 + letter_gap: float 54 + glyphs: List[GlyphMetrics] 55 + 56 + def width(self) -> float: 57 + if len(self.glyphs) == 0: 58 + return 0 59 + return sum(g.width for g in self.glyphs) + ( 60 + self.letter_gap * (len(self.glyphs) - 1) 61 + ) 62 + 63 + 64 + def measure_text(font, text: str, letter_gap=0.0) -> TextMetrics: 65 + font_head = font["head"] 66 + font_horizontal_metrics = font["hmtx"] 67 + em_units = font_head.unitsPerEm 68 + 69 + glyphs: List[GlyphMetrics] = [] 70 + for char in text: 71 + glyph_name = font.getBestCmap()[ord(char)] 72 + glyph_set = font.getGlyphSet() 73 + glyph = glyph_set[glyph_name] 74 + glyphs.append( 75 + GlyphMetrics(glyph, font_horizontal_metrics[glyph_name][0] / em_units) 76 + ) 77 + 78 + return TextMetrics(scale=1.0 / em_units, letter_gap=letter_gap, glyphs=glyphs) 79 + 80 + 81 + def draw_text_centered( 82 + pen, font, text, x, y, font_size=50, scale_y=1.0, letter_gap=0.0, offset_y=-0.1 83 + ) -> Rect: 84 + text_metrics = measure_text(font, text, letter_gap) 85 + height = font_size * scale_y 86 + width = text_metrics.width() * font_size 87 + 88 + x_pos = x - width / 2 89 + y_pos = y - height / 2 90 + 91 + for glyph in text_metrics.glyphs: 92 + transform_pen = TransformPen( 93 + pen, 94 + ( 95 + font_size * text_metrics.scale, 96 + 0, 97 + 0, 98 + font_size * scale_y * text_metrics.scale, 99 + x_pos, 100 + y_pos - height * offset_y, 101 + ), 102 + ) 103 + glyph.glyph.draw(transform_pen) 104 + x_pos += font_size * (glyph.width + letter_gap) 105 + 106 + return Rect(x=(x - width / 2), y=(y - height / 2), width=width, height=height) 107 + 108 + 109 + def draw_rectangle(pen, x1, y1, x2, y2): 110 + pen.moveTo((x1, y1)) 111 + pen.lineTo((x2, y1)) 112 + pen.lineTo((x2, y2)) 113 + pen.lineTo((x1, y2)) 114 + pen.closePath() 115 + 116 + 117 + def draw_bordered_rectangle(pen, x1, y1, x2, y2, stroke_width=12): 118 + # Draw a rectangle for each edge 119 + draw_rectangle(pen, x1, y1, x2, y1 + stroke_width) 120 + draw_rectangle(pen, x1, y2 - stroke_width, x2, y2) 121 + draw_rectangle(pen, x1, y1 + stroke_width, x1 + stroke_width, y2 - stroke_width) 122 + draw_rectangle(pen, x2 - stroke_width, y1 + stroke_width, x2, y2 - stroke_width) 123 + 124 + 125 + def draw_dashed_line(pen, y, start, end, stroke_width=4, dash_width=12, gap=6): 126 + for x in range(round(start), round(end), dash_width + gap): 127 + draw_solid_line(pen, y, x, x + dash_width, stroke_width) 128 + 129 + 130 + def draw_solid_line(pen, y, start, end, stroke_width=4): 131 + draw_rectangle(pen, start, y - stroke_width / 2, end, y + stroke_width / 2) 132 + 133 + 134 + def draw_line(pen, y, start, end, style="solid", stroke_width=8): 135 + if style == "solid": 136 + draw_solid_line(pen, y, start, end, stroke_width=stroke_width) 137 + elif style == "dashed": 138 + draw_dashed_line(pen, y, start, end, stroke_width=stroke_width) 139 + 140 + 141 + def draw_baseline(pen, font, y, label, style="solid", stroke_width=8): 142 + if label: 143 + drawn_text = draw_text_centered( 144 + pen, font, label, EM_SIZE / 2, y, font_size=50, scale_y=1, letter_gap=0 145 + ) 146 + draw_line( 147 + pen, 148 + style=style, 149 + stroke_width=stroke_width, 150 + y=y, 151 + start=BORDER_WIDTH, 152 + end=drawn_text.x - BORDER_WIDTH, 153 + ) 154 + draw_line( 155 + pen, 156 + style=style, 157 + stroke_width=stroke_width, 158 + y=y, 159 + start=drawn_text.x + drawn_text.width + BORDER_WIDTH, 160 + end=EM_SIZE - BORDER_WIDTH, 161 + ) 162 + else: 163 + draw_line( 164 + pen, 165 + style=style, 166 + stroke_width=stroke_width, 167 + y=y, 168 + start=BORDER_WIDTH, 169 + end=EM_SIZE - BORDER_WIDTH, 170 + ) 171 + 172 + 173 + def build_baselines_font(font_name: str, out_path: str, baselines: List[FontBaseline]): 174 + empty_glyph_pen = TTGlyphPen(None) 175 + draw_bordered_rectangle(empty_glyph_pen, 0, -EM_DESCENT, EM_SIZE, EM_ASCENT, BORDER_WIDTH) 176 + 177 + diag_glyph_pen = TTGlyphPen(None) 178 + draw_bordered_rectangle(diag_glyph_pen, 0, -EM_DESCENT, EM_SIZE, EM_ASCENT, BORDER_WIDTH) 179 + label_font = TTFont("./support/noto/NotoSansMono-Bold.ttf") 180 + for baseline in baselines: 181 + if baseline.style: 182 + draw_baseline( 183 + diag_glyph_pen, 184 + label_font, 185 + baseline.position, 186 + baseline.label, 187 + style=baseline.style.stroke_style, 188 + stroke_width=baseline.style.stroke_width, 189 + ) 190 + 191 + fb = FontBuilder(EM_SIZE, isTTF=True) 192 + fb.setupGlyphOrder([".notdef", "X"]) 193 + fb.setupCharacterMap({ ord("X"): "X" }) 194 + fb.setupGlyf({ 195 + ".notdef": empty_glyph_pen.glyph(), 196 + "X": diag_glyph_pen.glyph() 197 + }) 198 + 199 + os2_values = dict((base.name, base.position) for base in baselines if base.type == "OS/2") 200 + hhea_values = dict((base.name, base.position) for base in baselines if base.type == "hhea") 201 + 202 + style_name = "Regular" 203 + fb.setupPost() 204 + fb.setupNameTable({ 205 + "copyright": "Copyright (c) 2026, Sajid Anwar", 206 + "familyName": font_name, 207 + "styleName": style_name, 208 + "uniqueFontIdentifier": f"{font_name}-{style_name}", 209 + "fullName": f"{font_name}-{style_name}", 210 + "psName": f"{font_name}-{style_name}", 211 + "version": "Version 1.0", 212 + }) 213 + fb.setupHorizontalMetrics({".notdef": (EM_SIZE, 0), "X": (EM_SIZE, 0)}) 214 + fb.setupOS2(**os2_values) 215 + fb.setupHorizontalHeader(**hhea_values) 216 + fb.setupHead(unitsPerEm=EM_SIZE) 217 + 218 + font = fb.font 219 + bases = list(sorted(filter(lambda base: base.type == "BASE", baselines), key=lambda base: base.name)) 220 + base_names = list(base.name for base in bases) 221 + 222 + base_table = otTables.BASE() 223 + base_table.Version = 0x00010000 224 + base_table.HorizAxis = otTables.Axis() 225 + base_table.HorizAxis.BaseTagList = otTables.BaseTagList() 226 + base_table.HorizAxis.BaseTagList.BaselineTag = base_names 227 + base_table.HorizAxis.BaseScriptList = otTables.BaseScriptList() 228 + 229 + base_coords = [] 230 + for base in bases: 231 + base_coord = otTables.BaseCoord() 232 + base_coord.Coordinate = base.position 233 + base_coord.Format = 1 234 + base_coords.append(base_coord) 235 + 236 + base_script = otTables.BaseScriptRecord() 237 + base_script.BaseScriptTag = "DFLT" 238 + base_script.BaseScript = otTables.BaseScript() 239 + base_script.BaseScript.BaseValues = otTables.BaseValues() 240 + base_script.BaseScript.BaseValues.DefaultIndex = base_names.index("romn") 241 + base_script.BaseScript.BaseValues.BaseCoord = base_coords 242 + base_table.HorizAxis.BaseScriptList.BaseScriptRecord = [base_script] 243 + font["BASE"] = newTable("BASE") 244 + font["BASE"].table = base_table 245 + 246 + os.makedirs(os.path.dirname(out_path), exist_ok=True) 247 + fb.save(out_path) 248 + print(f"Created font at {out_path}")
+246
main.py
··· 1 + from font import FontBaseline, FontBaselineStyle, build_baselines_font 2 + from textwrap import dedent 3 + 4 + def main(): 5 + build_baselines_font( 6 + "BaselineDiagnostic", 7 + "dist/BaselineDiagnostic.ttf", 8 + [ 9 + FontBaseline("OS/2", "sTypoAscender", None, 800, None), 10 + FontBaseline("hhea", "ascent", None, 800, None), 11 + FontBaseline("BASE", "Idtp", "IDEOGRAPHIC-OVER", 750, FontBaselineStyle.SOLID), 12 + FontBaseline("BASE", "hang", "HANGING", 650, FontBaselineStyle.SOLID), 13 + FontBaseline("OS/2", "sCapHeight", "CAP-HEIGHT", 550, FontBaselineStyle.SOLID), 14 + FontBaseline("BASE", "math", "MATH", 450, FontBaselineStyle.SOLID), 15 + FontBaseline(None, None, "CENTRAL", 350, FontBaselineStyle.SOLID), 16 + FontBaseline(None, None, None, 300, FontBaselineStyle.DASHED), 17 + FontBaseline("OS/2", "sxHeight", "X-HEIGHT", 250, FontBaselineStyle.SOLID), 18 + FontBaseline(None, None, "X-MIDDLE", 150, FontBaselineStyle.SOLID), 19 + FontBaseline("BASE", "romn", "ALPHABETIC", 50, FontBaselineStyle.SOLID), 20 + FontBaseline(None, None, None, 0, FontBaselineStyle.DASHED), 21 + FontBaseline("BASE", "ideo", "IDEOGRAPHIC-UNDER", -50, FontBaselineStyle.SOLID), 22 + FontBaseline("OS/2", "sTypoDescender", None, -200, None), 23 + FontBaseline("hhea", "descent", None, -200, None), 24 + ] 25 + ) 26 + 27 + # Same as the "BaselineDiagnostic" font, but uses the common alphabetic 28 + # baseline of 0. This also results in the x-middle baseline being at 125. 29 + 30 + build_baselines_font( 31 + "BaselineDiagnosticAlphabeticZero", 32 + "dist/BaselineDiagnosticAlphabeticZero.ttf", 33 + [ 34 + FontBaseline("OS/2", "sTypoAscender", None, 800, None), 35 + FontBaseline("hhea", "ascent", None, 800, None), 36 + FontBaseline("BASE", "Idtp", "IDEOGRAPHIC-OVER", 750, FontBaselineStyle.SOLID), 37 + FontBaseline("BASE", "hang", "HANGING", 650, FontBaselineStyle.SOLID), 38 + FontBaseline("OS/2", "sCapHeight", "CAP-HEIGHT", 550, FontBaselineStyle.SOLID), 39 + FontBaseline("BASE", "math", "MATH", 450, FontBaselineStyle.SOLID), 40 + FontBaseline(None, None, "CENTRAL", 350, FontBaselineStyle.SOLID), 41 + FontBaseline(None, None, None, 300, FontBaselineStyle.DASHED), 42 + FontBaseline("OS/2", "sxHeight", "X-HEIGHT", 250, FontBaselineStyle.SOLID), 43 + FontBaseline(None, None, "X-MIDDLE", 125, FontBaselineStyle.SOLID), 44 + FontBaseline("BASE", "romn", None, 0, FontBaselineStyle.DASHED), 45 + FontBaseline("BASE", "ideo", "IDEOGRAPHIC-UNDER", -50, FontBaselineStyle.SOLID), 46 + FontBaseline("OS/2", "sTypoDescender", None, -200, None), 47 + FontBaseline("hhea", "descent", None, -200, None), 48 + ] 49 + ) 50 + 51 + write_font_stylesheet() 52 + write_font_readme() 53 + write_font_license() 54 + 55 + 56 + def write_font_stylesheet(): 57 + out_path = "dist/baseline-diagnostic-font.css" 58 + with open(out_path, "w") as f: 59 + f.write(dedent(r''' 60 + @font-face { 61 + /** 62 + * Font that can be used for validating baseline alignments. Given the embedded 63 + * text in the font, this should be used with very large font sizes. There are 64 + * two glyphs in the font. 65 + */ 66 + font-family: "BaselineDiagnostic"; 67 + src: url('./BaselineDiagnostic.ttf') format('opentype'); 68 + } 69 + 70 + @font-face { 71 + /** 72 + * Same as the "BaselineDiagnostic" font, but uses the common alphabetic baseline 73 + * of 0. This also results in the x-middle baseline being at 125. 74 + */ 75 + font-family: "BaselineDiagnostic"; 76 + src: url('./BaselineDiagnosticAlphabeticZero.ttf') format('opentype'); 77 + } 78 + ''')) 79 + print(f"Wrote stylesheet at {out_path}") 80 + 81 + 82 + def write_font_readme(): 83 + out_path = "dist/README.md" 84 + with open(out_path, "w") as f: 85 + f.write(dedent(r''' 86 + # Baseline Diagnostic Font 87 + 88 + ## Overview 89 + 90 + Font that can be used for validating baseline alignments. Given the embedded 91 + text in the font, this should be used with very large font sizes. There are 92 + two glyphs in the font: 93 + 94 + - `X` (U+0058) which has all baselines drawn 95 + - `.notdef` (for all other characters) which is an empty box 96 + 97 + It has the following baselines: 98 + 99 + | Baseline/Metric | Value | BASE Value | OS/2 Value | hhea Value | 100 + |-------------------|-------|------------|----------------|------------| 101 + | ascent | 800 | | sTypoAscender | ascent | 102 + | ideographic-over | 750 | Idtp | | | 103 + | hanging | 650 | hang | | | 104 + | cap-height | 550 | | sCapHeight | | 105 + | math | 450 | math | | | 106 + | /central/ | 350 | | | | 107 + | /em-middle/ | 300 | | | | 108 + | x-height | 250 | | sxHeight | | 109 + | /x-middle/ | 150 | | | | 110 + | alphabetic | 50 | romn | | | 111 + | /zero/ | | | | | 112 + | ideographic-under | -50 | ideo | | | 113 + | descent | -200 | | sTypoDescender | descent | 114 + 115 + The `BaselineDiagnosticAlphabeticZero` variant is the same as `Baseline`, 116 + except the alphabetic baseline is at the common value of 0. This also 117 + results in the x-middle baseline being at 125. 118 + 119 + ## License 120 + 121 + This font contains [Noto Sans Mono][noto-sans-mono] glyphs in the rendering 122 + of its baseline labels. Like that font, this font is licensed under the 123 + [SIL Open Font License, Version 1.1][ofl-1.1], and is available at `LICENSE.txt`. 124 + 125 + [noto-sans-mono]: https://fonts.google.com/noto/specimen/Noto+Sans+Mono/license 126 + [ofl-1.1]: https://openfontlicense.org/open-font-license-official-text/ 127 + ''')) 128 + print(f"Wrote README at {out_path}") 129 + 130 + 131 + def write_font_license(): 132 + out_path = "dist/LICENSE.md" 133 + with open(out_path, "w") as f: 134 + f.write(dedent(r''' 135 + Copyright (c) 2026, Sajid Anwar. 136 + 137 + This Font Software is licensed under the SIL Open Font License, Version 1.1. 138 + This license is copied below, and is also available with a FAQ at: 139 + https\://openfontlicense.org 140 +   141 + 142 + \---------------------------------------------------------------------- 143 + 144 + #### SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 145 + 146 + \---------------------------------------------------------------------- 147 + 148 +   149 + 150 + PREAMBLE 151 + ----------- 152 + 153 + The goals of the Open Font License (OFL) are to stimulate worldwide 154 + development of collaborative font projects, to support the font creation 155 + efforts of academic and linguistic communities, and to provide a free and 156 + open framework in which fonts may be shared and improved in partnership 157 + with others. 158 + 159 + The OFL allows the licensed fonts to be used, studied, modified and 160 + redistributed freely as long as they are not sold by themselves. The 161 + fonts, including any derivative works, can be bundled, embedded, 162 + redistributed and/or sold with any software provided that any reserved 163 + names are not used by derivative works. The fonts and derivatives, 164 + however, cannot be released under any other type of license. The 165 + requirement for fonts to remain under this license does not apply 166 + to any document created using the fonts or their derivatives. 167 + 168 + DEFINITIONS 169 + ----------- 170 + 171 + "Font Software" refers to the set of files released by the Copyright 172 + Holder(s) under this license and clearly marked as such. This may 173 + include source files, build scripts and documentation. 174 + 175 + "Reserved Font Name" refers to any names specified as such after the 176 + copyright statement(s). 177 + 178 + "Original Version" refers to the collection of Font Software components as 179 + distributed by the Copyright Holder(s). 180 + 181 + "Modified Version" refers to any derivative made by adding to, deleting, 182 + or substituting -- in part or in whole -- any of the components of the 183 + Original Version, by changing formats or by porting the Font Software to a 184 + new environment. 185 + 186 + "Author" refers to any designer, engineer, programmer, technical 187 + writer or other person who contributed to the Font Software. 188 + 189 + PERMISSION & CONDITIONS 190 + ----------- 191 + 192 + Permission is hereby granted, free of charge, to any person obtaining 193 + a copy of the Font Software, to use, study, copy, merge, embed, modify, 194 + redistribute, and sell modified and unmodified copies of the Font 195 + Software, subject to the following conditions: 196 + 197 + 1) Neither the Font Software nor any of its individual components, 198 + in Original or Modified Versions, may be sold by itself. 199 + 200 + 2) Original or Modified Versions of the Font Software may be bundled, 201 + redistributed and/or sold with any software, provided that each copy 202 + contains the above copyright notice and this license. These can be 203 + included either as stand-alone text files, human-readable headers or 204 + in the appropriate machine-readable metadata fields within text or 205 + binary files as long as those fields can be easily viewed by the user. 206 + 207 + 3) No Modified Version of the Font Software may use the Reserved Font 208 + Name(s) unless explicit written permission is granted by the corresponding 209 + Copyright Holder. This restriction only applies to the primary font name as 210 + presented to the users. 211 + 212 + 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font 213 + Software shall not be used to promote, endorse or advertise any 214 + Modified Version, except to acknowledge the contribution(s) of the 215 + Copyright Holder(s) and the Author(s) or with their explicit written 216 + permission. 217 + 218 + 5) The Font Software, modified or unmodified, in part or in whole, 219 + must be distributed entirely under this license, and must not be 220 + distributed under any other license. The requirement for fonts to 221 + remain under this license does not apply to any document created 222 + using the Font Software. 223 + 224 + TERMINATION 225 + ----------- 226 + 227 + This license becomes null and void if any of the above conditions are 228 + not met. 229 + 230 + DISCLAIMER 231 + ----------- 232 + 233 + THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 234 + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF 235 + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 236 + OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE 237 + COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 238 + INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL 239 + DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 240 + FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM 241 + OTHER DEALINGS IN THE FONT SOFTWARE. 242 + ''')) 243 + print(f"Wrote OFL 1.1 license at {out_path}") 244 + 245 + if __name__ == "__main__": 246 + main()
+9
pyproject.toml
··· 1 + [project] 2 + name = "baseline-diagnostic-font" 3 + version = "0.1.0" 4 + description = "Font that can be used for validating baseline alignments" 5 + readme = "README.md" 6 + requires-python = ">=3.14" 7 + dependencies = [ 8 + "fonttools>=4.61.1", 9 + ]
support/noto/NotoSansMono-Bold.ttf

This is a binary file and will not be displayed.

+93
support/noto/OFL.txt
··· 1 + Copyright 2022 The Noto Project Authors (https://github.com/notofonts/latin-greek-cyrillic) 2 + 3 + This Font Software is licensed under the SIL Open Font License, Version 1.1. 4 + This license is copied below, and is also available with a FAQ at: 5 + https://openfontlicense.org 6 + 7 + 8 + ----------------------------------------------------------- 9 + SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 10 + ----------------------------------------------------------- 11 + 12 + PREAMBLE 13 + The goals of the Open Font License (OFL) are to stimulate worldwide 14 + development of collaborative font projects, to support the font creation 15 + efforts of academic and linguistic communities, and to provide a free and 16 + open framework in which fonts may be shared and improved in partnership 17 + with others. 18 + 19 + The OFL allows the licensed fonts to be used, studied, modified and 20 + redistributed freely as long as they are not sold by themselves. The 21 + fonts, including any derivative works, can be bundled, embedded, 22 + redistributed and/or sold with any software provided that any reserved 23 + names are not used by derivative works. The fonts and derivatives, 24 + however, cannot be released under any other type of license. The 25 + requirement for fonts to remain under this license does not apply 26 + to any document created using the fonts or their derivatives. 27 + 28 + DEFINITIONS 29 + "Font Software" refers to the set of files released by the Copyright 30 + Holder(s) under this license and clearly marked as such. This may 31 + include source files, build scripts and documentation. 32 + 33 + "Reserved Font Name" refers to any names specified as such after the 34 + copyright statement(s). 35 + 36 + "Original Version" refers to the collection of Font Software components as 37 + distributed by the Copyright Holder(s). 38 + 39 + "Modified Version" refers to any derivative made by adding to, deleting, 40 + or substituting -- in part or in whole -- any of the components of the 41 + Original Version, by changing formats or by porting the Font Software to a 42 + new environment. 43 + 44 + "Author" refers to any designer, engineer, programmer, technical 45 + writer or other person who contributed to the Font Software. 46 + 47 + PERMISSION & CONDITIONS 48 + Permission is hereby granted, free of charge, to any person obtaining 49 + a copy of the Font Software, to use, study, copy, merge, embed, modify, 50 + redistribute, and sell modified and unmodified copies of the Font 51 + Software, subject to the following conditions: 52 + 53 + 1) Neither the Font Software nor any of its individual components, 54 + in Original or Modified Versions, may be sold by itself. 55 + 56 + 2) Original or Modified Versions of the Font Software may be bundled, 57 + redistributed and/or sold with any software, provided that each copy 58 + contains the above copyright notice and this license. These can be 59 + included either as stand-alone text files, human-readable headers or 60 + in the appropriate machine-readable metadata fields within text or 61 + binary files as long as those fields can be easily viewed by the user. 62 + 63 + 3) No Modified Version of the Font Software may use the Reserved Font 64 + Name(s) unless explicit written permission is granted by the corresponding 65 + Copyright Holder. This restriction only applies to the primary font name as 66 + presented to the users. 67 + 68 + 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font 69 + Software shall not be used to promote, endorse or advertise any 70 + Modified Version, except to acknowledge the contribution(s) of the 71 + Copyright Holder(s) and the Author(s) or with their explicit written 72 + permission. 73 + 74 + 5) The Font Software, modified or unmodified, in part or in whole, 75 + must be distributed entirely under this license, and must not be 76 + distributed under any other license. The requirement for fonts to 77 + remain under this license does not apply to any document created 78 + using the Font Software. 79 + 80 + TERMINATION 81 + This license becomes null and void if any of the above conditions are 82 + not met. 83 + 84 + DISCLAIMER 85 + THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 86 + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF 87 + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 88 + OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE 89 + COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 90 + INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL 91 + DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 92 + FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM 93 + OTHER DEALINGS IN THE FONT SOFTWARE.
+39
uv.lock
··· 1 + version = 1 2 + revision = 3 3 + requires-python = ">=3.14" 4 + 5 + [[package]] 6 + name = "baseline-diagnostic-font" 7 + version = "0.1.0" 8 + source = { virtual = "." } 9 + dependencies = [ 10 + { name = "fonttools" }, 11 + ] 12 + 13 + [package.metadata] 14 + requires-dist = [{ name = "fonttools", specifier = ">=4.61.1" }] 15 + 16 + [[package]] 17 + name = "fonttools" 18 + version = "4.61.1" 19 + source = { registry = "https://pypi.org/simple" } 20 + sdist = { url = "https://files.pythonhosted.org/packages/ec/ca/cf17b88a8df95691275a3d77dc0a5ad9907f328ae53acbe6795da1b2f5ed/fonttools-4.61.1.tar.gz", hash = "sha256:6675329885c44657f826ef01d9e4fb33b9158e9d93c537d84ad8399539bc6f69", size = 3565756, upload-time = "2025-12-12T17:31:24.246Z" } 21 + wheels = [ 22 + { url = "https://files.pythonhosted.org/packages/32/8f/4e7bf82c0cbb738d3c2206c920ca34ca74ef9dabde779030145d28665104/fonttools-4.61.1-cp314-cp314-macosx_10_15_universal2.whl", hash = "sha256:fff4f534200a04b4a36e7ae3cb74493afe807b517a09e99cb4faa89a34ed6ecd", size = 2846094, upload-time = "2025-12-12T17:30:43.511Z" }, 23 + { url = "https://files.pythonhosted.org/packages/71/09/d44e45d0a4f3a651f23a1e9d42de43bc643cce2971b19e784cc67d823676/fonttools-4.61.1-cp314-cp314-macosx_10_15_x86_64.whl", hash = "sha256:d9203500f7c63545b4ce3799319fe4d9feb1a1b89b28d3cb5abd11b9dd64147e", size = 2396589, upload-time = "2025-12-12T17:30:45.681Z" }, 24 + { url = "https://files.pythonhosted.org/packages/89/18/58c64cafcf8eb677a99ef593121f719e6dcbdb7d1c594ae5a10d4997ca8a/fonttools-4.61.1-cp314-cp314-manylinux1_x86_64.manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:fa646ecec9528bef693415c79a86e733c70a4965dd938e9a226b0fc64c9d2e6c", size = 4877892, upload-time = "2025-12-12T17:30:47.709Z" }, 25 + { url = "https://files.pythonhosted.org/packages/8a/ec/9e6b38c7ba1e09eb51db849d5450f4c05b7e78481f662c3b79dbde6f3d04/fonttools-4.61.1-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:11f35ad7805edba3aac1a3710d104592df59f4b957e30108ae0ba6c10b11dd75", size = 4972884, upload-time = "2025-12-12T17:30:49.656Z" }, 26 + { url = "https://files.pythonhosted.org/packages/5e/87/b5339da8e0256734ba0dbbf5b6cdebb1dd79b01dc8c270989b7bcd465541/fonttools-4.61.1-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:b931ae8f62db78861b0ff1ac017851764602288575d65b8e8ff1963fed419063", size = 4924405, upload-time = "2025-12-12T17:30:51.735Z" }, 27 + { url = "https://files.pythonhosted.org/packages/0b/47/e3409f1e1e69c073a3a6fd8cb886eb18c0bae0ee13db2c8d5e7f8495e8b7/fonttools-4.61.1-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:b148b56f5de675ee16d45e769e69f87623a4944f7443850bf9a9376e628a89d2", size = 5035553, upload-time = "2025-12-12T17:30:54.823Z" }, 28 + { url = "https://files.pythonhosted.org/packages/bf/b6/1f6600161b1073a984294c6c031e1a56ebf95b6164249eecf30012bb2e38/fonttools-4.61.1-cp314-cp314-win32.whl", hash = "sha256:9b666a475a65f4e839d3d10473fad6d47e0a9db14a2f4a224029c5bfde58ad2c", size = 2271915, upload-time = "2025-12-12T17:30:57.913Z" }, 29 + { url = "https://files.pythonhosted.org/packages/52/7b/91e7b01e37cc8eb0e1f770d08305b3655e4f002fc160fb82b3390eabacf5/fonttools-4.61.1-cp314-cp314-win_amd64.whl", hash = "sha256:4f5686e1fe5fce75d82d93c47a438a25bf0d1319d2843a926f741140b2b16e0c", size = 2323487, upload-time = "2025-12-12T17:30:59.804Z" }, 30 + { url = "https://files.pythonhosted.org/packages/39/5c/908ad78e46c61c3e3ed70c3b58ff82ab48437faf84ec84f109592cabbd9f/fonttools-4.61.1-cp314-cp314t-macosx_10_15_universal2.whl", hash = "sha256:e76ce097e3c57c4bcb67c5aa24a0ecdbd9f74ea9219997a707a4061fbe2707aa", size = 2929571, upload-time = "2025-12-12T17:31:02.574Z" }, 31 + { url = "https://files.pythonhosted.org/packages/bd/41/975804132c6dea64cdbfbaa59f3518a21c137a10cccf962805b301ac6ab2/fonttools-4.61.1-cp314-cp314t-macosx_10_15_x86_64.whl", hash = "sha256:9cfef3ab326780c04d6646f68d4b4742aae222e8b8ea1d627c74e38afcbc9d91", size = 2435317, upload-time = "2025-12-12T17:31:04.974Z" }, 32 + { url = "https://files.pythonhosted.org/packages/b0/5a/aef2a0a8daf1ebaae4cfd83f84186d4a72ee08fd6a8451289fcd03ffa8a4/fonttools-4.61.1-cp314-cp314t-manylinux1_x86_64.manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_5_x86_64.whl", hash = "sha256:a75c301f96db737e1c5ed5fd7d77d9c34466de16095a266509e13da09751bd19", size = 4882124, upload-time = "2025-12-12T17:31:07.456Z" }, 33 + { url = "https://files.pythonhosted.org/packages/80/33/d6db3485b645b81cea538c9d1c9219d5805f0877fda18777add4671c5240/fonttools-4.61.1-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:91669ccac46bbc1d09e9273546181919064e8df73488ea087dcac3e2968df9ba", size = 5100391, upload-time = "2025-12-12T17:31:09.732Z" }, 34 + { url = "https://files.pythonhosted.org/packages/6c/d6/675ba631454043c75fcf76f0ca5463eac8eb0666ea1d7badae5fea001155/fonttools-4.61.1-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:c33ab3ca9d3ccd581d58e989d67554e42d8d4ded94ab3ade3508455fe70e65f7", size = 4978800, upload-time = "2025-12-12T17:31:11.681Z" }, 35 + { url = "https://files.pythonhosted.org/packages/7f/33/d3ec753d547a8d2bdaedd390d4a814e8d5b45a093d558f025c6b990b554c/fonttools-4.61.1-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:664c5a68ec406f6b1547946683008576ef8b38275608e1cee6c061828171c118", size = 5006426, upload-time = "2025-12-12T17:31:13.764Z" }, 36 + { url = "https://files.pythonhosted.org/packages/b4/40/cc11f378b561a67bea850ab50063366a0d1dd3f6d0a30ce0f874b0ad5664/fonttools-4.61.1-cp314-cp314t-win32.whl", hash = "sha256:aed04cabe26f30c1647ef0e8fbb207516fd40fe9472e9439695f5c6998e60ac5", size = 2335377, upload-time = "2025-12-12T17:31:16.49Z" }, 37 + { url = "https://files.pythonhosted.org/packages/e4/ff/c9a2b66b39f8628531ea58b320d66d951267c98c6a38684daa8f50fb02f8/fonttools-4.61.1-cp314-cp314t-win_amd64.whl", hash = "sha256:2180f14c141d2f0f3da43f3a81bc8aa4684860f6b0e6f9e165a4831f24e6a23b", size = 2400613, upload-time = "2025-12-12T17:31:18.769Z" }, 38 + { url = "https://files.pythonhosted.org/packages/c7/4e/ce75a57ff3aebf6fc1f4e9d508b8e5810618a33d900ad6c19eb30b290b97/fonttools-4.61.1-py3-none-any.whl", hash = "sha256:17d2bf5d541add43822bcf0c43d7d847b160c9bb01d15d5007d84e2217aaa371", size = 1148996, upload-time = "2025-12-12T17:31:21.03Z" }, 39 + ]