Translated from FreeType glyph conventions

Source: Internet
Author: User
Tags uppercase character

FreeType style conventions

I. Basic printing concepts
1. font files, formats, and information
Font is a group
Various character images that can be displayed and printed share some common features in a single font, including appearance, style, and line. According to the printing field, it must distinguish between a family of fonts and multiple types of fonts.
The latter generally comes from the same template, but the style is different. For example, palatino regular and palatino
Italic is two different appearances, but belongs to the same family of palatino.

A single font term can refer to both the family and the appearance according to the context. For example
Users of word processors use fonts to refer to different font families. However, most of these families use multiple data files based on their formats. For
For TrueType, it is usually a file of every appearance (Arial. TTF corresponds to Arial regular appearance, ariali. TTF corresponds to Arial
Italic appearance) This file is also called a font, but it is actually just a font appearance.

A digital font is a data file that can contain one or more fonts.
All contain Character Images, character measurements, and other important information about text layout and specific character encoding. For some difficult formats, such as Adobe type1, the appearance of a font is illustrated by several files.
Description (one containing character image, one containing character measurement, etc ). Here, we ignore this situation and only consider the appearance of a file. However, in ft2.0, it can process multi-file fonts.

For convenience, a font file containing multiple appearances is called a font set. This is rare, but most fonts in Asia are like this. They contain two or more representations of images, for example, horizontal and vertical la S.

2. character image and Graph
Word
A character image is called a font. Based on the writing, usage, and context, a single character can have multiple different images, that is, multiple fonts. Multiple characters can also have a font (such as Roman ??). Between character and font
The relationship may be very complex. I will not talk about it in this article. In addition, most font formats are stored and accessed using less difficult solutions. For the sake of clarity, keep the following ideas when explaining ft:

* A font file contains a group of fonts, each font can be saved as a bitmap, vector representation, or other structure (a more scalable format uses a combination of mathematical representation and control data/programs ). These fonts can be stored in any order in the font file, usually accessed through a simple font index.

*
A font file contains one or more tables, called character graphs. It is used to convert character codes into character-type indexes for certain character encodings, such as ASCII, Unicode, and big5. Possible packages for a single font file
Contains multiple character charts. For example, most TrueType font files contain an apple-Specific Character Chart and Unicode Character Chart, which can be used on both Mac and Windows platforms.
.

3. Character and font Measurement
Each character image is associated with multiple metrics and used to describe how to place and manage them when rendering text. They will be detailed later. They are related to the font position, cursor step, and text layout. They are important when calculating text streams when rendering a text string.

Each scalable font format also contains some global measurements, expressed in conceptual units, describing some of the characteristics of all fonts of the same appearance, such as the largest font box, the upstream, downstream, and text height of the font.

Although these measurements also exist in some non-scaling formats, they are only applied to a group of specified character dimensions and resolutions and are usually represented in pixels.

Ii. Shape Contour
1. pixel, point, and device resolution
When processing computer graphics programs, the physical size of the specified pixel is not square. Usually, the output device is a screen or printer, and there are multiple resolutions in both the horizontal and vertical directions. When rendering text, pay attention to these situations.

Set
The resolution of a device is usually expressed by DPI (DOT per inch). For example, the resolution of a printer is 300 x DPI, indicating that the resolution of each inch is in the horizontal direction.
Pixels, with 600 pixels in the vertical direction. A typical computer display has different resolutions based on its size (15 ''and 17'' display have different pixel sizes for 640x '').
The format resolution is also different.

Therefore, the text size is usually represented by a point, rather than a device-specific pixel. Point is a simple physical unit. In digital printing, a point is equal to 1/72 inch. For example, most books in Rome use texts ranging from 10 to 14.

You can use the number of points to calculate the prime number. The formula is as follows:

Elephant prime number = points * Resolution/72

The resolution is represented by DPI. Because the horizontal and vertical resolutions can be different, the width and height of different pixel texts are usually defined for a single point.

