Example #1
0
        private bool SetStyleValue(StylePropertyId id, StyleFontDefinition inlineValue, FontDefinition sharedValue)
        {
            var sv = new StyleValue();

            if (TryGetStyleValue(id, ref sv))
            {
                var font      = sv.resource.IsAllocated ? sv.resource.Target as Font : null;
                var obj       = sv.resource.Target as Object;
                var fontAsset = sv.resource.IsAllocated && TextDelegates.IsFontAssetSafe(obj) ? obj : null;
                if ((font == inlineValue.value.font && fontAsset == inlineValue.value.fontAsset) && sv.keyword == inlineValue.keyword)
                {
                    return(false);
                }

                if (sv.resource.IsAllocated)
                {
                    sv.resource.Free();
                }
            }
            else if (inlineValue.keyword == StyleKeyword.Null)
            {
                return(false);
            }

            sv.id      = id;
            sv.keyword = inlineValue.keyword;
            if (inlineValue.value.font != null)
            {
                sv.resource = GCHandle.Alloc(inlineValue.value.font);
            }
            else if (inlineValue.value.fontAsset != null)
            {
                sv.resource = GCHandle.Alloc(inlineValue.value.fontAsset);
            }
            else
            {
                sv.resource = new GCHandle();
            }

            SetStyleValue(sv);

            if (inlineValue.keyword == StyleKeyword.Null)
            {
                if (sharedValue.font != null)
                {
                    sv.resource = GCHandle.Alloc(sharedValue.font);
                }
                else if (sharedValue.fontAsset != null)
                {
                    sv.resource = GCHandle.Alloc(sharedValue.fontAsset);
                }
                else
                {
                    sv.resource = new GCHandle();
                }
            }

            ApplyStyleValue(sv);
            return(true);
        }
Example #2
0
 internal StyleFontDefinition(StyleFontDefinition sfd)
 {
     m_Keyword = sfd.keyword;
     m_Value   = sfd.value;
 }
Example #3
0
 /// <undoc/>
 public bool Equals(StyleFontDefinition other)
 {
     return(m_Keyword == other.m_Keyword && m_Value.Equals(other.m_Value));
 }