From a52667ee9c7f0ac1ce04b62f8a2745e90944da53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Thu, 14 Apr 2005 00:22:01 +0000 Subject: [PATCH] added a comment about how it would be nice if ServerFont could be guaranteed to be valid (ie it doesn't crash if you call one of it's functions from outside code, I like it when a C++ class is an encapsulated object, maintaining a valid internal state, and whatever client code does, it should just never crash) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12390 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/servers/app/ServerFont.h | 6 ++++++ src/servers/app/ServerFont.cpp | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/headers/private/servers/app/ServerFont.h b/headers/private/servers/app/ServerFont.h index 20480a3ad2..689cd28974 100644 --- a/headers/private/servers/app/ServerFont.h +++ b/headers/private/servers/app/ServerFont.h @@ -39,6 +39,12 @@ public: uint16 flags=0, uint8 spacing=B_CHAR_SPACING); ServerFont(const ServerFont &font); ~ServerFont(void); + + // TODO: make more advanced... + status_t InitCheck() const + { return fStyle ? B_OK : B_NO_INIT; } + + font_direction Direction(void) const { return fDirection; } uint32 Encoding(void) const { return fEncoding; } edge_info Edges(void) const { return fEdges; } diff --git a/src/servers/app/ServerFont.cpp b/src/servers/app/ServerFont.cpp index 9a3115280d..5e2ba1d15a 100644 --- a/src/servers/app/ServerFont.cpp +++ b/src/servers/app/ServerFont.cpp @@ -57,6 +57,10 @@ ServerFont::ServerFont(FontStyle *style, float size, float rotation, float shear fStyle->AddDependent(); } +// TODO: fStyle should not be NULL. There should be another FontStyle +// constructor, that initializes without actually interfacing with +// freetype, so that a ServerFont can be guaranteed to be "valid". + ServerFont::ServerFont(void) { fStyle=NULL;