mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-22 16:10:48 +00:00
* Source/NSFont.m (-initWithName:...): Move replacement name into
separate method -_replacementFontName and add replacement for "Helvetica-" prefix. * Header/AppKit/NSLayoutManager.h: Add some 10.5 methods. * Source/NSLayoutManager.m: Simple implementations for these new methods. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@35922 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
0f3af93a92
commit
e93fd24f0d
4 changed files with 148 additions and 29 deletions
|
@ -1,3 +1,11 @@
|
|||
2012-12-23 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSFont.m (-initWithName:...): Move replacement name into
|
||||
separate method -_replacementFontName and add replacement for
|
||||
"Helvetica-" prefix.
|
||||
* Header/AppKit/NSLayoutManager.h: Add some 10.5 methods.
|
||||
* Source/NSLayoutManager.m: Simple implementations for these new methods.
|
||||
|
||||
2012-12-16 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSFontPanel.m (-_initWithoutGModel): Fix font panel size
|
||||
|
|
|
@ -171,6 +171,23 @@ GNUstep extension.
|
|||
originalCharacterIndex: (unsigned int)original
|
||||
distance: (float)distance;
|
||||
|
||||
|
||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_5, GS_API_LATEST)
|
||||
- (void) ensureGlyphsForGlyphRange: (NSRange)glyphRange;
|
||||
- (void) ensureGlyphsForCharacterRange: (NSRange)charRange;
|
||||
- (void) ensureLayoutForGlyphRange: (NSRange)glyphRange;
|
||||
- (void) ensureLayoutForCharacterRange: (NSRange)charRange;
|
||||
- (void) ensureLayoutForTextContainer: (NSTextContainer*)container;
|
||||
- (void) ensureLayoutForBoundingRect: (NSRect)bounds
|
||||
inTextContainer: (NSTextContainer*)container;
|
||||
|
||||
- (void) invalidateLayoutForCharacterRange: (NSRange)charRange
|
||||
actualCharacterRange: (NSRangePointer)actualCharRange;
|
||||
|
||||
- (BOOL) allowsNonContiguousLayout;
|
||||
- (void) setAllowsNonContiguousLayout: (BOOL)flag;
|
||||
- (BOOL) hasNonContiguousLayout;
|
||||
#endif
|
||||
@end
|
||||
|
||||
|
||||
|
|
|
@ -784,6 +784,40 @@ static void setNSFont(NSString *key, NSFont *font)
|
|||
return self;
|
||||
}
|
||||
|
||||
/*
|
||||
Last fallback: If a system font was explicitly requested
|
||||
and this font does not exist, try to replace it with the
|
||||
corresponding font in the current setup.
|
||||
*/
|
||||
- (NSString*) _replacementFontName
|
||||
{
|
||||
if (([fontName isEqualToString: @"Helvetica"] &&
|
||||
![font_roles[RoleSystemFont].defaultFont isEqualToString: @"Helvetica"])
|
||||
|| ([fontName isEqualToString: @"LucidaGrande"]))
|
||||
{
|
||||
return font_roles[RoleSystemFont].defaultFont;
|
||||
}
|
||||
else if (([fontName isEqualToString: @"Helvetica-Bold"] &&
|
||||
![font_roles[RoleBoldSystemFont].defaultFont isEqualToString: @"Helvetica-Bold"])
|
||||
|| ([fontName isEqualToString: @"LucidaGrande-Bold"]))
|
||||
{
|
||||
return font_roles[RoleBoldSystemFont].defaultFont;
|
||||
}
|
||||
else if ([fontName isEqualToString: @"Courier"] &&
|
||||
![font_roles[RoleUserFixedPitchFont].defaultFont isEqualToString: @"Courier"])
|
||||
{
|
||||
return font_roles[RoleUserFixedPitchFont].defaultFont;
|
||||
}
|
||||
else if ([fontName hasPrefix: @"Helvetica-"] &&
|
||||
![font_roles[RoleSystemFont].defaultFont isEqualToString: @"Helvetica"])
|
||||
{
|
||||
return [NSString stringWithFormat: @"%@-%@",
|
||||
font_roles[RoleSystemFont].defaultFont,
|
||||
[fontName substringFromIndex: 10]];
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
/** <init />
|
||||
* Initializes a newly created font instance from the name and
|
||||
* information given in the fontMatrix. The fontMatrix is a standard
|
||||
|
@ -829,36 +863,13 @@ static void setNSFont(NSString *key, NSFont *font)
|
|||
screenFont: screen]);
|
||||
if ((fontInfo == nil) && (aRole == RoleExplicit))
|
||||
{
|
||||
/*
|
||||
Last fallback: If a system font was explicitly requested
|
||||
and this font does not exist, try to replace it with the
|
||||
corresponding font in the current setup.
|
||||
*/
|
||||
if (([fontName isEqualToString: @"Helvetica"] &&
|
||||
![font_roles[RoleSystemFont].defaultFont isEqualToString: @"Helvetica"])
|
||||
|| ([fontName isEqualToString: @"LucidaGrande"]))
|
||||
NSString *replacementFontName = [self _replacementFontName];
|
||||
|
||||
if (replacementFontName != nil)
|
||||
{
|
||||
fontInfo = RETAIN([GSFontInfo fontInfoForFontName:
|
||||
font_roles[RoleSystemFont].defaultFont
|
||||
matrix: fontMatrix
|
||||
screenFont: screen]);
|
||||
}
|
||||
else if (([fontName isEqualToString: @"Helvetica-Bold"] &&
|
||||
![font_roles[RoleBoldSystemFont].defaultFont isEqualToString: @"Helvetica-Bold"])
|
||||
|| ([fontName isEqualToString: @"LucidaGrande-Bold"]))
|
||||
{
|
||||
fontInfo = RETAIN([GSFontInfo fontInfoForFontName:
|
||||
font_roles[RoleBoldSystemFont].defaultFont
|
||||
matrix: fontMatrix
|
||||
screenFont: screen]);
|
||||
}
|
||||
else if ([fontName isEqualToString: @"Courier"] &&
|
||||
![font_roles[RoleUserFixedPitchFont].defaultFont isEqualToString: @"Courier"])
|
||||
{
|
||||
fontInfo = RETAIN([GSFontInfo fontInfoForFontName:
|
||||
font_roles[RoleUserFixedPitchFont].defaultFont
|
||||
matrix: fontMatrix
|
||||
screenFont: screen]);
|
||||
fontInfo = RETAIN([GSFontInfo fontInfoForFontName: replacementFontName
|
||||
matrix: fontMatrix
|
||||
screenFont: screen]);
|
||||
}
|
||||
}
|
||||
if (fontInfo == nil)
|
||||
|
|
|
@ -1239,7 +1239,90 @@ has the same y origin and height as the line frag rect it is in.
|
|||
return from;
|
||||
}
|
||||
|
||||
- (void) ensureGlyphsForGlyphRange: (NSRange)glyphRange
|
||||
{
|
||||
[self _generateGlyphsUpToGlyph: NSMaxRange(glyphRange) - 1];
|
||||
}
|
||||
|
||||
- (void) ensureGlyphsForCharacterRange: (NSRange)charRange
|
||||
{
|
||||
[self _generateGlyphsUpToCharacter: NSMaxRange(charRange) - 1];
|
||||
}
|
||||
|
||||
- (void) ensureLayoutForGlyphRange: (NSRange)glyphRange
|
||||
{
|
||||
[self _doLayoutToGlyph: NSMaxRange(glyphRange) - 1];
|
||||
}
|
||||
|
||||
- (void) ensureLayoutForCharacterRange: (NSRange)charRange
|
||||
{
|
||||
NSRange glyphRange;
|
||||
|
||||
glyphRange = [self glyphRangeForCharacterRange: charRange
|
||||
actualCharacterRange: NULL];
|
||||
[self ensureLayoutForGlyphRange: glyphRange];
|
||||
}
|
||||
|
||||
- (void) ensureLayoutForTextContainer: (NSTextContainer*)container
|
||||
{
|
||||
int i;
|
||||
textcontainer_t *tc;
|
||||
NSSize size;
|
||||
|
||||
for (tc = textcontainers, i = 0; i < num_textcontainers; i++, tc++)
|
||||
if (tc->textContainer == container)
|
||||
break;
|
||||
if (i == num_textcontainers)
|
||||
{
|
||||
NSLog(@"%s: invalid text container", __PRETTY_FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
||||
size = [container containerSize];
|
||||
[self _doLayoutToContainer: i
|
||||
point: NSMakePoint(size.width, size.height)];
|
||||
}
|
||||
|
||||
- (void) ensureLayoutForBoundingRect: (NSRect)bounds
|
||||
inTextContainer: (NSTextContainer*)container
|
||||
{
|
||||
int i;
|
||||
textcontainer_t *tc;
|
||||
|
||||
for (tc = textcontainers, i = 0; i < num_textcontainers; i++, tc++)
|
||||
if (tc->textContainer == container)
|
||||
break;
|
||||
if (i == num_textcontainers)
|
||||
{
|
||||
NSLog(@"%s: invalid text container", __PRETTY_FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
||||
[self _doLayoutToContainer: i
|
||||
point: NSMakePoint(NSMaxX(bounds), NSMaxY(bounds))];
|
||||
}
|
||||
|
||||
- (void) invalidateLayoutForCharacterRange: (NSRange)charRange
|
||||
actualCharacterRange: (NSRangePointer)actualCharRange
|
||||
{
|
||||
[self invalidateLayoutForCharacterRange: charRange
|
||||
isSoft: NO
|
||||
actualCharacterRange: actualCharRange];
|
||||
}
|
||||
|
||||
- (BOOL) allowsNonContiguousLayout
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void) setAllowsNonContiguousLayout: (BOOL)flag;
|
||||
{
|
||||
}
|
||||
|
||||
- (BOOL) hasNonContiguousLayout;
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
|
Loading…
Reference in a new issue