viewBox for glyphpaths added
This commit is contained in:
parent
f96dc71b49
commit
0a3c3fda73
|
@ -326,6 +326,12 @@ static uint qskGlyphCount( const QRawFont& font )
|
|||
return fontEngine ? fontEngine->glyphCount() : 0;
|
||||
}
|
||||
|
||||
static qreal qskPixelSize( const QRawFont& font )
|
||||
{
|
||||
const auto fontEngine = QRawFontPrivate::get( font )->fontEngine;
|
||||
return fontEngine ? fontEngine->fontDef.pixelSize : 0.0;
|
||||
}
|
||||
|
||||
static GlyphNameTable qskGlyphNameTable( const QRawFont& font )
|
||||
{
|
||||
const auto count = qskGlyphCount( font );
|
||||
|
@ -452,10 +458,16 @@ QskGraphic QskGlyphTable::glyphGraphic( uint glyphIndex ) const
|
|||
|
||||
if ( glyphIndex > 0 && qskGlyphCount( m_data->font ) > 0 )
|
||||
{
|
||||
const auto path = glyphPath( glyphIndex );
|
||||
auto path = glyphPath( glyphIndex );
|
||||
|
||||
if ( !path.isEmpty() )
|
||||
{
|
||||
// vertical glyph coordinates are from [-sz, 0.0]
|
||||
const auto sz = qskPixelSize( m_data->font );
|
||||
|
||||
path.translate( 0.0, sz );
|
||||
graphic.setViewBox( QRectF( 0.0, 0.0, sz, sz ) );
|
||||
|
||||
QPainter painter( &graphic );
|
||||
painter.setRenderHint( QPainter::Antialiasing, true );
|
||||
painter.fillPath( path, Qt::black );
|
||||
|
|
|
@ -34,9 +34,11 @@ int main( int argc, char* argv[] )
|
|||
return -1;
|
||||
}
|
||||
|
||||
const int pixelSize = 24; // something
|
||||
|
||||
QGuiApplication app( argc, argv );
|
||||
|
||||
QRawFont font( QString( argv[1] ), 16 );
|
||||
QRawFont font( QString( argv[1] ), pixelSize );
|
||||
if ( !font.isValid() )
|
||||
{
|
||||
qWarning() << "invalid font name:" << argv[1];
|
||||
|
@ -52,14 +54,16 @@ int main( int argc, char* argv[] )
|
|||
return -3;
|
||||
}
|
||||
|
||||
const auto path = font.pathForGlyph( glyphIndex );
|
||||
auto path = font.pathForGlyph( glyphIndex );
|
||||
if ( path.isEmpty() )
|
||||
{
|
||||
qWarning() << "no glyph for index:" << argv[2];
|
||||
return -3;
|
||||
}
|
||||
path.translate( 0.0, pixelSize );
|
||||
|
||||
QskGraphic graphic;
|
||||
graphic.setViewBox( QRectF( 0.0, 0.0, pixelSize, pixelSize ) );
|
||||
|
||||
QPainter painter( &graphic );
|
||||
painter.setRenderHint( QPainter::Antialiasing, true );
|
||||
|
|
Loading…
Reference in New Issue