1// Copyright 2014 PDFium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7#include "core/fpdfapi/cmaps/Japan1/cmaps_japan1.h"
8
9#include "core/fpdfapi/cmaps/cmap_int.h"
10#include "core/fpdfapi/cpdf_modulemgr.h"
11#include "core/fpdfapi/font/cpdf_fontglobals.h"
12#include "core/fpdfapi/page/cpdf_pagemodule.h"
13
14static const FXCMAP_CMap g_FXCMAP_Japan1_cmaps[] = {
15    {"83pv-RKSJ-H", g_FXCMAP_83pv_RKSJ_H_1, nullptr, 222, 0, FXCMAP_CMap::Range,
16     0},
17    {"90ms-RKSJ-H", g_FXCMAP_90ms_RKSJ_H_2, nullptr, 171, 0, FXCMAP_CMap::Range,
18     0},
19    {"90ms-RKSJ-V", g_FXCMAP_90ms_RKSJ_V_2, nullptr, 78, 0, FXCMAP_CMap::Range,
20     -1},
21    {"90msp-RKSJ-H", g_FXCMAP_90msp_RKSJ_H_2, nullptr, 170, 0,
22     FXCMAP_CMap::Range, -2},
23    {"90msp-RKSJ-V", g_FXCMAP_90msp_RKSJ_V_2, nullptr, 78, 0,
24     FXCMAP_CMap::Range, -1},
25    {"90pv-RKSJ-H", g_FXCMAP_90pv_RKSJ_H_1, nullptr, 263, 0, FXCMAP_CMap::Range,
26     0},
27    {"Add-RKSJ-H", g_FXCMAP_Add_RKSJ_H_1, nullptr, 635, 0, FXCMAP_CMap::Range,
28     0},
29    {"Add-RKSJ-V", g_FXCMAP_Add_RKSJ_V_1, nullptr, 57, 0, FXCMAP_CMap::Range,
30     -1},
31    {"EUC-H", g_FXCMAP_EUC_H_1, nullptr, 120, 0, FXCMAP_CMap::Range, 0},
32    {"EUC-V", g_FXCMAP_EUC_V_1, nullptr, 27, 0, FXCMAP_CMap::Range, -1},
33    {"Ext-RKSJ-H", g_FXCMAP_Ext_RKSJ_H_2, nullptr, 665, 0, FXCMAP_CMap::Range,
34     -4},
35    {"Ext-RKSJ-V", g_FXCMAP_Ext_RKSJ_V_2, nullptr, 39, 0, FXCMAP_CMap::Range,
36     -1},
37    {"H", g_FXCMAP_H_1, nullptr, 118, 0, FXCMAP_CMap::Range, 0},
38    {"V", g_FXCMAP_V_1, nullptr, 27, 0, FXCMAP_CMap::Range, -1},
39    {"UniJIS-UCS2-H", g_FXCMAP_UniJIS_UCS2_H_4, nullptr, 9772, 0,
40     FXCMAP_CMap::Single, 0},
41    {"UniJIS-UCS2-V", g_FXCMAP_UniJIS_UCS2_V_4, nullptr, 251, 0,
42     FXCMAP_CMap::Single, -1},
43    {"UniJIS-UCS2-HW-H", g_FXCMAP_UniJIS_UCS2_HW_H_4, nullptr, 4, 0,
44     FXCMAP_CMap::Range, -2},
45    {"UniJIS-UCS2-HW-V", g_FXCMAP_UniJIS_UCS2_HW_V_4, nullptr, 199, 0,
46     FXCMAP_CMap::Range, -1},
47    {"UniJIS-UTF16-H", g_FXCMAP_UniJIS_UCS2_H_4, nullptr, 9772, 0,
48     FXCMAP_CMap::Single, 0},
49    {"UniJIS-UTF16-V", g_FXCMAP_UniJIS_UCS2_V_4, nullptr, 251, 0,
50     FXCMAP_CMap::Single, -1},
51};
52
53void CPDF_ModuleMgr::LoadEmbeddedJapan1CMaps() {
54  CPDF_FontGlobals* pFontGlobals =
55      CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGlobals();
56  pFontGlobals->SetEmbeddedCharset(CIDSET_JAPAN1, g_FXCMAP_Japan1_cmaps,
57                                   FX_ArraySize(g_FXCMAP_Japan1_cmaps));
58  pFontGlobals->SetEmbeddedToUnicode(CIDSET_JAPAN1,
59                                     g_FXCMAP_Japan1CID2Unicode_4, 15444);
60}
61