Class: FT2::Face
- Inherits:
-
Object
- Object
- FT2::Face
- Defined in:
- ext/ft2-ruby/ft2.c
Constant Summary collapse
- SCALABLE =
INT2FIX(FT_FACE_FLAG_SCALABLE)
- FIXED_SIZES =
INT2FIX(FT_FACE_FLAG_FIXED_SIZES)
- FIXED_WIDTH =
INT2FIX(FT_FACE_FLAG_FIXED_WIDTH)
- FIXED_HORIZONTAL =
INT2FIX(FT_FACE_FLAG_HORIZONTAL)
- FIXED_VERTICAL =
INT2FIX(FT_FACE_FLAG_VERTICAL)
- SFNT =
INT2FIX(FT_FACE_FLAG_SFNT)
- KERNING =
INT2FIX(FT_FACE_FLAG_KERNING)
- MULTIPLE_MASTERS =
INT2FIX(FT_FACE_FLAG_MULTIPLE_MASTERS)
- GLYPH_NAMES =
INT2FIX(FT_FACE_FLAG_GLYPH_NAMES)
- EXTERNAL_STREAM =
INT2FIX(FT_FACE_FLAG_EXTERNAL_STREAM)
- FAST_GLYPHS =
INT2FIX(FT_FACE_FLAG_FAST_GLYPHS)
- BOLD =
INT2FIX(FT_STYLE_FLAG_BOLD)
- ITALIC =
INT2FIX(FT_STYLE_FLAG_ITALIC)
Class Method Summary collapse
-
.initialize ⇒ Object
Constructor for FT2::Face.
-
.load(*args) ⇒ Object
Allocate and initialize a new FT2::Face object.
-
.new(*args) ⇒ Object
Allocate and initialize a new FT2::Face object.
-
.new_from_memory(*args) ⇒ Object
Allocate and initialize a new FT2::Face object from in-memory buffer.
Instance Method Summary collapse
-
#ascender ⇒ Object
Return the ascender for this FT2::Face object.
-
#attach(path) ⇒ Object
(also: #attach_file)
Attach a font file to this FT2::Face object.
-
#available_sizes ⇒ Object
(also: #num_available_sizes)
Return an array of sizes in an FT2::Face object.
-
#bbox ⇒ Object
Return the bounding box of an FT2::Face object.
-
#bold? ⇒ Boolean
Is this a bold FT2::Face?.
-
#char_index(char_code) ⇒ Object
Get the glyph index of a character code.
-
#charmap ⇒ Object
Return the current active FT2::CharMap of this FT2::Face object.
-
#charmaps ⇒ Object
Return an array of charmaps in an FT2::Face object.
-
#current_charmap ⇒ Object
Return the character code to glyph index map of the selected charmap of a FT2::Face object.
-
#descender ⇒ Object
Return the descender for this FT2::Face object.
-
#external_stream? ⇒ Boolean
Was this FT2::Face loaded from an external stream?.
-
#faces ⇒ Object
(also: #num_faces)
Return the number of faces in an FT2::Face object.
-
#family ⇒ Object
Return the family name of an FT2::Face object.
-
#fast_glyphs? ⇒ Boolean
Does this FT2::Face contain fast glyphs?.
-
#first_char ⇒ Object
Return the first character code of the selected charmap and corresponding glyph index of a FT2::Face object.
-
#fixed_sizes ⇒ Object
(also: #num_fixed_sizes)
Return the number of fixed sizes in an FT2::Face object.
-
#fixed_sizes? ⇒ Boolean
Does this FT2::Face contain bitmap strikes for some pixel sizes?.
-
#fixed_width? ⇒ Boolean
Does this FT2::Face contain fixed with characters?.
-
#flags ⇒ Object
(also: #face_flags)
Return the face flags of an FT2::Face object.
-
#glyph ⇒ Object
Return the glyph slot associated with this FT2::Face object.
-
#glyph_name(glyph_index) ⇒ Object
Get the ASCII name of a glyph in a FT2::Face object.
-
#glyphs ⇒ Object
(also: #num_glyphs)
Return the number of glyphs in an FT2::Face object.
-
#height ⇒ Object
Return the height of this FT2::Face object.
-
#horizontal? ⇒ Boolean
Does this FT2::Face contain horizontal glyph metrics?.
-
#index ⇒ Object
(also: #face_index)
Return the index of an FT2::Face object in its font file.
-
#italic? ⇒ Boolean
Is this an italic FT2::Face?.
-
#kerning(left_glyph, right_glyph, kern_mode) ⇒ Object
(also: #get_kerning)
Get the kerning vector between two glyphs of a FT2::Face object.
-
#kerning? ⇒ Boolean
Does this FT2::Face contain kerning information?.
-
#load_char(char_code, flags) ⇒ Object
Load a glyph at a given size into a glyph slot of a FT2::Face object.
-
#load_glyph(glyph_index, flags) ⇒ Object
Load a glyph at a given size into a glyph slot of a FT2::Face object.
-
#max_advance_height ⇒ Object
Return the maximal advance height of this FT2::Face object.
-
#max_advance_width ⇒ Object
Return the maximal advance width of this FT2::Face object.
-
#name_index(glyph_name) ⇒ Object
Get the glyph index of a given glyph name.
-
#next_char(char_code) ⇒ Object
Return the next character code of the selected charmap and corresponding glyph index of a FT2::Face object.
-
#num_charmaps ⇒ Object
Return the number of charmaps in an FT2::Face object.
-
#postscript_name ⇒ Object
(also: #name)
Get the ASCII Postscript name of a FT2::Face object.
-
#scalable? ⇒ Boolean
Is this FT2::Face scalable?.
-
#select_charmap(encoding) ⇒ Object
Select a FT2::Face object’s charmap by its encoding tag.
-
#set_char_size(c_w, c_h, h_r, v_r) ⇒ Object
Set the character dimensions of this FT2::Face object.
-
#set_charmap(charmap) ⇒ Object
(also: #charmap=)
Select the FT2::Face object’s charmap for character code to glyph index decoding.
-
#set_pixel_sizes(pixel_w, pixel_h) ⇒ Object
Set the character dimensions of this FT2::Face object.
-
#set_transform(matrix, delta) ⇒ Object
Set the pre-render transoformation matrix and vector of a FT2::Face object.
-
#sfnt? ⇒ Boolean
Is this FT2::Face stored in the ‘sfnt’ storage format?.
-
#size ⇒ Object
Return the current active size of this FT2::Face object.
-
#style ⇒ Object
Return the style name of an FT2::Face object.
-
#style_flags ⇒ Object
Return the style flags of an FT2::Face object.
-
#underline_position ⇒ Object
Return the underline position of this FT2::Face object.
-
#underline_thickness ⇒ Object
Return the underline thickness of this FT2::Face object.
-
#units_per_em ⇒ Object
(also: #units_per_EM)
Return the number of font units per EM for this FT2::Face object.
-
#vertical? ⇒ Boolean
Does this FT2::Face contain vertical glyph metrics?.
Class Method Details
.initialize ⇒ Object
Constructor for FT2::Face.
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).
440 441 442 |
# File 'ext/ft2-ruby/ft2.c', line 440 static VALUE ft_face_init(VALUE self) { return self; } |
.load(*args) ⇒ Object
Allocate and initialize a new FT2::Face object.
Note:
FreeType2-Ruby creates a new (hidden) FT2::Library instance at
runtime, which FT2::Face objects are automatically initialized with
if an a library is not specified.
Aliases:
FT2::Face.load
Examples:
# load font from file "yudit.ttf"
face = FT2::Face.new 'yudit.ttf'
# load second face from from file "yudit.ttf"
face = FT2::Face.new 'yudit.ttf', 1
# load font from file "yudit.ttf" under FT2::Library instance lib
face = FT2::Face.new lib, 'yudit.ttf'
# load second face from file "yudit.ttf" under FT2::Library instance lib
face = FT2::Face.new lib, 'yudit.ttf', 1
315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 |
# File 'ext/ft2-ruby/ft2.c', line 315
VALUE ft_face_new(int argc, VALUE *argv, VALUE klass) {
VALUE self, path;
FT_Library *lib;
FT_Face *face;
FT_Error err;
FT_Long face_index;
lib = &library;
switch (argc) {
case 1:
path = argv[0];
face_index = 0;
break;
case 2:
if (rb_obj_is_kind_of(argv[0], rb_cString)) {
path = argv[0];
face_index = NUM2INT(argv[1]);
} else if (rb_obj_is_kind_of(argv[0], cLibrary)) {
Data_Get_Struct(argv[0], FT_Library, lib);
path = argv[0];
face_index = 0;
} else {
rb_raise(rb_eArgError, "Invalid first argument.");
}
break;
case 3:
Data_Get_Struct(argv[0], FT_Library, lib);
path = argv[1];
face_index = NUM2INT(argv[1]);
break;
default:
rb_raise(rb_eArgError, "Invalid argument count: %d.", argc);
}
face = malloc(sizeof(FT_Face));
err = FT_New_Face(*lib, RSTRING_PTR(path), face_index, face);
if (err != FT_Err_Ok)
handle_error(err);
self = Data_Wrap_Struct(klass, 0, face_free, face);
rb_obj_call_init(self, 0, NULL);
return self;
}
|
.new(*args) ⇒ Object
Allocate and initialize a new FT2::Face object.
Note:
FreeType2-Ruby creates a new (hidden) FT2::Library instance at
runtime, which FT2::Face objects are automatically initialized with
if an a library is not specified.
Aliases:
FT2::Face.load
Examples:
# load font from file "yudit.ttf"
face = FT2::Face.new 'yudit.ttf'
# load second face from from file "yudit.ttf"
face = FT2::Face.new 'yudit.ttf', 1
# load font from file "yudit.ttf" under FT2::Library instance lib
face = FT2::Face.new lib, 'yudit.ttf'
# load second face from file "yudit.ttf" under FT2::Library instance lib
face = FT2::Face.new lib, 'yudit.ttf', 1
315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 |
# File 'ext/ft2-ruby/ft2.c', line 315
VALUE ft_face_new(int argc, VALUE *argv, VALUE klass) {
VALUE self, path;
FT_Library *lib;
FT_Face *face;
FT_Error err;
FT_Long face_index;
lib = &library;
switch (argc) {
case 1:
path = argv[0];
face_index = 0;
break;
case 2:
if (rb_obj_is_kind_of(argv[0], rb_cString)) {
path = argv[0];
face_index = NUM2INT(argv[1]);
} else if (rb_obj_is_kind_of(argv[0], cLibrary)) {
Data_Get_Struct(argv[0], FT_Library, lib);
path = argv[0];
face_index = 0;
} else {
rb_raise(rb_eArgError, "Invalid first argument.");
}
break;
case 3:
Data_Get_Struct(argv[0], FT_Library, lib);
path = argv[1];
face_index = NUM2INT(argv[1]);
break;
default:
rb_raise(rb_eArgError, "Invalid argument count: %d.", argc);
}
face = malloc(sizeof(FT_Face));
err = FT_New_Face(*lib, RSTRING_PTR(path), face_index, face);
if (err != FT_Err_Ok)
handle_error(err);
self = Data_Wrap_Struct(klass, 0, face_free, face);
rb_obj_call_init(self, 0, NULL);
return self;
}
|
.new_from_memory(*args) ⇒ Object
Allocate and initialize a new FT2::Face object from in-memory buffer.
Note:
FreeType2-Ruby creates a new (hidden) FT2::Library instance at
runtime, which FT2::Face objects are automatically initialized with
if an a library is not specified.
Examples:
# load font from string _buffer_
face = FT2::Face.new buffer, buffer_size
# load second face from string _buffer_
face = FT2::Face.new buffer, buffer_size, 1
# load font from string _buffer_ under FT2::Library instance _lib_
face = FT2::Face.new lib, buffer, buffer_size
# load second face from string _buffer_ under FT2::Library instance _lib_
face = FT2::Face.new lib, buffer, buffer_size, 1
381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 |
# File 'ext/ft2-ruby/ft2.c', line 381
VALUE ft_face_new_from_memory(int argc, VALUE *argv, VALUE klass) {
VALUE self;
FT_Library *lib;
FT_Face *face;
FT_Error err;
FT_Long face_index;
void *mem;
int len;
lib = &library;
switch (argc) {
case 2:
mem = RSTRING_PTR(argv[0]);
len = NUM2INT(argv[1]);
face_index = 0;
break;
case 3:
if (rb_obj_is_kind_of(argv[0], rb_cString)) {
mem = RSTRING_PTR(argv[0]);
len = NUM2INT(argv[1]);
face_index = NUM2INT(argv[2]);
} else if (rb_obj_is_kind_of(argv[0], cLibrary)) {
Data_Get_Struct(argv[0], FT_Library, lib);
mem = RSTRING_PTR(argv[1]);
len = NUM2INT(argv[2]);
face_index = 0;
} else {
rb_raise(rb_eArgError, "Invalid first argument.");
}
break;
case 4:
Data_Get_Struct(argv[0], FT_Library, lib);
mem = RSTRING_PTR(argv[1]);
len = NUM2INT(argv[2]);
face_index = NUM2INT(argv[3]);
break;
default:
rb_raise(rb_eArgError, "Invalid argument count: %d.", argc);
}
face = malloc(sizeof(FT_Face));
err = FT_New_Memory_Face(*lib, mem, len, face_index, face);
if (err != FT_Err_Ok)
handle_error(err);
self = Data_Wrap_Struct(klass, 0, face_free, face);
rb_obj_call_init(self, 0, NULL);
return self;
}
|
Instance Method Details
#ascender ⇒ Object
Return the ascender for this FT2::Face object.
Description:
An FT2::Face object's ascender is the vertical distance, in font
units, from the baseline to the topmost point of any glyph in the
face.
Examples:
asc = face.ascender
896 897 898 899 900 |
# File 'ext/ft2-ruby/ft2.c', line 896
static VALUE ft_face_ascender(VALUE self) {
FT_Face *face;
Data_Get_Struct(self, FT_Face, face);
return INT2FIX((int) (*face)->ascender);
}
|
#attach(path) ⇒ Object Also known as: attach_file
Attach a font file to this FT2::Face object.
Description:
This is usually to read additional information for a single face
object. For example, it is used to read the AFM files that come
with Type 1 fonts in order to add kerning data and other metrics.
Throws an exception if the font file could not be loaded.
FreeType2 also supports loading from an input stream, but this
feature is not implemented in FT2-Ruby.
Examples:
path = 'fonts'yudit.ttf'
begin
face.attach path # attach file "fonts/yudit.ttf"
rescue Exception
$stderr.puts "Couldn't open font file \"#{path}\": " << $!
end
1086 1087 1088 1089 1090 1091 1092 1093 |
# File 'ext/ft2-ruby/ft2.c', line 1086
static VALUE ft_face_attach(VALUE self, VALUE path) {
FT_Face *face;
FT_Error err;
Data_Get_Struct(self, FT_Face, face);
if ((err = FT_Attach_File(*face, RSTRING_PTR(path))) != FT_Err_Ok)
handle_error(err);
return self;
}
|
#available_sizes ⇒ Object Also known as: num_available_sizes
Return an array of sizes in an FT2::Face object.
Note:
This method does not currently work..
Examples:
face.available_sizesdflksjaflksdjf FIXME
801 802 803 804 805 806 |
# File 'ext/ft2-ruby/ft2.c', line 801
static VALUE ft_face_available_sizes(VALUE self) {
FT_Face *face;
Data_Get_Struct(self, FT_Face, face);
/* FIXME!! */
return INT2FIX((*face)->available_sizes);
}
|
#bbox ⇒ Object
Return the bounding box of an FT2::Face object.
Note:
This method is not currently implemented (FIXME).
Examples:
FIXME
856 857 858 859 860 861 |
# File 'ext/ft2-ruby/ft2.c', line 856
static VALUE ft_face_bbox(VALUE self) {
UNUSED(self);
/* FIXME */
rb_bug("not implemented yet");
return Qnil;
}
|
#bold? ⇒ Boolean
Is this a bold FT2::Face?
Examples:
puts "bold face" if face.bold?
695 696 697 698 699 |
# File 'ext/ft2-ruby/ft2.c', line 695
static VALUE ft_face_flag_bold(VALUE self) {
FT_Face *face;
Data_Get_Struct(self, FT_Face, face);
return ((*face)->style_flags & FT_STYLE_FLAG_BOLD) ? Qtrue : Qfalse;
}
|
#char_index(char_code) ⇒ Object
Get the glyph index of a character code.
Note:
This function uses a charmap object in order to do the translation.
FreeType computes its own glyph indices which are not necessarily
the same as used in the font in case the font is based on glyph
indices. Reason for this behaviour is to assure that index 0 is
never used, representing the missing glyph.
A return value of 0 means `undefined character code'.
Examples:
index = face.char_index 65
puts 'undefined character code' if index == 0
1352 1353 1354 1355 1356 |
# File 'ext/ft2-ruby/ft2.c', line 1352
static VALUE ft_face_char_index(VALUE self, VALUE char_code) {
FT_Face *face;
Data_Get_Struct(self, FT_Face, face);
return INT2FIX(FT_Get_Char_Index(*face, NUM2INT(char_code)));
}
|
#charmap ⇒ Object
Return the current active FT2::CharMap of this FT2::Face object.
Examples:
size = face.size
1056 1057 1058 1059 1060 1061 1062 1063 1064 |
# File 'ext/ft2-ruby/ft2.c', line 1056
static VALUE ft_face_charmap(VALUE self) {
FT_Face *face;
Data_Get_Struct(self, FT_Face, face);
if ((*face)->charmap)
return Data_Wrap_Struct(cCharMap, 0, dont_free, (*face)->charmap);
else
return Qnil;
}
|
#charmaps ⇒ Object
Return an array of charmaps in an FT2::Face object.
Note:
This method may not work correctly at the moment (FIXME).
Examples:
face.charmaps.each { |map| puts map.to_str }
831 832 833 834 835 836 837 838 839 840 841 842 843 844 |
# File 'ext/ft2-ruby/ft2.c', line 831
static VALUE ft_face_charmaps(VALUE self) {
FT_Face *face;
VALUE ary;
int i;
Data_Get_Struct(self, FT_Face, face);
/* FIXME */
rb_bug("not implemented yet");
ary = rb_ary_new();
for (i = 0; i < (*face)->num_charmaps; i++)
rb_ary_push(ary, INT2FIX(i));
return ary;
}
|
#current_charmap ⇒ Object
Return the character code to glyph index map of the selected charmap of a FT2::Face object.
Note:
Returns nil if the selected charmap is empty.
Examples:
mapping = face.charmap
1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 |
# File 'ext/ft2-ruby/ft2.c', line 1602
static VALUE ft_face_current_charmap(VALUE self) {
FT_Face *face;
FT_ULong c_code;
FT_UInt g_idx;
VALUE rtn;
rtn = Qnil;
Data_Get_Struct(self, FT_Face, face);
c_code = FT_Get_First_Char(*face, &g_idx);
if (!g_idx || !c_code)
return rtn;
rtn = rb_hash_new();
while (c_code != 0) {
rb_hash_aset(rtn, UINT2NUM(c_code), UINT2NUM(g_idx));
c_code = FT_Get_Next_Char(*face, c_code, &g_idx);
}
return rtn;
}
|
#descender ⇒ Object
Return the descender for this FT2::Face object.
Description:
An FT2::Face object's descender is the vertical distance, in font
units, from the baseline to the bottommost point of any glyph in
the face.
Examples:
asc = face.descender
914 915 916 917 918 |
# File 'ext/ft2-ruby/ft2.c', line 914
static VALUE ft_face_descender(VALUE self) {
FT_Face *face;
Data_Get_Struct(self, FT_Face, face);
return INT2FIX((int) (*face)->descender);
}
|
#external_stream? ⇒ Boolean
Was this FT2::Face loaded from an external stream?
Examples:
puts "face loaded from external stream" if face.external_stream?
637 638 639 640 641 |
# File 'ext/ft2-ruby/ft2.c', line 637
static VALUE ft_face_flag_external_stream(VALUE self) {
FT_Face *face;
Data_Get_Struct(self, FT_Face, face);
return ((*face)->face_flags & FT_FACE_FLAG_EXTERNAL_STREAM) ? Qtrue : Qfalse;
}
|
#faces ⇒ Object Also known as: num_faces
454 455 456 457 458 |
# File 'ext/ft2-ruby/ft2.c', line 454
static VALUE ft_face_faces(VALUE self) {
FT_Face *face;
Data_Get_Struct(self, FT_Face, face);
return INT2FIX((int) (*face)->num_faces);
}
|
#family ⇒ Object
Return the family name of an FT2::Face object.
Description:
This is an ASCII string, usually in English, which describes the
FT2::Face object's family (eg "Times New Roman" or "Geneva"). Some
formats (eg Truetype and OpenType) provide localized and Unicode
versions of this string, which are accessable via the format specific
interfaces.
Examples:
puts 'family: ' << face.family
745 746 747 748 749 |
# File 'ext/ft2-ruby/ft2.c', line 745
static VALUE ft_face_family(VALUE self) {
FT_Face *face;
Data_Get_Struct(self, FT_Face, face);
return rb_str_new2((*face)->family_name);
}
|
#fast_glyphs? ⇒ Boolean
Does this FT2::Face contain fast glyphs?
Note:
This flag is usually set for fixed-size formats like FNT.
Examples:
puts "face contains fast glyphs" if face.fast_glyphs?
653 654 655 656 657 |
# File 'ext/ft2-ruby/ft2.c', line 653
static VALUE ft_face_flag_fast_glyphs(VALUE self) {
FT_Face *face;
Data_Get_Struct(self, FT_Face, face);
return ((*face)->face_flags & FT_FACE_FLAG_FAST_GLYPHS) ? Qtrue : Qfalse;
}
|
#first_char ⇒ Object
Return the first character code of the selected charmap and corresponding glyph index of a FT2::Face object.
Note:
Using this with FT2::Face#next_char will allow you to iterate
through the charmap => glyph index mapping for the selected
charmap.
You should probably use the method FT2::Face#current_charmap
instead.
Examples:
c_code, g_idx = face.first_char
while g_idx != 0
puts "#{c_code} => #{g_idx}"
c_code, g_idx = face.next_char
end
1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 |
# File 'ext/ft2-ruby/ft2.c', line 1542 static VALUE ft_face_first_char(VALUE self) { FT_Face *face; VALUE ary; FT_ULong char_code; FT_UInt glyph_index; Data_Get_Struct(self, FT_Face, face); ary = rb_ary_new(); char_code = FT_Get_First_Char(*face, &glyph_index); rb_ary_push(ary, UINT2NUM(char_code)); rb_ary_push(ary, UINT2NUM(glyph_index)); return ary; } |
#fixed_sizes ⇒ Object Also known as: num_fixed_sizes
785 786 787 788 789 |
# File 'ext/ft2-ruby/ft2.c', line 785
static VALUE ft_face_fixed_sizes(VALUE self) {
FT_Face *face;
Data_Get_Struct(self, FT_Face, face);
return INT2FIX((int) (*face)->num_fixed_sizes);
}
|
#fixed_sizes? ⇒ Boolean
Does this FT2::Face contain bitmap strikes for some pixel sizes?
Examples:
puts "contains fixed sized glyphs" if face.fixed_sizes?
549 550 551 552 553 |
# File 'ext/ft2-ruby/ft2.c', line 549
static VALUE ft_face_flag_fixed_sizes(VALUE self) {
FT_Face *face;
Data_Get_Struct(self, FT_Face, face);
return ((*face)->face_flags & FT_FACE_FLAG_FIXED_SIZES) ? Qtrue : Qfalse;
}
|
#fixed_width? ⇒ Boolean
Does this FT2::Face contain fixed with characters?
Examples:
puts "contains fixed width characters" if face.fixed_width?
562 563 564 565 566 |
# File 'ext/ft2-ruby/ft2.c', line 562
static VALUE ft_face_flag_fixed_width(VALUE self) {
FT_Face *face;
Data_Get_Struct(self, FT_Face, face);
return ((*face)->face_flags & FT_FACE_FLAG_FIXED_WIDTH) ? Qtrue : Qfalse;
}
|
#flags ⇒ Object Also known as: face_flags
Return the face flags of an FT2::Face object.
You can binary OR this with any of the following values to obtain the value of that flag (note that this is returned as an Integer and not as a boolean value; eg non-zero for true and zero for false).
Face Flags:
FT2::Face::SCALABLE
FT2::Face::FIXED_SIZES
FT2::Face::FIXED_WIDTH
FT2::Face::FIXED_HORIZONTAL
FT2::Face::FIXED_VERTICAL
FT2::Face::SFNT
FT2::Face::KERNING
FT2::Face::MULTIPLE_MASTERS
FT2::Face::GLYPH_NAMES
FT2::Face::EXTERNAL_STREAM
FT2::Face::FAST_GLYPHS
Alternatively, if you’re only checking one flag, it’s slightly faster (and arguably more concise), to use the following flag methods, which DO return true or false.
Individual Flag Methods:
FT2::Face#scalable?
FT2::Face#fixed_sizes?
FT2::Face#fixed_width?
FT2::Face#horizontal?
FT2::Face#vertical?
FT2::Face#sfnt?
FT2::Face#kerning?
FT2::Face#external_stream?
FT2::Face#fast_glyphs?
Aliases:
FT2::Face#face_flags
Examples:
if (face.flags & (FT2::Face::FAST_GLYPHS | FT2::Face::KERNING) != 0)
puts 'face contains fast glyphs and kerning information'
end
523 524 525 526 527 |
# File 'ext/ft2-ruby/ft2.c', line 523
static VALUE ft_face_flags(VALUE self) {
FT_Face *face;
Data_Get_Struct(self, FT_Face, face);
return INT2FIX((int) (*face)->face_flags);
}
|
#glyph ⇒ Object
Return the glyph slot associated with this FT2::Face object.
Description:
The face's associated glyph slot(s) (a FT2::GlyphSlot). This object
is created automatically with a new FT2::Face object. However,
certain kinds of applications (mainly tools like converters) can
need more than one slot to ease their task.
Examples:
glyph = face.glyph
1022 1023 1024 1025 1026 1027 1028 1029 1030 |
# File 'ext/ft2-ruby/ft2.c', line 1022
static VALUE ft_face_glyph(VALUE self) {
FT_Face *face;
Data_Get_Struct(self, FT_Face, face);
if ((*face)->glyph)
return Data_Wrap_Struct(cGlyphSlot, 0, dont_free, &((*face)->glyph));
else
return Qnil;
}
|
#glyph_name(glyph_index) ⇒ Object
Get the ASCII name of a glyph in a FT2::Face object.
Note:
If the face doesn't provide glyph names or if the glyph index is
invalid, nil is returned. The glyph name is truncated if it is
longer than 1024 characters.
Examples:
glyph_index = 45
glyph_name = face.glyph_name glyph_index
1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 |
# File 'ext/ft2-ruby/ft2.c', line 1442
static VALUE ft_face_glyph_name(VALUE self, VALUE glyph_index) {
FT_Face *face;
FT_Error err;
char buf[1024];
Data_Get_Struct(self, FT_Face, face);
err = FT_Get_Glyph_Name(*face, NUM2INT(glyph_index), buf, sizeof(buf));
if (err != FT_Err_Ok)
handle_error(err);
return (buf && strlen(buf)) ? rb_str_new2(buf) : Qnil;
}
|
#glyphs ⇒ Object Also known as: num_glyphs
725 726 727 728 729 |
# File 'ext/ft2-ruby/ft2.c', line 725
static VALUE ft_face_glyphs(VALUE self) {
FT_Face *face;
Data_Get_Struct(self, FT_Face, face);
return INT2FIX((int) (*face)->num_glyphs);
}
|
#height ⇒ Object
Return the height of this FT2::Face object.
Description:
An FT2::Face object's height is the vertical distance, in font
units, from the baseline of one line to the baseline of the next.
The value can be computed as 'ascender + descender + line_gap',
where 'line_gap' is also called 'external leading'.
Examples:
h = face.height
933 934 935 936 937 |
# File 'ext/ft2-ruby/ft2.c', line 933
static VALUE ft_face_height(VALUE self) {
FT_Face *face;
Data_Get_Struct(self, FT_Face, face);
return INT2FIX((int) (*face)->height);
}
|
#horizontal? ⇒ Boolean
Does this FT2::Face contain horizontal glyph metrics?
Note:
This flag is true for virtually all fonts.
Examples:
puts "contains horizontal glyph metrics" if face.horizontal?
578 579 580 581 582 |
# File 'ext/ft2-ruby/ft2.c', line 578
static VALUE ft_face_flag_horizontal(VALUE self) {
FT_Face *face;
Data_Get_Struct(self, FT_Face, face);
return ((*face)->face_flags & FT_FACE_FLAG_HORIZONTAL) ? Qtrue : Qfalse;
}
|
#index ⇒ Object Also known as: face_index
473 474 475 476 477 |
# File 'ext/ft2-ruby/ft2.c', line 473
static VALUE ft_face_index(VALUE self) {
FT_Face *face;
Data_Get_Struct(self, FT_Face, face);
return INT2FIX((int) (*face)->face_index);
}
|
#italic? ⇒ Boolean
Is this an italic FT2::Face?
Examples:
puts "italic face" if face.italic?
708 709 710 711 712 |
# File 'ext/ft2-ruby/ft2.c', line 708
static VALUE ft_face_flag_italic(VALUE self) {
FT_Face *face;
Data_Get_Struct(self, FT_Face, face);
return ((*face)->style_flags & FT_STYLE_FLAG_ITALIC) ? Qtrue : Qfalse;
}
|
#kerning(left_glyph, right_glyph, kern_mode) ⇒ Object Also known as: get_kerning
Get the kerning vector between two glyphs of a FT2::Face object.
Description:
Get the kerning vector between two glyphs of a FT2::Face object.
left_glyph: The index of the left glyph in the kern pair.
right_glyph: The index of the right glyph in the kern pair.
kern_mode: One of the FT2::KerningMode::XXXX constants. Determines
the scale/dimension of the returned kerning vector.
Passing kern_mode == nil is the same as FT2::KerningMode::DEFAULT.
Returns a kerning vector (actually a two-element array). This is in
font units for scalable formats, and in pixels for fixed-sizes
formats.
Kerning Modes:
FT2::KerningMode::DEFAULT
FT2::KerningMode::UNFITTED
FT2::KerningMode::UNSCALED
Examples:
left_glyph = 10
left_glyph = 11
k_v = face.kerning left_glyph, right_glyph, nil
# another example, w/o default options
k_v = face.get_kerning 12, 13, FT2::KerningMode::UNFITTED
1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 |
# File 'ext/ft2-ruby/ft2.c', line 1407
static VALUE ft_face_kerning(VALUE self, VALUE left_glyph, VALUE right_glyph, VALUE kern_mode) {
FT_Face *face;
FT_Error err;
FT_Vector v;
VALUE ary;
Data_Get_Struct(self, FT_Face, face);
ary = rb_ary_new();
if (kern_mode == Qnil)
kern_mode = NUM2INT(ft_kerning_default);
err = FT_Get_Kerning(*face, NUM2INT(left_glyph), NUM2INT(right_glyph), NUM2INT(kern_mode), &v);
if (err != FT_Err_Ok)
handle_error(err);
rb_ary_push(ary, INT2FIX(v.x));
rb_ary_push(ary, INT2FIX(v.y));
return ary;
}
|
#kerning? ⇒ Boolean
Does this FT2::Face contain kerning information?
Examples:
puts "face contains kerning information" if face.kerning?
624 625 626 627 628 |
# File 'ext/ft2-ruby/ft2.c', line 624
static VALUE ft_face_flag_kerning(VALUE self) {
FT_Face *face;
Data_Get_Struct(self, FT_Face, face);
return ((*face)->face_flags & FT_FACE_FLAG_KERNING) ? Qtrue : Qfalse;
}
|
#load_char(char_code, flags) ⇒ Object
Load a glyph at a given size into a glyph slot of a FT2::Face object.
Description:
Load a glyph at a given size into a glyph slot of a FT2::Face
object according to its character code.
char_code: The glyph's character code, according to the current
charmap used in the FT2::Face object.
load_flags: A flag indicating what to load for this glyph. The
FT2::Load::XXXX constants can be used to control the
glyph loading process (e.g., whether the outline should
be scaled, whether to load bitmaps or not, whether to
hint the outline, etc).
Note:
If the face has no current charmap, or if the character code is not
defined in the charmap, this function will return an error.
If the glyph image is not a bitmap, and if the bit flag
FT2::Load::IGNORE_TRANSFORM is unset, the glyph image will be
transformed with the information passed to a previous call to
FT2::Face#set_transform
Note that this also transforms the `face.glyph.advance' field, but
not the values in `face.glyph.metrics'.
Load Flags:
FT2::Load::DEFAULT
FT2::Load::RENDER
FT2::Load::MONOCHROME
FT2::Load::LINEAR_DESIGN
FT2::Load::NO_SCALE
FT2::Load::NO_HINTING
FT2::Load::NO_BITMAP
FT2::Load::CROP_BITMAP
FT2::Load::VERTICAL_LAYOUT
FT2::Load::IGNORE_TRANSFORM
FT2::Load::IGNORE_GLOBAL_ADVANCE_WIDTH
FT2::Load::FORCE_AUTOHINT
FT2::Load::NO_RECURSE
FT2::Load::PEDANTIC
Examples:
face.load_char 5, FT2::Load::DEFAULT
1324 1325 1326 1327 1328 1329 1330 1331 1332 |
# File 'ext/ft2-ruby/ft2.c', line 1324
static VALUE ft_face_load_char(VALUE self, VALUE char_code, VALUE flags) {
FT_Face *face;
FT_Error err;
Data_Get_Struct(self, FT_Face, face);
err = FT_Load_Char(*face, NUM2INT(char_code), NUM2INT(flags));
if (err != FT_Err_Ok)
handle_error(err);
return self;
}
|
#load_glyph(glyph_index, flags) ⇒ Object
Load a glyph at a given size into a glyph slot of a FT2::Face object.
Description:
Load a glyph at a given size into a glyph slot of a FT2::Face
object.
glyph_index: The index of the glyph in the font file.
load_flags: A flag indicating what to load for this glyph. The
FT2::Load::XXXX constants can be used to control the
glyph loading process (e.g., whether the outline should
be scaled, whether to load bitmaps or not, whether to
hint the outline, etc).
Note:
If the glyph image is not a bitmap, and if the bit flag
FT2::Load::IGNORE_TRANSFORM is unset, the glyph image will be
transformed with the information passed to a previous call to
FT2::Face#set_transform
Note that this also transforms the `face.glyph.advance' field, but
not the values in `face.glyph.metrics'.
Load Flags:
FT2::Load::DEFAULT
FT2::Load::RENDER
FT2::Load::MONOCHROME
FT2::Load::LINEAR_DESIGN
FT2::Load::NO_SCALE
FT2::Load::NO_HINTING
FT2::Load::NO_BITMAP
FT2::Load::CROP_BITMAP
FT2::Load::VERTICAL_LAYOUT
FT2::Load::IGNORE_TRANSFORM
FT2::Load::IGNORE_GLOBAL_ADVANCE_WIDTH
FT2::Load::FORCE_AUTOHINT
FT2::Load::NO_RECURSE
FT2::Load::PEDANTIC
Examples:
face.load_glyph 5, FT2::Load::DEFAULT
1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 |
# File 'ext/ft2-ruby/ft2.c', line 1262
static VALUE ft_face_load_glyph(VALUE self, VALUE glyph_index, VALUE flags) {
FT_Face *face;
FT_Error err;
Data_Get_Struct(self, FT_Face, face);
if (flags == Qnil)
flags = INT2FIX(FT_LOAD_DEFAULT);
err = FT_Load_Glyph(*face, NUM2INT(glyph_index), NUM2INT(flags));
if (err != FT_Err_Ok)
handle_error(err);
return self;
}
|
#max_advance_height ⇒ Object
Return the maximal advance height of this FT2::Face object.
Description:
The maximal advance height, in font units, for all glyphs in this
FT2::Face object. This can be used to make word-wrapping
computations faster. Only relevant for scalable formats.
Examples:
mah = face.max_advance_height
969 970 971 972 973 |
# File 'ext/ft2-ruby/ft2.c', line 969
static VALUE ft_face_max_advance_height(VALUE self) {
FT_Face *face;
Data_Get_Struct(self, FT_Face, face);
return INT2FIX((int) (*face)->max_advance_height);
}
|
#max_advance_width ⇒ Object
Return the maximal advance width of this FT2::Face object.
Description:
The maximal advance width, in font units, for all glyphs in this
FT2::Face object. This can be used to make word-wrapping
computations faster. Only relevant for scalable formats.
Examples:
maw = face.max_advance_width
951 952 953 954 955 |
# File 'ext/ft2-ruby/ft2.c', line 951
static VALUE ft_face_max_advance_width(VALUE self) {
FT_Face *face;
Data_Get_Struct(self, FT_Face, face);
return INT2FIX((int) (*face)->max_advance_width);
}
|
#name_index(glyph_name) ⇒ Object
Get the glyph index of a given glyph name.
Note:
This method uses driver specific objects to do the translation.
A return value of 0 means `undefined character code'.
Examples:
index = face.name_index glyph_name
1370 1371 1372 1373 1374 |
# File 'ext/ft2-ruby/ft2.c', line 1370
static VALUE ft_face_name_index(VALUE self, VALUE glyph_name) {
FT_Face *face;
Data_Get_Struct(self, FT_Face, face);
return INT2FIX(FT_Get_Name_Index(*face, RSTRING_PTR(glyph_name)));
}
|
#next_char(char_code) ⇒ Object
Return the next character code of the selected charmap and corresponding glyph index of a FT2::Face object.
Note:
Using this with FT2::Face#first_char will allow you to iterate
through the charmap => glyph index mapping for the selected
charmap. Returns 0 if the charmap is empty, or if there are no
more codes in the charmap.
You should probably use the method FT2::Face#current_charmap
instead.
Examples:
c_code, g_idx = face.first_char
while g_idx != 0
puts "#{c_code} => #{g_idx}"
c_code, g_idx = face.next_char
end
1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 |
# File 'ext/ft2-ruby/ft2.c', line 1577
static VALUE ft_face_next_char(VALUE self, VALUE char_code) {
FT_Face *face;
VALUE ary;
FT_ULong ret_char_code;
FT_UInt glyph_index;
Data_Get_Struct(self, FT_Face, face);
ary = rb_ary_new();
ret_char_code = FT_Get_Next_Char(*face, char_code, &glyph_index);
rb_ary_push(ary, UINT2NUM(ret_char_code));
rb_ary_push(ary, UINT2NUM(glyph_index));
return ary;
}
|
#num_charmaps ⇒ Object
Return the number of charmaps in an FT2::Face object.
Examples:
puts 'number of charmaps: ' << face.num_charmaps
815 816 817 818 819 |
# File 'ext/ft2-ruby/ft2.c', line 815
static VALUE ft_face_num_charmaps(VALUE self) {
FT_Face *face;
Data_Get_Struct(self, FT_Face, face);
return INT2FIX((int) (*face)->num_charmaps);
}
|
#postscript_name ⇒ Object Also known as: name
Get the ASCII Postscript name of a FT2::Face object.
Note:
This should only work with Postscript and TrueType fonts. If the
PostScript name is un-avaialble, nil is returned.
Examples:
ps_name = face.postscript_name
name = face.name
1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 |
# File 'ext/ft2-ruby/ft2.c', line 1466
static VALUE ft_face_ps_name(VALUE self) {
FT_Face *face;
const char *str;
Data_Get_Struct(self, FT_Face, face);
if ((str = FT_Get_Postscript_Name(*face)) != NULL)
return rb_str_new2(str);
else
return Qnil;
}
|
#scalable? ⇒ Boolean
Is this FT2::Face scalable?
Examples:
puts "is scalable" if face.scalable?
536 537 538 539 540 |
# File 'ext/ft2-ruby/ft2.c', line 536
static VALUE ft_face_flag_scalable(VALUE self) {
FT_Face *face;
Data_Get_Struct(self, FT_Face, face);
return ((*face)->face_flags & FT_FACE_FLAG_SCALABLE) ? Qtrue : Qfalse;
}
|
#select_charmap(encoding) ⇒ Object
1490 1491 1492 1493 1494 1495 1496 1497 1498 |
# File 'ext/ft2-ruby/ft2.c', line 1490
static VALUE ft_face_select_charmap(VALUE self, VALUE encoding) {
FT_Face *face;
FT_Error err;
Data_Get_Struct(self, FT_Face, face);
err = FT_Select_Charmap(*face, NUM2INT(encoding));
if (err != FT_Err_Ok)
handle_error(err);
return self;
}
|
#set_char_size(c_w, c_h, h_r, v_r) ⇒ Object
Set the character dimensions of this FT2::Face object.
Description:
Sets the character dimensions of a FT2::Face object. The
`char_width' and `char_height' values are used for the width and
height, respectively, expressed in 26.6 fractional points.
If the horizontal or vertical resolution values are zero, a default
value of 72dpi is used. Similarly, if one of the character
dimensions is zero, its value is set equal to the other.
When dealing with fixed-size faces (i.e., non-scalable formats),
use the function FT2::Face#set_pixel_sizes .
Examples:
face.set_char_size char_width, char_height, horiz_res, vert_res
1114 1115 1116 1117 1118 1119 1120 1121 1122 |
# File 'ext/ft2-ruby/ft2.c', line 1114
static VALUE ft_face_set_char_size(VALUE self, VALUE c_w, VALUE c_h, VALUE h_r, VALUE v_r) {
FT_Face *face;
FT_Error err;
Data_Get_Struct(self, FT_Face, face);
err = FT_Set_Char_Size(*face, NUM2DBL(c_w), NUM2DBL(c_h), NUM2INT(h_r), NUM2INT(v_r));
if (err != FT_Err_Ok)
handle_error(err);
return self;
}
|
#set_charmap(charmap) ⇒ Object Also known as: charmap=
Select the FT2::Face object’s charmap for character code to glyph index decoding.
Examples:
charmap = face.charmaps[0]
face.set_charmap charmap
charmap = face.charmaps[0]
face.charmap = charmap
1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 |
# File 'ext/ft2-ruby/ft2.c', line 1511
static VALUE ft_face_set_charmap(VALUE self, VALUE charmap) {
FT_Face *face;
FT_CharMap *cm;
FT_Error err;
Data_Get_Struct(self, FT_Face, face);
Data_Get_Struct(charmap, FT_CharMap, cm);
err = FT_Set_Charmap(*face, *cm);
if (err != FT_Err_Ok)
handle_error(err);
return self;
}
|
#set_pixel_sizes(pixel_w, pixel_h) ⇒ Object
Set the character dimensions of this FT2::Face object.
Description:
Sets the character dimensions of a FT2::Face object. The width and
height are expressed in integer pixels.
If one of the character dimensions is zero, its value is set equal
to the other.
The values of `pixel_width' and `pixel_height' correspond to the
pixel values of the typographic character size, which are NOT
necessarily the same as the dimensions of the glyph `bitmap cells'.
The `character size' is really the size of an abstract square
called the `EM', used to design the font. However, depending on the
font design, glyphs will be smaller or greater than the EM.
This means that setting the pixel size to, say, 8x8 doesn't
guarantee in any way that you will get glyph bitmaps that all fit
within an 8x8 cell (sometimes even far from it).
Examples:
face.set_pixel_sizes pixel_width, pixel_height
1150 1151 1152 1153 1154 1155 1156 1157 1158 |
# File 'ext/ft2-ruby/ft2.c', line 1150
static VALUE ft_face_set_pixel_sizes(VALUE self, VALUE pixel_w, VALUE pixel_h) {
FT_Face *face;
FT_Error err;
Data_Get_Struct(self, FT_Face, face);
err = FT_Set_Pixel_Sizes(*face, NUM2INT(pixel_w), NUM2INT(pixel_h));
if (err != FT_Err_Ok)
handle_error(err);
return self;
}
|
#set_transform(matrix, delta) ⇒ Object
Set the pre-render transoformation matrix and vector of a FT2::Face object.
Description:
Used to set the transformation that is applied to glyph images just
before they are converted to bitmaps in a FT2::GlyphSlot when
FT2::GlyphSlot#render is called.
matrix: The transformation's 2x2 matrix. Use nil for the identity
matrix.
delta: The translation vector. Use nil for the null vector.
Note:
The transformation is only applied to scalable image formats after
the glyph has been loaded. It means that hinting is unaltered by
the transformation and is performed on the character size given in
the last call to FT2::Face#set_char_sizes or
FT2::Face#set_pixel_sizes.
Examples:
matrix = [[0, 1],
[0, 1]]
vector = nil
face.set_transform matrix, vector
1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 |
# File 'ext/ft2-ruby/ft2.c', line 1187
static VALUE ft_face_set_transform(VALUE self, VALUE matrix, VALUE delta) {
FT_Face *face;
FT_Matrix m;
FT_Vector v;
Data_Get_Struct(self, FT_Face, face);
if (matrix != Qnil) {
/* FIXME: do I have these reversed? */
m.xx = DBL2FTFIX(NUM2DBL(rb_ary_entry(rb_ary_entry(matrix, 0), 0)));
m.xy = DBL2FTFIX(NUM2DBL(rb_ary_entry(rb_ary_entry(matrix, 1), 0)));
m.yx = DBL2FTFIX(NUM2DBL(rb_ary_entry(rb_ary_entry(matrix, 0), 1)));
m.yy = DBL2FTFIX(NUM2DBL(rb_ary_entry(rb_ary_entry(matrix, 1), 1)));
}
if (delta != Qnil) {
v.x = NUM2INT(rb_ary_entry(delta, 0));
v.y = NUM2INT(rb_ary_entry(delta, 1));
}
if (matrix != Qnil && delta != Qnil)
FT_Set_Transform(*face, &m, &v);
else if (matrix == Qnil && delta != Qnil)
FT_Set_Transform(*face, NULL, &v);
else if (matrix != Qnil && delta == Qnil)
FT_Set_Transform(*face, &m, NULL);
else
FT_Set_Transform(*face, NULL, NULL);
return self;
}
|
#sfnt? ⇒ Boolean
Is this FT2::Face stored in the ‘sfnt’ storage format?
Note:
This currently means the file was either TrueType or OpenType.
Examples:
puts "sfnt format font" if face.sfnt?
611 612 613 614 615 |
# File 'ext/ft2-ruby/ft2.c', line 611
static VALUE ft_face_flag_sfnt(VALUE self) {
FT_Face *face;
Data_Get_Struct(self, FT_Face, face);
return ((*face)->face_flags & FT_FACE_FLAG_SFNT) ? Qtrue : Qfalse;
}
|
#size ⇒ Object
Return the current active size of this FT2::Face object.
Examples:
size = face.size
1039 1040 1041 1042 1043 1044 1045 1046 1047 |
# File 'ext/ft2-ruby/ft2.c', line 1039
static VALUE ft_face_size(VALUE self) {
FT_Face *face;
Data_Get_Struct(self, FT_Face, face);
if ((*face)->size)
return Data_Wrap_Struct(cSize, 0, dont_free, (*face)->size);
else
return Qnil;
}
|
#style ⇒ Object
Return the style name of an FT2::Face object.
Description:
This is an ASCII string, usually in English, which describes the
FT2::Face object's style (eg "Bold", "Italic", "Condensed", etc).
This field is optional and may be set to nil.
Examples:
puts 'style: ' << face.style if face.style
763 764 765 766 767 768 769 |
# File 'ext/ft2-ruby/ft2.c', line 763
static VALUE ft_face_style(VALUE self) {
FT_Face *face;
Data_Get_Struct(self, FT_Face, face);
if (!(*face)->style_name)
return Qnil;
return rb_str_new2((*face)->style_name);
}
|
#style_flags ⇒ Object
Return the style flags of an FT2::Face object.
You can binary OR this with any of the following values to obtain the value of that style flag (note that this is returned as an Integer and not as a boolean value; eg non-zero for true and zero for false).
Style Flags:
FT2::Face::BOLD
FT2::Face::ITALIC
Alternatively, if you’re only checking one style flag, it’s slightly faster (and arguably more concise), to use the following style flag methods, which DO return true or false.
Individual Style Flag Methods:
FT2::Face#bold?
FT2::Face#italic?
Examples:
style = face.style_flags
682 683 684 685 686 |
# File 'ext/ft2-ruby/ft2.c', line 682
static VALUE ft_face_style_flags(VALUE self) {
FT_Face *face;
Data_Get_Struct(self, FT_Face, face);
return INT2FIX((int) (*face)->style_flags);
}
|
#underline_position ⇒ Object
Return the underline position of this FT2::Face object.
Description:
The position, in font units, of the underline line for this face.
It's the center of the underlining stem. Only relevant for scalable
formats.
Examples:
uh = face.underline_position
987 988 989 990 991 |
# File 'ext/ft2-ruby/ft2.c', line 987
static VALUE ft_face_underline_position(VALUE self) {
FT_Face *face;
Data_Get_Struct(self, FT_Face, face);
return INT2FIX((int) (*face)->underline_position);
}
|
#underline_thickness ⇒ Object
Return the underline thickness of this FT2::Face object.
Description:
The thickness, in font units, of the underline for this face. Only
relevant for scalable formats.
Examples:
ut = face.underline_thickness
1004 1005 1006 1007 1008 |
# File 'ext/ft2-ruby/ft2.c', line 1004
static VALUE ft_face_underline_thickness(VALUE self) {
FT_Face *face;
Data_Get_Struct(self, FT_Face, face);
return INT2FIX((int) (*face)->underline_thickness);
}
|
#units_per_em ⇒ Object Also known as: units_per_EM
878 879 880 881 882 |
# File 'ext/ft2-ruby/ft2.c', line 878
static VALUE ft_face_units_per_em(VALUE self) {
FT_Face *face;
Data_Get_Struct(self, FT_Face, face);
return INT2FIX((int) (*face)->units_per_EM);
}
|
#vertical? ⇒ Boolean
Does this FT2::Face contain vertical glyph metrics?
Note:
If this flag is not set, the glyph loader will synthesize vertical
metrics itself.
Examples:
puts "contains vertical glyph metrics" if face.vertical?
595 596 597 598 599 |
# File 'ext/ft2-ruby/ft2.c', line 595
static VALUE ft_face_flag_vertical(VALUE self) {
FT_Face *face;
Data_Get_Struct(self, FT_Face, face);
return ((*face)->face_flags & FT_FACE_FLAG_VERTICAL) ? Qtrue : Qfalse;
}
|