From 6f121769adf06a153c16e156989ea940a4d8f44d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 1 Nov 2005 18:21:04 +0000 Subject: [PATCH] * Added and implemented AS_GET_FONT_FILE_FORMAT - currently, it returns always B_TRUETYPE_WINDOWS, though. * possibly returned an uninitialized error code in some BFont methods. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14622 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/app/ServerProtocol.h | 1 + headers/private/servers/app/FontFamily.h | 39 ++++++++---------------- src/kits/interface/Font.cpp | 24 ++++++++++++--- src/servers/app/ServerApp.cpp | 32 +++++++++++++++++-- 4 files changed, 63 insertions(+), 33 deletions(-) diff --git a/headers/private/app/ServerProtocol.h b/headers/private/app/ServerProtocol.h index e2fbe663de..db73c7e52b 100644 --- a/headers/private/app/ServerProtocol.h +++ b/headers/private/app/ServerProtocol.h @@ -123,6 +123,7 @@ enum { AS_GET_TUNED_COUNT, AS_GET_TUNED_INFO, AS_GET_FONT_HEIGHT, + AS_GET_FONT_FILE_FORMAT, AS_QUERY_FONT_FIXED, AS_SET_FAMILY_AND_STYLE, diff --git a/headers/private/servers/app/FontFamily.h b/headers/private/servers/app/FontFamily.h index 5f0e1609ea..455867d86b 100644 --- a/headers/private/servers/app/FontFamily.h +++ b/headers/private/servers/app/FontFamily.h @@ -1,41 +1,26 @@ -//------------------------------------------------------------------------------ -// Copyright (c) 2001-2002, Haiku, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. -// -// File Name: FontFamily.h -// Author: DarkWyrm -// Description: classes to represent font styles and families -// -//------------------------------------------------------------------------------ +/* + * Copyright 2001-2005, Haiku. + * Distributed under the terms of the MIT License. + * + * Authors: + * DarkWyrm + * Axel Dörfler, axeld@pinc-software.de + */ #ifndef FONT_FAMILY_H_ #define FONT_FAMILY_H_ + #include #include #include #include #include + #include #include FT_FREETYPE_H #include "SharedObject.h" + class FontFamily; class ServerFont; @@ -152,6 +137,8 @@ class FontStyle : public SharedObject, public BLocker { font_height GetHeight(const float& size) const; font_direction Direction() const { return B_FONT_LEFT_TO_RIGHT; } + font_file_format FileFormat() const + { return B_TRUETYPE_WINDOWS; } FT_Face GetFTFace() const { return fFTFace; } diff --git a/src/kits/interface/Font.cpp b/src/kits/interface/Font.cpp index bb1ae0cd67..d33031b14d 100644 --- a/src/kits/interface/Font.cpp +++ b/src/kits/interface/Font.cpp @@ -246,7 +246,7 @@ get_font_style(font_family family, int32 index, font_style *_name, link.AttachString(family); link.Attach(index); - int32 status; + int32 status = B_ERROR; if (link.FlushWithReply(status) != B_OK || status != B_OK) return status; @@ -382,7 +382,7 @@ BFont::SetFamilyAndStyle(const font_family family, const font_style style) link.Attach(0xffff); link.Attach(fFace); - int32 status; + int32 status = B_ERROR; if (link.FlushWithReply(status) != B_OK || status != B_OK) return status; @@ -455,7 +455,7 @@ BFont::SetFamilyAndFace(const font_family family, uint16 face) link.Attach(0xffff); link.Attach(face); - int32 status; + int32 status = B_ERROR; if (link.FlushWithReply(status) != B_OK || status != B_OK) return status; @@ -697,8 +697,22 @@ BFont::Blocks(void) const font_file_format BFont::FileFormat(void) const { - // TODO: this will not work until I extend FreeType to handle this kind of call - return B_TRUETYPE_WINDOWS; + BPrivate::AppServerLink link; + link.StartMessage(AS_GET_FONT_FILE_FORMAT); + link.Attach(fFamilyID); + link.Attach(fStyleID); + + int32 status; + if (link.FlushWithReply(status) != B_OK + || status != B_OK) { + // just take a safe bet... + return B_TRUETYPE_WINDOWS; + } + + uint16 format; + link.Read(&format); + + return (font_file_format)format; } diff --git a/src/servers/app/ServerApp.cpp b/src/servers/app/ServerApp.cpp index f46bb2fe62..9e9ece49d2 100644 --- a/src/servers/app/ServerApp.cpp +++ b/src/servers/app/ServerApp.cpp @@ -1252,8 +1252,7 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link) } case AS_GET_FONT_DIRECTION: { - FTRACE(("ServerApp %s: AS_GET_FONT_DIRECTION unimplemented\n", - Signature())); + FTRACE(("ServerApp %s: AS_GET_FONT_DIRECTION\n", Signature())); // Attached Data: // 1) uint16 - family ID // 2) uint16 - style ID @@ -1280,6 +1279,35 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link) fLink.Flush(); break; } + case AS_GET_FONT_FILE_FORMAT: + { + FTRACE(("ServerApp %s: AS_GET_FONT_FILE_FORMAT\n", Signature())); + // Attached Data: + // 1) uint16 - family ID + // 2) uint16 - style ID + + // Returns: + // 1) uint16 font_file_format of font + + int32 familyID, styleID; + link.Read(&familyID); + link.Read(&styleID); + + gFontServer->Lock(); + + FontStyle *fontStyle = gFontServer->GetStyle(familyID, styleID); + if (fontStyle) { + font_direction direction = fontStyle->Direction(); + + fLink.StartMessage(B_OK); + fLink.Attach((uint16)fontStyle->FileFormat()); + } else + fLink.StartMessage(B_BAD_VALUE); + + gFontServer->Unlock(); + fLink.Flush(); + break; + } case AS_GET_STRING_WIDTHS: { FTRACE(("ServerApp %s: AS_GET_STRING_WIDTHS\n", Signature()));