summaryrefslogtreecommitdiff
path: root/cocoa/font.m
diff options
context:
space:
mode:
authorSven Weidauer <sven.weidauer@gmail.com>2011-01-27 11:43:48 +0000
committerSven Weidauer <sven.weidauer@gmail.com>2011-01-27 11:43:48 +0000
commit3376f7f50ff774030596a2e84dd9f72920ee449c (patch)
tree54d6f33f418adc27a50e327d909ae5a6c1c55f31 /cocoa/font.m
parent73885bf3d0e6ff5438a4d2140dcc29dea924912a (diff)
downloadnetsurf-3376f7f50ff774030596a2e84dd9f72920ee449c.tar.gz
netsurf-3376f7f50ff774030596a2e84dd9f72920ee449c.tar.bz2
Implemented resolution-independent rendering for the browser view. Still needs to be implemented for the other views.
svn path=/trunk/netsurf/; revision=11507
Diffstat (limited to 'cocoa/font.m')
-rw-r--r--cocoa/font.m13
1 files changed, 7 insertions, 6 deletions
diff --git a/cocoa/font.m b/cocoa/font.m
index 73e73e7e1..4e50a48fa 100644
--- a/cocoa/font.m
+++ b/cocoa/font.m
@@ -28,6 +28,7 @@
#import "font.h"
#import "plotter.h"
+#import "cocoa/plotter.h"
static NSLayoutManager *cocoa_prepare_layout_manager( const char *string, size_t length,
const plot_font_style_t *style );
@@ -65,8 +66,8 @@ static bool nsfont_position_in_string(const plot_font_style_t *style,
if (chars >= [cocoa_text_storage length]) *char_offset = length;
else *char_offset = cocoa_bytes_for_characters( string, chars );
- *actual_x = NSMaxX( [layout boundingRectForGlyphRange: NSMakeRange( glyphIndex - 1, 1 )
- inTextContainer: cocoa_text_container] );
+ *actual_x = cocoa_pt_to_px( NSMaxX( [layout boundingRectForGlyphRange: NSMakeRange( glyphIndex - 1, 1 )
+ inTextContainer: cocoa_text_container] ) );
return true;
}
@@ -114,7 +115,7 @@ void cocoa_set_font_scale_factor( float newFactor )
cocoa_font_scale_factor = newFactor;
}
-void cocoa_draw_string( int x, int y, const char *bytes, size_t length, const plot_font_style_t *style )
+void cocoa_draw_string( CGFloat x, CGFloat y, const char *bytes, size_t length, const plot_font_style_t *style )
{
NSLayoutManager *layout = cocoa_prepare_layout_manager( bytes, length, style );
@@ -134,19 +135,19 @@ static inline CGFloat cocoa_layout_width( NSLayoutManager *layout )
{
if (layout == nil) return 0.0;
- return NSWidth( [layout usedRectForTextContainer: cocoa_text_container] );
+ return cocoa_pt_to_px( NSWidth( [layout usedRectForTextContainer: cocoa_text_container] ) );
}
static inline CGFloat cocoa_layout_width_chars( NSLayoutManager *layout, size_t characters )
{
NSUInteger glyphIndex = [layout glyphIndexForCharacterAtIndex: characters];
- return [layout locationForGlyphAtIndex: glyphIndex].x;
+ return cocoa_pt_to_px( [layout locationForGlyphAtIndex: glyphIndex].x );
}
static inline NSUInteger cocoa_glyph_for_location( NSLayoutManager *layout, CGFloat x )
{
CGFloat fraction = 0.0;
- NSUInteger glyphIndex = [layout glyphIndexForPoint: NSMakePoint( x, 0 )
+ NSUInteger glyphIndex = [layout glyphIndexForPoint: NSMakePoint( cocoa_px_to_pt( x ), 0 )
inTextContainer: cocoa_text_container
fractionOfDistanceThroughGlyph: &fraction];
if (fraction > 0) ++glyphIndex;