Permalink
Browse files

New font measure interface

  • Loading branch information...
1 parent 355299c commit 9bf0e10a5405debf0fb836a27aaf51063d382635 @praeclarum committed Apr 30, 2012
Showing with 4 additions and 6 deletions.
  1. +4 −6 src/CoreGraphicsGraphics.cs
@@ -501,8 +501,6 @@ public void MeasureText (CGContext c, Font f)
var sz = c.TextPosition.X - mmWidth;
if (sz < 0.1f) {
- // BAD FONT SIZE Why does this happen? I don't know
-// Console.WriteLine ("BAD FONT MEASUREMENT");
Widths = null;
return;
}
@@ -517,20 +515,20 @@ public CoreGraphicsFontMetrics ()
{
}
- public int StringWidth (string str)
+ public int StringWidth (string str, int startIndex, int length)
{
if (str == null) return 0;
- var n = str.Length;
- if (n == 0) return 0;
+ var end = startIndex + str.Length;
+ if (end <= 0) return 0;
if (Widths == null) {
return 0;
}
var w = 0.0f;
- for (var i = 0; i < n; i++) {
+ for (var i = startIndex; i < end; i++) {
var ch = (int)str[i];
if (ch < Widths.Length) {
w += Widths[ch];

0 comments on commit 9bf0e10

Please sign in to comment.