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/cpdf_document.h" | 9 #include "core/include/fpdfapi/cpdf_document.h" |
10 #include "core/include/fpdfapi/fpdf_module.h" | 10 #include "core/include/fpdfapi/fpdf_module.h" |
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
764 for (int i = 0; i < 4; i++) { | 764 for (int i = 0; i < 4; i++) { |
765 pBBox->AddInteger(bbox[i]); | 765 pBBox->AddInteger(bbox[i]); |
766 } | 766 } |
767 pFontDesc->SetAt("FontBBox", pBBox); | 767 pFontDesc->SetAt("FontBBox", pBBox); |
768 pFontDesc->SetAtInteger("ItalicAngle", italicangle); | 768 pFontDesc->SetAtInteger("ItalicAngle", italicangle); |
769 pFontDesc->SetAtInteger("Ascent", ascend); | 769 pFontDesc->SetAtInteger("Ascent", ascend); |
770 pFontDesc->SetAtInteger("Descent", descend); | 770 pFontDesc->SetAtInteger("Descent", descend); |
771 pFontDesc->SetAtInteger("CapHeight", capheight); | 771 pFontDesc->SetAtInteger("CapHeight", capheight); |
772 CGFloat fStemV = 0; | 772 CGFloat fStemV = 0; |
773 int16_t min_width = SHRT_MAX; | 773 int16_t min_width = SHRT_MAX; |
| 774 |
774 static const UniChar stem_chars[] = {'i', 'I', '!', '1'}; | 775 static const UniChar stem_chars[] = {'i', 'I', '!', '1'}; |
775 const size_t count = sizeof(stem_chars) / sizeof(stem_chars[0]); | 776 CGGlyph glyphs[FX_ArraySize(stem_chars)]; |
776 CGGlyph glyphs[count]; | 777 CGRect boundingRects[FX_ArraySize(stem_chars)]; |
777 CGRect boundingRects[count]; | 778 |
| 779 const size_t count = FX_ArraySize(stem_chars); |
778 if (CTFontGetGlyphsForCharacters(font, stem_chars, glyphs, count)) { | 780 if (CTFontGetGlyphsForCharacters(font, stem_chars, glyphs, count)) { |
779 CTFontGetBoundingRectsForGlyphs(font, kCTFontHorizontalOrientation, glyphs, | 781 CTFontGetBoundingRectsForGlyphs(font, kCTFontHorizontalOrientation, glyphs, |
780 boundingRects, count); | 782 boundingRects, count); |
781 for (size_t i = 0; i < count; i++) { | 783 for (size_t i = 0; i < count; i++) { |
782 int16_t width = boundingRects[i].size.width; | 784 int16_t width = boundingRects[i].size.width; |
783 if (width > 0 && width < min_width) { | 785 if (width > 0 && width < min_width) { |
784 min_width = width; | 786 min_width = width; |
785 fStemV = min_width; | 787 fStemV = min_width; |
786 } | 788 } |
787 } | 789 } |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1142 void FPDFAPI_FlatPageAttr(CPDF_Dictionary* pPageDict, | 1144 void FPDFAPI_FlatPageAttr(CPDF_Dictionary* pPageDict, |
1143 const CFX_ByteStringC& name) { | 1145 const CFX_ByteStringC& name) { |
1144 if (pPageDict->KeyExist(name)) { | 1146 if (pPageDict->KeyExist(name)) { |
1145 return; | 1147 return; |
1146 } | 1148 } |
1147 CPDF_Object* pObj = FPDFAPI_GetPageAttr(pPageDict, name); | 1149 CPDF_Object* pObj = FPDFAPI_GetPageAttr(pPageDict, name); |
1148 if (pObj) { | 1150 if (pObj) { |
1149 pPageDict->SetAt(name, pObj->Clone()); | 1151 pPageDict->SetAt(name, pObj->Clone()); |
1150 } | 1152 } |
1151 } | 1153 } |
OLD | NEW |