implement missing methods for various compact font format charsets and fix bug with constructors

This commit is contained in:
Eliot Jones
2019-05-11 10:23:57 +01:00
parent 7d9bd46437
commit a108672ce8
4 changed files with 14 additions and 10 deletions

View File

@@ -2,6 +2,7 @@
{ {
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
internal abstract class CompactFontFormatCharset : ICompactFontFormatCharset internal abstract class CompactFontFormatCharset : ICompactFontFormatCharset
{ {
@@ -36,7 +37,7 @@
public virtual string GetNameByStringId(int stringId) public virtual string GetNameByStringId(int stringId)
{ {
throw new NotImplementedException(); return GlyphIdToStringIdAndName.Single(x => x.Value.stringId == stringId).Value.name;
} }
public virtual int GetStringIdByGlyphId(int glyphId) public virtual int GetStringIdByGlyphId(int glyphId)

View File

@@ -1,6 +1,7 @@
namespace UglyToad.PdfPig.Fonts.CompactFontFormat.Charsets namespace UglyToad.PdfPig.Fonts.CompactFontFormat.Charsets
{ {
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
/// <summary> /// <summary>
/// A predefined Charset for a Compact Font Format font with Charset Id of 1. /// A predefined Charset for a Compact Font Format font with Charset Id of 1.
@@ -189,7 +190,7 @@
var i = 0; var i = 0;
foreach (var pair in StringIdToName) foreach (var pair in StringIdToName)
{ {
furtherMap[i] = pair; furtherMap[i++] = pair;
} }
characterIdToStringIdAndName = furtherMap; characterIdToStringIdAndName = furtherMap;
@@ -202,12 +203,12 @@
public string GetNameByStringId(int stringId) public string GetNameByStringId(int stringId)
{ {
throw new System.NotImplementedException(); return characterIdToStringIdAndName.Single(x => x.Value.Key == stringId).Value.Value;
} }
public int GetStringIdByGlyphId(int glyphId) public int GetStringIdByGlyphId(int glyphId)
{ {
throw new System.NotImplementedException(); return characterIdToStringIdAndName[glyphId].Key;
} }
} }
} }

View File

@@ -1,6 +1,7 @@
namespace UglyToad.PdfPig.Fonts.CompactFontFormat.Charsets namespace UglyToad.PdfPig.Fonts.CompactFontFormat.Charsets
{ {
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
/// <summary> /// <summary>
/// A predefined Charset for a Compact Font Format font with Charset Id of 2. /// A predefined Charset for a Compact Font Format font with Charset Id of 2.
@@ -110,7 +111,7 @@
var i = 0; var i = 0;
foreach (var pair in StringIdToName) foreach (var pair in StringIdToName)
{ {
furtherMap[i] = pair; furtherMap[i++] = pair;
} }
characterIdToStringIdAndName = furtherMap; characterIdToStringIdAndName = furtherMap;
@@ -123,12 +124,12 @@
public string GetNameByStringId(int stringId) public string GetNameByStringId(int stringId)
{ {
throw new System.NotImplementedException(); return characterIdToStringIdAndName.Single(x => x.Value.Key == stringId).Value.Value;
} }
public int GetStringIdByGlyphId(int glyphId) public int GetStringIdByGlyphId(int glyphId)
{ {
throw new System.NotImplementedException(); return characterIdToStringIdAndName[glyphId].Key;
} }
} }
} }

View File

@@ -1,6 +1,7 @@
namespace UglyToad.PdfPig.Fonts.CompactFontFormat.Charsets namespace UglyToad.PdfPig.Fonts.CompactFontFormat.Charsets
{ {
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
/// <summary> /// <summary>
/// A predefined Charset for a Compact Font Format font with Charset Id of 0. /// A predefined Charset for a Compact Font Format font with Charset Id of 0.
@@ -252,7 +253,7 @@
var i = 0; var i = 0;
foreach (var pair in StringIdToName) foreach (var pair in StringIdToName)
{ {
furtherMap[i] = pair; furtherMap[i++] = pair;
} }
characterIdToStringIdAndName = furtherMap; characterIdToStringIdAndName = furtherMap;
@@ -265,12 +266,12 @@
public string GetNameByStringId(int stringId) public string GetNameByStringId(int stringId)
{ {
throw new System.NotImplementedException(); return characterIdToStringIdAndName.Single(x => x.Value.Key == stringId).Value.Value;
} }
public int GetStringIdByGlyphId(int glyphId) public int GetStringIdByGlyphId(int glyphId)
{ {
throw new System.NotImplementedException(); return characterIdToStringIdAndName[glyphId].Key;
} }
} }
} }