private FontCreationSetting SaveFontCreationSettings()
        {
            FontCreationSetting result = default(FontCreationSetting);

            result.fontSourcePath    = AssetDatabase.GetAssetPath(font_TTF);
            result.fontSizingMode    = FontSizingOption_Selection;
            result.fontSize          = font_size;
            result.fontPadding       = font_padding;
            result.fontPackingMode   = (int)m_fontPackingSelection;
            result.fontAtlasWidth    = font_atlas_width;
            result.fontAtlasHeight   = font_atlas_height;
            result.fontCharacterSet  = font_CharacterSet_Selection;
            result.fontStyle         = (int)font_style;
            result.fontStlyeModifier = font_style_mod;
            result.fontRenderMode    = (int)font_renderMode;
            result.fontKerning       = includeKerningPairs;
            return(result);
        }
        FontCreationSetting SaveFontCreationSettings()
        {
            FontCreationSetting settings = new FontCreationSetting();

            settings.fontSourcePath    = AssetDatabase.GetAssetPath(font_TTF);
            settings.fontSizingMode    = FontSizingOption_Selection;
            settings.fontSize          = font_size;
            settings.fontPadding       = font_padding;
            settings.fontPackingMode   = (int)m_fontPackingSelection;
            settings.fontAtlasWidth    = font_atlas_width;
            settings.fontAtlasHeight   = font_atlas_height;
            settings.fontCharacterSet  = font_CharacterSet_Selection;
            settings.fontStyle         = (int)font_style;
            settings.fontStlyeModifier = font_style_mod;
            settings.fontRenderMode    = (int)font_renderMode;
            settings.fontKerning       = includeKerningPairs;

            return(settings);
        }
Пример #3
0
        FontCreationSetting SaveFontCreationSettings()
        {
            FontCreationSetting settings = new FontCreationSetting();
            settings.fontSourcePath = AssetDatabase.GetAssetPath(font_TTF);
            settings.fontSizingMode = FontSizingOption_Selection;
            settings.fontSize = font_size;
            settings.fontPadding = font_padding;
            settings.fontPackingMode = (int)m_fontPackingSelection;
            settings.fontAtlasWidth = font_atlas_width;
            settings.fontAtlasHeight = font_atlas_height;
            settings.fontCharacterSet = font_CharacterSet_Selection;
            settings.fontStyle = (int)font_style;
            settings.fontStlyeModifier = font_style_mod;
            settings.fontRenderMode = (int)font_renderMode;
            settings.fontKerning = includeKerningPairs;

            return settings;
        }
Пример #4
0
        void Awake()
        {
            if (!Application.isPlaying || Initialization.Environment == Enums.RunningState.Editor)
            {
                return;
            }

            var type     = typeof(global::TMPro.TMP_FontAsset);
            var fontInfo = new FaceInfo();

            fontInfo.Name               = FaceInfo_Name;
            fontInfo.PointSize          = FaceInfo_PointSize;
            fontInfo.Scale              = FaceInfo_Scale;
            fontInfo.CharacterCount     = FaceInfo_CharacterCount;
            fontInfo.LineHeight         = FaceInfo_LineHeight;
            fontInfo.Baseline           = FaceInfo_Baseline;
            fontInfo.Ascender           = FaceInfo_Ascender;
            fontInfo.CapHeight          = FaceInfo_CapHeight;
            fontInfo.Descender          = FaceInfo_Descender;
            fontInfo.CenterLine         = FaceInfo_CenterLine;
            fontInfo.SuperscriptOffset  = FaceInfo_SuperscriptOffset;
            fontInfo.SubscriptOffset    = FaceInfo_SubscriptOffset;
            fontInfo.SubSize            = FaceInfo_SubSize;
            fontInfo.Underline          = FaceInfo_Underline;
            fontInfo.UnderlineThickness = FaceInfo_UnderlineThickness;
            fontInfo.TabWidth           = FaceInfo_TabWidth;
            fontInfo.Padding            = FaceInfo_Padding;
            fontInfo.AtlasWidth         = FaceInfo_AtlasWidth;
            fontInfo.AtlasHeight        = FaceInfo_AtlasHeight;
#if UNITY_EDITOR
            fontInfo.strikethrough          = FaceInfo_strikethrough;
            fontInfo.strikethroughThickness = FaceInfo_strikethroughThickness;
#endif

            type.GetField("m_fontInfo", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(this, fontInfo);

            List <TMP_Glyph> glyphs = new List <TMP_Glyph>();

            for (int i = 0; i < TMP_Glyph_height.Count; i++)
            {
                TMP_Glyph glyph = new TMP_Glyph();

                glyph.height   = TMP_Glyph_height[i];
                glyph.id       = TMP_Glyph_id[i];
                glyph.scale    = TMP_Glyph_scale[i];
                glyph.width    = TMP_Glyph_width[i];
                glyph.x        = TMP_Glyph_x[i];
                glyph.xAdvance = TMP_Glyph_xAdvance[i];
                glyph.xOffset  = TMP_Glyph_xOffset[i];
                glyph.y        = TMP_Glyph_y[i];
                glyph.yOffset  = TMP_Glyph_yOffset[i];
                glyphs.Add(glyph);
            }

            type.GetField("m_glyphInfoList", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(this, glyphs);

            KerningTable kTable = new KerningTable();

            for (int i = 0; i < KerningTable_AscII_Left.Count; i++)
            {
                kTable.kerningPairs.Add(new KerningPair(KerningTable_AscII_Left[i], KerningTable_AscII_Right[i], KerningTable_XadvanceOffset[i]));
            }

            type.GetField("m_kerningInfo", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(this, kTable);

            var newKerningPair = new KerningPair(KerningPair_AscII_Left, KerningPair_AscII_Right, KerningPair_XadvanceOffset);
            type.GetField("m_kerningPair", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(this, newKerningPair);



            FontCreationSetting fontSettings = new FontCreationSetting();

            fontSettings.fontAtlasHeight   = FontCreationSetting_fontAtlasHeight;
            fontSettings.fontAtlasWidth    = FontCreationSetting_fontAtlasWidth;
            fontSettings.fontCharacterSet  = FontCreationSetting_fontCharacterSet;
            fontSettings.fontKerning       = FontCreationSetting_fontKerning;
            fontSettings.fontPackingMode   = FontCreationSetting_fontPackingMode;
            fontSettings.fontPadding       = FontCreationSetting_fontPadding;
            fontSettings.fontRenderMode    = FontCreationSetting_fontRenderMode;
            fontSettings.fontSize          = FontCreationSetting_fontSize;
            fontSettings.fontSizingMode    = FontCreationSetting_fontSizingMode;
            fontSettings.fontSourcePath    = FontCreationSetting_fontSourcePath;
            fontSettings.fontStlyeModifier = FontCreationSetting_fontStyleModifier;
            fontSettings.fontStyle         = FontCreationSetting_fontStyle;
            type.GetField("fontCreationSettings", BindingFlags.Public | BindingFlags.Instance).SetValue(this, fontSettings);


            TMP_FontWeights[] weights = new TMP_FontWeights[TMP_FontWeights_italicTypeface.Count];

            for (int i = 0; i < TMP_FontWeights_italicTypeface.Count; i++)
            {
                var newWeight = new TMP_FontWeights();
                newWeight.italicTypeface  = TMP_FontWeights_italicTypeface[i];
                newWeight.regularTypeface = TMP_FontWeights_regularTypeface[i];

                weights[i] = newWeight;
            }


            type.GetField("fontWeights", BindingFlags.Public | BindingFlags.Instance).SetValue(this, weights);
        }