Skip to content

Commit 7bfa54e

Browse files
authored
Merge pull request #4 from eff3ry/copilot/fix-4df4eaf9-2e46-47cf-bfed-f52f3771bedc
Refactor emoji pack generator to use JSON configuration files
2 parents 6c60a31 + 332f7a8 commit 7bfa54e

8 files changed

Lines changed: 932 additions & 83 deletions

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,3 +153,5 @@ cython_debug/
153153
# and can be added to the global gitignore or merged into this file. For a more nuclear
154154
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
155155
#.idea/
156+
cache/
157+
packs/

CONFIG_SCHEMA.md

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# Emoji Pack Configuration Schema
2+
3+
This document describes the JSON configuration schema for the emoji pack generator.
4+
5+
## Configuration Structure
6+
7+
```json
8+
{
9+
"name": "Pack Name",
10+
"version": "1.0.0",
11+
"source": {
12+
"type": "github",
13+
"repository": "owner/repository-name",
14+
"branch": "main",
15+
"folder": "path/to/assets/folder"
16+
},
17+
"input_structure": {
18+
"metadata_file": "metadata.json",
19+
"image_folders": [
20+
"{style}",
21+
"{skin_tone}/{style}"
22+
],
23+
"image_extensions": ["png"],
24+
"styles": ["3D", "Color", "Flat"],
25+
"skin_tones": ["Default", "Dark", "Medium-Dark", "Medium-Light", "Light"]
26+
},
27+
"output": {
28+
"type": "minecraft_resource_pack",
29+
"pack_format": 15,
30+
"description_template": "Pack Description with {style} and {skin_tone}",
31+
"output_directory": "./packs/{name}-{style}-{skin_tone}",
32+
"textures_path": "assets/minecraft/textures/font",
33+
"font_path": "assets/minecraft/font/default.json",
34+
"pack_meta_path": "pack.mcmeta",
35+
"pack_icon_source": "1f603"
36+
},
37+
"file_processing": {
38+
"filename_from_metadata": "unicode",
39+
"character_from_metadata": "glyph",
40+
"unicode_processing": {
41+
"skip_if_contains_space": true,
42+
"handle_variation_selector": {
43+
"enabled": true,
44+
"pattern": " fe0f",
45+
"action": "remove_and_convert"
46+
}
47+
}
48+
},
49+
"font_config": {
50+
"provider_type": "bitmap",
51+
"height": 7,
52+
"ascent": 7,
53+
"file_template": "minecraft:font/{filename}.png"
54+
}
55+
}
56+
```
57+
58+
## Field Descriptions
59+
60+
### Root Level
61+
- `name`: Human-readable name of the emoji pack
62+
- `version`: Version of this configuration
63+
- `source`: Configuration for where to download emoji assets from
64+
- `input_structure`: Describes the expected structure of the input data
65+
- `output`: Configuration for the generated output format
66+
- `file_processing`: Rules for processing individual files
67+
- `font_config`: Font-specific configuration for Minecraft resource packs
68+
69+
### Source Configuration
70+
- `type`: Type of source ("github" currently supported)
71+
- `repository`: GitHub repository in "owner/repo" format
72+
- `branch`: Git branch to download from
73+
- `folder`: Folder within the repository to extract
74+
75+
### Input Structure
76+
- `metadata_file`: Name of the metadata file in each emoji folder
77+
- `image_folders`: Array of folder patterns to search for images (supports {style}, {skin_tone} variables)
78+
- `image_extensions`: Supported image file extensions
79+
- `styles`: Available styles for this emoji set
80+
- `skin_tones`: Available skin tones for this emoji set
81+
82+
### Output Configuration
83+
- `type`: Output format type
84+
- `pack_format`: Minecraft pack format version
85+
- `description_template`: Template for pack description (supports variables)
86+
- `output_directory`: Where to generate the pack (supports variables)
87+
- `textures_path`: Path within pack for texture files
88+
- `font_path`: Path for font configuration JSON
89+
- `pack_meta_path`: Path for pack metadata file
90+
- `pack_icon_source`: Unicode value to use as pack icon
91+
92+
### File Processing
93+
- `filename_from_metadata`: Metadata field to use for filename
94+
- `character_from_metadata`: Metadata field to use for character mapping
95+
- `unicode_processing`: Rules for processing unicode values
96+
97+
### Font Configuration
98+
- `provider_type`: Minecraft font provider type
99+
- `height`: Font height in pixels
100+
- `ascent`: Font ascent in pixels
101+
- `file_template`: Template for texture file references
102+
103+
## Variable Substitution
104+
105+
The following variables can be used in templates:
106+
- `{style}`: Current style being processed
107+
- `{skin_tone}`: Current skin tone being processed
108+
- `{filename}`: Processed filename from metadata
109+
- `{name}`: Pack name from root configuration
110+
111+
## Wildcard Support
112+
113+
The system supports wildcards in the `image_folders` configuration:
114+
- `{style}`: Matches any style from the styles array
115+
- `{skin_tone}`: Matches any skin tone from the skin_tones array
116+
117+
This allows flexible folder structure matching without hardcoding paths.

