/// <summary> /// 根据当前字库中的内容,构建基于字符识别特征码的映射表对象 /// </summary> private void BuildIdentifyStrMap() { Dictionary <string, MyChar> identifyMap = new Dictionary <string, MyChar>(); foreach (KeyValuePair <char, Dictionary <Font, AbstractFont> > kvp in FontMap) { foreach (KeyValuePair <Font, AbstractFont> kvpDetail in kvp.Value) { MyChar mychar; if (!identifyMap.TryGetValue(kvpDetail.Value.RealData, out mychar)) { mychar = new MyChar() { Value = kvpDetail.Value.FontValue, RealHeight = kvpDetail.Value.RealHSize, RealWight = kvpDetail.Value.RealWSize }; identifyMap[kvpDetail.Value.RealData] = mychar; } } } _identifyStrMap = identifyMap; }
protected Dictionary <string, MyChar> BuildAllSystemFontIdentifyStrMap(ref Dictionary <char, Dictionary <Font, AbstractFont> > fontmap) { Dictionary <string, MyChar> identifyMap = new Dictionary <string, MyChar>(); foreach (KeyValuePair <char, Dictionary <Font, AbstractFont> > kvp in fontmap) { foreach (KeyValuePair <Font, AbstractFont> kvpDetail in kvp.Value) { MyChar mychar; if (!identifyMap.TryGetValue(kvpDetail.Value.RealData, out mychar)) { mychar = new MyChar() { Value = kvpDetail.Value.FontValue, RealHeight = kvpDetail.Value.RealHSize, RealWight = kvpDetail.Value.RealWSize }; identifyMap[kvpDetail.Value.RealData] = mychar; } } } //Console.WriteLine("构建系统字体识别特征库完成,累计识别码:" + identifyMap.Count+" 个"); return(identifyMap); }