summaryrefslogtreecommitdiff
path: root/core/fxge/cfx_font.cpp
AgeCommit message (Collapse)Author
2018-08-30Use span<> in CFX_FontMgrTom Sepez
Change-Id: I3f811b20399efac1b511e75d950699eee7192c65 Reviewed-on: https://pdfium-review.googlesource.com/41650 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-29Use pdfium::span<>/UnownedPtr in CFX_Font.Tom Sepez
Move some platform-specific ifdefs so the come last in each section as it is easier to read, perhaps. Change-Id: Ic1c2652c46ecebc63b66213735ed6d94737a7f32 Reviewed-on: https://pdfium-review.googlesource.com/41630 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-06-13Guard some non-windows only code in cfx_font with ifdefs.Tom Sepez
The callers are all in blocks controlled by the same ifdef. Change-Id: I2bf1dfd8725eefcfab5b05460fc31b0e7e08c75e Reviewed-on: https://pdfium-review.googlesource.com/35090 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-06-12Remove explicit calls to FXFT_Clear_Face_External_Stream().Tom Sepez
This landed earlier as part of a larger change that got reverted for unrelated reasons. Now re-land it by itself. See https://pdfium-review.googlesource.com/c/pdfium/+/33370 The current code could cause FT to try to free memory allocated by the caller, with potentially a different allocator. It appears that this may have been added ages ago as a way to kludge around a leak. If we're leaking, msan will find it, and we can deal with it properly rather than trying to force FT to tidy after us. Change-Id: I20abf4cd35d465de1f435ebe6d94b10c3ff74002 Reviewed-on: https://pdfium-review.googlesource.com/34930 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2018-06-04Revert "Remove more ifndef XFA cases"Tom Sepez
This reverts commit 38cb7263a0923dd5613da24b18d3d7ef052ff5e3. Reason for revert: Blocking prior revert. Original change's description: > Remove more ifndef XFA cases > > Remove FXFT_Clear_Face_External_Stream() calls, period. This would cause > FT to try to free memory allocated by the caller, with potentially a > different allocator. If we're leaking, msan will find it, and we can > deal with it properly rather than trying to force FT to tidy after us. > > Always call SetView(), if we have a PDF page. At worst, the link won't > be used in the XFA case. > > Always return 0 for the null document permissions. If we don't have a > document, then we can't dynamically tell if its an XFA doc, so there's > no reason to believe it should have all permissions. If there is an > XFA doc under the covers, then the extension will give us the value. > > > Change-Id: I6e3fb589eda722786567d96288cb35f43643437b > Reviewed-on: https://pdfium-review.googlesource.com/33370 > Commit-Queue: Tom Sepez <tsepez@chromium.org> > Reviewed-by: Lei Zhang <thestig@chromium.org> TBR=thestig@chromium.org,tsepez@chromium.org # Not skipping CQ checks because original CL landed > 1 day ago. Change-Id: I68b6a50ef28fb3d6ab9d8494c4486ca9fb66589e Reviewed-on: https://pdfium-review.googlesource.com/33734 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-06-02Remove more ifndef XFA caseschromium/3449chromium/3448Tom Sepez
Remove FXFT_Clear_Face_External_Stream() calls, period. This would cause FT to try to free memory allocated by the caller, with potentially a different allocator. If we're leaking, msan will find it, and we can deal with it properly rather than trying to force FT to tidy after us. Always call SetView(), if we have a PDF page. At worst, the link won't be used in the XFA case. Always return 0 for the null document permissions. If we don't have a document, then we can't dynamically tell if its an XFA doc, so there's no reason to believe it should have all permissions. If there is an XFA doc under the covers, then the extension will give us the value. Change-Id: I6e3fb589eda722786567d96288cb35f43643437b Reviewed-on: https://pdfium-review.googlesource.com/33370 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-05-31Move codepage/charset methods into related places.Artem Strygin
Change-Id: I71417cc5b1bd00f77d42740198cc17487ebd686e Reviewed-on: https://pdfium-review.googlesource.com/33330 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Art Snake <art-snake@yandex-team.ru>
2018-05-31Fix font regression in AdjustMMParamsNicolas Pena
Commit 2334660 changed the |dest_width| in CFX_Font::AdjustMMParams to unsigned, but this means that dest_width - min_width becomes unsigned, which is wrong because the subtraction could be negative. This CL fixes this bug. Bug: chromium:845697 Change-Id: I88fb2f3ee3837d80ff5fa70a08309d9e0fec50e0 Reviewed-on: https://pdfium-review.googlesource.com/33150 Commit-Queue: Nicolás Peña Moreno <npm@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-05-29Pass a CFX_Matrix by reference in font code.chromium/3445Lei Zhang
The callers always pass in a valid CFX_Matrix, so eliminate the possibility of a nullptr. Change-Id: Id7d8b731ed60d5f66517b50c56efeca343e897c4 Reviewed-on: https://pdfium-review.googlesource.com/33152 Reviewed-by: Nicolás Peña Moreno <npm@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-04-12Make CFX_Font take FX_RECT out params by pointer.Lei Zhang
Change-Id: I6643aaf66bf3e9d53d5afab5c99a5cb7deab3661 Reviewed-on: https://pdfium-review.googlesource.com/30054 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-01-30Use unsigned for char widthchromium/3335Nicolas Pena
Bug: 806612 Change-Id: I22bd9046dd37a1b596762c46a6b29a323d6e9fa1 Reviewed-on: https://pdfium-review.googlesource.com/24410 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
2018-01-12Move some RetainPtr getters/setters out of headers.Lei Zhang
RetainPtr operations are not trivial. Change-Id: Ic106ada69d1c023a8132a2a59db17d550fd81fa0 Reviewed-on: https://pdfium-review.googlesource.com/22911 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2017-11-16Refactor CFGAS_FontMgr's Windows implementationNicolas Pena
This CL unifies a bit the public methods of CFGAS_FontMgr. It does so by replacing the multiple maps on the Windows implementation to a single map from hash to font. Also, cloning CFX_Fonts is avoided with the use of SetLogicalFontStyle. These Windows changes are just mimicking other OS's. As a side-effect, some members of CFX_Fonts are now owned so the raw pointers are replaced with unique_ptrs. Change-Id: I576d438572ccbe6c48f8f5cc434d66fc6adba372 Reviewed-on: https://pdfium-review.googlesource.com/18131 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
2017-11-07Remove m_bFlagExact from CFX_SubstFontNicolas Pena
This CL removes the single use case from |m_bFlagExact|. This flag allows the PDF viewer to treat a substitute font with a matching name as if it was actually an embedded font, which is wrong. For all substitute fonts, it is important to follow the longer process of first obtaining the unicode from the charcode to then obtain the glyph in the substitute font that corresponds to that unicode. Bug: chromium:781785 Change-Id: Ie5958b43914e0e46334b89b7c2c55c02d0da0c11 Reviewed-on: https://pdfium-review.googlesource.com/17859 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
2017-10-19Fix integer overflows in cfx_font.cpp.chromium/3245Henrique Nakashima
Bug: chromium:775587 Change-Id: If927ebc0080a53d1c67f0aee5cab525fbcc24260 Reviewed-on: https://pdfium-review.googlesource.com/16290 Reviewed-by: dsinclair <dsinclair@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
2017-09-28Cleanup font definesDan Sinclair
This CL removes duplicate defines between XFA and core. Several OR'd values have been coverted into individual booleans to make the code clearer. Change-Id: Ic32a71c711cffd9a0cf1136e5a22f0502e085c39 Reviewed-on: https://pdfium-review.googlesource.com/15071 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-09-27Move CFX_Font definition to cfx_font.hDan Sinclair
This CL moves the CFX_Font definition out of fx_font.h and into cfx_font.h to match the cfx_font.cpp implementation. Change-Id: Icc2fc7463fa4b9d0bec925e80b60a638136a83a1 Reviewed-on: https://pdfium-review.googlesource.com/14951 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2017-09-27Cleanup FX macrosDan Sinclair
This CL renames the FX_OS defines to have _OS_ in their names and drops the _DESKTOP suffix. The FXM defines have been changed to just FX. Change-Id: Iab172fba541713b5f6d14fb8098baf68e3364c74 Reviewed-on: https://pdfium-review.googlesource.com/14833 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-09-26Remove fx_text_int.hDan Sinclair
The CFX_SizeGlyphCache is only used internally by the CFX_FaceCache. This CL moves the definition to that file and removes fx_text_int.h Change-Id: I38f26f437f0eaa72492995ae7442d5c38ed2f229 Reviewed-on: https://pdfium-review.googlesource.com/14771 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-09-21Rename CFX_RetainPtr to RetainPtrDan Sinclair
This CL renames CFX_RetainPtr to RetainPtr and places in the fxcrt namespace. Bug: pdfium:898 Change-Id: I8798a9f79cb0840d3f037e8d04937cedd742914e Reviewed-on: https://pdfium-review.googlesource.com/14616 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-09-18Convert string class namesRyan Harrison
Automated using git grep & sed. Replace StringC classes with StringView classes. Remove the CFX_ prefix and put string classes in fxcrt namespace. Change AsStringC() to AsStringView(). Rename tests from TEST(fxcrt, *String*Foo) to TEST(*String*, Foo). Couple of tests needed to have their names regularlized. BUG=pdfium:894 Change-Id: I7ca038685c8d803795f3ed02545124f7a224c83d Reviewed-on: https://pdfium-review.googlesource.com/14151 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2017-08-31Remove fx_basic.hDan Sinclair
This CL removes the fx_basic.h header and fixes up includes as needed. Change-Id: I49af32a8327bdbcda40c50a61ffbd75d06609040 Reviewed-on: https://pdfium-review.googlesource.com/12670 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-08-23Convert string Find methods to return an OptionalRyan Harrison
The Find and ReverseFind methods for WideString, WideStringC, ByteString, and ByteStringC have been converted from returning a raw FX_STRSIZE, to returning Optional<FX_STRSIZE>, so that success/failure can be indicated without using FX_STRNPOS. This allows for removing FX_STRNPOS and by association makes the conversion of FX_STRSIZE to size_t easier, since it forces checking the return value of Find to be explictly done as well as taking the error value out of the range of FX_STRSIZE. New Contains methods have been added for cases where the success or failure is all the call site to Find cared about, and the actual position was ignored. BUG=pdfium:828 Change-Id: Id827e508c8660affa68cc08a13d96121369364b7 Reviewed-on: https://pdfium-review.googlesource.com/11350 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-08-01Replace raw value for constant error value in string operationsRyan Harrison
Currently Find() and other methods that return a FX_STRSIZE return -1 to indicate error/failure. This means that there is a lot of magic numbers and magic checks floating around. The standard library for similar operations uses a npos constant. This CL implements FX_STRNPOS, and replaces usages of magic number checking. It also does some type cleanup along the way where it was obvious that FX_STRSIZE should be being used. Removing the magic numbers should make eventually changing FX_STRSIZE to be unsigned easier in the future. BUG=pdfium:828 Change-Id: I67e481e44cf2f75a1698afa8fbee4f375a74c490 Reviewed-on: https://pdfium-review.googlesource.com/9651 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-07-10Move core/fxge/ge to core/fxge.Dan Sinclair
This brings the cpp and h files together and removes the redundant ge/ path. Change-Id: I36594b8ae719d362768ba4c2e4ce173e287363eb Reviewed-on: https://pdfium-review.googlesource.com/7452 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>