Skip to content

Commit

Permalink
feat: customize the font size (#268)
Browse files Browse the repository at this point in the history
* add change font size function

* remove debug log

* Fix label font size hasn't been customised

* perf: adjust the range of custom font sizes

* perf: add property fontSizeRatio

* perf: rename currentFontSizeRatio to fontSizeRatio

* fix: font for pos meaning do not need bold

* fix: font for service name do not need to customzie

* perf: update Localizable.xcstrings

* added drag gesture to customize the font size, fixed the missing buoy in some cases.

* feat: make webView iframe font size follow user custom font size

* Add keyboard shortcuts to customise font size

* perf: adaptive big word title and details summary title font size

* perf: rename Shortcut to Shortcuts

* add the hints view for the keyboard shortcuts of change font size

* perf: update Localizable.xcstrings

* perf(UI): adjust change font size view UI

* chore: add library Hue for color extension

* perf(UI): adjust change font size view color

* perf(UI): adjust change font size view UI

---------

Co-authored-by: tisfeng <[email protected]>
  • Loading branch information
NeverAgain11 and tisfeng authored Dec 22, 2023
1 parent 12a8768 commit a930ec4
Show file tree
Hide file tree
Showing 21 changed files with 634 additions and 64 deletions.
33 changes: 33 additions & 0 deletions Easydict.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
03008B2B2940D3230062B821 /* EZDeepLTranslate.m in Sources */ = {isa = PBXBuildFile; fileRef = 03008B2A2940D3230062B821 /* EZDeepLTranslate.m */; };
03008B2E2941956D0062B821 /* EZURLSchemeHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 03008B2D2941956D0062B821 /* EZURLSchemeHandler.m */; };
03008B3F29444B0A0062B821 /* NSView+EZAnimatedHidden.m in Sources */ = {isa = PBXBuildFile; fileRef = 03008B3E29444B0A0062B821 /* NSView+EZAnimatedHidden.m */; };
03022F1C2B35DEBA00B63209 /* Hue in Frameworks */ = {isa = PBXBuildFile; productRef = 03022F1B2B35DEBA00B63209 /* Hue */; };
030570E22ADB919900C9905E /* EZAppleScriptManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 030570E12ADB919900C9905E /* EZAppleScriptManager.m */; };
0309E1ED292B439A00AFB76A /* EZTextView.m in Sources */ = {isa = PBXBuildFile; fileRef = 0309E1EC292B439A00AFB76A /* EZTextView.m */; };
0309E1F0292B4A5E00AFB76A /* NSView+EZGetViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 0309E1EF292B4A5E00AFB76A /* NSView+EZGetViewController.m */; };
Expand Down Expand Up @@ -229,6 +230,8 @@
C4DD01ED2B12BE9B0025EE8E /* TencentTranslateType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4DD01EC2B12BE9B0025EE8E /* TencentTranslateType.swift */; };
C4DE3D6D2AC00EB500C2B85D /* Localizable.xcstrings in Resources */ = {isa = PBXBuildFile; fileRef = C4DE3D6C2AC00EB500C2B85D /* Localizable.xcstrings */; };
C98CAE75239F4619005F7DCA /* EasydictHelper.app in CopyFiles */ = {isa = PBXBuildFile; fileRef = C90BE309239F38EB00ADE88B /* EasydictHelper.app */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
DC3C643F2B187119008EEDD8 /* ChangeFontSizeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC3C643E2B187119008EEDD8 /* ChangeFontSizeView.swift */; };
DC6D9C872B352EBC0055EFFC /* FontSizeHintView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC6D9C862B352EBC0055EFFC /* FontSizeHintView.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -676,6 +679,8 @@
C4DE3D6E2AC00EB500C2B85D /* mul */ = {isa = PBXFileReference; lastKnownFileType = text.json.xcstrings; name = mul; path = mul.lproj/Main.xcstrings; sourceTree = "<group>"; };
C90BE309239F38EB00ADE88B /* EasydictHelper.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = EasydictHelper.app; sourceTree = BUILT_PRODUCTS_DIR; };
C99EEB182385796700FEE666 /* Easydict-debug.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Easydict-debug.app"; sourceTree = BUILT_PRODUCTS_DIR; };
DC3C643E2B187119008EEDD8 /* ChangeFontSizeView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChangeFontSizeView.swift; sourceTree = "<group>"; };
DC6D9C862B352EBC0055EFFC /* FontSizeHintView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FontSizeHintView.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand All @@ -701,6 +706,7 @@
2721E4D02AFE920700A059AC /* Alamofire in Frameworks */,
03FD68BB2B1DC59600FD388E /* CryptoSwift in Frameworks */,
B87AC7E36367075BA5D13234 /* Pods_Easydict.framework in Frameworks */,
03022F1C2B35DEBA00B63209 /* Hue in Frameworks */,
03B63ABF2A86967800E155ED /* CoreServices.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -1274,6 +1280,7 @@
isa = PBXGroup;
children = (
62ED299F2B15F1BE00901F51 /* EZWrapView */,
DC3C643D2B18710D008EEDD8 /* ChangeFontSizeView */,
03E3E7BF2ADE313400812C84 /* EZQueryMenuTextView */,
03DC7C632A3CA465000BF7C9 /* EZSegmentedControl */,
03247E37296AE8C800AFCD67 /* LoadingAnimationView */,
Expand Down Expand Up @@ -1983,6 +1990,15 @@
name = Products;
sourceTree = "<group>";
};
DC3C643D2B18710D008EEDD8 /* ChangeFontSizeView */ = {
isa = PBXGroup;
children = (
DC3C643E2B187119008EEDD8 /* ChangeFontSizeView.swift */,
DC6D9C862B352EBC0055EFFC /* FontSizeHintView.swift */,
);
path = ChangeFontSizeView;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down Expand Up @@ -2043,6 +2059,7 @@
packageProductDependencies = (
2721E4CF2AFE920700A059AC /* Alamofire */,
03FD68BA2B1DC59600FD388E /* CryptoSwift */,
03022F1B2B35DEBA00B63209 /* Hue */,
);
productName = Bob;
productReference = C99EEB182385796700FEE666 /* Easydict-debug.app */;
Expand Down Expand Up @@ -2085,6 +2102,7 @@
packageReferences = (
2721E4CE2AFE920700A059AC /* XCRemoteSwiftPackageReference "Alamofire" */,
03FD68B92B1DC59600FD388E /* XCRemoteSwiftPackageReference "CryptoSwift" */,
03022F1A2B35DEBA00B63209 /* XCRemoteSwiftPackageReference "Hue" */,
);
productRefGroup = C99EEB192385796700FEE666 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -2396,6 +2414,7 @@
039D119929D5E26300C93F46 /* EZAudioUtils.m in Sources */,
03B0231729231FA6001C7E63 /* Snip.m in Sources */,
03BFFC6E295FE59C004E033E /* EZQueryResult+EZYoudaoDictModel.m in Sources */,
DC3C643F2B187119008EEDD8 /* ChangeFontSizeView.swift in Sources */,
03B0232829231FA6001C7E63 /* NSTextView+Height.m in Sources */,
03B0232129231FA6001C7E63 /* NSPasteboard+MM.m in Sources */,
03D043522928935300E7559E /* EZMainQueryWindow.m in Sources */,
Expand Down Expand Up @@ -2441,6 +2460,7 @@
03D8A6592A42A1A300D9A968 /* EZAppModel.m in Sources */,
036E7D7B293F4FC8002675DF /* EZOpenLinkButton.m in Sources */,
03008B2E2941956D0062B821 /* EZURLSchemeHandler.m in Sources */,
DC6D9C872B352EBC0055EFFC /* FontSizeHintView.swift in Sources */,
03B0232429231FA6001C7E63 /* NSUserDefaults+MM.m in Sources */,
03542A5E2938F05B00C34C33 /* EZLanguageModel.m in Sources */,
03F639952AA6CFBB009B9914 /* EZBingConfig.m in Sources */,
Expand Down Expand Up @@ -2839,6 +2859,14 @@
/* End XCConfigurationList section */

/* Begin XCRemoteSwiftPackageReference section */
03022F1A2B35DEBA00B63209 /* XCRemoteSwiftPackageReference "Hue" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/zenangst/Hue";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 5.0.1;
};
};
03FD68B92B1DC59600FD388E /* XCRemoteSwiftPackageReference "CryptoSwift" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/krzyzanowskim/CryptoSwift";
Expand All @@ -2858,6 +2886,11 @@
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
03022F1B2B35DEBA00B63209 /* Hue */ = {
isa = XCSwiftPackageProductDependency;
package = 03022F1A2B35DEBA00B63209 /* XCRemoteSwiftPackageReference "Hue" */;
productName = Hue;
};
03FD68BA2B1DC59600FD388E /* CryptoSwift */ = {
isa = XCSwiftPackageProductDependency;
package = 03FD68B92B1DC59600FD388E /* XCRemoteSwiftPackageReference "CryptoSwift" */;
Expand Down
9 changes: 9 additions & 0 deletions Easydict.xcworkspace/xcshareddata/swiftpm/Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@
"revision" : "db51c407d3be4a051484a141bf0bff36c43d3b1e",
"version" : "1.8.0"
}
},
{
"identity" : "hue",
"kind" : "remoteSourceControl",
"location" : "https://github.com/zenangst/Hue",
"state" : {
"revision" : "b9d920cee4ba795fefb828d130744eee1e3d2feb",
"version" : "5.0.1"
}
}
],
"version" : 2
Expand Down
18 changes: 14 additions & 4 deletions Easydict/App/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="22155" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="22505" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22155"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22505"/>
</dependencies>
<scenes>
<!--Application-->
Expand Down Expand Up @@ -308,9 +308,9 @@
</items>
</menu>
</menuItem>
<menuItem title="Shortcut" id="YF0-bI-c58">
<menuItem title="Shortcuts" id="YF0-bI-c58">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="Shortcut" id="eIi-Yp-9Iw">
<menu key="submenu" title="Shortcuts" id="eIi-Yp-9Iw">
<items>
<menuItem title="Clear Input" keyEquivalent="k" id="rr4-Iy-d6B" userLabel="Clear Input">
<connections>
Expand Down Expand Up @@ -363,6 +363,16 @@
<action selector="closeWindowAction:" target="qM9-fT-Fym" id="ds1-Hv-m1x"/>
</connections>
</menuItem>
<menuItem title="Increase Font Size" keyEquivalent="+" id="525-TU-MBZ">
<connections>
<action selector="increaseFontSizeAction:" target="qM9-fT-Fym" id="qRl-Vd-x3P"/>
</connections>
</menuItem>
<menuItem title="Decrease Font Size" keyEquivalent="-" id="K7d-rE-hVh">
<connections>
<action selector="decreaseFontSizeAction:" target="qM9-fT-Fym" id="B0U-RG-Wrn"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="QNI-LF-G6c"/>
<menuItem title="Google" toolTip="Open in Google" id="qiF-2J-X2C" userLabel="Google">
<string key="keyEquivalent" base64-UTF8="YES">
Expand Down
68 changes: 68 additions & 0 deletions Easydict/App/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -1050,6 +1050,23 @@
}
}
},
"font_size" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Font Size:"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "字体大小:"
}
}
}
},
"force_auto_get_selected_text" : {
"localizations" : {
"en" : {
Expand Down Expand Up @@ -1199,6 +1216,23 @@
}
}
},
"hints_keyboard_shortcuts_font_size" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Font size can be changed using the ⌘ +/- shortcut in the Translation windows."
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "支持在翻译窗口通过快捷键 ⌘ +/- 修改字体大小"
}
}
}
},
"Illegal parameter supplied to encryption/decryption algorithm" : {
"comment" : "Error reason",
"localizations" : {
Expand Down Expand Up @@ -1339,6 +1373,23 @@
}
}
},
"large" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Large"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "大"
}
}
}
},
"lastest_version" : {
"localizations" : {
"en" : {
Expand Down Expand Up @@ -2115,6 +2166,23 @@
}
}
},
"small" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Small"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "小"
}
}
}
},
"snip_translate" : {
"localizations" : {
"en" : {
Expand Down
36 changes: 30 additions & 6 deletions Easydict/App/mul.lproj/Main.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,18 @@
}
}
},
"525-TU-MBZ.title" : {
"comment" : "Class = \"NSMenuItem\"; title = \"Increase Font Size\"; ObjectID = \"525-TU-MBZ\";",
"extractionState" : "extracted_with_value",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "Increase Font Size"
}
}
}
},
"a4o-M9-LLq.title" : {
"comment" : "Class = \"NSMenuItem\"; title = \"Paste Ruler\"; ObjectID = \"a4o-M9-LLq\";",
"extractionState" : "extracted_with_value",
Expand Down Expand Up @@ -958,19 +970,19 @@
}
},
"eIi-Yp-9Iw.title" : {
"comment" : "Class = \"NSMenu\"; title = \"Shortcut\"; ObjectID = \"eIi-Yp-9Iw\";",
"comment" : "Class = \"NSMenu\"; title = \"Shortcuts\"; ObjectID = \"eIi-Yp-9Iw\";",
"extractionState" : "extracted_with_value",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "Shortcut"
"value" : "Shortcuts"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "Shortcut"
"value" : "Shortcuts"
}
}
}
Expand Down Expand Up @@ -1475,6 +1487,18 @@
}
}
},
"K7d-rE-hVh.title" : {
"comment" : "Class = \"NSMenuItem\"; title = \"Decrease Font Size\"; ObjectID = \"K7d-rE-hVh\";",
"extractionState" : "extracted_with_value",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "Decrease Font Size"
}
}
}
},
"KbN-5H-9z5.ibShadowedToolTip" : {
"comment" : "Class = \"NSMenuItem\"; ibShadowedToolTip = \"Open in Eudic\"; ObjectID = \"KbN-5H-9z5\";",
"extractionState" : "extracted_with_value",
Expand Down Expand Up @@ -2816,19 +2840,19 @@
}
},
"YF0-bI-c58.title" : {
"comment" : "Class = \"NSMenuItem\"; title = \"Shortcut\"; ObjectID = \"YF0-bI-c58\";",
"comment" : "Class = \"NSMenuItem\"; title = \"Shortcuts\"; ObjectID = \"YF0-bI-c58\";",
"extractionState" : "extracted_with_value",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "Shortcut"
"value" : "Shortcuts"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "Shortcut"
"value" : "Shortcuts"
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions Easydict/Feature/Configuration/EZConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ NS_ASSUME_NONNULL_BEGIN

static NSString *const EZQuickLinkButtonUpdateNotification = @"EZQuickLinkButtonUpdateNotification";

static NSString *const EZFontSizeUpdateNotification = @"EZFontSizeUpdateNotification";

static NSString *const EZIntelligentQueryModeKey = @"IntelligentQueryMode";

typedef NS_ENUM(NSUInteger, EZLanguageDetectOptimize) {
Expand Down Expand Up @@ -63,6 +65,9 @@ typedef NS_ENUM(NSUInteger, EZLanguageDetectOptimize) {
@property (nonatomic, assign) BOOL disabledAutoSelect;
@property (nonatomic, assign) BOOL isRecordingSelectTextShortcutKey;

@property (nonatomic, copy) NSArray <NSNumber *>*fontSizes;
@property (nonatomic, assign, readonly) CGFloat fontSizeRatio;
@property (nonatomic, assign) NSInteger fontSizeIndex;

+ (instancetype)shared;
+ (void)destroySharedInstance;
Expand Down
Loading

0 comments on commit a930ec4

Please sign in to comment.