Skip to content

Commit

Permalink
fix(ios): revert rename hippy prefix for compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
wwwcg committed Jan 3, 2024
1 parent 5863fe7 commit a1cba87
Show file tree
Hide file tree
Showing 13 changed files with 171 additions and 188 deletions.
24 changes: 3 additions & 21 deletions renderer/native/ios/renderer/HippyFont.mm
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,6 @@
#import "HippyFont.h"
#import "HippyLog.h"

#if !defined(__IPHONE_8_2) || __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_8_2

// These constants are defined in iPhone SDK 8.2, but the app cannot run on
// iOS < 8.2 unless we redefine them here. If you target iOS 8.2 or above
// as a base target, the standard constants will be used instead.
// These constants can only be removed when Hippy Native drops iOS8 support.

#define UIFontWeightUltraLight -0.8
#define UIFontWeightThin -0.6
#define UIFontWeightLight -0.4
#define UIFontWeightRegular 0
#define UIFontWeightMedium 0.23
#define UIFontWeightSemibold 0.3
#define UIFontWeightBold 0.4
#define UIFontWeightHeavy 0.56
#define UIFontWeightBlack 0.62

#endif

static NSCache *fontCache;

Expand Down Expand Up @@ -116,7 +98,7 @@ struct __attribute__((__packed__)) CacheKey {
addObserverForName:(NSNotificationName)kCTFontManagerRegisteredFontsChangedNotification
object:nil
queue:nil
usingBlock:^(NSNotification *) {
usingBlock:^(NSNotification *note) {
[cache removeAllObjects];
}];
});
Expand Down Expand Up @@ -277,7 +259,7 @@ + (UIFont *)updateFont:(UIFont *)font

// Gracefully handle being given a font name rather than font family, for
// example: "Helvetica Light Oblique" rather than just "Helvetica".
if (!didFindFont && familyName.length > 0 && fontNamesForFamilyName(familyName).count == 0) {
if (font && !didFindFont && familyName.length > 0 && fontNamesForFamilyName(familyName).count == 0) {
familyName = font.familyName;
fontWeight = weight ? fontWeight : weightOfFont(font);
isItalic = style ? isItalic : isItalicFont(font);
Expand Down Expand Up @@ -329,7 +311,7 @@ + (UIFont *)updateFont:(UIFont *)font
}

// Apply font variants to font object
if (variant) {
if (font && variant) {
NSArray *fontFeatures = [HippyConvert NativeRenderFontVariantDescriptorArray:variant];
UIFontDescriptor *fontDescriptor =
[font.fontDescriptor fontDescriptorByAddingAttributes:
Expand Down
2 changes: 1 addition & 1 deletion renderer/native/ios/renderer/NativeRenderManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#import "HippyUIManager.h"
#import "HippyUIManager+Private.h"
#import "NativeRenderManager.h"
#import "NativeRenderObjectText.h"
#import "HippyShadowText.h"
#import "RenderVsyncManager.h"
#import "HippyAssert.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
#import "HippyConvert+NativeRender.h"
#import "HippyShadowView.h"

typedef NS_ENUM(NSInteger, NativeRenderSizeComparison) {
NativeRenderSizeTooLarge,
NativeRenderSizeTooSmall,
NativeRenderSizeWithinRange,
typedef NS_ENUM(NSInteger, HippySizeComparison) {
HippySizeTooLarge,
HippySizeTooSmall,
HippySizeWithinRange,
};

namespace hippy {
Expand All @@ -36,16 +36,16 @@ struct LayoutSize;
}
}

extern NSAttributedStringKey const NativeRenderIsHighlightedAttributeName;
extern NSAttributedStringKey const NativeRenderComponentTagAttributeName;
extern NSAttributedStringKey const NativeRenderRenderObjectAttributeName;
extern NSAttributedStringKey const HippyIsHighlightedAttributeName;
extern NSAttributedStringKey const HippyTagAttributeName;
extern NSAttributedStringKey const HippyShadowViewAttributeName;

hippy::LayoutSize textMeasureFunc(float width, hippy::LayoutMeasureMode widthMeasureMode,
__unused float height,
__unused hippy::LayoutMeasureMode heightMeasureMode,
void *layoutContext);

@interface NativeRenderObjectText : HippyShadowView {
@interface HippyShadowText : HippyShadowView {
@protected
NSTextStorage *_cachedTextStorage;
CGFloat _cachedTextStorageWidth;
Expand Down Expand Up @@ -73,7 +73,7 @@ hippy::LayoutSize textMeasureFunc(float width, hippy::LayoutMeasureMode widthMea
@property (nonatomic, assign) NSTextAlignment textAlign;
@property (nonatomic, strong) UIColor *textDecorationColor;
@property (nonatomic, assign) NSUnderlineStyle textDecorationStyle;
@property (nonatomic, assign) NativeRenderTextDecorationLineType textDecorationLine;
@property (nonatomic, assign) HippyTextDecorationLineType textDecorationLine;
@property (nonatomic, assign) CGFloat fontSizeMultiplier;
@property (nonatomic, assign) BOOL allowFontScaling;
@property (nonatomic, assign) CGFloat opacity;
Expand All @@ -90,7 +90,7 @@ hippy::LayoutSize textMeasureFunc(float width, hippy::LayoutMeasureMode widthMea
@end

/// Style information passed when generating attributedString
@interface NativeRenderAttributedStringStyleInfo : NSObject
@interface HippyAttributedStringStyleInfo : NSObject

@property (nonatomic, strong) NSString *fontFamily;
@property (nonatomic, strong) NSNumber *fontSize;
Expand Down
Loading

0 comments on commit a1cba87

Please sign in to comment.