Skip to content

Commit

Permalink
Merge branch 'main' into fix/upgrade_3.0_guidelines
Browse files Browse the repository at this point in the history
  • Loading branch information
siguangli authored Jun 14, 2024
2 parents 2815762 + b6697c5 commit 2ee6763
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
2 changes: 1 addition & 1 deletion driver/js/packages/hippy-vue-native-components/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Hippy Vue Native Components

> The package contains the **Native only** components provide by Hippy.
> The package contains the **Native only** components provided by Hippy.
> For web alternative could use `hippy-vue-web-components`(it's not exist yet).
![Hippy Group](https://img.shields.io/badge/group-Hippy-blue.svg)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,23 +185,30 @@ - (HippyShadowView *)shadowView {
}

HIPPY_CUSTOM_SHADOW_PROPERTY(fontFamily, NSString, HippyShadowTextView) {
view.font = [HippyFont updateFont:view.font withFamily:json];
// Convert fontName to fontFamily if needed
NSString *familyName = [self familyNameWithCSSNameMatching:json];
view.font = [HippyFont updateFont:view.font withFamily:familyName];
}

HIPPY_CUSTOM_VIEW_PROPERTY(fontSize, NSNumber, HippyBaseTextInput) {
UIFont *theFont = [HippyFont updateFont:view.font withSize:json ?: @(defaultView.font.pointSize)];
view.font = theFont;
}

HIPPY_CUSTOM_VIEW_PROPERTY(fontWeight, NSString, __unused HippyBaseTextInput) {
UIFont *theFont = [HippyFont updateFont:view.font withWeight:json]; // defaults to normal
view.font = theFont;
}

HIPPY_CUSTOM_VIEW_PROPERTY(fontStyle, NSString, __unused HippyBaseTextInput) {
UIFont *theFont = [HippyFont updateFont:view.font withStyle:json];
view.font = theFont; // defaults to normal
}

HIPPY_CUSTOM_VIEW_PROPERTY(fontFamily, NSString, HippyBaseTextInput) {
view.font = [HippyFont updateFont:view.font withFamily:json ?: defaultView.font.familyName];
// Convert fontName to fontFamily if needed
NSString *familyName = [self familyNameWithCSSNameMatching:json];
view.font = [HippyFont updateFont:view.font withFamily:familyName ?: defaultView.font.familyName];
}

- (HippyViewManagerUIBlock)uiBlockToAmendWithShadowView:(HippyShadowView *)hippyShadowView {
Expand All @@ -211,4 +218,24 @@ - (HippyViewManagerUIBlock)uiBlockToAmendWithShadowView:(HippyShadowView *)hippy
viewRegistry[componentTag].contentInset = padding;
};
}


#pragma mark - Private

/// Get the
/// JS side usually pass a `fontName` instead of `fontFamily`
/// - Parameter json: id
- (NSString *)familyNameWithCSSNameMatching:(id)json {
NSString *familyName = json;
if (json && ![[UIFont familyNames] containsObject:json]) {
// Not a real FamilyName
// Using CSS name matching semantics.
// fontSize here is just a placeholder for getting font.
UIFont *cssFont = [UIFont fontWithName:json size:14.0];
familyName = cssFont.familyName;
}
return familyName;
}


@end

0 comments on commit 2ee6763

Please sign in to comment.