/// <summary>Called when a @font-face font is done loading.</summary>
        public void FontLoaded(DynamicFont font)
        {
            Css.TextRenderingProperty text = RenderData.Text;

            if (text != null)
            {
                text.FontLoaded(font);
                text.RequestLayout();
            }
        }
Exemple #2
0
 // -> It's for overlaying images over text.
 public BackgroundOverlay(TextRenderingProperty text)
 {
     Text = text;
 }
Exemple #3
0
 public virtual void GetOpenTypeFeatures(TextRenderingProperty trp, List <OpenTypeFeature> features)
 {
 }
        /// <summary>Part of shrink-to-fit. Computes the maximum and minimum possible width for an element.</summary>
        public void GetWidthBounds(out float min, out float max)
        {
            // Get the text renderer (or create it):
            Css.TextRenderingProperty text = RenderData_.RequireTextProperty();

            if (text.AllEmpty)
            {
                min = 0f;
                max = 0f;
                return;
            }

            // Need to compute TAW?
            if (TotalAdvanceWidth == float.MinValue)
            {
                float width      = 0f;
                int   spaceCount = 0;
                float wordWidth  = 0f;
                LongestWord = 0f;

                for (int i = 0; i < text.Characters.Length; i++)
                {
                    // Get the glyph:
                    InfiniText.Glyph glyph = text.Characters[i];

                    if (glyph == null)
                    {
                        // Skip!
                        continue;
                    }

                    // The glyph's width is..
                    float gWidth = glyph.AdvanceWidth + text.LetterSpacing;
                    wordWidth += gWidth;
                    width     += gWidth;

                    // Got a space?
                    if (glyph.Charcode == (int)' ')
                    {
                        if (wordWidth > LongestWord)
                        {
                            LongestWord = wordWidth;
                            wordWidth   = 0f;
                        }

                        // Advance width:
                        spaceCount += 1;
                    }
                }

                if (wordWidth > LongestWord)
                {
                    LongestWord = wordWidth;
                }

                TotalAdvanceWidth = width;
                SpaceCount        = spaceCount;
            }

            min = LongestWord * text.FontSize;
            max = (TotalAdvanceWidth * text.FontSize) + (SpaceCount * text.WordSpacing);
        }
Exemple #5
0
 /// <summary>Apply this CSS style to the given computed style.
 /// Note that you can grab the element from the computed style if you need that.</summary>
 /// <param name="style">The computed style to apply the property to.</param>
 /// <param name="value">The new value being applied.</param>
 public virtual void ApplyText(TextRenderingProperty text, RenderableData data, ComputedStyle style, Value value)
 {
 }