Grails: Using Custom Fonts

Biniam Asnake
Feb 27, 2021

I want to include a custom font and I created a folder under web-app and named it ‘fonts’ and I copied my font to that folder. Then,

1. I added the fonts folder to be included as a grails resource in Config.groovy like:

// What URL patterns should be processed by the resources plugin  
grails.resources.adhoc.patterns = ['/images/*', '/css/*', '/js/*', '/plugins/*', '/fonts/*']
grails.resources.adhoc.includes = ['/images/**', '/css/**', '/js/**', '/plugins/**', '/fonts/**']

2. Since I’m using Spring security plugin for grails, I added the ‘fonts*’ folder to ‘permitAll’ category of Requestmap.

// Request map Stored in Database

for (String url in [  
'/', '/index', '/index.gsp', 'favicon.ico',
'js*', 'css*', 'images*', 'fonts*',
'/login', '/login*//**',
'/logout', '/logout*//**'
]) {

Requestmap.findOrSaveByUrlAndConfigAttribute(url, 'permitAll').save()
}

--

--