コード例 #1
0
    /// <summary>
    /// Makes the atlas.
    /// </summary>
    protected void MakeAtlas(string lang, ref LocalizationFontConfig.FontConfig config)
    {
        string filename = System.IO.Path.Combine(_toolDirectory, ToolAtlasMaker);
        string path     = LocalizationEditorUtils.CreateDirectoryIfNotExist(_workDirectory, "Fonts", lang);

        config._atlasFile = System.IO.Path.Combine(path, config._fontName + ".png");

        LocalizationCommand cmd = new LocalizationCommand("python");

        cmd.SetRequiredParams(filename, config._imagesDir, config._atlasFile);
        cmd.AddOptionalParams("-p", config._padding);

        cmd.Execute();


        _buildProgress += _buildstep;
        EditorUtility.DisplayCancelableProgressBar("Fonts maker", "Building...", _buildProgress);
    }
コード例 #2
0
    protected bool BuildFont(string lang, TextAsset charsetAsset, LocalizationFontConfig.FontConfig config)
    {
        Debug.Log("Localization: " + lang + " " + config._fontName + " build begin...");

        if (!CheckFont(config))
        {
            Debug.LogWarning("Localization: " + lang + " " + config._fontName + " config is not valid!");

            return(false);
        }

        string path = System.IO.Path.Combine(_workDirectory, "Fonts");

        path = System.IO.Path.Combine(path, lang);

        if (!System.IO.Directory.Exists(path))
        {
            System.IO.Directory.CreateDirectory(path);
        }

        string charsetFile = System.IO.Path.Combine(MultiLanguageAssetPostProcessor.MULTILANGUAGE_COMMON_FOLDER, lang + "_dict.txt");

        if (!System.IO.File.Exists(charsetFile))
        {
            EditorUtility.DisplayDialog("Fonts Maker", charsetFile + " is not exist!", "OK");

            return(false);
        }


        CreateImages(lang, ref config, charsetFile);

        ReplaceCustomImages(lang, ref config);

        MakeAtlas(lang, ref config);

        GenerateFnt(lang, ref config);

        Debug.Log("Localization: " + lang + " " + config._fontName + " build end...");

        return(true);
    }
コード例 #3
0
    /// <summary>
    /// Creates the images.
    /// </summary>
    protected void CreateImages(string lang, ref LocalizationFontConfig.FontConfig config, string charsetFile)
    {
        string filename = System.IO.Path.Combine(_toolDirectory, ToolTTF2Images);

        LocalizationCommand cmd = new LocalizationCommand(filename);

        config._imagesDir = LocalizationEditorUtils.CreateDirectoryIfNotExist(_toolDirectory, "Temp", lang, config._fontName);
        config._font_info = System.IO.Path.Combine(config._imagesDir, "font_info.txt");

        cmd.SetRequiredParams(config._ttfFile, config._fontSize, config._imagesDir);

        cmd.AddOptionalParams("-p", config._border);
        cmd.AddOptionalParams("-C", charsetFile);

        cmd.Execute();


        _buildProgress += _buildstep;
        EditorUtility.DisplayCancelableProgressBar("Fonts maker", "Building...", _buildProgress);
    }
コード例 #4
0
    protected bool CheckFont(LocalizationFontConfig.FontConfig fontConfig)
    {
        if (fontConfig._fontName == "")
        {
            EditorUtility.DisplayDialog("Fonts Maker", "Font Name Can't be empty!", "OK");

            Debug.LogWarning("Localization: fontConfig._fontName == null");

            return(false);
        }

        if (fontConfig._ttfFile == "")
        {
            EditorUtility.DisplayDialog("Fonts Maker", "True Type file Can't be empty!", "OK");

            Debug.LogWarning("Localization: fontConfig._ttfFile == null");

            return(false);
        }

        if (!System.IO.File.Exists(fontConfig._ttfFile))
        {
            EditorUtility.DisplayDialog("Fonts Maker", "True Type file is not exist!", "OK");

            Debug.LogWarning("Localization: fontConfig._ttfFile is not Exists");

            return(false);
        }

        if (fontConfig._fontSize <= 0)
        {
            EditorUtility.DisplayDialog("Fonts Maker", "Font size must be bigger than 0 !", "OK");

            Debug.LogWarning("Localization: fontConfig._fontSize must be bigger than 0");

            return(false);
        }

        return(true);
    }
コード例 #5
0
    /// <summary>
    /// Generates the fnt.
    /// </summary>
    protected void GenerateFnt(string lang, ref LocalizationFontConfig.FontConfig config)
    {
        string filename = System.IO.Path.Combine(_toolDirectory, ToolFntMaker);
        string path     = LocalizationEditorUtils.CreateDirectoryIfNotExist(_workDirectory, "Fonts", lang);
        string fntFile  = System.IO.Path.Combine(path, config._fontName + ".fnt");
        string txfFile  = System.IO.Path.Combine(path, config._fontName + ".txt");

        path = System.IO.Path.Combine(path, config._fontName + ".config");

        LocalizationCommand cmd = new LocalizationCommand("python");

        cmd.SetRequiredParams(filename, path, config._atlasFile, config._font_info);

        cmd.Execute();

        // Rename *.fnt to *.txt
        System.IO.File.Delete(txfFile);
        System.IO.File.Move(fntFile, txfFile);

        _buildProgress += _buildstep;
        EditorUtility.DisplayCancelableProgressBar("Fonts maker", "Building...", _buildProgress);
    }
コード例 #6
0
    protected void ReplaceCustomImages(string lang, ref LocalizationFontConfig.FontConfig config)
    {
        if (config._customImagesPath == "")
        {
            return;
        }

        if (!System.IO.Directory.Exists(config._customImagesPath))
        {
            return;
        }

        string filename         = System.IO.Path.Combine(_toolDirectory, ToolCustomImages);
        LocalizationCommand cmd = new LocalizationCommand("python");

        cmd.SetRequiredParams(filename, config._imagesDir, config._imagesDir, config._customImagesPath);

        cmd.Execute();


        _buildProgress += _buildstep;
        EditorUtility.DisplayCancelableProgressBar("Fonts maker", "Building...", _buildProgress);
    }