Fixes as per @sethhillbrand's comments
This commit is contained in:
parent
383beeba8e
commit
5b7198dfc8
|
@ -107,9 +107,9 @@ void FONTCONFIG::ListFonts( std::vector<std::string>& aFonts )
|
|||
std::ostringstream s;
|
||||
s << family;
|
||||
|
||||
std::string theFile( (char*) file );
|
||||
std::string theFamily( (char*) family );
|
||||
std::string theStyle( (char*) style );
|
||||
std::string theFile( reinterpret_cast<char *>( file ) );
|
||||
std::string theFamily( reinterpret_cast<char *>( family ) );
|
||||
std::string theStyle( reinterpret_cast<char *>( style ) );
|
||||
FONTINFO fontInfo( theFile, theStyle, theFamily );
|
||||
|
||||
if( theFamily.length() > 0 && theFamily.front() == '.' )
|
||||
|
|
|
@ -148,34 +148,33 @@ void OUTLINE_DECOMPOSER::OutlineToSegments( CONTOURS* aContours )
|
|||
|
||||
|
||||
// use converter in kimath
|
||||
bool OUTLINE_DECOMPOSER::approximateQuadraticBezierCurve( GLYPH_POINTS& aResult,
|
||||
bool OUTLINE_DECOMPOSER::approximateQuadraticBezierCurve( GLYPH_POINTS& aResult,
|
||||
const GLYPH_POINTS& aBezier ) const
|
||||
{
|
||||
// TODO: assert aBezier.size == 3
|
||||
wxASSERT( aBezier.size() == 3 );
|
||||
|
||||
// BEZIER_POLY only handles cubic Bezier curves, even though the comments say otherwise...
|
||||
// BEZIER_POLY only handles cubic Bezier curves, even though the
|
||||
// comments say otherwise...
|
||||
//
|
||||
// Quadratic to cubic Bezier conversion:
|
||||
// cpn = Cubic Bezier control points (n = 0..3, 4 in total)
|
||||
// qpn = Quadratic Bezier control points (n = 0..2, 3 in total)
|
||||
// cp0 = qp0, cp1 = qp0 + 2/3 * (qp1 - qp0), cp2 = qp2 + 2/3 * (qp1 - qp2), cp3 = qp2
|
||||
|
||||
static const double twoThirds = 2 / 3.0;
|
||||
|
||||
GLYPH_POINTS cubic;
|
||||
cubic.push_back( aBezier.at( 0 ) ); // cp0
|
||||
cubic.push_back( aBezier.at( 0 ) + twoThirds * ( aBezier.at( 1 ) - aBezier.at( 0 ) ) ); // cp1
|
||||
cubic.push_back( aBezier.at( 2 ) + twoThirds * ( aBezier.at( 1 ) - aBezier.at( 2 ) ) ); // cp2
|
||||
cubic.push_back( aBezier.at( 2 ) ); // cp3
|
||||
cubic.push_back( aBezier[0] ); // cp0
|
||||
cubic.push_back( aBezier[0] + ( ( aBezier[1] - aBezier[0] ) * 2 / 3 ) ); // cp1
|
||||
cubic.push_back( aBezier[2] + ( ( aBezier[1] - aBezier[2] ) * 2 / 3 ) ); // cp2
|
||||
cubic.push_back( aBezier[2] ); // cp3
|
||||
|
||||
return approximateCubicBezierCurve( aResult, cubic );
|
||||
}
|
||||
|
||||
|
||||
bool OUTLINE_DECOMPOSER::approximateCubicBezierCurve( GLYPH_POINTS& aResult,
|
||||
bool OUTLINE_DECOMPOSER::approximateCubicBezierCurve( GLYPH_POINTS& aResult,
|
||||
const GLYPH_POINTS& aCubicBezier ) const
|
||||
{
|
||||
// TODO: assert aCubicBezier.size == 4
|
||||
wxASSERT( aCubicBezier.size() == 4 );
|
||||
|
||||
// TODO: find out what the minimum segment length should really be!
|
||||
static const int minimumSegmentLength = 50;
|
||||
|
@ -184,21 +183,27 @@ bool OUTLINE_DECOMPOSER::approximateCubicBezierCurve( GLYPH_POINTS& aResult,
|
|||
converter.GetPoly( tmp, minimumSegmentLength );
|
||||
|
||||
for( unsigned int i = 0; i < tmp.size(); i++ )
|
||||
aResult.push_back( tmp.at( i ) );
|
||||
aResult.push_back( tmp[i] );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool OUTLINE_DECOMPOSER::approximateBezierCurve( GLYPH_POINTS& aResult,
|
||||
bool OUTLINE_DECOMPOSER::approximateBezierCurve( GLYPH_POINTS& aResult,
|
||||
const GLYPH_POINTS& aBezier ) const
|
||||
{
|
||||
bool bezierIsCubic = ( aBezier.size() == 4 );
|
||||
|
||||
if( bezierIsCubic )
|
||||
switch( aBezier.size() )
|
||||
{
|
||||
case 4: // cubic
|
||||
return approximateCubicBezierCurve( aResult, aBezier );
|
||||
else
|
||||
break;
|
||||
case 3: // quadratic
|
||||
return approximateQuadraticBezierCurve( aResult, aBezier );
|
||||
break;
|
||||
default:
|
||||
// error, only 3 and 4 are acceptable values
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -106,12 +106,13 @@ bool OUTLINE_FONT::loadFontSimple( const wxString& aFontFileName )
|
|||
|
||||
if( ft_error == FT_Err_Unknown_File_Format )
|
||||
{
|
||||
std::cerr << "The font file " << fileName << " could be opened and read, "
|
||||
<< "but it appears that its font format is unsupported." << std::endl;
|
||||
wxLogWarning( _( "The font file %s could be opened and read, "
|
||||
"but it appears that its font format is unsupported." ),
|
||||
fileName );
|
||||
}
|
||||
else if( ft_error )
|
||||
{
|
||||
std::cerr << "ft_error " << ft_error << std::endl;
|
||||
wxLogWarning( _( "Unknown font error (%d) " ), ft_error );
|
||||
return false;
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue