OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include <limits.h> | 7 #include <limits.h> |
8 | 8 |
9 #include "core/include/fpdfapi/fpdf_module.h" | 9 #include "core/include/fpdfapi/fpdf_module.h" |
10 #include "core/include/fpdfapi/fpdf_page.h" | 10 #include "core/include/fpdfapi/fpdf_page.h" |
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
763 for (int i = 0; i < 4; i++) { | 763 for (int i = 0; i < 4; i++) { |
764 pBBox->AddInteger(bbox[i]); | 764 pBBox->AddInteger(bbox[i]); |
765 } | 765 } |
766 pFontDesc->SetAt("FontBBox", pBBox); | 766 pFontDesc->SetAt("FontBBox", pBBox); |
767 pFontDesc->SetAtInteger("ItalicAngle", italicangle); | 767 pFontDesc->SetAtInteger("ItalicAngle", italicangle); |
768 pFontDesc->SetAtInteger("Ascent", ascend); | 768 pFontDesc->SetAtInteger("Ascent", ascend); |
769 pFontDesc->SetAtInteger("Descent", descend); | 769 pFontDesc->SetAtInteger("Descent", descend); |
770 pFontDesc->SetAtInteger("CapHeight", capheight); | 770 pFontDesc->SetAtInteger("CapHeight", capheight); |
771 CGFloat fStemV = 0; | 771 CGFloat fStemV = 0; |
772 int16_t min_width = SHRT_MAX; | 772 int16_t min_width = SHRT_MAX; |
| 773 |
773 static const UniChar stem_chars[] = {'i', 'I', '!', '1'}; | 774 static const UniChar stem_chars[] = {'i', 'I', '!', '1'}; |
774 const size_t count = sizeof(stem_chars) / sizeof(stem_chars[0]); | 775 CGGlyph glyphs[FX_ArraySize(stem_chars)]; |
775 CGGlyph glyphs[count]; | 776 CGRect boundingRects[FX_ArraySize(stem_chars)]; |
776 CGRect boundingRects[count]; | 777 |
| 778 const size_t count = FX_ArraySize(stem_chars); |
777 if (CTFontGetGlyphsForCharacters(font, stem_chars, glyphs, count)) { | 779 if (CTFontGetGlyphsForCharacters(font, stem_chars, glyphs, count)) { |
778 CTFontGetBoundingRectsForGlyphs(font, kCTFontHorizontalOrientation, glyphs, | 780 CTFontGetBoundingRectsForGlyphs(font, kCTFontHorizontalOrientation, glyphs, |
779 boundingRects, count); | 781 boundingRects, count); |
780 for (size_t i = 0; i < count; i++) { | 782 for (size_t i = 0; i < count; i++) { |
781 int16_t width = boundingRects[i].size.width; | 783 int16_t width = boundingRects[i].size.width; |
782 if (width > 0 && width < min_width) { | 784 if (width > 0 && width < min_width) { |
783 min_width = width; | 785 min_width = width; |
784 fStemV = min_width; | 786 fStemV = min_width; |
785 } | 787 } |
786 } | 788 } |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1141 void FPDFAPI_FlatPageAttr(CPDF_Dictionary* pPageDict, | 1143 void FPDFAPI_FlatPageAttr(CPDF_Dictionary* pPageDict, |
1142 const CFX_ByteStringC& name) { | 1144 const CFX_ByteStringC& name) { |
1143 if (pPageDict->KeyExist(name)) { | 1145 if (pPageDict->KeyExist(name)) { |
1144 return; | 1146 return; |
1145 } | 1147 } |
1146 CPDF_Object* pObj = FPDFAPI_GetPageAttr(pPageDict, name); | 1148 CPDF_Object* pObj = FPDFAPI_GetPageAttr(pPageDict, name); |
1147 if (pObj) { | 1149 if (pObj) { |
1148 pPageDict->SetAt(name, pObj->Clone()); | 1150 pPageDict->SetAt(name, pObj->Clone()); |
1149 } | 1151 } |
1150 } | 1152 } |
OLD | NEW |