hrev45181 adds 12 changesets to branch 'master' old head: 058f84c3e160eefe9c084ae1a343eeba7afd2b5f new head: 6a4b222bc9666e27518ce30b0fcaf75818fdd580 overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=6a4b222+%5E058f84c ---------------------------------------------------------------------------- 1f7ff05: Style updates and remove docs from cpp file 566e828: Add initial BFont documentation c969b46: Put comments in methods, only description line outside 840476e: Rename SetFamilyAndStyle variable to code matching the header and BeBook. c258d2f: Fill out BFont member docs a8f3c5a: Style fixes only 9c840df: Woops, I meant == not = 05757eb: Fill out BFont detailed description. Also a bunch of cleanup including removing private method docs and cleaning up language. BFont is pretty much completely documented at this point. 0d2b04c: Minor update use fixed font for B_OK 27c3eae: Another minor fix, style constant 4f7717a: By removing the style on escapement_delta doxygen links it up which is better 6a4b222: Use condensed, not squished together. Better [ John Scipione <jscipione@xxxxxxxxx> ] ---------------------------------------------------------------------------- 2 files changed, 1485 insertions(+), 131 deletions(-) docs/user/interface/Font.dox | 1423 ++++++++++++++++++++++++++++++++++++++ src/kits/interface/Font.cpp | 193 ++---- ############################################################################ Commit: 1f7ff051a783362f02d3a8bf5f3b8b845fda7d98 URL: http://cgit.haiku-os.org/haiku/commit/?id=1f7ff05 Author: John Scipione <jscipione@xxxxxxxxx> Date: Sat Jan 19 01:09:48 2013 UTC Style updates and remove docs from cpp file ---------------------------------------------------------------------------- diff --git a/src/kits/interface/Font.cpp b/src/kits/interface/Font.cpp index 5e66b8a..21e81b8 100644 --- a/src/kits/interface/Font.cpp +++ b/src/kits/interface/Font.cpp @@ -384,16 +384,9 @@ status_t set_font_cache_info(uint32 id, void *set) } -/*! - \brief Private function used to replace the R5 hack which sets a system font - \param which string denoting which font to set - \param family the new family for the system font - \param style the new style for the system font - \param size the size for the system font to have - - R5 used a global area offset table to set the system fonts in the Font - preferences panel. Bleah. -*/ +// Private function used to replace the R5 hack which sets a system font +// R5 used a global area offset table to set the system fonts in the Font +// preferences panel. Bleah. void _set_system_font_(const char *which, font_family family, font_style style, float size) @@ -430,10 +423,7 @@ _get_system_default_font_(const char* which, font_family family, } -/*! - \brief Returns the number of installed font families - \return The number of installed font families -*/ +// Returns the number of installed font families int32 count_font_families() { @@ -441,10 +431,7 @@ count_font_families() } -/*! - \brief Returns the number of styles available for a font family - \return The number of styles available for a font family -*/ +// Returns the number of styles available for a font family int32 count_font_styles(font_family family) { @@ -452,14 +439,7 @@ count_font_styles(font_family family) } -/*! - \brief Retrieves the family name at the specified index - \param index Unique font identifier code. - \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 - \return B_ERROR if the index does not correspond to a font family -*/ +// Retrieves the family name at the specified index status_t get_font_family(int32 index, font_family *_name, uint32 *_flags) { @@ -470,14 +450,7 @@ get_font_family(int32 index, font_family *_name, uint32 *_flags) } -/*! - \brief Retrieves the family name at the specified index - \param index Unique font identifier code. - \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 - \return B_ERROR if the index does not correspond to a font style -*/ +// Retrieves the family name at the specified index status_t get_font_style(font_family family, int32 index, font_style *_name, uint32 *_flags) @@ -486,19 +459,10 @@ get_font_style(font_family family, int32 index, font_style *_name, } -/*! - \brief Retrieves the family name at the specified index - \param index Unique font identifier code. - \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 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 - - The face value returned by this function is not very reliable. At the same - time, the value returned should be fairly reliable, returning the proper - flag for 90%-99% of font names. -*/ +// Retrieves the family name at the specified index +// The face value returned by this function is not very reliable. At the same +// time, the value returned should be fairly reliable, returning the proper +// flag for 90%-99% of font names. status_t get_font_style(font_family family, int32 index, font_style *_name, uint16 *_face, uint32 *_flags) @@ -510,11 +474,7 @@ get_font_style(font_family family, int32 index, font_style *_name, } -/*! - \brief Updates the font family list - \param checkOnly is ignored - \return true if the font list has changed, false if not. -*/ +// Updates the font family list bool update_font_families(bool /*checkOnly*/) { @@ -558,19 +518,14 @@ BFont::BFont(const BFont &font) BFont::BFont(const BFont *font) { - if (font) + if (font != NULL) *this = *font; else *this = *be_plain_font; } -/*! - \brief Sets the font's family and style all at once - \param family Font family to set - \param style Font style to set - \return B_NAME_NOT_FOUND if family or style do not exist. -*/ +// Sets the font's family and style all at once status_t BFont::SetFamilyAndStyle(const font_family family, const font_style style) { @@ -587,8 +542,7 @@ BFont::SetFamilyAndStyle(const font_family family, const font_style style) link.Attach<uint16>(fFace); int32 status = B_ERROR; - if (link.FlushWithReply(status) != B_OK - || status != B_OK) + if (link.FlushWithReply(status) != B_OK || status != B_OK) return status; link.Read<uint16>(&fFamilyID); @@ -601,10 +555,7 @@ BFont::SetFamilyAndStyle(const font_family family, const font_style style) } -/*! - \brief Sets the font's family and style all at once - \param code Unique font identifier obtained from the server. -*/ +// Sets the font's family and style all at once void BFont::SetFamilyAndStyle(uint32 fontcode) { @@ -627,8 +578,7 @@ BFont::SetFamilyAndStyle(uint32 fontcode) link.Attach<uint16>(fFace); int32 code; - if (link.FlushWithReply(code) != B_OK - || code != B_OK) + if (link.FlushWithReply(code) != B_OK || code != B_OK) return; link.Read<uint16>(&fFamilyID); @@ -639,17 +589,11 @@ BFont::SetFamilyAndStyle(uint32 fontcode) } -/*! - \brief Sets the font's family and face all at once - \param family Font family to set - \param face Font face to set. - \return B_ERROR if family does not exists or face is an invalid value. - - To comply with the BeBook, this function will only set valid values - i.e. - passing a nonexistent family will cause only the face to be set. - Additionally, if a particular face does not exist in a family, the closest - match will be chosen. -*/ +// Sets the font's family and face all at once +// To comply with the BeBook, this function will only set valid values - i.e. +// passing a nonexistent family will cause only the face to be set. +// Additionally, if a particular face does not exist in a family, the closest +// match will be chosen. status_t BFont::SetFamilyAndFace(const font_family family, uint16 face) { @@ -662,8 +606,7 @@ BFont::SetFamilyAndFace(const font_family family, uint16 face) link.Attach<uint16>(face); int32 status = B_ERROR; - if (link.FlushWithReply(status) != B_OK - || status != B_OK) + if (link.FlushWithReply(status) != B_OK || status != B_OK) return status; link.Read<uint16>(&fFamilyID); @@ -760,8 +703,7 @@ BFont::GetFamilyAndStyle(font_family *family, font_style *style) const link.Attach<uint16>(fStyleID); int32 code; - if (link.FlushWithReply(code) != B_OK - || code != B_OK) { + if (link.FlushWithReply(code) != B_OK || code != B_OK) { // the least we can do is to clear the buffers memset(*family, 0, sizeof(font_family)); memset(*style, 0, sizeof(font_style)); @@ -852,13 +794,10 @@ BFont::IsFixed() const } -/*! - \brief Returns true if the font is fixed-width and contains both full - and half-width characters - - 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. -*/ +// Returns whether or not the font is fixed-width and contains both +// full and half-width characters. +// This was left unimplemented as of R5. It is a way to work with both +// Kanji and Roman characters in the same fixed-width font. bool BFont::IsFullAndHalfFixed() const { @@ -938,7 +877,7 @@ BFont::CountTuned() const void BFont::GetTunedInfo(int32 index, tuned_font_info *info) const { - if (!info) + if (info == NULL) return; BPrivate::AppServerLink link; @@ -948,8 +887,7 @@ BFont::GetTunedInfo(int32 index, tuned_font_info *info) const link.Attach<uint32>(index); int32 code; - if (link.FlushWithReply(code) != B_OK - || code != B_OK) + if (link.FlushWithReply(code) != B_OK || code != B_OK) return; link.Read<tuned_font_info>(info); @@ -1013,7 +951,7 @@ BFont::GetTruncatedStrings(const char *stringArray[], int32 numStrings, float BFont::StringWidth(const char *string) const { - if (!string) + if (string == NULL) return 0.0; int32 length = strlen(string); @@ -1041,8 +979,10 @@ void BFont::GetStringWidths(const char *stringArray[], const int32 lengthArray[], int32 numStrings, float widthArray[]) const { - if (!stringArray || !lengthArray || numStrings < 1 || !widthArray) + if (stringArray == NULL || lengthArray == NULL || numStrings < 1 + || widthArray == NULL) { return; + } BPrivate::AppServerLink link; link.StartMessage(AS_GET_STRING_WIDTHS); @@ -1055,13 +995,11 @@ BFont::GetStringWidths(const char *stringArray[], const int32 lengthArray[], // TODO: all strings into a single array??? // 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]); - } status_t status; - if (link.FlushWithReply(status) != B_OK - || status != B_OK) + if (link.FlushWithReply(status) != B_OK || status != B_OK) return; link.Read(widthArray, sizeof(float) * numStrings); @@ -1102,8 +1040,7 @@ BFont::GetEscapements(const char charArray[], int32 numChars, link.Attach(charArray, bytesInBuffer); int32 code; - if (link.FlushWithReply(code) != B_OK - || code != B_OK) + if (link.FlushWithReply(code) != B_OK || code != B_OK) return; link.Read(escapementArray, numChars * sizeof(float)); @@ -1146,8 +1083,7 @@ BFont::GetEscapements(const char charArray[], int32 numChars, link.Attach(charArray, bytesInBuffer); int32 code; - if (link.FlushWithReply(code) != B_OK - || code != B_OK) + if (link.FlushWithReply(code) != B_OK || code != B_OK) return; link.Read(escapementArray, sizeof(BPoint) * numChars); @@ -1175,8 +1111,7 @@ BFont::GetEdges(const char charArray[], int32 numChars, link.Attach<int32>(bytesInBuffer); link.Attach(charArray, bytesInBuffer); - if (link.FlushWithReply(code) != B_OK - || code != B_OK) + if (link.FlushWithReply(code) != B_OK || code != B_OK) return; link.Read(edgeArray, sizeof(edge_info) * numChars); @@ -1199,8 +1134,7 @@ BFont::GetHeight(font_height *_height) const link.Attach<float>(fSize); int32 code; - if (link.FlushWithReply(code) != B_OK - || code != B_OK) + if (link.FlushWithReply(code) != B_OK || code != B_OK) return; // Who put that "const" to this method? :-) @@ -1217,8 +1151,8 @@ void BFont::GetBoundingBoxesAsGlyphs(const char charArray[], int32 numChars, font_metric_mode mode, BRect boundingBoxArray[]) const { - _GetBoundingBoxes(charArray, numChars, mode, false, NULL, boundingBoxArray, - false); + _GetBoundingBoxes(charArray, numChars, mode, false, NULL, + boundingBoxArray, false); } @@ -1227,8 +1161,8 @@ BFont::GetBoundingBoxesAsString(const char charArray[], int32 numChars, font_metric_mode mode, escapement_delta *delta, BRect boundingBoxArray[]) const { - _GetBoundingBoxes(charArray, numChars, mode, true, delta, boundingBoxArray, - true); + _GetBoundingBoxes(charArray, numChars, mode, true, delta, + boundingBoxArray, true); } @@ -1237,7 +1171,7 @@ 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 == NULL || numChars < 1 || boundingBoxArray == NULL) return; int32 code; @@ -1257,7 +1191,7 @@ BFont::_GetBoundingBoxes(const char charArray[], int32 numChars, link.Attach<font_metric_mode>(mode); link.Attach<bool>(string_escapement); - if (delta) { + if (delta != NULL) { link.Attach<escapement_delta>(*delta); } else { escapement_delta emptyDelta = {0, 0}; @@ -1269,8 +1203,7 @@ BFont::_GetBoundingBoxes(const char charArray[], int32 numChars, link.Attach<int32>(bytesInBuffer); link.Attach(charArray, bytesInBuffer); - if (link.FlushWithReply(code) != B_OK - || code != B_OK) + if (link.FlushWithReply(code) != B_OK || code != B_OK) return; link.Read(boundingBoxArray, sizeof(BRect) * numChars); @@ -1314,8 +1247,7 @@ BFont::GetBoundingBoxesForStrings(const char *stringArray[], int32 numStrings, } } - if (link.FlushWithReply(code) != B_OK - || code != B_OK) + if (link.FlushWithReply(code) != B_OK || code != B_OK) return; link.Read(boundingBoxArray, sizeof(BRect) * numStrings); @@ -1348,8 +1280,7 @@ BFont::GetGlyphShapes(const char charArray[], int32 numChars, link.Attach<int32>(bytesInBuffer); link.Attach(charArray, bytesInBuffer); - if (link.FlushWithReply(code) != B_OK - || code != B_OK) + if (link.FlushWithReply(code) != B_OK || code != B_OK) return; for (int32 i = 0; i < numChars; i++) @@ -1376,8 +1307,7 @@ BFont::GetHasGlyphs(const char charArray[], int32 numChars, link.Attach<int32>(bytesInBuffer); link.Attach(charArray, bytesInBuffer); - if (link.FlushWithReply(code) != B_OK - || code != B_OK) + if (link.FlushWithReply(code) != B_OK || code != B_OK) return; link.Read(hasArray, sizeof(bool) * numChars); @@ -1461,8 +1391,7 @@ BFont::_GetExtraFlags() const link.Attach<uint16>(fStyleID); status_t status = B_ERROR; - if (link.FlushWithReply(status) != B_OK - || status != B_OK) { + if (link.FlushWithReply(status) != B_OK || status != B_OK) { // use defaut values for the flags fExtraFlags = (uint32)B_FONT_LEFT_TO_RIGHT << B_PRIVATE_FONT_DIRECTION_SHIFT; @@ -1471,4 +1400,3 @@ BFont::_GetExtraFlags() const link.Read<uint32>(&fExtraFlags); } - ############################################################################ Commit: 566e828c5f9a265bc6dc610e930c95a68caa03ad URL: http://cgit.haiku-os.org/haiku/commit/?id=566e828 Author: John Scipione <jscipione@xxxxxxxxx> Date: Sat Jan 19 01:10:09 2013 UTC Add initial BFont documentation ---------------------------------------------------------------------------- diff --git a/docs/user/interface/Font.dox b/docs/user/interface/Font.dox new file mode 100644 index 0000000..ddb3a10 --- /dev/null +++ b/docs/user/interface/Font.dox @@ -0,0 +1,602 @@ +/* + * Copyright 2013 Haiku inc. + * Distributed under the terms of the MIT License. + * + * Documentation by: + * John Scipione <jscipione@xxxxxxxxx> + * Corresponds to: + * /trunk/headers/os/interface/Font.h hrev45178 + * /trunk/src/kits/interface/Font.cpp hrev45178 + */ + + +/*! + \file Font.h + \brief BFont class definition and support structs and enums. +*/ + + +/*! + \var B_FONT_FAMILY_LENGTH + \var B_FONT_STYLE_LENGTH + \typedef char font_family[B_FONT_FAMILY_LENGTH + 1]; + \typedef char font_style[B_FONT_STYLE_LENGTH + 1]; +*/ + + +/*! + \var B_CHAR_SPACING + Character spacing +*/ + + +/*! + \var B_STRING_SPACING + String spacing +*/ + + +/*! + \var B_BITMAP_SPACING + Bitmap spacing +*/ + + +/*! + \var B_FIXED_SPACING + Fixed width spacing +*/ + + +/*! + \enum font_direction + Determines the direction of the font left-to-right or right-to-left. +*/ + +/*! + \var font_direction B_FONT_LEFT_TO_RIGHT + Left to right. +*/ + +/*! + \var font_direction B_FONT_RIGHT_TO_LEFT + Right to left. +*/ + + +/*! + \var B_DISABLE_ANTIALIASING + Disable antialiasing. +*/ + + +/*! + \var B_FORCE_ANTIALIASING + Force antialiasing. +*/ + + +/*! + \var B_TRUNCATE_END + Truncate at end of the string. +*/ + + +/*! + \var B_TRUNCATE_BEGINNING + Truncate at beginning of the string. +*/ + + +/*! + \var B_TRUNCATE_MIDDLE + Truncate in the middle of the string. +*/ + + +/*! + \var B_TRUNCATE_SMART + Perform a smart truncation of the string. +*/ + + +/*! + \var B_UNICODE_UTF8 + UTF-8 font encoding. +*/ + + +/*! + \var B_ISO_8859_1 + ISO 8859-1 aka Latin 1 font encoding. +*/ + + +/*! + \var B_ISO_8859_2 + ISO 8859-2 aka Latin 2 font encoding. It is generally intended for Eastern + European languages that are written in the Latin script. +*/ + + +/*! + \var B_ISO_8859_3 + ISO 8859-3 "South European" font encoding. +*/ + + +/*! + \var B_ISO_8859_4 + ISO 8859-4 "North European" font encoding. +*/ + + +/*! + \var B_ISO_8859_5 + ISO 8859-5 "Latin/Cyrillic" font encoding. +*/ + + +/*! + \var B_ISO_8859_6 + ISO 8859-6 "Latin/Arabic" font encoding. +*/ + + +/*! + \var B_ISO_8859_7 + ISO 8859-7 "Latin/Greek" font encoding. +*/ + + +/*! + \var B_ISO_8859_8 + ISO 8859-8 "Latin/Hebrew" font encoding. +*/ + + +/*! + \var B_ISO_8859_9 + ISO 8859-9 "Latin/Turkish" font encoding. +*/ + + +/*! + \var B_ISO_8859_10 + ISO 8859-10 font encoding. +*/ + + +/*! + \var B_MACINTOSH_ROMAN + Macintosh Roman font encoding. +*/ + + +/*! + \var B_HAS_TUNED_FONT + flags for get_font_family() and get_font_style() +*/ + + +/*! + \var B_IS_FIXED + flags for get_font_family() and get_font_style() +*/ + + +/*! + \var B_ITALIC_FACE + Italic font face flag. +*/ + + +/*! + \var B_UNDERSCORE_FACE + Underscore font face flag. +*/ + + +/*! + \var B_NEGATIVE_FACE + Negative font face flag. +*/ + + +/*! + \var B_OUTLINED_FACE + Outline font face flag. +*/ + + +/*! + \var B_STRIKEOUT_FACE + Strikeout font face flag. +*/ + + +/*! + \var B_BOLD_FACE + Bold font face flag. +*/ + + +/*! + \var B_REGULAR_FACE + Regular font face flag. +*/ + + +/*! + \var B_CONDENSED_FACE + Condensed font face flag. Not in BeOS 5. +*/ + + +/*! + \var B_LIGHT_FACE + Light font face flag. Not in BeOS 5. +*/ + + +/*! + \var B_HEAVY_FACE + Heavy font face flag. Not in BeOS 5. +*/ + + +/*! + \enum font_metric_mode + Font metric mode, screen or printing. +*/ + +/*! + \var font_metric_mode B_SCREEN_METRIC + Screen font metric mode. +*/ + +/*! + \var font_metric_mode B_PRINTING_METRIC + Print font metric mode. +*/ + + +/*! + \enum font_file_format + Font file format, truetype or type1. +*/ + +/*! + \var font_file_format B_TRUETYPE_WINDOWS + Truetype font file format. +*/ + +/*! + \var font_file_format B_POSTSCRIPT_TYPE1_WINDOWS + Type1 font file format. +*/ + + +/*! + \class unicode_block + \brief Unicode block class. +*/ + + +/*! + \struct edge_info + \brief Edge info parameters: left or right. Both \c float type. +*/ + + +/*! + \struct font_height + \brief Font height parameters: ascent, descent or leading. All \c float type. +*/ + + +/*! + \struct escapement_delta + \brief Escapement delta parameters: nonspace or space. Both \c float type. +*/ + + +/*! + \struct font_cache_info + \brief Font cache parameters. +*/ + + +/*! + \var font_cache_info sheared_font_penalty + Sheared font penalty. Type \c int32. +*/ + + +/*! + \var font_cache_info rotated_font_penalty + Rotated font penalty. Type \c int32. +*/ + + +/*! + \var font_cache_info oversize_threshold + Oversize threshold. Type \c float. +*/ + + +/*! + \var font_cache_info oversize_penalty + Oversize penalty. Type \c int32. +*/ + +/*! + \var font_cache_info cache_size + Cache size. Type \c int32. +*/ + + +/*! + \var font_cache_info spacing_size_threshold + Spacing size threshold. Type \c float. +*/ + + +/*! + \struct tuned_font_info + \brief Tuned font information. +*/ + + +/*! + \var tuned_font_info size + Font size. Type \c float. +*/ + + +/*! + \var tuned_font_info shear + Font shear. Type \c float. +*/ + + +/*! + \var tuned_font_info rotation + Font rotation. Type \c float. +*/ + + +/*! + \var tuned_font_info flags + Font flags. Type \c uint32. +*/ + +/*! + \var tuned_font_info face + Font face. Type \c uint16. +*/ + + +/*! + \fn void _set_system_font_(const char *which, font_family family, + font_style style, float size) + \brief Private function used to replace the R5 hack which sets a + system font. + + \param which String denoting which font to set. + \param family The new family for the system font. + \param style The new style for the system font. + \param size The size for the system font to have. + + BeOS R5 used a global area offset table to set the system fonts in the + Font preferences panel. +*/ + + +/*! + \fn int32 count_font_families() + \brief Gets the number of installed font families + + \return The number of installed font families +*/ + + +/*! + \fn int32 count_font_styles(font_family family) + \brief Gets the number of styles available for a font family. + + \return The number of styles available for a font family. +*/ + + +/*! + \fn status_t get_font_family(int32 index, font_family *_name, + uint32 *_flags) + \brief Retrieves the family name at the specified index. + + \param index Unique font identifier code. + \param _name font_family String to receive the name of the family. + \param _flags if non-<tt>NULL</tt>, the values of the flags \c IS_FIXED + and \c B_HAS_TUNED_FONT are returned. + + \return A status code, \c B_OK on success or an error code. + \retval B_BAD_VALUE \a _name is \c NULL. + \retval B_ERROR \a index does not correspond to a font family. +*/ + + +/*! + \fn status_t get_font_style(font_family family, int32 index, + font_style *_name, uint32 *_flags) + \brief Retrieves the family name at the specified index. + + \param family The font family. + \param index Unique font identifier code. + \param _name string to receive the name of the family. + \param _flags if non-<tt>NULL</tt>, the values of the flags \c IS_FIXED + and \c B_HAS_TUNED_FONT are returned + + \return A status code, \c B_OK on success or an error code. + \retval B_ERROR \a index does not correspond to a font style. +*/ + + +/*! + \fn status_t get_font_style(font_family family, int32 index, + font_style *_name, uint16 *_face, uint32 *_flags) + \brief Retrieves the family name at the specified index. + + The face value returned by this function is not very reliable. At the same + time, the value returned should be fairly reliable, returning the proper + flag for 90%-99% of font names. + + \param family The font family. + \param index Unique font identifier code. + \param _name String to receive the name of the family. + \param _face recipient of font face value, such as \c B_REGULAR_FACE. + \param _flags if non-<tt>NULL</tt>, the values of the flags \c IS_FIXED + and \c B_HAS_TUNED_FONT are returned. + + \return A status code, \c B_OK on success or an error code. + \retval B_ERROR \a index does not correspond to a font style. +*/ + + +/*! + \fn bool update_font_families(bool checkOnly) + \brief Updates the font family list. + + \param checkOnly Parameter is ignored. + + \return \c true if the font list has changed, \c false if not. +*/ + + +/*! + \class BFont + \ingroup interface + \ingroup libbe + \brief A class representing a typeface including the family, style and size. +*/ + + +/*! + \fn BFont::BFont() + \brief Creates and initializes a BFont object to \c be_plain_font. + + \see BView::SetFont() +*/ + + +/*! + \fn BFont::BFont(const BFont &font) + \brief Creates and initializes a BFont object from another BFont object. + + \param font The BFont object to initialize from. +*/ + + +/*! + \fn BFont::BFont(const BFont *font) + \brief Creates and initializes a BFont object from a pointer to a BFont + object. + + \param font The pointer to a BFont object to initialize from. +*/ + + +/*! + \fn BFont::BFont(const BFont *font) + \brief Creates and initializes a BFont object from a pointer to a BFont + object. + + \param font The pointer to a BFont object to initialize from. +*/ + + +/*! + \fn status_t BFont::SetFamilyAndStyle(const font_family family, + const font_style style) + \brief Sets the font's family and style all at once. + + \param family Font family to set. + \param style Font style to set. + + \returns A status code, \c B_OK on success or an error code. + \retval B_BAD_VALUE \a family is \c NULL and \a style is \c NULL. + \retval B_NAME_NOT_FOUND Family or style do not exist. +*/ + + +/*! + \fn void BFont::SetFamilyAndStyle(uint32 fontcode) + \brief Sets the font's family and style from a font identifier. + + \param code Unique font identifier obtained from the server. +*/ + + +/*! + \fn status_t BFont::SetFamilyAndFace(const font_family family, uint16 face) + \brief Sets the font's family and face all at once. + + \param family Font family to set. + \param face Font face to set. + + \note To comply with the BeBook, this function will only set valid values, + i.e. passing a nonexistent family will cause only the face to be set. + Additionally, if a particular face does not exist in a family, the + closest match will be chosen. + + \returns A status code, B_OK on success or an error code. + \retval B_ERROR Family does not exists or face has an invalid value. +*/ + + +/*! + \fn void BFont::SetSize(float size) + \brief Set the font size. + + \param size The point size to set the font to. +*/ + + +/*! + \fn void BFont::SetShear(float shear) + \brief Set the angle in degrees relative to the baseline. + + The default shear is 90.0° measured counterclockwise. The shear + range is from 45.0° to 135.0°. + + \param size The shear in degrees to set the font to. +*/ + + +/*! + \fn void BFont::SetRotation(float rotation) + \brief Set the font rotation from the baseline in degrees. + + The default baseline is 0° and rotates counterclockwise. Rotation is not + supported by BTextView. + + \param size The rotation in degrees to set the font to. +*/ + + +/*! + \fn void BFont::SetFalseBoldWidth(float width) + \brief Set the false bold width. + + \param width The false bold width to set. +*/ + + +/*! + \fn bool BFont::IsFullAndHalfFixed() const + \brief Returns whether or not the font is fixed-width and contains both + full and half-width characters. + + \note This was left unimplemented as of R5. It is a way to work with both + Kanji and Roman characters in the same fixed-width font. +*/ + ############################################################################ Commit: c969b46240df3923e288b13d264da16a10d4f32e URL: http://cgit.haiku-os.org/haiku/commit/?id=c969b46 Author: John Scipione <jscipione@xxxxxxxxx> Date: Sat Jan 19 01:54:24 2013 UTC Put comments in methods, only description line outside ---------------------------------------------------------------------------- diff --git a/src/kits/interface/Font.cpp b/src/kits/interface/Font.cpp index 21e81b8..31473c9 100644 --- a/src/kits/interface/Font.cpp +++ b/src/kits/interface/Font.cpp @@ -385,12 +385,12 @@ status_t set_font_cache_info(uint32 id, void *set) // Private function used to replace the R5 hack which sets a system font -// R5 used a global area offset table to set the system fonts in the Font -// preferences panel. Bleah. void _set_system_font_(const char *which, font_family family, font_style style, float size) { + // R5 used a global area offset table to set the system fonts in the Font + // preferences panel. Bleah. BPrivate::AppServerLink link; link.StartMessage(AS_SET_SYSTEM_FONT); @@ -460,13 +460,14 @@ get_font_style(font_family family, int32 index, font_style *_name, // Retrieves the family name at the specified index -// The face value returned by this function is not very reliable. At the same -// time, the value returned should be fairly reliable, returning the proper -// flag for 90%-99% of font names. status_t get_font_style(font_family family, int32 index, font_style *_name, uint16 *_face, uint32 *_flags) { + // The face value returned by this function is not very reliable. At the + // same time, the value returned should be fairly reliable, returning the + // proper flag for 90%-99% of font names. + if (_name == NULL) return B_BAD_VALUE; @@ -590,13 +591,14 @@ BFont::SetFamilyAndStyle(uint32 fontcode) // Sets the font's family and face all at once -// To comply with the BeBook, this function will only set valid values - i.e. -// passing a nonexistent family will cause only the face to be set. -// Additionally, if a particular face does not exist in a family, the closest -// match will be chosen. status_t BFont::SetFamilyAndFace(const font_family family, uint16 face) { + // To comply with the BeBook, this function will only set valid values + // i.e. passing a nonexistent family will cause only the face to be set. + // Additionally, if a particular face does not exist in a family, the + // closest match will be chosen. + BPrivate::AppServerLink link; link.StartMessage(AS_GET_FAMILY_AND_STYLE_IDS); link.AttachString(family, sizeof(font_family)); @@ -796,11 +798,12 @@ BFont::IsFixed() const // Returns whether or not the font is fixed-width and contains both // full and half-width characters. -// This was left unimplemented as of R5. It is a way to work with both -// Kanji and Roman characters in the same fixed-width font. bool BFont::IsFullAndHalfFixed() const { + // This was left unimplemented as of R5. It is a way to work with both + // Kanji and Roman characters in the same fixed-width font. + _GetExtraFlags(); return (fExtraFlags & B_PRIVATE_FONT_IS_FULL_AND_HALF_FIXED) != 0; } @@ -993,8 +996,8 @@ BFont::GetStringWidths(const char *stringArray[], const int32 lengthArray[], link.Attach<int32>(numStrings); // 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++) link.AttachString(stringArray[i], lengthArray[i]); ############################################################################ Commit: 840476e1cbde279423c4e4ae8c75fc53350caf53 URL: http://cgit.haiku-os.org/haiku/commit/?id=840476e Author: John Scipione <jscipione@xxxxxxxxx> Date: Sat Jan 19 03:07:53 2013 UTC Rename SetFamilyAndStyle variable to code matching the header and BeBook. ---------------------------------------------------------------------------- diff --git a/src/kits/interface/Font.cpp b/src/kits/interface/Font.cpp index 31473c9..404ac1e 100644 --- a/src/kits/interface/Font.cpp +++ b/src/kits/interface/Font.cpp @@ -558,7 +558,7 @@ BFont::SetFamilyAndStyle(const font_family family, const font_style style) // Sets the font's family and style all at once void -BFont::SetFamilyAndStyle(uint32 fontcode) +BFont::SetFamilyAndStyle(uint32 code) { // R5 has a bug here: the face is not updated even though the IDs are set. // This is a problem because the face flag includes Regular/Bold/Italic @@ -567,8 +567,8 @@ BFont::SetFamilyAndStyle(uint32 fontcode) // than R5's in order to be correct uint16 family, style; - style = fontcode & 0xFFFF; - family = (fontcode & 0xFFFF0000) >> 16; + style = code & 0xFFFF; + family = (code & 0xFFFF0000) >> 16; BPrivate::AppServerLink link; link.StartMessage(AS_GET_FAMILY_AND_STYLE_IDS); @@ -578,8 +578,8 @@ BFont::SetFamilyAndStyle(uint32 fontcode) link.Attach<uint16>(style); link.Attach<uint16>(fFace); - int32 code; - if (link.FlushWithReply(code) != B_OK || code != B_OK) + int32 fontcode; + if (link.FlushWithReply(fontcode) != B_OK || fontcode != B_OK) return; link.Read<uint16>(&fFamilyID); ############################################################################ Commit: c258d2fa0e72c357147f9198554dc070ff7b95df URL: http://cgit.haiku-os.org/haiku/commit/?id=c258d2f Author: John Scipione <jscipione@xxxxxxxxx> Date: Sat Jan 19 06:23:44 2013 UTC Fill out BFont member docs ---------------------------------------------------------------------------- diff --git a/docs/user/interface/Font.dox b/docs/user/interface/Font.dox index ddb3a10..8af8252 100644 --- a/docs/user/interface/Font.dox +++ b/docs/user/interface/Font.dox @@ -12,7 +12,8 @@ /*! \file Font.h - \brief BFont class definition and support structs and enums. + \brief BFont class definition, unicode_block class definition, and + font-related struct and enum definitions. */ @@ -26,31 +27,35 @@ /*! \var B_CHAR_SPACING - Character spacing + Position each character without adjustment. Best mode for printing. */ /*! \var B_STRING_SPACING - String spacing + Optimizes the position of each character within it's space. Collisions + are unlikely but characters may touch each other. Best mode to use when + the screen needs to match what appears on the printed page. */ /*! \var B_BITMAP_SPACING - Bitmap spacing + The widths of the characters are chosen so that they never collide and + rarely touch. Best mode for drawing small amounts of text. */ /*! \var B_FIXED_SPACING - Fixed width spacing + Positions characters at a constant width. Best mode for fixed-width fonts. */ /*! \enum font_direction - Determines the direction of the font left-to-right or right-to-left. + Determines the direction of the text rendered by the font, + left-to-right or right-to-left. */ /*! @@ -66,13 +71,13 @@ /*! \var B_DISABLE_ANTIALIASING - Disable antialiasing. + Disable antialiasing. Used by BFont::Flags() and BFont::SetFlags(). */ /*! \var B_FORCE_ANTIALIASING - Force antialiasing. + Force antialiasing. Used by BFont::Flags() and BFont::SetFlags(). */ @@ -84,19 +89,19 @@ /*! \var B_TRUNCATE_BEGINNING - Truncate at beginning of the string. + Truncate from the beginning of the string. */ /*! \var B_TRUNCATE_MIDDLE - Truncate in the middle of the string. + Truncate from the middle of the string. */ /*! \var B_TRUNCATE_SMART - Perform a smart truncation of the string. + Truncate while keeping each string unique. */ @@ -108,26 +113,25 @@ /*! \var B_ISO_8859_1 - ISO 8859-1 aka Latin 1 font encoding. + ISO 8859-1 aka Latin 1 "Western European" font encoding. */ /*! \var B_ISO_8859_2 - ISO 8859-2 aka Latin 2 font encoding. It is generally intended for Eastern - European languages that are written in the Latin script. + ISO 8859-2 aka Latin 2 "Eastern European" font encoding. */ /*! \var B_ISO_8859_3 - ISO 8859-3 "South European" font encoding. + ISO 8859-3 aka Latin 3 "South European" font encoding. */ /*! \var B_ISO_8859_4 - ISO 8859-4 "North European" font encoding. + ISO 8859-4 aka Latin 4 "Northern European" font encoding. */ @@ -157,13 +161,13 @@ /*! \var B_ISO_8859_9 - ISO 8859-9 "Latin/Turkish" font encoding. + ISO 8859-9 aka Latin 5 "Latin/Turkish" font encoding. */ /*! \var B_ISO_8859_10 - ISO 8859-10 font encoding. + ISO 8859-10 aka Latin 6 "Nordic" font encoding. */ @@ -263,41 +267,210 @@ /*! \enum font_file_format - Font file format, truetype or type1. + Font file format, TrueType™ or PostScript™ Type1. + + \see BFont::FileFormat() */ /*! \var font_file_format B_TRUETYPE_WINDOWS - Truetype font file format. + TrueType™ font file format. */ /*! \var font_file_format B_POSTSCRIPT_TYPE1_WINDOWS - Type1 font file format. + PostScript™ Type1 font file format. */ /*! \class unicode_block - \brief Unicode block class. + \brief Provides the blocks of unicode characters supported by a font. + + \see BFont::Blocks() +*/ + + +/*! + \fn unicode_block::unicode_block() + \brief Construct a \c unicode_block and set block data to 0LL. + + You must initialize the block data before before using this object. +*/ + + +/*! + \fn unicode_block::unicode_block(uint64 block2, uint64 block1) + \brief Construct a \c unicode_block object and initialize it with the + supplied Unicode block range. + + \param block2 End block. + \param block1 Begin block. +*/ + + +/*! + \fn bool unicode_block::Includes(const unicode_block& block) const + \brief Determines if \a block is a subset of the \c unicode_block object. + + \param block The Unicode block to compare. + + \returns Whether or not \a block is a subset of the \c unicode_block + object. + \retval true \a block is a subset. + \retval false \a block is NOT a subset. +*/ + + +/*! + \name Assignment operators +*/ + + +//! @{ + + +/*! + \fn unicode_block unicode_block::operator&(const unicode_block& block) const + \brief Creates a new \c unicode_block object that is the intersection of + \a block and the \c unicode_block object. + + \param block The Unicode block to intersect with. + + \returns The intersection of \a block and the \c unicode_block object. +*/ + + +/*! + \fn unicode_block unicode_block::operator|(const unicode_block& block) const + \brief Creates a new \c unicode_block object that is the union of \a block + and the \c unicode_block object. + + \param block The Unicode block to form a union with. + + \returns The union of \a block and the \c unicode_block object. +*/ + + +/*! + \fn unicode_block& unicode_block::operator=(const unicode_block& block) + \brief Copies \a block data into the left-hand side object. + + \param block The unicode block to copy from. + + \returns A copy of \a block. +*/ + + +//! @} + + +/*! + \name Comparison operators +*/ + + +//! @{ + + +/*! + \fn bool unicode_block::operator==(const unicode_block& block) const + \brief Determines if the block object are exactly equal. + + \param block The unicode block to compare against. + + \returns \c true if the block object are exactly equal, \c false + otherwise. */ /*! + \fn bool unicode_block::operator!=(const unicode_block& block) const + \brief Determines if the block object are not equal. + + \param block The unicode block to compare against. + + \returns \c true if the block object are NOT equal, \c false + if the block objects are exactly equal. +*/ + + +//! @} + + +/*! \struct edge_info - \brief Edge info parameters: left or right. Both \c float type. + \brief The distance that a character outline is inset from its escapement + boundaries. + + Edge values, like escapements, need to be multiplied by the font size to + get the correct value for the font. + + \see BFont::GetEdges() +*/ + + +/*! + \var edge_info::left + \brief The distance that the character outline is inset from the left + escapement boundary. +*/ + + +/*! + \var edge_info::right + \brief The distance that the character outline is inset from the right + escapement boundary. */ /*! \struct font_height - \brief Font height parameters: ascent, descent or leading. All \c float type. + \brief The amount of vertical space surrounding a character. + + \see BFont::GetHeight() +*/ + + +/*! + \var font_height::ascent + \brief The distance characters can ascend above the baseline. +*/ + + +/*! + \var font_height::descent + \brief The distance characters can descend below the baseline. +*/ + + +/*! + \var font_height::leading + \brief The distance between lines, descent above to ascent below. */ /*! \struct escapement_delta - \brief Escapement delta parameters: nonspace or space. Both \c float type. + \brief The amount of horizontal space surrounding a character. + + Escapements need to be multiplied by the font size to get the correct + value for the font. + + \see BFont::GetEscapements() +*/ + + +/*! + \var escapement_delta::nonspace + \brief The amount of space surrounding a character with a visible glyph. +*/ + + +/*! + \var escapement_delta::space + \brief The amount of space surrounding a whitespace character, for example + \c B_TAB and \c B_SPACE. */ @@ -308,72 +481,76 @@ /*! - \var font_cache_info sheared_font_penalty - Sheared font penalty. Type \c int32. + \var font_cache_info::sheared_font_penalty + \brief Sheared font penalty. */ /*! - \var font_cache_info rotated_font_penalty - Rotated font penalty. Type \c int32. + \var font_cache_info::rotated_font_penalty + \brief Rotated font penalty. */ /*! - \var font_cache_info oversize_threshold - Oversize threshold. Type \c float. + \var font_cache_info::oversize_threshold + \brief Oversize threshold. */ /*! - \var font_cache_info oversize_penalty - Oversize penalty. Type \c int32. + \var font_cache_info::oversize_penalty + \brief Oversize penalty. */ /*! - \var font_cache_info cache_size - Cache size. Type \c int32. + \var font_cache_info::cache_size + \brief Cache size. */ /*! - \var font_cache_info spacing_size_threshold - Spacing size threshold. Type \c float. + \var font_cache_info::spacing_size_threshold + \brief Spacing size threshold. */ /*! \struct tuned_font_info - \brief Tuned font information. + \brief Tuning information of fonts used to make it look better when + displayed on-screen. + + \see BFont::GetTunedInfo() + \see BFont::CountTuned() */ /*! - \var tuned_font_info size - Font size. Type \c float. + \var tuned_font_info::size + \brief Font size. */ /*! - \var tuned_font_info shear - Font shear. Type \c float. + \var tuned_font_info::shear + \brief Font shear. */ /*! - \var tuned_font_info rotation - Font rotation. Type \c float. + \var tuned_font_info::rotation + \brief Font rotation. */ /*! - \var tuned_font_info flags - Font flags. Type \c uint32. + \var tuned_font_info::flags + \brief Font flags. */ /*! - \var tuned_font_info face - Font face. Type \c uint16. + \var tuned_font_info::face + \brief Font face. */ @@ -476,7 +653,7 @@ \class BFont \ingroup interface \ingroup libbe - \brief A class representing a typeface including the family, style and size. + \brief Represents a typeface including it's family, style and size. */ @@ -529,7 +706,7 @@ /*! - \fn void BFont::SetFamilyAndStyle(uint32 fontcode) + \fn void BFont::SetFamilyAndStyle(uint32 code) \brief Sets the font's family and style from a font identifier. \param code Unique font identifier obtained from the server. @@ -555,7 +732,7 @@ /*! \fn void BFont::SetSize(float size) - \brief Set the font size. + \brief Sets the font size. \param size The point size to set the font to. */ @@ -563,35 +740,223 @@ /*! \fn void BFont::SetShear(float shear) - \brief Set the angle in degrees relative to the baseline. + \brief Sets the angle in degrees relative to the baseline. The default shear is 90.0° measured counterclockwise. The shear range is from 45.0° to 135.0°. - \param size The shear in degrees to set the font to. + \param shear The shear in degrees to set the font to. */ /*! \fn void BFont::SetRotation(float rotation) - \brief Set the font rotation from the baseline in degrees. + \brief Sets the font rotation from the baseline in degrees. The default baseline is 0° and rotates counterclockwise. Rotation is not supported by BTextView. - \param size The rotation in degrees to set the font to. + \param rotation The rotation in degrees to set the font to. */ /*! \fn void BFont::SetFalseBoldWidth(float width) - \brief Set the false bold width. + \brief Sets the false bold width. \param width The false bold width to set. */ /*! + \fn void BFont::SetSpacing(uint8 spacing) + \brief Sets how characters are horizontally spaced relative to each other. + + - \c B_CHAR_SPACING Position each character without adjustment. Best mode + for printing. Characters may collide or overlap at small font sizes. + - \c B_STRING_SPACING Optimizes the position of each character within it's + space. Collisions are unlikely but characters may touch each other. + Best mode to use when the screen needs to match what appears on the + printed page. Adding new characters requires the entire string to + be redrawn. + - \c B_BITMAP_SPACING The widths of the characters are chosen so that they + never collide and rarely touch. Best mode for drawing small amounts + of text. Character widths are integral values. Spacing on screen will + not match spacing used by \c B_CHAR_SPACING mode for printing. + - \c B_FIXED_SPACING Positions characters at a constant width. Must be + used with fixed-width fonts otherwise \c B_CHAR_SPACING mode is used. + All characters have an identical integral escapement. + + \c B_STRING_SPACING and \c B_BITMAP_SPACING modes are relevant only for + font sizes from 7.0pt to 18.0pt, above and below that range + \c B_CHAR_SPACING produces nicer results. \c B_CHAR_SPACING is also always + used for rotated or sheared text and when antialiasing is disabled. + + \param spacing The spacing mode to set. + + \see BView::DrawString() + \see GetEscapements() +*/ + + +/*! + \fn void BFont::SetEncoding(uint8 encoding) + \brief Sets the character encoding of the font. + + The following character encodings are supported: + - \c B_UNICODE_UTF8 + - \c B_ISO_8859_1 aka Latin 1 aka "Western European". + - \c B_ISO_8859_2 aka Latin 2 aka "Eastern European". + - \c B_ISO_8859_3 aka Latin 3 aka "South European". + - \c B_ISO_8859_4 aka Latin 4 aka "Northern European". + - \c B_ISO_8859_5 aka "Latin/Cyrillic". + - \c B_ISO_8859_6 aka "Latin/Arabic". + - \c B_ISO_8859_7 aka "Latin/Greek". + - \c B_ISO_8859_8 aka "Latin/Hebrew". + - \c B_ISO_8859_9 aka Latin 5 aka "Latin/Turkish". + - \c B_ISO_8859_10 aka Latin 6 aka "Nordic". + - \c B_MACINTOSH_ROMAN + + \param encoding The character encoding to set. +*/ + + +/*! + \fn void BFont::SetFace(uint16 face) + \brief Sets the font face according to the flags set by \a face. + + The following font face flags are supported: + - \c B_ITALIC_FACE Characters are slanted to the right. + - \c B_UNDERSCORE_FACE Characters are underlined. + - \c B_NEGATIVE_FACE High and low colors are reversed when drawing + characters. + - \c B_OUTLINED_FACE Characters are drawn hollowed out. + - \c B_STRIKEOUT_FACE A horizontal line is drawn through their middle. + - \c B_BOLD_FACE Characters are bold. + - \c B_REGULAR_FACE Characters are drawn normally. + - \c B_CONDENSED_FACE Characters are drawn squished together. Not in + BeOS 5. + - \c B_LIGHT_FACE Characters are drawn thiner than normal. Not in BeOS 5. + - \c B_HEAVY_FACE Characters are drawn heavier than normal. Not in BeOS 5. + + \param face The mask of font face flags to set. +*/ + + +/*! + \fn void BFont::SetFlags(uint32 flags) + \brief Sets font flags controlling antialiasing. + + The following flags are supported: + - B_DISABLE_ANTIALIASING Disable antialiasing. + - B_FORCE_ANTIALIASING Force antialiasing. + + \param flags The mask of flags to set. +*/ + + +/*! + \fn void BFont::GetFamilyAndStyle(font_family *family, + font_style *style) const + \brief Writes out the name of the font family and/or font style. + + This method may be called with either \a family or \a style set to + \c NULL in order to get one or the other. + + \param family A font_family pointer to be filled out. + \param style A font_style pointer to be filled out. +*/ + + +/*! + \fn uint32 BFont::FamilyAndStyle() const + \brief Gets the code of the font family and style combination. + + \returns The family and style combination encoded as a unique integer. +*/ + + +/*! + \fn float BFont::Size() const + \brief Gets the font size. + + \returns The font size in points. +*/ + + +/*! + \fn float BFont::Size() const + \brief Gets the font shear. + + \returns The font shear as an angle from 45.0° to 135.0°. +*/ + + +/*! + \fn float BFont::Rotation() const + \brief Gets the font rotation. + + \returns The font rotation as an angle in degrees. +*/ + + +/*! + \fn float BFont::FalseBoldWidth() const + \brief Gets the width of the font as if it were bold. + + \returns The font width of the bold font variety. +*/ + + +/*! + \fn uint8 BFont::Spacing() const + \brief Gets the spacing constant. + + \returns The spacing constant. +*/ + + +/*! + \fn uint8 BFont::Encoding() const + \brief Gets the character encoding constant. + + \returns The character encoding constant. +*/ + + +/*! + \fn uint16 BFont::Face() const + \brief Gets the font face flags mask. + + \returns The font face flags mask. +*/ + + +/*! + \fn uint32 BFont::Flags() const + \brief Gets the antialiasing flags. + + \returns The antialiasing flags. +*/ + + +/*! + \fn font_direction BFont::Direction() const + \brief Gets the font direction, left-to-right or right-to left. + + \returns The font direction. +*/ + + +/*! + \fn bool BFont::IsFixed() const + \brief Gets whether or not the font is fixed width. + + \returns \c true if the font is fixed width, \c false otherwise. +*/ + + +/*! \fn bool BFont::IsFullAndHalfFixed() const \brief Returns whether or not the font is fixed-width and contains both full and half-width characters. @@ -600,3 +965,446 @@ Kanji and Roman characters in the same fixed-width font. */ + +/*! + \fn BRect BFont::BoundingBox() const + \brief Gets a BRect that encloses the font text. + + \returns A BRect that encloses the font text. +*/ + + +/*! + \fn unicode_block BFont::Blocks() const + \brief Gets a \c unicode_block object identifying the Unicode blocks + supported by the font. + + \attention Currently unimplemented, returns an empty \a unicode_block + object. + + \returns A \c unicode_block object. +*/ + + +/*! + \fn font_file_format BFont::FileFormat() const + \brief Gets whether the font is TrueType™ or Type1 font. + + \returns A \c font_file_format struct containing the font file format. +*/ + + +/*! + \fn int32 BFont::CountTuned() const + \brief Gets the number of tuned fonts for the font family and style. + + \returns The number of tuned fonts. +*/ + + +/*! + \fn void BFont::GetTunedInfo(int32 index, tuned_font_info *info) const + \brief Writes information about the tuned font at \a index into \a info. + + The index begins at 0 and counts tuned fonts for current font family and + style only. + + \param index The index of desired tuned font. + \param info The \a turned_font_info struct to fill out. +*/ + + +/*! + \fn void BFont::TruncateString(BString *inOut, uint32 mode, + float width) const + \brief Truncates \a inOut to be no longer than \a width using the + supplied truncation \a mode. + + The following truncation modes are supported: + - \c B_TRUNCATE_BEGINNING Truncate from the beginning of the string. + - \c B_TRUNCATE_MIDDLE Truncate from the middle of the string. + - \c B_TRUNCATE_END Truncate from the end of the string. + - \c B_TRUNCATE_SMART Truncate from anywhere, but do so so that each + string is made unique after being truncated. + + \param inOut The BString to truncate. + \param mode Truncation mode to use. + \param width The maximum width to truncate to. +*/ + + +/*! + \fn void BFont::GetTruncatedStrings(const char *stringArray[], + int32 numStrings, uint32 mode, float width, + BString resultArray[]) const + \brief Write truncated BString objects to \a resultArray given source + BString objects in \a stringArray. + + The following truncation modes are supported: + - \c B_TRUNCATE_BEGINNING Truncate from the beginning of the string. + - \c B_TRUNCATE_MIDDLE Truncate from the middle of the string. + - \c B_TRUNCATE_END Truncate from the end of the string. + - \c B_TRUNCATE_SMART Truncate from anywhere, but do so so that each + string is made unique after being truncated. + + \param stringArray The source string array. + \param numStrings The number of strings in \a stringArray. + \param mode Truncation mode to use. + \param width The maximum width to truncate to. + \param resultArray The destination string array. +*/ + + +/*! + \fn void BFont::GetTruncatedStrings(const char *stringArray[], + int32 numStrings, uint32 mode, float width, char *resultArray[]) const + \brief Write truncated strings to \a resultArray given source + BString objects in \a stringArray. + + \a resultArray is an array of pointers to string buffers which should be + allocated ahead of time and should be at least 3 bytes longer than the + matching input string. The 3 extra bytes provide enough room for the + truncated output given that GetTruncatedStrings() truncates only a + single-byte character from the input string and replaces it with an + ellipsis character (which takes three bytes for the UTF-8 encoding), + and adds a \c NUL-terminator. + + The following truncation modes are supported: + - \c B_TRUNCATE_BEGINNING Truncate from the beginning of the string. + - \c B_TRUNCATE_MIDDLE Truncate from the middle of the string. + - \c B_TRUNCATE_END Truncate from the end of the string. + - \c B_TRUNCATE_SMART Truncate from anywhere, but do so so that each + string is made unique after being truncated. + + \param stringArray The source string array. + \param numStrings The number of strings in \a stringArray. + \param mode Truncation mode to use. + \param width The maximum width to truncate to. + \param resultArray The destination string array. +*/ + + +/*! + \fn float BFont::StringWidth(const char *string) const + \brief Determines the amount of space required to draw \a string in the + current font. + + \param string The source string. + + \returns The width required to draw the string. +*/ + + +/*! + \fn float BFont::StringWidth(const char *string, int32 length) const + \brief Determines the amount of space required to draw \a string in the + current font up to \a length characters. + + \param string The source string. + \param length The number of characters in \a string to consider. + + \returns The width required to draw the string. +*/ + + +/*! + \fn void BFont::GetStringWidths(const char *stringArray[], + const int32 lengthArray[], int32 numStrings, float widthArray[]) const + \brief Determines the amount of space required to draw each string in + \a stringArray and writes the result in \a widthArray. + + \param stringArray The source string array. + \param lengthArray The number of characters to consider for each string in + \a stringArray + \param numStrings The number of strings in \a stringArray. + \param widthArray The destination array to put the widths required to draw + each string. +*/ + + +/*! + \fn void BFont::GetEscapements(const char charArray[], int32 numChars, + float escapementArray[]) const + \brief Determines the escapements for each char in \a charArray and writes + the result in \a escapementArray. + + \param charArray The source character array. + \param numChars The number of characters to consider in \a charArray. + \param escapementArray The destination array to put the escapements. +*/ + + +/*! + \fn void BFont::GetEscapements(const char charArray[], int32 numChars, + escapement_delta *delta, float escapementArray[]) const + \brief Determines the escapements for each char in \a charArray and writes + the result in \a escapementArray with consideration to the provided + escapement \a delta. + + The \c escapement_delta structure contains the following values: + - \c nonspace The amount of space surrounding a character with a visible + glyph. + - \c space The amount of space surrounding a whitespace character, for + example \c B_TAB and \c B_SPACE. + + \param charArray The source character array. + \param numChars The number of characters to consider in \a charArray. + \param delta The \c escapement_delta structure to use. + \param escapementArray The destination array to put the escapements. +*/ + + +/*! + \fn void BFont::GetEscapements(const char charArray[], int32 numChars, + escapement_delta *delta, BPoint escapementArray[]) const + \brief Determines the escapements for each char in \a charArray and writes + the result in \a escapementArray as an array of BPoint objects + with consideration to the provided escapement \a delta. + + The \c escapement_delta structure contains the following values: + - \c nonspace The amount of space surrounding a character with a visible + glyph. + - \c space The amount of space surrounding a whitespace character, for + example \c B_TAB and \c B_SPACE. + + \param charArray The source character array. + \param numChars The number of characters to consider in \a charArray. + \param delta The \c escapement_delta structure to use. + \param escapementArray The destination array of escapements as BPoint + objects. +*/ + + +/*! + \fn void BFont::GetEscapements(const char charArray[], int32 numChars, + escapement_delta *delta, BPoint escapementArray[], + BPoint offsetArray[]) const + \brief Determines the escapements for each char in \a charArray and writes + the result in \a escapementArray as an array of BPoint objects + with consideration to the provided escapement \a delta + and writes offsets to \a offsetArray. + + The \c escapement_delta structure contains the following values: + - \c nonspace The amount of space surrounding a character with a visible + glyph. + - \c space The amount of space surrounding a whitespace character, for + example \c B_TAB and \c B_SPACE. + + \param charArray The source character array. + \param numChars The number of characters to consider in \a charArray. + \param delta The \c escapement_delta structure to use. + \param escapementArray The destination array of escapements as BPoint + objects. + \param offsetArray The destination array of offsets as BPoint objects. +*/ + + +/*! + \fn void BFont::GetEdges(const char charArray[], int32 numChars, + edge_info edgeArray[]) const + \brief Determines the edge information for each character in \a charArray + and writes the result in \a edgeArray. + + The \c edge_info struct contains the following values: + - \c left The distance that the character outline is inset from the left + escapement boundary. + - \c right The distance that the character outline is inset from the + right escapement boundary. + + \param charArray The source character array. + \param numChars The number of characters to consider in \a charArray. + \param edgeArray The destination array of \c edge_info structs. +*/ + + +/*! + \fn void BFont::GetHeight(font_height *_height) const + \brief Fills out the \c font_height struct with the amount of vertical + space surrounding a character. + + The \c font_height struct contains the following values: + - \c ascent The distance characters can ascend above the baseline. + - \c descent The distance characters can descend below the baseline. + - \c leading The distance between lines, descent above to ascent below. + + \param _height The \c font_height struct to fill out. +*/ + + +/*! + \fn void BFont::GetBoundingBoxesAsGlyphs(const char charArray[], + int32 numChars, font_metric_mode mode, BRect boundingBoxArray[]) const + \brief Writes an array of BRect objects to \a boundingBoxArray + representing the bounding rectangles of each character in + \a charArray. + + Each BRect object corresponds to the glyph of one character. + + The \c font_metric_mode should contain one of the following values: + - \c B_SCREEN_METRIC The bounding boxes should use the screen metric. + - \c B_PRINTING_METRIC The bounding boxes should use the print metric. + + \param charArray The source character array. + \param numChars The number of characters to consider in \a charArray. + \param mode The \c font_metric_mode to use, screen or printing. + \param boundingBoxArray The destination array of BRect bounding boxes. +*/ + + +/*! + \fn void BFont::GetBoundingBoxesAsString(const char charArray[], + int32 numChars, font_metric_mode mode, escapement_delta *delta, + BRect boundingBoxArray[]) const + \brief Writes an array of BRect objects to \a boundingBoxArray + representing the bounding rectangles of each character in + \a charArray with consideration to the provided escapement + \a delta. + + Each BRect object corresponds to the glyph of one character. + + The \c font_metric_mode should contain one of the following values: + - \c B_SCREEN_METRIC The bounding boxes should use the screen metric. + - \c B_PRINTING_METRIC The bounding boxes should use the print metric. + + The \c escapement_delta structure contains the following values: + - \c nonspace The amount of space surrounding a character with a visible + glyph. + - \c space The amount of space surrounding a whitespace character, for + example \c B_TAB and \c B_SPACE. + + \param charArray The source character array. + \param numChars The number of characters to consider in \a charArray. + \param mode The \c font_metric_mode to use, screen or printing. + \param delta The \c escapement_delta structure to use. + \param boundingBoxArray The destination array of BRect bounding boxes. +*/ + + +/*! + \fn void BFont::_GetBoundingBoxes(const char charArray[], int32 numChars, + font_metric_mode mode, bool string_escapement, escapement_delta *delta, + BRect boundingBoxArray[], bool asString) const + \brief Writes an array of BRect objects to \a boundingBoxArray + representing the bounding rectangles of each character in + \a charArray with consideration to the provided escapement + \a delta and \a string_escapement. + + Each BRect object corresponds to the glyph of one character. + + The \c font_metric_mode should contain one of the following values: + - \c B_SCREEN_METRIC The bounding boxes should use the screen metric. + - \c B_PRINTING_METRIC The bounding boxes should use the print metric. + + The \c escapement_delta structure contains the following values: + - \c nonspace The amount of space surrounding a character with a visible + glyph. + - \c space The amount of space surrounding a whitespace character, for + example \c B_TAB and \c B_SPACE. + + \param charArray The source character array. + \param numChars The number of characters to consider in \a charArray. + \param mode The \c font_metric_mode to use, screen or printing. + \param string_escapement ??? + \param delta The \c escapement_delta structure to use. + \param boundingBoxArray The destination array of BRect bounding boxes. + \param asString ??? +*/ + + +/*! + \fn void BFont::GetBoundingBoxesForStrings(const char *stringArray[], + int32 numStrings, font_metric_mode mode, escapement_delta deltas[], + BRect boundingBoxArray[]) const + \brief Writes an array of BRect objects to \a boundingBoxArray + representing the bounding rectangles of each string in + \a stringArray with consideration to the provided escapement + \a delta. + + Each BRect object corresponds to the bounding box of the entire string. + + The \c font_metric_mode should contain one of the following values: + - \c B_SCREEN_METRIC The bounding boxes should use the screen metric. + - \c B_PRINTING_METRIC The bounding boxes should use the print metric. + + The \c escapement_delta structure contains the following values: + - \c nonspace The amount of space surrounding a character with a visible + glyph. + - \c space The amount of space surrounding a whitespace character, for + example \c B_TAB and \c B_SPACE. + + \param stringArray The source string array. + \param numStrings The number of strings to consider in \a stringArray. + \param mode The \c font_metric_mode to use, screen or printing. + \param deltas The array of \c escapement_delta structures to use. + \param boundingBoxArray The destination array of BRect bounding boxes. +*/ + + +/*! + void BFont::GetGlyphShapes(const char charArray[], int32 numChars, + BShape *glyphShapeArray[]) const + \brief Writes an array of BShape objects to \a glyphShapeArray + representing the glyph shapes of each character in + \a charArray. + + Each BShape object corresponds to the glyph of one character. + + \param charArray The source character array. + \param numChars The number of characters to consider in \a charArray. + \param glyphShapeArray The destination array of BShape glyphs. +*/ + + +/*! + void BFont::GetHasGlyphs(const char charArray[], int32 numChars, + bool hasArray[]) const + \brief Fills out \a hasArray with whether or not each characters in + \a charArray has a glyph for the font. + + \c true is written in \a hasArray if the character has a glyph in the + current font and \c false is written in \a hasArray if the character + does NOT have a glyph in the current font. + + \param charArray The source character array. + \param numChars The number of characters to consider in \a charArray. + \param hasArray The destination array of booleans. +*/ + + +/*! + BFont& BFont::operator=(const BFont &font) + \brief Assignment overload method. + + \param font The BFont object to assign from. +*/ + + +/*! + bool BFont::operator==(const BFont &font) const + \brief Equality comparison overload method. + + \param font The BFont object to compare the current font to. + + \returns \c true if the fonts objects are identical, \c false otherwise. +*/ + + +/*! + bool BFont::operator!=(const BFont &font) const + \brief Inequality comparison overload method. + + \param font The BFont object to compare the current font to. + + \returns \c true if the fonts objects are NOT identical, \c true + otherwise. +*/ + + +/*! + void BFont::PrintToStream() const + \brief Writes information about the font to \c stdout. + + printf("BFont { %s (%d), %s (%d) 0x%x %f/%f %fpt (%f %f %f), %d }\n", + family, fFamilyID, style, fStyleID, fFace, fShear, fRotation, fSize, + fHeight.ascent, fHeight.descent, fHeight.leading, fEncoding); +*/ ############################################################################ Commit: a8f3c5a8fb8cf179ff555c2236a05ce764854fa7 URL: http://cgit.haiku-os.org/haiku/commit/?id=a8f3c5a Author: John Scipione <jscipione@xxxxxxxxx> Date: Sat Jan 19 06:23:56 2013 UTC Style fixes only ---------------------------------------------------------------------------- diff --git a/src/kits/interface/Font.cpp b/src/kits/interface/Font.cpp index 404ac1e..10a2b18 100644 --- a/src/kits/interface/Font.cpp +++ b/src/kits/interface/Font.cpp @@ -1021,7 +1021,7 @@ void BFont::GetEscapements(const char charArray[], int32 numChars, escapement_delta *delta, float escapementArray[]) const { - if (!charArray || numChars < 1 || !escapementArray) + if (charArray = NULL || numChars < 1 || escapementArray = NULL) return; BPrivate::AppServerLink link; @@ -1063,7 +1063,7 @@ BFont::GetEscapements(const char charArray[], int32 numChars, escapement_delta *delta, BPoint escapementArray[], BPoint offsetArray[]) const { - if (!charArray || numChars < 1 || !escapementArray) + if (charArray = NULL || numChars < 1 || escapementArray = NULL) return; BPrivate::AppServerLink link; ############################################################################ Commit: 9c840df052ed690ed6fcbf870e1769e1e34644c0 URL: http://cgit.haiku-os.org/haiku/commit/?id=9c840df Author: John Scipione <jscipione@xxxxxxxxx> Date: Sat Jan 19 06:31:24 2013 UTC Woops, I meant == not = ---------------------------------------------------------------------------- diff --git a/src/kits/interface/Font.cpp b/src/kits/interface/Font.cpp index 10a2b18..d9a3003 100644 --- a/src/kits/interface/Font.cpp +++ b/src/kits/interface/Font.cpp @@ -1021,7 +1021,7 @@ void BFont::GetEscapements(const char charArray[], int32 numChars, escapement_delta *delta, float escapementArray[]) const { - if (charArray = NULL || numChars < 1 || escapementArray = NULL) + if (charArray == NULL || numChars < 1 || escapementArray == NULL) return; BPrivate::AppServerLink link; @@ -1063,7 +1063,7 @@ BFont::GetEscapements(const char charArray[], int32 numChars, escapement_delta *delta, BPoint escapementArray[], BPoint offsetArray[]) const { - if (charArray = NULL || numChars < 1 || escapementArray = NULL) + if (charArray == NULL || numChars < 1 || escapementArray == NULL) return; BPrivate::AppServerLink link; ############################################################################ Commit: 05757eb6b3066a2606afae81f4ab9b0bb0187919 URL: http://cgit.haiku-os.org/haiku/commit/?id=05757eb Author: John Scipione <jscipione@xxxxxxxxx> Date: Sat Jan 19 07:45:18 2013 UTC Fill out BFont detailed description. Also a bunch of cleanup including removing private method docs and cleaning up language. BFont is pretty much completely documented at this point. ---------------------------------------------------------------------------- diff --git a/docs/user/interface/Font.dox b/docs/user/interface/Font.dox index 8af8252..23d26a5 100644 --- a/docs/user/interface/Font.dox +++ b/docs/user/interface/Font.dox @@ -18,14 +18,6 @@ /*! - \var B_FONT_FAMILY_LENGTH - \var B_FONT_STYLE_LENGTH - \typedef char font_family[B_FONT_FAMILY_LENGTH + 1]; - \typedef char font_style[B_FONT_STYLE_LENGTH + 1]; -*/ - - -/*! \var B_CHAR_SPACING Position each character without adjustment. Best mode for printing. */ @@ -83,7 +75,7 @@ /*! \var B_TRUNCATE_END - Truncate at end of the string. + Truncate from the end of the string. */ @@ -261,7 +253,7 @@ /*! \var font_metric_mode B_PRINTING_METRIC - Print font metric mode. + Printing font metric mode. */ @@ -285,7 +277,7 @@ /*! \class unicode_block - \brief Provides the blocks of unicode characters supported by a font. + \brief Describes the blocks of Unicode characters supported by a font. \see BFont::Blocks() */ @@ -293,7 +285,7 @@ /*! \fn unicode_block::unicode_block() - \brief Construct a \c unicode_block and set block data to 0LL. + \brief Construct a \c unicode_block and set block data to 0. You must initialize the block data before before using this object. */ @@ -313,12 +305,12 @@ \fn bool unicode_block::Includes(const unicode_block& block) const \brief Determines if \a block is a subset of the \c unicode_block object. - \param block The Unicode block to compare. + \param block The Unicode block to check. \returns Whether or not \a block is a subset of the \c unicode_block object. - \retval true \a block is a subset. - \retval false \a block is NOT a subset. + \retval true \a block is a subset of the current \c unicode_block. + \retval false \a block is NOT a subset of the current \c unicode_block. */ @@ -555,22 +547,6 @@ /*! - \fn void _set_system_font_(const char *which, font_family family, - font_style style, float size) - \brief Private function used to replace the R5 hack which sets a - system font. - - \param which String denoting which font to set. - \param family The new family for the system font. - \param style The new style for the system font. - \param size The size for the system font to have. - - BeOS R5 used a global area offset table to set the system fonts in the - Font preferences panel. -*/ - - -/*! \fn int32 count_font_families() \brief Gets the number of installed font families @@ -641,7 +617,7 @@ /*! \fn bool update_font_families(bool checkOnly) - \brief Updates the font family list. + \brief Updates the font families list. \param checkOnly Parameter is ignored. @@ -654,14 +630,56 @@ \ingroup interface \ingroup libbe \brief Represents a typeface including it's family, style and size. + + The Interface Kit provides three prebuilt BFont objects which can be used + but not modified. + - \c const BFont* \c be_plain_font A plain font used by many controls. + - \c const BFont* \c be_bold_font A bold font used by titles. + - \c const BFont* \c be_fixed_font A fixed-width font. + + A BFont object does nothing on it's own but is used in combination with + a view or control. Here is an example of creating a BFont object from a + system font and assigning it to a view: + +\code + BFont font(be_plain_font); + font.SetSize(12.0); + font.SetEncoding(B_ISO_8859_1); + view->SetFont(&font); +\endcode + + You may also create a BFont object from a view, modify it and reassign it + back to the view like this: + +\code + BFont font; + view->GetFont(&font); + font.SetFace(B_ITALIC_FACE); + font.SetSpacing(B_CHAR_SPACING); + myView->SetFont(&font); +\endcode + + You can change the way a font renders with the SetFamilyAndStyle(), + SetFamilyAndFace(), SetSize(), SetShear(), SetRotation(), + SetFalseBoldWidth(), SetSpacing(), SetEncoding(), SetFace(), and + SetFlags() methods. + + More information about the space taken up by a font can be determined + by querying a BFont object using the following methods: + StringWidth(), GetStringWidths() GetEscapements(), GetEdges(), + GetHeight(), BoundingBox() GetBoundingBoxesAsGlyphs(), + GetBoundingBoxesAsString(), and GetBoundingBoxesForStrings(). [ *** diff truncated: 234 lines dropped *** ] ############################################################################ Commit: 0d2b04ca8366dc8eb0d2a1a54cb002b565fb2e8d URL: http://cgit.haiku-os.org/haiku/commit/?id=0d2b04c Author: John Scipione <jscipione@xxxxxxxxx> Date: Sat Jan 19 07:51:31 2013 UTC Minor update use fixed font for B_OK ---------------------------------------------------------------------------- ############################################################################ Commit: 27c3eae9b4cb2938b640b5a390c1c41398ba0a0b URL: http://cgit.haiku-os.org/haiku/commit/?id=27c3eae Author: John Scipione <jscipione@xxxxxxxxx> Date: Sat Jan 19 07:54:22 2013 UTC Another minor fix, style constant ---------------------------------------------------------------------------- ############################################################################ Commit: 4f7717a999d7d6bc21fdcd7c581437ac925c12e1 URL: http://cgit.haiku-os.org/haiku/commit/?id=4f7717a Author: John Scipione <jscipione@xxxxxxxxx> Date: Sat Jan 19 08:01:55 2013 UTC By removing the style on escapement_delta doxygen links it up which is better ---------------------------------------------------------------------------- ############################################################################ Revision: hrev45181 Commit: 6a4b222bc9666e27518ce30b0fcaf75818fdd580 URL: http://cgit.haiku-os.org/haiku/commit/?id=6a4b222 Author: John Scipione <jscipione@xxxxxxxxx> Date: Sat Jan 19 18:13:27 2013 UTC Use condensed, not squished together. Better ----------------------------------------------------------------------------