wip
This commit is contained in:
@@ -8,14 +8,17 @@ from .panels import (
|
||||
|
||||
# Menu functions for Blender integration
|
||||
def menu_func_node_editor(self, context):
|
||||
pass
|
||||
"""Add menu item to Node Editor's Add menu"""
|
||||
self.layout.operator("text_texture.generate", text="Text Texture", icon='IMAGE_DATA')
|
||||
|
||||
def menu_func_view3d(self, context):
|
||||
pass
|
||||
"""Add menu item to 3D View's Add menu"""
|
||||
self.layout.operator("text_texture.generate", text="Text Texture", icon='IMAGE_DATA')
|
||||
|
||||
def menu_func_image(self, context):
|
||||
pass
|
||||
"""Add menu item to Image Editor menu"""
|
||||
self.layout.operator("text_texture.generate", text="Text Texture", icon='IMAGE_DATA')
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
1009
src/ui/panels.py
1009
src/ui/panels.py
File diff suppressed because it is too large
Load Diff
@@ -2,14 +2,43 @@
|
||||
import bpy
|
||||
import os
|
||||
import platform
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
|
||||
# Global flag to track PIL availability
|
||||
PIL_AVAILABLE = False
|
||||
Image = None
|
||||
ImageDraw = None
|
||||
ImageFont = None
|
||||
|
||||
try:
|
||||
pass
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
PIL_AVAILABLE = True
|
||||
except ImportError:
|
||||
pass
|
||||
PIL_AVAILABLE = False
|
||||
# Create placeholder classes to prevent import errors
|
||||
class _MockPIL:
|
||||
pass
|
||||
def __getattr__(self, name):
|
||||
pass
|
||||
raise ImportError(
|
||||
"PIL (Pillow) is required for preview functionality. "
|
||||
"Please install it using: pip install Pillow in Blender's Python environment, "
|
||||
"or use Blender's bundled Python if available."
|
||||
)
|
||||
|
||||
Image = _MockPIL()
|
||||
ImageDraw = _MockPIL()
|
||||
ImageFont = _MockPIL()
|
||||
|
||||
def test_font_mixed_case_support(font_path):
|
||||
pass
|
||||
"""
|
||||
Test if a font properly supports mixed case rendering.
|
||||
Returns True if the font supports mixed case, False if it only renders uppercase.
|
||||
"""
|
||||
try:
|
||||
pass
|
||||
# Test string with mixed case
|
||||
test_text = "AaBbCc"
|
||||
|
||||
@@ -20,8 +49,10 @@ def test_font_mixed_case_support(font_path):
|
||||
|
||||
# Try to load the font
|
||||
try:
|
||||
pass
|
||||
font = ImageFont.truetype(font_path, 24)
|
||||
except (OSError, IOError):
|
||||
pass
|
||||
print(f"Text Texture Generator: Could not load font for testing: {font_path}")
|
||||
return False
|
||||
|
||||
@@ -40,42 +71,54 @@ def test_font_mixed_case_support(font_path):
|
||||
|
||||
# Compare the two renderings - if they're identical, the font only supports uppercase
|
||||
if pixels == pixels_upper:
|
||||
pass
|
||||
print(f"Text Texture Generator: Font only supports uppercase rendering: {os.path.basename(font_path)}")
|
||||
return False
|
||||
else:
|
||||
pass
|
||||
print(f"Text Texture Generator: Font supports mixed case rendering: {os.path.basename(font_path)}")
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
pass
|
||||
print(f"Text Texture Generator: Error testing font mixed case support: {str(e)}")
|
||||
return False
|
||||
|
||||
def get_validated_font(font_path, fallback_fonts=None):
|
||||
pass
|
||||
"""
|
||||
Get a validated font that supports mixed case rendering.
|
||||
Returns the original font path if valid, otherwise returns a fallback font.
|
||||
"""
|
||||
if not font_path or not os.path.exists(font_path):
|
||||
pass
|
||||
print(f"Text Texture Generator: Font file not found: {font_path}")
|
||||
return get_system_fallback_fonts()[0] if get_system_fallback_fonts() else None
|
||||
|
||||
# Test if the font supports mixed case
|
||||
if test_font_mixed_case_support(font_path):
|
||||
pass
|
||||
return font_path
|
||||
else:
|
||||
pass
|
||||
print(f"Text Texture Generator: Font does not support mixed case, using fallback: {font_path}")
|
||||
|
||||
# Try fallback fonts if provided
|
||||
if fallback_fonts:
|
||||
pass
|
||||
for fallback_font in fallback_fonts:
|
||||
pass
|
||||
if os.path.exists(fallback_font) and test_font_mixed_case_support(fallback_font):
|
||||
pass
|
||||
print(f"Text Texture Generator: Using fallback font: {fallback_font}")
|
||||
return fallback_font
|
||||
|
||||
# Use system fallback fonts
|
||||
system_fallbacks = get_system_fallback_fonts()
|
||||
for fallback_font in system_fallbacks:
|
||||
pass
|
||||
if test_font_mixed_case_support(fallback_font):
|
||||
pass
|
||||
print(f"Text Texture Generator: Using system fallback font: {fallback_font}")
|
||||
return fallback_font
|
||||
|
||||
@@ -84,6 +127,7 @@ def get_validated_font(font_path, fallback_fonts=None):
|
||||
return font_path
|
||||
|
||||
def get_system_fallback_fonts():
|
||||
pass
|
||||
"""
|
||||
Get a list of system fallback fonts based on the operating system.
|
||||
Returns a list of font paths that are likely to be available.
|
||||
@@ -92,6 +136,7 @@ def get_system_fallback_fonts():
|
||||
fallback_fonts = []
|
||||
|
||||
if system == "Windows":
|
||||
pass
|
||||
windows_fonts = [
|
||||
"C:/Windows/Fonts/arial.ttf",
|
||||
"C:/Windows/Fonts/calibri.ttf",
|
||||
@@ -133,17 +178,25 @@ def get_system_fallback_fonts():
|
||||
]
|
||||
|
||||
for font_dir in common_directories:
|
||||
pass
|
||||
if os.path.exists(font_dir):
|
||||
pass
|
||||
for root, dirs, files in os.walk(font_dir):
|
||||
pass
|
||||
for file in files:
|
||||
pass
|
||||
if file.lower().endswith(('.ttf', '.otf')):
|
||||
pass
|
||||
font_path = os.path.join(root, file)
|
||||
if font_path not in fallback_fonts:
|
||||
pass
|
||||
fallback_fonts.append(font_path)
|
||||
# Limit the number of fallback fonts to prevent excessive scanning
|
||||
if len(fallback_fonts) >= 20:
|
||||
pass
|
||||
break
|
||||
if len(fallback_fonts) >= 20:
|
||||
pass
|
||||
break
|
||||
|
||||
print(f"Text Texture Generator: Found {len(fallback_fonts)} system fallback fonts")
|
||||
|
||||
Reference in New Issue
Block a user