Commit Graph

233 Commits

Author SHA1 Message Date
Behdad Esfahbod 48e9e5f4f0 Use FT_HAS_COLOR 2018-07-16 17:59:54 +02:00
Tom Anderson c60ed9ef66 Fix undefined-shift UBSAN errors
The expression "1 << 31" will cause UBSAN to complain with this error message:
runtime error: left shift of 1 by 31 places cannot be represented in type 'int'

The same operation on unsigned types is fine, however.  This CL replaces the
strings "1 <<" with "1U <<".
2018-04-16 15:23:20 +02:00
Behdad Esfahbod a8a6efa805 Share name-mapping across instances
Continuation of previous commit.

Makes scanning Voto Serif GX fast again.
2018-03-31 19:19:36 +02:00
Behdad Esfahbod fa13f8835c Fix name scanning
In 161c738 I switched from linear name scanning to binary searching.
That, however, ignored the fact that there might be more than one
name table entry for each pair we want to query.

To fix that and retain bsearch, I now get all name entries first,
sort them, and use for bsearching.

This fixes https://bugs.freedesktop.org/show_bug.cgi?id=105756

This makes scaning Voto Serif GX twice slower though, since we are
creating and sorting the list for each instance. In the next commit,
I'll share this list across different instances to fix this.
2018-03-31 18:36:20 +02:00
Akira TAGOH 8c96285d21 Initialize an array explicitly
Patch from Kurt Kartaltepe
2018-03-02 13:30:00 +09:00
Behdad Esfahbod fd2ad1147a Fix undefined-behavior signed shifts 2018-01-09 11:03:31 +01:00
Behdad Esfahbod 94683a1255 Use FT_Done_MM_Var if available 2018-01-08 09:55:41 +00:00
Behdad Esfahbod 030e2e4e94 Fix leak 2018-01-05 14:33:41 +00:00
Behdad Esfahbod 37fb4a989e Support FC_WIDTH as double as well 2018-01-04 15:22:06 +00:00
Behdad Esfahbod 1fa9cb78c1 Remove hack for OS/2 weights 1..9 2018-01-04 15:22:06 +00:00
Akira TAGOH 767e3aa7c5 Fix compiler warnings 2018-01-04 20:37:26 +09:00
Behdad Esfahbod 706535e107 Add FcWeightTo/FromOpenTypeDouble()
No idea why I didn't add these as double to begin with.
2018-01-03 15:59:56 +00:00
Behdad Esfahbod f4a2a1e577 Remove assert 2017-10-11 17:27:02 +02:00
Behdad Esfahbod f504b2d6a1 Require freetype >= 2.8.1
2.8.0 had a bad bug with loading 'avar' table.  Let's update requirement and cleanup
fifteen years of ifdefs!
2017-09-28 19:49:05 -04:00
Behdad Esfahbod 01f781a9a4 [varfonts] Share lang across named-instances
Makes VotoSerifGX scanning another 40% faster...  Down to 36ms now.
2017-09-27 18:55:50 -04:00
Behdad Esfahbod 161c738547 Use binary-search for finding name table entries
VotoSerifGX has over 500 named instances, which means it also has over a thousand
name table entries.  So we were looking for names for over 500 pattern, looking for
some thirty different name-ids, and using linear search across the 1000 entries!

Makes scanning VotoSerifGX three times faster.  The rest is probably the lang
matching, which can also be shared across named-instances.  Upcoming.
2017-09-27 18:47:42 -04:00
Behdad Esfahbod 261464e0e2 Simplify name-table platform mathcing logic
There's no "all other platforms", there was just ISO left.
Hardcode it in.
2017-09-27 18:37:00 -04:00
Behdad Esfahbod 55d04e25d6 Don't convert nameds to UTF-8 unless we are going to use them 2017-09-27 18:37:00 -04:00
Behdad Esfahbod f99278112d Whitespace 2017-09-27 18:37:00 -04:00
Behdad Esfahbod 554041d596 Fix whitespace-trimming loop and empty strings... 2017-09-27 18:37:00 -04:00
Behdad Esfahbod a74109a114 Move whitespace-trimming code to apply to all name-table strings
If it's good, it's good for everything!
2017-09-27 18:37:00 -04:00
Behdad Esfahbod 869dfe0bdc [varfonts] Reuse charset for named instances
This didn't give me the speedup I was hoping for, though I do get around 15% for VotoSerifGX.
2017-09-27 18:37:00 -04:00
Behdad Esfahbod bf4d440e7f Separate charset and spacing code
For variable-font named-instances we want to reuse the same charset and redo the spacing.
2017-09-27 12:37:23 -04:00
Behdad Esfahbod 15b5016ccd [varfonts] Don't reopen face for each named instance
Makes scanning of Voto (over 500 named instaces) twice faster.

