Minor cleanup.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24159 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2008-02-28 00:12:06 +00:00
parent 07d1827688
commit e705558bb9
+61 -50
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2001-2006, Haiku, Inc. * Copyright 2001-2008, Haiku, Inc.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -223,7 +223,8 @@ FontList::_FindFamily(font_family name)
::family family; ::family family;
family.name = name; family.name = name;
fLastFamily = const_cast< ::family*>(fFamilies.BinarySearch(family, compare_families)); fLastFamily = const_cast< ::family*>(fFamilies.BinarySearch(family,
compare_families));
return fLastFamily; return fLastFamily;
} }
@@ -408,7 +409,6 @@ _get_system_default_font_(const char* which, font_family family,
\brief Returns the number of installed font families \brief Returns the number of installed font families
\return The number of installed font families \return The number of installed font families
*/ */
int32 int32
count_font_families() count_font_families()
{ {
@@ -420,7 +420,6 @@ count_font_families()
\brief Returns the number of styles available for a font family \brief Returns the number of styles available for a font family
\return The number of styles available for a font family \return The number of styles available for a font family
*/ */
int32 int32
count_font_styles(font_family family) count_font_styles(font_family family)
{ {
@@ -432,10 +431,10 @@ count_font_styles(font_family family)
\brief Retrieves the family name at the specified index \brief Retrieves the family name at the specified index
\param index Unique font identifier code. \param index Unique font identifier code.
\param name font_family string to receive the name of the family \param name font_family string to receive the name of the family
\param flags if non-NULL, the values of the flags IS_FIXED and B_HAS_TUNED_FONT are returned \param flags if non-NULL, the values of the flags IS_FIXED and
B_HAS_TUNED_FONT are returned
\return B_ERROR if the index does not correspond to a font family \return B_ERROR if the index does not correspond to a font family
*/ */
status_t status_t
get_font_family(int32 index, font_family *_name, uint32 *_flags) get_font_family(int32 index, font_family *_name, uint32 *_flags)
{ {
@@ -450,10 +449,10 @@ get_font_family(int32 index, font_family *_name, uint32 *_flags)
\brief Retrieves the family name at the specified index \brief Retrieves the family name at the specified index
\param index Unique font identifier code. \param index Unique font identifier code.
\param name font_family string to receive the name of the family \param name font_family string to receive the name of the family
\param flags if non-NULL, the values of the flags IS_FIXED and B_HAS_TUNED_FONT are returned \param flags if non-NULL, the values of the flags IS_FIXED and
B_HAS_TUNED_FONT are returned
\return B_ERROR if the index does not correspond to a font style \return B_ERROR if the index does not correspond to a font style
*/ */
status_t status_t
get_font_style(font_family family, int32 index, font_style *_name, get_font_style(font_family family, int32 index, font_style *_name,
uint32 *_flags) uint32 *_flags)
@@ -467,13 +466,14 @@ get_font_style(font_family family, int32 index, font_style *_name,
\param index Unique font identifier code. \param index Unique font identifier code.
\param name font_family string to receive the name of the family \param name font_family string to receive the name of the family
\param face recipient of font face value, such as B_REGULAR_FACE \param face recipient of font face value, such as B_REGULAR_FACE
\param flags if non-NULL, the values of the flags IS_FIXED and B_HAS_TUNED_FONT are returned \param flags if non-NULL, the values of the flags IS_FIXED and
B_HAS_TUNED_FONT are returned
\return B_ERROR if the index does not correspond to a font style \return B_ERROR if the index does not correspond to a font style
The face value returned by this function is not very reliable. At the same time, the value The face value returned by this function is not very reliable. At the same
returned should be fairly reliable, returning the proper flag for 90%-99% of font names. time, the value returned should be fairly reliable, returning the proper
flag for 90%-99% of font names.
*/ */
status_t status_t
get_font_style(font_family family, int32 index, font_style *_name, get_font_style(font_family family, int32 index, font_style *_name,
uint16 *_face, uint32 *_flags) uint16 *_face, uint32 *_flags)
@@ -490,7 +490,6 @@ get_font_style(font_family family, int32 index, font_style *_name,
\param checkOnly is ignored \param checkOnly is ignored
\return true if the font list has changed, false if not. \return true if the font list has changed, false if not.
*/ */
bool bool
update_font_families(bool /*checkOnly*/) update_font_families(bool /*checkOnly*/)
{ {
@@ -547,7 +546,6 @@ BFont::BFont(const BFont *font)
\param style Font style to set \param style Font style to set
\return B_NAME_NOT_FOUND if family or style do not exist. \return B_NAME_NOT_FOUND if family or style do not exist.
*/ */
status_t status_t
BFont::SetFamilyAndStyle(const font_family family, const font_style style) BFont::SetFamilyAndStyle(const font_family family, const font_style style)
{ {
@@ -582,7 +580,6 @@ BFont::SetFamilyAndStyle(const font_family family, const font_style style)
\brief Sets the font's family and style all at once \brief Sets the font's family and style all at once
\param code Unique font identifier obtained from the server. \param code Unique font identifier obtained from the server.
*/ */
void void
BFont::SetFamilyAndStyle(uint32 fontcode) BFont::SetFamilyAndStyle(uint32 fontcode)
{ {
@@ -628,7 +625,6 @@ BFont::SetFamilyAndStyle(uint32 fontcode)
Additionally, if a particular face does not exist in a family, the closest Additionally, if a particular face does not exist in a family, the closest
match will be chosen. match will be chosen.
*/ */
status_t status_t
BFont::SetFamilyAndFace(const font_family family, uint16 face) BFont::SetFamilyAndFace(const font_family family, uint16 face)
{ {
@@ -838,7 +834,6 @@ BFont::IsFixed() const
This was left unimplemented as of R5. It was a way to work with both This was left unimplemented as of R5. It was a way to work with both
Kanji and Roman characters in the same fixed-width font. Kanji and Roman characters in the same fixed-width font.
*/ */
bool bool
BFont::IsFullAndHalfFixed() const BFont::IsFullAndHalfFixed() const
{ {
@@ -987,8 +982,7 @@ BFont::GetTruncatedStrings(const char *stringArray[], int32 numStrings,
GetEscapements(stringArray[i], numChars, NULL, escapementArray); GetEscapements(stringArray[i], numChars, NULL, escapementArray);
truncate_string(stringArray[i], mode, width, resultArray[i], truncate_string(stringArray[i], mode, width, resultArray[i],
escapementArray, fSize, ellipsisWidth, length, escapementArray, fSize, ellipsisWidth, length, numChars);
numChars);
delete[] escapementArray; delete[] escapementArray;
} }
@@ -1039,7 +1033,8 @@ BFont::GetStringWidths(const char *stringArray[], const int32 lengthArray[],
link.Attach<int32>(numStrings); link.Attach<int32>(numStrings);
// TODO: all strings into a single array??? // TODO: all strings into a single array???
// we do have a maximum message length, and it could be easily touched here... // we do have a maximum message length, and it could be easily touched
// here...
for (int32 i = 0; i < numStrings; i++) { for (int32 i = 0; i < numStrings; i++) {
link.AttachString(stringArray[i], lengthArray[i]); link.AttachString(stringArray[i], lengthArray[i]);
} }
@@ -1054,15 +1049,16 @@ BFont::GetStringWidths(const char *stringArray[], const int32 lengthArray[],
void void
BFont::GetEscapements(const char charArray[], int32 numChars, float escapementArray[]) const BFont::GetEscapements(const char charArray[], int32 numChars,
float escapementArray[]) const
{ {
GetEscapements(charArray, numChars, NULL, escapementArray); GetEscapements(charArray, numChars, NULL, escapementArray);
} }
void void
BFont::GetEscapements(const char charArray[], int32 numChars, escapement_delta *delta, BFont::GetEscapements(const char charArray[], int32 numChars,
float escapementArray[]) const escapement_delta *delta, float escapementArray[]) const
{ {
if (!charArray || numChars < 1 || !escapementArray) if (!charArray || numChars < 1 || !escapementArray)
return; return;
@@ -1095,16 +1091,17 @@ BFont::GetEscapements(const char charArray[], int32 numChars, escapement_delta *
void void
BFont::GetEscapements(const char charArray[], int32 numChars, escapement_delta *delta, BFont::GetEscapements(const char charArray[], int32 numChars,
BPoint escapementArray[]) const escapement_delta *delta, BPoint escapementArray[]) const
{ {
GetEscapements(charArray, numChars, delta, escapementArray, NULL); GetEscapements(charArray, numChars, delta, escapementArray, NULL);
} }
void void
BFont::GetEscapements(const char charArray[], int32 numChars, escapement_delta *delta, BFont::GetEscapements(const char charArray[], int32 numChars,
BPoint escapementArray[], BPoint offsetArray[]) const escapement_delta *delta, BPoint escapementArray[],
BPoint offsetArray[]) const
{ {
if (!charArray || numChars < 1 || !escapementArray) if (!charArray || numChars < 1 || !escapementArray)
return; return;
@@ -1140,7 +1137,8 @@ BFont::GetEscapements(const char charArray[], int32 numChars, escapement_delta *
void void
BFont::GetEdges(const char charArray[], int32 numChars, edge_info edgeArray[]) const BFont::GetEdges(const char charArray[], int32 numChars,
edge_info edgeArray[]) const
{ {
if (!charArray || numChars < 1 || !edgeArray) if (!charArray || numChars < 1 || !edgeArray)
return; return;
@@ -1186,7 +1184,8 @@ BFont::GetHeight(font_height *_height) const
return; return;
// Who put that "const" to this method? :-) // Who put that "const" to this method? :-)
// We made fHeight mutable for this, but we should drop the "const" when we can // We made fHeight mutable for this, but we should drop the "const"
// when we can
link.Read<font_height>(&fHeight); link.Read<font_height>(&fHeight);
} }
@@ -1195,24 +1194,28 @@ BFont::GetHeight(font_height *_height) const
void void
BFont::GetBoundingBoxesAsGlyphs(const char charArray[], int32 numChars, font_metric_mode mode, BFont::GetBoundingBoxesAsGlyphs(const char charArray[], int32 numChars,
font_metric_mode mode, BRect boundingBoxArray[]) const
{
_GetBoundingBoxes(charArray, numChars, mode, false, NULL, boundingBoxArray,
false);
}
void
BFont::GetBoundingBoxesAsString(const char charArray[], int32 numChars,
font_metric_mode mode, escapement_delta *delta,
BRect boundingBoxArray[]) const BRect boundingBoxArray[]) const
{ {
_GetBoundingBoxes(charArray, numChars, mode, false, NULL, boundingBoxArray, false); _GetBoundingBoxes(charArray, numChars, mode, true, delta, boundingBoxArray,
true);
} }
void void
BFont::GetBoundingBoxesAsString(const char charArray[], int32 numChars, font_metric_mode mode, BFont::_GetBoundingBoxes(const char charArray[], int32 numChars,
escapement_delta *delta, BRect boundingBoxArray[]) const font_metric_mode mode, bool string_escapement, escapement_delta *delta,
{ BRect boundingBoxArray[], bool asString) const
_GetBoundingBoxes(charArray, numChars, mode, true, delta, boundingBoxArray, true);
}
void
BFont::_GetBoundingBoxes(const char charArray[], int32 numChars, font_metric_mode mode,
bool string_escapement, escapement_delta *delta, BRect boundingBoxArray[], bool asString) const
{ {
if (!charArray || numChars < 1 || !boundingBoxArray) if (!charArray || numChars < 1 || !boundingBoxArray)
return; return;
@@ -1220,7 +1223,8 @@ BFont::_GetBoundingBoxes(const char charArray[], int32 numChars, font_metric_mod
int32 code; int32 code;
BPrivate::AppServerLink link; BPrivate::AppServerLink link;
link.StartMessage(asString ? AS_GET_BOUNDINGBOXES_STRING : AS_GET_BOUNDINGBOXES_CHARS); link.StartMessage(asString
? AS_GET_BOUNDINGBOXES_STRING : AS_GET_BOUNDINGBOXES_CHARS);
link.Attach<uint16>(fFamilyID); link.Attach<uint16>(fFamilyID);
link.Attach<uint16>(fStyleID); link.Attach<uint16>(fStyleID);
link.Attach<float>(fSize); link.Attach<float>(fSize);
@@ -1255,7 +1259,8 @@ BFont::_GetBoundingBoxes(const char charArray[], int32 numChars, font_metric_mod
void void
BFont::GetBoundingBoxesForStrings(const char *stringArray[], int32 numStrings, BFont::GetBoundingBoxesForStrings(const char *stringArray[], int32 numStrings,
font_metric_mode mode, escapement_delta deltas[], BRect boundingBoxArray[]) const font_metric_mode mode, escapement_delta deltas[],
BRect boundingBoxArray[]) const
{ {
if (!stringArray || numStrings < 1 || !boundingBoxArray) if (!stringArray || numStrings < 1 || !boundingBoxArray)
return; return;
@@ -1298,9 +1303,11 @@ BFont::GetBoundingBoxesForStrings(const char *stringArray[], int32 numStrings,
void void
BFont::GetGlyphShapes(const char charArray[], int32 numChars, BShape *glyphShapeArray[]) const BFont::GetGlyphShapes(const char charArray[], int32 numChars,
BShape *glyphShapeArray[]) const
{ {
// TODO: implement code specifically for passing BShapes to and from the server // TODO: implement code specifically for passing BShapes to and
// from the server
if (!charArray || numChars < 1 || !glyphShapeArray) if (!charArray || numChars < 1 || !glyphShapeArray)
return; return;
@@ -1331,7 +1338,8 @@ BFont::GetGlyphShapes(const char charArray[], int32 numChars, BShape *glyphShape
void void
BFont::GetHasGlyphs(const char charArray[], int32 numChars, bool hasArray[]) const BFont::GetHasGlyphs(const char charArray[], int32 numChars,
bool hasArray[]) const
{ {
if (!charArray || numChars < 1 || !hasArray) if (!charArray || numChars < 1 || !hasArray)
return; return;
@@ -1413,8 +1421,8 @@ BFont::PrintToStream() const
font_style style; font_style style;
GetFamilyAndStyle(&family, &style); GetFamilyAndStyle(&family, &style);
printf("BFont { %s (%d), %s (%d) 0x%x %f/%f %fpt (%f %f %f), %d }\n", family, printf("BFont { %s (%d), %s (%d) 0x%x %f/%f %fpt (%f %f %f), %d }\n",
fFamilyID, style, fStyleID, fFace, fShear, fRotation, fSize, family, fFamilyID, style, fStyleID, fFace, fShear, fRotation, fSize,
fHeight.ascent, fHeight.descent, fHeight.leading, fEncoding); fHeight.ascent, fHeight.descent, fHeight.leading, fEncoding);
} }
@@ -1422,7 +1430,8 @@ BFont::PrintToStream() const
void void
BFont::_GetExtraFlags() const BFont::_GetExtraFlags() const
{ {
// TODO: this has to be const in order to allow other font getters to stay const as well // TODO: this has to be const in order to allow other font getters to
// stay const as well
if (fExtraFlags != kUninitializedExtraFlags) if (fExtraFlags != kUninitializedExtraFlags)
return; return;
@@ -1435,9 +1444,11 @@ BFont::_GetExtraFlags() const
if (link.FlushWithReply(status) != B_OK if (link.FlushWithReply(status) != B_OK
|| status != B_OK) { || status != B_OK) {
// use defaut values for the flags // use defaut values for the flags
fExtraFlags = (uint32)B_FONT_LEFT_TO_RIGHT << B_PRIVATE_FONT_DIRECTION_SHIFT; fExtraFlags = (uint32)B_FONT_LEFT_TO_RIGHT
<< B_PRIVATE_FONT_DIRECTION_SHIFT;
return; return;
} }
link.Read<uint32>(&fExtraFlags); link.Read<uint32>(&fExtraFlags);
} }