Related
I wanted to use a custom font in my react-native project, but I got an error on ios simulator
How can I solve it
I tried every way but I couldn't find a solution.
Unrecognized Font Family: sfproregular
Error: Error Screenshot
Project Structure:
Project structure screenshot
react-native.config.js
module.exports = {
project: {
ios: {},
android: {}, // grouped into "project"
},
assets: ["./assets/fonts/"], // stays the same
};
versions
"react": "16.13.1",
"react-native": "0.63.2",
"react-native-gesture-handler": "^1.7.0",
"react-native-phone-input": "^0.2.4",
"react-navigation": "^4.4.0"
I wanted to use the font in "Welcome.js"
Welcome.js
import React from 'react';
import {
SafeAreaView,
StyleSheet,
ScrollView,
View,
Text,
Image,
StatusBar,
TouchableOpacity,
Button,
ImageBackground,
} from 'react-native';
import Logo from '../components/WelcomeLogo';
import arkaplan from '../assets/images/arkaplan.png';
export default class Welcome extends React.Component {
render() {
return (
<>
<ImageBackground source={arkaplan} style={styles.constrain} >
<StatusBar barStyle="light-content"/>
<Logo />
<Text style={styles.welcome} >Welcome!</Text>
</View>
</>
)
}
};
const styles = StyleSheet.create({
constrain: {
flex: 1,
alignItems:'center',
justifyContent:'center',
welcome: {
fontSize: 50,
color: 'white',
fontFamily: 'sfprogregular',
marginTop: 20,
marginBottom: 5,
},
});
Much like you I experienced this Unrecognized Font family issue when running the iOS build via Terminal. For whatever reason, it doesn't effect the final archive build or if one runs the build via Xcode. This is on the latest RN 0.63.3 in macOS Catalina 10.15.7 with Xcode 12.0.1.
The issue was with the font name itself.
Solution Summary
In your case, I recommend the following steps to take.
Install your font sfprogregular on your macOS system
With the font installed, and selected in Font Book press CMD+I to see postscript name
Rename the font files in your project to their respective PostScript names
Run npx react-native link in your project to setup the renamed fonts
Do cleanup of the older font files prior to the rename (remove old fonts)
Change the name of the font to the postscript name in code when referring to the font in styles
My experience detailed
In my case, we are using TradeGothic.
Initially, when we linked the font, the name of the font file itself was:
Trade Gothic LT.ttf
Android is fine with this, but not iOS. That's because Android relies on the filename, but iOS depends on the PostScript name of the font.
To fix this, I renamed the ttf file to it's postscript name TradeGothicLT.ttf. For the bold one which was Trade Gothic LT Bold.ttf I renamed it to TradeGothicLT-Bold.ttf.
I then did npx react-native link inside my project to connect my newly renamed fonts. Then, I cleaned up by removing the older .ttf files from the XCode project under resources (just press delete on each of the red font files that are no longer there) and removed the font files from the older Android link process in the folder /android/app/src/main/assets/fonts/. In the info.plist file, under the section UIAppFonts remove the older font filenames.
Finally in code, instead of referring to 'Trade Gothic LT' we now refer to it as 'TradeGothicLT'. That's it, it works now!
You can find the postscript name of the font by installing the .ttf file (double click it) on macOS and in Font Book with the font selected press CMD+I to get information about the font.
NOTE: It's not necessary to install the font to macOS, it's just the only way I know of to get the PostScript name. If you already have the PostScript name of the fonts, you don't need to install them.
I hope this helps you and others that might stumble upon this issue!
After adding the custom fonts, you need to link it using react-native link.
That will create an entry in Info.plist file (iOS) & android/src/main/assets/fonts/ directory (Android).
If the above command fails, you need to add those fonts manually in the android directory & plist file.
Sometimes your font name is not the same for Android and iOS (since iOS uses postscript name as fontFamily). In most cases, in android, the font is the same as the file, for example, I had this problem when using HelveticaNeueLTPro-BdEx font in iOS.
I am sharing the fix that helps me out.
Run npx react-native link. Maybe you already did.
Add this inside the didFinishLaunchingWithOptions method on your AppDelegate.m:
for (NSString *familyName in [UIFont familyNames]){
NSLog(#"Family name: %#", familyName);
for (NSString *fontName in [UIFont fontNamesForFamilyName:familyName]) {
NSLog(#"--Font name: %#", fontName);
}
}
Then, when you launch your app with xcode, you will be able to see all the fonts installed on your app, so you just have to use it the way it is listed on your console:
You can add fontFamily based on OS like:
Platform.OS == 'android' ? 'Linotype - HelveticaNeueLTPro-BlkEx' : 'HelveticaNeueLTPro-BlkEx'
Or you can rename the font file name and then run npx react-native link again and also maybe have to delete the previous UIAppFonts entry for the previously linked font in Info.plist file.
In Visual Studio Code Ctrl+V is not working on editor.
However from the command palette Ctrl+Shift+V is working.
I´ve had this problem when I enabled the "VIM" plugin for VSCode.
After uninstalling it, the problem was fixed.
Open the keyboard shortcuts preferences by pressing CTRL + SHIFT + P and search for open keyboard shortcuts file.
Then, search for the editor.action.clipboardPasteAction property. In your case, it might be CTRL+SHIFT+V. Try changing it to Ctrl + V. Like so:
Solution as of 2022
You could also CTRL + SHIFT + P and search for open keyboard shortcuts (JSON) and paste the following:
// Place your key bindings in this file to override the defaults
[
{
"key": "ctrl+v",
"command": "-workbench.action.terminal.sendSequence",
"when": "terminalFocus && !accessibilityModeEnabled && terminalShellType == 'pwsh'"
},
{
"key": "ctrl+k",
"command": "workbench.action.terminal.clear"
}
]
#WebD'is answer is very helpful and I have upvoted it. But my comment focused on whether there was a conflicting binding for CTRL-V and how to find it. You can literally type "Ctrl+V" (note the "plus+" sign, not a hyphen) and it will find all keybindings that use that binding in whole or part. I suggest that there must be a something else also bound to CTRL-V.
Since this original answer, vscode introduced another way to see what other commands might be bound to given keystrokes. With the Gear/Keyboard Shortcuts file open click on the little keyboardy icon to the right (or Alt+K with this file open) and it will indicate Recording Keys next to it. Now you can literally press Ctrl+V (or whichever keybinding you are interested in) and those corresponding commands, if any, that use that keybinding will be filtered up.
Remember to disable the Recording Keys functionality by clicking the keyboardy icon if you want to go back to regular searching in the Keyboard Shortcuts file.
I have the same problem: can't CTRL+X, CTRL+C, CTRL+V on VSCode editor.
I uninstall the Vim extension and the problem is fixed.
If you install the vim extension for visual studio code and find that ctrl + x, ctrl + v .. or other shortcuts stopped working, this is because they are overwritten by extension.vim_
If you prefer to get those shortcuts back go to keyboard shortcuts (ctrl + shift + p, then search for open keyboard shortcuts file).
Search for extension.vim_ and check too see if any shortcuts are
assigned to your key combination like ctrl + v. Remove it (right click, delete).
Also check for any other conflict by searching the file.
Save the file, it should work now.
For future searchers who do not have Vim (or any other extension) installed which is causing the issue, and who might have verified that their keyboard bindings are correct....
I have the Salesforce Extension Pack installed and had right-clicked on a file and run SFDX: Deploy Source to Org. The deployment had errors, so in the Panel area (which I have at the bottom of my screen) [see image] I had clicked on both the OUTPUT and PROBLEMS tabs, which shifted focus away from my PowerShell TERMINAL tab.
My Ctrl-V issue was when I was trying to correct my Apex code in the EDITOR pane. Ctrl-V was not pasting the code I had just Cut or Copied (but right-clicking and choosing Paste was working).
I ultimately discovered, when I changed my Panel focus back to my PowerShell TERMINAL tab, that ALL of the Ctrl-V pasting I had attempted had shown up after my PowerShell prompt! ["circled" in blue in image]
tl;dr
Make sure your pasted text did not show up in your TERMINAL - even if it is not in focus or even if your cursor is in another Panel tab or in the EDITOR.
From File > Performance > Keyboard Shortcuts > search paste > just try to remove or rest some keybinding with right click on paste or default:paste
If you have the Vim extension installed, you may set the vim.useSystemClipboard in the vim extension setting to true. Then you can paste the content from the clipboard by simply pressing p in the NORMAL mode, or use Ctrl+V in the INSERT mode.
This problem happened to me after I left VSC update itself (currently 1.53.0). It had been converted to Shift-Insert.
Go to File->Preferences->Keyboard shortcuts. Find the editor.action.clipboardPasteAction and double click it, then type Ctrl+V.
+1 for this - in case this helps anyone:
In my case it was only happening in the Thunder Client extension's text fields.
The culprit for me was the Indent on Paste extension (I'm on a Mac, so it was cmd+v instead of ctrl+v - but it fires the same event in VS Code).
I've left issue comments on the Thunder Client and Indent on Paste repos respectively, should anyone wish to add to those.
Look if and remove any VS Code extension :
for example - "Awesome Emacs Keymap" in my case, or any other keymaps installed.
i.e. : FILE/Preferences>/extensions and then look if any special keymap was installed
Modify the setting of vscode:
Settings - input:vim ctrl key - unselect: Enale some vim ctrl key commands that override otherwise common operations, like ctrl + c
go to extensions search Emacs keymap and uninstall it
There should something conflicting to your any previous keyboard shortcut
like in my case for Change All Occurrence: (Ctrl-C + Ctrl-A), vs code, confused with
Ctrl-C for a copy shortcut to this : (Ctrl-C + Ctrl-A), so I change this to (Shift-C + Shift-A), My Issue resolved.
Go to File>Preference>keyboard Shortcuts
Then Check for Copy and paste and enter the Ctrl+C and Ctrl+v shortcuts
Happy Coding ;)
None of the issues above solved this for me. I had a key binding Ctrl+C Ctrl+L. So when I pressed Ctrl+C it was in a state where it was waiting for the next key to be pressed and wouldn't do anything.
This showed up in the toolbar like so (an example):
This didn't come up in the list of keybindings when searching for Ctrl+C. So I found it be looking through the list.
Remove all cmd+v or in windows ctrl+v associated keybindings.
For me the solution was going through my extensions and disabling them one by one to find the culprit.
I had 'Paste and Indent' enabled which was messing up copying and pasting.
Just had to disable it and reload vs code.
Open Settings > keyboard shortcuts
Search for Ctrl + c
Delete the mapping for vim.
i have same problem
step:1
ctrl+shift+p
step:2 find
Open keyboard shortcuts
step:3
find paste
then you can see
editor.action.cliboardPasteAction
right click then changekeybinding if key wrong
or remove key if u found two same line(editor.action.cliboardPasteAction)
in my case is 2nd one(so i removed)
In some cases, if you use remote ssh connects to a remote server and code there, ctrl + V may not be useful because that your remote server has a high balance, you can try to uninstall some useless plugins in that remote server then reload vscode.
I have disabled all extensions, and VS Code hangs for a few seconds whenever I try to paste something. This occurs with Ctrl+V, Shift+Ins and also with right click + Paste.
It hangs, and then nothing happens.
[UPDATE]
I simply reinstalled it, and that solved the issue for me.
In my case just the relaunch of VSCode solved the issue. My key bindings were fine.
"Paste JSON as Code" was my offender, as well as a few other ones. I got a little extension happy there for a bit.
Its easy don't worry, you need to search using ctrl+shift+p and find Prefernces: Open Keyboard Shortcuts(JSON) and add this dict
// Place your key bindings in this file to override the defaults
[
{
"key": "ctrl+c",
"command": "editor.action.clipboardCopyAction",
"when": "textInputFocus"
}
]
I thins it's very helpfull good luck :)
Well I'm using Sublime Text 2 for a lot of tasks, included the creation of documents with LaTeX. I downloaded and installed the alignmentpackage and works great when I want to align respect the = symbol. But in LaTeX I need to align also with respect to & and sometimes % but I don't understand where or how can I custom that. I read the documentation about that package here, and now I see I must go to Preferences > Package Settings > Alignment > Settings – User but there the only I see is:
{
"color_scheme": "Packages/Color Scheme - Default/Monokai Bright.tmTheme",
"font_size": 12.0,
"ignored_packages":
[
"Vintage",
"PyV8"
]
}
And I don't know what exactly should I add, and if it's before close the {} o later opening a new pair. Could someone help me with that?
On my mac you would need to look at Alignment/Base File.sublime-settings
// The mid-line characters to align in a multi-line selection, changing
// this to an empty array will disable mid-line alignment
"alignment_chars": ["="],
Add the characters you want to align on either to this file, or create a user settings file as you indicated.
"alignment_chars": ["=", "%", "&"],
The contents of the file you listed is actually your user system preferences, not the user settings file for Alignment.
I would like to change the style for the default look of the Dart-plugin editor in eclipse IDE. For example I would like to change the colour of comments from green (default) to pale gray. How can I accomplish this in the Dart eclipse plugin. I see how it is done for Java, JavaScript etc but none for Dart.
I found a way to change the theme manually (the Dart plug-in doesn't have any option to change it automatically, and doesn't support other plug-ins like Eclipse Color Theme).
Depending on your OS, these steps might be different, but this worked for me on Linux.
From your Eclipse workspace directory, go to .metadata/.plugins/org.eclipse.core.runtime/.settings. There is a file named com.google.dart.tools.ui.prefs; open it with your preferred text editor.
In my case, I wanted to use the "Dartboard" theme included in Dart Editor. I copy-pasted the following from the same file in the Dart Editor workspace directory (on my system, found in ~/.dartEditor/.metadata/.plugins/org.eclipse.core.runtime/.settings) :
content_assist_completion_replacement_background=250,250,250
content_assist_completion_replacement_foreground=0,0,0
content_assist_parameters_background=250,250,250
content_assist_parameters_foreground=0,0,0
content_assist_proposals_background=250,250,250
content_assist_proposals_foreground=0,0,0
dart_bracket=96,96,96
dart_comment_task_tag=96,96,96
dart_default=0,0,0
dart_doc_default=96,96,96
dart_doc_keyword=96,96,96
dart_doc_link=96,96,96
dart_doc_tag=96,96,96
dart_keyword=0,0,0
dart_keyword_return=0,0,0
dart_multi_line_comment=96,96,96
dart_multiline_string=103,155,59
dart_operator=0,0,0
dart_single_line_comment=122,122,122
dart_string=103,155,59
glanceColorBackground=251,251,200
glanceSelectedColorBackground=182,214,253
pf_coloring_argument=0,0,0
pf_coloring_assignment=0,0,0
pf_coloring_comment=122,122,122
pf_coloring_key=0,0,0
pf_coloring_value=103,155,59
semanticHighlighting.annotation.color=0,0,0
semanticHighlighting.annotation.enabled=true
semanticHighlighting.builtin.bold=true
semanticHighlighting.builtin.color=0,0,0
semanticHighlighting.builtin.enabled=true
semanticHighlighting.class.color=6,70,167
semanticHighlighting.class.enabled=true
semanticHighlighting.constructor.color=6,70,167
semanticHighlighting.constructor.enabled=true
semanticHighlighting.deprecated.color=0,0,0
semanticHighlighting.deprecated.enabled=true
semanticHighlighting.directive.bold=true
semanticHighlighting.directive.color=1,77,100
semanticHighlighting.directive.enabled=true
semanticHighlighting.dynamicType.color=0,0,0
semanticHighlighting.dynamicType.enabled=true
semanticHighlighting.field.color=135,49,46
semanticHighlighting.field.enabled=true
semanticHighlighting.function.color=0,0,0
semanticHighlighting.function.enabled=true
semanticHighlighting.functionTypeAlias.color=6,70,167
semanticHighlighting.functionTypeAlias.enabled=true
semanticHighlighting.getterDeclaration.color=135,49,46
semanticHighlighting.getterDeclaration.enabled=true
semanticHighlighting.importPrefix.color=0,0,0
semanticHighlighting.importPrefix.enabled=true
semanticHighlighting.inheritedMethodInvocation.color=0,0,0
semanticHighlighting.inheritedMethodInvocation.enabled=true
semanticHighlighting.localVariable.color=0,0,0
semanticHighlighting.localVariable.enabled=true
semanticHighlighting.localVariableDeclaration.color=0,0,0
semanticHighlighting.localVariableDeclaration.enabled=true
semanticHighlighting.method.color=0,0,0
semanticHighlighting.method.enabled=true
semanticHighlighting.methodDeclarationName.bold=true
semanticHighlighting.methodDeclarationName.color=11,91,210
semanticHighlighting.methodDeclarationName.enabled=true
semanticHighlighting.number.color=0,0,0
semanticHighlighting.number.enabled=true
semanticHighlighting.parameterVariable.color=135,49,46
semanticHighlighting.parameterVariable.enabled=true
semanticHighlighting.setterDeclaration.color=135,49,46
semanticHighlighting.setterDeclaration.enabled=true
semanticHighlighting.staticField.color=135,49,46
semanticHighlighting.staticField.enabled=true
semanticHighlighting.staticFinalField.color=85,18,42
semanticHighlighting.staticFinalField.enabled=true
semanticHighlighting.staticMethod.color=0,0,0
semanticHighlighting.staticMethod.enabled=true
semanticHighlighting.staticMethodDeclarationName.bold=true
semanticHighlighting.staticMethodDeclarationName.color=11,91,210
semanticHighlighting.staticMethodDeclarationName.enabled=true
semanticHighlighting.typeArgument.color=3,49,120
semanticHighlighting.typeArgument.enabled=true
semanticHighlighting.typeParameter.color=3,49,120
semanticHighlighting.typeParameter.enabled=true
sourceHoverBackgroundColor=251,251,200
This will change the appearance of every Dart source file you open in Eclipse. Then, you can change the colors as you wish.
It's better than that eye-stinging and ugly purple default Eclipse theme... (in my opinion)
Based on this issue I'm guessing this probably isn't possible right now :-/
Having an issue trying to use an icon font for scalable icons in a RubyMotion (ios) app.
I created a small set of icons from icomoon, and set the characters to 'A', 'B', and 'C'.
I imported this into the Font Book and it appears to respect the 'A', 'B', and 'C' characters:
To test, I fired up a word document and typed 'A', 'B', and 'C' and it appears to display fine:
Now, onto the RubyMotion app - I included the font in /resources:
(Loading Lobster and Open Sans from sub-directories work)
Then I reference the font in my Rakefile:
Motion::Project::App.setup do |app|
# Use `rake config' to see complete project settings.
app.name = 'myapp'
app.fonts = ["OpenSans-Bold.ttf", "icomoon.ttf"]
end
In my controller, I add a label to the screen using the icomoon font:
#lblIcon = UILabel.alloc.initWithFrame([[0,0],[100,100]])
#lblIcon.text = "A"
#lblIcon.backgroundColor = UIColor.clearColor
#lblIcon.color = "#ffffff".to_color
ico_font = UIFont.fontWithName("icomoon", size:48)
#lblIcon.font = ico_font
self.view.addSubview #lblIcon
Now, when I run rake clean to force a refresh and rake to launch the simulator, the font doesn't seem to work:
If I use the RubyMotion inspector/REPL and drill down on the font, it say it is loading Helvetica, not icomoon as I intended:
I'm at a loss here on why I can't apply the icomoon font family and helvetica appears instead.
Any suggestions or ideas?
I have added my fonts in the 'resources' folder and successfully using them directly without manipulating app.fonts:
b.titleLabel.font = UIFont.fontWithName('Entypo', size: barHeight*1.1)
(the font I'm using is called Entypo.ttf)
Otherwise, the code you've pasted looks ok to me.