45

Is there any way to reduce the size of the .ttf fonts? i.e. if we want to remove some glyps which we are not using.

7 Answers 7

28

FontSquirrel's Webfont generator makes it very easy to reduce a font's filesize.

  • Upload your font
  • Choose Expert...
  • Choose which glyphs to include
  • Press Download Your Kit

I was able to take a 263kb font down to 34kb.

FontSquirrel Webfont Generator

4
  • 2
    Click the Custom Subsetting... radio box to further enable reducing the file size.
    – Jeff
    Commented Dec 7, 2021 at 1:06
  • 1
    This link is not working now. Giving 502 error
    – Suprabha
    Commented Oct 3, 2022 at 11:04
  • Worked great for me. A google font I was using for a react native application which was originally 4.8MB got reduced to 40KB.
    – Reez0
    Commented Oct 5, 2022 at 18:17
  • cool, material icon font reduced from 808 -> 12 kb
    – Martinedo
    Commented Feb 28, 2023 at 20:58
18

With Google Web Fonts, you can limit the character set like:

//fonts.googleapis.com/css?family=FontName&text=Lorem%20Ipsum

This would be particularly useful if Google had icon fonts like Font Awesome

2
  • 1
    Neat trick, didn't know that. You can also request certain weights in the paramater as well. (e.g. only bold, no italic or normal) Commented Oct 20, 2012 at 6:57
  • 1
    This does not address the actual question of how to reduce the filesize of a truetype font that you already have, specifically by removing glyphs that you are not using. It addresses a different question "How do you remove all excess glyphs from a Google Web Font?" Google fonts are not woff2 format, not ttf, and you cannot use this method if you already have a font that you want to use.
    – ADJenks
    Commented Oct 9, 2018 at 17:05
16

You can use fonttools to remove unwanted glyphs from a font.

pip install fonttools
pyftsubset myFont.ttf --output-file=mySmallerFont.ttf --unicodes=U+0020-007E

mySmallerFont.ttf will contain only unicode characters ranging from U+0020 to U+007E (basic latin).

Full documentation is available here.

For the list of unicode characters, you can check Wikipedia.

2
  • 1
    by far the easiest and most flexible option. Also works under cygwin without needing to install pip
    – Max
    Commented Jan 17, 2023 at 4:34
  • Cool and impressive! I've just used this tool to reduce Iosevkas size from 6MB to 64KB (!) by selecting the subset, that is required by my use case: pyftsubset iosevka-medium.ttf --output-file=slim-iosevka-medium.ttf --unicodes=U+0020-007E,U+00A0-00FF That command selects Basic Latin and Latin-1 Supplement.
    – sschober
    Commented Mar 9, 2023 at 14:27
8

You can use fontforge to reduce the file size

This is explained at http://www.cnx-software.com/2010/02/19/reducing-truetype-font-file-size-for-embedded-systems/

6

I did the following to remove all Cyrillic glyphs (letters) from a font, hence cutting file size in half as I only needed the Latin letters.

  1. get FontForge (https://fontforge.github.io/en-US/)
  2. start FontForge and open your ttf font file
  3. go to Edit -> Select -> Select By Script
  4. on the pop up selection window chose Cyrillic from the drop down menu. As you might have guessed this will mark only the Cyrillic letters.
  5. go to Encoding -> Detach & Remove Glyphs, confirm the question. See how the Cyrillic letters disappear?
  6. go to Encoding -> Compact to get a better overview of the remaining letters which makes it easier to select more deleting candidates. (But I did not dare to manually delete/remove them.)
  7. go to File -> Generate Fonts and don't forget to chose ttf as output format.

Please consider that I am not a pro in this. But I needed a fast solution.

Here you can read more on this topic: http://wiki.unity3d.com/index.php?title=Create_a_new_TrueType_font_using_a_subset_of_characters_from_an_existing_TrueType_font

3

I was using fontmin to remove glyph from ttf fonts.

It succeeded to reduce Noto Sans (weight=medium) from 20MB to less than 10, yet still cover common Chinese/Japanese characters.

1

What is the application for this? Most fonts are relatively lightweight. TTFs store vector data instead of bitmap data, so it takes relatively few bytes to describe the shape of each glyph. Even very busy fonts can be kept below 100kb. Many modern fonts come with ClearType hinting, but even this adds very little file size.

If you really want to take certain glyphs out of a font, then you will need a font editing tool (Macromedia had one called Fontographer that is now owned by FontLab). But you're probably better off just picking a lighter font. For example, OCR A Std is only 30kb and includes ClearType hinting as well as all US ASCII characters. Try to avoid Unicode fonts since full Unicode support requires a ton of glyphs. But most fonts don't offer full Unicode support.

Lastly, if you do decide to modify a font, make sure you name it something else. A naming conflict could result in some really annoying surprises for users.

4
  • 7
    Complex .ttf fonts can easily get up to 1MB or more. Commented Jun 22, 2013 at 20:46
  • @Mark: Maybe Big5 or GB fonts or others with large character sets, but these are edge cases. Otherwise, even very elaborate Western fonts rarely get above 500KB, and the few that are 500KB are whales that could probably be optimized. Commented Jun 22, 2013 at 21:20
  • 3
    But you asked for the application. :) I'm dealing with the exact problem right now. Commented Jun 23, 2013 at 18:08
  • 2
    Fonts in Chinese, for instance, regularly run 8-12MB. They contain 20K-40K individual glyphs.
    – XML
    Commented Mar 3, 2015 at 9:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.