Difference between revisions of "Nfont packages"

From GNUstepWiki
Jump to navigation Jump to search
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
==Nfonts packages==
 
==Nfonts packages==
  
The [[Arts]] backend manages fonts using so-called nfonts.
+
The [[Arts backend]] manages fonts using so-called nfonts.
  
 
Nfonts are hand-crafted directories with a plist file and
 
Nfonts are hand-crafted directories with a plist file and
Line 16: Line 16:
 
==Example==
 
==Example==
  
A typical nfont folder - in this case System.nfont packaged by Jeff Teunissen (Deek) - looks like this:
+
A typical nfont folder - in this case Arial.nfont packaged by Jeff Teunissen (Deek) - looks like this:
  
  System.nfont/
+
  Arial.nfont/
  System.nfont/DejaVuSans-Oblique.ttf
+
  Arial.nfont/ariali.ttf
  System.nfont/DejaVuSansCondensed-Oblique.ttf
+
  Arial.nfont/arial.ttf
  System.nfont/DejaVuSans-Bold.ttf
+
  Arial.nfont/arialbi.ttf
  System.nfont/DejaVuSansCondensed-BoldOblique.ttf
+
  Arial.nfont/arialbd.ttf
  System.nfont/DejaVuSansCondensed-Bold.ttf
+
  Arial.nfont/FontInfo.plist
System.nfont/FontInfo.plist
+
  Arial.nfont/arialblk.ttf
  System.nfont/DejaVuSans.ttf
 
System.nfont/DejaVuSansCondensed.ttf
 
System.nfont/DejaVuSans-BoldOblique.ttf
 
  
 
This is the FontInfo.plist file in that directory:
 
