fixed confusion of byteCount and charCount in ServerFont::StringWidth(), just in case anyone really uses it later. Added UTF8CountChars() to moreUTF8.h, but then I didn't need it...
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12750 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -24,20 +24,6 @@ UTF8NextCharLen(const char *text)
|
||||
return ptr - text;
|
||||
}
|
||||
|
||||
static inline uint32
|
||||
UTF8CountBytes(const char *text, uint32 numChars)
|
||||
{
|
||||
const char *ptr = text;
|
||||
|
||||
while (numChars) {
|
||||
ptr += UTF8NextCharLen(ptr);
|
||||
numChars--;
|
||||
}
|
||||
|
||||
return ptr - text;
|
||||
}
|
||||
|
||||
|
||||
static inline uint32
|
||||
UTF8PreviousCharLen(const char *text, const char *limit)
|
||||
{
|
||||
@@ -55,4 +41,33 @@ UTF8PreviousCharLen(const char *text, const char *limit)
|
||||
return text - ptr;
|
||||
}
|
||||
|
||||
static inline uint32
|
||||
UTF8CountBytes(const char *text, uint32 numChars)
|
||||
{
|
||||
const char *ptr = text;
|
||||
|
||||
while (numChars) {
|
||||
ptr += UTF8NextCharLen(ptr);
|
||||
numChars--;
|
||||
}
|
||||
|
||||
return ptr - text;
|
||||
}
|
||||
|
||||
static inline uint32
|
||||
UTF8CountChars(const char *text, int32 numBytes)
|
||||
{
|
||||
const char* ptr = text;
|
||||
const char* last = ptr + numBytes - 1;
|
||||
|
||||
uint32 count = 0;
|
||||
while (ptr <= last) {
|
||||
ptr += UTF8NextCharLen(ptr);
|
||||
count++;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -120,7 +120,7 @@ class ServerFont {
|
||||
float widthArray[],
|
||||
escapement_delta delta) const;
|
||||
|
||||
float StringWidth(const char* string, int32 numChars) const;
|
||||
float StringWidth(const char* string, int32 numBytes) const;
|
||||
|
||||
FT_Face GetFTFace() const
|
||||
{ return fStyle->GetFTFace(); };
|
||||
|
||||
Reference in New Issue
Block a user