Typeye 如何辨識字體,以及為何兩款字體看起來一模一樣
How font identification actually works (and why two fonts look identical)
Typeye 的字體辨識旨在分辨外觀近似的字體,難點不在單純偵測,而是辨認容易混淆的字體複製品。緊貼字樣裁切,並比較字形骨架、接點和末端,比依賴原始像素距離更有用。結果宜列出一組難以區分的候選字體,並在使用前核對授權。
You see a font in a screenshot, a poster, a menu, and you need to know what it is. Most guides tell you to "just upload the image", which hides the interesting part: the hard problems are not detection, they are the near-duplicates.
I have been building Typeye for that exact job, so here is the honest engineering picture.
1. Cropping matters more than the model
A whole page photo gives you inconsistent letter heights, perspective skew, and background noise. A tight crop of one word in a consistent weight is worth far more than a fancy classifier, because the classifier is comparing shapes and anything that changes the shape hurts.
2. Skeleton beats pixels
The useful step is thinning strokes down to a skeleton and describing each glyph by junctions and terminals: does the lowercase 'a' have a spur, is the 't' topped flat or angled, does the 'g' close. Those features survive scaling, anti-aliasing and JPEG mush. Raw pixel distance does not.
3. The real problem is clones
Half the fonts on a typical page are clones of something older: Nimbus Sans against Helvetica, Liberation Sans against Arial, dozens of neo-grotesques against the original Akzidenz. A correct answer is often "this is X, but it could equally be these four rebadged copies", and a tool that returns a single confident name is lying to you slightly. Showing a short family of visually indistinguishable candidates is more useful.
4. Licensing is the part nobody mentions
Identifying a font and legally using it are different questions. Free lookalikes are usually OFL and safe; the commercial original often is not, and people find that out after they have shipped a logo.
So my rule of thumb: crop tight, compare skeletons, expect a family of answers, then check the license before you ship.
來源:DEV Community · dev.to