* 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
This commit is contained in:
Axel Dörfler
2005-11-01 18:21:04 +00:00
parent f3aa24ede7
commit 6f121769ad
4 changed files with 63 additions and 33 deletions
+1
View File
@@ -123,6 +123,7 @@ enum {
AS_GET_TUNED_COUNT, AS_GET_TUNED_COUNT,
AS_GET_TUNED_INFO, AS_GET_TUNED_INFO,
AS_GET_FONT_HEIGHT, AS_GET_FONT_HEIGHT,
AS_GET_FONT_FILE_FORMAT,
AS_QUERY_FONT_FIXED, AS_QUERY_FONT_FIXED,
AS_SET_FAMILY_AND_STYLE, AS_SET_FAMILY_AND_STYLE,
+13 -26
View File
@@ -1,41 +1,26 @@
//------------------------------------------------------------------------------ /*
// Copyright (c) 2001-2002, Haiku, Inc. * Copyright 2001-2005, Haiku.
// * Distributed under the terms of the MIT License.
// Permission is hereby granted, free of charge, to any person obtaining a *
// copy of this software and associated documentation files (the "Software"), * Authors:
// to deal in the Software without restriction, including without limitation * DarkWyrm <[email protected]>
// the rights to use, copy, modify, merge, publish, distribute, sublicense, * Axel Dörfler, [email protected]
// 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 <[email protected]>
// Description: classes to represent font styles and families
//
//------------------------------------------------------------------------------
#ifndef FONT_FAMILY_H_ #ifndef FONT_FAMILY_H_
#define FONT_FAMILY_H_ #define FONT_FAMILY_H_
#include <String.h> #include <String.h>
#include <Rect.h> #include <Rect.h>
#include <Font.h> #include <Font.h>
#include <ObjectList.h> #include <ObjectList.h>
#include <Locker.h> #include <Locker.h>
#include <ft2build.h> #include <ft2build.h>
#include FT_FREETYPE_H #include FT_FREETYPE_H
#include "SharedObject.h" #include "SharedObject.h"
class FontFamily; class FontFamily;
class ServerFont; class ServerFont;
@@ -152,6 +137,8 @@ class FontStyle : public SharedObject, public BLocker {
font_height GetHeight(const float& size) const; font_height GetHeight(const float& size) const;
font_direction Direction() const font_direction Direction() const
{ return B_FONT_LEFT_TO_RIGHT; } { return B_FONT_LEFT_TO_RIGHT; }
font_file_format FileFormat() const
{ return B_TRUETYPE_WINDOWS; }
FT_Face GetFTFace() const FT_Face GetFTFace() const
{ return fFTFace; } { return fFTFace; }
+19 -5
View File
@@ -246,7 +246,7 @@ get_font_style(font_family family, int32 index, font_style *_name,
link.AttachString(family); link.AttachString(family);
link.Attach<int32>(index); link.Attach<int32>(index);
int32 status; int32 status = B_ERROR;
if (link.FlushWithReply(status) != B_OK if (link.FlushWithReply(status) != B_OK
|| status != B_OK) || status != B_OK)
return status; return status;
@@ -382,7 +382,7 @@ BFont::SetFamilyAndStyle(const font_family family, const font_style style)
link.Attach<uint16>(0xffff); link.Attach<uint16>(0xffff);
link.Attach<uint16>(fFace); link.Attach<uint16>(fFace);
int32 status; int32 status = B_ERROR;
if (link.FlushWithReply(status) != B_OK if (link.FlushWithReply(status) != B_OK
|| status != B_OK) || status != B_OK)
return status; return status;
@@ -455,7 +455,7 @@ BFont::SetFamilyAndFace(const font_family family, uint16 face)
link.Attach<uint16>(0xffff); link.Attach<uint16>(0xffff);
link.Attach<uint16>(face); link.Attach<uint16>(face);
int32 status; int32 status = B_ERROR;
if (link.FlushWithReply(status) != B_OK if (link.FlushWithReply(status) != B_OK
|| status != B_OK) || status != B_OK)
return status; return status;
@@ -697,8 +697,22 @@ BFont::Blocks(void) const
font_file_format font_file_format
BFont::FileFormat(void) const BFont::FileFormat(void) const
{ {
// TODO: this will not work until I extend FreeType to handle this kind of call BPrivate::AppServerLink link;
return B_TRUETYPE_WINDOWS; link.StartMessage(AS_GET_FONT_FILE_FORMAT);
link.Attach<uint16>(fFamilyID);
link.Attach<uint16>(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<uint16>(&format);
return (font_file_format)format;
} }
+30 -2
View File
@@ -1252,8 +1252,7 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
} }
case AS_GET_FONT_DIRECTION: case AS_GET_FONT_DIRECTION:
{ {
FTRACE(("ServerApp %s: AS_GET_FONT_DIRECTION unimplemented\n", FTRACE(("ServerApp %s: AS_GET_FONT_DIRECTION\n", Signature()));
Signature()));
// Attached Data: // Attached Data:
// 1) uint16 - family ID // 1) uint16 - family ID
// 2) uint16 - style ID // 2) uint16 - style ID
@@ -1280,6 +1279,35 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
fLink.Flush(); fLink.Flush();
break; 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<int32>(&familyID);
link.Read<int32>(&styleID);
gFontServer->Lock();
FontStyle *fontStyle = gFontServer->GetStyle(familyID, styleID);
if (fontStyle) {
font_direction direction = fontStyle->Direction();
fLink.StartMessage(B_OK);
fLink.Attach<uint16>((uint16)fontStyle->FileFormat());
} else
fLink.StartMessage(B_BAD_VALUE);
gFontServer->Unlock();
fLink.Flush();
break;
}
case AS_GET_STRING_WIDTHS: case AS_GET_STRING_WIDTHS:
{ {
FTRACE(("ServerApp %s: AS_GET_STRING_WIDTHS\n", Signature())); FTRACE(("ServerApp %s: AS_GET_STRING_WIDTHS\n", Signature()));