blob: a714643028ff62d204e7cc0b7d2600bae44e1dde (
plain)
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
|
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ppapi/shared_impl/ppb_font_shared.h"
#include "ppapi/c/dev/ppb_font_dev.h"
namespace ppapi {
// static
bool PPB_Font_Shared::IsPPFontDescriptionValid(
const PP_FontDescription_Dev& desc) {
// Check validity of string. We can't check the actual text since we could
// be on the wrong thread and don't know if we're in the plugin or the host.
if (desc.face.type != PP_VARTYPE_STRING &&
desc.face.type != PP_VARTYPE_UNDEFINED)
return false;
// Check enum ranges.
if (static_cast<int>(desc.family) < PP_FONTFAMILY_DEFAULT ||
static_cast<int>(desc.family) > PP_FONTFAMILY_MONOSPACE)
return false;
if (static_cast<int>(desc.weight) < PP_FONTWEIGHT_100 ||
static_cast<int>(desc.weight) > PP_FONTWEIGHT_900)
return false;
// Check for excessive sizes which may cause layout to get confused.
if (desc.size > 200)
return false;
return true;
}
} // namespace ppapi
|