Hello everyone! I am the author of a piece of software called osgPango, which glues Pango and OpenSceneGraph together in order to use Pango''s layout engine in OpenGL. This software is used in both Linux and Windows (about half and half, really), so some users are using the Freetype+Cairo backend to rasterize, and others are using the Win32+Cairo backend. However, I''m not entirely sure this information is relevant, though I include it anyways. :) My question is: using the Fontconfig API, is it possible to--in a generic way--find out what font file (or more likely "files", the Fontconfig API will probably want to work with sets of data)--corresponds to a particular Fontconfig string? For example, we love the expressively Pango provides when it allows us to use fonts in the form of: "Arial Bold 20px" However, a separate API requires the exact font "file" on disk instead, and so we''d like to continue using this expressive Pango/Fontconfig syntax in order to provide the REAL file to the older software. I''ll continue browsing through the source for now, but if anyone has any advice to get me started, I''d really appreciate it!
Hi Jeremy, On 03/02/11 14:34, Jeremy Moles wrote:> > My question is: using the Fontconfig API, is it possible to--in a > generic way--find out what font file (or more likely "files", the > Fontconfig API will probably want to work with sets of > data)--corresponds to a particular Fontconfig string?That''s what FcFontMatch() does.> For example, we love the expressively Pango provides when it allows us > to use fonts in the form of: > > "Arial Bold 20px" > > However, a separate API requires the exact font "file" on disk instead, > and so we''d like to continue using this expressive Pango/Fontconfig > syntax in order to provide the REAL file to the older software.Unfortunately Pango currently does not provide the function pango_fc_font_description_to_pattern(). It will in some future version. You can build a PangoFontDescription, but you need to convert that to a Fontconfig pattern yourself (or copy the code from pango). Hope that helps, behdad> I''ll continue browsing through the source for now, but if anyone has any > advice to get me started, I''d really appreciate it! > > _______________________________________________ > Fontconfig mailing list > Fontconfig at lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/fontconfig >
On Wed, 2011-03-02 at 16:29 -0500, Behdad Esfahbod wrote:> Hi Jeremy, > > On 03/02/11 14:34, Jeremy Moles wrote: > > > > My question is: using the Fontconfig API, is it possible to--in a > > generic way--find out what font file (or more likely "files", the > > Fontconfig API will probably want to work with sets of > > data)--corresponds to a particular Fontconfig string? > > That''s what FcFontMatch() does. > > > > For example, we love the expressively Pango provides when it allows us > > to use fonts in the form of: > > > > "Arial Bold 20px" > > > > However, a separate API requires the exact font "file" on disk instead, > > and so we''d like to continue using this expressive Pango/Fontconfig > > syntax in order to provide the REAL file to the older software. > > Unfortunately Pango currently does not provide the function > pango_fc_font_description_to_pattern(). It will in some future version. > You can build a PangoFontDescription, but you need to convert that to a > Fontconfig pattern yourself (or copy the code from pango).============================================= FcPattern* pat = FcNameParse("arial"); FcFontSet* fs = FcFontList(0, pat, 0); for(i = 0; i < fs->nfont; i++) { if(FcPatternGetString(fs->fonts[i], FC_FILE, 0, &path) == FcResultMatch) } ============================================= The code above is essentially what I''m using to get the font file paths. It works for sure on Linux, haven''t tested it (yet) in Windows. Without a pango_fc_font_description_to_pattern() function, I''d like to go the route (temporarily) of copying this code from Pango. Can you give me any hints as to whereabouts this process is performed? You mentioned also a kind of "hackish" way of getting the information out of Pango (loading the font into the PangoFontMap in the context isn''t a problem), but I wasn''t able to piece together the series of calls in order to achieve this... (we can use whatever version of Pango is necessary) Thanks!> Hope that helps, > > behdad > > > > I''ll continue browsing through the source for now, but if anyone has any > > advice to get me started, I''d really appreciate it! > > > > _______________________________________________ > > Fontconfig mailing list > > Fontconfig at lists.freedesktop.org > > http://lists.freedesktop.org/mailman/listinfo/fontconfig > > >
On 03/03/11 15:09, Jeremy Moles wrote:> Without a pango_fc_font_description_to_pattern() function, I''d like to > go the route (temporarily) of copying this code from Pango. Can you give > me any hints as to whereabouts this process is performed?grep for pango_fc_make_pattern().> You mentioned also a kind of "hackish" way of getting the information > out of Pango (loading the font into the PangoFontMap in the context > isn''t a problem), but I wasn''t able to piece together the series of > calls in order to achieve this... (we can use whatever version of Pango > is necessary)I checked in and what I had in mind wouldn''t work. behdad