2. Vector Representation
The source format of a font profile is a closed set of paths called outlines. Each contour line defines the external or internal area of the glyph, which can be a line segment or a bezr curve.

Qu
The line is defined by the control point. Based on the font format, it can be a quadratic (CONIC beziers) or cubic (cubic beziers) polynomial. In the document, Conic
Betillers are generally called quadratic beziers. Therefore, each point in the outline has a flag indicating whether it is of the general type or a control point, which scales the entire outline.

The initial contour points of each font are placed in the grid of an inseparable unit. The points are usually stored in 16 integer grid coordinates in the font file, and the origin of the grid is (0, 0 ), its range is-16384 to 16383 (although some formats such as type1 use floating point type, we agree to use integer Analysis for simplicity ).

The orientation of the grid is the same as that of the traditional two-dimensional plane of mathematics. the X axis is left to right, and the Y axis is bottom to top.

When creating a font profile, a font designer uses an imaginary square called an EM square. He can think of it as a plane that draws characters. The size of a square, that is, the grid unit with the side length, is very important because

* It is a reference for scaling a contour to a specified text size. For example, the 12pt size in 300/72 x dpi corresponds to 12 x = 50 pixels. You can use the following formula to scale a grid unit to a pixel.

Elephant prime number = point X resolution/72
Pixel coordinate = grid coordinate * elephant prime number/EM size

* The larger the EM size, the larger resolution can be achieved. For example, in an extreme example, a 4-unit EM has only 25 points, which is obviously not enough, generally, the TrueType font uses the 2048-unit em; The type1 PostScript font has a fixed 1000-unit em, but the coordinate can be expressed as a floating point value.

Note that the font can freely exceed the EM square. Grid units are usually staggered font units or em units. The above prime number does not refer to the actual character size, but the size displayed by the EM square. Therefore, although the same size is different in different fonts, their heights may be different.

3. hinting and bitmap Rendering
The outline stored in a font file is called the "Main" Contour. Its coordinate points are represented by the font unit. When it is converted into a bitmap, it must be scaled to the specified size. This is done through a simple conversion, but it will always produce some unwanted side effects, such as letters E and H, their trunk width and height will be different.

Institute
To scale a grid-fitting operation (usually hinting) in a grid-fitting process, you need to align them to the pixels of the target device.
Grid. One of the main purposes is to ensure that the important width and height of the entire font are consistent. For example, for characters I and T, the vertical strokes must keep the same pixel width. In addition, it aims
There are features such as stem and Overshoot management, which may cause some problems in the image font.

There are several ways to handle grid alignment. In most zooming formats, each glyph profile has some control data and programs.

* Explicit grid alignment

The TrueType format defines a stack-based Virtual Machine (VM) that can be programmed with more than 200 medium operation codes (mostly geometric operations). Each glyph consists of a profile and a control program, the latter can handle the actual grid alignment, which is defined by the font designer.

* Implicit grid alignment (also known as hinting)

The type1 format has a simpler method. each glyph consists of a contour and several hints. The latter describes some important features of the glyph, for example, the existence of the trunk, some width symmetry, and so on. There are not many hint types, depending on how the Renderer interprets hint to generate an alignment profile.

* Automatic grid alignment

Some formats are simple and do not include control information. The font measurements are separated by step, width, and height. The Renderer is used to guess the characteristics of the contour to achieve proper grid alignment.

The advantages and disadvantages of each solution are summarized below

Advantages and disadvantages

Explicit quality: it has good results for small fonts, which is very important for screen display. Speed: if the program is complex, the bytecode is interpreted very slowly.
Consistency: All Renderer generate the same font bitmap. Size: the font size is very long.
Technical difficulty: it is very difficult to compile excellent hinting programs, and there is no good tool support.

Implicit size: hint is usually much smaller than the explicit font size: the small font is not good.
Speed: Grid alignment is fast and inconsistent: Different Renderer results are different, and even different versions of the same engine are different.

