Esempio n. 1
0
        /// <summary>
        /// Runs the PSD specific cases examples
        /// </summary>
        private static void RunPsdSpecificCases()
        {
            Console.WriteLine("Starting PSD Specific Cases Examples");

            SettingforReplacingMissingFonts.Run();
            SupportEditingGlobalFontList.Run();
            ImplementBicubicResampler.Run();
            DetectFlattenedPSD.Run();
            ColorReplacementInPSD.Run();
            CreateThumbnailsFromPSDFiles.Run();
            CreateIndexedPSDFiles.Run();
            ExtractThumbnailFromJFIF.Run();
            AddThumbnailToJFIFSegment.Run();
            AddThumbnailToEXIFSegment.Run();
            ReadandModifyJpegEXIFTags.Run();
            ReadAllEXIFTagList.Run();
            ImplementLossyGIFCompressor.Run();
            ForceFontCache.Run();
            FontReplacement.Run();
            ReadAllEXIFTags.Run();
            ReadSpecificEXIFTagsInformation.Run();
            WritingAndModifyingEXIFData.Run();
            SupportForJPEG_LSWithCMYK.Run();
            SupportFor2_7BitsJPEG.Run();
            ClassesToManipulateVectorPathObjects.Run();
            ResizeLayersWithVogkResourceAndVectorPaths.Run();
            ResizeLayersWithVectorPaths.Run();
        }
        private static bool AddFontReplacement(string asset)
        {
            if (PlatDependant.IsFileExist(asset))
            {
                try
                {
                    var desc = AssetDatabase.LoadAssetAtPath <CapsFontReplacement>(asset);
                    if (desc)
                    {
                        try
                        {
                            var    phname = desc.PlaceHolderFontName;
                            var    rfont = desc.SubstituteFont;
                            string type, mod, dist;
                            string norm = ResManager.GetAssetNormPath(asset, out type, out mod, out dist);

                            if (!_FontReplacementDescs.ContainsKey(asset))
                            {
                                var info = new FontReplacement()
                                {
                                    PlaceHolderFontName = phname,
                                    SubstituteFont      = rfont,
                                    DescAssetPath       = asset,
                                    Mod  = mod,
                                    Dist = dist,
                                };
                                List <FontReplacement> list;
                                if (!_FontReplacements.TryGetValue(phname, out list))
                                {
                                    list = new List <FontReplacement>();
                                    _FontReplacements[phname] = list;
                                }
                                list.Add(info);

                                _FontReplacementDescs[asset] = info;
                                return(true);
                            }
                            else
                            {
                                var info = _FontReplacementDescs[asset];
                                if (info.PlaceHolderFontName != desc.name)
                                {
                                    RemoveFontReplacement(asset);
                                    AddFontReplacement(asset);
                                    return(true);
                                }
                            }
                        }
                        finally
                        {
                            Resources.UnloadAsset(desc);
                        }
                    }
                }
                catch { }
            }
            return(false);
        }
        private static string GetFontReplacementPHFontName(string asset)
        {
            if (_PHFontNameToAssetName.Count == 0)
            {
                Debug.LogError("No Place Holder Font to Replace!");
                return(null);
            }

            string type, mod, dist;
            string norm = ResManager.GetAssetNormPath(asset, out type, out mod, out dist);

            FontReplacement found = null;

            foreach (var fname in _PHFontNameToAssetName.Keys)
            {
                bool exist = false;
                List <FontReplacement> list;
                if (_FontReplacements.TryGetValue(fname, out list))
                {
                    for (int i = 0; i < list.Count; ++i)
                    {
                        var info = list[i];
                        if (info.Mod == mod && info.Dist == dist)
                        {
                            found = info;
                            exist = true;
                            break;
                        }
                    }
                }
                if (!exist)
                {
                    return(fname);
                }
            }
            Debug.LogError("All Place Holder Font are already replaced in current Mod&Dist! See " + found.DescAssetPath);
            return(null);
        }