File type associated icons package for flutter? - flutter

I have searched but can't find anything or don't know how to find this. Is there an existing flutter package that has icons for common file types? If I'm displaying a file list, I'd like to show associated icons for those files such as .txt, .exe, .jpg, and just about anything else you'd find on a desktop computer, if possible.
It may not be possible to get the actual associated icon. For instance, a .jpg could be associated with multiple apps but I'd be fine with just a generic .jpg file icon for this or any other file type. I just don't want to show the same material icon for every file.

Try this,
https://pub.dev/packages/file_icon
Please note that the package is not maintained.

Related

Flutter - Deformed/overflowing custom icons using FlutterIcon.com

I have a few custom icons (11 to be exact) that I added to my project using Flutter Icon. For most of these icons, everything is working as expected:
However, some of them just overflow out of their intended size, or are given a wrong size. No idea what the problem is, but here is how it looks like:
as you can see, the right side of the infinity loop is just hanging outside of its intended container (button). Also, if I try to be hacky and resize only the infinity icon, it appears to be offsetted to the right.
I can be hacky and create a custom size for the couple of troublesome icons, but I would like to know if there is something that I, or my designer (also me) can do to fix this properly.
Already Tried:
Converting to compound path.
Removing unnecessary tags such as <style> tags.
Using flutter_svg package. This works okay, but it seems to be less performant that the Flutter Icon method. My app has quite a few animations running at the same time, and animating a SvgPicture is a little bit janky.
So I haven't been able to find out why the problem is happening, but I found out how to fix it.
After uploading your custom icons' svg's into FlutterIcon you'll download a .zip file. This file contains a bunch of files, including a .ttf file, which is a font file that contains your icons. You will need to manipulate the symbols/icons in that file in order to fix the issue.
To modify the faulty symbols, you will need to download some font editing application. FontForge does the trick. Download it and open the .ttf file you got from FlutterIcon from it. Once you have it open, you'll see a window full of squares with Xs in them. These are the font's glyphs.
You now need to find the glyphs with your icons. To save yourself from a LOT of scrolling, you can go to Encoding -> Compact from the toolbar. This will hide all unused (empty) glyphs. You should now be able to see all your icons. You should have something like this:
Right click the symbol you want to fix, and click Transform.... You will then be prompted with a menu that will let you transform the symbol in anyway you want. Apply transforms on all your faulty icons until you are satisfied. Transform window looks like this:
Once you have finish all your modifications, got to File -> Generate Font.... Select the destination folder and the file name (make sure it has the same name as the .ttf file generated from FlutterIcons). Also make sure you the TrueType file type from the first dropdown menu:
Once you're done, click generate, and voila! Now you have the .ttf file with the correctly-shaped icons. If you still find that something is wrong with the icons, you can rinse and repeat this process until you're satisfied with the result.

Adding a custom font to macOS app using Swift

I followed a bunch of tutorials but it doesn’t work: I simply want to add a custom font to a macOS app.
What I tried essentially:
Added the .ttf font-files to my project: Target Membership is set and I also made sure that the files are copied using Copy Files within Bundle Phases. After compiling I can see that all files are within the Bundle. So that seems to work perfectly fine.
Info.plist: I added Fonts provided by application and created an item for every font-file I want to add (values like myFont.tff).
I made sure that I use the correct font name. I installed the fonts on my system and configured a Label with Interface Builder so that it uses the desired font. I printed it’s value print(myLabel.font.fontName).
Confusing: If the exactly same font-file I want to add to the app is installed in the systems Fontbook and activated, everything works well. When I deactivate it, it doesn’t work. For me that indicates that I am using the correct font name.
I found ATSApplicationFontsPath and tried to add it to the Info.plist, but neither using a path (recommended by the docs) or values like . (which seemed to work for some people out there) worked out.
Appreciate any help!
I had a hard time getting this to work based on the previous answers, so I decided to write up an answer myself. This is based on previous answers by #ixany and #rob-keniger.
Create a folder named Fonts
Add fonts to the Fonts folder. Uncheck Add to targets and check Copy items if needed.
Add Application fonts resource path to Info.plist and enter Fonts.
Go to Build Phases and create a New Copy Files Phase.
Set the Destinations to Resources and Subpath to Fonts. Then add your font files to the list.
I solved my problem by accident.
I noticed that within the Bundle files, my fonts were included twice: They were copied to the "Resources" directory as well as to the subpath I declared in the "Copy Files" Build Phases.
I removed the fonts from my project, added them again (without checking the "Target Membership") and added them in the Build Phases so they were copied just to the subpath. After that it worked.
Additional notes:
Turned out that Fonts provided by application is a iOS only property so it is not needed for an macOS implementation.
Also, ATSApplicationFontsPath does not need any slashes. For example: Fonts should work just fine.
I had a difficult time finding the correct names for .ttf font files and sometimes discovered some strange behaviour: NSFont picked randomly fonts (regular, medium, bold...) from a font family without any code changes. By using .otf files instead I could solve that too.
None of the above worked for me in Xcode 12 beta 1 running BigSur but these steps did.
Create a Fonts folder for organization.
Add your fonts to the project. Be sure to check the macOS target!
Set Application fonts resource path to "." (no quotes).
No need to edit build phases or anything else.
THe value ATSApplicationFontsPath (i.e. Application fonts resource path) is relative to the Resources folder of your app bundle.
To see where your fonts are copied to:
In Xcode, expand the Products section under Project Navigator and click Show in Finder
In Finder, Ctrl-click on your app and click Show Resource Contents. Browse to the Resources folder and find your fonts there.
Xcode 12 to add custom fonts you have to exclude extension name from the string provided.
i.e.
.font(.custom("your font name", size:xx)) // works every time
.font(.custom("your font name.extension",size:xx)) // always fails
same is not true with Xcode 11.xx there fontname.extension is working.