README.md

Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
# Emoji Pack Generator
2+
3+
A flexible, configuration-driven system for generating emoji resource packs from various sources.
4+
5+
## Features
6+
7+
- **JSON Configuration**: Define emoji pack sources, structure, and output formats via JSON
8+
- **Multiple Source Support**: Currently supports GitHub repositories
9+
- **Flexible Input Structure**: Support for wildcard patterns in folder structures
10+
- **Multiple Output Formats**: Currently supports Minecraft resource packs
11+
- **Skin Tone & Style Support**: Generate packs for different styles and skin tones
12+
- **Backward Compatibility**: Legacy FluentUI script still works
13+
14+
## Quick Start
15+
16+
### Using the New Configuration System
17+
18+
1. **Generate a pack using an existing configuration:**
19+
```bash
20+
python emoji_pack_generator.py --config configs/fluentui-3d-only.json --download
21+
```
22+
23+
2. **Generate for specific style/skin tone:**
24+
```bash
25+
python emoji_pack_generator.py --config configs/fluentui-3d-only.json --style 3D --skin-tone Dark --download
26+
```
27+
28+
3. **Use existing downloaded files:**
29+
```bash
30+
python emoji_pack_generator.py --config configs/fluentui-3d-only.json --extract-to ./cache/assets/
31+
```
32+
33+
### Using the Legacy System
34+
35+
The original fluentui-emoji.py still works for backward compatibility:
36+
37+
```bash
38+
# Legacy mode (deprecated)
39+
python fluentui-emoji.py --download --style 3D --skin-tone Default
40+
41+
# Legacy mode with new configuration
42+
python fluentui-emoji.py --config configs/fluentui-3d-only.json --style 3D --skin-tone Default
43+
```
44+
45+
## Configuration
46+
47+
### Example Configuration Files
48+
49+
- `configs/fluentui-3d-only.json` - FluentUI emojis, 3D style only
50+
- `configs/fluentui-emoji.json` - FluentUI emojis, all styles (includes SVG)
51+
- `configs/twemoji-example.json` - Example Twemoji configuration
52+
53+
### Configuration Schema
54+
55+
See [CONFIG_SCHEMA.md](CONFIG_SCHEMA.md) for detailed documentation of the JSON schema.
56+
57+
### Basic Configuration Structure
58+
59+
```json
60+
{
61+
"name": "Pack Name",
62+
"source": {
63+
"type": "github",
64+
"repository": "owner/repo-name",
65+
"branch": "main",
66+
"folder": "assets"
67+
},
68+
"input_structure": {
69+
"metadata_file": "metadata.json",
70+
"image_folders": ["{style}", "{skin_tone}/{style}"],
71+
"image_extensions": ["png"],
72+
"styles": ["3D", "Color", "Flat"],
73+
"skin_tones": ["Default", "Dark", "Light"]
74+
},
75+
"output": {
76+
"type": "minecraft_resource_pack",
77+
"pack_format": 15,
78+
"description_template": "{name} {style}-{skin_tone} Pack",
79+
"output_directory": "./packs/{name}-{style}-{skin_tone}"
80+
},
81+
"file_processing": {
82+
"filename_from_metadata": "unicode",
83+
"character_from_metadata": "glyph"
84+
},
85+
"font_config": {
86+
"provider_type": "bitmap",
87+
"height": 7,
88+
"ascent": 7
89+
}
90+
}
91+
```
92+
93+
## Command Line Options
94+
95+
### emoji_pack_generator.py
96+
97+
```
98+
--config CONFIG Path to JSON configuration file (required)
99+
--extract-to DIR Extraction directory (default: ./cache/assets/)
100+
--style STYLE Emoji style (overrides config)
101+
--skin-tone TONE Skin tone (overrides config)
102+
--download Force download of assets
103+
--commit HASH Specific commit hash to download
104+
```
105+
106+
### fluentui-emoji.py (Legacy)
107+
108+
```
109+
--repo-url URL GitHub repository URL
110+
--folder-name NAME Folder name in repository
111+
--extract-to DIR Extraction directory
112+
--skin-tone TONE Skin tone
113+
--style STYLE Emoji style
114+
--download Force download of assets
115+
--config CONFIG Use JSON configuration (recommended)
116+
```
117+
118+
## Creating Custom Configurations
119+
120+
1. **Create a new JSON configuration file** based on the schema
121+
2. **Define your source repository** and folder structure
122+
3. **Configure input patterns** with wildcard support
123+
4. **Set up output format** and naming conventions
124+
5. **Test with a small subset** before full generation
125+
126+
### Wildcard Support
127+
128+
The system supports these wildcards in folder patterns:
129+
- `{style}` - Matches any style from the configuration
130+
- `{skin_tone}` - Matches any skin tone from the configuration
131+
132+
Example: `["{style}", "{skin_tone}/{style}"]` will match both:
133+
- `3D/` and `Default/3D/`
134+
- `Color/` and `Dark/Color/`
135+
136+
## File Structure
137+
138+
```
139+
emoji_pack/
140+
├── emoji_pack_generator.py # New configuration-based generator
141+
├── fluentui-emoji.py # Legacy script with backward compatibility
142+
├── configs/ # Configuration files
143+
│ ├── fluentui-3d-only.json # FluentUI 3D only (recommended)
144+
│ ├── fluentui-emoji.json # FluentUI all styles
145+
│ └── twemoji-example.json # Example Twemoji config
146+
├── CONFIG_SCHEMA.md # Configuration schema documentation
147+
├── cache/ # Downloaded assets cache
148+
└── packs/ # Generated resource packs
149+
```
150+
151+
## Supported Input Formats
152+
153+
- **PNG images** - Ready for Minecraft resource packs
154+
- **SVG images** - Requires conversion to PNG (not implemented yet)
155+
- **Metadata JSON** - For emoji information and mapping
156+
157+
## Supported Output Formats
158+
159+
- **Minecraft Resource Pack** - Complete pack with textures and font JSON
160+
161+
## Known Limitations
162+
163+
1. **SVG Support**: SVG files are detected but not converted to PNG automatically
164+
2. **Single Source Type**: Only GitHub repositories supported currently
165+
3. **Minecraft Format Only**: Only Minecraft resource pack output implemented
166+
167+
## Contributing
168+
169+
To add support for new source types or output formats:
170+
171+
1. Extend the `EmojiPackProcessor` class
172+
2. Add new configuration options to the schema
173+
3. Update validation in `EmojiPackConfig`
174+
4. Test with example configurations
175+
176+
## Examples
177+
178+
### Generate FluentUI 3D Pack
179+
```bash
180+
python emoji_pack_generator.py --config configs/fluentui-3d-only.json --download
181+
```
182+
183+
### Generate for Specific Skin Tone
184+
```bash
185+
python emoji_pack_generator.py --config configs/fluentui-3d-only.json --skin-tone Dark
186+
```
187+
188+
### Use Specific Commit
189+
```bash
190+
python emoji_pack_generator.py --config configs/fluentui-3d-only.json --commit abc123 --download
191+
```
192+
193+
The generated packs will be in the `packs/` directory and can be installed as Minecraft resource packs.

