diff options
Diffstat (limited to 'libs')
-rw-r--r-- | libs/hwui/FontRenderer.cpp | 14 | ||||
-rw-r--r-- | libs/utils/Unicode.cpp | 13 |
2 files changed, 14 insertions, 13 deletions
diff --git a/libs/hwui/FontRenderer.cpp b/libs/hwui/FontRenderer.cpp index dd05e61..a077cbc 100644 --- a/libs/hwui/FontRenderer.cpp +++ b/libs/hwui/FontRenderer.cpp @@ -185,7 +185,7 @@ void Font::render(SkPaint* paint, const char* text, uint32_t start, uint32_t len return; } - SkFixed penX = SkIntToFixed(x); + float penX = x; int penY = y; int glyphsLeft = 1; if (numGlyphs > 0) { @@ -193,7 +193,7 @@ void Font::render(SkPaint* paint, const char* text, uint32_t start, uint32_t len } SkFixed prevRsbDelta = 0; - penX += SK_Fixed1 / 2; + penX += 0.5f; text += start; @@ -206,25 +206,25 @@ void Font::render(SkPaint* paint, const char* text, uint32_t start, uint32_t len } CachedGlyphInfo* cachedGlyph = getCachedGlyph(paint, glyph); - penX += SkAutoKern_AdjustF(prevRsbDelta, cachedGlyph->mLsbDelta); + penX += SkFixedToFloat(SkAutoKern_AdjustF(prevRsbDelta, cachedGlyph->mLsbDelta)); prevRsbDelta = cachedGlyph->mRsbDelta; // If it's still not valid, we couldn't cache it, so we shouldn't draw garbage if (cachedGlyph->mIsValid) { switch(mode) { case FRAMEBUFFER: - drawCachedGlyph(cachedGlyph, SkFixedFloor(penX), penY); + drawCachedGlyph(cachedGlyph, (int) floorf(penX), penY); break; case BITMAP: - drawCachedGlyph(cachedGlyph, SkFixedFloor(penX), penY, bitmap, bitmapW, bitmapH); + drawCachedGlyph(cachedGlyph, (int) floorf(penX), penY, bitmap, bitmapW, bitmapH); break; case MEASURE: - measureCachedGlyph(cachedGlyph, SkFixedFloor(penX), penY, bounds); + measureCachedGlyph(cachedGlyph, (int) floorf(penX), penY, bounds); break; } } - penX += cachedGlyph->mAdvanceX; + penX += SkFixedToFloat(cachedGlyph->mAdvanceX); // If we were given a specific number of glyphs, decrement if (numGlyphs > 0) { diff --git a/libs/utils/Unicode.cpp b/libs/utils/Unicode.cpp index 78c61b4..41cbf03 100644 --- a/libs/utils/Unicode.cpp +++ b/libs/utils/Unicode.cpp @@ -542,11 +542,7 @@ ssize_t utf8_to_utf16_length(const uint8_t* u8str, size_t u8len) return u16measuredLen; } -/** - * Convert a UTF-8 string to UTF-16. The destination UTF-16 buffer must have - * space for NULL at the end. - */ -void utf8_to_utf16(const uint8_t* u8str, size_t u8len, char16_t* u16str) +char16_t* utf8_to_utf16_no_null_terminator(const uint8_t* u8str, size_t u8len, char16_t* u16str) { const uint8_t* const u8end = u8str + u8len; const uint8_t* u8cur = u8str; @@ -569,7 +565,12 @@ void utf8_to_utf16(const uint8_t* u8str, size_t u8len, char16_t* u16str) u8cur += u8len; } - *u16cur = 0; + return u16cur; +} + +void utf8_to_utf16(const uint8_t* u8str, size_t u8len, char16_t* u16str) { + char16_t* end = utf8_to_utf16_no_null_terminator(u8str, u8len, u16str); + *end = 0; } } |