Commit Graph

1087 Commits

Author SHA1 Message Date
Khem Raj 1ab5258f7c Avoid conflicts with integer width macros from TS 18661-1:2014
glibc 2.25+ has now defined these macros in <limits.h>
https://sourceware.org/git/?p=glibc.git;a=commit;h=5b17fd0da62bf923cb61d1bb7b08cf2e1f1f9c1a

Create an alias for FC_CHAR_WIDTH for ABI compatibility

Signed-off-by: Khem Raj <raj.khem@gmail.com>
2016-12-20 16:33:07 +09:00
Akira TAGOH 0e9b2a1527 Fix FcCacheOffsetsValid()
Validation fails when the FcValueList contains more than font->num.
this logic was wrong because font->num contains a number of the elements
in FcPatternElt but FcValue in FcValueList.

This corrects 7a4a5bd7.

Patch from Tobias Stoeckmann
2016-11-14 20:16:40 +09:00
Tobias Stoeckmann 7a4a5bd789 Properly validate offsets in cache files.
The cache files are insufficiently validated. Even though the magic
number at the beginning of the file as well as time stamps are checked,
it is not verified if contained offsets are in legal ranges or are
even pointers.

The lack of validation allows an attacker to trigger arbitrary free()
calls, which in turn allows double free attacks and therefore arbitrary
code execution. Due to the conversion from offsets into pointers through
macros, this even allows to circumvent ASLR protections.

This attack vector allows privilege escalation when used with setuid
binaries like fbterm. A user can create ~/.fonts or any other
system-defined user-private font directory, run fc-cache and adjust
cache files in ~/.cache/fontconfig. The execution of setuid binaries will
scan these files and therefore are prone to attacks.

If it's not about code execution, an endless loop can be created by
letting linked lists become circular linked lists.

This patch verifies that:

- The file is not larger than the maximum addressable space, which
  basically only affects 32 bit systems. This allows out of boundary
  access into unallocated memory.
- Offsets are always positive or zero
- Offsets do not point outside file boundaries
- No pointers are allowed in cache files, every "pointer or offset"
  field must be an offset or NULL
- Iterating linked lists must not take longer than the amount of elements
  specified. A violation of this rule can break a possible endless loop.

If one or more of these points are violated, the cache is recreated.
This is current behaviour.

Even though this patch fixes many issues, the use of mmap() shall be
forbidden in setuid binaries. It is impossible to guarantee with these
checks that a malicious user does not change cache files after
verification. This should be handled in a different patch.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2016-08-05 14:35:05 +09:00
Akira TAGOH 99645ff9ee Bug 96676 - Check range of FcWeightFromOpenType argument
Fix a crash issue when FcWeightFromOpenType() gets a number more than it expects.
2016-07-08 14:18:35 +09:00
Akira TAGOH add5f7329f Remove unused code 2016-06-15 20:10:31 +09:00
Erik de Castro Lopo ea26c5e9f8 Fix a couple of minor memory leaks
These fixes are needed for the test suite to pass when compiled
with Address Sanitizer.
2016-05-30 10:30:10 +09:00
Akira TAGOH 7441dbec03 Bug 95481 - Build fails on Android due to broken lconv struct 2016-05-27 11:16:09 +09:00
Petr Filipsky d15c46d75e Fix memory leak in FcDirCacheLock 2016-05-23 11:09:22 +09:00
Akira TAGOH 9ab7633f2f Bug 95477 - FcAtomicLock fails when SELinux denies link() syscall with EACCES
This is an issue on Android M, which denies non-root users access to link().

Patch from Rodger Combs
2016-05-19 11:11:46 +09:00
Akira TAGOH d179cbc253 Revert "Workaround another race condition issue"
This reverts commit f44bfad235.
2016-04-06 14:39:15 +09:00
Behdad Esfahbod d05d083e9f [GX] Improve weight mapping
Align the 'wght' axis default value to OS/2 weight value and
adjust accordingly.  This makes both default=1.0 and default=400
models to work.
2016-03-08 17:20:55 -08:00
Behdad Esfahbod d709220d74 Improve OpenType to Fontconfig weight mapping 2016-03-08 17:20:28 -08:00
Behdad Esfahbod 27d61f1ddc [GX] Enumerate all named-instances in TrueType GX fonts 2016-03-08 13:39:05 -08:00
Behdad Esfahbod 00c8408c6a [GX] Support instance weight, width, and style name 2016-03-08 13:39:05 -08:00
Behdad Esfahbod 28f62d1bb8 Call FcFreeTypeQueryFace() from fcdir.c, instead of FcFreeTypeQuery()
Need for upcoming work.  No functional change expected.
2016-03-08 13:39:05 -08:00
Patrick Haller d570a841a2 Optimizations in FcStrSet
Applied optimizations:
- skip duplicate check in FcStrSetAppend for values originating from readdir()
- grow FcStrSet in 64-element bulks for local FcStrSets (FcConfig layout unaltered)

Starting gedit is measured to

                        Unoptimized     Optimized
user[s]                         0,806         0,579
sys[s]                          0,062         0,062
Total Instr Fetch Cost: 1.658.683.750   895.069.820
Cachegrind D Refs:        513.917.619   312.000.436
Cachegrind Dl Misses:       8.605.632     4.954.639
2016-01-12 10:42:40 +09:00
Akira TAGOH 1d87fab8b1 remomve unnecessary code 2015-11-18 14:44:17 +09:00
Akira TAGOH d162a4a83d Fix assertion on 32bit arch 2015-10-16 17:24:22 +09:00
Akira TAGOH bd96984e4b Use int64_t instead of long long 2015-10-15 15:51:50 +09:00
Akira TAGOH 7ccde89758 Fix build issue on MinGW 2015-10-13 13:06:54 +09:00
Akira TAGOH a44cc450b5 Use long long to see the same size between LP64 and LLP64 2015-10-13 13:04:33 +09:00
Akira TAGOH ad9f588050 Fix the broken cache more.
Take a look at the nano second in the mtime to figure out
if the cache needs to be updated if available.
and do the mutex lock between scanning and writing a cache
to avoid the conflict.

Also we don't need to scan directories again after writing
caches. so getting rid of the related code as well.

https://bugs.freedesktop.org/show_bug.cgi?id=69845

and for reference:

https://bugzilla.redhat.com/show_bug.cgi?id=1236034
2015-08-14 17:19:29 +09:00
Behdad Esfahbod 46ec6a52d4 Revert changes made to FcConfigAppFontAddDir() recently
In 32ac7c75e8 the behavior of
FcConfigAppFontAddFile/Dir() were changed to return false
if not fonts were found.  While this is welldefined and useful
for AddFile(), it's quite problematic for AddDir().  For example,
if the directory is empty, is that a failure or success?  Worse,
the false value from AddDir() was being propagated all the way
to FcInit() returning false now.  This only happened upon memory
allocation failure before, and some clients assert that FcInit()
is successful.

With this change, AddDir() is reverted back to what it was.
AddFont() change (which was actually in fcdir.c) from the original
commit is left in.
2015-06-26 17:02:13 -07:00
Akira TAGOH a8096dfa59 Bug 90867 - Memory Leak during error case in fccharset
https://bugs.freedesktop.org/show_bug.cgi?id=90867
2015-06-24 15:46:45 +09:00
Akira TAGOH 6f929ff37c Fix a memory leak in FcFreeTypeQueryFace 2015-06-17 16:34:29 +09:00
Akira TAGOH 46b2c62faa Add a warning for blank in fonts.conf
and remove the unnecessary code for parsing blanks
2015-06-17 16:29:08 +09:00
Akira TAGOH 33fd436a3e Don't return FcFalse even when no fonts dirs is configured 2015-06-17 16:15:35 +09:00
Akira TAGOH f6d61c9bee mark as private at this moment 2015-06-12 11:30:01 +09:00
Akira TAGOH dbda117142 No need to be public 2015-06-09 11:15:25 +09:00
Akira TAGOH 359ada2b4c Fix a crash when no objects are available after filtering 2015-06-09 11:15:06 +09:00
Akira TAGOH 10a57edd07 Add one more debugging option to see transformation on font-matching
just setting FC_MATCH=3 shows a lot of information and hard to keep on track for informamtion
which is really necessary to see. to use this more effectively, added FC_DBG_MATCH_FILTER to
see for what one really want to see. it takes a comma-separated-list of object names.
If you want to see family name only, try like this:

FC_DBG_MATCH_FILTER=family FC_DEBUG=4096 fc-match

debugging output will be filtered out and see family only in the result.
2015-06-08 17:39:25 +09:00
Behdad Esfahbod ee2d1da2d2 Reduce number of places that cache version is specified to 1 2015-05-27 14:36:35 -07:00
Behdad Esfahbod 5bad26ccb6 Simplify FcRange 2015-05-27 14:18:28 -07:00
Behdad Esfahbod 13a5ae9fb9 Fix compiler warnings 2015-05-27 14:12:49 -07:00
Behdad Esfahbod 346073d9dc Don't set FC_SIZE for bitmap fonts
They get FC_PIXELSIZE set, which is later converted to FC_SIZE using
FC_DPI.
2015-05-27 14:12:49 -07:00
Behdad Esfahbod eba6f109de Accept Integer for FC_SIZE
There are more places to fix I'm sure...

