1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-09 08:29:42 +00:00
mpv/TOOLS/subfont-c
rathann 0eb98079d5 fix overcomplicated macros and a few warnings
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@13187 b3059339-0415-0410-9bf9-f77b7e298cf2
2004-08-28 20:53:01 +00:00
..
encodings
osd
.cvsignore
font.desc.tail embarassing typo 2004-07-19 23:19:07 +00:00
fontgen
Makefile
README
runme
subfont.c fix overcomplicated macros and a few warnings 2004-08-28 20:53:01 +00:00

Usage:
~~~~~~
1. Make sure you have FreeType 2 installed.
2. Get a TrueType or Type 1 font.
3. Run ./configure from mplayer's root directory.
4. Modify `runme' script for your encoding and font path.
5. Type: ./runme
6. Copy *.raw and font.desc files to ~/.mplayer/font/
7. Run subfont alone to see more options.


About:
~~~~~~
`subfont' program renders antialiased OSD and subtitle fonts for mplayer.

What you get are bitmap and alpha *.raw files and a font.desc.
What you need is TrueType, Type 1 or any other font supported by FreeType.

Alpha channel is created using outline and Gaussian blur filters.

ANY encoding is now supported! That is, all 8-bit encodings known by libc
and user-supplied encodings (also multibyte) through custom encoding files.

I prepared also Type 1 font `osd.pfb' for OSD characters based on bitmaps
created by chass.


Encodings:
~~~~~~~~~~
You can get any encoding and any charset.
1. If you want 8-bit charset, which is known to libc, encoded either in 8-bit
   or Unicode (like ISO-8859-*, KOI8-*):
   
   Find correct encoding name using `iconv --list' (on RedHat) and use it.
   For latin2 subtitles I would write:
   ./subfont iso-8859-2 24 verdana.ttf
   and for UTF-8 subtitles with latin2 charset:
   ./subfont --unicode iso-8859-2 24 verdana.ttf

2. If you want encoding not known to libc or non 8-bit (like EUC-KR):

   Create file describing your charset:

   For each character you want to render write the line consisting of:
       hexadecimal Unicode character code
       followed by whitespace
       followed by hexadecimal number representing your encoding
       followed by new line character
   or (for UTF-8 subtitles):
       hexadecimal Unicode character code
       followed by new line character.

   Example:
       To render a single letter `aogonek' (Unicode 0x0105) and encode
       it using iso-8859-2 encoding (0xB1), your custom encoding file will consist
       of a sigle line:
       0105 B1

       or to get unicode font.desc, write only:
       0105

   Subfont was tested with Korean fonts from truetype-fonts-ko-2.0-1k.noarch.rpm
   I found on http://rpmfind.net/ and euc-kr encoding.  Custom encoding file
   for euc-kr was generated from charmap I found in /usr/share/i18n/charmaps/EUC-KR.gz
   (glibc package).  Simple script for this you will find in encodings directory.
   This should work with -unicode switch for mplayer (though this is not Unicode).
   It took about 10 seconds to render over 8000 characters on P3 @ 600MHz.


New font.desc format (proposal):
~~~~~~~~~~~~~~~~~~~~~==========~
Subfont will generate new font.desc format when compiled with NEW_DESC macro defined
(uncomment appropriate line in Makefile).

These changes are to make bitmaps smaller and processing faster.

Changes to [info] section:
 There is no `spacewidth'. It will not be useful.
 `height` is the distance from one baseline to the next.
 `ascender' is the distance from the baseline to the highest grid coordinate used to place the outline point.
 `descender' is the distance from the baseline to the lowest grid coordinate used to place the outline point.
Note: upwards direction is positive.
Read more: freetype-2.*/docs/glyphs/glyphs-3.html

Changes to [characters] section:
 Bitmap start and bitmap end are replaced with:
  bitmap start,
  bitmap width,
  bitmap height,
  left bearing -- the horizontal distance from the current pen position to the bitmaps's left edge,
  top bearing -- the vertical distance from the baseline to the bitmaps's top edge,
  advance -- the horizontal distance the pen position must be incremented by after each glyph is rendered.

To anderstand this you must think in verctorial coordinates.
Necessarily read freetype-2.*/docs/glyphs/glyphs-7.html about vectorial coordinates!


Notes:
~~~~~~
  + Starting x position of each character and the bitmap width is aligned
to multiple of 8 (required by mplayer).

  + My development platform is RedHat 7.1.  FreeType versions tested are
2.0.1 through 2.0.4.

  + FreeType library has a bug that makes subfont display some warning message
about Unicode charmap for osd.pfb.


Author:
~~~~~~~
Artur Zaprzala <zybi@fanthom.irc.pl>