File indexing completed on 2024-04-14 05:44:29

0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 // SPDX-FileCopyrightText: 2010 Dominik Seichter <domseichter@web.de>
0003 
0004 #ifndef FONT_PLUGIN_H
0005 #define FONT_PLUGIN_H
0006 
0007 #include "fileplugin.h"
0008 
0009 #include <QMap>
0010 
0011 #include <ft2build.h>
0012 #include FT_FREETYPE_H
0013 
0014 class FontPlugin : public FilePlugin
0015 {
0016 public:
0017     explicit FontPlugin(PluginLoader *loader);
0018 
0019     ~FontPlugin() override;
0020 
0021     /**
0022      * This function is the core of your plugin.
0023      *
0024      * It does the actual processing of a file, filename or token depending of the type
0025      * of your plugin.
0026      *
0027      * \see type()
0028      *
0029      * @param b the parent BatchRenamer instance calling this plugin
0030      * @param index the index of the current file (i.e. the first file has index 0,
0031      *              the second file to be renamed has index 1 ....)
0032      * @param filenameOrToken this parameter depends on the type of your plugin.
0033      *                        If type is ePluginType_File, this is the absolute path
0034      *                        or URL to the renamed file.
0035      *                        If type is ePluginType_Filename, this is the filename
0036      *                        (without path) as created by KRename.
0037      *                        If type is ePluginType_Token, this is the contents of a token
0038      *                        in brackets. If your plugin supports the token [example],
0039      *                        KRename will pass the strign "example" to your method.
0040      * @param eCurrentType the current type of plugin that is requested (for plugins that support more than one type)
0041      *
0042      * @returns the result of the function, depending on type().
0043      * @returns an empty QString if this plugin has nothing to do.
0044      * @returns A new filename if type is ePluginType_Filename
0045      * @returns the value of the token if type is ePluginType_Token
0046      * @returns an error message or an empty QString if type is ePluginType_File
0047      */
0048     QString processFile(BatchRenamer *b, int index, const QString &filenameOrToken, EPluginType eCurrentType) override;
0049 
0050     /** Returns help descriptions for the supported tokens
0051      *
0052      *  The returned stringlist contains strings that are the tokens
0053      *  and the description separated by ;;
0054      *
0055      *  @returns a stringlist containing help on the supported tokens
0056      */
0057     inline const QStringList &help() const override;
0058 
0059 private:
0060     QStringList           m_help;
0061 
0062     FT_Library            m_library;
0063 };
0064 
0065 inline const QStringList &FontPlugin::help() const
0066 {
0067     return m_help;
0068 }
0069 
0070 #endif // FONT_PLUGIN_H