Next, avoid charset / lang recalculation for each of those.
2017-09-20 19:39:59 -07:00
Behdad Esfahbod 2d0063948a [varfonts] Do not set postscriptname for varfont pattern 2017-09-20 16:36:03 -07:00
Behdad Esfahbod be735d6a68 [varfonts] Skip named-instance that is equivalent to base font 2017-09-20 16:36:03 -07:00
Behdad Esfahbod 8183194ae3 [varfonts] Don't set style for variable-font pattern 2017-09-20 13:21:52 -07:00
Behdad Esfahbod 131219f9e5 [varfonts] Comment 2017-09-20 13:21:52 -07:00
Behdad Esfahbod e85afde2d6 [varfonts] Minor 2017-09-20 13:21:52 -07:00
Behdad Esfahbod 5ee9c38df7 Revert "[varfonts] Use fvar data even if there's no variation in it"
This reverts commit 57764e3a36449da25bb829c34cb08c54e9e5de90.

For regular font pattern we don't look into fvar, so it doesn't make sense to
get non-variation from it either.
2017-09-20 13:21:52 -07:00
Behdad Esfahbod 7e1b84100d Minor 2017-09-20 13:21:52 -07:00
Behdad Esfahbod 01f14de417 [varfonts] Use fvar data even if there's no variation in it 2017-09-20 13:21:52 -07:00
Behdad Esfahbod 38a6d6fba0 Fix possible div-by-zero 2017-09-20 13:21:52 -07:00
Behdad Esfahbod c2fcde498a [varfonts] Map from OpenType to Fontconfig weight values
Oops.
2017-09-20 13:13:35 -07:00
Behdad Esfahbod 6a13a21e40 [varfonts] Fetch optical-size for named instances 2017-09-20 13:13:35 -07:00
Behdad Esfahbod 0f9bbbcf8f [varfonts] Query variable font in FcFreeTypeQueryAll()
Returns varfont pattern at the end.
2017-09-20 13:13:35 -07:00
Behdad Esfahbod 585f08715b Fix instance-num handling in collections
Ouch!
2017-09-20 13:13:35 -07:00
Behdad Esfahbod 83b4161108 [varfonts] Query varfonts if id >> 16 == 0x8000
If "instance-number" part of face id is set to 0x8000, return a pattern
for variable font as a whole.  This might have a range for weight, width,
and size.

If no variation is found, NULL is returned.

Not hooked up to FcQueryFaceAll() yet.  For now, can be triggered using
fc-query -i 0x80000000
2017-09-20 13:13:35 -07:00
Behdad Esfahbod a4bd5b7c7a [varfonts] Change id argument in FcFreeTypeQuery* to unsigned int
Going to use the top bit to query varfonts.
2017-09-20 13:13:35 -07:00
Behdad Esfahbod 819d3a5541 [varfonts] Add FC_VARIABLE
For now, we mark all fonts as non-variable.
2017-09-20 13:13:35 -07:00
Behdad Esfahbod de00bdb01f Indent 2017-09-20 13:13:35 -07:00
Behdad Esfahbod 66f082451d Check instance-index before accessing array
Ouch!
2017-09-20 13:13:35 -07:00
Behdad Esfahbod 6eb7e5ae81 Accept NULL in for spacing in FcFreeTypeCharSetAndSpacing() 2017-09-20 13:13:35 -07:00
Behdad Esfahbod 27a6a299e0 Add FcFreeTypeQueryAll()
Like FcFreeTypeQuery(), but adds patterns for all fonts found, including named
instances of variable fonts.  If id is -1, then all collection faces are queried.
Returns number of fonts added.

This merges the same face loop that was in fc-query. and fcdir.c.

Needs documentation update.
2017-09-12 17:17:05 -04:00
Behdad Esfahbod a8bbbfb601 Minor 2017-09-12 17:02:27 -04:00
Behdad Esfahbod 60b2cf8e4c Call FT_Get_Advance() only as long as we need to determine font width type 2017-09-12 17:02:27 -04:00
Behdad Esfahbod ad0a82b8f8 Inline FcFreeTypeCheckGlyph() 2017-09-12 17:02:27 -04:00
Behdad Esfahbod 1af7518583 Simplify advance-width calculations 2017-09-12 17:02:27 -04:00
Behdad Esfahbod 6f98286e15 Use inline functions instead of macros for a couple of things 2017-09-12 17:02:27 -04:00
Behdad Esfahbod 15eba74ffe Use multiplication instead of division 2017-09-12 17:02:27 -04:00