qskinny/tools/svg2qvg/main.cpp
2019-12-04 18:33:30 +01:00

64 lines
1.5 KiB
C++

/******************************************************************************
* QSkinny - Copyright (C) 2016 Uwe Rathmann
* This file may be used under the terms of the QSkinny License, Version 1.0
*****************************************************************************/
#if defined( QSK_STANDALONE )
#include <QskGraphic.cpp>
#include <QskRgbValue.cpp>
#include <QskColorFilter.cpp>
#include <QskPainterCommand.cpp>
#include <QskGraphicPaintEngine.cpp>
#include <QskGraphicIO.cpp>
#else
#include <QskGraphicIO.h>
#include <QskGraphic.h>
#endif
#include <QGuiApplication>
#include <QSvgRenderer>
#include <QPainter>
#include <QDebug>
static void usage( const char* appName )
{
qWarning() << "usage: " << appName << "svgfile qvgfile";
}
int main( int argc, char* argv[] )
{
if ( argc != 3 )
{
usage( argv[0] );
return -1;
}
#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 ...
*/
qputenv( "QT_QPA_PLATFORM", "minimal" );
QGuiApplication app( argc, argv );
#endif
QSvgRenderer renderer;
if ( !renderer.load( QString( argv[1] ) ) )
return -2;
QskGraphic graphic;
QPainter painter( &graphic );
renderer.render( &painter );
painter.end();
if ( graphic.commandTypes() & QskGraphic::RasterData )
qWarning() << argv[1] << "contains non scalable parts.";
QskGraphicIO::write( graphic, argv[2] );
return 0;
}