Automatic size: No need to control the information, resulting in smaller font file quality: small font is not good, and finally combined with reverse sample
Speed: dependent on the alignment algorithm, which is usually faster than explicit alignment. Speed: Dependent Algorithm
Inconsistent: Different Renderer results are different, and even different versions of the same engine are different.

Iii. Shape Measurement
1. Baseline, pen, and Layout)
A baseline is a hypothetical line used to know the font when rendering text. It can be horizontal (such as Roman) or vertical (such as Chinese ). Furthermore, in order to render the text, there is a virtual point on the baseline, called the pen position or origin, which is used to locate the font.

Different la s are used for different la s:

* For horizontal layout, the glyphs are simply placed on the baseline and the text can be rendered by adding a pen position, either to the right or to the left.

The distance between two adjacent pen locations is different based on the font, called the step width (advance width ). Note that this value is always a positive number, even if the characters are arranged from right to left, such as Arabic. This is different from the text rendering method.

The pen position is always placed on the baseline.

* For vertical layout, the font is placed in the center of the baseline:

2. Printing measurement and border Frame
Multiple appearance measurements are defined in the specified font.

* The uplink height (ascent ). The mesh coordinate from the baseline to the top/side of the placed contour point is a positive value because the Y axis is upward.

* Descent ). From the baseline to the grid coordinate at the lowest/Bottom of the contour point, because the Y axis is upward, It is a negative value.

* Line spacing (linegap ). The required distance between the two texts. The distance from the baseline to the baseline should be calculated

Uplink height-downlink height + line spacing

*
Bounding
Box, bBox ). This is an imaginary box, which is loaded as closely as possible into the shape. It is represented by four values: xmin, ymin, xmax, and Ymax.
They can be a font unit (measuring the original contour) or an integer pixel unit (measuring the scaled contour ). Note: if it is not for grid alignment, you don't need to know the value of this box, you just need to know its
Size. However, to correctly render an alignment, you need to save the important alignment for converting and placing each alignment on the baseline.

* Internal leading. This concept comes from the traditional printing industry. It represents the number of EM square spaces in the shape, which is usually calculated as follows:

Internal leading = ascent-descent-em_size

* External leading. The alias of the line spacing.

3. Bearing and stepping
Each shape has a distance between a span and a step. They are defined as constants, but their values depend on the layout. The same shape can be used to render horizontal or vertical text.

* Left SPAN or bearingx. The horizontal distance from the current pen position to the left bBox boundary of the font. The horizontal layout is positive, and the vertical layout is mostly negative.

* Upper SPAN or bearingy. The vertical distance from the baseline to the boundary on the bBox is positive for the horizontal layout and negative for the vertical layout.

* Step width or advancex. After processing a text rendering, the pen position must increase (from left to right) or decrease (from right to left) the horizontal distance. The horizontal layout is always positive, and the vertical layout is null.

* Step height or advancey. After each glyph is rendered, the vertical distance between the pen position must be reduced. The horizontal layout is null, and the vertical layout is always positive.

* The font width. Horizontal length of the font. For UN-scaled font coordinates, It is bBox. xMax-bbox.xMin, for the scaled font, its calculation depends on the specific situation, depending on the grid alignment.

* The font height. Vertical length of the font. For UN-scaled font coordinates, It is bBox. yMax-bbox.yMin, for the scaled font, its calculation depends on the specific situation, depending on the grid alignment.

* Right span. It is used only for horizontal layout and describes the distance from the right side of bBox to the stepping width. It is usually a non-negative value.

Advance_width-left_side_bearing-(xmax-xmin)

All measurements of horizontal layout

Is the measurement of vertical layout

4. Grid alignment Effect
Because
For hinting, the control point of the font is aligned to the Pixel Grid. This process slightly modifies the size of the character image, which is different from the simple scaling. For example, the image of lowercase letter M is sometimes
A square, but hinting tries to expand its scaled profile so that it can be distinguished by its three legs, which leads to a larger bitmap.

The font measurement is also affected by the grid alignment process:

