mirror of
https://github.com/gnustep/libs-back.git
synced 2025-05-30 08:51:03 +00:00
Replicating the svn commit from the old repository:
r22389 | fredkiefer | 2006-01-29 15:51:31 -0600 (Sun, 29 Jan 2006) | 2 lines Different default fonts and better UTF8 conversion for cairo backend. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@22393 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
33ac1163e4
commit
8289d73137
3 changed files with 74 additions and 13 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2006-01-29 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
|
* Source/cairo/CairoFontInfo.m (_cairo_extents_for_NSGlyph,
|
||||||
|
-drawGlyphs:length:on:) Corrected the conversion from NSGlyph to UTF8.
|
||||||
|
* Source/cairo/CairoFontEnumerator.m:
|
||||||
|
Use the same default fonts as the art backend.
|
||||||
|
|
||||||
2006-01-23 Fred Kiefer <FredKiefer@gmx.de>
|
2006-01-23 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
* Headers/cairo/CairoFaceInfo.h,
|
* Headers/cairo/CairoFaceInfo.h,
|
||||||
|
|
|
@ -192,18 +192,30 @@ static NSArray *faFromFc(FcPattern *pat)
|
||||||
__allFonts = fcxft_allFonts;
|
__allFonts = fcxft_allFonts;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *) defaultSystemFontName
|
-(NSString *) defaultSystemFontName
|
||||||
{
|
{
|
||||||
return @"Adobe Helvetica";
|
if ([allFontNames containsObject: @"Bitstream Vera Sans"])
|
||||||
|
return @"Bitstream Vera Sans";
|
||||||
|
if ([allFontNames containsObject: @"FreeSans"])
|
||||||
|
return @"FreeSans";
|
||||||
|
return @"Helvetica";
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *) defaultBoldSystemFontName
|
-(NSString *) defaultBoldSystemFontName
|
||||||
{
|
{
|
||||||
return @"Adobe Helvetica-Bold";
|
if ([allFontNames containsObject: @"Bitstream Vera Sans-Bold"])
|
||||||
|
return @"Bitstream Vera Sans-Bold";
|
||||||
|
if ([allFontNames containsObject: @"FreeSans-Bold"])
|
||||||
|
return @"FreeSans-Bold";
|
||||||
|
return @"Helvetica-Bold";
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *) defaultFixedPitchFontName
|
-(NSString *) defaultFixedPitchFontName
|
||||||
{
|
{
|
||||||
|
if ([allFontNames containsObject: @"Bitstream Vera Sans Mono"])
|
||||||
|
return @"Bitstream Vera Sans Mono";
|
||||||
|
if ([allFontNames containsObject: @"FreeMono"])
|
||||||
|
return @"FreeMono";
|
||||||
return @"Courier";
|
return @"Courier";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA.
|
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "GNUstepBase/Unicode.h"
|
||||||
#include <AppKit/NSAffineTransform.h>
|
#include <AppKit/NSAffineTransform.h>
|
||||||
#include "cairo/CairoFontInfo.h"
|
#include "cairo/CairoFontInfo.h"
|
||||||
#include "cairo/CairoFontEnumerator.h"
|
#include "cairo/CairoFontEnumerator.h"
|
||||||
|
@ -158,11 +159,23 @@ static
|
||||||
BOOL _cairo_extents_for_NSGlyph(cairo_scaled_font_t *scaled_font, NSGlyph glyph,
|
BOOL _cairo_extents_for_NSGlyph(cairo_scaled_font_t *scaled_font, NSGlyph glyph,
|
||||||
cairo_text_extents_t *ctext)
|
cairo_text_extents_t *ctext)
|
||||||
{
|
{
|
||||||
char str[3];
|
unichar ustr[2];
|
||||||
|
char str[4];
|
||||||
|
unsigned char *b;
|
||||||
|
unsigned int size = 4;
|
||||||
|
int length = 1;
|
||||||
|
|
||||||
// FIXME: This is wrong for none ASCII characters!
|
ustr[0] = glyph;
|
||||||
str[0] = glyph;
|
ustr[1] = 0;
|
||||||
str[1] = 0;
|
|
||||||
|
b = (unsigned char *)str;
|
||||||
|
if (!GSFromUnicode(&b, &size, ustr, length,
|
||||||
|
NSUTF8StringEncoding, NULL, GSUniTerminate))
|
||||||
|
{
|
||||||
|
NSLog(@"Conversion failed for %@",
|
||||||
|
[NSString stringWithCharacters: ustr length: length]);
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
cairo_scaled_font_text_extents(scaled_font, str, ctext);
|
cairo_scaled_font_text_extents(scaled_font, str, ctext);
|
||||||
return cairo_scaled_font_status(scaled_font) == CAIRO_STATUS_SUCCESS;
|
return cairo_scaled_font_status(scaled_font) == CAIRO_STATUS_SUCCESS;
|
||||||
|
@ -250,23 +263,52 @@ BOOL _cairo_extents_for_NSGlyph(cairo_scaled_font_t *scaled_font, NSGlyph glyph,
|
||||||
on: (cairo_t*)ct
|
on: (cairo_t*)ct
|
||||||
{
|
{
|
||||||
cairo_matrix_t font_matrix;
|
cairo_matrix_t font_matrix;
|
||||||
char str[length+1];
|
unichar ustr[length+1];
|
||||||
|
char str[3*length+1];
|
||||||
|
unsigned char *b;
|
||||||
int i;
|
int i;
|
||||||
|
unsigned int size = 3*length+1;
|
||||||
|
|
||||||
for (i = 0; i < length; i++)
|
for (i = 0; i < length; i++)
|
||||||
{
|
{
|
||||||
str[i] = glyphs[i];
|
ustr[i] = glyphs[i];
|
||||||
|
}
|
||||||
|
ustr[length] = 0;
|
||||||
|
|
||||||
|
b = (unsigned char *)str;
|
||||||
|
if (!GSFromUnicode(&b, &size, ustr, length,
|
||||||
|
NSUTF8StringEncoding, NULL, GSUniTerminate))
|
||||||
|
{
|
||||||
|
NSLog(@"Conversion failed for %@",
|
||||||
|
[NSString stringWithCharacters: ustr length: length]);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
str[length] = 0;
|
|
||||||
|
|
||||||
cairo_matrix_init(&font_matrix, matrix[0], matrix[1], matrix[2],
|
cairo_matrix_init(&font_matrix, matrix[0], matrix[1], matrix[2],
|
||||||
-matrix[3], matrix[4], matrix[5]);
|
-matrix[3], matrix[4], matrix[5]);
|
||||||
cairo_set_font_face(ct, [_faceInfo fontFace]);
|
|
||||||
cairo_set_font_matrix(ct, &font_matrix);
|
cairo_set_font_matrix(ct, &font_matrix);
|
||||||
|
if (cairo_status(ct) != CAIRO_STATUS_SUCCESS)
|
||||||
|
{
|
||||||
|
NSLog(@"Error while setting font matrix: %s",
|
||||||
|
cairo_status_to_string(cairo_status(ct)));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cairo_set_font_face(ct, [_faceInfo fontFace]);
|
||||||
|
if (cairo_status(ct) != CAIRO_STATUS_SUCCESS)
|
||||||
|
{
|
||||||
|
NSLog(@"Error while setting font face: %s",
|
||||||
|
cairo_status_to_string(cairo_status(ct)));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// FIXME: Need some adjustment here
|
// FIXME: Need some adjustment here
|
||||||
cairo_rel_move_to(ct, 0.0, -5.0);
|
cairo_rel_move_to(ct, 0.0, -5.0);
|
||||||
cairo_show_text(ct, str);
|
cairo_show_text(ct, str);
|
||||||
|
if (cairo_status(ct) != CAIRO_STATUS_SUCCESS)
|
||||||
|
{
|
||||||
|
NSLog(@"Error drawing string: '%s' for string %s",
|
||||||
|
cairo_status_to_string(cairo_status(ct)), str);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue