angular 6 personalized material icons with ligature assistance

Can I create my own custom material icons with ligature support? Currently, I use svgIcon to get Custom Icons, Is there a way to make custom icons that support ligatures?

Here is my current code snippet:

app.component.ts

import { Component } from '@angular/core';
import { DomSanitizer } from '@angular/platform-browser';
import { MatIconRegistry } from '@angular/material';

  @Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.scss']
  })
  export class AppComponent {
    title = 'app';

    constructor(
      iconRegistry: MatIconRegistry,
      sanitizer: DomSanitizer
    ) {
      iconRegistry.addSvgIcon('key',
        sanitizer.bypassSecurityTrustResourceUrl('assets/icons/key.svg')
      );
      iconRegistry.addSvgIcon('user',
        sanitizer.bypassSecurityTrustResourceUrl('assets/icons/user.svg')
      );
    }

  }

login.component.html

<mat-form-field>
  <input matInput placeholder="Username" formControlName="username">
  <mat-icon matPrefix svgIcon="user"></mat-icon>
  <mat-error *ngIf="username.invalid">Username is required</mat-error>
</mat-form-field>

<mat-form-field>
  <input matInput type="password" placeholder="Password" formControlName="password">
  <mat-icon matPrefix svgIcon="key"></mat-icon>
  <mat-error *ngIf="password.invalid">Password is required</mat-error>
</mat-form-field>

Answer №1

Of course it can be done:

Step 1) Collect all the SVG icons.

Step 2) Develop your own font featuring a personalized ligature.

Use this tool to construct your unique font library with ligature capabilities.

Step 3:

Define your customized font.

@font-face {
  font-family: 'icomoon';
  src: url('path.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

Step 4: Replace the .material-icons with your created font

.material-icons {
  font-family: 'MyFontFamily';
   ...
}

or define your own fontSet to have access to both fonts.

// Add to AppComponent

 constructor(iconRegistry: MatIconRegistry) {
    iconRegistry.registerFontClassAlias('MyFontFamily', 'MyIconClass');
 }

Final step.

<mat-icon>LigatureToDisplay</mat-icon>

OR

<mat-icon fontSet="MyIconClass">LigatureOrUnicodeToDisplay</mat-icon>

Check out this brief guide for assistance.

https://medium.com/@buddhiv/add-a-custom-icon-font-in-your-application-b1e07a687953

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Insert items into an array at a specific index in typescript

Using the map function, I am adding elements to array arr1. Is there a way to specify the starting index position in typescript? For example: If I want to add elements from the 3rd index position of the array, with the first two indices holding a value of ...

Managing TypeScript objects

Just starting out with TypeScript and feeling a bit lost. The data I receive from my BackEnd looks like this: { "A": [ { "fieldA": 0, "fieldB": "A", "fieldC": ...

How can I receive the response from a GET request using React Query? I am currently only able to get the response

I have created a search component where I input a name in the request, receive a response, and display it immediately. However, after the first input submit, I get undefined in response. Only after the second submit do I get the desired response. The tec ...

Display Nested Data in Angular Material Table: A Step-by-Step Guide

I recently received a REST API response from the following URL: { "list": [ { "id": 1, "login": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7c08190f08234d3c0508521f1311"& ...

Issue with Angular 4: @HostBinding not properly rendering the CSS class on the host element, resulting in incorrect UI display

My creation of the ProductListComponent allows access to the child component, ProductRowComponent. Please see the code below: ProductListComponent import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; import { Product ...

Steps for specifying the required type of an Object literal in Typescript

Let's analyze a straightforward code snippet interface Foo{ bar:string; idx:number; } const test1:Foo={bar:'name'}; // this is highly recommended as it includes all required fields const test2={bar:'name'} as Foo; // this is ...

Sharing boolean values between Angular components is not working as expected

I'm working on a simple use case but seem to be missing something. In this scenario, I have two components: componentA and componentB. I am trying to pass a boolean value from componentB to componentA using an eventEmitter in order to show/hide a spe ...

Creating a unique ngrx operator from scratch that modifies the source observable and outputs its type

I developed a custom operator called waitFor that is being used in my effects like this: public effect$: Observable<Action> = createEffect(() => { return this.actions$.pipe( ofType(myAction), waitFor<ReturnType<typeof myActio ...

ExpressJs Request Params Override Error

I am currently utilizing express version 4.19.2 (the latest available at the time of writing) This is how I have declared the generic type Request interface ParamsDictionary { [key: string]: string; } interface Request< P = core.ParamsDictionary, ...

Angular 4/5 | Custom Dropdown Component

I have been working on a custom dropdown directive in Angular that I can attach to any DOM element. Below is the code for my directive: import { Directive, HostListener } from '@angular/core'; @Directive({ selector: '[appDropdown]' ...

Is there a way to retrieve the Angular-Redux store in a child module?

Within my Angular application, I utilize angular-redux for managing the application state. In my main module, I have defined the redux store in the following manner: export class MainModule { constructor(private ngRedux: NgRedux<MainAppState>, ...

How to reference an object from an external file in TypeScript using Ionic 2 and Angular 2

I am currently developing a mobile application with Ionic2 and have integrated a simple online payment service called Paystack for processing payments. The way it operates is by adding a js file to your webpage and then invoking a function. <script> ...

An action in redux-toolkit has detected the presence of a non-serializable value

When I download a file, I store it in the payload of the action in the store as a File type. This file will then undergo verification in the saga. const form = new FormData(); if (privateKey && privateKey instanceof Blob) { const blob = new Blo ...

Ensuring the proper export of global.d.ts in an npm package

I'm looking to release a typescript npm package with embedded types, and my file structure is set up like so dist/ [...see below] src/ global.d.ts index.ts otherfile.ts test/ examples/ To illustrate, the global.d.ts file contains typings ...

Removing Angular Template space highlights in WebStorm can be done easily with a few simple steps

Is there a way to remove space highlights in Angular / TypeScript using WebStorm 2019? https://i.stack.imgur.com/vfudR.jpg Many thanks, Sean ...

What is the best way to distinguish between administrators and regular users in an Angular project?

I am embarking on a project using Angular and I plan to incorporate both an admin and a user section within it. Is there a way to effectively separate the admin area from the user area in Angular? Additionally, how can I differentiate the style files for ...

When a node_module package includes type imports, Next.js can encounter build failures during the linting and type validity checking processes

This NextJS 13 project utilizes a package that has an inner core dependency (react-leaflet->@react-leaflet/core). When running yarn run build, the build fails at "Linting and checking validity of types." It appears to be a TypeScript compatibility iss ...

Can fields from one type be combined with those of another type?

Is it possible to achieve a similar outcome as shown below? type Info = { category: string } type Product = { code: string, ...Info } Resulting in the following structure for Product: type Product = { code: string, category : string } ...

Angular 9 Singleton Service Issue: Not Functioning as Expected

I have implemented a singleton service to manage shared data in my Angular application. The code for the service can be seen below: import { Injectable } from '@angular/core'; @Injectable({ providedIn: 'root' }) export class DataS ...

The angular mat-checkbox [checked] property is being triggered multiple times when dynamically assigning a value

<ul> <li *ngFor=let choice of checkboxlist.options> <mat-checkbox [checked]=isChecked(choice) > <mat-checkbox> <li> <ul> Within my TypeScript file, I have a function called isChecked which determines whether a checkbox ...