* The width and height of the image have changed. Even if it is just a pixel, the differences between the font size and the font size of the image are very large;

* The border box of the image is changed, and the span is also changed;

* The step must be changed. For example, if the bitmap to be hint is larger than the scaled bitmap, the step width must be increased to reflect the expanded font width.

This has the following meanings,

* Because of hinting, simple zooming of the font's uplink or downlink height may not produce correct results. One possible method is to keep the top of the scaled uplink height and the bottom of the scaled downlink height.

* There is no easy way to remove the glyphs within a range of hint and step them in width, because hinting works differently for each profile. Each hint is a unique hint and the return value is recorded. Some formats, such as TrueType, include some tables to calculate their pixel size for some common characters in advance.

* Hinting depends on the pixel value of the final character width and height, which means that it is very dependent on resolution. This feature makes the correct WYSIWYG layout very difficult to implement.

At ft
It is easy to process the 2D transformation of the hex contour. However, for an hint contour, note that the integer pixel distance (meaning ft_outline_translate () must be used exclusively ()
Function parameters should be multiplied by 64, because the coordinate points are all 26.6 fixed floating point format). Otherwise, the transformation will destroy hinter's work, resulting in a very ugly bitmap.

5. Text width and border box
As shown above, it is not necessary to locate an angle in the shape boundary box when the source point of the specified font corresponds to the position of the base line pen. This is not similar to most typical bitmap font formats. In some cases, the origin can be outside the boundary frame or inside, depending on the given shape.

Similarly, the step width of the font is the increment applied to the pen position during layout, instead of the font width, which is the width of the boundary of the font. It has the same protocol for text strings, which means:

* The border box of the specified text string does not need to contain the text cursor, nor does the font behind it need to be placed on its corner.

* The step width of a string has nothing to do with the size of its border box. In particular, it contains spaces or tabs at the beginning and end.

* Finally, additional processing, such as padding adjustment, allows you to create text strings. The size of a text string does not directly depend on individual font measurements in parallel. For example, the step width of VA is not the sum of the steps of V and.

4. Padding Adjustment
The term "padding adjustment" refers to the specific information used to adjust the relative position of the coincident font in a text string.

1. Adjust the padding
Padding adjustment includes modifying the distance between adjacent glyphs based on their outlines. For example, T and Y can be closer to each other, because the upper margin of Y is exactly at the bottom of the top right corner of T.

When the text is laid out based on the standard width of the font, some consecutive characters seem a little too crowded and loose. For example, the distance between A and V is too long.

In comparison, the distance between A and V in the same word is closer.

As you can see, this adjustment can lead to a big difference. Some font appearances contain a table that contains the distance between the specified font pairs required for text layout.

* This pair is ordered, and the distance between the AV pair is not necessarily the same as that of the VA pair;

* Based on the layout or writing, the padding can represent the horizontal or vertical direction.

* The distance is represented as grid units. They are usually in the X axis direction, meaning that a negative value indicates that the two fonts need to be closer in the horizontal direction.

2. Apply the padding Adjustment
It is a simple process to apply the Data Adjustment During text rendering. You only need to add the scaled distance to the pen position when writing the next font. However, the correct Renderer should be more detailed.

The "slide point" problem is a good example: Many font appearances include an uppercase character (such as t, F) and a dot. to place the point on the right of the main leg of the former.

According to the character shape, sometimes it is necessary to add adjustments between the points and subsequent characters. When the "standard" padding adjustment is applied, the above sentence is as follows:

This is obviously too compact. One solution is to slide points only when needed. Of course, you need to understand the meaning of the text. If we were to render the last point of a specific paragraph, the above adjustment would not be appropriate. This is just an example, and many other examples show that a real printer needs to properly layout the text.

There is a simple algorithm that can avoid sliding points.

1. Place the first font on the base line;
2. Save the pen position to pen1;
3. Adjust the pen position based on the distance between the first and second glyphs;
4. Place the second font, calculate the next position, and place it in pen2;
5. If pen1 is greater than pen2, use pen1 as the next pen position; otherwise, use pen2.