configs/fluentui-3d-only.json

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"name": "FluentUI 3D Emoji Pack",
3+
"version": "1.0.0",
4+
"description": "FluentUI Emoji Pack configured for 3D style only (PNG files)",
5+
"source": {
6+
"type": "github",
7+
"repository": "microsoft/fluentui-emoji",
8+
"branch": "main",
9+
"folder": "assets"
10+
},
11+
"input_structure": {
12+
"metadata_file": "metadata.json",
13+
"image_folders": [
14+
"{style}",
15+
"{skin_tone}/{style}"
16+
],
17+
"image_extensions": ["png"],
18+
"styles": ["3D"],
19+
"skin_tones": ["Default", "Dark", "Medium-Dark", "Medium-Light", "Light"]
20+
},
21+
"output": {
22+
"type": "minecraft_resource_pack",
23+
"pack_format": 15,
24+
"description_template": "FluentUi {style}-{skin_tone} Emoji Resource Pack",
25+
"output_directory": "./packs/FluentUi-{style}-{skin_tone}-Emoji",
26+
"textures_path": "assets/minecraft/textures/font",
27+
"font_path": "assets/minecraft/font/default.json",
28+
"pack_meta_path": "pack.mcmeta",
29+
"pack_icon_source": "1f603"
30+
},
31+
"file_processing": {
32+
"filename_from_metadata": "unicode",
33+
"character_from_metadata": "glyph",
34+
"unicode_processing": {
35+
"skip_if_contains_space": true,
36+
"handle_variation_selector": {
37+
"enabled": true,
38+
"pattern": " fe0f",
39+
"action": "remove_and_convert"
40+
}
41+
}
42+
},
43+
"font_config": {
44+
"provider_type": "bitmap",
45+
"height": 7,
46+
"ascent": 7,
47+
"file_template": "minecraft:font/{filename}.png"
48+
}
49+
}

0 commit comments

Comments
 (0)