mirror of
https://github.com/zoriya/react-native-svg.git
synced 2026-06-03 23:16:13 +00:00
Implement getAlignmentBaseline and getBaselineShift in ios. (#527)
* Implement correct transform parser * Implement getAlignmentBaseline and getBaselineShift in ios. Add comments to glyphcontext and align with android. Implement correct isWordSeparator predicate. Cleanup GlyphContext j2objc remnants. * Fix getBaselineShift bugs and font data invalidation.
This commit is contained in:
committed by
Dustin Savery
parent
4821a7cd3a
commit
ec2a967592
@@ -499,10 +499,10 @@ class TSpanShadowNode extends TextShadowNode {
|
||||
Neither 'text-before-edge' nor 'text-after-edge' should be used with the vertical-align property.
|
||||
*/
|
||||
final Paint.FontMetrics fm = paint.getFontMetrics();
|
||||
final double top = -fm.top;
|
||||
final double bottom = fm.bottom;
|
||||
final double ascenderHeight = -fm.ascent;
|
||||
final double descenderDepth = fm.descent;
|
||||
final double bottom = descenderDepth + fm.leading;
|
||||
final double ascenderHeight = -fm.ascent + fm.leading;
|
||||
final double top = -fm.top;
|
||||
final double totalHeight = top + bottom;
|
||||
double baselineShift = 0;
|
||||
String baselineShiftString = getBaselineShift();
|
||||
@@ -593,6 +593,7 @@ class TSpanShadowNode extends TextShadowNode {
|
||||
baselineShift = top;
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*
|
||||
2.2.2. Alignment Shift: baseline-shift longhand
|
||||
|
||||
@@ -621,52 +622,51 @@ class TSpanShadowNode extends TextShadowNode {
|
||||
|
||||
https://www.w3.org/TR/css-inline-3/#propdef-baseline-shift
|
||||
*/
|
||||
if (baselineShiftString != null) {
|
||||
switch (baseline) {
|
||||
case top:
|
||||
case bottom:
|
||||
break;
|
||||
if (baselineShiftString != null && !baselineShiftString.isEmpty()) {
|
||||
switch (baseline) {
|
||||
case top:
|
||||
case bottom:
|
||||
break;
|
||||
|
||||
default:
|
||||
switch (baselineShiftString) {
|
||||
case "sub":
|
||||
// TODO
|
||||
if (fontData != null && fontData.hasKey("tables") && fontData.hasKey("unitsPerEm")) {
|
||||
int unitsPerEm = fontData.getInt("unitsPerEm");
|
||||
ReadableMap tables = fontData.getMap("tables");
|
||||
if (tables.hasKey("os2")) {
|
||||
ReadableMap os2 = tables.getMap("os2");
|
||||
if (os2.hasKey("ySubscriptYOffset")) {
|
||||
double subOffset = os2.getDouble("ySubscriptYOffset");
|
||||
baselineShift += fontSize * subOffset / unitsPerEm;
|
||||
}
|
||||
default:
|
||||
switch (baselineShiftString) {
|
||||
case "sub":
|
||||
// TODO
|
||||
if (fontData != null && fontData.hasKey("tables") && fontData.hasKey("unitsPerEm")) {
|
||||
int unitsPerEm = fontData.getInt("unitsPerEm");
|
||||
ReadableMap tables = fontData.getMap("tables");
|
||||
if (tables.hasKey("os2")) {
|
||||
ReadableMap os2 = tables.getMap("os2");
|
||||
if (os2.hasKey("ySubscriptYOffset")) {
|
||||
double subOffset = os2.getDouble("ySubscriptYOffset");
|
||||
baselineShift += mScale * fontSize * subOffset / unitsPerEm;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case "super":
|
||||
// TODO
|
||||
if (fontData != null && fontData.hasKey("tables") && fontData.hasKey("unitsPerEm")) {
|
||||
int unitsPerEm = fontData.getInt("unitsPerEm");
|
||||
ReadableMap tables = fontData.getMap("tables");
|
||||
if (tables.hasKey("os2")) {
|
||||
ReadableMap os2 = tables.getMap("os2");
|
||||
if (os2.hasKey("ySuperscriptYOffset")) {
|
||||
double superOffset = os2.getDouble("ySuperscriptYOffset");
|
||||
baselineShift -= fontSize * superOffset / unitsPerEm;
|
||||
}
|
||||
case "super":
|
||||
// TODO
|
||||
if (fontData != null && fontData.hasKey("tables") && fontData.hasKey("unitsPerEm")) {
|
||||
int unitsPerEm = fontData.getInt("unitsPerEm");
|
||||
ReadableMap tables = fontData.getMap("tables");
|
||||
if (tables.hasKey("os2")) {
|
||||
ReadableMap os2 = tables.getMap("os2");
|
||||
if (os2.hasKey("ySuperscriptYOffset")) {
|
||||
double superOffset = os2.getDouble("ySuperscriptYOffset");
|
||||
baselineShift -= mScale * fontSize * superOffset / unitsPerEm;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case "baseline":
|
||||
break;
|
||||
case "baseline":
|
||||
break;
|
||||
|
||||
default:
|
||||
baselineShift -= PropHelper.fromRelative(baselineShiftString, fontSize, 0, mScale, fontSize);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
baselineShift -= PropHelper.fromRelative(baselineShiftString, mScale * fontSize, 0, mScale, fontSize);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user