コード例 #1
0
        /// <summary>
        /// build glyph shape from glyph to be read
        /// </summary>
        /// <param name="glyphIndex"></param>
        /// <param name="sizeInPoints"></param>
        public void BuildFromGlyph(Glyph glyph, float sizeInPoints)
        {
            //for true type font
            _outputGlyphPoints = glyph.GlyphPoints;
            _outputContours    = glyph.EndPoints;


            //------------
            //temp fix for Cff Font
            if (glyph.IsCffGlyph)
            {
                _cffGlyphData = glyph.GetCff1GlyphData();
                _ownerCff     = glyph.GetOwnerCff();
            }

            //---------------



            if ((RecentFontSizeInPixels = Typeface.ConvPointsToPixels(sizeInPoints)) < 0)
            {
                //convert to pixel size
                //if size< 0 then set _recentPixelScale = 1;
                //mean that no scaling at all, we use original point value
                _recentPixelScale = 1;
            }
            else
            {
                _recentPixelScale = Typeface.CalculateScaleToPixel(RecentFontSizeInPixels);
                IsSizeChanged     = true;
            }
            //-------------------------------------
            FitCurrentGlyph(glyph);
        }
コード例 #2
0
        public Typeface ResolveTypeface(RequestFont font)
        {
            //from user's request font
            //resolve to actual Typeface
            //get data from...
            //cache level-1 (attached inside the request font)
            Typeface typeface = PixelFarm.Drawing.Internal.RequestFontCacheAccess.GetActualFont <Typeface>(font, _system_id);

            if (typeface != null)
            {
                return(typeface);
            }
            //
            //cache level-2 (stored in this Ifonts)
            if (!_resolvedTypefaceCache.TryGetValue(font.FontKey, out typeface))
            {
                //not found ask the typeface store to load that font
                //....
                typeface = _txtServices.GetTypeface(font.Name, font.Style.ConvToInstalledFontStyle());
                if (typeface == null)
                {
                    throw new NotSupportedException();
                }
                //
                //cache here (level-1)
                _resolvedTypefaceCache.Add(font.FontKey, typeface);
            }
            //and cache into level-0

            float pxSize = Typeface.ConvPointsToPixels(font.SizeInPoints);

            float pxscale = typeface.CalculateScaleToPixelFromPointSize(font.SizeInPoints);

            float recommedLineSpacingInPx = typeface.CalculateRecommendLineSpacing() * pxscale;
            float descentInPx             = typeface.Descender * pxscale;
            float ascentInPx  = typeface.Ascender * pxscale;
            float lineGapInPx = typeface.LineGap * pxscale;

            PixelFarm.Drawing.Internal.RequestFontCacheAccess.SetActualFont(font, _system_id, typeface);
            PixelFarm.Drawing.Internal.RequestFontCacheAccess.SetGeneralFontMetricInfo(font,
                                                                                       pxSize,
                                                                                       ascentInPx,
                                                                                       descentInPx,
                                                                                       lineGapInPx,
                                                                                       recommedLineSpacingInPx);

            TextBufferSpan w           = new TextBufferSpan(new char[] { ' ' });
            Size           whiteSpaceW = MeasureString(ref w, font);

            PixelFarm.Drawing.Internal.RequestFontCacheAccess.SetWhitespaceWidth(font, _system_id, whiteSpaceW.Width);
            return(typeface);
        }
コード例 #3
0
 public void BuildFromGlyph(Glyph glyph, float sizeInPoints)
 {
     this._outputGlyphPoints = glyph.GlyphPoints;
     this._outputContours    = glyph.EndPoints;
     if ((RecentFontSizeInPixels = Typeface.ConvPointsToPixels(sizeInPoints)) < 0)
     {
         //convert to pixel size
         //if size< 0 then set _recentPixelScale = 1;
         //mean that no scaling at all, we use original point value
         _recentPixelScale = 1;
     }
     else
     {
         _recentPixelScale = Typeface.CalculateScaleToPixel(RecentFontSizeInPixels);
         IsSizeChanged     = true;
     }
     //-------------------------------------
     //optional ...
     //FitCurrentGlyph(glyphIndex, glyph);
 }
コード例 #4
0
        /// <summary>
        /// build glyph shape from glyphIndex and
        /// </summary>
        /// <param name="glyphIndex"></param>
        /// <param name="sizeInPoints"></param>
        public void BuildFromGlyphIndex(ushort glyphIndex, float sizeInPoints)
        {
            //
            Glyph glyph = _typeface.GetGlyphByIndex(glyphIndex);

            this._outputGlyphPoints = glyph.GlyphPoints;
            this._outputContours    = glyph.EndPoints;

            if ((RecentFontSizeInPixels = Typeface.ConvPointsToPixels(sizeInPoints)) < 0)
            {
                //convert to pixel size
                //if size< 0 then set _recentPixelScale = 1;
                //mean that no scaling at all, we use original point value
                _recentPixelScale = 1;
            }
            else
            {
                _recentPixelScale = Typeface.CalculateScaleToPixel(RecentFontSizeInPixels);
            }
            //-------------------------------------
            FitCurrentGlyph(glyphIndex, glyph);
        }
コード例 #5
0
        /// <summary>
        /// build glyph shape from glyph to be read
        /// </summary>
        /// <param name="glyphIndex"></param>
        /// <param name="sizeInPoints"></param>
        public void BuildFromGlyph(Glyph glyph, float sizeInPoints)
        {
            //------------
            //Trimmable feature note:
            //in this mode
            //we build from input glyphs
            //please ensure that the glyph has full build instructions
            //------------

            _outputGlyphPoints = glyph.GlyphPoints;
            _outputContours    = glyph.EndPoints;

            //------------
            //temp fix for Cff Font
            if (glyph.IsCffGlyph)
            {
                _cffGlyphData = glyph.GetCff1GlyphData();
            }

            //---------------
            if ((RecentFontSizeInPixels = Typeface.ConvPointsToPixels(sizeInPoints)) < 0)
            {
                //convert to pixel size
                //if size< 0 then set _recentPixelScale = 1;
                //mean that no scaling at all, we use original point value
                _recentPixelScale = 1;
            }
            else
            {
                _recentPixelScale = Typeface.CalculateScaleToPixel(RecentFontSizeInPixels);
                HasSizeChanged    = true;
            }
            //-------------------------------------
            if (!HasColorInfo)
            {
                //when no color info
                FitCurrentGlyph(glyph);
            }
        }