summaryrefslogtreecommitdiffstats
path: root/src/core/file_sys/system_archive/shared_font.cpp
blob: 9ea16aa59ed5176fd4cebc88a2137cd428af5eb6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

#include "core/file_sys/system_archive/data/font_chinese_simplified.h"
#include "core/file_sys/system_archive/data/font_chinese_traditional.h"
#include "core/file_sys/system_archive/data/font_extended_chinese_simplified.h"
#include "core/file_sys/system_archive/data/font_korean.h"
#include "core/file_sys/system_archive/data/font_nintendo_extended.h"
#include "core/file_sys/system_archive/data/font_standard.h"
#include "core/file_sys/system_archive/shared_font.h"
#include "core/file_sys/vfs/vfs_vector.h"
#include "core/hle/service/ns/platform_service_manager.h"

namespace FileSys::SystemArchive {

namespace {

template <std::size_t Size>
VirtualFile PackBFTTF(const std::array<u8, Size>& data, const std::string& name) {
    std::vector<u32> vec(Size / sizeof(u32));
    std::memcpy(vec.data(), data.data(), vec.size() * sizeof(u32));

    std::vector<u8> bfttf(Size + sizeof(u64));

    size_t offset = 0;
    Service::NS::EncryptSharedFont(vec, bfttf, offset);
    return std::make_shared<VectorVfsFile>(std::move(bfttf), name);
}

} // Anonymous namespace

VirtualDir FontNintendoExtension() {
    return std::make_shared<VectorVfsDirectory>(
        std::vector<VirtualFile>{
            PackBFTTF(SharedFontData::FONT_NINTENDO_EXTENDED, "nintendo_ext_003.bfttf"),
            PackBFTTF(SharedFontData::FONT_NINTENDO_EXTENDED, "nintendo_ext2_003.bfttf"),
        },
        std::vector<VirtualDir>{});
}

VirtualDir FontStandard() {
    return std::make_shared<VectorVfsDirectory>(
        std::vector<VirtualFile>{
            PackBFTTF(SharedFontData::FONT_STANDARD, "nintendo_udsg-r_std_003.bfttf"),
        },
        std::vector<VirtualDir>{});
}

VirtualDir FontKorean() {
    return std::make_shared<VectorVfsDirectory>(
        std::vector<VirtualFile>{
            PackBFTTF(SharedFontData::FONT_KOREAN, "nintendo_udsg-r_ko_003.bfttf"),
        },
        std::vector<VirtualDir>{});
}

VirtualDir FontChineseTraditional() {
    return std::make_shared<VectorVfsDirectory>(
        std::vector<VirtualFile>{
            PackBFTTF(SharedFontData::FONT_CHINESE_TRADITIONAL,
                      "nintendo_udjxh-db_zh-tw_003.bfttf"),
        },
        std::vector<VirtualDir>{});
}

VirtualDir FontChineseSimple() {
    return std::make_shared<VectorVfsDirectory>(
        std::vector<VirtualFile>{
            PackBFTTF(SharedFontData::FONT_CHINESE_SIMPLIFIED,
                      "nintendo_udsg-r_org_zh-cn_003.bfttf"),
            PackBFTTF(SharedFontData::FONT_EXTENDED_CHINESE_SIMPLIFIED,
                      "nintendo_udsg-r_ext_zh-cn_003.bfttf"),
        },
        std::vector<VirtualDir>{});
}

} // namespace FileSys::SystemArchive