730 && topLeftX <= -2.0f) {
731 int minx = getGlyphImageMinX(ptr, (int)result.x);
732 if (minx > result.x) {
733 result.x += 1;
734 result.width -=1;
735 }
736 }
737 }
738
739 private int getGlyphImageMinX(long ptr, int origMinX) {
740
741 int width = StrikeCache.unsafe.getChar(ptr+StrikeCache.widthOffset);
742 int height = StrikeCache.unsafe.getChar(ptr+StrikeCache.heightOffset);
743 int rowBytes =
744 StrikeCache.unsafe.getChar(ptr+StrikeCache.rowBytesOffset);
745
746 if (rowBytes == width) {
747 return origMinX;
748 }
749
750 long pixelData;
751 if (StrikeCache.nativeAddressSize == 4) {
752 pixelData = 0xffffffff &
753 StrikeCache.unsafe.getInt(ptr + StrikeCache.pixelDataOffset);
754 } else {
755 pixelData =
756 StrikeCache.unsafe.getLong(ptr + StrikeCache.pixelDataOffset);
757 }
758 if (pixelData == 0L) {
759 return origMinX;
760 }
761
762 for (int y=0;y<height;y++) {
763 for (int x=0;x<3;x++) {
764 if (StrikeCache.unsafe.getByte(pixelData+y*rowBytes+x) != 0) {
765 return origMinX;
766 }
767 }
768 }
769 return origMinX+1;
770 }
771
772 /* These 3 metrics methods below should be implemented to return
773 * values in user space.
774 */
775 StrikeMetrics getFontMetrics() {
776 if (strikeMetrics == null) {
777 strikeMetrics =
|
730 && topLeftX <= -2.0f) {
731 int minx = getGlyphImageMinX(ptr, (int)result.x);
732 if (minx > result.x) {
733 result.x += 1;
734 result.width -=1;
735 }
736 }
737 }
738
739 private int getGlyphImageMinX(long ptr, int origMinX) {
740
741 int width = StrikeCache.unsafe.getChar(ptr+StrikeCache.widthOffset);
742 int height = StrikeCache.unsafe.getChar(ptr+StrikeCache.heightOffset);
743 int rowBytes =
744 StrikeCache.unsafe.getChar(ptr+StrikeCache.rowBytesOffset);
745
746 if (rowBytes == width) {
747 return origMinX;
748 }
749
750 long pixelData = StrikeCache.unsafe.getAddress(ptr + StrikeCache.pixelDataOffset);
751
752 if (pixelData == 0L) {
753 return origMinX;
754 }
755
756 for (int y=0;y<height;y++) {
757 for (int x=0;x<3;x++) {
758 if (StrikeCache.unsafe.getByte(pixelData+y*rowBytes+x) != 0) {
759 return origMinX;
760 }
761 }
762 }
763 return origMinX+1;
764 }
765
766 /* These 3 metrics methods below should be implemented to return
767 * values in user space.
768 */
769 StrikeMetrics getFontMetrics() {
770 if (strikeMetrics == null) {
771 strikeMetrics =
|