Skip to content

Commit

Permalink
font CLI & UI
Browse files Browse the repository at this point in the history
  • Loading branch information
Soare-Robert-Daniel committed Mar 22, 2021
1 parent 88d647e commit da27591
Show file tree
Hide file tree
Showing 12 changed files with 289 additions and 41 deletions.
34 changes: 34 additions & 0 deletions development/createFontConfigFile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/* eslint-disable @typescript-eslint/no-var-requires */

// Importing the Required Modules
const fs = require('fs');
const readline = require('readline');

const file = readline.createInterface({
input: fs.existsSync('development/fonts.txt') ? fs.createReadStream('development/fonts.txt') : fs.createReadStream('fonts.txt'),
output: process.stdout,
terminal: false
});

const fonts = []
file.on('line', (line) => {
fonts.push(line.trim())
});

file.on('close', () => {
console.log(`Total Fonts: ${fonts.length} :`,fonts )
fs.writeFileSync( './src/assets/fonts/fonts.json', JSON.stringify(fonts, {}, 4), function(err) {
if (err) throw err;
console.log('Fonts JSON file created');
} )

const webpackFonts = fonts.map( function(font){
return {
family: font
}
})
fs.writeFileSync( './webpack.fonts.json', JSON.stringify(webpackFonts, {}, 4), function(err) {
if (err) throw err;
console.log('Webpack Fonts JSON file created');
} )
})
33 changes: 33 additions & 0 deletions development/fonts.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Open Sans
Bangers
Roboto
Dancing Script
Henny Penny
Alfa Slab One
Oswald
Anton
Permanent Marker
Cinzel Decorative
Lato
Karla
Montserrat
Libre Baskerville
Bebas Neue
Fira Sans
Play
Crete Round
Rajdhani
Satisfy
Lobster Two
Orbitron
Parisienne
Playball
Noto Serif
Noto Sans
Lora
Source Serif Pro
Ubuntu
Lemonada
UnifrakturMaguntia
Oleo Script Swash Caps
Creepster
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
"start-plugin": "webpack --watch --mode development",
"plugin-build": "webpack --mode production",
"linux:make-zip": "npm run plugin-build && zip -r logo_maker_plugin.zip index.php plugin_build && mv logo_maker_plugin.zip development/",
"create:font:config": "node development/createFontConfigFile.js",
"gen-docs": "npx typedoc",
"format": "prettier --write \"src/**/*.{js,jsx,ts,tsx}\"",
"lint": "eslint \"src/**/*.{js,jsx,ts,tsx}\""

},
"dependencies": {
"@beyonk/google-fonts-webpack-plugin": "^1.5.0",
Expand Down
2 changes: 1 addition & 1 deletion plugin_build/logo-maker.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'react-dom'), 'version' => 'ae1bb6f1a2ca77fa74f2fa4343935695');
<?php return array('dependencies' => array('react', 'react-dom'), 'version' => '3e63f244d75252778e7269ca7092b12d');
2 changes: 1 addition & 1 deletion plugin_build/logo-maker.js

Large diffs are not rendered by default.

35 changes: 35 additions & 0 deletions src/assets/fonts/fonts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[
"Open Sans",
"Bangers",
"Roboto",
"Dancing Script",
"Henny Penny",
"Alfa Slab One",
"Oswald",
"Anton",
"Permanent Marker",
"Cinzel Decorative",
"Lato",
"Karla",
"Montserrat",
"Libre Baskerville",
"Bebas Neue",
"Fira Sans",
"Play",
"Crete Round",
"Rajdhani",
"Satisfy",
"Lobster Two",
"Orbitron",
"Parisienne",
"Playball",
"Noto Serif",
"Noto Sans",
"Lora",
"Source Serif Pro",
"Ubuntu",
"Lemonada",
"UnifrakturMaguntia",
"Oleo Script Swash Caps",
"Creepster"
]
80 changes: 44 additions & 36 deletions src/assets/fonts/google-fonts.ts
Original file line number Diff line number Diff line change
@@ -1,39 +1,47 @@
const fonts = [
"Helvetica",
"Open Sans",
"Bangers",
"Roboto",
"Dancing Script",
"Henny Penny",
"Pacifico",
"Amatic SC",
"Alfa Slab One",
"Oswald",
"Anton",
"Permanent Marker",
"Cinzel Decorative",
"Lato",
"Karla",
"Montserrat",
"Libre Baskerville",
"Bebas Neue",
"IBM Plex Serif",
"Fira Sans",
"Caveat",
"Tinos",
"Play",
"Crete Round",
"Rajdhani",
"Satisfy",
"Arial",
"Consolas",
"Georgia",
"Lobster Two",
"Orbitron",
"Parisienne",
"Playball",
"Noto Serif"
]
import fonts from './fonts.json'
console.log(fonts)
// const fonts = [
// "Helvetica",
// "Open Sans",
// "Bangers",
// "Roboto",
// "Dancing Script",
// "Henny Penny",
// "Amatic SC",
// "Alfa Slab One",
// "Oswald",
// "Anton",
// "Permanent Marker",
// "Cinzel Decorative",
// "Lato",
// "Karla",
// "Montserrat",
// "Libre Baskerville",
// "Bebas Neue",
// "IBM Plex Serif",
// "Fira Sans",
// "Caveat",
// "Tinos",
// "Play",
// "Crete Round",
// "Rajdhani",
// "Satisfy",
// "Arial",
// "Georgia",
// "Lobster Two",
// "Orbitron",
// "Parisienne",
// "Playball",
// "Noto Serif",
// "Noto Sans",
// "Lora",
// "Source Serif Pro",
// "Ubuntu",
// "Lemonada",
// "UnifrakturMaguntia",
// "Oleo Script Swash Caps",
// "Creepster"
// ]

