| Index: content/renderer/pepper/pepper_truetype_font_mac.mm
|
| diff --git a/content/renderer/pepper/pepper_truetype_font_mac.mm b/content/renderer/pepper/pepper_truetype_font_mac.mm
|
| index 0c396a39db797be41bd60b349467127e76da40d7..6ef16ee2fa80481a9c27e9a57efa73644ffbd253 100644
|
| --- a/content/renderer/pepper/pepper_truetype_font_mac.mm
|
| +++ b/content/renderer/pepper/pepper_truetype_font_mac.mm
|
| @@ -16,11 +16,20 @@
|
| #include "base/sys_byteorder.h"
|
| #include "ppapi/c/dev/ppb_truetype_font_dev.h"
|
| #include "ppapi/c/pp_errors.h"
|
| +#include "ppapi/proxy/serialized_structs.h"
|
|
|
| namespace content {
|
|
|
| namespace {
|
|
|
| +static bool FindFloat(CFDictionaryRef dict, CFStringRef name, float* value) {
|
| + CFNumberRef num;
|
| + return
|
| + CFDictionaryGetValueIfPresent(dict, name, (const void**)&num) &&
|
| + CFNumberIsFloatType(num) &&
|
| + CFNumberGetValue(num, kCFNumberFloatType, value);
|
| +}
|
| +
|
| float GetMacWeight(PP_TrueTypeFontWeight_Dev weight) {
|
| // Map values from NORMAL (400) to HEAVY (900) to the range [0 .. 1], and
|
| // values below NORMAL to the range [-0.6 .. 0]. NORMAL should map to 0.
|
| @@ -234,28 +243,18 @@ int32_t PepperTrueTypeFontMac::Describe(
|
| if (symbolic_traits & kCTFontBoldTrait) {
|
| desc->weight = PP_TRUETYPEFONTWEIGHT_BOLD;
|
| } else {
|
| - base::mac::ScopedCFTypeRef<CFNumberRef> weight_trait_ref(
|
| - static_cast<CFNumberRef>(
|
| - CFDictionaryGetValue(traits_ref, kCTFontWeightTrait)));
|
| - if (weight_trait_ref) {
|
| - float weight;
|
| - if (CFNumberGetValue(weight_trait_ref, kCFNumberFloat32Type, &weight))
|
| - desc->weight = GetPepperWeight(weight);
|
| - }
|
| + float weight;
|
| + if (FindFloat(traits_ref, kCTFontWeightTrait, &weight))
|
| + desc->weight = GetPepperWeight(weight);
|
| }
|
| if (symbolic_traits & kCTFontCondensedTrait) {
|
| desc->width = PP_TRUETYPEFONTWIDTH_CONDENSED;
|
| } else if (symbolic_traits & kCTFontExpandedTrait) {
|
| desc->width = PP_TRUETYPEFONTWIDTH_EXPANDED;
|
| } else {
|
| - base::mac::ScopedCFTypeRef<CFNumberRef> width_trait_ref(
|
| - static_cast<CFNumberRef>(
|
| - CFDictionaryGetValue(traits_ref, kCTFontWidthTrait)));
|
| - if (width_trait_ref) {
|
| - float width;
|
| - if (CFNumberGetValue(width_trait_ref, kCFNumberFloat32Type, &width))
|
| - desc->width = GetPepperWidth(width);
|
| - }
|
| + float width;
|
| + if (FindFloat(traits_ref, kCTFontWidthTrait, &width))
|
| + desc->width = GetPepperWidth(width);
|
| }
|
|
|
| // Character set isn't supported on Mac.
|
|
|