This is the FontInfo.plist file in that directory:
  
 
  {
 
  {
 +
    Description = "Monotype Arial, WGL4 Character Set";
 
     Faces = (
 
     Faces = (
 
  {
 
  {
 
      Files = (
 
      Files = (
  DejaVuSans.ttf
+
  arial.ttf
 
      );
 
      );
      Name = Book;
+
    LocalizedNames = {
      PostScriptName = DejaVuSans;
+
Basque = Arrunta;
 +
Catalan = Normal;
 +
Danish = normal;
 +
Dutch = Standaard;
 +
English = Regular;
 +
Finnish = Normaali;
 +
French = Normal;
 +
Germany = Standard;
 +
Hungarian = "Norm\u00e1l";
 +
Italian = Normale;
 +
Norwegian = Normal;
 +
Polish = Normalne;
 +
Portuguese = Normal;
 +
Slovak = "Norm\u00e1lne";
 +
Slovene = Navadno;
 +
Spanish = Normal;
 +
Swedish = Normal;
 +
Turkish = Normal;
 +
    };
 +
      Name = Regular;
 +
      PostScriptName = ArialMT;
 +
    RenderHints_hack = 0x0002;
 +
    Traits = 0;
 
      Weight = 5;
 
      Weight = 5;
    Traits = 0;
 
 
  },
 
  },
 
  {
 
  {
 
      Files = (
 
      Files = (
  "DejaVuSans-Oblique.ttf"
+
  ariali.ttf
 
      );
 
      );
      Name = "Book Oblique";
+
    LocalizedNames = {
      PostScriptName = "DejaVuSans-Oblique";
+
English = Italic;
      Weight = 5;
+
    };
 +
      Name = Italic;
 +
      PostScriptName = "Arial-ItalicMT";
 +
      RenderHints_hack = 0x0002;
 
      Traits = 1;
 
      Traits = 1;
},
 
{
 
    Files = (
 
DejaVuSansCondensed.ttf
 
    );
 
    Name = "Book Condensed";
 
    PostScriptName = DejaVuSansCondensed;
 
 
      Weight = 5;
 
      Weight = 5;
    Traits = 16;
 
 
  },
 
  },
 
  {
 
  {
 
      Files = (
 
      Files = (
  "DejaVuSansCondensed-Oblique.ttf"
+
  arialbd.ttf
    );
 
    Name = "Book Condensed Oblique";
 
    PostScriptName = "DejaVuSansCondensed-Oblique";
 
    Weight = 5;
 
    Traits = 17;
 
},
 
{
 
    Files = (
 
"DejaVuSans-Bold.ttf"
 
 
      );
 
      );
 +
    LocalizedNames = {
 +
English = Bold;
 +
    };
 
      Name = Bold;
 
      Name = Bold;
      PostScriptName = "DejaVuSans-Bold";
+
      PostScriptName = "Arial-BoldMT";
 +
    RenderHints_hack = 0x0002;
 +
    Traits = 2;
 
      Weight = 9;
 
      Weight = 9;
    Traits = 2;
 
 
  },
 
  },
 
  {
 
  {
 
      Files = (
 
      Files = (
  "DejaVuSans-BoldOblique.ttf"
+
  arialbi.ttf
 
      );
 
      );
      Name = "Bold Oblique";
+
    LocalizedNames = {
      PostScriptName = "DejaVuSans-BoldOblique";
+
English = "Bold Italic";
      Weight = 9;
+
    };
 +
      Name = "Bold Italic";
 +
      PostScriptName = "Arial-BoldItalicMT";
 +
      RenderHints_hack = 0x0002;
 
      Traits = 3;
 
      Traits = 3;
},
 
{
 
    Files = (
 
"DejaVuSansCondensed-Bold.ttf"
 
    );
 
    Name = "Bold Condensed";
 
    PostScriptName = "DejaVuSansCondensed-Bold";
 
 
      Weight = 9;
 
      Weight = 9;
    Traits = 18;
 
 
  },
 
  },
 
  {
 
  {
 
      Files = (
 
      Files = (
  "DejaVuSansCondensed-BoldOblique.ttf"
+
  arialblk.ttf
 
      );
 
      );
      Name = "Bold Condensed Oblique";
+
    LocalizedNames = {
      PostScriptName = "DejaVuSansCondensed-BoldOblique";
+
English = Black;
      Weight = 9;
+
    };
      Traits = 19;
+
      Name = Black;
 +
      PostScriptName = "Arial-Black";
 +
      RenderHints_hack = 0x0002;
 +
      Traits = 2;
 +
    Weight = 12;
 
  }
 
  }
 
     );
 
     );
 +
    FontCopyright = "Typeface \u00a9 The Monotype Corporation plc.\nData \u00a9 The Monotype Corporation plc/Type Solutions Inc. 1990-1992.\nAll Rights Reserved";
 +
    Foundry = "Monotype Typography";
 +
    Packager = "Jeff Teunissen <deek@d2dc.net>";
 +
    Version = 2.82;
 
  }
 
  }
 +
 +
==Rendering Hints==
 +
 +
There's a hack for encoding rendering hints into Nfonts packages. You provide them using
 +
the RenderHints_hack value. It's a 24-bit value (usually given in hexadecimal form), where
 +
the highest-order byte contains information on if we want to use antialiasing by default and the
 +
two following bytes contain hinting information for antialiased displays and non-antialiased
 +
displays.
 +
 +
<-- high-order bits                      low-order bits -->
 +
[  0 0 0 0 0 0 0 D  |  0 0 0 0 0 0 A A  | 0 0 0 0 0 0 N N  ]
 +
                  |                \ /                \ /
 +
      antialiasing switch          |                  |
 +
                            hinting type          hinting type
 +
                      on antialiased displays    on non-antialiased displays
 +
 +
 +
The rendering hint types are as follows:
 +
 +
* '0' - unhinted, use only the font geometry
 +
* '1' - use FreeType's auto-hinter
 +
* '2' - use instructions in the font, if present
 +
* '3' - force automatic hinting
 +
 +
===Rendering Hint example===
 +
 +
Let's say we have a RenderHints-hack-value of 0x010203. This would then
 +
mean "use antialiasing, on antialiased displays use instructions in the
 +
font and on unantialiased displays force automatic hinting.

Latest revision as of 11:32, 23 August 2005

Nfonts packages

The Arts backend manages fonts using so-called nfonts.

Nfonts are hand-crafted directories with a plist file and the font files, where the backend can find additional information to the fonts.