https://bugs.freedesktop.org/show_bug.cgi?id=80873
2015-05-27 14:12:49 -07:00
Behdad Esfahbod cb2f096e15 Add bitmap-only font size as Double, not Range
The whole size setting part still smells to me.
2015-05-27 14:12:49 -07:00
Behdad Esfahbod 51756aab18 Only set FC_SIZE for scalable fonts if OS/2 version 5 is present
Part of https://bugs.freedesktop.org/show_bug.cgi?id=80873
2015-05-27 14:12:49 -07:00
Behdad Esfahbod d09ba38589 Write ranges using a [start finish) format
To show closed and open ends.
2015-05-27 14:12:49 -07:00
Akira TAGOH 4c9101f704 Revert the previous change
and just abort if the object id is overflowed.
2015-05-25 21:41:05 +09:00
Akira TAGOH 09edd84cf8 Detect the overflow for the object ID
Continue to increase the object id even after FcFini()
and detect the overflow. that would be rather easier than
reset the object id with the complicated mutex and atomic
functions.

This situation would be quite unlikely to happen though
2015-05-22 20:51:21 +09:00
Akira TAGOH f053231186 Fix a crash
segfault happens when the config needs to be migrated to XDG's
and no definition for include with prefix="xdg"
2015-05-22 20:46:54 +09:00
Akira TAGOH 249306fbd7 Fix a typo 2015-05-22 20:45:05 +09:00
Akira TAGOH fa6c6b53c5 Fix memory leaks after FcFini()
Reported by Jia Wang

https://bugs.freedesktop.org/show_bug.cgi?id=83770
2015-05-22 16:53:34 +09:00
Behdad Esfahbod bcfe167e3d Add su[pport for symbol fonts
Adds FC_SYMBOL.

This affects fonts having a cmap with platform 3 encoding 0.
We now map their glyphs from the PUA area to the Latin1 area.

See thread "Webdings and other MS symbol fonts don't display"
on the mailing list.

Test before/after with:
$ pango-view --markup --text='<span fallback="false">&#xd7;&#xf0d7;</span>' --font=Wingdings
2015-05-18 15:26:03 -07:00
Akira TAGOH ead7275e05 Bug 90148 - Don't warn if cachedir isn't specified
only warn when FONTCONFIG_FILE or FONTCONFIG_PATH is set.

Bug 90148 - Don't warn if cachedir isn't specified
2015-05-18 14:03:50 +09:00
Akira TAGOH 3a4136778c Drop unmaintained code
Use four-byte code for foundry as is instead.

https://bugs.freedesktop.org/show_bug.cgi?id=88679
2015-04-22 16:29:25 +09:00
Руслан Ижбулатов f6e6a8a22b W32: Support cache paths relative to the root directory
Paths starting with '/' don't make sense on W32 as-is,
prepend the installation root directory to them.

This allows the cache to be contained within a particular
fontconfig installation (as long as the default
--with-cache-dir= is overriden at configure time).
2015-04-09 15:19:17 +09:00
Akira TAGOH 7bc07cf6c2 Fix SIGFPE 2015-03-30 15:18:44 +09:00
Akira TAGOH e92c92ff22 Fix unknown attribute in Win32 2015-03-25 12:10:48 +09:00
Akira TAGOH c965c9f677 Bug 89617 - FcConfigAppFontAddFile() returns false on any font file
Prior to the change of 32ac7c75e8
FcConfigAppFontAddFile() always returned FcTrue no matter what
fonts was added. after that, it always returned FcFalse because
adding a font doesn't add any subdirs with FcFileScanConfig().
so changing that to simply ignore it.

Also fixing it to return FcFalse if non-fonts was added, i.e.
FcFreeTypeQuery() fails.

https://bugs.freedesktop.org/show_bug.cgi?id=89617
2015-03-23 13:31:57 +09:00
Akira TAGOH 7301f2f028 Remove the dead code 2015-03-23 13:18:49 +09:00
Akira TAGOH f5b1e0ab97 Fix an infinite loop in FcBlanksIsMember() 2015-03-09 12:20:22 +09:00
Akira TAGOH 484834c186 Fix a bug in the previous change forFcBlanksIsMember() 2015-03-06 11:15:26 +09:00
Akira TAGOH ed74a58ccc Fix a segfault when OOM happened.
Reported by Matt Breedlove
2015-03-06 11:10:05 +09:00
Akira TAGOH 96a3f6879c Improve the performance on searching blanks
After the change of d6a5cc665a
we have a lot of code points in FcBlanks. doing the linear search
on the array isn't comfortable anymore.
So re-implementing FcBlanksIsMember() to use the binary search.

Figuring out how much improved after this change depends on
how many fonts proceed with fc-cache say though, it's about 20 times
faster here on testing. which sounds good enough for
improvement.
2015-03-05 17:52:04 +09:00
Behdad Esfahbod d997d7c770 Simplify some more 2015-03-03 16:00:39 -08:00
Behdad Esfahbod 9c99baba66 Remove dead code after previous commit 2015-03-03 16:00:39 -08:00
Akira TAGOH 2f311c562d Fix the array allocation 2015-03-03 11:30:12 +09:00
Akira TAGOH f18f2f88f2 Don't add FC_LANG when it has "und"
to avoid the situation to find the better fallback font.

https://code.google.com/p/chromium/issues/detail?id=392724 has
more words to explain the details.

https://bugs.freedesktop.org/show_bug.cgi?id=81185
2015-03-02 11:35:42 +09:00
Akira TAGOH d6a5cc665a Hardcode the blanks in the library
https://bugs.freedesktop.org/show_bug.cgi?id=79956
2015-02-27 14:18:32 +09:00
Akira TAGOH 97cf7ec4d7 Rework again to copy the struct dirent
Assuming that d_name is the last member of struct dirent.
In POSIX, the maximum length of d_name is defined as NAME_MAX
or FILENAME_MAX though, that assumption may be wrong on some
platforms where defines d_name as the flexible array member
and allocate the minimum memory to store d_name.

Patch from Raimund Steger
2015-02-27 12:04:44 +09:00
Michael Haubenwallner 1add10bfbc Ensure config.h is included first, bug#89336.
config.h may define ABI-specific macros, especially for AIX,
so has to be included before any system header - via fcint.h.

https://bugs.freedesktop.org/show_bug.cgi?id=89336
2015-02-26 21:06:16 +09:00
Akira TAGOH 8809d1b73b Copy the real size of struct dirent
In some platforms, d_name is defined as the flexible array member.
We may need to compute the real size for that case.
2015-02-26 14:09:33 +09:00
Akira TAGOH dd427253cc filter can be null 2015-02-25 17:36:50 +09:00
Akira TAGOH 45018e6979 Fix pointer cast warning on win32 2015-02-24 15:25:16 +09:00
Akira TAGOH f43c58189b ifdef'd the unnecessary code for win32 2015-02-24 15:01:14 +09:00
Akira TAGOH ed0d705e22 Fix a build fail on some non-POSIX platforms
Use own scandir function. according to this change,
we don't need -Werror things in configure anymore.
2015-02-23 15:21:08 +09:00
Behdad Esfahbod d6d5adeb79 Fix symbol cmap handling
A while back we removed Apple Roman encoding support.  This broke
symbol fonts (Wingdings, etc) because those fonts come with two
cmaps:

  1) platform=1,encoding=0, aka Apple Roman, which maps identity,
  2) platform=3,encoding=0, aka MS Symbol font

Now, the reason the Apple Roman removal "broke" these fonts is
obvious, and for the better: these fonts were mapping ASCII and
other Latin chars to symbols.

The reason the fonts didn't work anymore, however, is that we were
mishandling the MS symbol-font cmaps.  In their modern incarnation
they are like regular non-symbol-font cmap that map PUA codepoints
to symbols.  We want to expose those as such.  Hence, this change
just removes the special-handling for that.

Now, the reason this confusion happened, if I was to guess, is either
that FreeType docs are wrong saying that FT_ENCODING_MS_SYMBOL is
the "Microsoft Symbol encoding, used to encode mathematical symbols":

  http://www.kostis.net/charsets/symbol.htm

or maybe it started that way, but turned into also mapping MS symbol-
font cmaps, which is a completely different thing.  At any rate, I
don't know if there are any fonts that use this thing these days, but
the code here didn't seem to produce charset for any font.  By now I'm
convinced that this change is the Right Thing to do.  The MS Symbol
thing was called AdobeSymbol in our code by the way.

This fixes the much-reported bug that windings, etc are not usable
with recent fontconfig:
https://bugs.freedesktop.org/show_bug.cgi?id=58641

Now I see PUA mappings reported for Wingdings.

This also fixes:
Bug 48947 - Drop the non-Unicode cmap support gradually
https://bugs.freedesktop.org/show_bug.cgi?id=48947
since the AdobeSymbol was the last non-Unicode cmap we were
trying to parse (very incorrectly).

