Files
react-native/ReactCommon/fabric/textlayoutmanager/platform/ios/RCTTextPrimitivesConversions.h
T
Valentin SherginandFacebook Github Bot ede2c5031f Codemod: Clang-format for all files in ReactCommon directory
Summary:
We are moving towards 100%-prettified files. That's the first step when we apply Clang Format for `ReactCommon`.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D20110895

fbshipit-source-id: 0a0ce4997cf1c3721b0b07ef78c1a57ce87d20f9
2020-02-25 19:52:27 -08:00

103 lines
3.0 KiB
Objective-C

/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#import <UIKit/UIKit.h>
#include <react/textlayoutmanager/RCTFontProperties.h>
#include <react/textlayoutmanager/RCTFontUtils.h>
using namespace facebook::react;
inline static NSTextAlignment RCTNSTextAlignmentFromTextAlignment(TextAlignment textAlignment)
{
switch (textAlignment) {
case TextAlignment::Natural:
return NSTextAlignmentNatural;
case TextAlignment::Left:
return NSTextAlignmentLeft;
case TextAlignment::Right:
return NSTextAlignmentRight;
case TextAlignment::Center:
return NSTextAlignmentCenter;
case TextAlignment::Justified:
return NSTextAlignmentJustified;
}
}
inline static NSWritingDirection RCTNSWritingDirectionFromWritingDirection(WritingDirection writingDirection)
{
switch (writingDirection) {
case WritingDirection::Natural:
return NSWritingDirectionNatural;
case WritingDirection::LeftToRight:
return NSWritingDirectionLeftToRight;
case WritingDirection::RightToLeft:
return NSWritingDirectionRightToLeft;
}
}
inline static RCTFontStyle RCTFontStyleFromFontStyle(FontStyle fontStyle)
{
switch (fontStyle) {
case FontStyle::Normal:
return RCTFontStyleNormal;
case FontStyle::Italic:
return RCTFontStyleItalic;
case FontStyle::Oblique:
return RCTFontStyleOblique;
}
}
inline static RCTFontVariant RCTFontVariantFromFontVariant(FontVariant fontVariant)
{
return (RCTFontVariant)fontVariant;
}
inline static NSUnderlineStyle RCTNSUnderlineStyleFromStyleAndPattern(
TextDecorationLineStyle textDecorationLineStyle,
TextDecorationLinePattern textDecorationLinePattern)
{
NSUnderlineStyle style = NSUnderlineStyleNone;
switch (textDecorationLineStyle) {
case TextDecorationLineStyle::Single:
style = NSUnderlineStyle(style | NSUnderlineStyleSingle);
break;
case TextDecorationLineStyle::Thick:
style = NSUnderlineStyle(style | NSUnderlineStyleThick);
break;
case TextDecorationLineStyle::Double:
style = NSUnderlineStyle(style | NSUnderlineStyleDouble);
break;
}
switch (textDecorationLinePattern) {
case TextDecorationLinePattern::Solid:
style = NSUnderlineStyle(style | NSUnderlinePatternSolid);
break;
case TextDecorationLinePattern::Dash:
style = NSUnderlineStyle(style | NSUnderlinePatternDash);
break;
case TextDecorationLinePattern::Dot:
style = NSUnderlineStyle(style | NSUnderlinePatternDot);
break;
case TextDecorationLinePattern::DashDot:
style = NSUnderlineStyle(style | NSUnderlinePatternDashDot);
break;
case TextDecorationLinePattern::DashDotDot:
style = NSUnderlineStyle(style | NSUnderlinePatternDashDotDot);
break;
}
return style;
}
inline static UIColor *RCTUIColorFromSharedColor(const SharedColor &color)
{
return color ? [UIColor colorWithCGColor:color.get()] : nil;
}