2017-07-21 18:21:34 +02:00
|
|
|
/******************************************************************************
|
2024-01-17 14:31:45 +01:00
|
|
|
* QSkinny - Copyright (C) The authors
|
2023-04-06 09:23:37 +02:00
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
2017-07-21 18:21:34 +02:00
|
|
|
*****************************************************************************/
|
|
|
|
|
2019-01-07 09:13:53 +01:00
|
|
|
#if defined( QSK_STANDALONE )
|
2018-10-22 10:09:37 +02:00
|
|
|
#include <QskGraphic.cpp>
|
|
|
|
#include <QskRgbValue.cpp>
|
|
|
|
#include <QskColorFilter.cpp>
|
|
|
|
#include <QskPainterCommand.cpp>
|
|
|
|
#include <QskGraphicPaintEngine.cpp>
|
|
|
|
#include <QskGraphicIO.cpp>
|
|
|
|
#else
|
2017-07-21 18:21:34 +02:00
|
|
|
#include <QskGraphicIO.h>
|
|
|
|
#include <QskGraphic.h>
|
2018-10-22 10:09:37 +02:00
|
|
|
#endif
|
|
|
|
|
2018-11-06 09:02:58 +01:00
|
|
|
#include <QGuiApplication>
|
2017-07-21 18:21:34 +02:00
|
|
|
#include <QSvgRenderer>
|
2018-07-19 14:10:48 +02:00
|
|
|
#include <QPainter>
|
2017-07-21 18:21:34 +02:00
|
|
|
#include <QDebug>
|
|
|
|
|
|
|
|
static void usage( const char* appName )
|
|
|
|
{
|
2018-07-19 14:10:48 +02:00
|
|
|
qWarning() << "usage: " << appName << "svgfile qvgfile";
|
2017-07-21 18:21:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int main( int argc, char* argv[] )
|
|
|
|
{
|
|
|
|
if ( argc != 3 )
|
|
|
|
{
|
|
|
|
usage( argv[0] );
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2020-03-17 12:01:50 +01:00
|
|
|
#if 0
|
|
|
|
/*
|
|
|
|
When there are no "text" parts in the SVGs we can avoid
|
|
|
|
the costs of initializing not needed fonts
|
|
|
|
by using the minimal plugin.
|
|
|
|
*/
|
|
|
|
qputenv( "QT_QPA_PLATFORM", "minimal" );
|
|
|
|
#endif
|
|
|
|
|
2018-11-13 09:42:44 +01:00
|
|
|
#if 1
|
|
|
|
/*
|
|
|
|
When having a SVG with specific font assignments Qt runs on
|
|
|
|
qGuiApp to load a default font. Makes no sense in this context,
|
|
|
|
but to avoid having segfaults ...
|
|
|
|
*/
|
2018-11-06 09:02:58 +01:00
|
|
|
QGuiApplication app( argc, argv );
|
2018-11-13 09:42:44 +01:00
|
|
|
#endif
|
2018-11-06 09:02:58 +01:00
|
|
|
|
2017-07-21 18:21:34 +02:00
|
|
|
QSvgRenderer renderer;
|
|
|
|
if ( !renderer.load( QString( argv[1] ) ) )
|
|
|
|
return -2;
|
|
|
|
|
|
|
|
QskGraphic graphic;
|
|
|
|
|
2024-04-17 14:46:29 +02:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
QSvgRenderer::viewBoxF() returns a bounding box when no viewBox
|
|
|
|
has been defined. So we clear the viewBox and compare the result with
|
|
|
|
the initial value - assuming, that there was a viewBox when they differ.
|
|
|
|
|
|
|
|
*/
|
|
|
|
const auto viewBox = renderer.viewBoxF();
|
|
|
|
renderer.setViewBox( QRectF() );
|
|
|
|
|
|
|
|
if ( viewBox != renderer.viewBoxF() )
|
|
|
|
graphic.setViewBox( viewBox );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-07-21 18:21:34 +02:00
|
|
|
QPainter painter( &graphic );
|
|
|
|
renderer.render( &painter );
|
|
|
|
painter.end();
|
|
|
|
|
2019-12-04 18:33:30 +01:00
|
|
|
if ( graphic.commandTypes() & QskGraphic::RasterData )
|
2019-10-16 10:07:34 +02:00
|
|
|
qWarning() << argv[1] << "contains non scalable parts.";
|
|
|
|
|
2017-07-21 18:21:34 +02:00
|
|
|
QskGraphicIO::write( graphic, argv[2] );
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|