qskinny/tools/svg2qvg/main.cpp

72 lines
1.7 KiB
C++
Raw Normal View History

2017-07-21 18:21:34 +02:00
/******************************************************************************
* QSkinny - Copyright (C) 2016 Uwe Rathmann
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 )
#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>
#endif
#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;
}
#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 ...
*/
QGuiApplication app( argc, argv );
2018-11-13 09:42:44 +01:00
#endif
2017-07-21 18:21:34 +02:00
QSvgRenderer renderer;
if ( !renderer.load( QString( argv[1] ) ) )
return -2;
QskGraphic graphic;
QPainter painter( &graphic );
renderer.render( &painter );
painter.end();
2019-12-04 18:33:30 +01:00
if ( graphic.commandTypes() & QskGraphic::RasterData )
qWarning() << argv[1] << "contains non scalable parts.";
2017-07-21 18:21:34 +02:00
QskGraphicIO::write( graphic, argv[2] );
return 0;
}