Skip to content

Commit

Permalink
Font Style configuration to Terminal
Browse files Browse the repository at this point in the history
Apply Font Style settings.
  • Loading branch information
Carlos Cabanero committed Sep 10, 2016
1 parent 340ffcc commit 895274a
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 6 deletions.
4 changes: 4 additions & 0 deletions Blink.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
07F670771D05EEE200C0A53C /* SSHSession.m in Sources */ = {isa = PBXBuildFile; fileRef = 07F670701D05EEE200C0A53C /* SSHSession.m */; };
C94437571D8311960096F84E /* BKResource.m in Sources */ = {isa = PBXBuildFile; fileRef = C94437561D8311960096F84E /* BKResource.m */; };
C94437601D831CD30096F84E /* Themes in Resources */ = {isa = PBXBuildFile; fileRef = C944375F1D831CD30096F84E /* Themes */; };
C94437651D838ABF0096F84E /* Fonts in Resources */ = {isa = PBXBuildFile; fileRef = C94437641D838ABF0096F84E /* Fonts */; };
C9472D561D74E9BA001B6022 /* BKKeyboardFuncTriggersViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C9472D551D74E9BA001B6022 /* BKKeyboardFuncTriggersViewController.m */; };
C94E9B631D6BA21C00DA4DD6 /* DismissSegue.m in Sources */ = {isa = PBXBuildFile; fileRef = C94E9B621D6BA21C00DA4DD6 /* DismissSegue.m */; };
C989E54A1D6CC488003E0079 /* BKHostsDetailViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C989E53D1D6CC488003E0079 /* BKHostsDetailViewController.m */; };
Expand Down Expand Up @@ -213,6 +214,7 @@
C94437551D8311960096F84E /* BKResource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BKResource.h; sourceTree = "<group>"; };
C94437561D8311960096F84E /* BKResource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BKResource.m; sourceTree = "<group>"; };
C944375F1D831CD30096F84E /* Themes */ = {isa = PBXFileReference; lastKnownFileType = folder; path = Themes; sourceTree = "<group>"; };
C94437641D838ABF0096F84E /* Fonts */ = {isa = PBXFileReference; lastKnownFileType = folder; path = Fonts; sourceTree = "<group>"; };
C9472D541D74E9BA001B6022 /* BKKeyboardFuncTriggersViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BKKeyboardFuncTriggersViewController.h; sourceTree = "<group>"; };
C9472D551D74E9BA001B6022 /* BKKeyboardFuncTriggersViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BKKeyboardFuncTriggersViewController.m; sourceTree = "<group>"; };
C94E9B611D6BA21C00DA4DD6 /* DismissSegue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DismissSegue.h; path = ViewControllers/DismissSegue.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -330,6 +332,7 @@
0732F0481D062B9A00AB5438 /* Resources */ = {
isa = PBXGroup;
children = (
C94437641D838ABF0096F84E /* Fonts */,
C944375F1D831CD30096F84E /* Themes */,
0759A8641D6361D1009CF12F /* HockeySDKResources.bundle */,
070058EB1D12FA6D00D133E3 /* termcontrol.js */,
Expand Down Expand Up @@ -704,6 +707,7 @@
0732F04D1D062B9A00AB5438 /* locales.bundle in Resources */,
074F307B1D062A3F00A73445 /* SmartKeys.xib in Resources */,
0716B5741CFFAB9300268B5B /* LaunchScreen.storyboard in Resources */,
C94437651D838ABF0096F84E /* Fonts in Resources */,
0759A8651D6361D1009CF12F /* HockeySDKResources.bundle in Resources */,
0716B5751CFFAB9300268B5B /* Main.storyboard in Resources */,
0732F04C1D062B9A00AB5438 /* hterm_all.js in Resources */,
Expand Down
2 changes: 1 addition & 1 deletion Blink/TermController.m
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ - (void)setAppearanceFromSettings

BKFont *font = [BKFont withName:[BKDefaults selectedFontName]];
if (font) {
[_terminal loadTerminalFontCSS:font.fullPath];
[_terminal loadTerminalFont:font.name fromCSS:font.fullPath];
}

if (!_disableFontSizeSelection) {
Expand Down
3 changes: 2 additions & 1 deletion Blink/TermView.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,6 @@ extern NSString * const TermViewFFuncSeq;
- (void)assignKey:(NSString *)key toModifier:(UIKeyModifierFlags)modifier;
- (void)assignFunction:(NSString *)function toTriggers:(UIKeyModifierFlags)triggers;
- (void)loadTerminalThemeJS:(NSString *)themeContent;
- (void)loadTerminalFontCSS:(NSString *)cssPath;
- (void)loadTerminalFont:(NSString *)familyName fromCSS:(NSString *)cssPath;

@end
4 changes: 2 additions & 2 deletions Blink/TermView.m
Original file line number Diff line number Diff line change
Expand Up @@ -547,9 +547,9 @@ - (void)loadTerminalThemeJS:(NSString *)themeContent
[_webView evaluateJavaScript:themeContent completionHandler:nil];
}

- (void)loadTerminalFontCSS:(NSString *)cssPath
- (void)loadTerminalFont:(NSString *)familyName fromCSS:(NSString *)cssPath
{
[_webView evaluateJavaScript:[NSString stringWithFormat:@"loadFontFromCSS(%@);", cssPath] completionHandler:nil];
[_webView evaluateJavaScript:[NSString stringWithFormat:@"loadFontFromCSS(\"%@\", \"%@\");", cssPath, familyName] completionHandler:nil];
}

#pragma mark External Keyboard
Expand Down
4 changes: 4 additions & 0 deletions Resources/Fonts/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore
1 change: 1 addition & 0 deletions Resources/term.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<meta charset="utf-8" />
<meta name = "viewport" content = "user-scalable=no, height=device-height, initial-scale=1.0">
<script src="hterm_all.js"></script>
<script src="webfont.js"></script>
<script src="termcontrol.js"></script>
<style>
body {
Expand Down
12 changes: 10 additions & 2 deletions Resources/termcontrol.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ var setWidth = function(columnCount) {
t.setWidth(columnCount);
}

var loadFontFromCSS = function(cssPath) {

var loadFontFromCSS = function(cssPath, name) {
WebFont.load({
custom: {
families: [name],
urls: [cssPath]
},
context: t.scrollPort_.iframe_.contentWindow,
active: function() { t.syncFontFamily() }
});
t.prefs_.set('font-family', name);
}

0 comments on commit 895274a

Please sign in to comment.