Commit d7e9a478 authored by darin's avatar darin
Browse files

* WebCoreSupport.subproj/IFTextRenderer.h: Moved most of the

	stuff from here into the .m file so this header can be included
	by clients. Also added floatWidthForCharacters:length:.
	* WebCoreSupport.subproj/IFTextRenderer.m:
	(freeWidthMap): Check for NULL.
	(freeGlyphMap): Check for NULL.
	(-[IFTextRenderer slowFloatWidthForCharacters:length:]): Renamed,
	and made it return the float.
	(-[IFTextRenderer floatWidthForCharacters:length:]): Renamed, and
	made it return the float.
	(-[IFTextRenderer widthForCharacters:length:]): Do rounding here.

	* WebCoreSupport.subproj/IFTextRendererFactory.h:
	* WebCoreSupport.subproj/IFTextRendererFactory.m:
	Make the interface slightly easier to use by using the specific types.

	* WebKit.pbproj/project.pbxproj: Exported the headers.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@1132 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 461174d2
2002-05-10 Darin Adler <darin@apple.com>
* WebCoreSupport.subproj/IFTextRenderer.h: Moved most of the
stuff from here into the .m file so this header can be included
by clients. Also added floatWidthForCharacters:length:.
* WebCoreSupport.subproj/IFTextRenderer.m:
(freeWidthMap): Check for NULL.
(freeGlyphMap): Check for NULL.
(-[IFTextRenderer slowFloatWidthForCharacters:length:]): Renamed,
and made it return the float.
(-[IFTextRenderer floatWidthForCharacters:length:]): Renamed, and
made it return the float.
(-[IFTextRenderer widthForCharacters:length:]): Do rounding here.
* WebCoreSupport.subproj/IFTextRendererFactory.h:
* WebCoreSupport.subproj/IFTextRendererFactory.m:
Make the interface slightly easier to use by using the specific types.
* WebKit.pbproj/project.pbxproj: Exported the headers.
2002-05-10 Kenneth Kocienda <kocienda@apple.com>
Fixed build breakage caused by my previous checkin.
......
2002-05-10 Darin Adler <darin@apple.com>
* WebCoreSupport.subproj/IFTextRenderer.h: Moved most of the
stuff from here into the .m file so this header can be included
by clients. Also added floatWidthForCharacters:length:.
* WebCoreSupport.subproj/IFTextRenderer.m:
(freeWidthMap): Check for NULL.
(freeGlyphMap): Check for NULL.
(-[IFTextRenderer slowFloatWidthForCharacters:length:]): Renamed,
and made it return the float.
(-[IFTextRenderer floatWidthForCharacters:length:]): Renamed, and
made it return the float.
(-[IFTextRenderer widthForCharacters:length:]): Do rounding here.
* WebCoreSupport.subproj/IFTextRendererFactory.h:
* WebCoreSupport.subproj/IFTextRendererFactory.m:
Make the interface slightly easier to use by using the specific types.
* WebKit.pbproj/project.pbxproj: Exported the headers.
2002-05-10 Kenneth Kocienda <kocienda@apple.com>
Fixed build breakage caused by my previous checkin.
......
......@@ -7,24 +7,9 @@
//
#import <WebCoreTextRenderer.h>
#import <QD/ATSUnicodePriv.h>
typedef float IFGlyphWidth;
typedef struct _WidthMap {
ATSGlyphRef startRange;
ATSGlyphRef endRange;
struct _WidthMap *next;
IFGlyphWidth *widths;
} WidthMap;
typedef struct _GlyphMap {
UniChar startRange;
UniChar endRange;
struct _GlyphMap *next;
ATSGlyphRef *glyphs;
} GlyphMap;
typedef struct WidthMap WidthMap;
typedef struct GlyphMap GlyphMap;
@interface IFTextRenderer : NSObject <WebCoreTextRenderer>
{
......@@ -32,7 +17,7 @@ typedef struct _GlyphMap {
int descent;
int lineSpacing;
ATSStyleGroupPtr styleGroup;
struct AttributeGroup *styleGroup;
@public
NSFont *font;
......@@ -41,10 +26,7 @@ typedef struct _GlyphMap {
}
- initWithFont:(NSFont *)font;
- (void)convertCharacters: (const unichar *)characters length: (int)numCharacters glyphs: (ATSGlyphVector *)glyphs;
- (ATSGlyphRef)extendCharacterToGlyphMapToInclude:(UniChar) c;
- (WidthMap *)extendGlyphToWidthMapToInclude:(ATSGlyphRef)glyphID;
- (bool) slowPackGlyphsForCharacters:(const UniChar *)characters numCharacters: (unsigned int)numCharacters glyphBuffer:(CGGlyph **)glyphBuffer numGlyphs:(unsigned int *)numGlyphs;
- (float)floatWidthForCharacters:(const unichar *)characters length:(unsigned)length;
@end
......@@ -16,6 +16,8 @@
#import <WebKit/IFTextRendererFactory.h>
#import <WebKit/WebKitDebug.h>
#import <QD/ATSUnicodePriv.h>
#define NON_BREAKING_SPACE 0xA0
#define SPACE 0x20
......@@ -42,6 +44,23 @@
#define IsNonBaseChar(X) ((CFCharacterSetIsCharacterMember(nonBaseChars, X) || IsHangulConjoiningJamo(X) || (((X) & 0x1FFFF0) == 0xF870)))
typedef float IFGlyphWidth;
struct WidthMap {
ATSGlyphRef startRange;
ATSGlyphRef endRange;
WidthMap *next;
IFGlyphWidth *widths;
};
struct GlyphMap {
UniChar startRange;
UniChar endRange;
GlyphMap *next;
ATSGlyphRef *glyphs;
};
@interface NSLanguage : NSObject
{
}
......@@ -62,8 +81,16 @@ + (NSFont *) findFontLike:(NSFont *)aFont forString:(NSString *)string withRange
static CFCharacterSetRef nonBaseChars = NULL;
@interface IFTextRenderer (IFPrivate)
- (WidthMap *)extendGlyphToWidthMapToInclude:(ATSGlyphRef)glyphID;
- (ATSGlyphRef)extendCharacterToGlyphMapToInclude:(UniChar) c;
@end
static void freeWidthMap (WidthMap *map)
{
if (!map)
return;
if (map->next)
freeWidthMap (map->next);
free (map->widths);
......@@ -73,6 +100,8 @@ static void freeWidthMap (WidthMap *map)
static void freeGlyphMap (GlyphMap *map)
{
if (!map)
return;
if (map->next)
freeGlyphMap (map->next);
free (map->glyphs);
......@@ -438,7 +467,7 @@ - (void)drawCharacters:(const UniChar *)characters length: (unsigned int)length
if (!hasGlyphs){
substituteFont = [self substituteFontForCharacters: characters length: length];
if (substituteFont){
[(IFTextRenderer *)[(IFTextRendererFactory *)[IFTextRendererFactory sharedFactory] rendererWithFont: substituteFont] drawCharacters: characters length: length atPoint: point withColor: color];
[[[IFTextRendererFactory sharedFactory] rendererWithFont: substituteFont] drawCharacters: characters length: length atPoint: point withColor: color];
goto cleanup;
}
}
......@@ -452,7 +481,7 @@ - (void)drawCharacters:(const UniChar *)characters length: (unsigned int)length
if (glyphID == 0){
substituteFont = [self substituteFontForCharacters: characters length: length];
if (substituteFont){
[(IFTextRenderer *)[(IFTextRendererFactory *)[IFTextRendererFactory sharedFactory] rendererWithFont: substituteFont] drawCharacters: characters length: length atPoint: point withColor: color];
[[[IFTextRendererFactory sharedFactory] rendererWithFont: substituteFont] drawCharacters: characters length: length atPoint: point withColor: color];
goto cleanup;
}
}
......@@ -533,7 +562,7 @@ - (void)drawUnderlineForString:(NSString *)string atPoint:(NSPoint)point withCol
}
- (int)slowWidthForCharacters: (const UniChar *)characters length: (unsigned)length
- (float)slowFloatWidthForCharacters: (const UniChar *)characters length: (unsigned)length
{
float totalWidth = 0;
unsigned int i, numGlyphs;
......@@ -558,7 +587,7 @@ - (int)slowWidthForCharacters: (const UniChar *)characters length: (unsigned)len
}
- (int)widthForCharacters:(const UniChar *)characters length:(unsigned)length
- (float)floatWidthForCharacters:(const UniChar *)characters length:(unsigned)length
{
float totalWidth = 0;
unsigned int i;
......@@ -573,7 +602,7 @@ - (int)widthForCharacters:(const UniChar *)characters length:(unsigned)length
c = SPACE;
}
else if (IsNonBaseChar(c)){
return [self slowWidthForCharacters: characters length: length];
return [self slowFloatWidthForCharacters: characters length: length];
}
glyphID = glyphForCharacter(characterToGlyphMap, c);
......@@ -587,7 +616,7 @@ - (int)widthForCharacters:(const UniChar *)characters length:(unsigned)length
substituteFont = [self substituteFontForCharacters: characters length: length];
if (substituteFont){
WEBKITDEBUGLEVEL (WEBKIT_LOG_FONTCACHE, "substituting %s for %s, missing 0x%04x\n", DEBUG_OBJECT([substituteFont displayName]), DEBUG_OBJECT([font displayName]), c);
return [[(IFTextRendererFactory *)[IFTextRendererFactory sharedFactory] rendererWithFont: substituteFont] widthForCharacters: characters length: length];
return [[[IFTextRendererFactory sharedFactory] rendererWithFont: substituteFont] widthForCharacters: characters length: length];
}
}
......@@ -597,6 +626,11 @@ - (int)widthForCharacters:(const UniChar *)characters length:(unsigned)length
return ROUND_TO_INT(totalWidth);
}
- (int)widthForCharacters:(const UniChar *)characters length:(unsigned)length
{
return ROUND_TO_INT([self floatWidthForCharacters:characters length:length]);
}
// This method is rarely (never?) called. It's slow.
- (void)drawString:(NSString *)string inRect:(NSRect)rect withColor:(NSColor *)color paragraphStyle:(NSParagraphStyle *)style
......
......@@ -8,13 +8,17 @@
#import <WebCoreTextRendererFactory.h>
@class IFTextRenderer;
@interface IFTextRendererFactory : WebCoreTextRendererFactory
{
NSMutableDictionary *cache;
}
+ (void)createSharedFactory;
+ (IFTextRendererFactory *)sharedFactory;
- init;
- (id <WebCoreTextRenderer>)rendererWithFont:(NSFont *)font;
- (IFTextRenderer *)rendererWithFont:(NSFont *)font;
@end
......@@ -69,6 +69,11 @@ + (void)createSharedFactory;
WEBKIT_ASSERT([[self sharedFactory] isMemberOfClass:self]);
}
+ (IFTextRendererFactory *)sharedFactory;
{
return (IFTextRendererFactory *)[super sharedFactory];
}
- init
{
[super init];
......@@ -85,7 +90,7 @@ - (void)dealloc
[super dealloc];
}
- (id <WebCoreTextRenderer>)rendererWithFont:(NSFont *)font
- (IFTextRenderer *)rendererWithFont:(NSFont *)font
{
IFTextRenderer *renderer = [cache objectForKey:font];
if (renderer == nil) {
......
......@@ -7,24 +7,9 @@
//
#import <WebCoreTextRenderer.h>
#import <QD/ATSUnicodePriv.h>
typedef float IFGlyphWidth;
typedef struct _WidthMap {
ATSGlyphRef startRange;
ATSGlyphRef endRange;
struct _WidthMap *next;
IFGlyphWidth *widths;
} WidthMap;
typedef struct _GlyphMap {
UniChar startRange;
UniChar endRange;
struct _GlyphMap *next;
ATSGlyphRef *glyphs;
} GlyphMap;
typedef struct WidthMap WidthMap;
typedef struct GlyphMap GlyphMap;
@interface IFTextRenderer : NSObject <WebCoreTextRenderer>
{
......@@ -32,7 +17,7 @@ typedef struct _GlyphMap {
int descent;
int lineSpacing;
ATSStyleGroupPtr styleGroup;
struct AttributeGroup *styleGroup;
@public
NSFont *font;
......@@ -41,10 +26,7 @@ typedef struct _GlyphMap {
}
- initWithFont:(NSFont *)font;
- (void)convertCharacters: (const unichar *)characters length: (int)numCharacters glyphs: (ATSGlyphVector *)glyphs;
- (ATSGlyphRef)extendCharacterToGlyphMapToInclude:(UniChar) c;
- (WidthMap *)extendGlyphToWidthMapToInclude:(ATSGlyphRef)glyphID;
- (bool) slowPackGlyphsForCharacters:(const UniChar *)characters numCharacters: (unsigned int)numCharacters glyphBuffer:(CGGlyph **)glyphBuffer numGlyphs:(unsigned int *)numGlyphs;
- (float)floatWidthForCharacters:(const unichar *)characters length:(unsigned)length;
@end
......@@ -16,6 +16,8 @@
#import <WebKit/IFTextRendererFactory.h>
#import <WebKit/WebKitDebug.h>
#import <QD/ATSUnicodePriv.h>
#define NON_BREAKING_SPACE 0xA0
#define SPACE 0x20
......@@ -42,6 +44,23 @@
#define IsNonBaseChar(X) ((CFCharacterSetIsCharacterMember(nonBaseChars, X) || IsHangulConjoiningJamo(X) || (((X) & 0x1FFFF0) == 0xF870)))
typedef float IFGlyphWidth;
struct WidthMap {
ATSGlyphRef startRange;
ATSGlyphRef endRange;
WidthMap *next;
IFGlyphWidth *widths;
};
struct GlyphMap {
UniChar startRange;
UniChar endRange;
GlyphMap *next;
ATSGlyphRef *glyphs;
};
@interface NSLanguage : NSObject
{
}
......@@ -62,8 +81,16 @@ + (NSFont *) findFontLike:(NSFont *)aFont forString:(NSString *)string withRange
static CFCharacterSetRef nonBaseChars = NULL;
@interface IFTextRenderer (IFPrivate)
- (WidthMap *)extendGlyphToWidthMapToInclude:(ATSGlyphRef)glyphID;
- (ATSGlyphRef)extendCharacterToGlyphMapToInclude:(UniChar) c;
@end
static void freeWidthMap (WidthMap *map)
{
if (!map)
return;
if (map->next)
freeWidthMap (map->next);
free (map->widths);
......@@ -73,6 +100,8 @@ static void freeWidthMap (WidthMap *map)
static void freeGlyphMap (GlyphMap *map)
{
if (!map)
return;
if (map->next)
freeGlyphMap (map->next);
free (map->glyphs);
......@@ -438,7 +467,7 @@ - (void)drawCharacters:(const UniChar *)characters length: (unsigned int)length
if (!hasGlyphs){
substituteFont = [self substituteFontForCharacters: characters length: length];
if (substituteFont){
[(IFTextRenderer *)[(IFTextRendererFactory *)[IFTextRendererFactory sharedFactory] rendererWithFont: substituteFont] drawCharacters: characters length: length atPoint: point withColor: color];
[[[IFTextRendererFactory sharedFactory] rendererWithFont: substituteFont] drawCharacters: characters length: length atPoint: point withColor: color];
goto cleanup;
}
}
......@@ -452,7 +481,7 @@ - (void)drawCharacters:(const UniChar *)characters length: (unsigned int)length
if (glyphID == 0){
substituteFont = [self substituteFontForCharacters: characters length: length];
if (substituteFont){
[(IFTextRenderer *)[(IFTextRendererFactory *)[IFTextRendererFactory sharedFactory] rendererWithFont: substituteFont] drawCharacters: characters length: length atPoint: point withColor: color];
[[[IFTextRendererFactory sharedFactory] rendererWithFont: substituteFont] drawCharacters: characters length: length atPoint: point withColor: color];
goto cleanup;
}
}
......@@ -533,7 +562,7 @@ - (void)drawUnderlineForString:(NSString *)string atPoint:(NSPoint)point withCol
}
- (int)slowWidthForCharacters: (const UniChar *)characters length: (unsigned)length
- (float)slowFloatWidthForCharacters: (const UniChar *)characters length: (unsigned)length
{
float totalWidth = 0;
unsigned int i, numGlyphs;
......@@ -558,7 +587,7 @@ - (int)slowWidthForCharacters: (const UniChar *)characters length: (unsigned)len
}
- (int)widthForCharacters:(const UniChar *)characters length:(unsigned)length
- (float)floatWidthForCharacters:(const UniChar *)characters length:(unsigned)length
{
float totalWidth = 0;
unsigned int i;
......@@ -573,7 +602,7 @@ - (int)widthForCharacters:(const UniChar *)characters length:(unsigned)length
c = SPACE;
}
else if (IsNonBaseChar(c)){
return [self slowWidthForCharacters: characters length: length];
return [self slowFloatWidthForCharacters: characters length: length];
}
glyphID = glyphForCharacter(characterToGlyphMap, c);
......@@ -587,7 +616,7 @@ - (int)widthForCharacters:(const UniChar *)characters length:(unsigned)length
substituteFont = [self substituteFontForCharacters: characters length: length];
if (substituteFont){
WEBKITDEBUGLEVEL (WEBKIT_LOG_FONTCACHE, "substituting %s for %s, missing 0x%04x\n", DEBUG_OBJECT([substituteFont displayName]), DEBUG_OBJECT([font displayName]), c);
return [[(IFTextRendererFactory *)[IFTextRendererFactory sharedFactory] rendererWithFont: substituteFont] widthForCharacters: characters length: length];
return [[[IFTextRendererFactory sharedFactory] rendererWithFont: substituteFont] widthForCharacters: characters length: length];
}
}
......@@ -597,6 +626,11 @@ - (int)widthForCharacters:(const UniChar *)characters length:(unsigned)length
return ROUND_TO_INT(totalWidth);
}
- (int)widthForCharacters:(const UniChar *)characters length:(unsigned)length
{
return ROUND_TO_INT([self floatWidthForCharacters:characters length:length]);
}
// This method is rarely (never?) called. It's slow.
- (void)drawString:(NSString *)string inRect:(NSRect)rect withColor:(NSColor *)color paragraphStyle:(NSParagraphStyle *)style
......
......@@ -8,13 +8,17 @@
#import <WebCoreTextRendererFactory.h>
@class IFTextRenderer;
@interface IFTextRendererFactory : WebCoreTextRendererFactory
{
NSMutableDictionary *cache;
}
+ (void)createSharedFactory;
+ (IFTextRendererFactory *)sharedFactory;
- init;
- (id <WebCoreTextRenderer>)rendererWithFont:(NSFont *)font;
- (IFTextRenderer *)rendererWithFont:(NSFont *)font;
@end
......@@ -69,6 +69,11 @@ + (void)createSharedFactory;
WEBKIT_ASSERT([[self sharedFactory] isMemberOfClass:self]);
}
+ (IFTextRendererFactory *)sharedFactory;
{
return (IFTextRendererFactory *)[super sharedFactory];
}
- init
{
[super init];
......@@ -85,7 +90,7 @@ - (void)dealloc
[super dealloc];
}
- (id <WebCoreTextRenderer>)rendererWithFont:(NSFont *)font
- (IFTextRenderer *)rendererWithFont:(NSFont *)font
{
IFTextRenderer *renderer = [cache objectForKey:font];
if (renderer == nil) {
......
......@@ -1504,6 +1504,9 @@
fileRef = F5B36B410281DF55018635CB;
isa = PBXBuildFile;
settings = {
ATTRIBUTES = (
Private,
);
};
};
F5B36B440281DF55018635CB = {
......@@ -1847,6 +1850,9 @@
fileRef = F5B36B450281DF9C018635CB;
isa = PBXBuildFile;
settings = {
ATTRIBUTES = (
Private,
);
};
};
F5F7174C02885C5B018635CA = {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment