From 88a501d998b00791e8974ad31202360669fc00d5 Mon Sep 17 00:00:00 2001 From: Uwe Rathmann Date: Mon, 10 Feb 2025 15:14:41 +0100 Subject: [PATCH] avoid viewBox translation --- src/graphic/QskGlyphTable.cpp | 8 +++----- tools/glyph2qvg/main.cpp | 11 ++++++----- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/graphic/QskGlyphTable.cpp b/src/graphic/QskGlyphTable.cpp index e166d5d7..13cd7607 100644 --- a/src/graphic/QskGlyphTable.cpp +++ b/src/graphic/QskGlyphTable.cpp @@ -458,15 +458,13 @@ QskGraphic QskGlyphTable::glyphGraphic( uint glyphIndex ) const if ( glyphIndex > 0 && qskGlyphCount( m_data->font ) > 0 ) { - auto path = glyphPath( glyphIndex ); + const auto path = glyphPath( glyphIndex ); if ( !path.isEmpty() ) { - // vertical glyph coordinates are from [-sz, 0.0] + // vertical glyph coordinates are in the range [-sz, 0.0] const auto sz = qskPixelSize( m_data->font ); - - path.translate( 0.0, sz ); - graphic.setViewBox( QRectF( 0.0, 0.0, sz, sz ) ); + graphic.setViewBox( QRectF( 0.0, -sz, sz, sz ) ); QPainter painter( &graphic ); painter.setRenderHint( QPainter::Antialiasing, true ); diff --git a/tools/glyph2qvg/main.cpp b/tools/glyph2qvg/main.cpp index feea2643..ba3053c5 100644 --- a/tools/glyph2qvg/main.cpp +++ b/tools/glyph2qvg/main.cpp @@ -34,11 +34,11 @@ int main( int argc, char* argv[] ) return -1; } - const int pixelSize = 24; // something + const int sz = 24; // something QGuiApplication app( argc, argv ); - QRawFont font( QString( argv[1] ), pixelSize ); + QRawFont font( QString( argv[1] ), sz ); if ( !font.isValid() ) { qWarning() << "invalid font name:" << argv[1]; @@ -54,16 +54,17 @@ int main( int argc, char* argv[] ) return -3; } - auto path = font.pathForGlyph( glyphIndex ); + const 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 ) ); + + // vertical glyph coordinates are in the range [-sz, 0.0] + graphic.setViewBox( QRectF( 0.0, -sz, sz, sz ) ); QPainter painter( &graphic ); painter.setRenderHint( QPainter::Antialiasing, true );