System-wide available Nfont directories are usually installed to $GNUSTEP_SYSTEM_ROOT/Library/Fonts/.

Creating a nfont is mainly a trivial task, so there are tools to help you creating them. One of them is alexm's mknfonts package.

Example

A typical nfont folder - in this case Arial.nfont packaged by Jeff Teunissen (Deek) - looks like this:

Arial.nfont/
Arial.nfont/ariali.ttf
Arial.nfont/arial.ttf
Arial.nfont/arialbi.ttf
Arial.nfont/arialbd.ttf
Arial.nfont/FontInfo.plist
Arial.nfont/arialblk.ttf

This is the FontInfo.plist file in that directory:

{
    Description = "Monotype Arial, WGL4 Character Set";
    Faces = (
	{
	    Files = (
		arial.ttf
	    );
	    LocalizedNames = {
		Basque = Arrunta;
		Catalan = Normal;
		Danish = normal;
		Dutch = Standaard;
		English = Regular;
		Finnish = Normaali;
		French = Normal;
		Germany = Standard;
		Hungarian = "Norm\u00e1l";
		Italian = Normale;
		Norwegian = Normal;
		Polish = Normalne;
		Portuguese = Normal;
		Slovak = "Norm\u00e1lne";
		Slovene = Navadno;
		Spanish = Normal;
		Swedish = Normal;
		Turkish = Normal;
	    };
	    Name = Regular;
	    PostScriptName = ArialMT;
	    RenderHints_hack = 0x0002;
	    Traits = 0;
	    Weight = 5;
	},
	{
	    Files = (
		ariali.ttf
	    );
	    LocalizedNames = {
		English = Italic;
	    };
	    Name = Italic;
	    PostScriptName = "Arial-ItalicMT";
	    RenderHints_hack = 0x0002;
	    Traits = 1;
	    Weight = 5;
	},
	{
	    Files = (
		arialbd.ttf
	    );
	    LocalizedNames = {
		English = Bold;
	    };
	    Name = Bold;
	    PostScriptName = "Arial-BoldMT";
	    RenderHints_hack = 0x0002;
	    Traits = 2;
	    Weight = 9;
	},
	{
	    Files = (
		arialbi.ttf
	    );
	    LocalizedNames = {
		English = "Bold Italic";
	    };
	    Name = "Bold Italic";
	    PostScriptName = "Arial-BoldItalicMT";
	    RenderHints_hack = 0x0002;
	    Traits = 3;
	    Weight = 9;
	},
	{
	    Files = (
		arialblk.ttf
	    );
	    LocalizedNames = {
		English = Black;
	    };
	    Name = Black;
	    PostScriptName = "Arial-Black";
	    RenderHints_hack = 0x0002;
	    Traits = 2;
	    Weight = 12;
	}
    );
    FontCopyright = "Typeface \u00a9 The Monotype Corporation plc.\nData \u00a9 The Monotype Corporation plc/Type Solutions Inc. 1990-1992.\nAll Rights Reserved";
    Foundry = "Monotype Typography";
    Packager = "Jeff Teunissen <deek@d2dc.net>";
    Version = 2.82;
}

Rendering Hints

There's a hack for encoding rendering hints into Nfonts packages. You provide them using the RenderHints_hack value. It's a 24-bit value (usually given in hexadecimal form), where the highest-order byte contains information on if we want to use antialiasing by default and the two following bytes contain hinting information for antialiased displays and non-antialiased displays.

<-- high-order bits                       low-order bits -->
[  0 0 0 0 0 0 0 D  |  0 0 0 0 0 0 A A  | 0 0 0 0 0 0 N N  ]
                 |                 \ /                \ /
      antialiasing switch           |                  |
                            hinting type           hinting type
                     on antialiased displays    on non-antialiased displays


The rendering hint types are as follows:

  • '0' - unhinted, use only the font geometry
  • '1' - use FreeType's auto-hinter
  • '2' - use instructions in the font, if present
  • '3' - force automatic hinting

Rendering Hint example

Let's say we have a RenderHints-hack-value of 0x010203. This would then mean "use antialiasing, on antialiased displays use instructions in the font and on unantialiased displays force automatic hinting.