Subscript for specific characters

I have a 14 MB TTF containing mostly simplified Chinese characters.

I would like to reduce the size by creating a subset that contains only certain characters in the HTML page.

So, ideally, I would like to transfer (Linux) the program with a block of text and update the font based on the contained characters.

eg.

./magic-font-squisher input.tff "ABC123水小长" 

or

  ./magic-font-squisher input.tff /path/to/test.html 

The new font will contain only those 9 characters.

+4
source share
2 answers

Used https://bitbucket.org/philip/font-optimizer/src

 ./subset.pl --chars="ABC 123 水小长" input.ttf output.ttf 

This is exactly what I want.

How i found it

Google's font catalog contains a subset tool, readme says

- string =: Create a subset only for the specified string. Useful for creating a subset of the menu. Usually we use subset.pl from Font Optimizer for this, however.

The Font Optimizer search took me to a demo site that allows you to test the script.

There is also a forked GitHub repo that has better documentation.

+5
source

You can do this with FontForge scripts . This works, although it can probably be made smarter or wrapped up in the containing script.

 #!/usr/bin/env fontforge Open($1); # first param SelectAll(); SelectFewer(0u41, 0u43, 0u31, 0u33); # a range SelectFewer(0u6c34); # or a single codepoint SelectFewer(0u5c0f); SelectFewer(0u957f); DetachAndRemoveGlyphs(); Save($2); # second param Quit(0); 

I needed to define FONTFORGE_LANGUAGE before starting:

 FONTFORGE_LANGUAGE=ff ./squish source.ttf squished.ttf 
+3
source

Source: https://habr.com/ru/post/1481977/


All Articles