# Compare Text Sample With Your Fonts > Rank the font files you supply by how closely they match a picture of text. Upload a picture of one or more lines of text, type the text it shows and add up to four font files you own. The tool finds each character, draws the same characters with every font from its own outlines at a matching size and ranks the fonts by shape, overlap, width, height, stroke weight and baseline. It compares your sample with the fonts you provide — it does not identify unknown fonts. Files are uploaded to the server for this calculation; Lumina's Type Lab Font Matcher does the same on your device. Part of usefulweb.app (https://usefulweb.app/). Part of [Lumina](https://lumina.usefulweb.app/) (ownerApp: lumina). Results are deterministic calculations from the inputs and the listed assumptions; the API returns exactly what the web page shows. ## Use it - Human interface: https://luminafontcompare.usefulweb.app/ (interactive tool at https://luminafontcompare.usefulweb.app/tool) - JSON API: POST https://luminafontcompare.usefulweb.app/api/v1/calculate with a JSON object of inputs (schema: https://luminafontcompare.usefulweb.app/api/v1/tool) - OpenAPI: https://luminafontcompare.usefulweb.app/openapi.json - MCP (Streamable HTTP): https://luminafontcompare.usefulweb.app/mcp - tool `lumina_font_compare` ## Inputs - image (file, required): Sample picture of text (PNG, JPEG or WebP; up to 8 MB) - text (text, required): Text shown in the picture, in reading order (spaces are ignored) - font1 (file, required): Font file 1 (TTF, OTF or WOFF with TrueType outlines; up to 2 MB) - font2 (file): Font file 2 (optional) - font3 (file): Font file 3 (optional) - font4 (file): Font file 4 (optional) - threshold (integer): Ink threshold (1–254; leave empty for automatic) - polarity (select): Text colour - deskew (boolean): Straighten tilted text ## Method - The sample is converted to luminance (transparent pixels on white). Ink is separated with Otsu's threshold, or your fixed threshold; with automatic text colour the smaller class is ink. Images above 2000 pixels per side or 2.4 megapixels are scaled down first. - Tilt is estimated between −10° and +10° by maximising the energy of the horizontal projection profile (0.5° steps, refined to 0.1°) and removed by bilinear rotation. Specks smaller than 3 pixels (or 2% of the median part) are dropped. - Characters are 8-connected ink parts. Rows with ink form lines (thin rows such as accents join their nearest line); parts of one line that overlap horizontally by at least half the narrower width are merged (i-dots, umlauts, colons). Boxes are read top to bottom, left to right and paired with the characters of your text without spaces; the counts must match. Touching or broken letters need the box editor in Lumina's Type Lab. - Every font draws each character from its own TrueType outlines (default instance; composite glyphs resolved) with a non-zero rasteriser. One size per font is chosen as the median ratio of sample height to drawn height over the taller characters, so proportions between letters stay meaningful. - Per character: shape = exp(−d/1.5) with d the symmetric mean 3-4 chamfer distance on 32 × 32 grids of each glyph's own box; overlap = best Dice over ±1 cell; aspect, height and stroke width (2 × area / perimeter) as exp(−3·|ln ratio|); baseline = exp(−5 × offset / line height) against the line's median baseline; moments = exp(−mean |Δ log10|) of the first two Hu invariants. Score = 30% shape + 15% overlap + 13% aspect + 12% height + 15% stroke + 8% baseline + 7% moments. - A font's score is the mean over all characters; characters the font does not contain count as 0 and are listed. Scores are similarities between 0 and 100, not probabilities. CFF (PostScript-outline) OpenType fonts, WOFF2 and font collections are excluded with a reason. Kerning, ligatures and right-to-left reading order are not modelled; type the characters in left-to-right visual order.