2020-09-18 17:04:24 +02:00
|
|
|
# ##### BEGIN GPL LICENSE BLOCK #####
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
# ##### END GPL LICENSE BLOCK #####
|
|
|
|
|
|
|
|
|
2020-09-20 19:53:51 +02:00
|
|
|
import logging
|
|
|
|
import os
|
|
|
|
from pathlib import Path
|
|
|
|
|
2020-09-18 17:04:24 +02:00
|
|
|
import bpy
|
2020-09-20 19:53:51 +02:00
|
|
|
|
2020-09-18 17:04:24 +02:00
|
|
|
from .bl_datablock import BlDatablock
|
2020-09-21 12:12:19 +02:00
|
|
|
from .bl_file import get_filepath, ensure_unpacked
|
2020-09-20 19:53:51 +02:00
|
|
|
from .dump_anything import Dumper, Loader
|
|
|
|
|
2020-09-18 17:04:24 +02:00
|
|
|
|
|
|
|
class BlFont(BlDatablock):
|
|
|
|
bl_id = "fonts"
|
|
|
|
bl_class = bpy.types.VectorFont
|
|
|
|
bl_check_common = False
|
|
|
|
bl_icon = 'FILE_FONT'
|
2020-12-09 14:49:26 +01:00
|
|
|
bl_reload_parent = False
|
2020-09-18 17:04:24 +02:00
|
|
|
|
2021-03-26 12:30:15 +01:00
|
|
|
def construct(data: dict) -> object:
|
2020-09-28 10:40:07 +02:00
|
|
|
filename = data.get('filename')
|
|
|
|
|
|
|
|
if filename == '<builtin>':
|
|
|
|
return bpy.data.fonts.load(filename)
|
2020-09-20 19:53:51 +02:00
|
|
|
else:
|
|
|
|
return bpy.data.fonts.load(get_filepath(filename))
|
2020-09-18 17:04:24 +02:00
|
|
|
|
2021-03-24 16:08:12 +01:00
|
|
|
def load(self, data, target):
|
2020-09-28 10:40:07 +02:00
|
|
|
pass
|
2020-09-18 17:04:24 +02:00
|
|
|
|
2021-03-24 16:08:12 +01:00
|
|
|
def dump(self, instance=None):
|
2020-09-28 10:40:07 +02:00
|
|
|
if instance.filepath == '<builtin>':
|
|
|
|
filename = '<builtin>'
|
|
|
|
else:
|
|
|
|
filename = Path(instance.filepath).name
|
|
|
|
|
|
|
|
if not filename:
|
|
|
|
raise FileExistsError(instance.filepath)
|
|
|
|
|
2020-09-20 19:53:51 +02:00
|
|
|
return {
|
2020-09-28 10:40:07 +02:00
|
|
|
'filename': filename,
|
2020-09-20 19:53:51 +02:00
|
|
|
'name': instance.name
|
2020-09-18 17:04:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
def diff(self):
|
|
|
|
return False
|
2020-09-20 19:53:51 +02:00
|
|
|
|
2021-03-25 14:55:53 +01:00
|
|
|
@staticmethod
|
2021-03-26 12:30:15 +01:00
|
|
|
def resolve_deps(datablock: object) -> [object]:
|
2020-09-20 19:53:51 +02:00
|
|
|
deps = []
|
2021-03-25 14:55:53 +01:00
|
|
|
if datablock.filepath and datablock.filepath != '<builtin>':
|
|
|
|
ensure_unpacked(datablock)
|
2020-09-28 10:40:07 +02:00
|
|
|
|
2021-03-25 14:55:53 +01:00
|
|
|
deps.append(Path(bpy.path.abspath(datablock.filepath)))
|
2020-09-20 19:53:51 +02:00
|
|
|
|
|
|
|
return deps
|