Module: PangoFT2

Defined in:
lib/pango/ft2-loader.rb,
lib/pango.rb

Overview

Copyright (C) 2021 Ruby-GNOME Project Team

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

Defined Under Namespace

Classes: FontMap, Loader

Instance Method Summary collapse

Instance Method Details

#font_get_coverage(font, language) ⇒ Pango::Coverage

Gets the PangoCoverage for a PangoFT2Font.

Use [methodPango.Font.get_coverage] instead.

Parameters:

Returns:

#font_get_face(font) ⇒ freetype2::Face

Returns the native FreeType2 FT_Face structure used for this PangoFont.

This may be useful if you want to use FreeType2 functions directly.

Use [methodPangoFc.Font.lock_face] instead; when you are done with a face from [methodPangoFc.Font.lock_face], you must call [methodPangoFc.Font.unlock_face].

Parameters:

Returns:

  • (freetype2::Face)

    a pointer to a FT_Face structure, with the size set correctly

#font_get_kerning(font, left, right) ⇒ Integer

Retrieves kerning information for a combination of two glyphs.

Use pango_fc_font_kern_glyphs() instead.

Parameters:

  • font (Pango::Font)

    a PangoFont

  • left (Pango::Glyph)

    the left PangoGlyph

  • right (Pango::Glyph)

    the right PangoGlyph

Returns:

  • (Integer)

    The amount of kerning (in Pango units) to apply for the given combination of glyphs.

#get_context(dpi_x, dpi_y) ⇒ Pango::Context

Retrieves a PangoContext for the default PangoFT2 fontmap (see pango_ft2_font_map_for_display()) and sets the resolution for the default fontmap to dpi_x by dpi_y.

Parameters:

  • dpi_x (Float)

    the horizontal DPI of the target device

  • dpi_y (Float)

    the vertical DPI of the target device

Returns:

#get_unknown_glyph(font) ⇒ Pango::Glyph

Return the index of a glyph suitable for drawing unknown characters with font, or %PANGO_GLYPH_EMPTY if no suitable glyph found.

If you want to draw an unknown-box for a character that is not covered by the font, use PANGO_GET_UNKNOWN_GLYPH() instead.

Parameters:

Returns:

  • (Pango::Glyph)

    a glyph index into font, or %PANGO_GLYPH_EMPTY

#render(bitmap, font, glyphs, x, y) ⇒ nil

Renders a PangoGlyphString onto a FreeType2 bitmap.

Parameters:

  • bitmap (freetype2::Bitmap)

    the FreeType2 bitmap onto which to draw the string

  • font (Pango::Font)

    the font in which to draw the string

  • glyphs (Pango::GlyphString)

    the glyph string to draw

  • x (Integer)

    the x position of the start of the string (in pixels)

  • y (Integer)

    the y position of the baseline (in pixels)

Returns:

  • (nil)

#render_layout(bitmap, layout, x, y) ⇒ nil

Render a PangoLayout onto a FreeType2 bitmap

Parameters:

  • bitmap (freetype2::Bitmap)

    a FT_Bitmap to render the layout onto

  • layout (Pango::Layout)

    a PangoLayout

  • x (Integer)

    the X position of the left of the layout (in pixels)

  • y (Integer)

    the Y position of the top of the layout (in pixels)

Returns:

  • (nil)

#render_layout_line(bitmap, line, x, y) ⇒ nil

Render a PangoLayoutLine onto a FreeType2 bitmap

Parameters:

  • bitmap (freetype2::Bitmap)

    a FT_Bitmap to render the line onto

  • line (Pango::LayoutLine)

    a PangoLayoutLine

  • x (Integer)

    the x position of start of string (in pixels)

  • y (Integer)

    the y position of baseline (in pixels)

Returns:

  • (nil)

#render_layout_line_subpixel(bitmap, line, x, y) ⇒ nil

Render a PangoLayoutLine onto a FreeType2 bitmap, with he location specified in fixed-point Pango units rather than pixels.

(Using this will avoid extra inaccuracies from rounding to integer pixels multiple times, even if the final glyph positions are integers.)

Parameters:

  • bitmap (freetype2::Bitmap)

    a FT_Bitmap to render the line onto

  • line (Pango::LayoutLine)

    a PangoLayoutLine

  • x (Integer)

    the x position of start of string (in Pango units)

  • y (Integer)

    the y position of baseline (in Pango units)

Returns:

  • (nil)

#render_layout_subpixel(bitmap, layout, x, y) ⇒ nil

Render a PangoLayout onto a FreeType2 bitmap, with he location specified in fixed-point Pango units rather than pixels.

(Using this will avoid extra inaccuracies from rounding to integer pixels multiple times, even if the final glyph positions are integers.)

Parameters:

  • bitmap (freetype2::Bitmap)

    a FT_Bitmap to render the layout onto

  • layout (Pango::Layout)

    a PangoLayout

  • x (Integer)

    the X position of the left of the layout (in Pango units)

  • y (Integer)

    the Y position of the top of the layout (in Pango units)

Returns:

  • (nil)

#render_transformed(bitmap, matrix, font, glyphs, x, y) ⇒ nil

Renders a PangoGlyphString onto a FreeType2 bitmap, possibly transforming the layed-out coordinates through a transformation matrix.

Note that the transformation matrix for font is not changed, so to produce correct rendering results, the font must have been loaded using a PangoContext with an identical transformation matrix to that passed in to this function.

Parameters:

  • bitmap (freetype2::Bitmap)

    the FreeType2 bitmap onto which to draw the string

  • matrix (Pango::Matrix)

    a PangoMatrix

  • font (Pango::Font)

    the font in which to draw the string

  • glyphs (Pango::GlyphString)

    the glyph string to draw

  • x (Integer)

    the x position of the start of the string (in Pango units in user space coordinates)

  • y (Integer)

    the y position of the baseline (in Pango units in user space coordinates)

Returns:

  • (nil)

#shutdown_displaynil

Free the global fontmap. (See pango_ft2_font_map_for_display()) Use of the global PangoFT2 fontmap is deprecated.

Returns:

  • (nil)