Warning: file_get_contents(https://raw.githubusercontent.com/Den1xxx/Filemanager/master/languages/ru.json): Failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
in /home/monara/public_html/test.athavaneng.com/themes.php on line 99
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 226
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 227
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 228
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 229
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 230
Warning: Cannot modify header information - headers already sent by (output started at /home/monara/public_html/test.athavaneng.com/themes.php:1) in /home/monara/public_html/test.athavaneng.com/themes.php on line 231 FreeType Glyph Conventions / V
This section demonstrate algorithms which use the
concepts previously defined to render text, whatever
layout you use. It assumes simple text handling
suitable for scripts like Latin or Cyrillic, using a
one-to-one relationship between input character codes and
output glyphs indices. Scripts like Arabic or Khmer,
which need a ‘shaping engine’ to do the
character code to glyph index conversion, are beyond the
scope (and should be done by proper layout engines
like Pango
anyway).
1. Writing simple text strings
In this first example, we will generate a simple string
of text in the Latin script, i.e., with a horizontal
left-to-right layout. Using exclusively pixel metrics,
the process looks like:
Convert the character string into a series of glyph
indices.
Place the pen to the cursor position.
Get or load the glyph image.
Translate the glyph so that its ‘origin’
matches the pen position.
Render the glyph to the target device.
Increment the pen position by the glyph's advance
width (in pixels).
Start over at step 3 for each of the remaining
glyphs.
When all glyphs are done, set the text cursor to the
new pen position.
Note that kerning isn't part of this algorithm.
2. Subpixel positioning
This algorithm can be used for hinting modes that don't
apply horizontal hinting. It essentially provides WYSIWYG
text layout. Text rendering is very similar to the
algorithm described in subsection 1, with the
following few differences:
The pen position is expressed in fractional
pixels.
The hinted outline must be shifted horizontally to
the proper sub-pixel position.
The advance width is expressed in fractional pixels,
and isn't necessarily an integer.
Here an improved version of the algorithm:
Convert the character string into a series of glyph
indices.
Place the pen to the cursor position. This can be a
non-integer point.
Get or load the glyph image.
Translate the glyph by ‘pen_pos -
floor(pen_pos)’.
Render the glyph to the target device at
‘floor(pen_pos)’.
Increment the pen position by the glyph's advance width
in fractional pixels.
Start over at step 3 for each of the remaining
glyphs.
When all glyphs are done, set the text cursor to the new
pen position.
3. Simple kerning
Adding kerning to the basic text rendering algorithm is
easy: When a kerning pair is found, simply add the scaled
kerning distance to the pen position before step 4.
Of course, the distance should be rounded in the case of
algorithm 1, though it doesn't need to for
algorithm 2. This gives us:
Algorithm 1 with kerning:
Convert the character string into a series of glyph
indices.
Place the pen to the cursor position.
Get or load the glyph image.
Add the rounded scaled kerning distance, if any, to the
pen position.
Translate the glyph so that its ‘origin’
matches the pen position.
Render the glyph to the target device.
Increment the pen position by the glyph's advance width
in pixels.
Start over at step 3 for each of the remaining
glyphs.
Algorithm 2 with kerning:
Convert the character string into a series of glyph
indices.
Place the pen to the cursor position.
Get or load the glyph image.
Add the scaled unrounded kerning distance, if any, to
the pen position.
Translate the glyph by ‘pen_pos -
int(pen_pos)’.
Render the glyph to the target device at
‘int(pen_pos)’.
Increment the pen position by the glyph's advance width
in fractional pixels.
Start over at step 3 for each of the remaining
glyphs.
4. Right-to-left layout
The process of laying out right-to-left scripts like
(modern) Hebrew text is very similar. The only difference
is that the pen position must be decremented before the
glyph rendering (remember: the advance width is always
positive, even for Hebrew glyphs).
Right-to-left algorithm 1:
Convert the character string into a series of glyph
indices.
Place the pen to the cursor position.
Get or load the glyph image.
Decrement the pen position by the glyph's advance
width in pixels.
Translate the glyph so that its ‘origin’
matches the pen position.
Render the glyph to the target device.
Start over at step 3 for each of the remaining
glyphs.
The changes to algorithm 2, as well as the inclusion
of kerning are left as an exercise to the reader.
5. Vertical layouts
Laying out vertical text uses exactly the same processes,
with the following significant differences:
The baseline is vertical, and the vertical metrics
must be used instead of the horizontal one.
The left bearing is usually negative, but this
doesn't change the fact that the glyph origin must be
located on the baseline.
The advance height is always positive, so the pen
position must be decremented if one wants to write top
to bottom (assuming the Y axis is oriented
upwards).
Here the algorithm:
Convert the character string into a series of glyph
indices.
Place the pen to the cursor position.
Get or load the glyph image.
Translate the glyph so that its ‘origin’
matches the pen position.
Render the glyph to the target device.
Decrement the vertical pen position by the glyph's
advance height in pixels.
Start over at step 3 for each of the remaining
glyphs.
When all glyphs are done, set the text cursor to the new
pen position.