How to use Material icons in Vaadin Flow (14.6) - google-material-icons

I'd like to use Material icons in a Vaadin 14.6 application. I found recipes for Lumo and Iron icons here (the default), but did not discover how to integrate Material icons.
How can that be accomplished?
NB: This component seems to be not usable for Vaadin 14.x

There are basically three approaches to this.
Easy approach
If you use only few icons. https://fonts.google.com/icons allows you to download each icon as svg or png file. So you can easily use those in Image component of Vaadin.
Light approach, use it as a font
There is training video at Vaadin's site which describes various things related to theming and styling of the app, at 19:30 timestamp there is a chapter about how to configure custom font:
https://vaadin.com/learn/training/v14-theming
Material icons are just a font, which you can include in your project.
Place the webfont files under e.g. "src/main/webapp/fonts/MaterialIcons" (note location is different if you have Spring Boot jar packaged project) and import the generated css
#StyleSheet("context://fonts/MaterialIcons/materialicons.css")
Where materialicons.css content is for example:
#font-face {
font-family: 'MaterialIcons';
font-style: normal;
font-weight: 400;
src: local('Material Icons'),
local('MaterialIcons-Regular'),
url(MaterialIcons-Regular.woff2) format('woff2'),
url(MaterialIcons-Regular.woff) format('woff'),
url(MaterialIcons-Regular.ttf) format('truetype');
}
The developer experience is not the nicest possible, as you need to use the icons by using character codes, like for example "search" icons seams to be "e8b6", etc. So set text content of a span or div and define css of the element to use the material font icon.
span.getElement().getStyles().set("font-family","MaterialIcons");
Create it as add-on package
This is worth of effort if you need to use many of the fonts in multiple projects.
There already exists add-on package for FontAwesome. This gives a good showcase how to built such add-ons. Replacing font resources is straightforward, more work is needed to generate the list of icon names for the enum, so that there is a more intuitive Java API to use the icons. There seems to be standard codepoints files for the font in https://github.com/google/material-design-icons/tree/master/font So similar script as in the FontAwesome add-on project can probably be used.
https://github.com/FlowingCode/FontAwesomeIronIconset

Related

Custom fonts FMX ios not working Delphi 11

With this Embarcadero tutorial on custom fonts we were enabled to use custom fonts on iOS and Android:
https://docwiki.embarcadero.com/RADStudio/Rio/en/Creating_an_iOS_App#Using_Custom_Fonts_in_iOS_Apps
With new projects we cannot get it to work anymore in iOS, since Delphi 11 (or maybe 10.4). It’s only working on Android.
Does anyone know why the fonts are not picked up/ embedded on iOS?
I have created a sample application showcasing the use of a custom font on an iOS application. Please, the code is available here. It is important to bring up here the need to add the custom font file to the project deployment list:
The mentioned sample application contains a combo box to list all the font family names that are available as value for the TFont.Family property. I have added the SCRIPTBL.ttf font file to the application and it causes the Script MT Bold item to be added to the mentioned combo box.

Flutter and Material design 2

Is there some chance to use Material Design 2 in Flutter?
I can't find any informations about this on official website.
For Android app are informations here: https://material.io/develop/android/
Even though you shouldn't completely copy Google's design, you can of course use some tweaks ;) Here are some I would recommend:
The package rounded_modal
Using splashFactory: InkRipple.splashFactory in your Theme, aswell as setting the highlightColor: Colors.transparent
Having the app bar the same color as the Scaffold background with no elevation (I would recommend a CustomScrollView)
Using BottomNavigationBar instead of a Drawer
Actually, a "Material Design 2.0" does not exist. It is just Google's personal version of Material Theming, which every brand should do for it's own design.
So I wouldn't recommend just copying Google's design standarts, come up with something creative by yourself ;)
All the components from material.io can be implemented and customized in Flutter with ease, just look up the documentation for the specified component.
The material design components in Flutter can be explored here: material.io's Flutter specific site

Using Helvetica Neue in WatchKit not working, other custom fonts work

