Commit graph

15 commits

Author SHA1 Message Date
Riccardo Mottola
895fdbcf39 reshuffle code, compact name calculation and return NSString and not NSMutableString 2023-11-21 23:40:49 +01:00
Riccardo Mottola
4bb1370086 fix compiler warning with some code cleanup 2023-11-21 23:26:40 +01:00
fredkiefer
e929b48e0b * Headers/fontconfig/FCFaceInfo.h: Add instancevariable _patternIsResolved.
* Source/fontconfig/FCFaceInfo.m (-matchedPattern): Cache the
resolved pattern and return this. The method characterSet now uses
this cached pattern.
Patch by Josh Freeman <gnustep_lists@twilightedge.com>
2020-06-10 18:24:51 +02:00
fredkiefer
36283735ab * Source/cairo/CairoFontInfo.m,
* Source/fontconfig/FCFontEnumerator.m: Small cleanup of last pull
request.
2019-05-19 22:56:48 +02:00
Jeff Teunissen
d519e8542b Stub code for SFNT access
Some simple code for getting access to the main SFNT tables used for
drawing the right glyphs in the right ways. It's hidden with an "#if 0" for
future use.
2019-03-26 03:58:18 -04:00
Jeff Teunissen
1b23bfe1fd Better sorting of fonts
Rather than sorting fonts by the integer value of "traits", let's sort by
the traits we are looking for specifically. Again, like many other things,
totally correct handling of this stuff will have to wait for a good method
of inspecting and correctly processing SFNT tables.
2019-03-26 03:58:18 -04:00
Jeff Teunissen
d0a9f5b943 Handle "strange" font weights
Fontconfig's font weights are almost but not entirely defined by the
constants found in its source code. Things like FC_WEIGHT_LIGHT are not,
as we had presumed, a list of definitive weights. As such, it seems there
are a goodly number of fonts that have weights not appearing in the list.

For example, say there's a font that is heavier than Medium (weight 100 for
fontconfig, and 6 for us) but not as heavy as Demibold (FC: 180, GS: 7),
then it might tell Fontconfig it has a weight of 130.

When this happens, we _could_ assign its NSWeight to be 6 or 7, but it's
possible that there will be another face in that font that ALSO fits there,
which might throw off the sorting. Instead, what I suggest is to do what
I have done...assign an NSWeight with a weight class that represents the
numeric distance _between_ the two defined values.

So the GS weight for this font face becomes something like:

NSWeight = 6 + ((FCWeight - Medium) * (1.0 / (Demibold - Medium)))

or, in numeric terms, 6 + 0.375

In service of this change, I have switched the actual Weight value within
the font dictionary from int to float. This is an attempt to translate this
situation into a sortable form we can work with, compressing an approximate
range of possible FC font weights into our 0-15 system.

There may well be a better way to go about this, such as figuring out where
fontconfig gets this info in the first place and converting from the source
directly, but accessing the SFNT tables (which will almost certainly be
required) is something for a later day.
2019-03-26 03:58:18 -04:00
Jeff Teunissen
5737e249f5 fix 'italic' detection
Don't check for italic, check for slant greater than roman. That way, we
catch oblique (which is more slanted than 'italic') too.
2019-03-26 03:58:18 -04:00
Jeff Teunissen
8df5bb1064 More postscriptname support
Support reading the PS name from a pattern.
2019-03-26 03:58:18 -04:00
Jeff Teunissen
325c927814 fontconfig: use fullname for displayName (most of the time)
Can't use fullname ALL the time, because some (mostly Adobe) fonts store
a duplicate of their PostScript name in the fullname field (and for that
case, we can just do what we already did), but it works well for just about
everything else.
2019-03-26 03:58:18 -04:00
Jeff Teunissen
ecba94053d sort font faces
GNUstep's font architecture makes it extremely difficult and annoying to
have a properly sorted font panel (or even one that makes any sense at all).

This might not be the best place to implement font sorting, but I'll be
damned if I can find a better one. The font enumerator knows where to look,
and has all the information needed to do it.

So, once we've enumerated all the fonts, sort them with a function that's
only slightly more clever than alphabetizing them. We sort by these
criteria, in order of importance:

1. font weight
2. traits (numeric ordering)
3. style name, with special cases so "Regular"/"Normal"/"Roman" sort
   earlier than other stuff (caption, titling, etc.)

This sorting function seems to work about as well as can be expected,
producing the obvious "Regular"/"Italic"/"Bold"/"Bold Italic" for
undemanding families, while getting more advanced ones (like, say, the 168
font faces of Kepler Std) pretty close.
2019-03-26 03:58:18 -04:00
Jeff Teunissen
233e44dc4c Support fontconfig 2.11's new 'postscriptname' attribute.
GNUstep has been bending over backwards to deal with fontconfig's baffling
lack of support for PostScript-style font names, just as it bent over
backwards to deal with XLFD's lack of same. Luckily, the fontconfig guys
have done us (and let's be honest, ghostscript and every pdf reader in
creation) a solid, and now that it's here it would be downright criminal
to not use it.

Implement it. :)
2019-03-26 03:58:18 -04:00
Jeff Teunissen
016f5eda25 Cairo: Reduce the hilarity of the font panel
Use many more weights and widths when generating the (still extremely
stupid) synthetic PostScript font names.
2019-03-26 03:58:18 -04:00
Ivan Vučica
3f417045cc Opal backend: Progress on implementing fonts based on Opal's Core Graphics and fontconfig/ classes in gnustep-back.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@37082 72102866-910b-0410-8b05-ffd578937521
2013-09-16 22:46:45 +00:00
Ivan Vučica
61cf75b2fc In preparation for reusing this code in the Opal backend, moved fontconfig code to a dedicated set of classes that are now superclasses of Cairo backend's font classes.
Fixed a bug in CairoGState: a NSDebugMLLog() had this obvious mistake in its format (as was printed out by the compiler): @"%self"



git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@37066 72102866-910b-0410-8b05-ffd578937521
2013-09-10 21:07:03 +00:00