// TODO: rewrite public void ReadFontMetrics(out int descendMin, out int ascendMax, out int lsbMin, out int rsbMax, DIAction dia) { descendMin = -700; ascendMax = 2100; lsbMin = -1000; rsbMax = 3500; try { BoxD bboxRes = new BoxD(); Table_cmap tableCmap = (Table_cmap)this.m_font.GetTable("cmap"); if (tableCmap == null) { return; } Table_cmap.EncodingTableEntry eteUni = tableCmap.GetEncodingTableEntry(3, 1); if (eteUni == null) { return; } Table_cmap.Subtable subtableCmap = tableCmap.GetSubtable(eteUni); char[] samples = { 'A', 'W', 'p' }; for (int iSample = 0; iSample < samples.Length; iSample++) { byte[] charbuf = new byte[2]; charbuf[0] = (byte)'A'; charbuf[1] = 0; int indGlyph = (int)subtableCmap.MapCharToGlyph(charbuf, 0); Table_glyf.header header = this.m_tableGlyf.GetGlyphHeader((uint)indGlyph, this.m_font); if (header == null) { return; } BoxD bboxCur = new BoxD(header.xMin, header.yMin, header.xMax, header.yMax); bboxRes.Unite(bboxCur); } descendMin = (int)bboxRes.VecMin.Y; ascendMax = (int)bboxRes.VecMax.Y; lsbMin = (int)bboxRes.VecMin.X; rsbMax = (int)bboxRes.VecMax.X; } catch { } }
internal StatusGV.TypeStatusExec ValidateCompSource(GErrList gerrlist) { if (this.bbox != null) { this.bbox.Clear(); this.bbox = null; } if (this.comp != null) { this.comp.ClearDestroy(); this.comp = null; } if (this.outl != null) { this.outl.ClearDestroy(); this.outl = null; } if (this.typeGlyph == GConsts.TypeGlyph.Empty) { return(StatusGV.TypeStatusExec.Completed); } if (this.typeGlyph != GConsts.TypeGlyph.Composite) { //throw new ExceptionGlyph("Glyph","ValidateCompSource",null); return(StatusGV.TypeStatusExec.Aborted); } DIAction dia = DIActionBuilder.DIA(gerrlist, "DIAFunc_AddToListUnique"); gerrlist.DIW = new DIWrapperSource(this.index, this.typeGlyph, GScope.TypeGScope._GGB_); I_IOGlyphs i_IOGlyphs = this.fm.IIOGlyphs; if (i_IOGlyphs == null) { //throw new ExceptionGlyph("Glyph","ValidateCompSource",null); return(StatusGV.TypeStatusExec.Aborted); } i_IOGlyphs.ReadGGB(this.index, out this.bbox, dia); i_IOGlyphs.ReadGGC(this.index, out this.comp, dia); if (this.comp != null) { this.fm.OnGComposite(this.index); } gerrlist.DIW = null; return(StatusGV.TypeStatusExec.Completed); }
public Glyph(int indexGlyph, FManager fm) { this.fm = fm; this.index = indexGlyph; this.typeGlyph = GConsts.TypeGlyph.Uninitialized; this.bbox = null; this.outl = null; this.comp = null; this.statusGV = new StatusGV[DefsGV.NumTest]; for (int iTest = 0; iTest < DefsGV.NumTest; iTest++) { this.statusGV[iTest] = new StatusGV(); } }
public void ClearRelease() { if (this.bbox != null) { this.bbox.Clear(); this.bbox = null; } if (this.comp != null) { this.comp.ClearRelease(); this.comp = null; } if (this.outl != null) { this.outl.ClearRelease(); this.outl = null; } this.index = GConsts.IND_UNINITIALIZED; this.fm = null; }
public void ReadGGB(int indexGlyph, out BoxD bbox, DIAction dia) { this.m_validator.DIA = dia; bbox = null; int offsStart, length; if (!this.m_tableLoca.GetValidateEntryGlyf(indexGlyph, out offsStart, out length, this.m_validator, this.m_font)) { return; } if (length == 0) { return; } short xMin, yMin, xMax, yMax; if ((int)Table_glyf.FieldOffsets.nextAfterHeader >= length) { this.m_validator.Error( E._GEN_E_OffsetExceedsTableLength, (OTTag)"glyf"); return; } MBOBuffer buffer = this.m_tableGlyf.Buffer; xMin = buffer.GetShort((uint)(offsStart + (int)Table_glyf.FieldOffsets.xMin)); yMin = buffer.GetShort((uint)(offsStart + (int)Table_glyf.FieldOffsets.yMin)); xMax = buffer.GetShort((uint)(offsStart + (int)Table_glyf.FieldOffsets.xMax)); yMax = buffer.GetShort((uint)(offsStart + (int)Table_glyf.FieldOffsets.yMax)); bbox = new BoxD(xMin, yMin, xMax, yMax); }
/* * METHODS: I_DRAWABLE */ public void Draw(I_Draw i_draw, DrawParam dp) { if (this.bbox != null) { DrawParam dpBBox = new DrawParam("Yellow", 0.5F); this.bbox.Draw(i_draw, dpBBox); } if (this.outl != null) { DrawParamKnot dpKnot = new DrawParamKnot("Blue", 0.5F, 1.5F, true); DrawParamVec dpEndPoints = new DrawParamVec("Orange", 0.5F, 0.7F, true); string colorCurve; if (this.typeGlyph == GConsts.TypeGlyph.Composite) { colorCurve = "Blue"; } else { bool isOrientDefined = (this.statusGV[(int)DefsGV.TypeGV.ValidateSimpContMisor].IsValid) && (this.statusGV[(int)DefsGV.TypeGV.ValidateSimpContMisor].StatusExec == StatusGV.TypeStatusExec.Completed); colorCurve = isOrientDefined? "Blue": "Green"; } DrawParamCurve dpCurve = new DrawParamCurve(colorCurve, 1F, true, dpEndPoints); DrawParamContour dpContour = new DrawParamContour(dpCurve, dpKnot); this.outl.Draw(i_draw, dpContour); BoxD bboxComputed = this.outl.BBox; bboxComputed.SetEnlargeFU(); DrawParam dpBBoxComputed = new DrawParam("Yellow", 0.5F); bboxComputed.Draw(i_draw, dpBBoxComputed); } }
public void ClearDestroy() { if (this.bbox != null) { this.bbox.Clear(); this.bbox = null; } if (this.comp != null) { this.comp.ClearDestroy(); this.comp = null; } if (this.outl != null) { this.outl.ClearDestroy(); this.outl = null; } if (this.statusGV != null) { this.statusGV = null; } this.index = GConsts.IND_UNINITIALIZED; this.fm = null; }
private void CleanUpOnNonCompletedGV(DefsGV.TypeGV typeGV) { /* * TRY/CATCH function */ switch (typeGV) { case DefsGV.TypeGV.ValidateTypeGlyphSource: this.typeGlyph = GConsts.TypeGlyph.Undef; break; case DefsGV.TypeGV.ValidateSimpSource: if (this.bbox != null) { this.bbox = null; } if (this.outl != null) { try { this.outl.ClearDestroy(); } catch (System.Exception) { } this.outl = null; } break; case DefsGV.TypeGV.ValidateCompSource: if (this.bbox != null) { this.bbox = null; } if (this.comp != null) { try { this.comp.ClearDestroy(); } catch (System.Exception) { } this.comp = null; } break; case DefsGV.TypeGV.ValidateCompBind: if (this.outl != null) { try { this.outl.ClearDestroy(); } catch (System.Exception) { } this.outl = null; } break; } /* * private int index; * private GConsts.TypeGlyph typeGlyph; * BoxD bbox; * Outline outl; * Composite comp; * private FManager fm; * private StatusGV[] statusGV; */ }