This repository has been archived on 2023-10-09. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
blender-archive/extern/bFTGL/src/FTSize.cpp
Kent Mein 26f63bfa19 Added bFTGL to extern and updated the Makefiles. I'm guessing there will
need to be tweaks but it seems to work on my linux box.  I haven't
touched any of the other build systems so those will need to be done.

We probably don't need all of this stuff but I figured better to add a little
too much then to little.

Kent
2005-01-21 05:15:33 +00:00

106 lines
1.8 KiB
C++
Executable File

#include "FTSize.h"
FTSize::FTSize()
: ftFace(0),
ftSize(0),
size(0),
err(0)
{}
FTSize::~FTSize()
{}
bool FTSize::CharSize( FT_Face* face, unsigned int point_size, unsigned int x_resolution, unsigned int y_resolution )
{
err = FT_Set_Char_Size( *face, 0L, point_size * 64, x_resolution, y_resolution);
if( !err)
{
ftFace = face;
size = point_size;
ftSize = (*ftFace)->size;
}
else
{
ftFace = 0;
size = 0;
ftSize = 0;
}
return !err;
}
unsigned int FTSize::CharSize() const
{
return size;
}
float FTSize::Ascender() const
{
return ftSize == 0 ? 0.0f : static_cast<float>( ftSize->metrics.ascender) / 64.0f;
}
float FTSize::Descender() const
{
return ftSize == 0 ? 0.0f : static_cast<float>( ftSize->metrics.descender) / 64.0f;
}
float FTSize::Height() const
{
if( 0 == ftSize)
{
return 0.0f;
}
if( FT_IS_SCALABLE((*ftFace)))
{
return ( (*ftFace)->bbox.yMax - (*ftFace)->bbox.yMin) * ( (float)ftSize->metrics.y_ppem / (float)(*ftFace)->units_per_EM);
}
else
{
return static_cast<float>( ftSize->metrics.height) / 64.0f;
}
}
float FTSize::Width() const
{
if( 0 == ftSize)
{
return 0.0f;
}
if( FT_IS_SCALABLE((*ftFace)))
{
return ( (*ftFace)->bbox.xMax - (*ftFace)->bbox.xMin) * ( static_cast<float>(ftSize->metrics.x_ppem) / static_cast<float>((*ftFace)->units_per_EM));
}
else
{
return static_cast<float>( ftSize->metrics.max_advance) / 64.0f;
}
}
float FTSize::Underline() const
{
return 0.0f;
}
unsigned int FTSize::XPixelsPerEm() const
{
return ftSize == 0 ? 0 : ftSize->metrics.x_ppem;
}
unsigned int FTSize::YPixelsPerEm() const
{
return ftSize == 0 ? 0 : ftSize->metrics.y_ppem;
}