mirror of
https://review.haiku-os.org/haiku
synced 2025-01-18 12:38:51 +01:00
BFont: allow skipping fallbacks in GetHasGlyphs
Change-Id: I5a68008d25cce34596fb5ce6fb07259ae56c3a3d Reviewed-on: https://review.haiku-os.org/c/haiku/+/7829 Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org> Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk> Haiku-Format: Haiku-format Bot <no-reply+haikuformatbot@haiku-os.org>
This commit is contained in:
parent
36087e77db
commit
b8a45b3a2d
@ -1740,12 +1740,18 @@
|
||||
/*!
|
||||
\fn 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.
|
||||
\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 is written in \a hasArray if the character
|
||||
does NOT have a glyph in the current font.
|
||||
\c true is written in \a hasArray if a glyph is found for the character,
|
||||
\c false otherwise.
|
||||
|
||||
\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 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)
|
||||
\brief Assignment overload method.
|
||||
|
@ -275,6 +275,8 @@ public:
|
||||
void GetHasGlyphs(const char charArray[],
|
||||
int32 numChars,
|
||||
bool hasArray[]) const;
|
||||
void GetHasGlyphs(const char charArray[], int32 numChars,
|
||||
bool hasArray[], bool useFallbacks) const;
|
||||
|
||||
BFont& operator=(const BFont& font);
|
||||
bool operator==(const BFont& font) const;
|
||||
|
@ -1345,6 +1345,14 @@ BFont::GetGlyphShapes(const char charArray[], int32 numChars,
|
||||
void
|
||||
BFont::GetHasGlyphs(const char charArray[], int32 numChars,
|
||||
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)
|
||||
return;
|
||||
@ -1361,6 +1369,8 @@ BFont::GetHasGlyphs(const char charArray[], int32 numChars,
|
||||
link.Attach<int32>(bytesInBuffer);
|
||||
link.Attach(charArray, bytesInBuffer);
|
||||
|
||||
link.Attach<bool>(useFallbacks);
|
||||
|
||||
if (link.FlushWithReply(code) != B_OK || code != B_OK)
|
||||
return;
|
||||
|
||||
|
@ -2487,6 +2487,7 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
||||
// 3) int32 - numChars
|
||||
// 4) int32 - numBytes
|
||||
// 5) char - the char buffer with size numBytes
|
||||
// 6) bool - whether to try fallback fonts
|
||||
|
||||
uint16 familyID, styleID;
|
||||
link.Read<uint16>(&familyID);
|
||||
@ -2506,13 +2507,15 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
|
||||
|
||||
link.Read(charArray, numBytes);
|
||||
|
||||
bool useFallbacks;
|
||||
link.Read<bool>(&useFallbacks);
|
||||
|
||||
ServerFont font;
|
||||
status_t status = font.SetFamilyAndStyle(familyID, styleID,
|
||||
fAppFontManager);
|
||||
|
||||
if (status == B_OK) {
|
||||
status = font.GetHasGlyphs(charArray, numBytes, numChars,
|
||||
hasArray);
|
||||
status = font.GetHasGlyphs(charArray, numBytes, numChars, hasArray, useFallbacks);
|
||||
if (status == B_OK) {
|
||||
fLink.StartMessage(B_OK);
|
||||
fLink.Attach(hasArray, numChars * sizeof(bool));
|
||||
|
@ -692,8 +692,8 @@ ServerFont::IncludesUnicodeBlock(uint32 start, uint32 end, bool& hasBlock)
|
||||
|
||||
|
||||
status_t
|
||||
ServerFont::GetHasGlyphs(const char* string, int32 numBytes, int32 numChars,
|
||||
bool* hasArray) const
|
||||
ServerFont::GetHasGlyphs(const char* string, int32 numBytes, int32 numChars, bool* hasArray,
|
||||
bool useFallbacks) const
|
||||
{
|
||||
if (string == NULL || numBytes <= 0 || numChars <= 0 || hasArray == NULL)
|
||||
return B_BAD_DATA;
|
||||
@ -714,7 +714,7 @@ ServerFont::GetHasGlyphs(const char* string, int32 numBytes, int32 numChars,
|
||||
while (charIndex < numChars && (charCode = UTF8ToCharCode(&string)) != 0) {
|
||||
hasArray[charIndex] = entry->CanCreateGlyph(charCode);
|
||||
|
||||
if (hasArray[charIndex] == false) {
|
||||
if (hasArray[charIndex] == false && useFallbacks) {
|
||||
if (fallbacks.IsEmpty())
|
||||
GlyphLayoutEngine::PopulateFallbacks(fallbacks, *this, false);
|
||||
|
||||
|
@ -123,7 +123,7 @@ class ServerFont {
|
||||
|
||||
status_t GetHasGlyphs(const char charArray[],
|
||||
int32 numBytes, int32 numChars,
|
||||
bool hasArray[]) const;
|
||||
bool hasArray[], bool useFallbacks) const;
|
||||
|
||||
status_t GetEdges(const char charArray[], int32 numBytes,
|
||||
int32 numChars, edge_info edgeArray[])
|
||||
|
Loading…
Reference in New Issue
Block a user