Lots of code around this change can be simplified.  I'll push those
out (including removing the table itself) in subsequent changes.
2015-01-21 14:13:36 -08:00
Akira TAGOH 365809938e Bump the cache version to 5
FcPattern isn't compatible to the older.
2014-12-25 13:11:21 +09:00
Behdad Esfahbod 66db69a6d9 Treat color fonts as scalable
All color fonts are designed to be scaled, even if they only have
bitmap strikes.  Client is responsible to scale the bitmaps.  This
is in constrast to non-color strikes...

Clients can still use FC_OUTLINE to distinguish bitmap vs outline
fonts.  Previously FC_OUTLINE and FC_SCALABLE always had the same
value.  Now FC_SCALABLE is set to (FC_OUTLINE || FC_COLOR).

Fixes:
https://bugs.freedesktop.org/show_bug.cgi?id=87122
2014-12-14 13:57:24 -08:00
Behdad Esfahbod dbc7c4a2cf Add FC_COLOR
Only adds "color" to pattern if FreeType version supports color.

Based on patch from Jungshik Shin.
2014-12-14 13:40:02 -08:00
Behdad Esfahbod fc7e1a9497 Fix buffer overflow in copying PS name
As reported on the mailing list by Tanel Liiv.  Found using American Fuzzy Lop.
2014-12-12 21:42:35 -08:00
Akira TAGOH 32ac7c75e8 Returns False if no fonts found
https://bugs.freedesktop.org/show_bug.cgi?id=86950
2014-12-09 19:06:46 +09:00
Akira TAGOH 1082161ea3 Add FcRangeGetDouble()
https://bugs.freedesktop.org/show_bug.cgi?id=82876
2014-09-25 17:03:27 +09:00
Behdad Esfahbod 286cdc9c10 Revert "[fcmatch] When matching, reserve score 0 for when elements don't exist"
This reverts commit a5a384c5ff.

I don't remember what I had in mind for "We will use this property later.", but
the change was wrong.  If a font pattern doesn't have any value for element,
it must be interpretted as "it matches any value perfectly.  And "perfectly"
must have a score of 0 for that to happen.

This was actually affecting bitmap fonts (in a bad way), as the change made
an outline font to always be preferred over a (otherwise equal) bitmap font,
even for the exact size of the bitmap font.  That probably was never noticed
by anyone, but with the font range support this has become clear (and worked
around by Akira).  To clean that up, I'm reverting this so I can land the
rest of patches for bug 80873.

https://bugs.freedesktop.org/show_bug.cgi?id=80873#c10
2014-08-20 15:23:04 -04:00
Akira TAGOH 23e88d8c6a Increase the refcount in FcConfigSetCurrent()
https://bugs.freedesktop.org/show_bug.cgi?id=82432
2014-08-12 18:48:00 +09:00
Akira TAGOH 841753a93f fallback to the another method to lock when link() failed
Bug 82358 - FcAtomicLock fails on OS X on network mounts
https://bugs.freedesktop.org/show_bug.cgi?id=82358
2014-08-11 12:14:54 +09:00
Behdad Esfahbod 80edaccc3c If OS/2 table says weight is 1 to 9, multiply by 100
https://bugs.freedesktop.org/show_bug.cgi?id=82228
2014-08-06 12:29:35 -04:00
Behdad Esfahbod 01bb6978b6 Fix assertion failure
https://bugs.freedesktop.org/show_bug.cgi?id=82220
https://bugs.freedesktop.org/show_bug.cgi?id=82228
2014-08-06 12:23:24 -04:00
Behdad Esfahbod 37e501ed0a Remove unneeded FcPublic 2014-07-27 16:53:28 -04:00
Behdad Esfahbod a9e7b0494e Export recently added API
We should remove this alias mess.
2014-07-26 16:17:02 -04:00
Behdad Esfahbod ffda7c0e81 Linearly interpolate weight values
Rest of Part of https://bugs.freedesktop.org/show_bug.cgi?id=81453

Adds new API:

	FcWeightFromOpenType()
	FcWeightToOpenType()
2014-07-25 18:07:59 -04:00
Behdad Esfahbod be6506ca04 Add FC_WEIGHT_DEMILIGHT
Part of https://bugs.freedesktop.org/show_bug.cgi?id=81453
Also hooks up FC_WEIGHT_BOOK to fcfreetype.c.
2014-07-25 16:24:26 -04:00
Behdad Esfahbod 9839d0112c Improve / cleanup namelang matching
Previously, if the patten didn't request, eg, style, then the style
and stylelang were fully copied from the font, even though the pattern
had a stylelang.  Eg:

$ fc-match 'Apple Color Emoji:stylelang=en'
Apple Color Emoji.ttf: "Apple Color Emoji" "標準體"

This change both fixes that and makes the code much more readable.  Now:

$ fc-match 'Apple Color Emoji:stylelang=en'
Apple Color Emoji.ttf: "Apple Color Emoji" "Regular"
2014-07-24 16:07:13 -04:00
Behdad Esfahbod 874a549164 Remove unused regex code
Regex matching was disabled in f6244d2cf2
2014-07-24 15:42:54 -04:00
Behdad Esfahbod 9a8e812477 Use lang=und instead of lang=xx for "undetermined"
That's the correct BCP 47 code.
2014-07-24 15:37:51 -04:00
Behdad Esfahbod 76151ceaf3 Ouch, fix buffer 2014-07-24 15:34:20 -04:00
Behdad Esfahbod aeba5bf4b6 Decode MacRoman encoding in name table without iconv
iconv support was turned off by default in f30a5d76.
Some fonts, like Apple Color Emoji, only have their English
name in a MacRoman entry.  As such, decode MacRoman ourselves.
2014-07-24 15:28:09 -04:00
Behdad Esfahbod 07a0f511b1 Call FcInitDebug from FcFreeTypeQueryFace 2014-07-24 15:01:57 -04:00
Akira TAGOH 107b44f50b Don't add duplicate lang
Don't add duplicate lang from FC_LANG if the pattern already has.

https://bugs.freedesktop.org/show_bug.cgi?id=81186
2014-07-23 19:17:26 +09:00
Behdad Esfahbod 342b908b96 More mingw32 MemoryBarrier() fixup 2014-07-19 16:33:49 -04:00
Behdad Esfahbod 6781c6baef Update mingw32 MemoryBarrier from HarfBuzz
Fixes https://bugs.freedesktop.org/show_bug.cgi?id=81228
2014-07-11 12:20:24 -04:00
Behdad Esfahbod da8233b0f2 Fixup previous commit 2014-07-06 18:26:03 -04:00
Behdad Esfahbod bb27d6969c Remove HASH from matching priorities
We deprecated FC_HASH, so doesn't make sense to sort on it.
2014-07-06 18:10:49 -04:00
Behdad Esfahbod 5674b8a663 Comments 2014-07-06 17:42:33 -04:00
Akira TAGOH 5b22776999 Fix a crash when no sysroot is given and failed to load the default fonts.conf 2014-07-04 18:04:52 +09:00
Behdad Esfahbod f5b4b2c1ed Fix charset unparse after recent changes 2014-07-04 01:43:47 -04:00
Behdad Esfahbod 940d27a197 Minor 2014-07-03 21:15:25 -04:00
Behdad Esfahbod e708e97c35 Change charset parse/unparse format to be human readable
Previous format was unusable.  New format is ranges of hex values.
To choose space character and Latin capital letters for example:

$ fc-pattern ':charset=20 41-5a'
Pattern has 1 elts (size 16)
	charset:
	0000: 00000000 00000001 07fffffe 00000000 00000000 00000000 00000000 00000000
(s)
2014-07-03 17:54:11 -04:00
Akira TAGOH dab60e4476 Rework for 5004e8e01f
Don't read/write from/to the XDG dirs even if XDG_*_HOME is set
and the home directory is disabled.
2014-06-30 15:12:32 +09:00
Akira TAGOH 5004e8e01f Don't read/write from/to the XDG dirs if the home directory is disabled 2014-06-30 12:39:31 +09:00
Akira TAGOH 6c3c2603b9 Fix a segfault
introduced by the previous commit d17f556153
2014-06-18 19:13:06 +09:00
Akira TAGOH d17f556153 Read the config files and fonts on the sysroot when --sysroot is given to fc-cache
Fix for e96d776088

https://bugs.freedesktop.org/show_bug.cgi?id=59456
2014-06-17 20:11:02 +09:00
Behdad Esfahbod 8f62ccaa96 Remove unused FcHash code now that FC_HASH is deprecated 2014-06-12 17:02:10 -04:00
Behdad Esfahbod 75abdaf5c8 Deprecate FC_HASH and don't compute it
It was added without proper measurement and a fuzzy possible
use-case (font servers) in mind, but reality check shows that
this significantly slows down caching.  As such, deprecate it
and do NOT compute hash during caching.

Makes caching two to three times faster (ignoring the 2 second
delay in fc-cache).
2014-06-12 17:02:10 -04:00
Akira TAGOH f44bfad235 Workaround another race condition issue
See https://bugzilla.redhat.com/show_bug.cgi?id=921706
2014-06-05 19:06:02 +09:00
Behdad Esfahbod 58acd993cb Allow passing NULL for file to FcFreeTypeQueryFace() 2014-05-16 15:08:52 -06:00
Behdad Esfahbod 3f992254f2 Rewrite hashing to use FT_Stream directly
This is more robust but introduces a small change in behavior:
For .pcf.gz fonts, the new code calculates the hash of the uncompressed
font data whereas the original code was calculating the hash of the
compressed data.

No big deal IMO.
2014-05-16 15:02:58 -06:00
Behdad Esfahbod 8284df49ef Further simplify hash code 2014-05-16 14:23:56 -06:00
Behdad Esfahbod 748e77e89f Simplify hash code 2014-05-16 14:10:06 -06:00
Behdad Esfahbod e4d8847eee Remove unused code 2014-05-16 13:45:44 -06:00
Akira TAGOH 48c8b7938a Allow the modification on FcTypeVoid with FcTypeLangSet and FcTypeCharSet
FcTypeVoid is likely to happen when 'lang' and 'charset'
is deleted by 'delete' or 'delete_all' mode in edit.
Without this change, any modification on them are simply
ignored.

This is useful to make a lot of changes, particularly
when one wants to add a few and delete a lot say.
2014-05-13 21:22:17 +09:00
Akira TAGOH fff91eee7d Fix a build issue with freetype <2.5.1 2014-03-26 12:22:02 +09:00
Akira TAGOH 3cd573fc1f Bug 71287 - size specific design selection support in OS/2 table version 5
This feature requires the FreeType 2.5.1 or later at the build time.

Besides <range> element allows <double> elements with this changes.

This may breaks the cache but not bumping in this change sets at this moment.
please be aware if you want to try it and run fc-cache before/after to
avoid the weird thing against it.
2014-03-26 12:19:04 +09:00
Akira TAGOH 39a2f1e8f9 Fallback to lstat() in case the filesystem doesn't support d_type in struct dirent 2014-03-05 18:29:29 +09:00
Akira TAGOH e310d2fac2 Fix incompatible API on AIX with random_r and initstate_r
https://bugs.freedesktop.org/show_bug.cgi?id=74603
2014-02-06 19:40:01 +09:00
Akira TAGOH 7d75653285 Add missing #include <sys/statvfs.h> in fcstat.c
https://bugs.freedesktop.org/show_bug.cgi?id=74602
2014-02-06 17:29:19 +09:00
Akira TAGOH 80081555fd Fix a crash issue when empty strings are set to the BDF properties 2014-01-31 11:10:02 +09:00
Akira TAGOH 5918d5bea5 Add missing license headers
https://bugs.freedesktop.org/show_bug.cgi?id=73401
2014-01-17 13:05:25 +09:00
Akira TAGOH 7a6622f25c Improve the performance issue on rescanning directories 2013-12-20 11:57:16 +09:00
Akira TAGOH 5c725f2f58 Fix a build issue on platforms where doesn't support readlink() 2013-12-16 17:44:37 +09:00
Behdad Esfahbod fee834a9c9 Bug 72380 - Never drop first font when trimming
Let me show it with an example.

Currently:

$ fc-match symbol
symbol.ttf: "Symbol" "Regular"

$ fc-match symbol --sort | head -n 1
Symbol.pfb: "Symbol" "Regular"

$ fc-match symbol --sort --all | head -n 1
symbol.ttf: "Symbol" "Regular"

I want to make sure the above three commands all return the same font.
Ie.  I want to make sure FcFontMatch() always returns the first font
from FcFontSort().  As such, never trim first font.
2013-12-09 21:22:49 -05:00
Akira TAGOH 5152115349 Simplify to validate the availability of posix_fadvise 2013-12-02 18:43:10 +09:00
Akira TAGOH 38acb08d97 Fix typo
Use FcTypeUnknown instead of -1 with type casting.
This seems missed when it was changed.

Patch from brian porter
2013-11-11 11:53:09 +09:00
Alan Coopersmith 0b7f42f777 Avoid null pointer dereference in FcNameParse if malloc fails
Reported by parfait 1.3:
Error: Null pointer dereference (CWE 476)
   Read from null pointer t
        at line 423 of src/fcname.c in function 'FcNameParse'.
          Function _FcObjectLookupOtherTypeByName may return constant 'NULL'
           at line 63, called at line 122 of src/fcobjs.c in function
           'FcObjectLookupOtherTypeByName'.
          Function FcObjectLookupOtherTypeByName may return constant 'NULL'
           at line 122, called at line 67 of src/fcname.c in function
           'FcNameGetObjectType'.
          Function FcNameGetObjectType may return constant 'NULL' at line 67,
           called at line 422 in function 'FcNameParse'.
          Null pointer introduced at line 63 of src/fcobjs.c in function
           '_FcObjectLookupOtherTypeByName'.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2013-11-05 11:44:23 +09:00
Alan Coopersmith 5b8380d52e Avoid memory leak when NULL path passed to FcStrBuildFilename
Reported by parfait 1.3:
   Memory leak of pointer sset allocated with FcStrSetCreate()
        at line 933 of src/fcstr.c in function 'FcStrBuildFilename'.
          sset allocated at line 927 with FcStrSetCreate().
          sset leaks when sset != NULL at line 932.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2013-11-05 11:43:41 +09:00
Akira TAGOH aa22e6e639 Warn if no <test> nor <edit> elements in <match>
This corrects an error message being reported at
  https://bugs.freedesktop.org/show_bug.cgi?id=71085
  Bug 71085 - "out of memory" errors on empty match element in fonts.conf

and somewhat works as a workaround for
  https://bugs.freedesktop.org/show_bug.cgi?id=59438
  Bug 59438 - Fix <alias> inside <match>
2013-10-31 21:48:27 +09:00
Akira TAGOH 525a135ccf Change the default weight on match to FC_WEIGHT_NORMAL 2013-10-28 11:54:04 +09:00
Akira TAGOH 06b388523d Fix build issue on Debian/kFreeBSD 7.0
There are posix_fadvise(2) but not POSIX_FADV_WILLNEED.
Patch from Ryo ONODERA.
2013-10-21 11:50:55 +09:00
Akira TAGOH 0203055520 Workaround the race condition issue on updating cache 2013-10-02 16:34:34 +09:00
Akira TAGOH 43f768b53f avoid reading config.h twice
config.h is read from fcint.h now so having a line of the sort of #include "config.h"
is duplicate.

Bug 69833 - Incorrect SIZEOF_VOID_P and ALIGNOF_DOUBLE definitions causes nasty warnings on MacOSX when building fat libraries
2013-09-26 17:51:15 +09:00
Akira TAGOH 8a174b6c51 Fix a crash when FcPattern is set to null on FcFontSetList() and FcFontList() 2013-09-24 11:14:57 +09:00
Akira TAGOH 5e6b8894ea Copy all values from the font to the pattern if the pattern doesn't have the element 2013-09-18 17:33:45 +09:00
Akira TAGOH a61e145304 Fix memory leaks in FcFreeTypeQueryFace 2013-09-09 19:59:31 +09:00
Akira TAGOH 3e5f70a16a Do not create a config dir for migration when no config files nor dirs 2013-09-02 20:51:46 +09:00
Akira TAGOH 272a99217b Fix a crash 2013-08-31 10:43:13 +09:00
Akira TAGOH fba9efecd2 Fix a wrong edit position when 'kind' is different 2013-08-26 12:47:07 +09:00
Akira TAGOH 223c1384c9 Fix a crash when non-builtin objects are edited 2013-08-24 13:46:44 +09:00
Akira TAGOH 6c664d533d Fix a typo 2013-08-24 13:46:40 +09:00
Behdad Esfahbod f3bb3f19c9 Fix assertion
Apparently some AIX versions have 64bit pointers yet 32bit double
alignment.  Fix assertion.
2013-08-21 14:31:55 -04:00
Behdad Esfahbod ec3f0af6f0 Minor 2013-08-21 14:27:16 -04:00
Akira TAGOH 084cf7c44e Bug 16818 - fontformat in match pattern is not respected? 2013-08-14 12:51:26 +09:00
Akira TAGOH 45221ab12f Bug 67845 - Match on FC_SCALABLE 2013-08-07 12:19:33 +09:00
Akira TAGOH 041deb0cc5 warn deprecated only when migration failed 2013-08-07 12:05:32 +09:00
Akira TAGOH d52daa0024 Bug 67809 - Invalid read/write with valgrind when assigning something twice 2013-08-06 15:09:23 +09:00
Akira TAGOH a51d2767ce Fix wrong edit position 2013-08-06 13:05:53 +09:00
Akira TAGOH 04bd904632 trivial code optimization 2013-07-09 16:43:26 +09:00
Akira TAGOH d420e1df98 Rework to apply the intermixed test and edit elements in one-pass 2013-07-04 19:51:03 +09:00
Akira TAGOH 1162515a98 Add FC_UNUSED to FC_ASSERT_STATIC macro to avoid compiler warning 2013-07-03 11:56:58 +09:00