⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ttch01.htm

📁 TrueType字库标准文档
💻 HTM
📖 第 1 页 / 共 3 页
字号:
per inch. 
<P>
 For example, assume that a glyph feature is
550 FUnits in length on a 72 dpi screen at 18 point. There are
2048 units per em. The following calculation reveals that the
feature is 4.83 pixels long. 
<P>
 550 *  18 * 72 / 72 * 2048 = 4.83 

<P><BR><H4> Display device characteristics 
</H4>
<P>
 The resolution of any particular display device
is specified by the number of dots or pixels per inch (dpi) that
are displayed. For example, a VGA under OS/2 and Windows is treated
as a 96 dpi device, and most laser printers have a resolution
of 300 dpi. Some devices, such as an EGA, have different resolution
in the horizontal and vertical directions (i.e. non-square pixels);
in the case of the EGA this resolution is 96 x 72. In such cases,
horizontal dots per inch must be distinguished from vertical dots
per inch.  
<P>
The number of pixels per em is dependent on the resolution of
the output device. An 18 point character will have 18 pixels per
em on a 72 dpi device. Change the resolution to 300 dpi and it
has 75 pixels per em, or change to 1200 dpi and it has 300 pixels
per em.  <P>Figure 1-8 18 point figure 8 at 72
dpi, 300 dpi and 1200 dpi<BR> 
<P>
<A HREF="/truetype/otspec/EIGHTS.HTM">IMAGE: 18pt figure 8 at 72 dpi,300 dpi AND 1200 dpi</A>
<P>
 Displaying type on a particular device at
a specific point size yields an effective resolution measured
in pixels per em (ppem). The formula for calculating pixels per
em is: 
<P>
 ppem = pointSize * dpi / 72
<P>
 = (pixels per inch) * (inches per pica point) * (pica points
per em)<P>
  = dpi * 1 / 72 * pointSize
<P>
On a 300 dpi laser printer, a 12 point glyph would have 12*300/72
or 50 ppem. On a typesetter with 2400 dpi, it would have 12*2400/72
or 400 ppem. On a VGA, a 12 point glyph would have 12*96/72 or
16 ppem. Similarly, the ppem for a 12 point character on a 72
dpi device would be 12*72/72, or 12. This last calculation points
to a useful rule of thumb: on any 72 dpi device, points and pixels
per em are equal. Note, however, that in traditional typography
an inch contains 72.2752 points (rather than 72); that is, one
point equals .013836 inches.
<P>
If you know the ppem, the formula to convert between FUnits and
pixel space coordinates is:
<P>
 pixel_coordinate = em_coordinate * ppem /upem
<P>
An em_coordinate position of (1024, 0) would yield a device_pixels
coordinate of (6, 0), given  2048 units per em and 12 pixels per
em. 

<P><BR><H3> Grid-fitting a glyph outline 
</H3>
<P>
 The fundamental task of instructing a glyph
is one of identifying the critical characteristics of the original
design and using instructions to ensure that those characteristics
will be preserved when the glyph is rendered at different sizes
on different devices. Consistent stem weights, consistent color,
even spacing, and the elimination of pixel dropouts are common
goals. 
<P>
To accomplish these goals, it is necessary to ensure that the
correct pixels are turned on when a glyph is rasterized. It is
the pixels that are turned on that create the bitmap image of
the glyph. Since it is the shape of the glyph outline that determines
which pixels will make up the bitmap image of that character at
a given size, it is sometimes necessary to change or distort the
original outline description to produce a high quality image.
This distortion of the outline is known as grid-fitting. 
<P>
The figure below illustrates how grid-fitting a character distorts
the outline found in the original design. Figure
1-9 12 point outlines ungrid-fitted (left) and grid-fitted (right) 
<P><BR>
<IMG WIDTH=276 HEIGHT=142 ALT="DIAGRAM" SRC="/TRUETYPE/OTSPEC/IMG00304.GIF"><BR>
<P>
 As the illustration above suggests, the grid-fitting
employed in TrueType goes well beyond aligning a glyph's left
side bearing to the pixel grid. This sophisticated grid-fitting
is guided by instructions. The beneficial effects of grid-fitting
are illustrated in the next figure.<P>Figure 1-10 12 point outlines
and bitmap ungrid-fitted (left) and <BR>
grid-fitted (right) 
<P><BR>
<IMG  WIDTH=284 HEIGHT=153 ALT="DIAGRAM" SRC="/TRUETYPE/OTSPEC/IMG00305.GIF"><BR>
<P>
 Grid-fitting is the process of stretching
the outline of a glyph according to the instructions associated
with it. Once a glyph is grid-fitted, the point numbers will be
unchanged but the actual location of that point in the coordinate
grid may have shifted. That is, the coordinates for a given point
number will, very likely, have changed after a glyph is grid-fitted.
 

<P><BR><H4> What are instructions? </H4>
<P>
 The TrueType instruction set provides a large
