public CharacterBoundingBox GetBoundingBox(int characterCode) { if (boundingBoxCache.TryGetValue(characterCode, out var cached)) { return(cached); } var matrix = GetFontMatrix(); var boundingBox = GetBoundingBoxInGlyphSpace(characterCode); boundingBox = matrix.Transform(boundingBox); var characterIdentifier = CMap.ConvertToCid(characterCode); var width = CidFont.GetWidthFromFont(characterIdentifier); var advanceWidth = matrix.TransformX(width); var result = new CharacterBoundingBox(boundingBox, advanceWidth); boundingBoxCache[characterCode] = result; return(result); }
public decimal GetWidth(int characterCode) { var cid = CMap.ConvertToCid(characterCode); var fromFont = CidFont.GetWidthFromDictionary(cid); return(fromFont); }
public CharacterBoundingBox GetBoundingBox(int characterCode) { var matrix = GetFontMatrix(); var boundingBox = GetBoundingBoxInGlyphSpace(characterCode); boundingBox = matrix.Transform(boundingBox); var characterIdentifier = CMap.ConvertToCid(characterCode); var width = CidFont.GetWidthFromFont(characterIdentifier); var advanceWidth = matrix.Transform(new PdfPoint(width, 0)).X; return(new CharacterBoundingBox(boundingBox, advanceWidth)); }
// Note. Make this constructor protected. Only PdfFontFactory (kernel level) will // be able to create Type0 font based on predefined font. // Or not? Possible it will be convenient construct PdfType0Font based on custom CidFont. // There is no typography features in CJK fonts. internal PdfType0Font(CidFont font, String cmap) : base() { if (!CidFontProperties.IsCidFont(font.GetFontNames().GetFontName(), cmap)) { throw new PdfException("Font {0} with {1} encoding is not a cjk font.").SetMessageParams(font.GetFontNames ().GetFontName(), cmap); } this.fontProgram = font; vertical = cmap.EndsWith("V"); String uniMap = GetCompatibleUniMap(fontProgram.GetRegistry()); cmapEncoding = new CMapEncoding(cmap, uniMap); longTag = new SortedSet <int>(); cidFontType = CID_FONT_TYPE_0; }
internal PdfType0Font(CidFont font, String cmap) : base() { // Note. Make this constructor protected. Only PdfFontFactory (kernel level) will // be able to create Type0 font based on predefined font. // Or not? Possible it will be convenient construct PdfType0Font based on custom CidFont. // There is no typography features in CJK fonts. if (!CidFontProperties.IsCidFont(font.GetFontNames().GetFontName(), cmap)) { throw new PdfException("font.1.with.2.encoding.is.not.a.cjk.font").SetMessageParams(font.GetFontNames().GetFontName (), cmap); } this.fontProgram = font; vertical = cmap.EndsWith("V"); String uniMap = GetCompatibleUniMap(fontProgram.GetRegistry()); cmapEncoding = new CMapEncoding(cmap, uniMap); longTag = new LinkedDictionary <int, int[]>(); cidFontType = CID_FONT_TYPE_0; }
public PdfVector GetDisplacementVector(int characterCode) { var characterIdentifier = CMap.ConvertToCid(characterCode); return(CidFont.GetDisplacementVector(characterIdentifier).Scale(1 / 1000.0)); }
public PdfVector GetPositionVector(int characterCode) { var characterIdentifier = CMap.ConvertToCid(characterCode); return(CidFont.GetPositionVector(characterIdentifier).Scale(-1 / 1000.0)); }
public PdfRectangle GetBoundingBoxInGlyphSpace(int characterCode) { var characterIdentifier = CMap.ConvertToCid(characterCode); return(CidFont.GetBoundingBox(characterIdentifier)); }