V. Text Processing
1. Write simple text strings
In the first example, we will generate a simple Roman text string, that is, horizontal left-to-right layout and proprietary pixel measurement. The process is as follows:

1. convert a string into a series of font indexes;
2. Place the pen at the cursor position;
3. Obtain or load a font image;
4. Translate the font to match the position of the start point;
5. render the font to the target device;
6. Add the pen position based on the step pixel of the font;
7. Perform step 3 on the remaining glyphs;
8. When all the glyphs are processed, set the text cursor at the new pen position.

Note that the padding adjustment is not in this algorithm.

2. sub-pixel location
It is sometimes useful to use sub-pixel location when rendering text. This is very important. For example, to provide a semi-WYSIWYG text layout, the text rendering algorithm is similar to the previous section, but there are some differences:

* The pen position is represented as a decimal pixel;
* If you translate an existing hint contour into a non-integer distance, the grid alignment is broken. The position of the font origin must be rounded before rendering the character image;
* The step width is represented as a decimal pixel without an integer.

Here is the improved version of the algorithm:

1. convert a string into a series of font indexes;
2. Place the pen at the cursor position, which can be a non-integer point;
3. Obtain or load a font image;
4. Shift the font to match its origin point with the position of the entire pen;
5. render the font to the target device;
6. Increase the pen position based on the step pixel width of the font. The width can be in decimal form;
7. Perform step 3 on the remaining glyphs;
8. When all the glyphs are processed, set the text cursor at the new pen position.

Note that after positioning by decimal pixels, the space between two specified characters is not fixed. It is determined by the number of accumulated operations in the previous round operation on the right.

3. Simple padding Adjustment
It is very easy to add a padding adjustment to the basic text rendering algorithm. When a padding adjustment is found, simply add the scaled adjustment distance to the pen position before the 4th step. However, this distance needs to be rounded up in algorithm 1, and algorithm 2 is unnecessary.

4. layout from right to left
The layout of the Arabic or heberw text process is very similar, the difference is that before the font rendering, the pen position needs to be reduced (remember that the step width is always positive)

5. vertical layout
The layout of vertical text is the same process. The important differences are as follows:

* The baseline is vertical. Vertical measurements are used instead of horizontal measurements;
* The left span is usually negative, but the font origin must be in the baseline;
* The stepping height is always positive, so the pen position must be reduced to write from top to bottom;

6. Wysiwyg Layout

Vi. FT Contour
1. FT profile description and Structure
A. contour curve Decomposition
A contour is a series of closed contour lines on a 2D plane. Each contour line is composed of a series of line segments and bezr arcs. The curve can be quadratic and cubic polynomials according to different file formats. The former is quadratic or CONIC arc, which are used in TrueType format, the latter is called cubic arc, which is mostly used in type1 format.

Each arc is described by a series of starting points, ending points, and control points. each point in the contour has a specific mark, indicating that it is used to describe a line segment or an arc. This tag can have the following values:

Ft_curve_tag_on points on the curve, which corresponds to the start and end points of the Line Segment and the arc. The other mark is called the "off" point, that is, it is not in the contour line, but serves as the control point of the bezr arc.
Ft_curve_tag_conic: one off point, which controls one conic besuppliers arc.
Ft_curve_tag_cubic: one off point, which controls a cubic beserx arc.

The following rule is used to divide a contour point into a line segment and an arc.

* Two Adjacent "on" points represent a line segment;
* A Conic off point indicates a conic besuppliers arc between two on points. The off point is the control point, and the on point is the start point and end point;
* Two Adjacent cubic off points represent a cubic besuppliers arc between two on points, which must have two cubic control points and two on points.
* Finally, two adjacent conic off points are forced ?? Create a virtual on point between them. This greatly facilitates the definition of consecutive conic arcs. The TrueType specification is defined in this way.

 