How to change an icon of the folder in VS code?

I use this plugin https://github.com/robertohuertasm/vscode-icons
It changes the icon of the files which is nice. I want to give an icon to a specific folder. Like a different icon to the folder which has all CSS files. I know icon of .css and CSS folder should not be the same so I want to have different icons for file and folder. The same I would like to have for javascript folder.
Not sure it's possible or not, though.
I just installed the vscode-extensions icon from the extension management panel in vscode and it already DOES have different icons for folders called CSS and .css files.
If you want to add your custom icons, there is currently no easy way to do this. Writing about per-rule theme overrides, #aeschli wrote that the team "currently has no plans to do this"
You can, however, fork whichever theme you like and add the custom mappings yourself and/or make a pull request against the original theme. The api describes in detail what to do, but in summary you would associate a folder name with an icon name and that icon name with an actual icon by modifying icons.json:
"iconDefinitions": {
"_my_folder": {
"iconPath": "./images/My_Folder_16x_.svg"
}
},
"folderNames": {
".vscode": "_my_folder",
},

localize many images in Xcode at once?

I have this project that i need to add a translation to. I already know how to add localisation to single image files, but there are 200+ images with text on it in that project. Do i really have to click one file at a time, "get info", click "add localisation" enter the Language and click OK for every file?
When i select multiple images the languages and do those steps the new language is not added :-/
Please someone have a way to save me from insanity ;-)
Thanks!
S
What I do is create my localizable directories (en.lproj, fr_FR.lproj, etc) then I will drag all the localizable images into their respective directories, then add all the new images to the Xcode project. Xcode is smart enough to realize that the same image name exists in multiple .lproj directories
So, to reiterate:
Create localizable directories (you can use Get Info->Make File Localizable then add localizations for all desired locales)
Copy images for each locale into their respective directories
Add all the images to the xcode project

Change order of images in icon file

Is there an app that can change the order of images inside an icon?
Thanks!
What you'll need to do that is a resource editor. A google search will reveal many free ones out there. The restorator is a great one, but not free and over-priced IMO.
Any decent resource editor will allow you to see icons in the exe or dll and save them or replace them. I don't know of any that will allow you to reorder them, but just about any out there would allow you to save the icons out and then replace them back in the exe/dll in whatever order you'd like.
The only resource editor I know of that will allow you to re-order the embedded icons including png compressed vista icons is Resource Tuner Console.
You can change the image order using Pixelformer (an icon/bitmap editor). Import the icon, reorder the images as you wish, then export it back.
Using a resource editor is not an easy way to do this because you have to edit both ICON and ICON GROUP and I tried to do this with Resource Hacker and could not do it.
I found Easy Icon Maker is able to rearrange the order of the icons properly... it's the only icon editor that I found with this option, and I tried about half a dozen. The editor itself is not nearly as good as IcoFX (http://portableapps.com/apps/graphics_pictures/icofx_portable)
Why would you want to do this? Well there are certain times when Windows will use the first icon file that matches the size, but this may not be the color-depth that you want... for instance if you are on an older machine like Windows 2000 that doesn't support Alpha Channels then putting these at the beginning of your ICO file will cause Windows 2000 to try to render it so it results in black dots all over the image.