internal void AddInstalledTypeface(InstalledTypeface other) { if (_others == null) { _others = new List <InstalledTypeface>(); } _others.Add(other); }
internal void CollectCandidateFont(TypefaceStyle style, ushort weight, List <InstalledTypeface> candidates) { if ((ushort)_first.WeightClass == weight && _first.TypefaceStyle == style) { candidates.Add(_first); } if (_others != null) { int j = _others.Count; for (int i = 0; i < j; ++i) { InstalledTypeface inst = _others[i]; if ((ushort)inst.WeightClass == weight && inst.TypefaceStyle == style) { candidates.Add(inst); } } } }
internal InstalledTypefaceGroup(string fontname, InstalledTypeface first) { _first = first; FontName = fontname; }
bool Register(InstalledTypeface instTypeface) { //[A] --------------------------------------- string register_name = instTypeface.TypographicFamilyName; //use typographic name first if (register_name == null) { //switch to font name, this should not be null! register_name = instTypeface.FontName; } string reg_name_only = register_name.ToUpper(); register_name = reg_name_only + "," + instTypeface.TypefaceStyle + "," + instTypeface.WeightClass; //*** bool register_result = false; if (_all3.TryGetValue(register_name, out InstalledTypeface found)) { //TODO: //we already have this font name //(but may be different file //we let user to handle it if (_fontNameDuplicatedHandler != null) { switch (_fontNameDuplicatedHandler(found, instTypeface)) { default: throw new NotSupportedException(); case FontNameDuplicatedDecision.Skip: break; case FontNameDuplicatedDecision.Replace: //selectedFontGroup.Replace(register_name, instTypeface); _all3[register_name] = instTypeface; register_result = true; break; } } } else { _all3.Add(register_name, instTypeface); register_result = true; } if (!register_result) { return(false); } //early exit //[B]--------------------------------------- //register other names... if (!_regNames.TryGetValue(reg_name_only, out InstalledTypefaceGroup regNameGroup)) { regNameGroup = new InstalledTypefaceGroup(reg_name_only, instTypeface); _regNames.Add(reg_name_only, regNameGroup); } else { regNameGroup.AddInstalledTypeface(instTypeface); } string fontName = instTypeface.FontName.ToUpper(); if (fontName != null && fontName != reg_name_only) { if (!_otherNames.TryGetValue(fontName, out InstalledTypefaceGroup found2)) { found2 = new InstalledTypefaceGroup(fontName, instTypeface); _otherNames.Add(fontName, found2); } else { found2.AddInstalledTypeface(instTypeface); } } //----- string typographicName = instTypeface.TypographicFamilyName?.ToUpper(); if (typographicName != null && typographicName != reg_name_only && typographicName != fontName) { if (!_otherNames.TryGetValue(typographicName, out InstalledTypefaceGroup found2)) { found2 = new InstalledTypefaceGroup(typographicName, instTypeface); _otherNames.Add(typographicName, found2); } else { found2.AddInstalledTypeface(instTypeface); } } //----- string postScriptName = instTypeface.PostScriptName?.ToUpper(); if (postScriptName != null && postScriptName != fontName && postScriptName != typographicName) { if (!_otherNames.TryGetValue(postScriptName, out InstalledTypefaceGroup found2)) { found2 = new InstalledTypefaceGroup(postScriptName, instTypeface); _otherNames.Add(postScriptName, found2); } else { found2.AddInstalledTypeface(instTypeface); } } //classified by its weight GetInstalledTypefaceByWeightClass(instTypeface.WeightClass).Add(instTypeface); //register by its path (if available) if (instTypeface.FontPath != null && !_installedTypefacesByFilenames.ContainsKey(instTypeface.FontPath)) //beware case-sensitive! { _installedTypefacesByFilenames.Add(instTypeface.FontPath, instTypeface); } return(true); }
public SelectedTypeface(Typeface typeface) { Typeface = typeface; InstalledTypeface = null; }
public SelectedTypeface(InstalledTypeface installedTypeface) { Typeface = null; InstalledTypeface = installedTypeface; }