-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
62 changed files
with
8,190 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 2013 | ||
VisualStudioVersion = 12.0.20623.1 VSUPREVIEW | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenType Inspector", "OpenType Inspector\OpenType Inspector.csproj", "{90B6CB51-A9D4-4B30-8AEE-0A067D50B34A}" | ||
EndProject | ||
Global | ||
GlobalSection(TeamFoundationVersionControl) = preSolution | ||
SccNumberOfProjects = 2 | ||
SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C} | ||
SccTeamFoundationServer = http://tfs.mach.im:8080/tfs/mff | ||
SccLocalPath0 = . | ||
SccProjectUniqueName1 = OpenType\u0020Inspector\\OpenType\u0020Inspector.csproj | ||
SccProjectName1 = OpenType\u0020Inspector | ||
SccLocalPath1 = OpenType\u0020Inspector | ||
EndGlobalSection | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{90B6CB51-A9D4-4B30-8AEE-0A067D50B34A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{90B6CB51-A9D4-4B30-8AEE-0A067D50B34A}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{90B6CB51-A9D4-4B30-8AEE-0A067D50B34A}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{90B6CB51-A9D4-4B30-8AEE-0A067D50B34A}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/> | ||
</startup> | ||
</configuration> |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<Application x:Class="OpenTypeInspector.App" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:code="clr-namespace:OpenTypeInspector" | ||
StartupUri="MainWindow.xaml"> | ||
<Application.Resources> | ||
<code:EnumSourceConverter x:Key="EnumSource" /> | ||
<code:GlyphTypefaceConverter x:Key="FontConverter" /> | ||
</Application.Resources> | ||
</Application> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Configuration; | ||
using System.Data; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
|
||
namespace OpenTypeInspector | ||
{ | ||
/// <summary> | ||
/// Interaction logic for App.xaml | ||
/// </summary> | ||
public partial class App : Application | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
namespace OpenTypeInspector | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Windows.Media; | ||
|
||
internal class GlyphCollection : ICollectionViewFactory, IReadOnlyList<GlyphItem>, System.Collections.IList | ||
{ | ||
private GlyphTypeface _typeface; | ||
public GlyphTypeface Typeface { get { return _typeface; } } | ||
|
||
private bool _classesRetreived; | ||
private Dictionary<GlyphClass, int> _classCounts; | ||
private ExpandableDictionary<ushort, GlyphClass> _classes; | ||
protected IDictionary<ushort, GlyphClass> Classes | ||
{ | ||
get { return EnsureClasses() ? _classes : default; } | ||
} | ||
|
||
private bool EnsureClasses() | ||
{ | ||
if (_classes == null) | ||
{ | ||
if (_classesRetreived) return false; | ||
|
||
_classesRetreived = true; | ||
var classes = new GlyphTypefaceInspector(_typeface).Definitions.GetGlyphClasses(); | ||
if (classes != null) | ||
{ | ||
_classes = new ExpandableDictionary<ushort, GlyphClass>(classes); | ||
|
||
int[] counts = new int[6]; | ||
foreach (var c in classes.Values) | ||
counts[(int)c]++; | ||
|
||
_classCounts = new Dictionary<GlyphClass, int>(); | ||
for (int i = 0; i < counts.Length; i++) | ||
{ | ||
_classCounts[(GlyphClass)i] = counts[i]; | ||
} | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
|
||
public int GetClassCount(GlyphClass c) | ||
{ | ||
EnsureClasses(); | ||
if (_classCounts?.TryGetValue(c, out int count) == true) | ||
return count; | ||
|
||
return 0; | ||
} | ||
|
||
public GlyphCollection(GlyphTypeface typeface) | ||
{ | ||
if (typeface == null) | ||
throw new ArgumentNullException("typeface"); | ||
|
||
_typeface = typeface; | ||
} | ||
|
||
public ICollectionView CreateView() | ||
{ | ||
return new System.Windows.Data.ListCollectionView(this); | ||
// return new GlyphCollectionView(this); | ||
} | ||
|
||
public GlyphItem this[int index] | ||
{ | ||
get | ||
{ | ||
if (index < 0 || index >= Count) | ||
throw new ArgumentOutOfRangeException("index"); | ||
|
||
return new GlyphItem((ushort)index, _typeface) { Class = Classes?[(ushort)index] ?? default }; | ||
} | ||
} | ||
|
||
public int Count | ||
{ | ||
get { return _typeface.GlyphCount; } | ||
} | ||
|
||
public IEnumerator<GlyphItem> GetEnumerator() | ||
{ | ||
for (ushort index = 0; index < _typeface.GlyphCount; index++) | ||
yield return new GlyphItem(index, _typeface) { Class = Classes?[index] ?? default }; | ||
} | ||
|
||
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() | ||
{ | ||
return GetEnumerator(); | ||
} | ||
|
||
#region IList | ||
|
||
int System.Collections.ICollection.Count | ||
{ | ||
get { return Count; } | ||
} | ||
|
||
bool System.Collections.IList.IsFixedSize | ||
{ | ||
get { return true; } | ||
} | ||
|
||
bool System.Collections.IList.IsReadOnly | ||
{ | ||
get { return true; } | ||
} | ||
|
||
bool System.Collections.IList.Contains(object value) | ||
{ | ||
return ((GlyphItem)value).GlyphID < Count; | ||
} | ||
|
||
int System.Collections.IList.IndexOf(object value) | ||
{ | ||
return ((GlyphItem)value).GlyphID; | ||
} | ||
|
||
object System.Collections.IList.this[int index] | ||
{ | ||
get { return this[index]; } | ||
set { throw new NotSupportedException(); } | ||
} | ||
|
||
int System.Collections.IList.Add(object value) { throw new NotSupportedException(); } | ||
void System.Collections.IList.Clear() { throw new NotSupportedException(); } | ||
void System.Collections.IList.Insert(int index, object value) { throw new NotSupportedException(); } | ||
void System.Collections.IList.Remove(object value) { throw new NotSupportedException(); } | ||
void System.Collections.IList.RemoveAt(int index) { throw new NotSupportedException(); } | ||
void System.Collections.ICollection.CopyTo(Array array, int index) { throw new NotImplementedException(); } | ||
bool System.Collections.ICollection.IsSynchronized { get { throw new NotSupportedException(); } } | ||
object System.Collections.ICollection.SyncRoot { get { throw new NotSupportedException(); } } | ||
|
||
#endregion | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
namespace OpenTypeInspector | ||
{ | ||
using System; | ||
using System.Collections; | ||
using System.Collections.ObjectModel; | ||
using System.Collections.Specialized; | ||
using System.ComponentModel; | ||
using System.Globalization; | ||
|
||
internal class GlyphCollectionView : ICollectionView | ||
{ | ||
private class Deferer : IDisposable | ||
{ | ||
GlyphCollectionView _view; | ||
|
||
public Deferer(GlyphCollectionView collection) | ||
{ | ||
_view = collection; | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
_view.OnCollectionReset(); | ||
} | ||
} | ||
|
||
private GlyphCollection _collection; | ||
private int _count; | ||
private bool _needsReset; | ||
|
||
public GlyphCollectionView(GlyphCollection collection) | ||
{ | ||
_collection = collection; | ||
_count = collection.Count; | ||
_needsReset = true; | ||
} | ||
|
||
public CultureInfo Culture { get; set; } | ||
|
||
public bool CanFilter { get { return false; } } | ||
public bool CanGroup { get { return false; } } | ||
public bool CanSort { get { return false; } } | ||
|
||
public bool Contains(object item) { return ((GlyphItem)item).GlyphID < _count; } | ||
|
||
private ushort? _currentGlyphID; | ||
public object CurrentItem { get { return _currentGlyphID.HasValue ? new GlyphItem(_currentGlyphID.Value, _collection.Typeface) : (object)null; } } | ||
public int CurrentPosition { get { return _currentGlyphID ?? -1; } } | ||
|
||
public Predicate<object> Filter { get { return null; } set { throw new NotSupportedException(); } } | ||
public SortDescriptionCollection SortDescriptions { get { return null; } } | ||
public ObservableCollection<GroupDescription> GroupDescriptions {get { return null; } } | ||
public ReadOnlyObservableCollection<object> Groups { get { return null; } } | ||
|
||
public bool IsCurrentAfterLast { get { return _currentGlyphID == null; } } | ||
public bool IsCurrentBeforeFirst { get { return _currentGlyphID == null; } } | ||
public bool IsEmpty { get { return _count < 1; } } | ||
|
||
public bool MoveCurrentTo(object item) { return MoveCurrentToPosition(((GlyphItem)item).GlyphID); } | ||
public bool MoveCurrentToFirst() { return MoveCurrentToPosition(_count < 1 ? -1 : 0); } | ||
public bool MoveCurrentToLast() { return MoveCurrentToPosition(_count - 1); } | ||
public bool MoveCurrentToNext() { return MoveCurrentToPosition((_currentGlyphID ?? -1) + 1); } | ||
public bool MoveCurrentToPrevious() { return MoveCurrentToPosition((_currentGlyphID ?? 0) - 1); } | ||
public bool MoveCurrentToPosition(int index) | ||
{ | ||
if (index < -1 || index >= _count) | ||
throw new ArgumentOutOfRangeException("index"); | ||
|
||
ushort? newGlyphID; | ||
bool inView; | ||
|
||
if (index == -1) | ||
{ | ||
newGlyphID = null; | ||
inView = false; | ||
} | ||
else | ||
{ | ||
newGlyphID = (ushort)index; | ||
inView = true; | ||
} | ||
|
||
if (_currentGlyphID != newGlyphID && OnCurrentChanging()) | ||
{ | ||
_currentGlyphID = newGlyphID; | ||
OnCurrentChanged(); | ||
} | ||
|
||
return inView; | ||
} | ||
|
||
public IDisposable DeferRefresh() { return new Deferer(this); } | ||
public void Refresh() { } | ||
|
||
public IEnumerable SourceCollection { get { return _collection; } } | ||
public IEnumerator GetEnumerator() { return _collection.GetEnumerator(); } | ||
|
||
public event EventHandler CurrentChanged; | ||
public event CurrentChangingEventHandler CurrentChanging; | ||
|
||
private bool OnCurrentChanging() | ||
{ | ||
CurrentChangingEventHandler changing = CurrentChanging; | ||
|
||
if (changing == null) | ||
return true; | ||
|
||
CurrentChangingEventArgs args = new CurrentChangingEventArgs(true); | ||
changing(this, args); | ||
|
||
return args.Cancel == false; | ||
} | ||
private void OnCurrentChanged() | ||
{ | ||
EventHandler changed = CurrentChanged; | ||
|
||
if (changed != null) | ||
changed(this, EventArgs.Empty); | ||
} | ||
|
||
public event NotifyCollectionChangedEventHandler CollectionChanged; | ||
|
||
private void OnCollectionReset() | ||
{ | ||
if (!_needsReset) | ||
return; | ||
else | ||
_needsReset = false; | ||
|
||
NotifyCollectionChangedEventHandler changed = CollectionChanged; | ||
|
||
if (changed != null) | ||
changed(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); | ||
} | ||
} | ||
} |
Oops, something went wrong.