[Mwinapi-commits] SF.net SVN: mwinapi:[77] trunk/ManagedWinapi/CodepointRange.cs
Status: Beta
Brought to you by:
schierlm
|
From: <sch...@us...> - 2009-01-17 14:28:11
|
Revision: 77
http://mwinapi.svn.sourceforge.net/mwinapi/?rev=77&view=rev
Author: schierlm
Date: 2009-01-17 14:28:01 +0000 (Sat, 17 Jan 2009)
Log Message:
-----------
Fix codepoint range calculation for fonts that include an U+FFFF glyph.
Modified Paths:
--------------
trunk/ManagedWinapi/CodepointRange.cs
Modified: trunk/ManagedWinapi/CodepointRange.cs
===================================================================
--- trunk/ManagedWinapi/CodepointRange.cs 2008-08-28 22:23:10 UTC (rev 76)
+++ trunk/ManagedWinapi/CodepointRange.cs 2009-01-17 14:28:01 UTC (rev 77)
@@ -34,7 +34,20 @@
{
char firstIncluded = (char)Marshal.ReadInt16(glyphSet, 16 + i * 4);
char firstExcluded = (char)(firstIncluded + Marshal.ReadInt16(glyphSet, 18 + i * 4));
- tmp += firstExcluded - firstIncluded;
+ if (firstExcluded == 0 && firstIncluded > 0)
+ {
+ // when U+FFFF is included, firstExcluded will wrap around, so
+ // provide a workaround here
+ tmp += 0x10000 - firstIncluded;
+ }
+ else if (firstExcluded > firstIncluded)
+ {
+ tmp += firstExcluded - firstIncluded;
+ }
+ else
+ {
+ throw new Exception("Invalid inclusion range: " + font.FontFamily.Name + " [" + ((int)firstIncluded).ToString("X4") + "-" + ((int)firstExcluded).ToString("X4") + "]");
+ }
rangeList.Add(firstIncluded);
rangeList.Add(firstExcluded);
}
@@ -120,9 +133,11 @@
public bool IsSupported(char codepoint)
{
bool result = false;
+ bool first = true;
foreach (char c in ranges)
{
- if (c > codepoint) break;
+ if (c > codepoint || (c == 0 && !first)) break;
+ first = false;
result = !result;
}
return result;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|