Class: FT2::GlyphSlot
- Inherits:
-
Object
- Object
- FT2::GlyphSlot
- Defined in:
- ext/ft2-ruby/ft2.c
Class Method Summary collapse
-
.initialize ⇒ Object
Constructor for FT2::GlyphSlot class.
Instance Method Summary collapse
-
#advance ⇒ Object
Get the transformed advance width for a FT2::GlyphSlot object.
-
#bitmap ⇒ Object
Get the bitmap of a bitmap format FT2::GlyphSlot object.
-
#bitmap_left ⇒ Object
Get the left bearing (in pixels) of a bitmap format FT2::GlyphSlot object.
-
#bitmap_top ⇒ Object
Get the top bearing (in pixels) of a bitmap format FT2::GlyphSlot object.
-
#control_data ⇒ Object
Get optional control data for a FT2::GlyphSlot object.
-
#control_len ⇒ Object
Get the length of the optional control data for a FT2::GlyphSlot object.
-
#face ⇒ Object
Get the FT2::Face object this FT2::GlyphSlot object belongs to.
-
#format ⇒ Object
Get the format of a FT2::GlyphSlot object.
- #glyph ⇒ Object (also: #get_glyph)
-
#h_advance ⇒ Object
(also: #linearHoriAdvance, #h_adv, #ha, #linearVertAdvance, #v_adv, #va)
Get the linearly scaled horizontal advance width of a FT2::GlyphSlot object.
-
#library ⇒ Object
Get the FT2::Library instance this FT2::GlyphSlot object belongs to.
-
#metrics ⇒ Object
Get the FT2::GlyphMetrics of a FT2::GlyphSlot object.
-
#next ⇒ Object
Get the next FT2::GlyphSlot object.
-
#num_subglyphs ⇒ Object
Get the number of subglyphs of a FT2::GlyphSlot object.
-
#outline ⇒ Object
Get the outline of a bitmap outline format FT2::GlyphSlot object.
-
#render(render_mode) ⇒ Object
(also: #render_glyph)
Convert a FT2::GlyphSlot object to a bitmap.
-
#subglyphs ⇒ Object
Get a list of subglyphs of a composite format FT2::GlyphSlot object.
-
#v_advance ⇒ Object
Get the linearly scaled vertical advance height of a FT2::GlyphSlot object.
Class Method Details
.initialize ⇒ Object
Constructor for FT2::GlyphSlot class.
This method is currently empty. You should never call this method directly unless you’re instantiating a derived class (ie, you know what you’re doing).
1844 1845 1846 |
# File 'ext/ft2-ruby/ft2.c', line 1844 static VALUE ft_glyphslot_init(VALUE self) { return self; } |
Instance Method Details
#advance ⇒ Object
Get the transformed advance width for a FT2::GlyphSlot object.
Examples:
adv = slot.advance
2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 |
# File 'ext/ft2-ruby/ft2.c', line 2052
static VALUE ft_glyphslot_advance(VALUE self) {
FT_GlyphSlot *glyph;
VALUE ary;
Data_Get_Struct(self, FT_GlyphSlot, glyph);
ary = rb_ary_new();
rb_ary_push(ary, INT2NUM((*glyph)->advance.x));
rb_ary_push(ary, INT2NUM((*glyph)->advance.y));
return ary;
}
|
#bitmap ⇒ Object
Get the bitmap of a bitmap format FT2::GlyphSlot object.
Examples:
bmap = slot.bitmap
2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 |
# File 'ext/ft2-ruby/ft2.c', line 2090
static VALUE ft_glyphslot_bitmap(VALUE self) {
FT_GlyphSlot *glyph;
FT_Bitmap *bitmap;
Data_Get_Struct(self, FT_GlyphSlot, glyph);
bitmap = malloc(sizeof(FT_Bitmap));
*bitmap = (*glyph)->bitmap;
return Data_Wrap_Struct(cBitmap, 0, dont_free, bitmap);
}
|
#bitmap_left ⇒ Object
Get the left bearing (in pixels) of a bitmap format FT2::GlyphSlot object.
Note:
Only valid if the format is FT2::GlyphFormat::BITMAP.
Examples:
left = slot.bitmap_left
2111 2112 2113 2114 2115 |
# File 'ext/ft2-ruby/ft2.c', line 2111
static VALUE ft_glyphslot_bitmap_left(VALUE self) {
FT_GlyphSlot *glyph;
Data_Get_Struct(self, FT_GlyphSlot, glyph);
return INT2NUM((*glyph)->bitmap_left);
}
|
#bitmap_top ⇒ Object
Get the top bearing (in pixels) of a bitmap format FT2::GlyphSlot object.
Note:
Only valid if the format is FT2::GlyphFormat::BITMAP. The value
returned is the distance from the baseline to the topmost glyph
scanline, upwards y-coordinates being positive.
Examples:
top = slot.bitmap_top
2129 2130 2131 2132 2133 |
# File 'ext/ft2-ruby/ft2.c', line 2129
static VALUE ft_glyphslot_bitmap_top(VALUE self) {
FT_GlyphSlot *glyph;
Data_Get_Struct(self, FT_GlyphSlot, glyph);
return INT2NUM((*glyph)->bitmap_top);
}
|
#control_data ⇒ Object
Get optional control data for a FT2::GlyphSlot object.
Description:
Certain font drivers can also return the control data for a given
FT2::GlyphSlot (e.g. TrueType bytecode, Type 1 charstrings, etc.).
This field is a pointer to such data.
Examples:
data = slot.control_data
2215 2216 2217 2218 2219 |
# File 'ext/ft2-ruby/ft2.c', line 2215
static VALUE ft_glyphslot_control_data(VALUE self) {
FT_GlyphSlot *glyph;
Data_Get_Struct(self, FT_GlyphSlot, glyph);
return rb_str_new((*glyph)->control_data, (*glyph)->control_len);
}
|
#control_len ⇒ Object
Get the length of the optional control data for a FT2::GlyphSlot object.
Examples:
len = slot.control_len
2228 2229 2230 2231 2232 |
# File 'ext/ft2-ruby/ft2.c', line 2228
static VALUE ft_glyphslot_control_len(VALUE self) {
FT_GlyphSlot *glyph;
Data_Get_Struct(self, FT_GlyphSlot, glyph);
return INT2NUM((*glyph)->control_len);
}
|
#face ⇒ Object
Get the FT2::Face object this FT2::GlyphSlot object belongs to.
Examples:
face = slot.face
1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 |
# File 'ext/ft2-ruby/ft2.c', line 1928
static VALUE ft_glyphslot_face(VALUE self) {
FT_GlyphSlot *glyph;
FT_Face *face;
Data_Get_Struct(self, FT_GlyphSlot, glyph);
face = malloc(sizeof(FT_Face));
*face = (*glyph)->face;
/* do we really want to dont_free() cb here? */
return Data_Wrap_Struct(cFace, 0, dont_free, face);
}
|
#format ⇒ Object
2077 2078 2079 2080 2081 |
# File 'ext/ft2-ruby/ft2.c', line 2077
static VALUE ft_glyphslot_format(VALUE self) {
FT_GlyphSlot *glyph;
Data_Get_Struct(self, FT_GlyphSlot, glyph);
return INT2NUM((*glyph)->format);
}
|
#glyph ⇒ Object Also known as: get_glyph
1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 |
# File 'ext/ft2-ruby/ft2.c', line 1887
static VALUE ft_glyphslot_glyph(VALUE self) {
FT_Error err;
FT_GlyphSlot *slot;
FT_Glyph *glyph;
glyph = malloc(sizeof(FT_Glyph));
Data_Get_Struct(self, FT_GlyphSlot, slot);
err = FT_Get_Glyph(*slot, glyph);
if (err != FT_Err_Ok) {
free(glyph);
handle_error(err);
}
return Data_Wrap_Struct(cGlyph, 0, glyph_free, glyph);
}
|
#h_advance ⇒ Object Also known as: linearHoriAdvance, h_adv, ha, linearVertAdvance, v_adv, va
Get the linearly scaled horizontal advance width of a FT2::GlyphSlot object.
Description:
For scalable formats only, this field holds the linearly scaled
horizontal advance width for the FT2:GlyphSlot (i.e. the scaled and
unhinted value of the hori advance). This can be important to
perform correct WYSIWYG layout.
Note:
The return value is expressed by default in 16.16 pixels. However,
when the FT2::GlyphSlot is loaded with the FT2::Load::LINEAR_DESIGN
flag, this field contains simply the value of the advance in
original font units.
Aliases:
FT2::GlyphSlot#linearHoriAdvance
FT2::GlyphSlot#h_adv
FT2::GlyphSlot#ha
Examples:
h_adv = slot.h_advance
2007 2008 2009 2010 2011 2012 |
# File 'ext/ft2-ruby/ft2.c', line 2007
static VALUE ft_glyphslot_h_advance(VALUE self) {
FT_GlyphSlot *glyph;
Data_Get_Struct(self, FT_GlyphSlot, glyph);
return rb_float_new(FTFIX2DBL((*glyph)->linearHoriAdvance));
}
|
#library ⇒ Object
Get the FT2::Library instance this FT2::GlyphSlot object belongs to.
Examples:
lib = slot.library
1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 |
# File 'ext/ft2-ruby/ft2.c', line 1910
static VALUE ft_glyphslot_library(VALUE self) {
FT_GlyphSlot *glyph;
FT_Library *lib;
Data_Get_Struct(self, FT_GlyphSlot, glyph);
lib = malloc(sizeof(FT_Library));
*lib = (*glyph)->library;
return Data_Wrap_Struct(cLibrary, 0, dont_free, lib);
}
|
#metrics ⇒ Object
Get the FT2::GlyphMetrics of a FT2::GlyphSlot object.
Examples:
metrics = slot.metrics
1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 |
# File 'ext/ft2-ruby/ft2.c', line 1972
static VALUE ft_glyphslot_metrics(VALUE self) {
FT_GlyphSlot *glyph;
FT_Glyph_Metrics *metrics;
Data_Get_Struct(self, FT_GlyphSlot, glyph);
metrics = malloc(sizeof(FT_Glyph_Metrics));
*metrics = (*glyph)->metrics;
return Data_Wrap_Struct(cGlyphMetrics, 0, dont_free, metrics);
}
|
#next ⇒ Object
Get the next FT2::GlyphSlot object.
Description:
In some cases (like some font tools), several FT2::GlyphSlot s per
FT2::Face object can be a good thing. As this is rare, the
FT2::GlyphSlot s are listed through a direct, single-linked list
using its `next' field.
Examples:
next_slot = slot.next
1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 |
# File 'ext/ft2-ruby/ft2.c', line 1953
static VALUE ft_glyphslot_next(VALUE self) {
FT_GlyphSlot *glyph;
FT_GlyphSlot *next;
Data_Get_Struct(self, FT_GlyphSlot, glyph);
next = malloc(sizeof(FT_GlyphSlot));
*next = (*glyph)->next;
/* do we really want to dont_free() cb here? */
return Data_Wrap_Struct(cGlyphSlot, 0, dont_free, next);
}
|
#num_subglyphs ⇒ Object
Get the number of subglyphs of a FT2::GlyphSlot object.
Note:
Only valid if the format is FT2::GlyphFormat::COMPOSITE.
Examples:
outline = slot.outline
2166 2167 2168 2169 2170 |
# File 'ext/ft2-ruby/ft2.c', line 2166
static VALUE ft_glyphslot_num_subglyphs(VALUE self) {
FT_GlyphSlot *glyph;
Data_Get_Struct(self, FT_GlyphSlot, glyph);
return INT2NUM((*glyph)->num_subglyphs);
}
|
#outline ⇒ Object
Get the outline of a bitmap outline format FT2::GlyphSlot object.
Note:
Only valid if the format is FT2::GlyphFormat::OUTLINE.
Examples:
outline = slot.outline
2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 |
# File 'ext/ft2-ruby/ft2.c', line 2145
static VALUE ft_glyphslot_outline(VALUE self) {
FT_GlyphSlot *glyph;
FT_Outline *outline;
Data_Get_Struct(self, FT_GlyphSlot, glyph);
outline = malloc(sizeof(FT_Outline));
*outline = (*glyph)->outline;
return Data_Wrap_Struct(cOutline, 0, dont_free, outline);
}
|
#render(render_mode) ⇒ Object Also known as: render_glyph
Convert a FT2::GlyphSlot object to a bitmap.
Description:
Converts a given FT2::GlyphSlot to a bitmap. It does so by
$inspecting the FT2::GlyphSlot format, finding the relevant
renderer, and invoking it.
render_mode: This is the render mode used to render the glyph image
into a bitmap. See below for a list of possible
values. If render_mode is nil, then it defaults to
FT2::RenderMode::NORMAL.
Aliases:
FT2::GlyphSlot#render_glyph
Render Modes:
FT2::RenderMode::NORMAL
FT2::RenderMode::MONO
Examples:
slot.render FT2::RenderMode::NORMAL
1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 |
# File 'ext/ft2-ruby/ft2.c', line 1872
static VALUE ft_glyphslot_render(VALUE self, VALUE render_mode) {
FT_Error err;
FT_GlyphSlot *glyph;
Data_Get_Struct(self, FT_GlyphSlot, glyph);
if (render_mode == Qnil)
render_mode = INT2FIX(ft_render_mode_normal);
err = FT_Render_Glyph(*glyph, NUM2INT(render_mode));
if (err != FT_Err_Ok)
handle_error(err);
return self;
}
|
#subglyphs ⇒ Object
Get a list of subglyphs of a composite format FT2::GlyphSlot object.
Note:
Only valid if the format is FT2::GlyphFormat::COMPOSITE. FIXME:
this method may not work correctly at the moment.
Examples:
sub_glyphs = slot.subglyphs
2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 |
# File 'ext/ft2-ruby/ft2.c', line 2183
static VALUE ft_glyphslot_subglyphs(VALUE self) {
FT_GlyphSlot *glyph;
VALUE rtn;
int num;
Data_Get_Struct(self, FT_GlyphSlot, glyph);
if ((num = (*glyph)->num_subglyphs) < 1)
return Qnil;
/* FIXME: this probably doesn't work */
rtn = rb_ary_new();
/*
* for (i = 0; i < num; i++)
* rb_ary_push(rtn, Data_Wrap_Struct(cSubGlyph, 0,
* dont_free,
* (*glyph)->subglyphs[i]));
*/
return rtn;
}
|
#v_advance ⇒ Object
Get the linearly scaled vertical advance height of a FT2::GlyphSlot object.
Description:
For scalable formats only, this field holds the linearly scaled
vertical advance height for the FT2:GlyphSlot (i.e. the scaled and
unhinted value of the hori advance). This can be important to
perform correct WYSIWYG layout.
Note:
The return value is expressed by default in 16.16 pixels. However,
when the FT2::GlyphSlot is loaded with the FT2::Load::LINEAR_DESIGN
flag, this field contains simply the value of the advance in
original font units.
Aliases:
FT2::GlyphSlot#linearVertAdvance
FT2::GlyphSlot#v_adv
FT2::GlyphSlot#va
Examples:
v_adv = slot.v_advance
2038 2039 2040 2041 2042 2043 |
# File 'ext/ft2-ruby/ft2.c', line 2038
static VALUE ft_glyphslot_v_advance(VALUE self) {
FT_GlyphSlot *glyph;
Data_Get_Struct(self, FT_GlyphSlot, glyph);
return rb_float_new(ft_fixed_to_double((*glyph)->linearVertAdvance));
}
|