Revision: 16310
http://sourceforge.net/p/skim-app/code/16310
Author: hofman
Date: 2026-05-25 09:25:36 +0000 (Mon, 25 May 2026)
Log Message:
-----------
get glyph range in text rect
Modified Paths:
--------------
trunk/QuickLook-Skim/GenerateThumbnailForURL.m
trunk/SkimQuickLookThumbnails/SKThumbnailProvider.m
Modified: trunk/QuickLook-Skim/GenerateThumbnailForURL.m
===================================================================
--- trunk/QuickLook-Skim/GenerateThumbnailForURL.m 2026-05-24 22:06:40 UTC
(rev 16309)
+++ trunk/QuickLook-Skim/GenerateThumbnailForURL.m 2026-05-25 09:25:36 UTC
(rev 16310)
@@ -70,8 +70,6 @@
[textStorage setAttributedString:attrString];
[textStorage endEditing];
- NSRect stringRect = NSZeroRect;
- stringRect.size = _paperSize;
CGContextSaveGState(context);
@@ -88,11 +86,10 @@
NSLayoutManager *lm = [[textStorage layoutManagers] objectAtIndex:0];
NSTextContainer *tc = [[lm textContainers] objectAtIndex:0];
- NSRange glyphRange;
-
// we now have a properly flipped graphics context, so force layout and
then draw the text
- glyphRange = [lm glyphRangeForBoundingRect:stringRect inTextContainer:tc];
- NSRect usedRect = [lm usedRectForTextContainer:tc];
+ NSRect stringRect = NSMakeRect(_horizontalMargin, _verticalMargin,
_paperSize.width - 2 * _horizontalMargin, _paperSize.height - 2 *
_verticalMargin);
+ NSRange glyphRange = [lm glyphRangeForBoundingRect:stringRect
inTextContainer:tc];
+ stringRect = [lm usedRectForTextContainer:tc];
// NSRunStorage raises if we try drawing a zero length range (happens if
you have an empty text file)
if (glyphRange.length > 0) {
@@ -100,8 +97,8 @@
[NSGraphicsContext saveGraphicsState];
[NSGraphicsContext setCurrentContext:nsContext];
- [lm drawBackgroundForGlyphRange:glyphRange atPoint:usedRect.origin];
- [lm drawGlyphsForGlyphRange:glyphRange atPoint:usedRect.origin];
+ [lm drawBackgroundForGlyphRange:glyphRange atPoint:stringRect.origin];
+ [lm drawGlyphsForGlyphRange:glyphRange atPoint:stringRect.origin];
[NSGraphicsContext restoreGraphicsState];
}
Modified: trunk/SkimQuickLookThumbnails/SKThumbnailProvider.m
===================================================================
--- trunk/SkimQuickLookThumbnails/SKThumbnailProvider.m 2026-05-24 22:06:40 UTC
(rev 16309)
+++ trunk/SkimQuickLookThumbnails/SKThumbnailProvider.m 2026-05-25 09:25:36 UTC
(rev 16310)
@@ -72,8 +72,6 @@
[textStorage setAttributedString:attrString];
[textStorage endEditing];
- NSRect stringRect = NSZeroRect;
- stringRect.size = _paperSize;
CGContextSaveGState(context);
@@ -85,11 +83,10 @@
NSLayoutManager *lm = [[textStorage layoutManagers] objectAtIndex:0];
NSTextContainer *tc = [[lm textContainers] objectAtIndex:0];
- NSRange glyphRange;
-
// we now have a properly flipped graphics context, so force layout and
then draw the text
- glyphRange = [lm glyphRangeForBoundingRect:stringRect inTextContainer:tc];
- NSRect usedRect = [lm usedRectForTextContainer:tc];
+ NSRect stringRect = NSMakeRect(_horizontalMargin, _verticalMargin,
_paperSize.width - 2 * _horizontalMargin, _paperSize.height - 2 *
_verticalMargin);
+ NSRange glyphRange = [lm glyphRangeForBoundingRect:stringRect
inTextContainer:tc];
+ stringRect = [lm usedRectForTextContainer:tc];
// NSRunStorage raises if we try drawing a zero length range (happens if
you have an empty text file)
if (glyphRange.length > 0) {
@@ -97,8 +94,8 @@
[NSGraphicsContext saveGraphicsState];
[NSGraphicsContext setCurrentContext:nsContext];
- [lm drawBackgroundForGlyphRange:glyphRange atPoint:usedRect.origin];
- [lm drawGlyphsForGlyphRange:glyphRange atPoint:usedRect.origin];
+ [lm drawBackgroundForGlyphRange:glyphRange atPoint:stringRect.origin];
+ [lm drawGlyphsForGlyphRange:glyphRange atPoint:stringRect.origin];
[NSGraphicsContext restoreGraphicsState];
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit