summaryrefslogtreecommitdiff
path: root/include/mupdf/fitz/font.h
AgeCommit message (Collapse)Author
2018-11-13Add more encoding tables.Tor Andersson
Add tables for Windows-1250, Windows-1251, and ISO-8859-1. Also add unicode_from_encoding tables. Move encodings from PDF namespace to Fitz.
2018-09-21Add fz_lookup_cjk_font_by_name to create builtin CJK fonts.Tor Andersson
2018-09-21Regularize language and script names.Tor Andersson
Drop the unused 'serif' argument to the CJK lookup functions. Use the BCP 47 names for CJK scripts and languages: zh-Hant for traditional Chinese, zh-Hans for simplified Chinese, ja for Japanese, ko for Korean. The lookup function also allows commonly used language+country codes: zh-TW and zh-HK for traditional Chinese, zh-CN for simplified Chinese.
2018-09-05Use colorspace type enum instead of magic profile names.Tor Andersson
2018-07-05Pass rects by value: device and document interface.Tor Andersson
2018-07-05Pass matrices by value: device and document interface.Tor Andersson
2018-07-05Pass rect and matrix by value in geometry functions.Tor Andersson
Several things irk me about passing values as const pointers: * They can be NULL, which is not a valid value. * They require explicit temporary variables for storage. * They don't compose easily in a legible manner, requiring weird pointer passing semantics where the variable being assigned is hidden as an argument in the innermost function call. * We can't change the value through the pointer, requiring yet more local variables to hold copies of the input value. In the device interface where we pass a matrix to a function, we often find ourselves making a local copy of the matrix so we can concatenate other transforms to it. This copying is a lot of unnecessary busywork that I hope to eventually avoid by laying the groundwork with this commit. This is a rather large API change, so I apologize for the inconvenience, but I hope the end result and gain in legibility will be worth the pain.
2018-06-22Remember the md5 digest in the fz_font struct.Tor Andersson
2018-05-16Restore Emoji font.Tor Andersson
The Noto symbol font has been split into two. The second symbol font only contains a subset of the emojis, so reinstate the real emoji font and add both symbol fonts to the fallback chain.
2018-04-25Don't use WMode as part of CJK font lookup.Tor Andersson
Return TTC subfont index from fz_lookup_noto_font.
2018-04-11Rework how we handle DynaLab tricky fonts in freetype.Tor Andersson
Force the face_flags to include TRICKY if we detect a DynaLab font name instead of trying to force hinting ourselves.
2018-03-16Add simple functions to create the built-in fonts by name.Tor Andersson
2017-08-17Simplify stext structure and device.Tor Andersson
* Use pool allocator and linked lists for all levels. * Remove separate fz_stext_sheet struct. * Remove unused 'script' style. * Remove 'span' level items. * Detect visual/logical RTL layouts. * Detect indented paragraphs.
2017-06-29Harfbuzz tweaks.Robin Watts
Avoid defining any functions/variables beginning with hb_ to avoid potential namespace clashes. Clarify language about why the Harfbuzz workarounds are needed.
2017-06-22Use unsigned char arrays in hexdumped data.Tor Andersson
2017-06-22Add Color Management interface to MuPDF, with LCMS implementation.Michael Vrhel
This commit adds an interface for a color management engine to MuPDF, together with the internal changes required to use it. We also add an implementation of this interface using the LCMS2 library. This commit is the "lcms" development branch squashed to a single commit. The individual commits that make it up are as follows: ------ Add LCMS2 submodule. Add required source files to MSVC libthirdparty project. Plus changes to the Makefile. ------ Change name of libfont to libresources The library can hold things other than fonts including ICC profiles and eventually halftone screens etc. ------ Generate and include icc profiles on windows solution Makefile for linux needs to be updated ------ Initial cut at interface to little cms Methods for getting profile handles, link handles and transform buffers as well as individual colors. ------ Install ICC profiles from source When the source color space is an ICC profile install the ICC space. Use alternative color space if ICC is invalid. ------ Rename ICC resources The way that fontdump generates the names was causing some redundant prefix/suffix combinations. ------ Make resource ICC profiles usable This brings in the resource profiles for use with the target device. When mudraw is invoked with the icc color type, it will set up the target pixmap to have an icc based color space. ------ Make Default ICC color spaces not storable The ICC color spaces in the color context should not be put into the store. ICC color spaces that are contained in the source document are however storable. ------ Add in support for single color conversion This adds in the selection of the icc single color converter. Note that we may want to look at using the float conversion in lcms here since we are going from and to float. The down side is that the creation of such converters may be expensive. ------ Pixmap ICC conversion Also clean up and further simplify some of the code. Use common dst, src in function parameters instead of src, dst. ------ Add md5 calculation for profiles Compare md5 of source and destination. If they are the same set link as identity and do not bother creating link from cmm. ------ Initial attempt at adding links to store Next need to make sure I have all the dropping set up correctly and that the links are getting freed when we are all done with them. ------ Add drop for link Make sure that we drop the links when we are done with them. ------ Fix icc link store ref. counting + rendering intent The key allocations, rc and removal was wrong for the icc links. Also added in support on the graphic state for rendering intent. ------ Add ICC profiles to Makefile. ------ Move ICC profile loading to colorspace.c ------ Fix build on linux. ------ Use hexdump in creating icc profiles ------ First cut at CalRGB CalGray handling These color spaces are converted to equivalent ICC profiles when the drawing operation occurs. ToDo still is avoid creating brand new CalGray, CalRGB or ICC color spaces when we encounter the same object in the source file. Instead we should make use of the store. ------ Adding fz_color_params into device API Stroke and fill of paths and text which will have color rendering related settings including overprint, overprint mode, rendering intent and black point settings. Images have a fz_color_params member added to them. ------ Rendering intent support for graphic and text Graphic fills and strokes as well as text fill and strokes handle the rendering intent settings. This works through the display list. The parameters related to color rendering, ri, bp, op, opm are packed in the flags bits through the display list. To do: Add support for images and shadings. ------ Add support for rendering intent with images Required change to fill_image api, hence the large number of files touched. ------ Add support for shadings rendering intent and DeviceN This adds support for the rendering intent in shading fills. Also, adds in support for color management of DeviceN and Separation color spaces where the base space is defined to be ICC. ------ Add clamping proc to colorspace-imp.h In the head of mupdf, the index color values were not being clamped properly. I moved the clamping operation to be performed by a procedure in of the color space. The a*, b* values in LAB will need to include a range value for proper clamping as well as the ICC color space at some point. ------ Fix assert test with index images ------ Support for DeviceN images color managed The base space for DeviceN and separation images is now color managed when the ICC work flow is used. ------ Add DefaultGray etc to names.txt The DefaultGray, DefaultRGB, and DefaultCMYK settings in the pdf page resource dictionary need to be parsed and handled if present. ------ Remove methods for setting color space in context The methods that existed for setting the color spaces in the color space context were broken and we will not be changing them from their initial setting at startup. ------ Add front end support for default color spaces PDF can specify in the resource dictionary color spaces that should be used for DeviceGray, DeviceRGB and DeviceCMYK. This commit handles the extraction of these color spaces and passes them through the display list and gets them into a structure on a draw device (if one is used). Next step is to have the draw device make use of them. ------ Backend of default color spaces This handles the use of page level definitions for DefaultGray, DefaultRGB, DefaultCMYK in the draw device. The interface for the pixmap color conversion had to be expanded a bit to pass the default_cs object. This was needed due to the fact that the image could be DeviceN or Separation and have a base space that needs to be replaced by a page level Default color space. Tested this with a file that had two pages each with an common reference image object but different DefaultCMYK definitions in the page resource dictionary. Proper rendering was obtained. ------ Add icc support to band-writer and png output For image viewers that support icc profiles, it is important that we include the icc profile into those formats that support. Currently the only output format we have that supports it is PNG. But if we decide to do tiff, jpeg or psd those also support the embedding of icc profiles. ------ Work toward multithreading Each cloned context creates a new cmm context to reduce contention. This may not be optimal though as it may create conflicts in any shared store. ------ Add missing files. Failed to check in icc-imp.h and icc34.h ------ Fix default device color calls copy and paste errors. ------ Fixes ------ Fix clamping of lab colors The lab colors when used with the lab resource profile need to be properly clamped and scaled. ------ Turn off ICC create debug define ------ Fix memory leak issues ------ Set clamp proc in color context color spaces When NO_ICC is enabled there was an issue as the default spaces did not have the clamp proc (which was added in the lcms branch). ------ Fix several issues after rebase During rebase of the branch there were several issues that came up. In addition there was a fix related to the use of the lcms2 context branch that did not make it in for some reason. ------ Fix for fz_store_type structure changes ------ Fixes for multithreaded This fixes a few issues. One issue is that we can not be changing the input and output formatter for the links if they are being shared among threads. This adds the format as part of the link definition. Next step is to create a link clone operation in lcms so that we can readily create a different one with everything the same except the formatter. Also, this shares the profiles that exist in the color context among the threads. When a context is cloned, it will use the profiles in the current context but it will create a new cmm context.c ------ Fix NO_ICC issues There were a few issues that occurred when we compiled and ran with the NO_ICC setting. ------ Change CMM to use lower resolution tables in links The table resolution greatly affects the performance for some files. I don't see any significant color rendering issues going with a lower resolution. Selecting cmsFLAGS_LOWRESPRECALC uses a MLUT resolution of 17. This is going to be sufficient color wise and gives a large improvement performance wise especially for files where the color link creation is significant compared to the rendering. ------ Fix link key creation to populate alpha and bit depth. The store key for icc links needs to include the bit depth and if the transform has to handle an alpha value. This is needed due to the fact that we can't change the formatter when we are sharing links among different threads. ------ Pull in some MSVC 2005 fixes for lcms2 ------ Fix non-prototype prototype. ------ Miscellaneous typos, whitespace fixes. ------ Tidy colorspace creation API. Rather than pass a magic implementation reference count value (-1 for static, 1 for normal), pass a boolean "is_static" flag. This gives a nicer API (IMAO etc). ------ Make all colorspaces use an fz_buffer. ------ Fix internal naming of MSVC project file. ------ Fix some error handling. ------ Add some consts. ------ Tweak fz_color_params and fz_store_hash. Use uint8_t for fz_color_param entries - no need to use larger. Same change in fz_store_hash. This limits the size required for the hash table too. ------ Throw on errors, rather than returning NULL. fz_cmm_transform_pixmap should throw if it's fed pixmaps incompatible with its transforms. fz_cmm_new_ctx should throw if the cmm fails to initialise. ------ Ensure LCMS2_OBJs are built/linked using Makefile. Also ensure that ICC_OBJs are included. ------ Fix some unused variable warnings. ------ cs_params fixes. Use the ones that are passed. ------ fz_color_params tweaks. Make them const in many places. Cope with cs_params == NULL meaning default (i.e. fz_cs_param(ctx)). Minimise the places we call fz_cs_params(ctx). Consistently use cs_params rather than a mix of cs_param and cs_params. ------ Improve PDF color params handling. PDF allows different OP settings for strokes and fills. This means that either we need to keep separate entries in each fz_color_param structure for the stroke one or the fill one, OR we need to duplicate the fz_color_param structure. It seems neatest to do the latter (not least because this means we don't pass more information to each device function than it actually needs). Accordingly, we put an fz_color_param in each pdf_material. We update the code that reads ExtGStates to set the values appropriately. We take the opportunity to add support for the PDF 2.0 UseBlackPtComp option too. ------ Fix colorspace ref count problems. 1) Don't drop colorspace until we've finished using it. 2) Don't drop it twice. ------ Convert NULL deref into a thrown error. Seen with: mutool draw -D -o out.png ../tests_private/comparefiles/Bug689760.pdf We seem to have a pdf-cal space with no profile. Talk to Michael about this. ------ Avoid using colorspace names to distinguish colorspaces. Using strcmp is slow. ------ Cope with failure to parse default colorspaces during PDF page load. ------ Avoid SEGV due to to pdf_cal space with no profile. As seen in: tests_private/pdf/PDFIA1.7_SUBSET/CATX4879.pdf ------ Handle cases where base space of sep is pdf-cal We handled this for images, but not for solid fills. ------ Accelerate ICC color conversion. ------ Cope with indexed images in the color management. Some images (JPX images) come to the cm code still in the indexed color space. Their base space could be DevN so we need to cope with multiple base decodes. This continues the decode until we get to a space for which we can create an ICC link. ------ Ignore alpha presence in component count check ------ Eliminate recursion in fz_source_colorspace_cm. ------ Cope with bare ICCBased colorspace defs. Bug692137.pdf has ICCBased colorspaced definitions given directly as a stream, rather than as [ /ICCBased <stream reference> ] Acrobat copes with these, as does gs. We therefore update our code to cope too. Also, the PDF spec says that any problems found when reading the Default spaces should be ignored (or at least not to abort rendering). Update our code to do that too. ------ Tweak color converter logic for speed. When we are using an icc profile based conversion, avoid ever having to lookup the color converter for each conversion call; do it at the lookup stage. ------ Harden us against failures during ICC link creation. Seen with corrupted profiles. ------ Fix for handling alpha with lcms. Note that this currently maintains an alpha when it is present. We may need to do some work for the gray scale conversion to alpha mask. ------ Delay pdf-cal profile creation Put the creation of the pdf cal profile into the link creation function (rather than have it scattered). Also be robust in the condition of failure to create the profile. ------ Proper clamping with embedded CIELAB ICC profile If the ICC profiles alternate color space is LAB then use the LAB clamping proc. ------ Use the color space clamp when converting to base color spaces In many of the Ghent test files, we have a DeviceN image whose alternate color space is CIELAB. We need to make sure to use the CIELAB clamping operation in this case. ------ Make ICC runtime configurable. Add fz_icc_flowflow, fz_set_icc_workflow functions to read ICC workflow state, and set the ICC workflow state. The latter will throw an error if trying to enable ICC workflow in a NO_ICC build. Add -N flag to mutool to disable ICC. Incorporates build fixes from Michael. ------ Ensure fz_draw_fill_image uses the pixmap colorspace It appears that the image colorspace historically has been able to differ from the pixmap colorspace. While we've fixed the cases that we know about for this (see the previous commits), tweak fz_draw_fill_image to work the way it always has in the past. ------ Add support for output intent PDF documents can have an ICC profile defined in their Catalog which defines the output color space and the color space to use for one of the Device color spaces (e.g. DeviceGray, DeviceRGB or DeviceCMYK). ------ Catch errors in default color spaces Before setting the default color space contained in the file, make sure it is the correct type. Bug692213.pdf ------ Clamp to base space during sep color conversion This was the source of a problem when the base space was CIELAB. ------ Rename some functions to be more MuPDFy drop rather than free etc. ------ Fix "casting away const" warning. srcv is a const *. Do the clamping operation on src_map (the same value) before it is assigned into the const variable. ------ Rejig top level color management interface slightly. Same code, just change the encapsulation. ------ Remove pre-multiplied alpha prior to color management The pixmaps in mupdf use a premultiplied alpha format. Prior to doing any color management we need to undo the alpha and then reapply after color management. ------ Remove global output intent as unused. ------ Move fz_color_params to be the final arg in dev calls. Frequently this will be NULL, and it doesn't form part of the colorspace/color/alpha triple. ------ Rename fz_default_xxx static variables. Remove fz prefix, to prepare for a later renaming that would conflict. ------ Rename cs_params to color_params. ------ Rename lcms branch identifiers. ------ Return device colorspaces if the default colorspace is NULL. ------ Clean up device call function for set_default_colorspaces. ------ Add missing rethrow. ------ Load page default colorspaces lazily. ------ murun: Add color params device argument. Stubbed to always be NULL at the moment. ------ Rename extgstate processor ops. ------ Fix a few minor issues from Tor Removes icc-imp.h Rename color-icccreate.c Add context to some methods ------ Fix javalib with recent lcms dev changes. ------ Update lcms2 with sub project fixes. ------ Fix build failure. ------ Add icc profile into other PNG output methods ------ Fix some ints that should be size_t's. ------ Tweak fz_new_icc_data_from_icc_colorspace. Ensure that the colorspace is const, and that we set size to 0 if we don't find any data. ------ Combine band writer methods for header and ICC writing For many formats (like PSD), we need to delay writing some of the header until we know whether we are getting an ICC profile to write or not. Makes more sense to just write them at the same time. ------ Miscellaneous tweaks in colorspace.c Mainly to avoid pointer aliasing, "nicer" whitespace, and a leak on error. ------ Avoid rightward drift in get_base_icc. ------ Ensure that pdf_load_output_intent copes with exceptions. If load_icc_based throws and exception, warn and continue. Don't not render a file just because the inbuilt default profiles are broken. ------ Revert change in pdf-page.c The page resources load had been moved so we could get the default colorspaces, but this has been moved into run_contents, so putting stuff back as it was before. ------ Revert changes in mudraw. We had added some colorspages in mudraw, and then later removed them. Revert the changes to accomodate this to make the overall branch diffs smaller. ------ Use fz_buffer in color-icc-create.c ------ Force mapping through proof icc profile always. ------ Fix behaviour on fz_cmm_new_profile failure. If the profile fails to be made, return an error code, and have the callers take sane steps. ------ Tweak load_icc_based Cope better with errors in reading the ICC space not stopping us loading the alternate. ------ Remove unused variable. ------ Get page resource for DefaultCS look-up res = pdf_dict_get(ctx, PDF_NAME_Resources, page->obj); was not returning resource. Replaced with res = pdf_page_resources(ctx, page); ------ Move default color space set up to pdf_run_page_contents_with_usage ------ Review fixes for lcms branch. ------ Fixes for calibrated colorspace loading. ------ Add fz_document_output_intent wrapper. Lazy load intent for PDF. ------ Copy DefaultCS logic into pdf_run_annot_with_usage. Same code as from pdf_run_page_contents_with_usage. ------ More review fixes. ------ Avoid rightward drift in pdf_load_cal_common ------ Rename color_converter functions to be find/drop. Better than than lookup/discard. lookup suggests something that doesn't need dropping, and we use drop rather than discard by convention. ------ Move cmm from context into colorspace context. ------ Review fixes: Remove recursion and rename functions. ------ Don't access doc->oi directly in pdf_load_default_colorspaces. ------ Rename fz_colorspace_is_pdf_cal to fz_colorspace_is_cal and make it public. ------ Tweak function naming to be more consistent. ------ fz_md5_icc can be implemented using fz_md5_buffer. ------ Print full md5 checksums in link key debug prints. ------ Make fz_md5_buffer NULL safe. ------ Simplify debug saving of ICC profiles. ------ Rename fz_cmm_new/drop_profile to init/fin. ------ Indentation cleanups. ------ Move CMM static inline functions from private header to C file. ------ Tweak fz_icc_data_from_icc_colorspace to return a buffer. Also, remove the _new_ from the name to reflect the fact that we are passed a borrowed handle, not given a new reference. ------ java: Add ColorParams.pack() function. ------ Generate one C file for the embedded ICC profiles. ------ Return const pointer from fz_default_color_params. ------ Change misleading argument names to fz_new_colorspace. ------ Rename fz_cmm_new/drop_link to fz_cmm_init/fin_link. ------ Change definition of fz_cmm_instance. Rather than void, use an undefined struct in keeping with the rest of the code. ------ Add support for color managed bgr color space ------ Return unsigned char array from fz_lookup_icc. ------ Make default_color_params immutable. Changing the defaults used by the draw device should happen via a device call, should we need the functionality in the future. ------ Clean up error handling in color-lcms.c ------ Fix signed/unsigned warning.
2017-05-25Update Type 3 font bbox with glyph bboxes if the former is invalid.Tor Andersson
Fix for bug 697943. Set the initial replacement font bbox to the empty rectangle for type3 fonts, and let the type3 glyph loading initialize by taking the union of all glyph bboxes. Set the replacement font bbox for non-Type3 fonts to the unit rectangle. Also remove unused flag from fz_font struct.
2017-04-27Typedef function pointers consistently.Tor Andersson
2017-04-27Remove debug printing code.Tor Andersson
It's not used, so prone to bit rot. Better to purge it.
2017-02-20Add fz_font_is_bold and italic functions. Use them for svg output.Tor Andersson
2017-01-20Add system fallback font callback.Tor Andersson
2017-01-17Fix typos.Sebastian Rasmussen
2017-01-17Fix 697476: Rename header files.Tor Andersson
Xcode has an idiotic default configuration where it gets confused by include search paths and file names in projects, so that it will load our "mupdf/fitz/math.h" instead of the system <math.h>. Work around this by renaming header files that have the same base name as a system header (even though they live in a subdirectory, and should never be available directly on the compiler's include path).
2016-11-14More API tweaks.Robin Watts
Move internal functions from public to private headers.
2016-10-07Add ctx to fz_font functions.Robin Watts
2016-10-07Add comments to API declarations.Robin Watts
2016-10-05Add a const to a lookup function.Robin Watts
2016-10-05Uncouple font shaper data from harfbuzz.Robin Watts
The fz_font structure now doesn't know anything about harfbuzz at all, it merely offers an abstract 'fz_shaper_data_t' entry.
2016-10-05Move fz_font definition to be private.Robin Watts
Move the definition of fz_font to be in a private header file rather than in the public API. Add accessors for specific parts of the structure and use them as appropriate. The font flags, and the harfbuzz records remain public. This means that only 3 files now need access to the font implementation (font.c, pdf-font.c and pdf-type3.c). This may be able to be improved further in future.
2016-08-01Move to bitfields in fz_font rather than chars/ints etc.Robin Watts
2016-08-01Bug 696984: Badly rendered characters.Robin Watts
The type3 font(s) in the file have an invalid (0 sized) bbox, hence the clipping of the chars goes wrong. We now spot the invalid bbox, and suppress the clipping.
2016-07-08git stripspaceTor Andersson
2016-06-23epub: Use markup language when shaping and selecting fallback fonts.Tor Andersson
2016-05-30Avoid fz_font pulling harfbuzz in.Robin Watts
We store an hb_font in every font, and currently have fz_drop_font know to call harfbuzz to destroy it. This causes harfbuzz to be included even in builds that never use it. We improve this situation by storing both an hb_font, and a function pointer to destroy it within fz_font. This costs us an extra pointer per fz_font, but solves the problem.
2016-04-04epub: Add harfbuzz bypass for fonts without opentype tables.Tor Andersson
In certain simple circumstances, we can bypass harfbuzz shaping and gain a lot of performance.
2016-04-04Add glyph names to trace device output.Tor Andersson
2016-03-31html: Tweak how builtin font families are loaded.Tor Andersson
2016-03-23Compile embedded fonts in separate C files.Tor Andersson
Also change unsigned char into const char for embedded data.
2016-02-29Create simple font width table when creating the PDF object.Tor Andersson
We don't need to store it in the fz_font.width_table.
2016-02-29Pass fz_font to pdf_add_xxx_font_res instead of a fz_buffer.Tor Andersson
Make sure all fz_fonts have a ft_buffer available.
2016-02-29Add mutool create tool, and PDF font and image resource creation.Michael Vrhel
Initial framework for creating pdfs This adds a create option to mutool for us to use in working on the API for creating content as well as adding content to existing documents. mutool create: Get page sizes and add them Start the parsing of the contents.txt file which may have multiple page information. Add the pages at the proper sizes. Further work on mutool create_pdf Remove the calls that were being made to the pdf-write device. Clean up several issues with the reading of the page contents. Get the content streams for each page associated with the page->contents Temp. created a pdf_create_page_contents procedure. I will merge this with pdf_create_page as there is significant overlap. Next is to add in the font and image resources and indirect references. Include pdfcreate in build Merge pdf_create_page_contents and pdf_create_page Add support for images in pdfcreate This adds images to the pdf document using a function stolen from pdf-device (send_image). This was renamed pdf_add_image_res and added to pdf-image. Down the road, send-image will be removed. Prior to that, I need to work on making sure that multiple copies of the same image do not end up in the document. Code was also added to create the page resources to point to the proper image in the document. Next fonts will be added in a similar manner, then I will work on computing the md5 sums of image and fonts to ensure only one copy ends up in the document. Then pdf-write will be reworked to use the same code as opposed to its current list of md5 sums that are stored in a device structure. mutool pdfcreate: support for WinAnsiEncoded fonts Added support for very simple fonts (WinAnsiEncoding). Methods added in pdf-font.c. Added first_width and last_width to fz_font_s and stem_v to pdf_font_desc_s. Ran code through memento with simple test of 4 page document creation including an image and a font. Fixed several leaks as well as buffer corruption issues (main changes in pdfcreate). Thanks to Robin for the help with Memento in finding leaks. Added StemV to pdf names as it was needed for the font descriptor creation. Fix for pdf_write_document rename to pdf_save_document Add resource_ids to pdf document structure The purpose of this structure will be to allow the search and reuse of resources when we attempt to add new ones to the document. Fix name changes from recent updates pdf_create branch updated to work with recent changes in master Initial use of hash table for resources To avoid adding in the same resource this adds a resource_tables member to pdf_document. The resource_tables structure consists of multiple fz_hash_table entries, one for each resource type. When an attempt is made to search for an existing resource, the table will be initialized in a brute force search for existing resources. Currently this is only set up for the image resources and accessed through pdf_add_image_res. If a match is found, the reference object is returned. If no match is found NULL is returned and the ref object created in pdf_add_image_res is added into the hash table. In this case, a command line such as create -o output.pdf -f F0:font.ttf -i Im0:image.jpg -i Im1:image1.jpg \\ -i Im2:image.jpg contents.txt will avoid the insertion of two copies of image.jpg into the output PDF document. CID Identity-H Font added for handing ttf This adds a method for adding a ttf to a PDF as a CID font with Identity-H mapping and a ToUnicode entry that is created using FT_Get_Char_Index This takes much care in the creation of the ToUnicode CMap to ensure that the minimum number of entries are created in that we try to use beginbfrange as much as possible before using beginbfchar. The code makes sure to limit the number of entries in a group to 100 and to not cross first-byte boundaries for the CID values as described in the Adobe Technical note 5411. Add missing file pdf-resources.c pdf-resources.c was missing and should have been committed earlier. Added to windows project file. Not sure where else it needs to be added for the other platforms. Clean up names and spacing Make sure that the visible functions have the proper namespace (e.g. pdf_xxxx) Also make sure we have a blank line prior to comment. Be consistent with static function naming in pdf_resources.c pdfwrite make use of image resource fz_hash_table The pdfwrite device now shares the structure that stores the resource images for pdfcreate. With this fix, pdfwrite now avoids duplicating the writing of the same images that are shared across multiple pages. Add missing file pdf-resources.c Initial work toward having pdfwrite use Identity-H Type0 encoding for fonts Finish of CID type0 Identity-H font for pdfwrite This adds in the proper widths which may have been stored in the source font in the width table (parsed from the W entry in the pdf file) or if the free type structure has its own cmap then we can get the width from free type. Widths are restructured into format described in 5.6.3 of PDF spec. Fix issue from conflict merging and multiple define of structure Clean up warnings and make mutool create use simple font
2016-02-24Add fz_show_string function and move wmode argument to end.Tor Andersson
2016-02-10Add bold/italic/monospaced/serif flags to fz_font.Tor Andersson
Use the flags when selecting a fallback font.
2016-02-04Make HTML layout use harfbuzz for shaping.Robin Watts
fz_fonts gain a 'shaper' field that will be filled in as required. Use a void * rather than an hb_font_t to avoid polluting top level include space. Harfbuff handles mirroring for us, so lose the 'mirror' fields. This simplifies our wrappers around the 'standard' bidi code in that we don't need to split fragments upon mirroring. We do need to split our fragments at script changes though as harfbuzz only operates on a single font at a time. Update the html flow structure so that each flow node contains details of the the direction specified for it in the markup, the language specified for it in the markup and the script detected by the bidi code. Get the bidi code to pass out the script for each fragment as part of the callback and populate that field in the node. Ensure that we pass in the markup direction to the bidi splitting code as the 'base' direction. When feeding the bidi code, rather than feeding it paragraphs at a time, break those paragraphs if different parts of them have different marked up directions.
2016-01-29Force all harfbuzz allocations through our allocators.Robin Watts
Because of a shortcoming in harfbuzz, we can't easily force all its allocations through our allocators. We fudge it, with the addition of some macros to change malloc/free/calloc into hb_malloc/hb_free/hb_calloc. To prevent thread safety issues, we use our freetype lock around calls to harfbuzz. We stash the current context in a static var.
2016-01-28Add fallback font cache to font context.Tor Andersson
2016-01-28Add Noto fallback fonts.Tor Andersson
Look up fallback fonts by unicode script, with a flag to select the serif or sans-serif font style where such variants exist. Move all builtin fonts into fitz namespace.
2016-01-21epub: Put font fallback chain in fz_font.Tor Andersson
fz_encode_character_with_fallback finds the first font in the fallback chain that has the glyph encoded, and if none do then try to encode a bullet character.
2016-01-21Drop the const on fz_font.Tor Andersson
The font is an immutable opaque structure, no need to add the const keyword since users aren't expected or expecting to change it.
2016-01-13Add lots of consts.Robin Watts
In general, we should use 'const fz_blah' in device calls whenever the callee should not alter the fz_blah. Push this through. This shows up various places where we fz_keep and fz_drop these const things. I've updated the fz_keep and fz_drops with appropriate casts to remove the consts. We may need to do the union dance to avoid the consts for some compilers, but will only do that if required. I think this is nicer overall, even allowing for the const<->no const problems.