bawr
1.0.0
이것은 SVG 파일 세트에서 아이콘 생성을 글꼴과 아틀라스로 자동화하는 도구입니다.
이 도구의 주요 목적은 C ++ 프로젝트의 빌드 프로세스에 추가하고 모든 작업을 수행하도록하는 것입니다. 그런 다음 SVG 아이콘을 글꼴 또는 스프리 시트로 사용할 수 있습니다.
프로젝트 URL은 다음과 같습니다. https://github.com/mnesarco/bawr이 프로젝트는 이전 프로젝트를 기반으로합니다. https://github.com/mnesarco/ff-batch
출처에서 구축
git clone https:://github.com/mnesarco/bawr.git
cd bawr
python3 -m pip install --upgrade build
python3 -m pip install wheel
python3 -m build
python3 -m pip install dist/bawr-0.0.6-py3-none-any.whl
또는 pypi에서 :
python3 -m pip install bawr| 개념 | 설명 |
|---|---|
| SVG 아이콘 | .svg 형식의 파일 일뿐입니다. 정사각형이어야합니다. |
| 아이콘 세트 또는 수집 | SVG 아이콘이있는 폴더입니다 |
| 구성 파일 | 파일을 생성하는 모든 옵션이 포함 된 파이썬 파일입니다. 컨벤션에 의해 config.py라고합니다 |
config.py 라는 파일을 넣으십시오 (예제 DIR https://github.com/mnesarco/bawr/tree/main/examples의 파일을 복사 할 수 있음) cd examples
python3 -m bawr.tool
예제 DIR (https://github.com/mnesarco/bawr/tree/main/examples)을 프로젝트 템플릿으로 사용할 수 있습니다.
examples/
├── config.py
├── icons/
└── bootstrap-icons/
examples/build/
├── atlas_cells.hpp
├── atlas.cpp
├── atlas.hpp
├── atlas.png
├── my-icons_codes.hpp
├── my-icons.cpp
├── my-icons.hpp
├── my-icons_loader.hpp
└── my-icons.ttf
config.py ) #------------------------------------------------------------------------------
# Import all required stuff:
#------------------------------------------------------------------------------
from bawr . config import *
#------------------------------------------------------------------------------
# Define an environment (Use the name that you want, but extend Environment):
#------------------------------------------------------------------------------
class Env ( Environment ):
# [Optional] FONTFORGE_PATH = Path to fontforge executable, deduced if it is in PATH
# FONTFORGE_PATH = ...
# [Optional] INKSCAPE_PATH = Path to inkscape executable, deduced if it is in PATH
# INKSCAPE_PATH = ...
# [Optional] BAWR_OUTPUT_DIR = Where all the output will be generated. Default = ./build
# BAWR_OUTPUT_DIR = ...
# [Optional] BAWR_SOURCE_DIR = Where all the icon folders will be found. Default = ./
# BAWR_SOURCE_DIR = ...
pass
#------------------------------------------------------------------------------
# Define your icon sets (extend IconSet):
#------------------------------------------------------------------------------
class BootstrapIcons ( IconSet ):
# [Mandatory] src = directory name (which contains svg icons)
src = 'bootstrap-icons'
# [Optional] select = selection of icons from the directory: list( tuple(file-name, glyph-name) )
select = [
( 'info-circle' , 'infoCircle' ),
( 'file-earmark' , 'fileEarmark' ),
( 'folder2-open' , 'folderOpen' ),
( 'hdd' , 'save' ),
( 'file-earmark-arrow-up' , 'fileImport' ),
( 'file-earmark-arrow-down' , 'fileExport' ),
( 'folder' , 'folder' ),
( 'sliders' , 'sliders' ),
( 'eye' , 'eye' ),
( 'layers' , 'layers' ),
]
# [Optional] options = Special options for generators
options = {
"font_transformation" : [( 'scale' , 0.75 , 0.75 )],
"atlas_preprocessors" : [
RegexReplacePreprocessor (
{
"currentColor" : "#ffffff" ,
'width="1em"' : 'width="16"' ,
'height="1em"' : 'height="16"' ,
}
)
],
"atlas_margin" : 0.0625
}
# Another icon set with different options
class MyIcons ( IconSet ):
src = 'icons'
options = {
"atlas_preprocessors" : [
RegexReplacePreprocessor (
{
'fill:#000000' : "fill:#ffffff" ,
'stroke:#000000' : 'stroke:#ffffff' ,
}
)
]
}
#------------------------------------------------------------------------------
# [Optional]
# Define Font generator to generate truetype fonts using FontForge
# (extend Font)
#------------------------------------------------------------------------------
class MyFont ( Font ):
# Generated font copyright notice [Mandatory]
copyright = "Copyright 2020 Frank D. Martinez M."
# Font name [Mandatory]
name = "my-icons"
# Font family [Mandatory]
family = "my-icons"
# First font glyph code [Optional] (default = 0xe000)
# start_code = 0xe000
# List ot tuple of the icon sets included in this font [Mandatory]
collections = ( BootstrapIcons , MyIcons )
# Global font transformation [Optiona] (See: Font transformations)
# transformation = []
# Output format [Optional] (default = ['ttf'])
# output_formats = ['ttf']
# Verbose output. Shows glyph generation details [Optional] (default = False)
# verbose = False
#------------------------------------------------------------------------------
# [Optional]
# You can generate a C++ font header file with glyph codes ready to use in C++.
# (extend CppFontHeader)
#------------------------------------------------------------------------------
class MyCppFontH ( CppFontHeader ):
# [Mandatory] Reference to the font generator to use
source = MyFont
# [Optional] Generate constexpr values (default = false)
constexpr = True
# [Optional] name of the generated c++ file (default = source.name)
# name = ...
# [Optional] namespace of the generated c++ file (default = icons)
# namespace = ...
# [Optional] Generate macros (default = True)
# macros = ...
# [Optional] Prefix for all macros (default = Icon_)
# macro_prefix = ...
#------------------------------------------------------------------------------
# [Optional]
# You can Embed your font binary into a C++ source file to be linked.
# (extend CppEmbedded)
#------------------------------------------------------------------------------
class MyCppFontEmbed ( CppEmbedded ):
# [Mandatory] Reference to the binary file to embed
source = "${BAWR_OUTPUT_DIR}/my-icons.ttf"
# [Optional] name prefix for the generated files (default = source name)
# name = ...
# [Optional] namespace for the generated files (default = icons)
# namespace = ...
#------------------------------------------------------------------------------
# [Optional]
# You can generate C++ code to load your font into Dear ImGui.
# (extend CppEmbedded)
#------------------------------------------------------------------------------
class MyCppFontImGui ( ImGuiFontLoader ):
# [Mandatory] reference to the font
font = MyFont
# [Mandatory] reference to the font header
header = MyCppFontH
# [Mandatory] reference to the embedded binary
data = MyCppFontEmbed
# [Optional] name prefix for the generated files (default = font.name)
# name = ...
# [Optional] namespace for the generated files (default = icons)
# namespace = ...
#------------------------------------------------------------------------------
# [Optional]
# You can generate an optimized png atlas with all your icons in different sizes.
# (extend Atlas)
#------------------------------------------------------------------------------
class MyAtlas ( Atlas ):
# [Optional] width of the atlas image (default = 512)
width = 512
# [Mandatory] sizes of the icons to be generated and included in the atlas
sizes = ( 16 , 32 , 64 )
# [Mandatory] References to collections (icon sets) to be included
collections = ( BootstrapIcons , MyIcons )
# [Optional] name prefix for the generated files (default = font.name)
# name = ...
# [Optional] Embed the Atlas png into a C++ source.
class MyCppAtlasEmbed ( CppEmbedded ):
source = "${BAWR_OUTPUT_DIR}/atlas.png"
#------------------------------------------------------------------------------
# [Optional]
# Generate a C++ header file with the atlas cells (frames) to be used in your code.
# (extend CppAtlasHeader)
#------------------------------------------------------------------------------
class MyAtlasHeader ( CppAtlasHeader ):
source = MyAtlas
https://github.com/mnesarco/bawr/blob/main/imgui.md
Bawr는 Bertrand Arthur William Russell을 기리기 위해 IX 및 XX 세기의 위대한 논리학 자, 수학자 및 철학자를 기리기 시작했습니다.