type WebpackFont = {
family: string,
Expand Down
7 changes: 7 additions & 0 deletions src/components/ui/SelectTypography.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ const SelectTypography: React.FunctionComponent<unknown> = () => {
...base,
boxShadow: "none",
}),
// eslint-disable-next-line @typescript-eslint/no-explicit-any
option: (styles: Record<string, any>, { data } : { data: { label: string, value: string }}) => {
return {
...styles,
fontFamily: ! Number.isInteger(Number.parseInt(data.value)) ? data.value : 'Nato Sans'
}
}
}

const defaultTitleFontFamily = UIStore.useState((s) => s.title.style.fontFamily)
Expand Down
1 change: 0 additions & 1 deletion src/engine/render/shapesBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ export function buildDefaultShapes(parent: Svg, componentsProps: LogoProps, font
const title = isFontFromGoogle(pTitle.style.fontFamily) && fontRenderers ? buildTextToSVG(parent, pTitle, fontRenderers) || parent.text(pTitle.text) : parent.text(pTitle.text)
const slogan = isFontFromGoogle(pSlogan.style.fontFamily) && fontRenderers ? buildTextToSVG(parent, pSlogan, fontRenderers) || parent.text(pSlogan.text) : parent.text(pSlogan.text)

console.log(isFontFromGoogle(pSlogan.style.fontFamily))
// Apply other properties
logo.viewbox(0, 0, logo.bbox().width, logo.bbox().height + 5)
.size(pLogo.width, pLogo.height)
Expand Down
3 changes: 1 addition & 2 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const path = require("path");
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const DependencyExtractionWebpackPlugin = require( '@wordpress/dependency-extraction-webpack-plugin' );
const GoogleFontsPlugin = require("@beyonk/google-fonts-webpack-plugin")
const webpackFonts = require("./webpack.fonts")
const webpackFonts = require("./webpack.fonts.json")

module.exports = {
entry: {
Expand Down Expand Up @@ -36,7 +36,6 @@ module.exports = {
path: path.resolve(__dirname, "plugin_build"),
clean: true
},

plugins: [
new DependencyExtractionWebpackPlugin(),
new BundleAnalyzerPlugin({
Expand Down
30 changes: 30 additions & 0 deletions webpack.fonts.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,36 @@ const familyFonts = [
{
family: "Noto Serif"
},
{
family: "Noto Sans"
},
{
family: "Anton"
},
{
family: "Lora"
},
{
family: "Rajdhani"
},
{
family: "Ubuntu"
},
{
family: "Lemonada"
},
{
family: "Source Serif Pro"
},
{
family: "Oleo Script Swash Caps"
},
{
family: "Creepster"
},
{
family: "UnifrakturMaguntia"
}
]

module.exports = familyFonts
101 changes: 101 additions & 0 deletions webpack.fonts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
[
{
"family": "Open Sans"
},
{
"family": "Bangers"
},
{
"family": "Roboto"
},
{
"family": "Dancing Script"
},
{
"family": "Henny Penny"
},
{
"family": "Alfa Slab One"
},
{
"family": "Oswald"
},
{
"family": "Anton"
},
{
"family": "Permanent Marker"
},
{
"family": "Cinzel Decorative"
},
{
"family": "Lato"
},
{
"family": "Karla"
},
{
"family": "Montserrat"
},
{
"family": "Libre Baskerville"
},
{
"family": "Bebas Neue"
},
{
"family": "Fira Sans"
},
{
"family": "Play"
},
{
"family": "Crete Round"
},
{
"family": "Rajdhani"
},
{
"family": "Satisfy"
},
{
"family": "Lobster Two"
},
{
"family": "Orbitron"
},
{
"family": "Parisienne"
},
{
"family": "Playball"
},
{
"family": "Noto Serif"
},
{
"family": "Noto Sans"
},
{
"family": "Lora"
},
{
"family": "Source Serif Pro"
},
{
"family": "Ubuntu"
},
{
"family": "Lemonada"
},
{
"family": "UnifrakturMaguntia"
},
{
"family": "Oleo Script Swash Caps"
},
{
"family": "Creepster"
}
]

0 comments on commit da27591

Please sign in to comment.