dan sinclair | 993a199 | 2017-10-25 20:21:09 -0400 | [diff] [blame] | 1 | // Copyright 2017 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 "fpdfsdk/javascript/cjs_font.h" |
| 8 | |
| 9 | JSConstSpec CJS_Font::ConstSpecs[] = { |
| 10 | {"Times", JSConstSpec::String, 0, "Times-Roman"}, |
| 11 | {"TimesB", JSConstSpec::String, 0, "Times-Bold"}, |
| 12 | {"TimesI", JSConstSpec::String, 0, "Times-Italic"}, |
| 13 | {"TimesBI", JSConstSpec::String, 0, "Times-BoldItalic"}, |
| 14 | {"Helv", JSConstSpec::String, 0, "Helvetica"}, |
| 15 | {"HelvB", JSConstSpec::String, 0, "Helvetica-Bold"}, |
| 16 | {"HelvI", JSConstSpec::String, 0, "Helvetica-Oblique"}, |
| 17 | {"HelvBI", JSConstSpec::String, 0, "Helvetica-BoldOblique"}, |
| 18 | {"Cour", JSConstSpec::String, 0, "Courier"}, |
| 19 | {"CourB", JSConstSpec::String, 0, "Courier-Bold"}, |
| 20 | {"CourI", JSConstSpec::String, 0, "Courier-Oblique"}, |
| 21 | {"CourBI", JSConstSpec::String, 0, "Courier-BoldOblique"}, |
| 22 | {"Symbol", JSConstSpec::String, 0, "Symbol"}, |
| 23 | {"ZapfD", JSConstSpec::String, 0, "ZapfDingbats"}, |
| 24 | {0, JSConstSpec::Number, 0, 0}}; |
| 25 | |
Dan Sinclair | 89d26c8 | 2017-10-26 12:21:28 -0400 | [diff] [blame^] | 26 | const char* CJS_Font::g_pClassName = "font"; |
| 27 | int CJS_Font::g_nObjDefnID = -1; |
| 28 | |
| 29 | void CJS_Font::DefineConsts(CFXJS_Engine* pEngine) { |
| 30 | for (size_t i = 0; i < FX_ArraySize(ConstSpecs) - 1; ++i) { |
| 31 | pEngine->DefineObjConst( |
| 32 | g_nObjDefnID, ConstSpecs[i].pName, |
| 33 | ConstSpecs[i].eType == JSConstSpec::Number |
| 34 | ? pEngine->NewNumber(ConstSpecs[i].number).As<v8::Value>() |
| 35 | : pEngine->NewString(ConstSpecs[i].pStr).As<v8::Value>()); |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | void CJS_Font::DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType) { |
| 40 | g_nObjDefnID = |
| 41 | pEngine->DefineObj(CJS_Font::g_pClassName, eObjType, nullptr, nullptr); |
| 42 | DefineConsts(pEngine); |
| 43 | } |