Skip to content
This repository has been archived by the owner on Oct 18, 2023. It is now read-only.

Commit

Permalink
Enhance overlap determination logic to calculate coverage of CFF stru…
Browse files Browse the repository at this point in the history
…ctures.

switch to List to make it sortable

and private

adding Occupied property to Overlap

not adding zero-length segments

allow zero-length segments, but break-ties on length on sorting

adding api to get at the end
  • Loading branch information
HinTak committed Feb 8, 2016
1 parent 04af62c commit 14b1d65
Showing 1 changed file with 45 additions and 4 deletions.
49 changes: 45 additions & 4 deletions OTFontFileVal/Overlap.cs
@@ -1,5 +1,5 @@
using System;
using System.Collections;
using System.Collections.Generic;

namespace OTFontFileVal
{
Expand All @@ -10,7 +10,7 @@ public class DataOverlapDetector
{
public DataOverlapDetector()
{
m_listFootprints = new ArrayList();
m_listFootprints = new List<Footprint>();
}

public bool CheckForNoOverlap(uint offset, uint length)
Expand All @@ -24,7 +24,7 @@ public bool CheckForNoOverlap(uint offset, uint length)

for (int i=0; i<m_listFootprints.Count; i++)
{
if (footprint.Overlaps((Footprint)m_listFootprints[i]))
if (footprint.Overlaps(m_listFootprints[i]))
{
bNoOverlap = false;
break;
Expand Down Expand Up @@ -64,12 +64,53 @@ public bool Overlaps(Footprint f)
return bOverlap;
}

public uint begins
{
get {
return first;
}
}
public uint ends
{
get {
return (first + length);
}
}

uint first;
uint last;
uint length;
}

ArrayList m_listFootprints;
public string Occupied
{
get {
m_listFootprints.Sort(delegate(Footprint x, Footprint y)
{
if (x.begins == y.begins)
return x.ends.CompareTo(y.ends);
return x.begins.CompareTo(y.begins);
});

string result = m_listFootprints[0].begins.ToString();
for (int i = 1; i < m_listFootprints.Count; i++)
{
if (m_listFootprints[i].begins != m_listFootprints[i-1].ends )
result += "-" + m_listFootprints[i-1].ends + ";" + m_listFootprints[i].begins;
}
result += "-" + m_listFootprints[m_listFootprints.Count -1 ].ends;
return result;
}
}

public uint ends
{
get {
return m_listFootprints[m_listFootprints.Count -1 ].ends;
}
}

private List<Footprint> m_listFootprints;
}

}

0 comments on commit 14b1d65

Please sign in to comment.