Ejemplo n.º 1
0
        public override void ReadShapes(IGlyphTranslator tx)
        {
            //read output shape from dynamic outline

            if (this.UseTrueTypeInstructions)
            {
                base.ReadShapes(tx);
                return;
            }
            if (!TemporaryDisableCustomFit && this.UseVerticalHinting)
            {
                //read from our auto hint fitoutline
                //need scale from original.
                float toPixelScale = Typeface.CalculateToPixelScale(RecentFontSizeInPixels);
                if (toPixelScale < 0)
                {
                    toPixelScale = 1;
                }
                _latestDynamicOutline.GenerateOutput(tx, toPixelScale);
            }
            else
            {
                base.ReadShapes(tx);
            }
        }
Ejemplo n.º 2
0
 protected override void FitCurrentGlyph(ushort glyphIndex, Glyph glyph)
 {
     //not use interperter so we need to scale it with our mechanism
     //this demonstrate our auto hint engine ***
     //you can change this to your own hint engine***
     _latestDynamicOutline = null;//reset
     if (this.UseTrueTypeInstructions)
     {
         base.FitCurrentGlyph(glyphIndex, glyph);
     }
     else
     {
         //
         if (TemporaryDisableCustomFit)
         {
             return;
         }
         //
         if (this.UseVerticalHinting)
         {
             if (!_fitoutlineCollection.TryGetValue(glyphIndex, out _latestDynamicOutline))
             {
                 //---------------------------------------------
                 //test code
                 //GlyphContourBuilder contBuilder = new GlyphContourBuilder();
                 //contBuilder.Reset();
                 //int x = 100, y = 120, w = 700, h = 200;
                 //contBuilder.MoveTo(x, y);
                 //contBuilder.LineTo(x + w, y);
                 //contBuilder.LineTo(x + w, y + h);
                 //contBuilder.LineTo(x, y + h);
                 //contBuilder.CloseFigure();
                 //---------------------------------------------
                 _latestDynamicOutline = _fitShapeAnalyzer.CreateDynamicOutline(
                     this._outputGlyphPoints,
                     this._outputContours);
                 //add more information for later scaling process
                 _latestDynamicOutline.OriginalAdvanceWidth       = glyph.OriginalAdvanceWidth;
                 _latestDynamicOutline.OriginalGlyphControlBounds = glyph.Bounds;
                 //store to our dynamic outline collection
                 //so we can reuse it
                 _fitoutlineCollection.Add(glyphIndex, _latestDynamicOutline);
                 //-------------------
                 //
                 _latestDynamicOutline.GenerateOutput(null, Typeface.CalculateToPixelScale(RecentFontSizeInPixels));
                 //-------------------
             }
             else
             {
                 if (IsSizeChanged)
                 {
                     _latestDynamicOutline.GenerateOutput(null, Typeface.CalculateToPixelScale(RecentFontSizeInPixels));
                     IsSizeChanged = false;
                 }
             }
         }
     }
 }
Ejemplo n.º 3
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.CalculateToPixelScale(RecentFontSizeInPixels);
            }
            //-------------------------------------
            FitCurrentGlyph(glyphIndex, glyph);
        }
Ejemplo n.º 4
0
 public override void ReadShapes(IGlyphTranslator tx)
 {
     if (this.UseTrueTypeInstructions)
     {
         base.ReadShapes(tx);
         return;
     }
     if (this.UseVerticalHinting)
     {
         //read from our auto hint fitoutline
         //need scale from original.
         float toPixelScale = Typeface.CalculateToPixelScale(this.RecentFontSizeInPixels);
         if (toPixelScale < 0)
         {
             toPixelScale = 1;
         }
         _fitOutline.ReadOutput(tx, toPixelScale);
     }
     else
     {
         base.ReadShapes(tx);
     }
 }