Note that conic and cubic arc can be used together in a single contour line, but there is no such font-driven outline.

B. Profile Descriptor
FT profile is described by a simple structure

Ft_outline
Points in the n_points Contour
Number of contour lines in n_contours Contour
Points coordinate Array
Contours contour endpoint Index Array
Tags point mark Array

Here, points is a pointer to an ft_vector record array to store the vector coordinates of each contour point. It is represented as 1/64 pixels, also known as 26.6 fixed floating point format.

Contours is a set of point indexes used to define the contour of a contour. For example, the first contour always starts from 0 and ends with contours [0. The second contour line starts from contours [0] + 1 and ends with contours [1.

Note that each line is closed and n_points should be the same as S [n_controus-1] + 1. Finally, tags is a group of bytes used to store the dot mark of each contour.

2. Boundary and control box Calculation
Edge
A boundary box (bBox) is a rectangle that completely contains the specified contour. It requires the smallest boundary box. Because of the definition of the arc, the control points of the besuppliers do not need to be included in the boundary box of the contour. For example, the top of a contour is
The arc of a bezeiser, where the off point is located on the top of the bBox. However, this rarely appears in Character outlines, because most font designers and creation tools place an on point at each Curve Inflection Point,
This makes hinting easier. So we defined the control box (cbox), which is the smallest rectangle that contains all vertices of the contour. Obviously, it contains bBox, which is usually the same. No
BBox and cbox are computed very quickly.

Unlike the bBox, The cbox is much faster to compute.

Control
You can use the ft_outline_get_cbox () and
Ft_outline_get_bbox () is automatically calculated. The former is always very fast, and the latter is slower when there are external control points, because the end Of the conic and cubic arc needs to be found.
If this is not the case, it is as fast as the computing control box.

Note that although the big multi-font contours are easy to hint with the same cbox and bBox, this is no longer the case after they are transformed, such as rotation.

3. Coordinates, scaling, and grid alignment
Vector coordinates of a contour point are expressed in the 26.6 format, that is, 1/64 of a pixel. Therefore, coordinates (1.0,-2.5) are used to store integer pairs (X: 64, Y:-192 ).

After the main font contour scales from the EM mesh to the current character size, hinter is responsible for alignment of important contour points to the pixel mesh. Although this process is difficult to say clearly, it aims to take the position of the entire point to maintain the important characteristics of the font, such as width and trunk. The following operations can be used to round the vector distance in the 26.6 format to the grid:

Round (x) = (x + 32) &-64
Floor (x) = x &-64
Ceiling (x) = (x + 63) &-64

Once a contour is aligned or transformed, the pixel size of the image is usually calculated before rendering. To do this, you must consider the following:

The scanline converter draws all the pixels in the center in the font shape. It can also detect the drop-outs ???

This results in the following calculation:

* Calculate bBox;
* Alignment bBox:
Xmin = floor (bBox. xmin)
Xmax = ceiling (bBox. xmax)
Ymin = floor (bBox. ymin)
Ymax = ceiling (bBox. Ymax)
* Returns the pixel size, that is
Width = (xmax-xmin)/64
And
Height = (Ymax-ymin)/64

By alignment bBox, we can ensure that all pixel centers will be painted, including those controlled from drop-out, which will be included in the adjusted box. Then, the pixel size of the box can be calculated.

At the same time, when translating an alignment profile, you should always use the integer distance to move. Otherwise, the edges of the shape are no longer aligned with the pixel mesh, and hinter's work will be ineffective, resulting in a very ugly bitmap.

VII. FT bitmap
1. Comparison of vector coordinates and pixel coordinates
The differences between the pixel coordinates of vector coordinates are described here. For a clearer description, square brackets are used to represent the pixel coordinates and parentheses are used to represent the vector coordinates.

In pixel coordinates, we use the y-axis-up algorithm. The coordinates [] Always indicate the pixels in the lower left corner of the bitmap. The coordinates [width-1, rows-1] are the pixels in the upper right corner. In vector coordinates, point coordinates are expressed in floating point units, such as (1.25,-2.3). This position is not a specific pixel, but a non-substantive point on the 2D plane.

Image
A prime is actually a square on the 2D plane, and its center is half of the pixel coordinate value. For example, the pixel in the lower left corner of the bitmap is defined by the square ()-(), and its center is located in
(0.5, 0.5 ). Note that vector coordinates are used here. This makes some difference to the calculation distance. For example, [0, 0]-[10.0] The pixel length of a line is 11. However,
(0, 0)-(10, 0) the vector degree covers 10 pixels, so its length is 10.

 

2. FT bitmap and pixel map Descriptor
A bitmap and a pixel map are described in a single structure called ft_bitmap, which is defined in <FreeType/ftimage. h>. The attributes are as follows:

Ft_bitmap
The number of rows, that is, the number of horizontal lines in the bitmap.
The horizontal Prime Number of the width bitmap.
The absolute value of pitch is the number of bytes occupied by each row of the bitmap. It can be a positive or negative value based on the bitmap vector direction.
Buffer: A non-type pointer pointing to the bitmap Pixel Buffer.
An enumerated value of pixel_mode is used to represent the pixel format of a bitmap. For example, ft_pixel_mode_mono indicates a 1-Bit Bitmap, and ft_pixel_mode_grays indicates an 8-bit reversed gray value.
Num_grays is only used in the gray-level pixel mode. It describes the gray-level series of the reversed image. The default value of FT is 255.

Pitch
The positive and negative symbols of the attribute values determine whether rows in the pixel buffer are stored in ascending or descending order. As mentioned above, FT always points to the lower left corner of the bitmap by using the Y axis to the upper right of the 2D plane. If
Picth is a positive value. rows are stored in the direction reduced by vectors. That is, the first byte of the Pixel Buffer represents the part of the top row of the bitmap. If it is a negative value, the first byte indicates the part of the bottom row of the bitmap. For all
Pitch can be seen as a byte increment that jumps to the next scan row in the specified bitmap buffer.

Normal pitch is usually used, and some systems use negative values.

3. contour conversion in-place and pixel charts
Using ft to convert a map from a vector image to a map in place and a pixel map is very simple. However, before conversion, you must understand the issues related to placing a contour on a 2D plane:

* When the font reprinter and hinter place outlines on a 2D plane, they always match (0, 0) to the character origin, which means the contour of the font and the corresponding boundary frame, it can be placed anywhere in the plane.

* The target bitmap maps to the 2D plane, and the lower left corner is (). This means that a [W, H] bitmap and the pixel map will be mapped) -A 2D rectangle window defined by (W, H.

* When scanning and converting the contour, all the parts in this bitmap window will be rendered, and others will be ignored.

Many developers who use FT may misunderstand that a loaded profile can be directly rendered into a bitmap of an appropriate size. The following image shows this problem.

* The first chart shows a loaded contour on a 2D plane;

* The second window Indicates a target window maintained at any size [W, H;

* The third represents the combination of outlines and windows on a 2D plane;

* The last part indicates the part actually rendered by the bitmap.

In fact, in almost all cases, the loaded or transformed contour must be translated before being rendered as the target bitmap to adjust the position of the target window.

For example, the correct method for creating a separate font bitmap is as follows:

* Calculate the size of a glyph bitmap, which can be calculated directly from the glyph measurement or its boundary frame (this is useful after transformation, and the glyph measurement is no longer valid at this time ).

* Create a bitmap based on the calculated size. Do not forget to fill the Pixel Buffer with the background color;

* Translate the contour to make the lower left corner match (0, 0 ). Do not forget to use an integer for hinting. Usually, this means to translate a vector (-round (xmin),-round (ymin )).

* Call the rendering function, such as the ft_outline_render () function.

When a font image is directly written into a large bitmap, the outlines must be translated to map their vector locations to the current text cursor/character origin.

Good communication skills and positive actions are the key to success.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.