~ubuntu-branches/ubuntu/gutsy/blender/gutsy-security

« back to all changes in this revision

Viewing changes to extern/bFTGL/src/FTSize.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Florian Ernst
  • Date: 2005-11-06 12:40:03 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051106124003-3pgs7tcg5rox96xg
Tags: 2.37a-1.1
* Non-maintainer upload.
* Split out parts of 01_SConstruct_debian.dpatch again: root_build_dir
  really needs to get adjusted before the clean target runs - closes: #333958,
  see #288882 for reference

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include    "FTSize.h"
 
2
 
 
3
 
 
4
FTSize::FTSize()
 
5
:   ftFace(0),
 
6
    ftSize(0),
 
7
    size(0),
 
8
    err(0)
 
9
{}
 
10
 
 
11
 
 
12
FTSize::~FTSize()
 
13
{}
 
14
 
 
15
 
 
16
bool FTSize::CharSize( FT_Face* face, unsigned int point_size, unsigned int x_resolution, unsigned int y_resolution )
 
17
{
 
18
    err = FT_Set_Char_Size( *face, 0L, point_size * 64, x_resolution, y_resolution);
 
19
 
 
20
    if( !err)
 
21
    {
 
22
        ftFace = face;
 
23
        size = point_size;
 
24
        ftSize = (*ftFace)->size;
 
25
    }
 
26
    else
 
27
    {
 
28
        ftFace = 0;
 
29
        size = 0;
 
30
        ftSize = 0;
 
31
    }
 
32
    
 
33
    return !err;
 
34
}
 
35
 
 
36
 
 
37
unsigned int FTSize::CharSize() const
 
38
{
 
39
    return size;
 
40
}
 
41
 
 
42
 
 
43
float FTSize::Ascender() const
 
44
{
 
45
    return ftSize == 0 ? 0.0f : static_cast<float>( ftSize->metrics.ascender) / 64.0f;
 
46
}
 
47
 
 
48
 
 
49
float FTSize::Descender() const
 
50
{
 
51
    return ftSize == 0 ? 0.0f : static_cast<float>( ftSize->metrics.descender) / 64.0f;
 
52
}
 
53
 
 
54
 
 
55
float FTSize::Height() const
 
56
{
 
57
    if( 0 == ftSize)
 
58
    {
 
59
        return 0.0f;
 
60
    }
 
61
    
 
62
    if( FT_IS_SCALABLE((*ftFace)))
 
63
    {
 
64
        return ( (*ftFace)->bbox.yMax - (*ftFace)->bbox.yMin) * ( (float)ftSize->metrics.y_ppem / (float)(*ftFace)->units_per_EM);
 
65
    }
 
66
    else
 
67
    {
 
68
        return static_cast<float>( ftSize->metrics.height) / 64.0f;
 
69
    }
 
70
}
 
71
 
 
72
 
 
73
float FTSize::Width() const
 
74
{
 
75
    if( 0 == ftSize)
 
76
    {
 
77
        return 0.0f;
 
78
    }
 
79
    
 
80
    if( FT_IS_SCALABLE((*ftFace)))
 
81
    {
 
82
        return ( (*ftFace)->bbox.xMax - (*ftFace)->bbox.xMin) * ( static_cast<float>(ftSize->metrics.x_ppem) / static_cast<float>((*ftFace)->units_per_EM));
 
83
    }
 
84
    else
 
85
    {
 
86
        return static_cast<float>( ftSize->metrics.max_advance) / 64.0f;
 
87
    }
 
88
}
 
89
 
 
90
 
 
91
float FTSize::Underline() const
 
92
{
 
93
    return 0.0f;
 
94
}
 
95
 
 
96
unsigned int FTSize::XPixelsPerEm() const
 
97
{
 
98
    return ftSize == 0 ? 0 : ftSize->metrics.x_ppem;
 
99
}
 
100
 
 
101
unsigned int FTSize::YPixelsPerEm() const
 
102
{
 
103
    return ftSize == 0 ? 0 : ftSize->metrics.y_ppem;
 
104
}
 
105