-
Notifications
You must be signed in to change notification settings - Fork 24.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modify Superscript implementation to align to the top (stackoverflow-…
…1, stackoverflow-2) #35704 (comment)
- Loading branch information
1 parent
7914cfd
commit fdeb37c
Showing
3 changed files
with
36 additions
and
17 deletions.
There are no files selected for viewing
16 changes: 0 additions & 16 deletions
16
ReactAndroid/src/main/java/com/facebook/react/views/text/ReactSuperscriptSpan.java
This file was deleted.
Oops, something went wrong.
35 changes: 35 additions & 0 deletions
35
ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTopAlignSpan.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
package com.facebook.react.views.text; | ||
|
||
import android.text.TextPaint; | ||
import android.text.style.MetricAffectingSpan; | ||
|
||
/** | ||
* Instances of this class are used to place reactTag information of nested text react nodes into | ||
* spannable text rendered by single {@link TextView} | ||
*/ | ||
public class ReactTopAlignSpan extends MetricAffectingSpan implements ReactSpan { | ||
double ratio = 0.4; | ||
|
||
public ReactTopAlignSpan() {} | ||
|
||
public ReactTopAlignSpan(double ratio) { | ||
this.ratio = ratio; | ||
} | ||
|
||
@Override | ||
public void updateDrawState(TextPaint paint) { | ||
paint.baselineShift += (int) (paint.ascent() * ratio); | ||
} | ||
|
||
@Override | ||
public void updateMeasureState(TextPaint paint) { | ||
paint.baselineShift += (int) (paint.ascent() * ratio); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters