BFont: allow skipping fallbacks in GetHasGlyphs
Change-Id: I5a68008d25cce34596fb5ce6fb07259ae56c3a3d Reviewed-on: https://review.haiku-os.org/c/haiku/+/7829 Tested-by: Commit checker robot <[email protected]> Reviewed-by: Adrien Destugues <[email protected]> Haiku-Format: Haiku-format Bot <[email protected]>
This commit is contained in:
committed by
Jérôme Duval
parent
36087e77db
commit
b8a45b3a2d
@@ -1740,12 +1740,18 @@
|
|||||||
/*!
|
/*!
|
||||||
\fn void BFont::GetHasGlyphs(const char charArray[], int32 numChars,
|
\fn void BFont::GetHasGlyphs(const char charArray[], int32 numChars,
|
||||||
bool hasArray[]) const
|
bool hasArray[]) const
|
||||||
\brief Fills out \a hasArray with whether or not each characters in
|
\brief Fills out \a hasArray with whether or not the font has a glyph
|
||||||
\a charArray has a glyph for the font.
|
for each character in \a charArray.
|
||||||
|
|
||||||
\c true is written in \a hasArray if the character has a glyph in the
|
\c true is written in \a hasArray if a glyph is found for the character,
|
||||||
current font and \c false is written in \a hasArray if the character
|
\c false otherwise.
|
||||||
does NOT have a glyph in the current font.
|
|
||||||
|
\remark After the introduction of fallback fonts for missing glyphs,
|
||||||
|
this is not exaclty what the name or the original desciption imply. As
|
||||||
|
the objective of this method is to know if a string can be presented
|
||||||
|
to the user without getting "no glyph" symbols, it will still write
|
||||||
|
\c true if the queried font does not provide a glyph for a character
|
||||||
|
but a fallback font does.
|
||||||
|
|
||||||
\param charArray The source character array.
|
\param charArray The source character array.
|
||||||
\param numChars The number of characters to consider in \a charArray.
|
\param numChars The number of characters to consider in \a charArray.
|
||||||
@@ -1755,6 +1761,25 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn void BFont::GetHasGlyphs(const char charArray[], int32 numChars,
|
||||||
|
bool hasArray[], bool useFallbacks) const
|
||||||
|
\brief Fills out \a hasArray with whether or not the font has a glyph
|
||||||
|
for each character in \a charArray.
|
||||||
|
|
||||||
|
\c true is written in \a hasArray if the character has a glyph in the
|
||||||
|
current font and \c false otherwise. Fallback fonts are also considered
|
||||||
|
in the search if \a useFallbacks is \c true.
|
||||||
|
|
||||||
|
\param charArray The source character array.
|
||||||
|
\param numChars The number of characters to consider in \a charArray.
|
||||||
|
\param hasArray The destination array of booleans.
|
||||||
|
\param useFallbacks Whether to consider fallback fonts in the answer.
|
||||||
|
|
||||||
|
\since Haiku R1
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn BFont& BFont::operator=(const BFont &font)
|
\fn BFont& BFont::operator=(const BFont &font)
|
||||||
\brief Assignment overload method.
|
\brief Assignment overload method.
|
||||||
|
|||||||
@@ -275,6 +275,8 @@ public:
|
|||||||
void GetHasGlyphs(const char charArray[],
|
void GetHasGlyphs(const char charArray[],
|
||||||
int32 numChars,
|
int32 numChars,
|
||||||
bool hasArray[]) const;
|
bool hasArray[]) const;
|
||||||
|
void GetHasGlyphs(const char charArray[], int32 numChars,
|
||||||
|
bool hasArray[], bool useFallbacks) const;
|
||||||
|
|
||||||
BFont& operator=(const BFont& font);
|
BFont& operator=(const BFont& font);
|
||||||
bool operator==(const BFont& font) const;
|
bool operator==(const BFont& font) const;
|
||||||
|
|||||||
@@ -1345,6 +1345,14 @@ BFont::GetGlyphShapes(const char charArray[], int32 numChars,
|
|||||||
void
|
void
|
||||||
BFont::GetHasGlyphs(const char charArray[], int32 numChars,
|
BFont::GetHasGlyphs(const char charArray[], int32 numChars,
|
||||||
bool hasArray[]) const
|
bool hasArray[]) const
|
||||||
|
{
|
||||||
|
GetHasGlyphs(charArray, numChars, hasArray, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BFont::GetHasGlyphs(const char charArray[], int32 numChars, bool hasArray[],
|
||||||
|
bool useFallbacks) const
|
||||||
{
|
{
|
||||||
if (!charArray || numChars < 1 || !hasArray)
|
if (!charArray || numChars < 1 || !hasArray)
|
||||||
return;
|
return;
|
||||||
@@ -1361,6 +1369,8 @@ BFont::GetHasGlyphs(const char charArray[], int32 numChars,
|
|||||||
link.Attach<int32>(bytesInBuffer);
|
link.Attach<int32>(bytesInBuffer);
|
||||||
link.Attach(charArray, bytesInBuffer);
|
link.Attach(charArray, bytesInBuffer);
|
||||||
|
|
||||||
|
link.Attach<bool>(useFallbacks);
|
||||||
|
|
||||||
if (link.FlushWithReply(code) != B_OK || code != B_OK)
|
if (link.FlushWithReply(code) != B_OK || code != B_OK)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -2487,6 +2487,7 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
|||||||
// 3) int32 - numChars
|
// 3) int32 - numChars
|
||||||
// 4) int32 - numBytes
|
// 4) int32 - numBytes
|
||||||
// 5) char - the char buffer with size numBytes
|
// 5) char - the char buffer with size numBytes
|
||||||
|
// 6) bool - whether to try fallback fonts
|
||||||
|
|
||||||
uint16 familyID, styleID;
|
uint16 familyID, styleID;
|
||||||
link.Read<uint16>(&familyID);
|
link.Read<uint16>(&familyID);
|
||||||
@@ -2506,13 +2507,15 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
|||||||
|
|
||||||
link.Read(charArray, numBytes);
|
link.Read(charArray, numBytes);
|
||||||
|
|
||||||
|
bool useFallbacks;
|
||||||
|
link.Read<bool>(&useFallbacks);
|
||||||
|
|
||||||
ServerFont font;
|
ServerFont font;
|
||||||
status_t status = font.SetFamilyAndStyle(familyID, styleID,
|
status_t status = font.SetFamilyAndStyle(familyID, styleID,
|
||||||
fAppFontManager);
|
fAppFontManager);
|
||||||
|
|
||||||
if (status == B_OK) {
|
if (status == B_OK) {
|
||||||
status = font.GetHasGlyphs(charArray, numBytes, numChars,
|
status = font.GetHasGlyphs(charArray, numBytes, numChars, hasArray, useFallbacks);
|
||||||
hasArray);
|
|
||||||
if (status == B_OK) {
|
if (status == B_OK) {
|
||||||
fLink.StartMessage(B_OK);
|
fLink.StartMessage(B_OK);
|
||||||
fLink.Attach(hasArray, numChars * sizeof(bool));
|
fLink.Attach(hasArray, numChars * sizeof(bool));
|
||||||
|
|||||||
@@ -692,8 +692,8 @@ ServerFont::IncludesUnicodeBlock(uint32 start, uint32 end, bool& hasBlock)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
ServerFont::GetHasGlyphs(const char* string, int32 numBytes, int32 numChars,
|
ServerFont::GetHasGlyphs(const char* string, int32 numBytes, int32 numChars, bool* hasArray,
|
||||||
bool* hasArray) const
|
bool useFallbacks) const
|
||||||
{
|
{
|
||||||
if (string == NULL || numBytes <= 0 || numChars <= 0 || hasArray == NULL)
|
if (string == NULL || numBytes <= 0 || numChars <= 0 || hasArray == NULL)
|
||||||
return B_BAD_DATA;
|
return B_BAD_DATA;
|
||||||
@@ -714,7 +714,7 @@ ServerFont::GetHasGlyphs(const char* string, int32 numBytes, int32 numChars,
|
|||||||
while (charIndex < numChars && (charCode = UTF8ToCharCode(&string)) != 0) {
|
while (charIndex < numChars && (charCode = UTF8ToCharCode(&string)) != 0) {
|
||||||
hasArray[charIndex] = entry->CanCreateGlyph(charCode);
|
hasArray[charIndex] = entry->CanCreateGlyph(charCode);
|
||||||
|
|
||||||
if (hasArray[charIndex] == false) {
|
if (hasArray[charIndex] == false && useFallbacks) {
|
||||||
if (fallbacks.IsEmpty())
|
if (fallbacks.IsEmpty())
|
||||||
GlyphLayoutEngine::PopulateFallbacks(fallbacks, *this, false);
|
GlyphLayoutEngine::PopulateFallbacks(fallbacks, *this, false);
|
||||||
|
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ class ServerFont {
|
|||||||
|
|
||||||
status_t GetHasGlyphs(const char charArray[],
|
status_t GetHasGlyphs(const char charArray[],
|
||||||
int32 numBytes, int32 numChars,
|
int32 numBytes, int32 numChars,
|
||||||
bool hasArray[]) const;
|
bool hasArray[], bool useFallbacks) const;
|
||||||
|
|
||||||
status_t GetEdges(const char charArray[], int32 numBytes,
|
status_t GetEdges(const char charArray[], int32 numBytes,
|
||||||
int32 numChars, edge_info edgeArray[])
|
int32 numChars, edge_info edgeArray[])
|
||||||
|
|||||||
Reference in New Issue
Block a user