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 "../../../../include/fpdfapi/fpdf_resource.h"
8 #include "../../../../include/fpdfapi/fpdf_module.h"
9 #include "../../fpdf_font/font_int.h"
10 #include "../cmap_int.h"
11 extern const FX_WORD g_FXCMAP_GB_EUC_H_0[];
12 extern const FX_WORD g_FXCMAP_GB_EUC_V_0[];
13 extern const FX_WORD g_FXCMAP_GBpc_EUC_H_0[];
14 extern const FX_WORD g_FXCMAP_GBpc_EUC_V_0[];
15 extern const FX_WORD g_FXCMAP_GBK_EUC_H_2[];
16 extern const FX_WORD g_FXCMAP_GBK_EUC_V_2[];
17 extern const FX_WORD g_FXCMAP_GBKp_EUC_H_2[];
18 extern const FX_WORD g_FXCMAP_GBKp_EUC_V_2[];
19 extern const FX_WORD g_FXCMAP_GBK2K_H_5[];
20 extern const FX_WORD g_FXCMAP_GBK2K_H_5_DWord[];
21 extern const FX_WORD g_FXCMAP_GBK2K_V_5[];
22 extern const FX_WORD g_FXCMAP_UniGB_UCS2_H_4[];
23 extern const FX_WORD g_FXCMAP_UniGB_UCS2_V_4[];
24 extern const FX_WORD g_FXCMAP_GB1CID2Unicode_5[];
25 static const FXCMAP_CMap g_FXCMAP_GB1_cmaps[] = {
26     { "GB-EUC-H", FXCMAP_CMap::Range, g_FXCMAP_GB_EUC_H_0, 90, FXCMAP_CMap::None, NULL, 0, 0 },
27     { "GB-EUC-V", FXCMAP_CMap::Range, g_FXCMAP_GB_EUC_V_0, 20, FXCMAP_CMap::None, NULL, 0, -1 },
28     { "GBpc-EUC-H", FXCMAP_CMap::Range, g_FXCMAP_GBpc_EUC_H_0, 91, FXCMAP_CMap::None, NULL, 0, 0 },
29     { "GBpc-EUC-V", FXCMAP_CMap::Range, g_FXCMAP_GBpc_EUC_V_0, 20, FXCMAP_CMap::None, NULL, 0, -1 },
30     { "GBK-EUC-H", FXCMAP_CMap::Range, g_FXCMAP_GBK_EUC_H_2, 4071, FXCMAP_CMap::None, NULL, 0, 0 },
31     { "GBK-EUC-V", FXCMAP_CMap::Range, g_FXCMAP_GBK_EUC_V_2, 20, FXCMAP_CMap::None, NULL, 0, -1 },
32     { "GBKp-EUC-H", FXCMAP_CMap::Range, g_FXCMAP_GBKp_EUC_H_2, 4070, FXCMAP_CMap::None, NULL, 0, -2 },
33     { "GBKp-EUC-V", FXCMAP_CMap::Range, g_FXCMAP_GBKp_EUC_V_2, 20, FXCMAP_CMap::None, NULL, 0, -1 },
34     { "GBK2K-H", FXCMAP_CMap::Range, g_FXCMAP_GBK2K_H_5, 4071, FXCMAP_CMap::Single, g_FXCMAP_GBK2K_H_5_DWord, 1017, -4 },
35     { "GBK2K-V", FXCMAP_CMap::Range, g_FXCMAP_GBK2K_V_5, 41, FXCMAP_CMap::None, NULL, 0, -1 },
36     { "UniGB-UCS2-H", FXCMAP_CMap::Range, g_FXCMAP_UniGB_UCS2_H_4, 13825, FXCMAP_CMap::None, NULL, 0, 0 },
37     { "UniGB-UCS2-V", FXCMAP_CMap::Range, g_FXCMAP_UniGB_UCS2_V_4, 24, FXCMAP_CMap::None, NULL, 0, -1 },
38     { "UniGB-UTF16-H", FXCMAP_CMap::Range, g_FXCMAP_UniGB_UCS2_H_4, 13825, FXCMAP_CMap::None, NULL, 0, 0 },
39     { "UniGB-UTF16-V", FXCMAP_CMap::Range, g_FXCMAP_UniGB_UCS2_V_4, 24, FXCMAP_CMap::None, NULL, 0, -1 },
40 };
LoadEmbeddedGB1CMaps()41 void CPDF_ModuleMgr::LoadEmbeddedGB1CMaps()
42 {
43     CPDF_FontGlobals* pFontGlobals = CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGlobals();
44     pFontGlobals->m_EmbeddedCharsets[CIDSET_GB1].m_pMapList = g_FXCMAP_GB1_cmaps;
45     pFontGlobals->m_EmbeddedCharsets[CIDSET_GB1].m_Count = sizeof g_FXCMAP_GB1_cmaps / sizeof (FXCMAP_CMap);
46     pFontGlobals->m_EmbeddedToUnicodes[CIDSET_GB1].m_pMap = g_FXCMAP_GB1CID2Unicode_5;
47     pFontGlobals->m_EmbeddedToUnicodes[CIDSET_GB1].m_Count = 30284;
48 }
49