I am wanting to use Helvetica Neue Ultra Light in my Watchkit app. I have followed all of the instructions for adding a custom font (added to Extension bundle and added in Info.plist for Extension and Watchkit app), but NOTHING is working and it will never get used.
Really strange thing is, other ttf fonts that I have added DO work, it seems to just be some strange issue with Helvetica.
Where is Helvetica, and why can't I add it?
Edit: To clear things up and prevent what people think might be obvious answers.
Watchkit only includes the system font (San Francisco), it doesn't
expose all of the fonts that iOS has. (Ref:
devforums.apple.com/message/1096179#1096179) THIS is why I am trying
to include Helvetica.
Option 1
I had the same issue. I fixed it by including the - character between the font name and the name of its weight. In some ways, Xcode could recognize the font.
Try changing HelveticaNeueUltraLight.ttf into HelveticaNeue-UltraLight.ttf wherever possible (info.plist file and in the project folder).
Option 2
Open up the FontBook that comes included within your Mac. Install the font if you haven't already and look closely at the PostScript name of the font. If it differs from the name you are currently using in Xcode, then change it.
Option 3
If you can't still get this working, download the same font from another source.

iOS equivalent to a stylesheet?

HTML has CSS styles e.g. class="styleName"
Windows8/XAML has static style resources e.g. Style="{StaticResource styleName}"
Android has style tags e.g. style="#style/styleName"
iOS has ???
I'm using the interface builder for iOS in Xcode, how do I start to build up a style set or equivalent to styles? I want the ability to apply 'styles' to elements and then if I update that style's properties, the changes are applied to all elements that have been given that style. Is this possible in iOS development? Can someone please enlighten me as to how this is achieved or the equivalent please in iOS development. I'm very new to iOS development as you can see.
Is it more related to skins or themes? I don't have a clue.
There's Appearence. You often see this being used for colours, but it also does fonts, sizes, and a few other things. Here's another good article from a well known source.
Additionally, a common way to style/'skin' is by having different sets of background/button/... images.
You can also style by parameterizing drawing code. Have a look at the fabulous tool PaintCode.
Then, some companies do (part of the) UI in HTML/JavaScript.
Another thing to mention in this context is iOS' Auto Layout
You can do this with MarkupKit. See the section in the README entitled "Template Properties".
There isn't a good API in UIKit for this, unfortunately, but there are third party solutions with various tradeoffs.
I created a library that uses style classes, like CSS, which you can define in code, or inside a JSON file, and then apply to views in your app. As an extra benefit, the library uses #IBDesignable to live render your styles inside Storyboards without having to compile the app first to see the results.
https://github.com/daniel-hall/Stylish

IE9 won't render #font-face truetype fonts

IE9 won't render #font-face truetype fonts though all other browsers do. I'm getting the following exception:
CSS3114: #font-face failed OpenType embedding permission check. Permission must
be Installable.
I found similar questions on here and other places, but none of the solutions provided worked for me. For example, adding the following in Web.config won't solve the problem.
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
</customHeaders>
</httpProtocol>
There is also no woff version of the font I'm using, and I'm not sure if converting it into the woff format is allowed or not. I'm currently making an ASP.NET MVC project. How could I embed a ttf font in the project and use it in IE9?
Because IE doesn't support truetype so you need to convert it to .eot
You should consult the owner of the font's copyrights to provide an installable version of the font or to send you the same font in an other format.
The other thing you can ask for is to give permission for you to make modifications. In this case I would recommend the full version of Fontlab Studio 5: install the program, open the ttf file, choose the "Font Info... Ctrl+Alt+F" from the "File" menu, expand the "Names and Copyright" item in the left panel, select the "Embedding" item, then set the "Embedding settings (fsType):" to "Everything is allowed (installable mode)", press "OK", "File", "Generate Font... Ctrl+Alt+G", press "Save".
If you can't use Fontlab Studio 5, you can try any of the tools listed below... But it depends on the given font if it can be modified or not, so it is not you who is doing something wrong if it can't be modified.
embed
TTFPATCH
FontUtils
If you really can't use any of these methods, choose an other font. (Or as a last approach, you could ignore SEO aspects by using images instead of fonts. Or ignore IE9 users.)
Good luck! :)

Resources