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.CalculateScaleToPixel(RecentFontSizeInPixels); if (toPixelScale < 0) { toPixelScale = 1; } _latestDynamicOutline.GenerateOutput(tx, toPixelScale); } else { base.ReadShapes(tx); } }
protected override void FitCurrentGlyph(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(glyph); } else { // if (TemporaryDisableCustomFit) { return; } // if (this.UseVerticalHinting) { if (!_fitoutlineCollection.TryGetValue(glyph.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( _outputGlyphPoints, _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(glyph.GlyphIndex, _latestDynamicOutline); //------------------- // _latestDynamicOutline.GenerateOutput(null, Typeface.CalculateScaleToPixel(RecentFontSizeInPixels)); //------------------- } else { if (IsSizeChanged) { _latestDynamicOutline.GenerateOutput(null, Typeface.CalculateScaleToPixel(RecentFontSizeInPixels)); IsSizeChanged = false; } } } } }
/// <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); }
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); }
/// <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); }
/// <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); } }