Add font enumerator, font info, and other classes

This commit is contained in:
Frederik Carlier 2023-09-28 11:53:15 +00:00
parent bc1d726f41
commit e9c633abf7
13 changed files with 509 additions and 10 deletions

View file

@ -23,8 +23,6 @@
#include "gsc/GSContext.h"
@interface HeadlessContext : GSContext
{
}
@end
#endif
#endif /* HeadlessContext_h_INCLUDE */

View file

@ -0,0 +1,38 @@
/*
HeadlessFaceInfo.h
Copyright (C) 2003 Free Software Foundation, Inc.
August 31, 2003
Written by Banlu Kemiyatorn <object at gmail dot com>
Base on code by Alexander Malmberg <alexander@malmberg.org>
Rewrite: Fred Kiefer <fredkiefer@gmx.de>
Date: Jan 2006
This file is part of GNUstep.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; see the file COPYING.LIB.
If not, see <http://www.gnu.org/licenses/> or write to the
Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef HEADLESSFACEINFO_H
#define HEADLESSFACEINFO_H
#include <Foundation/NSObject.h>
@interface HeadlessFaceInfo : NSObject
{
void *_fontFace;
}
- (void *)fontFace;
@end
#endif

View file

@ -0,0 +1,37 @@
/*
HeadlessFontEnumerator.h
Copyright (C) 2003 Free Software Foundation, Inc.
August 31, 2003
Written by Banlu Kemiyatorn <object at gmail dot com>
This file is part of GNUstep.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; see the file COPYING.LIB.
If not, see <http://www.gnu.org/licenses/> or write to the
Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef CairoFontEnumerator_h
#define CairoFontEnumerator_h
#include <GNUstepGUI/GSFontInfo.h>
#include "headless/HeadlessFaceInfo.h"
@interface HeadlessFontEnumerator : GSFontEnumerator
{
}
+ (Class) faceInfoClass;
+ (HeadlessFaceInfo *) fontWithName: (NSString *)name;
@end
#endif

View file

@ -0,0 +1,30 @@
/*
CairoFontInfo.h
Copyright (C) 2003 Free Software Foundation, Inc.
August 31, 2003
Written by Banlu Kemiyatorn <object at gmail dot com>
This file is part of GNUstep.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; see the file COPYING.LIB.
If not, see <http://www.gnu.org/licenses/> or write to the
Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef HeadlessFontInfo_h
#define HeadlessFontInfo_h
#include <GNUstepGUI/GSFontInfo.h>
@interface HeadlessFontInfo : GSFontInfo
@end
#endif

View file

@ -0,0 +1,30 @@
/*
Copyright (C) 2004 Free Software Foundation, Inc.
Author: Banlu Kemiyatorn <object at gmail dot com>
This file is part of GNUstep.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; see the file COPYING.LIB.
If not, see <http://www.gnu.org/licenses/> or write to the
Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef HeadlessGState_h
#define HeadlessGState_h
#include "gsc/GSGState.h"
@interface HeadlessGState : GSGState
{
}
@end
#endif

View file

@ -75,7 +75,7 @@
[WIN32Server initializeBackend];
#elif BUILD_SERVER == SERVER_wayland
[WaylandServer initializeBackend];
#elif BUILD_SERVER == SERVER_xheadless
#elif BUILD_SERVER == SERVER_headless
[HeadlessServer initializeBackend];
#else
[NSException raise: NSInternalInconsistencyException

View file

@ -30,10 +30,16 @@ include $(GNUSTEP_MAKEFILES)/common.make
include ../../config.make
# The library to be compiled, as a library or as a bundle
SUBPROJECT_NAME=xheadless
SUBPROJECT_NAME=headless
# The Objective-C source files to be compiled
xheadless_OBJC_FILES =
headless_OBJC_FILES = \
HeadlessContext.m \
HeadlessServer.m \
HeadlessFontInfo.m \
HeadlessFontEnumerator.m \
HeadlessFaceInfo.m \
HeadlessGState.m
-include GNUmakefile.preamble

View file

@ -19,8 +19,24 @@
#include "config.h"
#include "Headless/HeadlessContext.h"
#include "headless/HeadlessContext.h"
#include "headless/HeadlessFontInfo.h"
#include "headless/HeadlessFontEnumerator.h"
#include "headless/HeadlessGState.h"
@implementation HeadlessContext
@end
+ (void) initializeBackend
{
[NSGraphicsContext setDefaultContextClass: self];
[GSFontEnumerator setDefaultClass: [HeadlessFontEnumerator class]];
[GSFontInfo setDefaultClass: [HeadlessFontInfo class]];
}
+ (Class) GStateClass
{
return [HeadlessGState class];
}
@end

View file

@ -0,0 +1,42 @@
/*
HwadlessFaceInfo.m
Copyright (C) 2003, 2023 Free Software Foundation, Inc.
August 17, 2023
Re-written by Gregory Casamento <greg.casamento@gmail.com>
Based on work Marcian Lytwyn <gnustep@advcsi.com>
August 31, 2003
Originally Written by Banlu Kemiyatorn <object at gmail dot com>
Base on original code of Alex Malmberg
Rewrite: Fred Kiefer <fredkiefer@gmx.de>
Date: Jan 2006
This file is part of GNUstep.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; see the file COPYING.LIB.
If not, see <http://www.gnu.org/licenses/> or write to the
Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "headless/HeadlessFaceInfo.h"
@implementation HeadlessFaceInfo
- (void) dealloc
{
[super dealloc];
}
- (void *)fontFace
{
return _fontFace;
}
@end

View file

@ -0,0 +1,47 @@
/*
HeadlessFontEnumerator.m
Copyright (C) 2003, 2023 Free Software Foundation, Inc.
August 17, 2023
Re-written by Gregory Casamento <greg.casamento@gmail.com>
Based on work by Marcian Lytwyn <gnustep@advcsi.com>
August 31, 2003
Written by Banlu Kemiyatorn <object at gmail dot com>
Base on original code of Alex Malmberg
Rewrite: Fred Kiefer <fredkiefer@gmx.de>
Date: Jan 2006
This file is part of GNUstep.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; see the file COPYING.LIB.
If not, see <http://www.gnu.org/licenses/> or write to the
Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "headless/HeadlessFontEnumerator.h"
#include "headless/HeadlessFontInfo.h"
@implementation HeadlessFontEnumerator
+ (Class) faceInfoClass
{
return [HeadlessFaceInfo class];
}
+ (HeadlessFaceInfo *) fontWithName: (NSString *) name
{
return (HeadlessFaceInfo *) [super fontWithName: name];
}
- (void)enumerateFontsAndFamilies
{
}
@end

View file

@ -0,0 +1,95 @@
/*
HeadlessFontInfo.m
Copyright (C) 2003, 2023 Free Software Foundation, Inc.
August 17, 2023
Re-wrtten by Gregory Casamento <greg.casamento@gmail.com>
Based on work by Marcian Lytwyn <gnustep@advcsi.com>
August 31, 2003
Written by Banlu Kemiyatorn <object at gmail dot com>
Base on original code of Alex Malmberg
This file is part of GNUstep.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; see the file COPYING.LIB.
If not, see <http://www.gnu.org/licenses/> or write to the
Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "GNUstepBase/Unicode.h"
#include <AppKit/NSAffineTransform.h>
#include <AppKit/NSBezierPath.h>
#include "headless/HeadlessFontInfo.h"
#include "headless/HeadlessFontEnumerator.h"
#include <math.h>
@implementation HeadlessFontInfo
- (BOOL) setupAttributes
{
return YES;
}
- (id) initWithFontName: (NSString *)name
matrix: (const CGFloat *)fmatrix
screenFont: (BOOL)p_screenFont
{
self = [super init];
if (!self)
return nil;
fontName = [name copy];
memcpy(matrix, fmatrix, sizeof(matrix));
if (![self setupAttributes])
{
RELEASE(self);
return nil;
}
return self;
}
- (void) dealloc
{
[super dealloc];
}
- (BOOL) glyphIsEncoded: (NSGlyph)glyph
{
if ((glyph >= 0xFB00) && (glyph <= 0xFB05))
return NO;
else
return YES;
}
- (NSSize) advancementForGlyph: (NSGlyph)glyph
{
return NSZeroSize;
}
- (NSRect) boundingRectForGlyph: (NSGlyph)glyph
{
return NSZeroRect;
}
- (CGFloat) widthOfString: (NSString *)string
{
return 0.0;
}
- (void) appendBezierPathWithGlyphs: (NSGlyph *)glyphs
count: (int)length
toBezierPath: (NSBezierPath *)path
{
}
@end

View file

@ -0,0 +1,72 @@
/*
HeadlessGState.m
Copyright (C) 2003, 2023 Free Software Foundation, Inc.
August 17, 2023
Re-wrtten by Gregory Casamento <greg.casamento@gmail.com>
Based on work by Marcian Lytwyn <gnustep@advcsi.com>
August 31, 2003
Written by Banlu Kemiyatorn <object at gmail dot com>
Rewrite: Fred Kiefer <fredkiefer@gmx.de>
Date: Jan 2006
This file is part of GNUstep.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; see the file COPYING.LIB.
If not, see <http://www.gnu.org/licenses/> or write to the
Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "headless/HeadlessGState.h"
@implementation HeadlessGState
- (void) DPSclip
{
}
- (void) DPSfill
{
}
- (void) DPSsetlinewidth: (CGFloat)width
{
}
- (void) DPSsetdash: (const CGFloat *)pat : (NSInteger)size : (CGFloat)foffset
{
}
- (void) DPSimage: (NSAffineTransform *)matrix : (NSInteger)pixelsWide
: (NSInteger)pixelsHigh : (NSInteger)bitsPerSample
: (NSInteger)samplesPerPixel : (NSInteger)bitsPerPixel
: (NSInteger)bytesPerRow : (BOOL)isPlanar
: (BOOL)hasAlpha : (NSString *)colorSpaceName
: (const unsigned char *const[5])data
{
}
- (void) DPSstroke
{
}
- (void) compositerect: (NSRect)aRect op: (NSCompositingOperation)op
{
}
- (void) compositeGState: (HeadlessGState *)source
fromRect: (NSRect)srcRect
toPoint: (NSPoint)destPoint
op: (NSCompositingOperation)op
fraction: (CGFloat)delta
{
}
@end

View file

@ -1,7 +1,12 @@
/* HeadlessServer.m - Headless Server
*
* Copyright (c) 2023 Keysight Technologies
*
* Copyright (C) 1998,2002,2023 Free Software Foundation, Inc.
*
* Re-written by: Gregory John Casamento <greg.casamento@gmail.com>
* Based on work by: Marcian Lytwyn <gnustep@advcsi.com> for Keysight
* Based on work Written by: Adam Fedor <fedor@gnu.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
@ -19,8 +24,91 @@
#include "config.h"
#include "Headless/HeadlessServer.h"
#include <AppKit/NSApplication.h>
#include <Foundation/NSDebug.h>
#include <Foundation/NSValue.h>
#include "headless/HeadlessServer.h"
/* Terminate cleanly if we get a signal to do so */
static void
terminate(int sig)
{
if (nil != NSApp)
{
[NSApp terminate: NSApp];
}
else
{
exit(1);
}
}
@implementation HeadlessServer
/* Initialize AppKit backend */
+ (void) initializeBackend
{
NSDebugLog(@"Initializing GNUstep headless backend.\n");
[GSDisplayServer setDefaultServerClass: [HeadlessServer class]];
signal(SIGTERM, terminate);
signal(SIGINT, terminate);
}
- (NSArray *)screenList
{
NSDebugLog(@"GNUstep headless - fetching screen list");
NSMutableArray *screens = [NSMutableArray arrayWithCapacity: 1];
[screens addObject: [NSNumber numberWithInt: 1]];
return screens;
}
- (NSRect) boundsForScreen: (int)screen
{
return NSMakeRect(0, 0, 400, 400);
}
- (NSWindowDepth) windowDepthForScreen: (int) screen_num
{
return 0;
}
- (void) styleoffsets: (float *) l : (float *) r : (float *) t : (float *) b
: (unsigned int) style
{
}
- (void) standardcursor: (int)style : (void **)cid
{
}
- (int) window: (NSRect)frame
: (NSBackingStoreType)type
: (unsigned int)style
: (int)screen
{
return 1;
}
- (void) setwindowlevel: (int)level : (int)win
{
}
- (void) setWindowdevice: (int)win forContext: (NSGraphicsContext *)ctxt
{
}
- (void) orderwindow: (int)op : (int)otherWin : (int)winNum
{
}
- (void) setinputfocus: (int)win
{
}
- (void) imagecursor: (NSPoint)hotp : (NSImage *)image : (void **)cid
{
}
@end