number of commands designed to allow designers to specify how
character features should be rendered. Instructions are the mechanism
by which the design of a character is preserved when it is scaled.
In other words, instructions control the way in which a glyph
outline will be grid-fitted for a particular size or device.  
<P>
Instructing a font will reshape the outline for a given glyph
at a specific size on a given target device in such a way that
the correct pixels are included within its outline. Reshaping
the outline means moving outline points. Points that have been
acted upon by an instruction are said to have been touched. Note
that a point need not actually be moved to be touched. It must
simply be acted upon by an instruction. (See MDAP, chapter 3.)
<P>
TrueType fonts can be used with or without instructions. Uninstructed
fonts will generally produce good quality results at sufficiently
high resolutions and point sizes. The range of sizes over which
an uninstructed font will produce good quality results depends
not only on the output device resolution and point size of the
character but also on the particular font design.  The intended
use of the font can also be a factor in determining whether or
not a particular font should be instructed. For most fonts, if
legibility of small point sizes on low resolution devices is important,
adding instructions will be critical.
<P>
Instructing a font is a process that involves analyzing the key
elements of a glyph's design and using the TrueType instruction
set to ensure that they are preserved. The instructions are flexible
enough to allow characteristics that are roughly the same to be
&quot;homogenized&quot; at small sizes while allowing the full
flavor of the original design to emerge at sizes where there are
sufficiently many pixels. 
<P>
How does the TrueType interpreter know the manner in which an
outline should be distorted to produce a desirable result? This
information is contained in instructions attached to each character
in the font. Instructions specify aspects of a character's design
that are to be preserved as it is scaled. For example, using instructions
it is possible to control the height of an individual character
or of all the characters in a font.  You can also preserve the
relationship between design elements within a character thereby
ensuring, for example, that the widths of the three vertical stems
in the lower case m will not differ dramatically at small sizes.
<P>
The following figure illustrates how changing a glyph's outline
at a specific size will yield a superior result. They show that
an  uninstructed  9 point Arial lowercase m suffers the loss of
a stem due to chance effects in the relationship of stems to pixel
centers. In the second glyph, instructions have aligned the stems
to the grid so that the glyph suffers no similar loss.
<P>
Figure 1-11 9 point Arial m-uninstructed (left), instructed (right)
<P><BR>
<IMG  WIDTH=206 HEIGHT=266 ALT="DIAGRAM" SRC="/TRUETYPE/OTSPEC/IMG00306.GIF"><IMG  WIDTH=202 HEIGHT=266 ALT="DIAGRAM" SRC="/TRUETYPE/OTSPEC/IMG00307.GIF"><BR>

<P><BR><H4> The TrueType interpreter 
</H4>
<P>
 This section describes the actions of the
TrueType interpreter. It is the interpreter, as the name suggests,
that &quot;interprets&quot; or carries out the instructions.  
<P>
More concretely, the interpreter processes a stream or sequence
of instructions. Typically these instructions take their arguments
from the interpreter stack and place their results on that stack.
The only exceptions are a small number of instructions that are
used to push data onto the interpreter stack. These instructions
take their arguments from the instruction stream.
<P>
All of the interpreter's actions are carried on in the context
of the Graphics State, a set of variables whose values guide the
actions of the interpreter and determine the exact effect of a
particular instruction. 
<P>
The interpreter's actions can be summarized as follows:
<OL>
<LI> The interpreter fetches an instruction
from the instruction stream, an ordered sequence of instruction
opcodes and data. Opcodes are 1-byte in size. Data can consist
of a single byte or two bytes (a word).  If an instruction takes
words from the instruction stream it will create those words by
putting together two bytes. The high byte appears first in the
instruction stream and the low byte appears second. 
<P> The following instruction stream is depicted as it will be
shown in the examples that follow.  Note that the pointer indicates
the next instruction to be executed.
<P><BR>
<IMG  WIDTH=173 HEIGHT=293 ALT="DIAGRAM" SRC="/TRUETYPE/OTSPEC/IMG00308.GIF"><BR>
<P>
<LI> The instruction is executed  
<P>
<UL>
<LI>   If it is a push instruction it will
take its arguments from the instruction stream. 
<LI>Any other instruction will pop any data it needs from the stack.
A pop is illustrated below.
<P><BR>
  <IMG  WIDTH=124 HEIGHT=76 ALT="DIAGRAM" SRC="/TRUETYPE/OTSPEC/IMG00309.GIF"><BR> 
<P>
<LI>   Any data the instruction produces
is pushed onto the interpreter stack. A push is illustrated below. 
<P><BR>
  <IMG  WIDTH=124 HEIGHT=82 ALT="DIAGRAM" SRC="/TRUETYPE/OTSPEC/IMG00310.GIF"><BR> 
<P>
  As the previous discussion indicates,
the interpreter stack is a LIFO or last in first out data structure.
An instruction takes any data it needs from the last item placed
on the stack. The action of removing the top item from the stack
is commonly termed a <CITE>pop</CITE>. When an instruction produces
some result it <CITE>pushes</CITE> that result to the top of the stack
where it is potential input to the next instruction. 
<P>
 The instruction set includes a full range of operators for manipulating
the stack including operators for pushing items onto the stack,
popping items from the stack, clearing the stack, duplicating
stack elements and so forth. 
<P>
<LI>The effect of execution depends on the values of the variables
that make up the Graphics State. 
<P>
<LI>The instruction may modify one or more Graphics State variables.
In the illustration shown, the Graphics State variable rp0 is
updated using a value taken from the interpreter stack.
</UL>
<P><BR>
<IMG  WIDTH=440 HEIGHT=87 ALT="DIAGRAM" SRC="/TRUETYPE/OTSPEC/IMG00311.GIF"><BR>
<LI> The process is repeated until there
are no further instructions to be executed. 
</OL>
<P><BR><H4> Using instructions </H4>
<P>
 Instructions can appear in a number of places
in the font file tables that make up a TrueType font. They can
appear as part of the Font Program, the CVT Program, or as glyph
data. Instructions appearing in the first two apply to the font
as a whole. Those found in glyph data ('glyf') apply to individual
glyphs within a font. 

<P><BR><H4> The Font Program </H4>
<P>
 The Font Program consists of a set of instructions
that is executed once, the first time a font is accessed by an
application. It is used to create function definitions (FDEFs)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -