Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed text measurement regression #978

Merged
merged 3 commits into from Feb 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ private static YogaSize MeasureText(ReactTextShadowNode textNode, YogaNode node,
var normalizedHeight = YogaConstants.IsUndefined(height) ? double.PositiveInfinity : height;
textBlock.Measure(new Size(normalizedWidth, normalizedHeight));
return MeasureOutput.Make(
(float)textBlock.DesiredSize.Width,
(float)textBlock.DesiredSize.Height);
(float)Math.Ceiling(textBlock.DesiredSize.Width),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ceiling [](start = 32, length = 7)

That's strange that cropping occurs on WPF and not on UWP. We were going to use the same technique for UWP, but fixed the rounding issue in Yoga. facebook/yoga#300

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does that mean we should publish a new package (same hash they published to npm/cocoapods), and then update our version reference to fix the issue?

Copy link
Collaborator

@rozele rozele Feb 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually think this is also a problem on UWP still too. Can you add the Math.Ceiling to UWP as well?

(float)Math.Ceiling(textBlock.DesiredSize.Height));
});

return task.Result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,9 @@ private static YogaSize MeasureTextInput(ReactPasswordBoxShadowNode textInputNod
finalizedHeight += YogaConstants.IsUndefined(borderTopWidth) ? 0 : borderTopWidth;
finalizedHeight += YogaConstants.IsUndefined(borderBottomWidth) ? 0 : borderBottomWidth;

return MeasureOutput.Make(width, finalizedHeight);
return MeasureOutput.Make(
(float)Math.Ceiling(width),
(float)Math.Ceiling(finalizedHeight));
});

return task.Result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,9 @@ private static YogaSize MeasureTextInput(ReactTextInputShadowNode textInputNode,
finalizedHeight += YogaConstants.IsUndefined(borderTopWidth) ? 0 : borderTopWidth;
finalizedHeight += YogaConstants.IsUndefined(borderBottomWidth) ? 0 : borderBottomWidth;

return MeasureOutput.Make(width, (float)finalizedHeight);
return MeasureOutput.Make(
(float)Math.Ceiling(width),
(float)Math.Ceiling(finalizedHeight));
});

return task.Result;
Expand Down
4 changes: 2 additions & 2 deletions ReactWindows/ReactNative/Views/Text/ReactTextShadowNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ private static YogaSize MeasureText(ReactTextShadowNode textNode, YogaNode node,
var normalizedHeight = YogaConstants.IsUndefined(height) ? double.PositiveInfinity : height;
textBlock.Measure(new Size(normalizedWidth, normalizedHeight));
return MeasureOutput.Make(
(float)textBlock.DesiredSize.Width,
(float)textBlock.DesiredSize.Height);
(float)Math.Ceiling(textBlock.DesiredSize.Width),
(float)Math.Ceiling(textBlock.DesiredSize.Height));
});

return task.Result;
Expand Down