react-native-text-measure 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -167,9 +167,12 @@ public class ReactNativeTextMeasureModule extends ReactContextBaseJavaModule {
|
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
// ── 7. px → dp for output ─────────────────────────────────────────────
|
|
170
|
+
// Use ceil() to avoid sub-pixel truncation: e.g. on a 2.625x density device,
|
|
171
|
+
// 301px / 2.625 = 114.666...dp — without ceil the caller rounds down and clips
|
|
172
|
+
// the bottom of the last line. iOS already does this; Android must too.
|
|
170
173
|
WritableMap result = Arguments.createMap();
|
|
171
|
-
result.putDouble("width", measuredWidth / density);
|
|
172
|
-
result.putDouble("height", measuredHeight / density);
|
|
174
|
+
result.putDouble("width", Math.ceil(measuredWidth / density));
|
|
175
|
+
result.putDouble("height", Math.ceil(measuredHeight / density));
|
|
173
176
|
result.putInt( "lineCount", lineCount);
|
|
174
177
|
return result;
|
|
175
178
|
}
|
package/package.json
CHANGED